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 =
597 if (iz == first_node)
600 PetscScalar value_at = alpha * (*_mdot_soln)(node_in) * (*
_h_soln)(node_in);
604 value_at = alpha * (*_mdot_soln)(node_out) - (1 - alpha) * (*_mdot_soln)(node_in);
606 LibmeshPetscCall(MatSetValues(
609 value_at = (1 - alpha) * (*
_mdot_soln)(node_out);
611 LibmeshPetscCall(MatSetValues(
614 else if (iz == last_node)
617 PetscScalar value_at = 1.0 * (*_mdot_soln)(node_out);
619 LibmeshPetscCall(MatSetValues(
622 value_at = -1.0 * (*_mdot_soln)(node_in);
624 LibmeshPetscCall(MatSetValues(
632 PetscScalar value_at = -alpha * (*_mdot_soln)(node_in);
634 LibmeshPetscCall(MatSetValues(
637 value_at = alpha * (*_mdot_soln)(node_out) - (1 - alpha) * (*_mdot_soln)(node_in);
639 LibmeshPetscCall(MatSetValues(
642 value_at = (1 - alpha) * (*
_mdot_soln)(node_out);
644 LibmeshPetscCall(MatSetValues(
653 auto diff_center = K_center / (cp_center + 1e-15);
655 if (iz == first_node)
665 auto diff_bottom = K_bottom / (cp_bottom + 1e-15);
666 auto diff_top = K_top / (cp_top + 1e-15);
680 PetscScalar value_at = diff_up * S_up / dz_up + diff_down * S_down / dz_down;
681 LibmeshPetscCall(MatSetValues(
685 value_at = 1.0 * diff_down * S_down / dz_down * (*_h_soln)(node_bottom);
691 value_at = -diff_up * S_up / dz_up;
692 LibmeshPetscCall(MatSetValues(
695 else if (iz == last_node)
702 auto diff_bottom = K_bottom / (cp_bottom + 1e-15);
705 auto S_down = 0.5 * ((*_S_flow_soln)(node_center) + (*
_S_flow_soln)(node_bottom));
706 auto diff_down = 0.5 * (diff_center + diff_bottom);
711 PetscScalar value_at = diff_down * S_down / dz_down;
712 LibmeshPetscCall(MatSetValues(
717 value_at = -diff_down * S_down / dz_down;
718 LibmeshPetscCall(MatSetValues(
736 auto diff_bottom = K_bottom / (cp_bottom + 1e-15);
737 auto diff_top = K_top / (cp_top + 1e-15);
751 PetscScalar value_at = diff_up * S_up / dz_up + diff_down * S_down / dz_down;
752 LibmeshPetscCall(MatSetValues(
757 value_at = -diff_down * S_down / dz_down;
758 LibmeshPetscCall(MatSetValues(
763 value_at = -diff_up * S_up / dz_up;
764 LibmeshPetscCall(MatSetValues(
769 unsigned int counter = 0;
770 unsigned int cross_index = iz;
775 unsigned int ii_ch = chans.first;
776 unsigned int jj_ch = chans.second;
781 if (
_Wij(i_gap, cross_index) > 0.0)
783 if (iz == first_node)
785 h_star = (*_h_soln)(node_in_i);
786 PetscScalar value_vec_ct = -1.0 * alpha *
788 _Wij(i_gap, cross_index) * h_star;
790 LibmeshPetscCall(VecSetValues(
796 _Wij(i_gap, cross_index);
798 PetscInt col_ct = ii_ch +
_n_channels * (iz_ind - 1);
799 LibmeshPetscCall(MatSetValues(
802 PetscScalar value_ct = (1.0 - alpha) *
804 _Wij(i_gap, cross_index);
807 LibmeshPetscCall(MatSetValues(
810 else if (
_Wij(i_gap, cross_index) < 0.0)
812 if (iz == first_node)
814 h_star = (*_h_soln)(node_in_j);
815 PetscScalar value_vec_ct = -1.0 * alpha *
817 _Wij(i_gap, cross_index) * h_star;
819 LibmeshPetscCall(VecSetValues(
825 _Wij(i_gap, cross_index);
827 PetscInt col_ct = jj_ch +
_n_channels * (iz_ind - 1);
828 LibmeshPetscCall(MatSetValues(
831 PetscScalar value_ct = (1.0 - alpha) *
833 _Wij(i_gap, cross_index);
836 LibmeshPetscCall(MatSetValues(
841 if (iz == first_node)
843 PetscScalar value_vec_ct =
844 -2.0 * alpha * (*_h_soln)(node_in)*
_WijPrime(i_gap, cross_index);
845 value_vec_ct += alpha * (*_h_soln)(node_in_j)*
_WijPrime(i_gap, cross_index);
846 value_vec_ct += alpha * (*_h_soln)(node_in_i)*
_WijPrime(i_gap, cross_index);
853 PetscScalar value_center_ct = 2.0 * alpha *
_WijPrime(i_gap, cross_index);
855 PetscInt col_ct = i_ch +
_n_channels * (iz_ind - 1);
856 LibmeshPetscCall(MatSetValues(
859 PetscScalar value_left_ct = -1.0 * alpha *
_WijPrime(i_gap, cross_index);
862 LibmeshPetscCall(MatSetValues(
865 PetscScalar value_right_ct = -1.0 * alpha *
_WijPrime(i_gap, cross_index);
868 LibmeshPetscCall(MatSetValues(
871 PetscScalar value_center_ct = 2.0 * (1.0 - alpha) *
_WijPrime(i_gap, cross_index);
874 LibmeshPetscCall(MatSetValues(
877 PetscScalar value_left_ct = -1.0 * (1.0 - alpha) *
_WijPrime(i_gap, cross_index);
880 LibmeshPetscCall(MatSetValues(
883 PetscScalar value_right_ct = -1.0 * (1.0 - alpha) *
_WijPrime(i_gap, cross_index);
886 LibmeshPetscCall(MatSetValues(
892 Real dist_ij = pitch;
905 dist_ij = pitch / std::sqrt(3);
913 auto A_i = K_i / cp_i;
914 auto A_j = K_j / cp_j;
915 auto harm_A = 2.0 * A_i * A_j / (A_i + A_j);
917 0.66 * (pitch / pin_diameter) *
920 auto base_value = harm_A * shape_factor * Sij / dist_ij;
921 auto neg_base_value = -1.0 * base_value;
925 LibmeshPetscCall(MatSetValues(
930 LibmeshPetscCall(MatSetValues(
935 LibmeshPetscCall(MatSetValues(
940 LibmeshPetscCall(MatSetValues(
947 Real edge_flux_ave = 0.0;
950 for (
unsigned int i_ch = 0; i_ch <
_n_channels; i_ch++)
956 auto Si = (*_S_flow_soln)(node_in);
957 auto mdot_in = (*_mdot_soln)(node_in);
958 mdot_sum = mdot_sum + mdot_in;
959 si_sum = si_sum + Si;
962 edge_flux_ave = mdot_sum / si_sum;
964 PetscScalar sweep_enthalpy = 0.0;
966 (wire_diameter != 0.0) && (wire_lead_length != 0.0))
968 auto beta_in = std::numeric_limits<double>::quiet_NaN();
969 auto beta_out = std::numeric_limits<double>::quiet_NaN();
977 unsigned int ii_ch = chans.first;
978 unsigned int jj_ch = chans.second;
984 if ((ii_ch == sweep_donor) || (jj_ch == sweep_donor))
995 mooseAssert(!std::isnan(beta_in),
996 "beta_in was not set. Check gap logic for i_ch = " + std::to_string(i_ch) +
997 ", iz = " + std::to_string(iz));
998 mooseAssert(!std::isnan(beta_out),
999 "beta_out was not set. Check gap logic for i_ch = " + std::to_string(i_ch) +
1000 ", iz = " + std::to_string(iz));
1003 auto Sij = dz * gap;
1004 auto wsweep_in = edge_flux_ave * beta_in * Sij;
1005 auto wsweep_out = edge_flux_ave * beta_out * Sij;
1006 auto sweep_hin = (*_h_soln)(node_sweep_donor);
1007 auto sweep_hout = (*_h_soln)(node_in);
1008 sweep_enthalpy = (wsweep_in * sweep_hin - wsweep_out * sweep_hout);
1010 if (iz == first_node)
1013 PetscScalar value_hs = -sweep_enthalpy;
1020 PetscInt row_sh = i_ch +
_n_channels * (iz_ind - 1);
1021 PetscInt col_sh = i_ch +
_n_channels * (iz_ind - 1);
1022 LibmeshPetscCall(MatSetValues(
1024 PetscInt col_sh_l = sweep_donor +
_n_channels * (iz_ind - 1);
1025 PetscScalar neg_sweep_in = -1.0 * wsweep_in;
1027 LibmeshPetscCall(MatSetValues(
1035 PetscInt row_vec_ht = i_ch +
_n_channels * iz_ind;
1053 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1054 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1058 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1059 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1062 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1063 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1066 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1067 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1070 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1071 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1074 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1075 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1078 LibmeshPetscCall(MatAssemblyBegin(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1079 LibmeshPetscCall(MatAssemblyEnd(
_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1081 _console <<
"Block: " << iblock <<
" - Enthalpy conservation matrix assembled" << std::endl;