22 "Solver class for subchannels in a square lattice assembly and bare fuel pins");
39 _console <<
" =========== DEFORMATION RECALCULATION ACTIVATED ============== " << std::endl;
40 Real standard_area, additional_area, wetted_perimeter, displaced_area;
46 for (
unsigned int iz = 0; iz <
_n_cells + 1; iz++)
48 for (
unsigned int i_ch = 0; i_ch <
_n_channels; i_ch++)
54 Real rod_perimeter = 0.0;
58 rod_area += 0.25 * 0.25 * M_PI * (*_Dpin_soln)(pin_node) * (*
_Dpin_soln)(pin_node);
59 rod_perimeter += 0.25 * M_PI * (*_Dpin_soln)(pin_node);
67 additional_area =
pitch * side_gap + side_gap * side_gap;
69 rod_perimeter +
pitch + 2 * side_gap + 2 * (*_displacement_soln)(node) /
sqrt(2);
74 additional_area =
pitch * side_gap;
75 displaced_area =
pitch * (*_displacement_soln)(node);
76 wetted_perimeter = rod_perimeter +
pitch;
82 additional_area = 0.0;
83 wetted_perimeter = rod_perimeter;
87 auto subchannel_area = displaced_area + standard_area + additional_area - rod_area;
90 auto overlapping_pin_area = 0.0;
91 auto overlapping_wetted_perimeter = 0.0;
95 auto pin_1 = gap_pins.first;
96 auto pin_2 = gap_pins.second;
99 auto Diameter1 = (*_Dpin_soln)(pin_node_1);
100 auto Radius1 = Diameter1 / 2.0;
101 auto Diameter2 = (*_Dpin_soln)(pin_node_2);
102 auto Radius2 = Diameter2 / 2.0;
105 if (
pitch < (Radius1 + Radius2))
107 mooseWarning(
" The gap of index : '", i_gap,
" at axial cell ", iz,
" ' is blocked.");
109 (
pitch *
pitch + Radius1 * Radius1 - Radius2 * Radius2) / (2 *
pitch * Radius1);
111 (
pitch *
pitch + Radius2 * Radius2 - Radius1 * Radius1) / (2 *
pitch * Radius2);
112 auto angle1 = 2.0 * acos(cos1);
113 auto angle2 = 2.0 * acos(cos2);
115 overlapping_wetted_perimeter += 0.5 * angle1 * Radius1 + 0.5 * angle2 * Radius2;
117 overlapping_pin_area +=
118 0.5 * Radius1 * Radius1 * acos(cos1) + 0.5 * Radius2 * Radius2 * acos(cos2) -
119 0.25 *
sqrt((-
pitch + Radius1 + Radius2) * (
pitch + Radius1 - Radius2) *
120 (
pitch - Radius1 + Radius2) * (
pitch + Radius1 + Radius2));
123 subchannel_area += overlapping_pin_area;
124 wetted_perimeter += -overlapping_wetted_perimeter;
128 for (
const auto & i_blockage : index_blockage)
130 if (i_ch == i_blockage && (
Z >= z_blockage.front() &&
Z <= z_blockage.back()))
132 subchannel_area *= reduction_blockage[index];
142 for (
unsigned int iz = 0; iz <
_n_cells + 1; iz++)
144 for (
unsigned int i_gap = 0; i_gap <
_n_gaps; i_gap++)
147 auto pin_1 = gap_pins.first;
148 auto pin_2 = gap_pins.second;
153 auto displacement = 0.0;
161 displacement += (*_displacement_soln)(node);
165 displacement = displacement / counter;
167 iz, i_gap, (
pitch - (*
_Dpin_soln)(pin_node_1)) / 2.0 + side_gap + displacement);
181 for (
unsigned int iz = 1; iz <
_n_cells + 1; iz++)
183 for (
unsigned int i_ch = 0; i_ch <
_n_channels; i_ch++)
193 _aux->solution().close();
207 if (MooseUtils::absoluteFuzzyGreaterThan(z2, unheated_length_entry) &&
208 MooseUtils::absoluteFuzzyLessThan(z1, unheated_length_entry + heated_length))
212 auto heat_rate_in = 0.0;
213 auto heat_rate_out = 0.0;
218 heat_rate_out += 0.25 * (*_q_prime_soln)(node_out);
219 heat_rate_in += 0.25 * (*_q_prime_soln)(node_in);
221 return (heat_rate_in + heat_rate_out) * dz / 2.0;
239 mooseError(
"Channel is not a perimetric subchannel ");
245 unsigned int last_node = (iblock + 1) *
_block_size;
246 unsigned int first_node = iblock *
_block_size + 1;
249 for (
unsigned int i_ch = 0; i_ch <
_n_channels; i_ch++)
256 name(),
" : Calculation of negative Enthalpy h_out = : ", h_out,
" Axial Level= : ", 0);
264 for (
unsigned int iz = first_node; iz < last_node + 1; iz++)
267 for (
unsigned int i_ch = 0; i_ch <
_n_channels; i_ch++)
271 auto mdot_in = (*_mdot_soln)(node_in);
272 auto h_in = (*_h_soln)(node_in);
273 auto volume = dz * (*_S_flow_soln)(node_in);
274 auto mdot_out = (*_mdot_soln)(node_out);
277 Real sumWijPrimeDhij = 0.0;
280 unsigned int counter = 0;
284 unsigned int ii_ch = chans.first;
286 unsigned int jj_ch = chans.second;
291 if (
_Wij(i_gap, iz) > 0.0)
292 h_star = (*_h_soln)(node_in_i);
293 else if (
_Wij(i_gap, iz) < 0.0)
294 h_star = (*_h_soln)(node_in_j);
297 sumWijPrimeDhij +=
_WijPrime(i_gap, iz) * (2 * (*_h_soln)(node_in) -
301 h_out = (mdot_in * h_in - sumWijh - sumWijPrimeDhij + added_enthalpy +
307 " : Calculation of negative Enthalpy h_out = : ",
327 for (
unsigned int iz = first_node; iz < last_node + 1; iz++)
330 auto iz_ind = iz - first_node;
331 for (
unsigned int i_ch = 0; i_ch <
_n_channels; i_ch++)
335 auto S_in = (*_S_flow_soln)(node_in);
336 auto S_out = (*_S_flow_soln)(node_out);
338 auto volume = dz * S_interp;
344 if (iz == first_node)
346 PetscScalar value_vec_tt =
355 PetscInt col_tt = i_ch +
_n_channels * (iz_ind - 1);
357 LibmeshPetscCall(MatSetValues(
365 LibmeshPetscCall(MatSetValues(
369 PetscScalar rho_old_interp =
371 PetscScalar h_old_interp =
373 PetscScalar value_vec_tt =
_TR * rho_old_interp * h_old_interp *
volume /
_dt;
379 if (iz == first_node)
381 PetscScalar value_vec_at = (*_mdot_soln)(node_in) * (*
_h_soln)(node_in);
383 LibmeshPetscCall(VecSetValues(
389 PetscInt col_at = i_ch +
_n_channels * (iz_ind - 1);
390 PetscScalar value_at = -1.0 * (*_mdot_soln)(node_in);
391 LibmeshPetscCall(MatSetValues(
398 PetscScalar value_at = (*_mdot_soln)(node_out);
399 LibmeshPetscCall(MatSetValues(
403 unsigned int counter = 0;
404 unsigned int cross_index = iz;
408 unsigned int ii_ch = chans.first;
409 unsigned int jj_ch = chans.second;
414 if (
_Wij(i_gap, cross_index) > 0.0)
416 if (iz == first_node)
418 h_star = (*_h_soln)(node_in_i);
419 PetscScalar value_vec_ct = -1.0 *
alpha *
421 _Wij(i_gap, cross_index) * h_star;
423 LibmeshPetscCall(VecSetValues(
429 _Wij(i_gap, cross_index);
431 PetscInt col_ct = ii_ch +
_n_channels * (iz_ind - 1);
432 LibmeshPetscCall(MatSetValues(
435 PetscScalar value_ct = (1.0 -
alpha) *
437 _Wij(i_gap, cross_index);
440 LibmeshPetscCall(MatSetValues(
443 else if (
_Wij(i_gap, cross_index) < 0.0)
445 if (iz == first_node)
447 h_star = (*_h_soln)(node_in_j);
448 PetscScalar value_vec_ct = -1.0 *
alpha *
450 _Wij(i_gap, cross_index) * h_star;
452 LibmeshPetscCall(VecSetValues(
458 _Wij(i_gap, cross_index);
460 PetscInt col_ct = jj_ch +
_n_channels * (iz_ind - 1);
461 LibmeshPetscCall(MatSetValues(
464 PetscScalar value_ct = (1.0 -
alpha) *
466 _Wij(i_gap, cross_index);
469 LibmeshPetscCall(MatSetValues(
474 if (iz == first_node)
476 PetscScalar value_vec_ct =
478 value_vec_ct +=
alpha * (*_h_soln)(node_in_j)*
_WijPrime(i_gap, cross_index);
479 value_vec_ct +=
alpha * (*_h_soln)(node_in_i)*
_WijPrime(i_gap, cross_index);
486 PetscScalar value_center_ct = 2.0 *
alpha *
_WijPrime(i_gap, cross_index);
488 PetscInt col_ct = i_ch +
_n_channels * (iz_ind - 1);
489 LibmeshPetscCall(MatSetValues(
492 PetscScalar value_left_ct = -1.0 *
alpha *
_WijPrime(i_gap, cross_index);
495 LibmeshPetscCall(MatSetValues(
498 PetscScalar value_right_ct = -1.0 *
alpha *
_WijPrime(i_gap, cross_index);
501 LibmeshPetscCall(MatSetValues(
504 PetscScalar value_center_ct = 2.0 * (1.0 -
alpha) *
_WijPrime(i_gap, cross_index);
507 LibmeshPetscCall(MatSetValues(
510 PetscScalar value_left_ct = -1.0 * (1.0 -
alpha) *
_WijPrime(i_gap, cross_index);
513 LibmeshPetscCall(MatSetValues(
516 PetscScalar value_right_ct = -1.0 * (1.0 -
alpha) *
_WijPrime(i_gap, cross_index);
519 LibmeshPetscCall(MatSetValues(
538 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
539 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
541 #if !PETSC_VERSION_LESS_THAN(3, 15, 0) 543 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
544 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
547 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
548 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
554 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
555 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
558 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
559 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
563 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
564 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
566 _console <<
"Block: " << iblock <<
" - Enthalpy conservation matrix assembled" << std::endl;
PetscErrorCode solveAndPopulateEnthalpy(Mat A, Vec rhs, unsigned int first_node, unsigned int last_node, const char *ksp_prefix)
Solve a linear system (A * x = rhs) with a simple PCJACOBI KSP and populate the enthalpy solution int...
const bool _pin_mesh_exist
Flag that informs if there is a pin mesh or not.
EChannelType getSubchannelType(unsigned int index) const override
Return the type of the subchannel for given subchannel index.
std::unique_ptr< SolutionHandle > _T_soln
std::unique_ptr< SolutionHandle > _h_soln
const std::vector< unsigned int > & getPinChannels(unsigned int i_pin) const override
Return a vector of channel indices for a given Pin index.
T & getMesh(MooseMesh &mesh)
function to cast mesh
Real _TR
Flag that activates or deactivates the transient parts of the equations we solve by multiplication...
const PostprocessorValue & _P_out
Outlet pressure postprocessor value.
static InputParameters validParams()
Node * getChannelNode(unsigned int i_chan, unsigned int iz) const override
Get the subchannel mesh node for a given channel index and elevation index.
std::unique_ptr< SolutionHandle > _S_flow_soln
Vec _hc_time_derivative_rhs
const Real & getSideGap() const
Returns the side gap, not to be confused with the gap between pins, this refers to the gap next to th...
virtual void computeh(int iblock) override
Computes Enthalpy per channel for block iblock.
void setGapWidth(unsigned int axial_index, unsigned int gap_index, Real gap_width)
Set the gap width for a given axial cell and gap index.
static InputParameters validParams()
virtual Real computeAddedHeatPin(unsigned int i_ch, unsigned int iz) const override
Pure virtual: daughters provide different implementations.
const std::vector< unsigned int > & getChannelPins(unsigned int i_chan) const override
Return a vector of pin indices for a given channel index.
Creates the mesh of subchannels in a quadrilateral lattice.
QuadSubChannelMesh & _subchannel_mesh
PetscScalar computeInterpolatedValue(PetscScalar topValue, PetscScalar botValue, PetscScalar Peclet=0.0)
Vec _hc_cross_derivative_rhs
virtual Real getSubChannelPeripheralDuctWidth(unsigned int i_ch) const override
Function that computes the width of the duct cell that the peripheral subchannel i_ch sees...
registerMooseObject("SubChannelApp", QuadSubChannel1PhaseProblem)
const std::vector< unsigned int > & getChannelGaps(unsigned int i_chan) const override
Return a vector of gap indices for a given channel index.
std::unique_ptr< SolutionHandle > _rho_soln
Vec _hc_added_heat_rhs
Enthalpy conservation - source and sink.
std::vector< Real > _z_grid
axial location of nodes
const std::string & name() const
virtual const Real & getHeatedLength() const
Return heated length.
static const std::string pitch
PetscScalar computeInterpolationCoefficients(PetscScalar Peclet=0.0)
Functions that computes the interpolation scheme given the Peclet number.
const Real & getPitch() const override
Return the undeformed pitch between 2 subchannels.
std::shared_ptr< AuxiliarySystem > _aux
Mat _hc_cross_derivative_mat
Enthalpy conservation - cross flux derivative.
std::unique_ptr< SolutionHandle > _Dpin_soln
bool _deformation
Flag that activates the effect of deformation (pin/duct) based on the auxvalues for displacement...
virtual const std::vector< Real > & getReductionBlockage() const
Get area reduction of blocked subchannels.
const std::pair< unsigned int, unsigned int > & getGapPins(unsigned int i_gap) const override
Return a pair of pin indices for a given gap index.
Quadrilateral subchannel solver.
Base class for the 1-phase steady-state/transient subchannel solver.
const Real & getCrossflowSign(unsigned int i_chan, unsigned int i_local) const override
Return a sign for the crossflow given a subchannel index and local neighbor index.
std::unique_ptr< SolutionHandle > _mdot_soln
Solutions handles and link to TH tables properties.
Node * getPinNode(unsigned int i_pin, unsigned int iz) const override
Get the pin mesh node for a given pin index and elevation index.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::unique_ptr< SolutionHandle > _displacement_soln
virtual const std::vector< Real > & getZBlockage() const
Get axial location of blockage (in,out) [m].
libMesh::DenseMatrix< Real > & _Wij
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
static const std::string alpha
void detectDeformation()
Detects whether pin diameter or duct displacement fields require geometry recalculation.
Real getGapWidth(unsigned int axial_index, unsigned int gap_index) const override
Return gap width for a given gap index.
Vec _hc_advective_derivative_rhs
void mooseWarning(Args &&... args) const
const bool _verbose_subchannel
Boolean to printout information related to subchannel solve.
void mooseError(Args &&... args) const
const std::pair< unsigned int, unsigned int > & getGapChannels(unsigned int i_gap) const override
Return a pair of subchannel indices for a given gap index.
Mat _hc_advective_derivative_mat
Enthalpy conservation - advective (Eulerian) derivative;.
virtual const std::vector< unsigned int > & getIndexBlockage() const
Get index of blocked subchannels.
const bool _implicit_bool
Flag to define the usage of a implicit or explicit solution.
const ConsoleStream _console
Mat _hc_time_derivative_mat
Enthalpy Enthalpy conservation - time derivative.
libMesh::DenseMatrix< Real > _WijPrime
QuadSubChannel1PhaseProblem(const InputParameters ¶ms)
std::unique_ptr< SolutionHandle > _P_soln
virtual void initializeSolution() override
Function to initialize the solution & geometry fields.
std::unique_ptr< SolutionHandle > _w_perim_soln
virtual const Real & getHeatedLengthEntry() const
Return unheated length at entry.
const SinglePhaseFluidProperties * _fp
Non-owning pointer to fluid properties user object.
Mat _hc_sys_h_mat
System matrices.