14 #include "libmesh/edge_edge2.h" 15 #include "libmesh/unstructured_mesh.h" 19 SCMTriSubChannelMeshGenerator,
23 TriSubChannelMeshGenerator,
27 SCMTriPinMeshGenerator,
40 "Creates a mesh of 1D subchannels and 1D pins in a triangular lattice arrangement");
41 params.
addRequiredParam<
unsigned int>(
"n_cells",
"The number of cells in the axial direction");
44 params.
addParam<
Real>(
"unheated_length_entry", 0.0,
"Unheated length at entry [m]");
46 params.
addParam<
Real>(
"unheated_length_exit", 0.0,
"Unheated length at exit [m]");
49 "Number of fuel-pin rings per assembly, counting the center pin as the first ring [-]");
51 "Flat to flat distance for the hexagonal assembly [m]");
55 "spacer_z", {},
"Axial location of spacers/vanes/mixing vanes [m]");
57 "spacer_k", {},
"K-loss coefficient of spacers/vanes/mixing vanes [-]");
58 params.
addParam<
Real>(
"Kij", 0.5,
"Lateral form loss coefficient [-]");
59 params.
addParam<std::vector<Real>>(
"z_blockage",
60 std::vector<Real>({0.0, 0.0}),
61 "axial location of blockage (inlet, outlet) [m]");
62 params.
addParam<std::vector<unsigned int>>(
"index_blockage",
63 std::vector<unsigned int>({0}),
64 "index of subchannels affected by blockage");
67 std::vector<Real>({1.0}),
68 "Area reduction of subchannels affected by blockage (number to muliply the area)");
69 params.
addParam<std::vector<Real>>(
"k_blockage",
70 std::vector<Real>({0.0}),
71 "Form loss coefficient of subchannels affected by blockage");
72 params.
addParam<
unsigned int>(
"block_id", 0,
"Subchannel block id");
73 params.
deprecateParam(
"block_id",
"subchannel_block_id",
"07/01/2027");
74 params.
addParam<
unsigned int>(
"pin_block_id", 1,
"Fuel Pin block id");
80 _unheated_length_entry(getParam<
Real>(
"unheated_length_entry")),
81 _heated_length(getParam<
Real>(
"heated_length")),
82 _unheated_length_exit(getParam<
Real>(
"unheated_length_exit")),
83 _subchannel_block_id(getParam<unsigned
int>(
"subchannel_block_id")),
84 _pin_block_id(getParam<unsigned
int>(
"pin_block_id")),
85 _spacer_z(getParam<
std::vector<
Real>>(
"spacer_z")),
86 _spacer_k(getParam<
std::vector<
Real>>(
"spacer_k")),
87 _z_blockage(getParam<
std::vector<
Real>>(
"z_blockage")),
88 _index_blockage(getParam<
std::vector<unsigned
int>>(
"index_blockage")),
89 _reduction_blockage(getParam<
std::vector<
Real>>(
"reduction_blockage")),
90 _k_blockage(getParam<
std::vector<
Real>>(
"k_blockage")),
91 _pitch(getParam<
Real>(
"pitch")),
92 _kij(getParam<
Real>(
"Kij")),
93 _pin_diameter(getParam<
Real>(
"pin_diameter")),
94 _n_cells(getParam<unsigned
int>(
"n_cells")),
95 _n_rings(getParam<unsigned
int>(
"nrings")),
97 _flat_to_flat(getParam<
Real>(
"flat_to_flat")),
98 _dwire(getParam<
Real>(
"dwire")),
99 _hwire(getParam<
Real>(
"hwire")),
100 _duct_to_pin_gap(0.5 *
101 (_flat_to_flat - (_n_rings - 1) * _pitch *
std::
sqrt(3.0) - _pin_diameter)),
109 "'nrings' must be at least 2. In this mesh generator, the center pin counts as " 110 "the first ring, so a 7-pin bundle uses nrings = 2.");
113 paramError(
"n_cells",
"The number of axial cells must be greater than zero");
115 if (total_length <= 0.0)
116 mooseError(
"Total bundle length must be greater than zero");
119 mooseError(
"Size of vector spacer_z should be equal to size of vector spacer_k");
122 if (spacer_z < 0.0 || spacer_z > total_length)
123 paramError(
"spacer_z",
"Location of spacers should be between zero and total bundle length");
126 paramError(
"z_blockage",
"Size of vector z_blockage must be 2");
129 paramError(
"z_blockage",
"z_blockage inlet location must not exceed outlet location");
133 "The area reduction of the blocked subchannels cannot be more than 1");
138 mooseError(
"Size of vectors: index_blockage, reduction_blockage, k_blockage, must be equal " 145 Real L = total_length;
148 std::vector<int> spacer_cell;
150 spacer_cell.emplace_back(std::round(elem *
_n_cells / L));
153 std::vector<Real> kgrid;
157 for (
unsigned int index = 0; index < spacer_cell.size(); index++)
158 kgrid[spacer_cell[index]] +=
_spacer_k[index];
176 Real avg_coor_x = 0.0;
178 Real avg_coor_y = 0.0;
184 unsigned int kgap = 0;
186 unsigned int icorner = 0;
188 const Real positive_flow = 1.0;
190 const Real negative_flow = -1.0;
192 std::vector<std::pair<unsigned int, unsigned int>> gap_fill;
199 for (
unsigned int i = 1; i <
_n_rings; i++)
200 for (
unsigned int j = 0;
j < i * 6;
j++)
204 unsigned int chancount = 0.0;
213 "The index of the blocked subchannel cannot be more than the max index of the " 218 mooseError(
"Size of vectors: index_blockage, reduction_blockage, k_blockage, cannot be more " 219 "than the total number of subchannels");
228 for (
unsigned int i = 0; i <
_n_cells + 1; i++)
232 unsigned int index(0);
262 for (
unsigned int j = 0;
j < 3;
j++)
269 for (
unsigned int iz = 0; iz <
_n_cells + 1; iz++)
274 for (
unsigned int i = 0; i <
_npins; i++)
282 for (
unsigned int i = 1; i <
_n_rings; i++)
422 for (
unsigned int loc_rod = 0; loc_rod <
_npins; loc_rod++)
426 bool rod_in_sc =
false;
535 gap_fill[
j].first = 1;
540 gap_fill[
j].second = 1;
554 gap_fill[
j].first = 1;
559 gap_fill[
j].second = 1;
624 for (
unsigned int iz = 0; iz <
_n_cells + 1; iz++)
626 for (
unsigned int i_gap = 0; i_gap <
_n_gaps; i_gap++)
643 for (
unsigned int k = 0;
k < 3;
k++)
674 for (
unsigned int k = 0;
k < 2;
k++)
755 a2 = std::sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)) + a1;
767 a2 = std::sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0)) + a1;
794 const unsigned int node_sub = mesh_base.n_nodes();
795 const unsigned int elem_sub = mesh_base.n_elem();
800 unsigned int node_id = node_sub;
801 for (
unsigned int i = 0; i <
_npins; i++)
804 for (
unsigned int iz = 0; iz <
_n_cells + 1; iz++)
810 unsigned int elem_id = elem_sub;
811 for (
unsigned int i = 0; i <
_npins; i++)
812 for (
unsigned int iz = 0; iz <
_n_cells; iz++)
814 Elem * elem = mesh_base.add_elem(std::make_unique<Edge2>());
816 elem->set_id(elem_id++);
817 const int indx1 = (
_n_cells + 1) * i + iz + node_sub;
818 const int indx2 = (
_n_cells + 1) * i + (iz + 1) + node_sub;
819 elem->set_node(0, mesh_base.node_ptr(indx1));
820 elem->set_node(1, mesh_base.node_ptr(indx2));
826 std::unique_ptr<MeshBase>
831 BoundaryInfo & boundary_info = mesh_base->get_boundary_info();
832 mesh_base->set_spatial_dimension(3);
840 unsigned int node_id = 0;
844 for (
unsigned int iz = 0; iz <
_n_cells + 1; iz++)
846 _nodes[i].push_back(mesh_base->add_point(
853 unsigned int elem_id = 0;
856 for (
unsigned int iz = 0; iz <
_n_cells; iz++)
858 Elem * elem = mesh_base->add_elem(std::make_unique<Edge2>());
860 elem->set_id(elem_id++);
861 const int indx1 = (
_n_cells + 1) * i + iz;
862 const int indx2 = (
_n_cells + 1) * i + (iz + 1);
863 elem->set_node(0, mesh_base->node_ptr(indx1));
864 elem->set_node(1, mesh_base->node_ptr(indx2));
867 boundary_info.add_side(elem, 0, 0);
869 boundary_info.add_side(elem, 1, 1);
872 boundary_info.sideset_name(0) =
"inlet";
873 boundary_info.sideset_name(1) =
"outlet";
874 boundary_info.nodeset_name(0) =
"inlet";
875 boundary_info.nodeset_name(1) =
"outlet";
881 mesh_base->prepare_for_use();
895 sch_mesh._kij =
_kij;
923 sch_mesh._pin_mesh_exist = (
_npins > 0);
924 sch_mesh.computeAssemblyHydraulicParameters();
SCMTriAssemblyMeshGenerator(const InputParameters ¶meters)
const Real _flat_to_flat
the distance between flat surfaces of the duct facing each other
const std::vector< Real > & _spacer_k
form loss coefficient of the spacers
const unsigned int _subchannel_block_id
subchannel block index
void paramError(const std::string ¶m, Args... args) const
std::vector< std::vector< unsigned int > > _chan_to_gap_map
stores the gaps that forms each subchannel
const std::vector< Real > & _spacer_z
axial location of the spacers
std::vector< std::pair< unsigned int, unsigned int > > _chan_pairs_sf
sweeping flow model channel pairs to specify directional edge flow
std::vector< std::vector< Real > > _pins_in_rings
fuel pins that are belonging to each ring
const Real _unheated_length_entry
unheated length of the fuel Pin at the entry of the assembly
static void pinPositions(std::vector< Point > &positions, unsigned int nrings, Real pitch, Point center)
Calculates and stores the pin positions/centers for a hexagonal assembly containing the given number ...
const unsigned int _n_rings
number of rings of fuel pins
std::vector< std::vector< unsigned int > > _chan_to_pin_map
stores the fuel pins belonging to each subchannel
Real _unheated_length_entry
unheated length of the fuel Pin at the entry of the assembly
std::vector< EChannelType > _subch_type
subchannel type
std::vector< std::vector< unsigned int > > _pin_to_chan_map
stores the map from pins to channels
void buildPinMesh(MeshBase &mesh_base)
Build the 1D pin elements and append them to the subchannel mesh.
const std::vector< Real > _z_blockage
axial location of blockage (inlet, outlet) [m]
const Real _hwire
wire lead length
const Real _pitch
Distance between the neighbor fuel pins, pitch.
registerMooseObjectRenamed("SubChannelApp", SCMTriSubChannelMeshGenerator, "06/30/2027 24:00", SCMTriAssemblyMeshGenerator)
const std::vector< unsigned int > _index_blockage
index of subchannels affected by blockage
static void generateZGrid(Real unheated_length_entry, Real heated_length, Real unheated_length_exit, unsigned int n_cells, std::vector< Real > &z_grid)
Generate the spacing in z-direction using heated and unteaded lengths.
const unsigned int _n_cells
number of axial cells
const std::vector< Real > _reduction_blockage
area reduction of subchannels affected by blockage
unsigned int _n_channels
number of subchannels
registerMooseObject("SubChannelApp", SCMTriAssemblyMeshGenerator)
std::vector< std::vector< Real > > _sign_id_crossflow_map
Defines the global cross-flow direction -1 or 1 for each subchannel and for all gaps that are belongi...
std::vector< EChannelType > _gap_type
gap type
const Real _duct_to_pin_gap
the gap thickness between the duct and peripheral fuel pins
static InputParameters validParams()
std::unique_ptr< MeshBase > generate() override
Mesh class for triangular, edge and corner subchannels for hexagonal lattice fuel assemblies...
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const unsigned int _pin_block_id
pin block index
const std::vector< Real > _k_blockage
form loss coefficient of subchannels affected by blockage
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< std::vector< Real > > _gij_map
gap size
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
const Real _unheated_length_exit
unheated length of the fuel Pin at the exit of the assembly
std::vector< Real > _z_grid
axial location of nodes
std::vector< std::vector< Node * > > _pin_nodes
pin nodes
void mooseError(Args &&... args) const
const Real _dwire
wire diameter
Mesh generator that builds a mesh of 1D lines representing subchannels and pins in a triangular assem...
const Real _pin_diameter
fuel Pin diameter
std::vector< std::pair< unsigned int, unsigned int > > _gap_to_chan_map
stores the channel pairs for each gap
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
std::vector< std::vector< Node * > > _nodes
nodes
const Real & _kij
Lateral form loss coefficient.
std::unique_ptr< MeshBase > buildMeshBaseObject(unsigned int dim=libMesh::invalid_uint)
std::vector< Point > _pin_position
x,y coordinates of the fuel pins
static InputParameters validParams()
unsigned int _n_gaps
number of gaps
static const std::string k
std::vector< std::vector< Real > > _subchannel_position
x,y coordinates of the subchannel centroids
void ErrorVector unsigned int
std::vector< std::pair< unsigned int, unsigned int > > _gap_pairs_sf
sweeping flow model gap pairs per channel to specify directional edge flow
const Real _heated_length
heated length of the fuel Pin
std::vector< std::pair< unsigned int, unsigned int > > _gap_to_pin_map
stores the fuel pin pairs for each gap each gap
unsigned int _npins
number of fuel pins
std::vector< std::vector< Real > > _k_grid
axial form loss coefficient per computational cell