327 unsigned int last_node = (iblock + 1) *
_block_size;
328 unsigned int first_node = iblock *
_block_size + 1;
336 for (
unsigned int i_ch = 0; i_ch <
_n_channels; i_ch++)
343 name(),
" : Calculation of negative Enthalpy h_out = : ", h_out,
" Axial Level= : ", 0);
351 for (
unsigned int iz = first_node; iz < last_node + 1; iz++)
354 auto dz = z_grid[iz] - z_grid[iz - 1];
356 Real edge_flux_ave = 0.0;
359 for (
unsigned int i_ch = 0; i_ch <
_n_channels; i_ch++)
365 auto Si = (*_S_flow_soln)(node_in);
366 auto mdot_in = (*_mdot_soln)(node_in);
367 mdot_sum = mdot_sum + mdot_in;
368 si_sum = si_sum + Si;
371 edge_flux_ave = mdot_sum / si_sum;
373 for (
unsigned int i_ch = 0; i_ch <
_n_channels; i_ch++)
377 auto mdot_in = (*_mdot_soln)(node_in);
378 auto h_in = (*_h_soln)(node_in);
379 auto volume = dz * (*_S_flow_soln)(node_in);
380 auto mdot_out = (*_mdot_soln)(node_out);
383 Real sumWijPrimeDhij = 0.0;
384 Real sweep_enthalpy = 0.0;
393 unsigned int counter = 0;
399 unsigned int ii_ch = chans.first;
400 unsigned int jj_ch = chans.second;
407 if (
_Wij(i_gap, iz) > 0.0)
408 h_star = (*
_h_soln)(node_in_i);
409 else if (
_Wij(i_gap, iz) < 0.0)
410 h_star = (*
_h_soln)(node_in_j);
420 (wire_lead_length != 0) && (wire_diameter != 0))
428 if ((ii_ch == sweep_donor) || (jj_ch == sweep_donor))
431 (*_h_soln)(node_sweep_donor);
445 _WijPrime(i_gap, iz) * (2 * h_in - (*_h_soln)(node_in_j) - (*
_h_soln)(node_in_i));
449 Real dist_ij = pitch;
462 dist_ij = pitch / std::sqrt(3);
468 0.66 * (pitch / pin_diameter) *
472 e_cond += 0.5 * (thcon_i + thcon_j) * Sij * shape_factor *
477 e_cond += -0.5 * (thcon_i + thcon_j) * Sij * shape_factor *
487 auto Si = (*_S_flow_soln)(node_in_i);
488 auto dist_ij = z_grid[iz] - z_grid[iz - 1];
490 e_cond += 0.5 * (thcon_i + thcon_j) * Si * ((*
_T_soln)(node_in_j) - (*
_T_soln)(node_in_i)) /
501 auto Si = (*_S_flow_soln)(node_in_i);
502 auto dist_ij = z_grid[iz + 1] - z_grid[iz];
503 e_cond += 0.5 * (thcon_i + thcon_j) * Si *
509 (mdot_in * h_in - sumWijh - sumWijPrimeDhij + added_enthalpy + e_cond + sweep_enthalpy +
515 " : Calculation of negative Enthalpy h_out = : ",
544 for (
unsigned int iz = first_node; iz < last_node + 1; iz++)
549 auto iz_ind = iz - first_node;
551 for (
unsigned int i_ch = 0; i_ch <
_n_channels; i_ch++)
555 auto S_in = (*_S_flow_soln)(node_in);
556 auto S_out = (*_S_flow_soln)(node_out);
558 auto volume = dz * S_interp;
560 PetscScalar Pe = 0.5;
564 auto w_perim_in = (*_w_perim_soln)(node_in);
565 auto w_perim_out = (*_w_perim_soln)(node_out);
576 auto Dh_i = 4.0 * S_interp / w_perim_interp;
577 Pe = mdot_loc * Dh_i * cp / (K * S_interp) * (mdot_loc / std::abs(mdot_loc));
586 PetscScalar value_tt =
_TR * (*_rho_soln)(node_out)*volume /
_dt;
587 LibmeshPetscCall(MatSetValues(
590 PetscScalar value_vec_tt =
598 if (iz == first_node)
601 PetscScalar value_at = (*_mdot_soln)(node_in) * (*
_h_soln)(node_in);
608 PetscInt col_at = i_ch +
_n_channels * (iz_ind - 1);
609 PetscScalar value_at = -1.0 * (*_mdot_soln)(node_in);
610 LibmeshPetscCall(MatSetValues(
616 PetscScalar value_at = (*_mdot_soln)(node_out);
617 LibmeshPetscCall(MatSetValues(
625 auto diff_center = K_center / (cp_center + 1e-15);
627 if (iz == first_node)
637 auto diff_bottom = K_bottom / (cp_bottom + 1e-15);
638 auto diff_top = K_top / (cp_top + 1e-15);
652 PetscScalar value_at = diff_up * S_up / dz_up + diff_down * S_down / dz_down;
653 LibmeshPetscCall(MatSetValues(
657 value_at = 1.0 * diff_down * S_down / dz_down * (*_h_soln)(node_bottom);
663 value_at = -diff_up * S_up / dz_up;
664 LibmeshPetscCall(MatSetValues(
667 else if (iz == last_node)
674 auto diff_bottom = K_bottom / (cp_bottom + 1e-15);
677 auto S_down = 0.5 * ((*_S_flow_soln)(node_center) + (*
_S_flow_soln)(node_bottom));
678 auto diff_down = 0.5 * (diff_center + diff_bottom);
683 PetscScalar value_at = diff_down * S_down / dz_down;
684 LibmeshPetscCall(MatSetValues(
689 value_at = -diff_down * S_down / dz_down;
690 LibmeshPetscCall(MatSetValues(
708 auto diff_bottom = K_bottom / (cp_bottom + 1e-15);
709 auto diff_top = K_top / (cp_top + 1e-15);
723 PetscScalar value_at = diff_up * S_up / dz_up + diff_down * S_down / dz_down;
724 LibmeshPetscCall(MatSetValues(
729 value_at = -diff_down * S_down / dz_down;
730 LibmeshPetscCall(MatSetValues(
735 value_at = -diff_up * S_up / dz_up;
736 LibmeshPetscCall(MatSetValues(
741 unsigned int counter = 0;
742 unsigned int cross_index = iz;
747 unsigned int ii_ch = chans.first;
748 unsigned int jj_ch = chans.second;
753 if (
_Wij(i_gap, cross_index) > 0.0)
755 if (iz == first_node)
757 h_star = (*_h_soln)(node_in_i);
758 PetscScalar value_vec_ct = -1.0 * alpha *
760 _Wij(i_gap, cross_index) * h_star;
762 LibmeshPetscCall(VecSetValues(
768 _Wij(i_gap, cross_index);
770 PetscInt col_ct = ii_ch +
_n_channels * (iz_ind - 1);
771 LibmeshPetscCall(MatSetValues(
774 PetscScalar value_ct = (1.0 - alpha) *
776 _Wij(i_gap, cross_index);
779 LibmeshPetscCall(MatSetValues(
782 else if (
_Wij(i_gap, cross_index) < 0.0)
784 if (iz == first_node)
786 h_star = (*_h_soln)(node_in_j);
787 PetscScalar value_vec_ct = -1.0 * alpha *
789 _Wij(i_gap, cross_index) * h_star;
791 LibmeshPetscCall(VecSetValues(
797 _Wij(i_gap, cross_index);
799 PetscInt col_ct = jj_ch +
_n_channels * (iz_ind - 1);
800 LibmeshPetscCall(MatSetValues(
803 PetscScalar value_ct = (1.0 - alpha) *
805 _Wij(i_gap, cross_index);
808 LibmeshPetscCall(MatSetValues(
813 if (iz == first_node)
815 PetscScalar value_vec_ct =
816 -2.0 * alpha * (*_h_soln)(node_in)*
_WijPrime(i_gap, cross_index);
817 value_vec_ct += alpha * (*_h_soln)(node_in_j)*
_WijPrime(i_gap, cross_index);
818 value_vec_ct += alpha * (*_h_soln)(node_in_i)*
_WijPrime(i_gap, cross_index);
825 PetscScalar value_center_ct = 2.0 * alpha *
_WijPrime(i_gap, cross_index);
827 PetscInt col_ct = i_ch +
_n_channels * (iz_ind - 1);
828 LibmeshPetscCall(MatSetValues(
831 PetscScalar value_left_ct = -1.0 * alpha *
_WijPrime(i_gap, cross_index);
834 LibmeshPetscCall(MatSetValues(
837 PetscScalar value_right_ct = -1.0 * alpha *
_WijPrime(i_gap, cross_index);
840 LibmeshPetscCall(MatSetValues(
843 PetscScalar value_center_ct = 2.0 * (1.0 - alpha) *
_WijPrime(i_gap, cross_index);
846 LibmeshPetscCall(MatSetValues(
849 PetscScalar value_left_ct = -1.0 * (1.0 - alpha) *
_WijPrime(i_gap, cross_index);
852 LibmeshPetscCall(MatSetValues(
855 PetscScalar value_right_ct = -1.0 * (1.0 - alpha) *
_WijPrime(i_gap, cross_index);
858 LibmeshPetscCall(MatSetValues(
864 Real dist_ij = pitch;
877 dist_ij = pitch / std::sqrt(3);
885 auto A_i = K_i / cp_i;
886 auto A_j = K_j / cp_j;
887 auto harm_A = 2.0 * A_i * A_j / (A_i + A_j);
889 0.66 * (pitch / pin_diameter) *
892 auto base_value = harm_A * shape_factor * Sij / dist_ij;
893 auto neg_base_value = -1.0 * base_value;
897 const auto other_ch = (i_ch == ii_ch) ? jj_ch : ii_ch;
900 LibmeshPetscCall(MatSetValues(
904 LibmeshPetscCall(MatSetValues(
911 Real edge_flux_ave = 0.0;
914 for (
unsigned int i_ch = 0; i_ch <
_n_channels; i_ch++)
920 auto Si = (*_S_flow_soln)(node_in);
921 auto mdot_in = (*_mdot_soln)(node_in);
922 mdot_sum = mdot_sum + mdot_in;
923 si_sum = si_sum + Si;
926 edge_flux_ave = mdot_sum / si_sum;
928 PetscScalar sweep_enthalpy = 0.0;
930 (wire_diameter != 0.0) && (wire_lead_length != 0.0))
932 auto beta_in = std::numeric_limits<double>::quiet_NaN();
933 auto beta_out = std::numeric_limits<double>::quiet_NaN();
941 unsigned int ii_ch = chans.first;
942 unsigned int jj_ch = chans.second;
948 if ((ii_ch == sweep_donor) || (jj_ch == sweep_donor))
959 mooseAssert(!std::isnan(beta_in),
960 "beta_in was not set. Check gap logic for i_ch = " + std::to_string(i_ch) +
961 ", iz = " + std::to_string(iz));
962 mooseAssert(!std::isnan(beta_out),
963 "beta_out was not set. Check gap logic for i_ch = " + std::to_string(i_ch) +
964 ", iz = " + std::to_string(iz));
968 auto wsweep_in = edge_flux_ave * beta_in * Sij;
969 auto wsweep_out = edge_flux_ave * beta_out * Sij;
970 auto sweep_hin = (*_h_soln)(node_sweep_donor);
971 auto sweep_hout = (*_h_soln)(node_in);
972 sweep_enthalpy = (wsweep_in * sweep_hin - wsweep_out * sweep_hout);
976 if (iz == first_node)
978 PetscScalar value_hs = alpha * sweep_enthalpy;
984 PetscInt col_sh = i_ch +
_n_channels * (iz_ind - 1);
985 PetscScalar value_sh = alpha * wsweep_out;
986 LibmeshPetscCall(MatSetValues(
989 value_sh = -alpha * wsweep_in;
990 LibmeshPetscCall(MatSetValues(
994 PetscScalar value_sh = (1.0 - alpha) * wsweep_out;
998 value_sh = -(1.0 - alpha) * wsweep_in;
1006 PetscInt row_vec_ht = i_ch +
_n_channels * iz_ind;
1024 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1025 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1029 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1030 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1033 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1034 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1037 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1038 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1041 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1042 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1045 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1046 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1049 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1050 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1052 _console <<
"Block: " << iblock <<
" - Enthalpy conservation matrix assembled" << std::endl;