- wall_ff_closurechurchillFriction factor closureDefault:churchill C++ Type:MooseEnum Controllable:No Description:Friction factor closure 
- wall_htc_closuredittus_boelterHeat transfer coefficient closureDefault:dittus_boelter C++ Type:MooseEnum Controllable:No Description:Heat transfer coefficient closure 
Closures1PhaseTHM
Closures for 1-phase flow channels
The closures added are:
- a wall friction factor for the pressure drop, 
- a wall heat transfer coefficient for heat transfer. 
The user can choose between a range of correlations for the heat transfer coefficient and friction factor that covers pipes to rod-bundles. The available correlations for the heat transfer coefficient are listed in Table 1.
Table 1: Available correlations for the heat transfer coefficient.
| Name | Coolant | Geometry | Reference | 
|---|---|---|---|
| Dittus-Boelter | Liquid/Gases | Pipes | ADWallHeatTransferCoefficient3EqnDittusBoelterMaterial | 
| Gnielinski | Liquid/Gases | Pipes | ADWallHeatTransferCoefficientGnielinskiMaterial | 
| Wolf-McCarthy | Gases | Pipes | ADWallHeatTransferCoefficientWolfMcCarthyMaterial | 
| Lyon | Liquid Sodium | Pipes | ADWallHeatTransferCoefficientLyonMaterial | 
| Weisman | Water | Rod-bundles | ADWallHeatTransferCoefficientWeismanMaterial | 
| Kazimi-Carelli | Liquid Sodium | Rod-bundles | ADWallHeatTransferCoefficientKazimiMaterial | 
| Mikityuk | Liquid Sodium | Rod-bundles | ADWallHeatTransferCoefficientMikityukMaterial | 
| Schad | Liquid Sodium | Rod-bundles | ADWallHeatTransferCoefficientSchadMaterial | 
The available correlations for the friction factor are listed in Table 2.
Table 2: Available correlations for the friction factor.
| Name | Geometry | Reference | 
|---|---|---|
| Churchill | Pipes | ADWallFrictionChurchillMaterial | 
| Cheng-Todreas | Rod-bundles | ADWallFrictionChengMaterial | 
The user can also define the friction factor directly in the component block, overwriting the value given by the Closures1PhaseTHM, for example:
[Components]
  [pipe_1]
    type = FlowChannel1Phase
    fp = water
    position = '0 0 0'
    orientation = '1 0 0'
    length = 1
    n_elems = 10
    f = 0.01
  []
  [pipe_2]
    type = FlowChannel1Phase
    fp = water
    position = '1 0 0'
    orientation = '1 0 0'
    length = 1
    n_elems = 10
  []
[]
In this case, the friction factor for the Pipe_1 component will be equal to the value defined in the parameter f, while for Pipe_2 the friction factor will given by the correlation chosen in the Closures1PhaseTHM.
Additionally, this object defines:
- a wall temperature material, to be able to retrieve the wall temperature as a material property for each heat transfer. 
Input Parameters
- control_tagsAdds user-defined labels for accessing object parameters via control logic.C++ Type:std::vector<std::string> Controllable:No Description:Adds user-defined labels for accessing object parameters via control logic. 
- enableTrueSet the enabled status of the MooseObject.Default:True C++ Type:bool Controllable:No Description:Set the enabled status of the MooseObject. 
Advanced Parameters
Input Files
- (modules/thermal_hydraulics/tutorials/single_phase_flow/01_flow_channel.i)
- (modules/combined/test/tests/subchannel_thm_coupling/THM_SCM_coupling.i)
- (modules/thermal_hydraulics/tutorials/single_phase_flow/06_custom_closures.i)
- (modules/thermal_hydraulics/tutorials/single_phase_flow/03_upper_loop.i)
- (modules/thermal_hydraulics/tutorials/single_phase_flow/02_core.i)
- (modules/thermal_hydraulics/tutorials/single_phase_flow/05_secondary_side.i)
- (modules/combined/test/tests/subchannel_thm_coupling/THM_SCM_coupling_pump.i)
- (modules/thermal_hydraulics/test/tests/closures/THM_1phase/thm1phase.i)
- (modules/thermal_hydraulics/tutorials/single_phase_flow/04_loop.i)
(modules/thermal_hydraulics/tutorials/single_phase_flow/01_flow_channel.i)
T_in = 300. # K
m_dot_in = 1e-2 # kg/s
press = 10e5 # Pa
[GlobalParams]
  initial_p = ${press}
  initial_vel = 0.0001
  initial_T = ${T_in}
  gravity_vector = '0 0 0'
  rdg_slope_reconstruction = minmod
  scaling_factor_1phase = '1 1e-2 1e-4'
  closures = thm_closures
  fp = he
[]
[FluidProperties]
  [he]
    type = IdealGasFluidProperties
    molar_mass = 4e-3
    gamma = 1.67
    k = 0.2556
    mu = 3.22639e-5
  []
[]
[Closures]
  [thm_closures]
    type = Closures1PhaseTHM
  []
[]
[Components]
  [inlet]
    type = InletMassFlowRateTemperature1Phase
    input = 'core_chan:in'
    m_dot = ${m_dot_in}
    T = ${T_in}
  []
  [core_chan]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '0 0 1'
    length = 1
    n_elems = 25
    A = 7.2548e-3
    D_h = 7.0636e-2
  []
  [outlet]
    type = Outlet1Phase
    input = 'core_chan:out'
    p = ${press}
  []
[]
[Postprocessors]
  [core_p_in]
    type = SideAverageValue
    boundary = core_chan:in
    variable = p
  []
  [core_p_out]
    type = SideAverageValue
    boundary = core_chan:out
    variable = p
  []
  [core_delta_p]
    type = ParsedPostprocessor
    pp_names = 'core_p_in core_p_out'
    expression = 'core_p_in - core_p_out'
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  solve_type = NEWTON
  line_search = basic
  start_time = 0
  end_time = 1000
  dt = 10
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  nl_rel_tol = 1e-8
  nl_abs_tol = 1e-8
  nl_max_its = 25
[]
[Outputs]
  exodus = true
  [console]
    type = Console
    max_rows = 1
    outlier_variable_norms = false
  []
  print_linear_residuals = false
[]
(modules/combined/test/tests/subchannel_thm_coupling/THM_SCM_coupling.i)
# THM file based on https://mooseframework.inl.gov/modules/thermal_hydraulics/tutorials/single_phase_flow/step05.html
# Used to loosely couple THM with SCM
# This is a simple open loop with fixed massflow at the inlet and pressure at the outlet.
# THM sends massflux and temperature at the inlet of the core, and pressure at the outlet of the core
# to subchannel. Subchannel returns total pressure drop of the assembly and total power to THM and THM calculates an
# average friction factor for the core region.
T_in = 583.0 # K
m_dot_in = 1 # kg/s
press = 2e5 # Pa
SC_core = 0.0004980799633447909 #m2
# core parameters
core_length = 1. # m
core_n_elems = 1
A_core = 0.005 #dummy
# pipe parameters
pipe_dia = '${units 10. cm -> m}'
A_pipe = '${fparse 0.25 * pi * pipe_dia^2}'
# heat exchanger parameters
hx_dia_inner = '${units 12. cm -> m}'
hx_wall_thickness = '${units 5. mm -> m}'
hx_dia_outer = '${units 50. cm -> m}'
hx_radius_wall = '${fparse hx_dia_inner / 2. + hx_wall_thickness}'
hx_length = 1.5 # m
hx_n_elems = 25
m_dot_sec_in = 1. # kg/s
[GlobalParams]
  initial_p = ${press}
  initial_vel = 0.0001
  initial_T = ${T_in}
  initial_vel_x = 0
  initial_vel_y = 0
  initial_vel_z = 0
  gravity_vector = '0 0 0'
  rdg_slope_reconstruction = minmod
  scaling_factor_1phase = '1 1e-2 1e-4'
  scaling_factor_rhoV = 1
  scaling_factor_rhouV = 1e-2
  scaling_factor_rhovV = 1e-2
  scaling_factor_rhowV = 1e-2
  scaling_factor_rhoEV = 1e-4
  closures = thm_closures
  fp = sodium_eos
[]
[Functions]
  [q_wall_fn]
    type = ParsedFunction
    symbol_names = 'core_power length'
    symbol_values = 'core_power  ${core_length}'
    expression = 'core_power/length'
  []
[]
[FluidProperties]
  [water]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    cv = 1816.0
    q = -1.167e6
    p_inf = 1.0e9
    q_prime = 0
  []
  [sodium_eos]
    type = StiffenedGasFluidProperties
    gamma = 1.24
    cv = 1052.8
    q = -2.6292e+05
    p_inf = 1.1564e+08
    q_prime = 0
    mu = 3.222e-04
    k = 73.82
  []
[]
[Closures]
  [thm_closures]
    type = Closures1PhaseTHM
  []
  [none_closures]
    type = Closures1PhaseNone
  []
[]
[Materials]
  [f_mat]
    type = ADParsedMaterial
    property_name = f_D
    postprocessor_names = 'core_f'
    expression = 'core_f'
    block = 'core_chan'
  []
[]
[HeatStructureMaterials]
  [steel]
    type = SolidMaterialProperties
    rho = 8050
    k = 45
    cp = 466
  []
[]
[Components]
  [inlet]
    type = InletMassFlowRateTemperature1Phase
    input = 'bottom_2:in'
    m_dot = ${m_dot_in}
    T = ${T_in}
  []
  [outlet]
    type = Outlet1Phase
    input = 'bottom_1:out'
    p = ${press}
  []
  [up_pipe_1]
    type = FlowChannel1Phase
    position = '0 0 -0.5'
    orientation = '0 0 1'
    length = 0.5
    n_elems = 15
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct1]
    type = JunctionParallelChannels1Phase
    position = '0 0 0'
    connections = 'up_pipe_1:out core_chan:in'
    volume = 1e-5
  []
  [core_chan]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '0 0 1'
    length = ${core_length}
    n_elems = ${core_n_elems}
    A = ${A_core}
    closures = none_closures
  []
  [core_ht]
    type = HeatTransferFromHeatFlux1Phase
    flow_channel = core_chan
    q_wall = q_wall_fn
    P_hf = 1
  []
  [jct2]
    type = JunctionParallelChannels1Phase
    position = '0 0 1'
    connections = 'core_chan:out up_pipe_2:in'
    volume = 1e-5
  []
  [up_pipe_2]
    type = FlowChannel1Phase
    position = '0 0 1'
    orientation = '0 0 1'
    length = 0.5
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct3]
    type = JunctionOneToOne1Phase
    connections = 'up_pipe_2:out top_pipe_1:in'
  []
  [top_pipe_1]
    type = FlowChannel1Phase
    position = '0 0 1.5'
    orientation = '1 0 0'
    length = 0.5
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [top_pipe_2]
    type = FlowChannel1Phase
    position = '0.5 0 1.5'
    orientation = '1 0 0'
    length = 0.5
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct4]
    type = VolumeJunction1Phase
    position = '0.5 0 1.5'
    volume = 1e-5
    connections = 'top_pipe_1:out top_pipe_2:in'
  []
  [jct5]
    type = JunctionOneToOne1Phase
    connections = 'top_pipe_2:out down_pipe_1:in'
  []
  [down_pipe_1]
    type = FlowChannel1Phase
    position = '1 0 1.5'
    orientation = '0 0 -1'
    length = 0.25
    A = ${A_pipe}
    n_elems = 5
  []
  [jct6]
    type = JunctionParallelChannels1Phase
    position = '1 0 1.25'
    connections = 'down_pipe_1:out hx/pri:in'
    volume = 1e-5
  []
  [hx]
    [pri]
      type = FlowChannel1Phase
      position = '1 0 1.25'
      orientation = '0 0 -1'
      length = ${hx_length}
      n_elems = ${hx_n_elems}
      roughness = 1e-5
      A = '${fparse pi * hx_dia_inner * hx_dia_inner / 4.}'
      D_h = ${hx_dia_inner}
    []
    [ht_pri]
      type = HeatTransferFromHeatStructure1Phase
      hs = hx/wall
      hs_side = inner
      flow_channel = hx/pri
      P_hf = '${fparse pi * hx_dia_inner}'
    []
    [wall]
      type = HeatStructureCylindrical
      position = '1 0 1.25'
      orientation = '0 0 -1'
      length = ${hx_length}
      n_elems = ${hx_n_elems}
      widths = '${hx_wall_thickness}'
      n_part_elems = '3'
      materials = 'steel'
      names = '0'
      inner_radius = '${fparse hx_dia_inner / 2.}'
    []
    [ht_sec]
      type = HeatTransferFromHeatStructure1Phase
      hs = hx/wall
      hs_side = outer
      flow_channel = hx/sec
      P_hf = '${fparse 2 * pi * hx_radius_wall}'
    []
    [sec]
      type = FlowChannel1Phase
      position = '${fparse 1 + hx_wall_thickness} 0 -0.25'
      orientation = '0 0 1'
      length = ${hx_length}
      n_elems = ${hx_n_elems}
      A = '${fparse pi * (hx_dia_outer * hx_dia_outer / 4. - hx_radius_wall * hx_radius_wall)}'
      D_h = '${fparse hx_dia_outer - (2 * hx_radius_wall)}'
      fp = water
      initial_T = 300
    []
  []
  [jct7]
    type = JunctionParallelChannels1Phase
    position = '1 0 -0.25'
    connections = 'hx/pri:out down_pipe_2:in'
    volume = 1e-5
  []
  [down_pipe_2]
    type = FlowChannel1Phase
    position = '1 0 -0.25'
    orientation = '0 0 -1'
    length = 0.25
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct8]
    type = JunctionOneToOne1Phase
    connections = 'down_pipe_2:out bottom_1:in'
  []
  [bottom_1]
    type = FlowChannel1Phase
    position = '1 0 -0.5'
    orientation = '-1 0 0'
    length = 0.5
    n_elems = 5
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [bottom_2]
    type = FlowChannel1Phase
    position = '0.5 0 -0.5'
    orientation = '-1 0 0'
    length = 0.5
    n_elems = 5
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct9]
    type = JunctionOneToOne1Phase
    connections = 'bottom_2:out up_pipe_1:in'
  []
  [inlet_sec]
    type = InletMassFlowRateTemperature1Phase
    input = 'hx/sec:in'
    m_dot = ${m_dot_sec_in}
    T = 300
  []
  [outlet_sec]
    type = Outlet1Phase
    input = 'hx/sec:out'
    p = 1e5
  []
[]
[Postprocessors]
  [power_to_coolant]
    type = ADHeatRateDirectFlowChannel
    q_wall_prop = q_wall
    block = core_chan
    P_hf = 1
  []
  [core_T_out]
    type = SideAverageValue
    boundary = core_chan:out
    variable = T
  []
  [T_out]
    type = SideAverageValue
    boundary = bottom_1:out
    variable = T
  []
  [core_p_in]
    type = SideAverageValue
    boundary = up_pipe_1:out
    variable = p
  []
  [core_p_out]
    type = SideAverageValue
    boundary = up_pipe_2:in
    variable = p
  []
  [core_delta_p]
    type = ParsedPostprocessor
    pp_names = 'core_p_in core_p_out'
    function = 'core_p_in - core_p_out'
  []
  [hx_pri_T_out]
    type = SideAverageValue
    boundary = hx/pri:out
    variable = T
  []
  [hx_sec_T_in]
    type = SideAverageValue
    boundary = inlet_sec
    variable = T
  []
  [hx_sec_T_out]
    type = SideAverageValue
    boundary = outlet_sec
    variable = T
  []
  [m_dot_sec]
    type = ADFlowBoundaryFlux1Phase
    boundary = inlet_sec
    equation = mass
  []
  ############## Friction Factor Calculation #############
  [av_rhouA]
    type = ElementAverageValue
    variable = 'rhouA'
    block = 'core_chan'
  []
  [av_rho]
    type = ElementAverageValue
    variable = 'rho'
    block = 'core_chan'
  []
  [Kloss]
    type = ParsedPostprocessor
    pp_names = 'core_delta_p_tgt av_rhouA av_rho'
    function = '2.0 * core_delta_p_tgt * av_rho * ${A_core} * ${A_core} / (av_rhouA * av_rhouA)'
  []
  [Dh]
    type = ADElementAverageMaterialProperty
    mat_prop = D_h
    block = core_chan
  []
  [core_f]
    type = ParsedPostprocessor
    pp_names = 'Kloss Dh'
    function = 'Kloss * Dh / ${core_length}'
  []
  ### INFO to send to SC
  [outlet_pressure]
    type = SideAverageValue
    boundary = up_pipe_2:in
    variable = p
  []
  [inlet_mass_flow_rate]
    type = ADFlowJunctionFlux1Phase
    boundary = up_pipe_1:out
    connection_index = 0
    equation = mass
    junction = jct1
  []
  [inlet_temperature]
    type = SideAverageValue
    boundary = up_pipe_1:out
    variable = T
  []
  [inlet_mass_flux]
    type = ParsedPostprocessor
    pp_names = 'inlet_mass_flow_rate'
    function = 'abs(inlet_mass_flow_rate/${SC_core})'
  []
  #####
  ##### Info received from subchannel
  [core_delta_p_tgt]
    type = Receiver
    default = 100
  []
  [core_power]
    type = Receiver
    default = 100
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  start_time = 0
  [TimeStepper]
    type = IterationAdaptiveDT
    dt = 0.01
  []
  # dtmax = 5
  end_time = 5
  line_search = basic
  solve_type = NEWTON
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  nl_rel_tol = 1e-8
  nl_abs_tol = 1e-8
  nl_max_its = 25
[]
[Outputs]
  csv = true
  [console]
    type = Console
    max_rows = 1
    outlier_variable_norms = false
  []
  print_linear_residuals = false
[]
################################################################################
# A multiapp that couples THM to subchannel
################################################################################
[MultiApps]
  [subchannel]
    type = FullSolveMultiApp
    input_files = 'subchannel.i'
    execute_on = 'timestep_end'
    positions = '0 0 0'
    max_procs_per_app = 1
    output_in_position = true
    bounding_box_padding = '0 0 0.1'
  []
[]
[Transfers]
  [pressure_drop_transfer] # Get pressure drop to THM from subchannel
    type = MultiAppPostprocessorTransfer
    from_multi_app = subchannel
    from_postprocessor = total_pressure_drop_SC
    to_postprocessor = core_delta_p_tgt
    reduction_type = average
    execute_on = 'timestep_end'
  []
  [power_transfer] # Get Total power to THM from subchannel
    type = MultiAppPostprocessorTransfer
    from_multi_app = subchannel
    from_postprocessor = Total_power
    to_postprocessor = core_power
    reduction_type = average
    execute_on = 'timestep_end'
  []
  [mass_flux_tranfer] # Send mass_flux at the inlet of THM core to subchannel
    type = MultiAppPostprocessorTransfer
    to_multi_app = subchannel
    from_postprocessor = inlet_mass_flux
    to_postprocessor = report_mass_flux_inlet
    execute_on = 'timestep_end'
  []
  [outlet_pressure_tranfer] # Send pressure at the outlet of THM core to subchannel
    type = MultiAppPostprocessorTransfer
    to_multi_app = subchannel
    from_postprocessor = outlet_pressure
    to_postprocessor = report_pressure_outlet
    execute_on = 'timestep_end'
  []
  [inlet_temperature_transfer]
    type = MultiAppPostprocessorTransfer
    to_multi_app = subchannel
    from_postprocessor = inlet_temperature
    to_postprocessor = report_temperature_inlet
    execute_on = 'timestep_end'
  []
[]
(modules/thermal_hydraulics/tutorials/single_phase_flow/06_custom_closures.i)
T_in = 300. # K
m_dot_in = 1e-2 # kg/s
press = 10e5 # Pa
# core parameters
core_length = 1. # m
core_n_elems = 25
core_dia = '${units 2. cm -> m}'
core_pitch = '${units 8.7 cm -> m}'
A_core = '${fparse core_pitch^2 - 0.25 *pi * core_dia^2}'
P_wet_core = '${fparse 4*core_pitch + pi * core_dia}'
Dh_core = '${fparse 4 * A_core / P_wet_core}'
# pipe parameters
pipe_dia = '${units 10. cm -> m}'
A_pipe = '${fparse 0.25 * pi * pipe_dia^2}'
tot_power = 2000 # W
# heat exchanger parameters
hx_dia_inner = '${units 12. cm -> m}'
hx_wall_thickness = '${units 5. mm -> m}'
hx_dia_outer = '${units 50. cm -> m}'
hx_radius_wall = '${fparse hx_dia_inner / 2. + hx_wall_thickness}'
hx_length = 1.5 # m
hx_n_elems = 25
m_dot_sec_in = 1. # kg/s
[GlobalParams]
  initial_p = ${press}
  initial_vel = 0.0001
  initial_T = ${T_in}
  initial_vel_x = 0
  initial_vel_y = 0
  initial_vel_z = 0
  gravity_vector = '0 0 0'
  rdg_slope_reconstruction = minmod
  scaling_factor_1phase = '1 1e-2 1e-4'
  scaling_factor_rhoV = 1
  scaling_factor_rhouV = 1e-2
  scaling_factor_rhovV = 1e-2
  scaling_factor_rhowV = 1e-2
  scaling_factor_rhoEV = 1e-4
  closures = thm_closures
  fp = he
[]
[Functions]
  [m_dot_sec_fn]
    type = PiecewiseLinear
    xy_data = '
      0    0
      10 ${m_dot_sec_in}'
  []
[]
[FluidProperties]
  [he]
    type = IdealGasFluidProperties
    molar_mass = 4e-3
    gamma = 1.67
    k = 0.2556
    mu = 3.22639e-5
  []
  [water]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    cv = 1816.0
    q = -1.167e6
    p_inf = 1.0e9
    q_prime = 0
  []
[]
[Closures]
  [thm_closures]
    type = Closures1PhaseTHM
  []
[]
[Materials]
  [Re_mat]
    type = ADReynoldsNumberMaterial
    Re = Re
    rho = rho
    vel = vel
    D_h = D_h
    mu = mu
    block = hx/pri
  []
  [f_mat]
    type = ADParsedMaterial
    property_name = f_D
    constant_names = 'a b c'
    constant_expressions = '1 0.1 -0.5'
    material_property_names = 'Re'
    expression = 'a + b * Re^c'
    block = hx/pri
  []
  [Pr_mat]
    type = ADPrandtlNumberMaterial
    Pr = Pr
    cp = cp
    mu = mu
    k = k
    block = hx/pri
  []
  [Nu_mat]
    type = ADParsedMaterial
    property_name = 'Nu'
    constant_names = 'a b c'
    constant_expressions = '0.03 0.9 0.5'
    material_property_names = 'Re Pr'
    expression = 'a * Re ^b * Pr^c'
    block = hx/pri
  []
  [Hw_mat]
    type = ADConvectiveHeatTransferCoefficientMaterial
    D_h = D_h
    k = k
    Nu = Nu
    Hw = Hw
    block = hx/pri
  []
[]
[SolidProperties]
  [steel]
    type = ThermalFunctionSolidProperties
    rho = 8050
    k = 45
    cp = 466
  []
[]
[Components]
  [total_power]
    type = TotalPower
    power = ${tot_power}
  []
  [up_pipe_1]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '0 0 1'
    length = 0.5
    n_elems = 15
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct1]
    type = JunctionParallelChannels1Phase
    position = '0 0 0.5'
    connections = 'up_pipe_1:out core_chan:in'
    volume = 1e-5
  []
  [core_chan]
    type = FlowChannel1Phase
    position = '0 0 0.5'
    orientation = '0 0 1'
    length = ${core_length}
    n_elems = ${core_n_elems}
    roughness = .0001
    A = ${A_core}
    D_h = ${Dh_core}
  []
  [core_hs]
    type = HeatStructureCylindrical
    position = '0 0 0.5'
    orientation = '0 0 1'
    length = ${core_length}
    n_elems = ${core_n_elems}
    names = 'block'
    widths = '${fparse core_dia / 2.}'
    solid_properties = 'steel'
    solid_properties_T_ref = '300'
    n_part_elems = 3
  []
  [core_heating]
    type = HeatSourceFromTotalPower
    hs = core_hs
    regions = block
    power = total_power
  []
  [core_ht]
    type = HeatTransferFromHeatStructure1Phase
    flow_channel = core_chan
    hs = core_hs
    hs_side = outer
    P_hf = '${fparse pi * core_dia}'
  []
  [jct2]
    type = JunctionParallelChannels1Phase
    position = '0 0 1.5'
    connections = 'core_chan:out up_pipe_2:in'
    volume = 1e-5
  []
  [up_pipe_2]
    type = FlowChannel1Phase
    position = '0 0 1.5'
    orientation = '0 0 1'
    length = 0.5
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct3]
    type = JunctionOneToOne1Phase
    connections = 'up_pipe_2:out top_pipe_1:in'
  []
  [top_pipe_1]
    type = FlowChannel1Phase
    position = '0 0 2'
    orientation = '1 0 0'
    length = 0.5
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [top_pipe_2]
    type = FlowChannel1Phase
    position = '0.5 0 2'
    orientation = '1 0 0'
    length = 0.5
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct4]
    type = VolumeJunction1Phase
    position = '0.5 0 2'
    volume = 1e-5
    connections = 'top_pipe_1:out top_pipe_2:in press_pipe:in'
  []
  [press_pipe]
    type = FlowChannel1Phase
    position = '0.5 0 2'
    orientation = '0 1 0'
    length = 0.2
    n_elems = 5
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [pressurizer]
    type = InletStagnationPressureTemperature1Phase
    p0 = ${press}
    T0 = ${T_in}
    input = press_pipe:out
  []
  [jct5]
    type = JunctionOneToOne1Phase
    connections = 'top_pipe_2:out down_pipe_1:in'
  []
  [down_pipe_1]
    type = FlowChannel1Phase
    position = '1 0 2'
    orientation = '0 0 -1'
    length = 0.25
    A = ${A_pipe}
    n_elems = 5
  []
  [jct6]
    type = JunctionParallelChannels1Phase
    position = '1 0 1.75'
    connections = 'down_pipe_1:out hx/pri:in'
    volume = 1e-5
  []
  [hx]
    [pri]
      type = FlowChannel1Phase
      position = '1 0 1.75'
      orientation = '0 0 -1'
      length = ${hx_length}
      n_elems = ${hx_n_elems}
      roughness = 1e-5
      A = '${fparse pi * hx_dia_inner * hx_dia_inner / 4.}'
      D_h = ${hx_dia_inner}
      closures = ''
    []
    [ht_pri]
      type = HeatTransferFromHeatStructure1Phase
      hs = hx/wall
      hs_side = inner
      flow_channel = hx/pri
      P_hf = '${fparse pi * hx_dia_inner}'
    []
    [wall]
      type = HeatStructureCylindrical
      position = '1 0 1.75'
      orientation = '0 0 -1'
      length = ${hx_length}
      n_elems = ${hx_n_elems}
      widths = '${hx_wall_thickness}'
      n_part_elems = '3'
      solid_properties = 'steel'
      solid_properties_T_ref = '300'
      names = '0'
      inner_radius = '${fparse hx_dia_inner / 2.}'
    []
    [ht_sec]
      type = HeatTransferFromHeatStructure1Phase
      hs = hx/wall
      hs_side = outer
      flow_channel = hx/sec
      P_hf = '${fparse 2 * pi * hx_radius_wall}'
    []
    [sec]
      type = FlowChannel1Phase
      position = '${fparse 1 + hx_wall_thickness} 0 0.25'
      orientation = '0 0 1'
      length = ${hx_length}
      n_elems = ${hx_n_elems}
      A = '${fparse pi * (hx_dia_outer * hx_dia_outer / 4. - hx_radius_wall * hx_radius_wall)}'
      D_h = '${fparse hx_dia_outer - (2 * hx_radius_wall)}'
      fp = water
      initial_T = 300
    []
  []
  [jct7]
    type = JunctionParallelChannels1Phase
    position = '1 0 0.5'
    connections = 'hx/pri:out down_pipe_2:in'
    volume = 1e-5
  []
  [down_pipe_2]
    type = FlowChannel1Phase
    position = '1 0 0.25'
    orientation = '0 0 -1'
    length = 0.25
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct8]
    type = JunctionOneToOne1Phase
    connections = 'down_pipe_2:out bottom_1:in'
  []
  [bottom_1]
    type = FlowChannel1Phase
    position = '1 0 0'
    orientation = '-1 0 0'
    length = 0.5
    n_elems = 5
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [pump]
    type = Pump1Phase
    position = '0.5 0 0'
    connections = 'bottom_1:out bottom_2:in'
    volume = 1e-4
    A_ref = ${A_pipe}
    head = 0
  []
  [bottom_2]
    type = FlowChannel1Phase
    position = '0.5 0 0'
    orientation = '-1 0 0'
    length = 0.5
    n_elems = 5
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct9]
    type = JunctionOneToOne1Phase
    connections = 'bottom_2:out up_pipe_1:in'
  []
  [inlet_sec]
    type = InletMassFlowRateTemperature1Phase
    input = 'hx/sec:in'
    m_dot = 0
    T = 300
  []
  [outlet_sec]
    type = Outlet1Phase
    input = 'hx/sec:out'
    p = 1e5
  []
[]
[ControlLogic]
  [set_point]
    type = GetFunctionValueControl
    function = ${m_dot_in}
  []
  [pid]
    type = PIDControl
    initial_value = 0.0
    set_point = set_point:value
    input = m_dot_pump
    K_p = 1.
    K_i = 4.
    K_d = 0
  []
  [set_pump_head]
    type = SetComponentRealValueControl
    component = pump
    parameter = head
    value = pid:output
  []
  [m_dot_sec_inlet_ctrl]
    type = GetFunctionValueControl
    function = m_dot_sec_fn
  []
  [set_m_dot_sec_ctrl]
    type = SetComponentRealValueControl
    component = inlet_sec
    parameter = m_dot
    value = m_dot_sec_inlet_ctrl:value
  []
[]
[Postprocessors]
  [power_to_coolant]
    type = ADHeatRateConvection1Phase
    block = core_chan
    P_hf = '${fparse pi *core_dia}'
  []
  [m_dot_pump]
    type = ADFlowJunctionFlux1Phase
    boundary = core_chan:in
    connection_index = 1
    equation = mass
    junction = jct7
  []
  [core_T_out]
    type = SideAverageValue
    boundary = core_chan:out
    variable = T
  []
  [core_p_in]
    type = SideAverageValue
    boundary = core_chan:in
    variable = p
  []
  [core_p_out]
    type = SideAverageValue
    boundary = core_chan:out
    variable = p
  []
  [core_delta_p]
    type = ParsedPostprocessor
    pp_names = 'core_p_in core_p_out'
    expression = 'core_p_in - core_p_out'
  []
  [hx_pri_T_out]
    type = SideAverageValue
    boundary = hx/pri:out
    variable = T
  []
  [hx_sec_T_in]
    type = SideAverageValue
    boundary = inlet_sec
    variable = T
  []
  [hx_sec_T_out]
    type = SideAverageValue
    boundary = outlet_sec
    variable = T
  []
  [m_dot_sec]
    type = ADFlowBoundaryFlux1Phase
    boundary = inlet_sec
    equation = mass
  []
  [Hw_hx_pri]
    type = ADElementAverageMaterialProperty
    mat_prop = Hw
    block = hx/pri
  []
  [fD_hx_pri]
    type = ADElementAverageMaterialProperty
    mat_prop = f_D
    block = hx/pri
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  start_time = 0
  [TimeStepper]
    type = IterationAdaptiveDT
    dt = 1
  []
  dtmax = 5
  end_time = 500
  line_search = basic
  solve_type = NEWTON
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  nl_rel_tol = 1e-8
  nl_abs_tol = 1e-8
  nl_max_its = 25
[]
[Outputs]
  exodus = true
  [console]
    type = Console
    max_rows = 1
    outlier_variable_norms = false
  []
  print_linear_residuals = false
[]
(modules/thermal_hydraulics/tutorials/single_phase_flow/03_upper_loop.i)
T_in = 300. # K
m_dot_in = 1e-2 # kg/s
press = 10e5 # Pa
# core parameters
core_length = 1. # m
core_n_elems = 25
core_dia = '${units 2. cm -> m}'
core_pitch = '${units 8.7 cm -> m}'
A_core = '${fparse core_pitch^2 - 0.25 *pi * core_dia^2}'
P_wet_core = '${fparse 4*core_pitch + pi * core_dia}'
Dh_core = '${fparse 4 * A_core / P_wet_core}'
# pipe parameters
pipe_dia = '${units 10. cm -> m}'
A_pipe = '${fparse 0.25 * pi * pipe_dia^2}'
tot_power = 2000 # W
[GlobalParams]
  initial_p = ${press}
  initial_vel = 0.0001
  initial_T = ${T_in}
  initial_vel_x = 0
  initial_vel_y = 0
  initial_vel_z = 0
  gravity_vector = '0 0 0'
  rdg_slope_reconstruction = minmod
  scaling_factor_1phase = '1 1e-2 1e-4'
  scaling_factor_rhoV = 1
  scaling_factor_rhouV = 1e-2
  scaling_factor_rhovV = 1e-2
  scaling_factor_rhowV = 1e-2
  scaling_factor_rhoEV = 1e-4
  closures = thm_closures
  fp = he
[]
[FluidProperties]
  [he]
    type = IdealGasFluidProperties
    molar_mass = 4e-3
    gamma = 1.67
    k = 0.2556
    mu = 3.22639e-5
  []
[]
[Closures]
  [thm_closures]
    type = Closures1PhaseTHM
  []
[]
[SolidProperties]
  [steel]
    type = ThermalFunctionSolidProperties
    rho = 8050
    k = 45
    cp = 466
  []
[]
[Components]
  [total_power]
    type = TotalPower
    power = ${tot_power}
  []
  [inlet]
    type = InletMassFlowRateTemperature1Phase
    input = 'up_pipe_1:in'
    m_dot = ${m_dot_in}
    T = ${T_in}
  []
  [up_pipe_1]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '0 0 1'
    length = 0.5
    n_elems = 15
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct1]
    type = JunctionParallelChannels1Phase
    position = '0 0 0.5'
    connections = 'up_pipe_1:out core_chan:in'
    volume = 1e-5
  []
  [core_chan]
    type = FlowChannel1Phase
    position = '0 0 0.5'
    orientation = '0 0 1'
    length = ${core_length}
    n_elems = ${core_n_elems}
    roughness = .0001
    A = '${A_core}'
    D_h = ${Dh_core}
  []
  [core_hs]
    type = HeatStructureCylindrical
    position = '0 0 0.5'
    orientation = '0 0 1'
    length = ${core_length}
    n_elems = ${core_n_elems}
    names = 'block'
    widths = '${fparse core_dia / 2.}'
    solid_properties = 'steel'
    solid_properties_T_ref = '300'
    n_part_elems = 3
  []
  [core_heating]
    type = HeatSourceFromTotalPower
    hs = core_hs
    regions = block
    power = total_power
  []
  [core_ht]
    type = HeatTransferFromHeatStructure1Phase
    flow_channel = core_chan
    hs = core_hs
    hs_side = outer
    P_hf = '${fparse pi * core_dia}'
  []
  [jct2]
    type = JunctionParallelChannels1Phase
    position = '0 0 1.5'
    connections = 'core_chan:out up_pipe_2:in'
    volume = 1e-5
  []
  [up_pipe_2]
    type = FlowChannel1Phase
    position = '0 0 1.5'
    orientation = '0 0 1'
    length = 0.5
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct3]
    type = JunctionOneToOne1Phase
    connections = 'up_pipe_2:out top_pipe:in'
  []
  [top_pipe]
    type = FlowChannel1Phase
    position = '0 0 2'
    orientation = '1 0 0'
    length = 1
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct4]
    type = JunctionOneToOne1Phase
    connections = 'top_pipe:out down_pipe_1:in'
  []
  [down_pipe_1]
    type = FlowChannel1Phase
    position = '1 0 2'
    orientation = '0 0 -1'
    length = 0.25
    A = ${A_pipe}
    n_elems = 5
  []
  [jct5]
    type = JunctionOneToOne1Phase
    connections = 'down_pipe_1:out cooling_pipe:in'
  []
  [cooling_pipe]
    type = FlowChannel1Phase
    position = '1 0 1.75'
    orientation = '0 0 -1'
    length = 1.5
    n_elems = 25
    A = ${A_pipe}
  []
  [cold_wall]
    type = HeatTransferFromSpecifiedTemperature1Phase
    flow_channel = cooling_pipe
    T_wall = 300
    P_hf = '${fparse pi * pipe_dia}'
  []
  [jct6]
    type = JunctionOneToOne1Phase
    connections = 'cooling_pipe:out down_pipe_2:in'
  []
  [down_pipe_2]
    type = FlowChannel1Phase
    position = '1 0 0.25'
    orientation = '0 0 -1'
    length = 0.25
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [outlet]
    type = Outlet1Phase
    input = 'down_pipe_2:out'
    p = ${press}
  []
[]
[Postprocessors]
  [power_to_coolant]
    type = ADHeatRateConvection1Phase
    block = core_chan
    P_hf = '${fparse pi *core_dia}'
  []
  [core_T_out]
    type = SideAverageValue
    boundary = core_chan:out
    variable = T
  []
  [core_p_in]
    type = SideAverageValue
    boundary = core_chan:in
    variable = p
  []
  [core_p_out]
    type = SideAverageValue
    boundary = core_chan:out
    variable = p
  []
  [core_delta_p]
    type = ParsedPostprocessor
    pp_names = 'core_p_in core_p_out'
    expression = 'core_p_in - core_p_out'
  []
  [hx_pri_T_out]
    type = SideAverageValue
    boundary = cooling_pipe:out
    variable = T
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  start_time = 0
  [TimeStepper]
    type = IterationAdaptiveDT
    dt = 1
  []
  end_time = 500
  line_search = basic
  solve_type = NEWTON
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  nl_rel_tol = 1e-8
  nl_abs_tol = 1e-8
  nl_max_its = 25
[]
[Outputs]
  exodus = true
  [console]
    type = Console
    max_rows = 1
    outlier_variable_norms = false
  []
  print_linear_residuals = false
[]
(modules/thermal_hydraulics/tutorials/single_phase_flow/02_core.i)
T_in = 300. # K
m_dot_in = 1e-2 # kg/s
press = 10e5 # Pa
# core parameters
core_length = 1. # m
core_n_elems = 25
core_dia = '${units 2. cm -> m}'
core_pitch = '${units 8.7 cm -> m}'
A_core = '${fparse core_pitch^2 - 0.25 *pi * core_dia^2}'
P_wet_core = '${fparse 4*core_pitch + pi * core_dia}'
Dh_core = '${fparse 4 * A_core / P_wet_core}'
tot_power = 2000 # W
[GlobalParams]
  initial_p = ${press}
  initial_vel = 0.0001
  initial_T = ${T_in}
  gravity_vector = '0 0 0'
  rdg_slope_reconstruction = minmod
  scaling_factor_1phase = '1 1e-2 1e-4'
  closures = thm_closures
  fp = he
[]
[FluidProperties]
  [he]
    type = IdealGasFluidProperties
    molar_mass = 4e-3
    gamma = 1.67
    k = 0.2556
    mu = 3.22639e-5
  []
[]
[Closures]
  [thm_closures]
    type = Closures1PhaseTHM
  []
[]
[SolidProperties]
  [steel]
    type = ThermalFunctionSolidProperties
    rho = 8050
    k = 45
    cp = 466
  []
[]
[Components]
  [total_power]
    type = TotalPower
    power = ${tot_power}
  []
  [inlet]
    type = InletMassFlowRateTemperature1Phase
    input = 'core_chan:in'
    m_dot = ${m_dot_in}
    T = ${T_in}
  []
  [core_chan]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '0 0 1'
    length = ${core_length}
    n_elems = ${core_n_elems}
    roughness = .0001
    A = '${A_core}'
    D_h = ${Dh_core}
  []
  [core_hs]
    type = HeatStructureCylindrical
    position = '0 0 0'
    orientation = '0 0 1'
    length = ${core_length}
    n_elems = ${core_n_elems}
    names = 'block'
    widths = '${fparse core_dia / 2.}'
    solid_properties = 'steel'
    solid_properties_T_ref = '300'
    n_part_elems = 3
  []
  [core_heating]
    type = HeatSourceFromTotalPower
    hs = core_hs
    regions = block
    power = total_power
  []
  [core_ht]
    type = HeatTransferFromHeatStructure1Phase
    flow_channel = core_chan
    hs = core_hs
    hs_side = outer
    P_hf = '${fparse pi * core_dia}'
  []
  [outlet]
    type = Outlet1Phase
    input = 'core_chan:out'
    p = ${press}
  []
[]
[Postprocessors]
  [power_to_coolant]
    type = ADHeatRateConvection1Phase
    block = core_chan
    P_hf = '${fparse pi *core_dia}'
  []
  [core_T_out]
    type = SideAverageValue
    boundary = core_chan:out
    variable = T
  []
  [core_p_in]
    type = SideAverageValue
    boundary = core_chan:in
    variable = p
  []
  [core_p_out]
    type = SideAverageValue
    boundary = core_chan:out
    variable = p
  []
  [core_delta_p]
    type = ParsedPostprocessor
    pp_names = 'core_p_in core_p_out'
    expression = 'core_p_in - core_p_out'
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  start_time = 0
  [TimeStepper]
    type = IterationAdaptiveDT
    dt = 10
  []
  end_time = 5000
  line_search = basic
  solve_type = NEWTON
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  nl_rel_tol = 1e-8
  nl_abs_tol = 1e-8
  nl_max_its = 25
[]
[Outputs]
  exodus = true
  [console]
    type = Console
    max_rows = 1
    outlier_variable_norms = false
  []
  print_linear_residuals = false
[]
(modules/thermal_hydraulics/tutorials/single_phase_flow/05_secondary_side.i)
T_in = 300. # K
m_dot_in = 1e-2 # kg/s
press = 10e5 # Pa
# core parameters
core_length = 1. # m
core_n_elems = 25
core_dia = '${units 2. cm -> m}'
core_pitch = '${units 8.7 cm -> m}'
A_core = '${fparse core_pitch^2 - 0.25 *pi * core_dia^2}'
P_wet_core = '${fparse 4*core_pitch + pi * core_dia}'
Dh_core = '${fparse 4 * A_core / P_wet_core}'
# pipe parameters
pipe_dia = '${units 10. cm -> m}'
A_pipe = '${fparse 0.25 * pi * pipe_dia^2}'
tot_power = 2000 # W
# heat exchanger parameters
hx_dia_inner = '${units 12. cm -> m}'
hx_wall_thickness = '${units 5. mm -> m}'
hx_dia_outer = '${units 50. cm -> m}'
hx_radius_wall = '${fparse hx_dia_inner / 2. + hx_wall_thickness}'
hx_length = 1.5 # m
hx_n_elems = 25
m_dot_sec_in = 1. # kg/s
[GlobalParams]
  initial_p = ${press}
  initial_vel = 0.0001
  initial_T = ${T_in}
  initial_vel_x = 0
  initial_vel_y = 0
  initial_vel_z = 0
  gravity_vector = '0 0 0'
  rdg_slope_reconstruction = minmod
  scaling_factor_1phase = '1 1e-2 1e-4'
  scaling_factor_rhoV = 1
  scaling_factor_rhouV = 1e-2
  scaling_factor_rhovV = 1e-2
  scaling_factor_rhowV = 1e-2
  scaling_factor_rhoEV = 1e-4
  closures = thm_closures
  fp = he
[]
[Functions]
  [m_dot_sec_fn]
    type = PiecewiseLinear
    xy_data = '
      0    0
      10 ${m_dot_sec_in}'
  []
[]
[FluidProperties]
  [he]
    type = IdealGasFluidProperties
    molar_mass = 4e-3
    gamma = 1.67
    k = 0.2556
    mu = 3.22639e-5
  []
  [water]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    cv = 1816.0
    q = -1.167e6
    p_inf = 1.0e9
    q_prime = 0
  []
[]
[Closures]
  [thm_closures]
    type = Closures1PhaseTHM
  []
[]
[SolidProperties]
  [steel]
    type = ThermalFunctionSolidProperties
    rho = 8050
    k = 45
    cp = 466
  []
[]
[Components]
  [total_power]
    type = TotalPower
    power = ${tot_power}
  []
  [up_pipe_1]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '0 0 1'
    length = 0.5
    n_elems = 15
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct1]
    type = JunctionParallelChannels1Phase
    position = '0 0 0.5'
    connections = 'up_pipe_1:out core_chan:in'
    volume = 1e-5
  []
  [core_chan]
    type = FlowChannel1Phase
    position = '0 0 0.5'
    orientation = '0 0 1'
    length = ${core_length}
    n_elems = ${core_n_elems}
    roughness = .0001
    A = ${A_core}
    D_h = ${Dh_core}
  []
  [core_hs]
    type = HeatStructureCylindrical
    position = '0 0 0.5'
    orientation = '0 0 1'
    length = ${core_length}
    n_elems = ${core_n_elems}
    names = 'block'
    widths = '${fparse core_dia / 2.}'
    solid_properties = 'steel'
    solid_properties_T_ref = '300'
    n_part_elems = 3
  []
  [core_heating]
    type = HeatSourceFromTotalPower
    hs = core_hs
    regions = block
    power = total_power
  []
  [core_ht]
    type = HeatTransferFromHeatStructure1Phase
    flow_channel = core_chan
    hs = core_hs
    hs_side = outer
    P_hf = '${fparse pi * core_dia}'
  []
  [jct2]
    type = JunctionParallelChannels1Phase
    position = '0 0 1.5'
    connections = 'core_chan:out up_pipe_2:in'
    volume = 1e-5
  []
  [up_pipe_2]
    type = FlowChannel1Phase
    position = '0 0 1.5'
    orientation = '0 0 1'
    length = 0.5
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct3]
    type = JunctionOneToOne1Phase
    connections = 'up_pipe_2:out top_pipe_1:in'
  []
  [top_pipe_1]
    type = FlowChannel1Phase
    position = '0 0 2'
    orientation = '1 0 0'
    length = 0.5
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [top_pipe_2]
    type = FlowChannel1Phase
    position = '0.5 0 2'
    orientation = '1 0 0'
    length = 0.5
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct4]
    type = VolumeJunction1Phase
    position = '0.5 0 2'
    volume = 1e-5
    connections = 'top_pipe_1:out top_pipe_2:in press_pipe:in'
  []
  [press_pipe]
    type = FlowChannel1Phase
    position = '0.5 0 2'
    orientation = '0 1 0'
    length = 0.2
    n_elems = 5
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [pressurizer]
    type = InletStagnationPressureTemperature1Phase
    p0 = ${press}
    T0 = ${T_in}
    input = press_pipe:out
  []
  [jct5]
    type = JunctionOneToOne1Phase
    connections = 'top_pipe_2:out down_pipe_1:in'
  []
  [down_pipe_1]
    type = FlowChannel1Phase
    position = '1 0 2'
    orientation = '0 0 -1'
    length = 0.25
    A = ${A_pipe}
    n_elems = 5
  []
  [jct6]
    type = JunctionParallelChannels1Phase
    position = '1 0 1.75'
    connections = 'down_pipe_1:out hx/pri:in'
    volume = 1e-5
  []
  [hx]
    [pri]
      type = FlowChannel1Phase
      position = '1 0 1.75'
      orientation = '0 0 -1'
      length = ${hx_length}
      n_elems = ${hx_n_elems}
      roughness = 1e-5
      A = '${fparse pi * hx_dia_inner * hx_dia_inner / 4.}'
      D_h = ${hx_dia_inner}
    []
    [ht_pri]
      type = HeatTransferFromHeatStructure1Phase
      hs = hx/wall
      hs_side = inner
      flow_channel = hx/pri
      P_hf = '${fparse pi * hx_dia_inner}'
    []
    [wall]
      type = HeatStructureCylindrical
      position = '1 0 1.75'
      orientation = '0 0 -1'
      length = ${hx_length}
      n_elems = ${hx_n_elems}
      widths = '${hx_wall_thickness}'
      n_part_elems = '3'
      solid_properties = 'steel'
      solid_properties_T_ref = '300'
      names = '0'
      inner_radius = '${fparse hx_dia_inner / 2.}'
    []
    [ht_sec]
      type = HeatTransferFromHeatStructure1Phase
      hs = hx/wall
      hs_side = outer
      flow_channel = hx/sec
      P_hf = '${fparse 2 * pi * hx_radius_wall}'
    []
    [sec]
      type = FlowChannel1Phase
      position = '${fparse 1 + hx_wall_thickness} 0 0.25'
      orientation = '0 0 1'
      length = ${hx_length}
      n_elems = ${hx_n_elems}
      A = '${fparse pi * (hx_dia_outer * hx_dia_outer / 4. - hx_radius_wall * hx_radius_wall)}'
      D_h = '${fparse hx_dia_outer - (2 * hx_radius_wall)}'
      fp = water
      initial_T = 300
    []
  []
  [jct7]
    type = JunctionParallelChannels1Phase
    position = '1 0 0.5'
    connections = 'hx/pri:out down_pipe_2:in'
    volume = 1e-5
  []
  [down_pipe_2]
    type = FlowChannel1Phase
    position = '1 0 0.25'
    orientation = '0 0 -1'
    length = 0.25
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct8]
    type = JunctionOneToOne1Phase
    connections = 'down_pipe_2:out bottom_1:in'
  []
  [bottom_1]
    type = FlowChannel1Phase
    position = '1 0 0'
    orientation = '-1 0 0'
    length = 0.5
    n_elems = 5
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [pump]
    type = Pump1Phase
    position = '0.5 0 0'
    connections = 'bottom_1:out bottom_2:in'
    volume = 1e-4
    A_ref = ${A_pipe}
    head = 0
  []
  [bottom_2]
    type = FlowChannel1Phase
    position = '0.5 0 0'
    orientation = '-1 0 0'
    length = 0.5
    n_elems = 5
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct9]
    type = JunctionOneToOne1Phase
    connections = 'bottom_2:out up_pipe_1:in'
  []
  [inlet_sec]
    type = InletMassFlowRateTemperature1Phase
    input = 'hx/sec:in'
    m_dot = 0
    T = 300
  []
  [outlet_sec]
    type = Outlet1Phase
    input = 'hx/sec:out'
    p = 1e5
  []
[]
[ControlLogic]
  [set_point]
    type = GetFunctionValueControl
    function = ${m_dot_in}
  []
  [pid]
    type = PIDControl
    initial_value = 0.0
    set_point = set_point:value
    input = m_dot_pump
    K_p = 1.
    K_i = 4.
    K_d = 0
  []
  [set_pump_head]
    type = SetComponentRealValueControl
    component = pump
    parameter = head
    value = pid:output
  []
  [m_dot_sec_inlet_ctrl]
    type = GetFunctionValueControl
    function = m_dot_sec_fn
  []
  [set_m_dot_sec_ctrl]
    type = SetComponentRealValueControl
    component = inlet_sec
    parameter = m_dot
    value = m_dot_sec_inlet_ctrl:value
  []
[]
[Postprocessors]
  [power_to_coolant]
    type = ADHeatRateConvection1Phase
    block = core_chan
    P_hf = '${fparse pi *core_dia}'
  []
  [m_dot_pump]
    type = ADFlowJunctionFlux1Phase
    boundary = core_chan:in
    connection_index = 1
    equation = mass
    junction = jct7
  []
  [core_T_out]
    type = SideAverageValue
    boundary = core_chan:out
    variable = T
  []
  [core_p_in]
    type = SideAverageValue
    boundary = core_chan:in
    variable = p
  []
  [core_p_out]
    type = SideAverageValue
    boundary = core_chan:out
    variable = p
  []
  [core_delta_p]
    type = ParsedPostprocessor
    pp_names = 'core_p_in core_p_out'
    expression = 'core_p_in - core_p_out'
  []
  [hx_pri_T_out]
    type = SideAverageValue
    boundary = hx/pri:out
    variable = T
  []
  [hx_sec_T_in]
    type = SideAverageValue
    boundary = inlet_sec
    variable = T
  []
  [hx_sec_T_out]
    type = SideAverageValue
    boundary = outlet_sec
    variable = T
  []
  [m_dot_sec]
    type = ADFlowBoundaryFlux1Phase
    boundary = inlet_sec
    equation = mass
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  start_time = 0
  [TimeStepper]
    type = IterationAdaptiveDT
    dt = 1
  []
  dtmax = 5
  end_time = 500
  line_search = basic
  solve_type = NEWTON
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  nl_rel_tol = 0
  nl_abs_tol = 1e-8
  nl_max_its = 25
[]
[Outputs]
  exodus = true
  [console]
    type = Console
    max_rows = 1
    outlier_variable_norms = false
  []
  print_linear_residuals = false
[]
(modules/combined/test/tests/subchannel_thm_coupling/THM_SCM_coupling_pump.i)
# THM file based on https://mooseframework.inl.gov/modules/thermal_hydraulics/tutorials/single_phase_flow/step05.html
# Used to loosely couple THM with SCM
# This is a simple closed loop with a pump providing pressure head, core, pressurizer and HX.
# THM sends massflux and temperature at the inlet of the core, and pressure at the outlet of the core
# to subchannel. Subchannel returns total pressure drop of the assembly and total power to THM and THM calculates an
# average friction factor for the core region.
T_in = 583.0 # K
press = 2e5 # Pa
SC_core = 0.0004980799633447909 #m2
# core parameters
core_length = 1. # m
core_n_elems = 1
A_core = 0.005 #dummy
# pipe parameters
pipe_dia = '${units 10. cm -> m}'
A_pipe = '${fparse 0.25 * pi * pipe_dia^2}'
# heat exchanger parameters
hx_dia_inner = '${units 12. cm -> m}'
hx_wall_thickness = '${units 5. mm -> m}'
hx_dia_outer = '${units 50. cm -> m}'
hx_radius_wall = '${fparse hx_dia_inner / 2. + hx_wall_thickness}'
hx_length = 1.5 # m
hx_n_elems = 25
m_dot_sec_in = 1. # kg/s
[GlobalParams]
  initial_p = ${press}
  initial_vel = 0.0001
  initial_T = ${T_in}
  initial_vel_x = 0
  initial_vel_y = 0
  initial_vel_z = 0
  gravity_vector = '0 0 0'
  rdg_slope_reconstruction = minmod
  scaling_factor_1phase = '1 1e-2 1e-4'
  scaling_factor_rhoV = 1
  scaling_factor_rhouV = 1e-2
  scaling_factor_rhovV = 1e-2
  scaling_factor_rhowV = 1e-2
  scaling_factor_rhoEV = 1e-4
  closures = thm_closures
  fp = sodium_eos
[]
[Functions]
  [q_wall_fn]
    type = ParsedFunction
    symbol_names = 'core_power length'
    symbol_values = 'core_power  ${core_length}'
    expression = 'core_power/length'
  []
[]
[FluidProperties]
  [water]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    cv = 1816.0
    q = -1.167e6
    p_inf = 1.0e9
    q_prime = 0
  []
  [sodium_eos]
    type = StiffenedGasFluidProperties
    gamma = 1.24
    cv = 1052.8
    q = -2.6292e+05
    p_inf = 1.1564e+08
    q_prime = 0
    mu = 3.222e-04
    k = 73.82
  []
[]
[Closures]
  [thm_closures]
    type = Closures1PhaseTHM
  []
  [none_closures]
    type = Closures1PhaseNone
  []
[]
[Materials]
  [f_mat]
    type = ADParsedMaterial
    property_name = f_D
    postprocessor_names = 'core_f'
    expression = 'core_f'
    block = 'core_chan'
  []
[]
[HeatStructureMaterials]
  [steel]
    type = SolidMaterialProperties
    rho = 8050
    k = 45
    cp = 466
  []
[]
[Components]
  [up_pipe_1]
    type = FlowChannel1Phase
    position = '0 0 -0.5'
    orientation = '0 0 1'
    length = 0.5
    n_elems = 15
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct1]
    type = JunctionParallelChannels1Phase
    position = '0 0 0'
    connections = 'up_pipe_1:out core_chan:in'
    volume = 1e-5
  []
  [core_chan]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '0 0 1'
    length = ${core_length}
    n_elems = ${core_n_elems}
    A = ${A_core}
    closures = none_closures
  []
  [core_ht]
    type = HeatTransferFromHeatFlux1Phase
    flow_channel = core_chan
    q_wall = q_wall_fn
    P_hf = 1
  []
  [jct2]
    type = JunctionParallelChannels1Phase
    position = '0 0 1'
    connections = 'core_chan:out up_pipe_2:in'
    volume = 1e-5
  []
  [up_pipe_2]
    type = FlowChannel1Phase
    position = '0 0 1'
    orientation = '0 0 1'
    length = 0.5
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct3]
    type = JunctionOneToOne1Phase
    connections = 'up_pipe_2:out top_pipe_1:in'
  []
  [top_pipe_1]
    type = FlowChannel1Phase
    position = '0 0 1.5'
    orientation = '1 0 0'
    length = 0.5
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [top_pipe_2]
    type = FlowChannel1Phase
    position = '0.5 0 1.5'
    orientation = '1 0 0'
    length = 0.5
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct4]
    type = VolumeJunction1Phase
    position = '0.5 0 1.5'
    volume = 1e-5
    connections = 'top_pipe_1:out top_pipe_2:in press_pipe:in'
  []
  [press_pipe]
    type = FlowChannel1Phase
    position = '0.5 0 1.5'
    orientation = '0 1 0'
    length = 0.2
    n_elems = 5
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [pressurizer]
    type = InletStagnationPressureTemperature1Phase
    p0 = ${press}
    T0 = 580
    input = press_pipe:out
  []
  [jct5]
    type = JunctionOneToOne1Phase
    connections = 'top_pipe_2:out down_pipe_1:in'
  []
  [down_pipe_1]
    type = FlowChannel1Phase
    position = '1 0 1.5'
    orientation = '0 0 -1'
    length = 0.25
    A = ${A_pipe}
    n_elems = 5
  []
  [jct6]
    type = JunctionParallelChannels1Phase
    position = '1 0 1.25'
    connections = 'down_pipe_1:out hx/pri:in'
    volume = 1e-5
  []
  [hx]
    [pri]
      type = FlowChannel1Phase
      position = '1 0 1.25'
      orientation = '0 0 -1'
      length = ${hx_length}
      n_elems = ${hx_n_elems}
      roughness = 1e-5
      A = '${fparse pi * hx_dia_inner * hx_dia_inner / 4.}'
      D_h = ${hx_dia_inner}
    []
    [ht_pri]
      type = HeatTransferFromHeatStructure1Phase
      hs = hx/wall
      hs_side = inner
      flow_channel = hx/pri
      P_hf = '${fparse pi * hx_dia_inner}'
    []
    [wall]
      type = HeatStructureCylindrical
      position = '1 0 1.25'
      orientation = '0 0 -1'
      length = ${hx_length}
      n_elems = ${hx_n_elems}
      widths = '${hx_wall_thickness}'
      n_part_elems = '3'
      materials = 'steel'
      names = '0'
      inner_radius = '${fparse hx_dia_inner / 2.}'
    []
    [ht_sec]
      type = HeatTransferFromHeatStructure1Phase
      hs = hx/wall
      hs_side = outer
      flow_channel = hx/sec
      P_hf = '${fparse 2 * pi * hx_radius_wall}'
    []
    [sec]
      type = FlowChannel1Phase
      position = '${fparse 1 + hx_wall_thickness} 0 -0.25'
      orientation = '0 0 1'
      length = ${hx_length}
      n_elems = ${hx_n_elems}
      A = '${fparse pi * (hx_dia_outer * hx_dia_outer / 4. - hx_radius_wall * hx_radius_wall)}'
      D_h = '${fparse hx_dia_outer - (2 * hx_radius_wall)}'
      fp = water
      initial_T = 300
    []
  []
  [jct7]
    type = JunctionParallelChannels1Phase
    position = '1 0 -0.25'
    connections = 'hx/pri:out down_pipe_2:in'
    volume = 1e-5
  []
  [down_pipe_2]
    type = FlowChannel1Phase
    position = '1 0 -0.25'
    orientation = '0 0 -1'
    length = 0.25
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct8]
    type = JunctionOneToOne1Phase
    connections = 'down_pipe_2:out bottom_1:in'
  []
  [bottom_1]
    type = FlowChannel1Phase
    position = '1 0 -0.5'
    orientation = '-1 0 0'
    length = 0.5
    n_elems = 5
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [pump]
    type = Pump1Phase
    position = '0.5 0 -0.5'
    connections = 'bottom_1:out bottom_2:in'
    volume = 1e-4
    A_ref = ${A_pipe}
    head = 3.56
  []
  [bottom_2]
    type = FlowChannel1Phase
    position = '0.5 0 -0.5'
    orientation = '-1 0 0'
    length = 0.5
    n_elems = 5
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct9]
    type = JunctionOneToOne1Phase
    connections = 'bottom_2:out up_pipe_1:in'
  []
  [inlet_sec]
    type = InletMassFlowRateTemperature1Phase
    input = 'hx/sec:in'
    m_dot = ${m_dot_sec_in}
    T = 300
  []
  [outlet_sec]
    type = Outlet1Phase
    input = 'hx/sec:out'
    p = 1e5
  []
[]
[Postprocessors]
  [power_to_coolant]
    type = ADHeatRateDirectFlowChannel
    q_wall_prop = q_wall
    block = core_chan
    P_hf = 1
  []
  [core_T_out]
    type = SideAverageValue
    boundary = core_chan:out
    variable = T
  []
  [T_out]
    type = SideAverageValue
    boundary = bottom_1:out
    variable = T
  []
  [core_p_in]
    type = SideAverageValue
    boundary = up_pipe_1:out
    variable = p
  []
  [core_p_out]
    type = SideAverageValue
    boundary = up_pipe_2:in
    variable = p
  []
  [core_delta_p]
    type = ParsedPostprocessor
    pp_names = 'core_p_in core_p_out'
    function = 'core_p_in - core_p_out'
  []
  [hx_pri_T_out]
    type = SideAverageValue
    boundary = hx/pri:out
    variable = T
  []
  [hx_sec_T_in]
    type = SideAverageValue
    boundary = inlet_sec
    variable = T
  []
  [hx_sec_T_out]
    type = SideAverageValue
    boundary = outlet_sec
    variable = T
  []
  [m_dot_sec]
    type = ADFlowBoundaryFlux1Phase
    boundary = inlet_sec
    equation = mass
  []
  ############## Friction Factor Calculation #############
  [av_rhouA]
    type = ElementAverageValue
    variable = 'rhouA'
    block = 'core_chan'
  []
  [av_rho]
    type = ElementAverageValue
    variable = 'rho'
    block = 'core_chan'
  []
  [Kloss]
    type = ParsedPostprocessor
    pp_names = 'core_delta_p_tgt av_rhouA av_rho'
    function = '2.0 * core_delta_p_tgt * av_rho * ${A_core} * ${A_core} / (av_rhouA * av_rhouA)'
  []
  [Dh]
    type = ADElementAverageMaterialProperty
    mat_prop = D_h
    block = core_chan
  []
  [core_f]
    type = ParsedPostprocessor
    pp_names = 'Kloss Dh'
    function = 'Kloss * Dh / ${core_length}'
  []
  ### INFO to send to SC
  [outlet_pressure]
    type = SideAverageValue
    boundary = up_pipe_2:in
    variable = p
  []
  [inlet_mass_flow_rate]
    type = ADFlowJunctionFlux1Phase
    boundary = up_pipe_1:out
    connection_index = 0
    equation = mass
    junction = jct1
  []
  [inlet_temperature]
    type = SideAverageValue
    boundary = up_pipe_1:out
    variable = T
  []
  [inlet_mass_flux]
    type = ParsedPostprocessor
    pp_names = 'inlet_mass_flow_rate'
    function = 'abs(inlet_mass_flow_rate/${SC_core})'
  []
  #####
  ##### Info received from subchannel
  [core_delta_p_tgt]
    type = Receiver
    default = 100
  []
  [core_power]
    type = Receiver
    default = 100
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  start_time = 0
  [TimeStepper]
    type = IterationAdaptiveDT
    dt = 2
  []
  dtmax = 50
  end_time = 10
  line_search = basic
  solve_type = NEWTON
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  nl_rel_tol = 1e-7
  nl_abs_tol = 1e-7
  nl_max_its = 25
  fixed_point_min_its = 1
  fixed_point_max_its = 5
  accept_on_max_fixed_point_iteration = true
  auto_advance = true
  relaxation_factor = 0.5
[]
[Outputs]
  csv = true
  [console]
    type = Console
    max_rows = 1
    outlier_variable_norms = false
  []
  print_linear_residuals = false
[]
################################################################################
# A multiapp that couples THM to subchannel
################################################################################
[MultiApps]
  # active = ''
  [subchannel]
    type = FullSolveMultiApp
    input_files = 'subchannel.i'
    execute_on = 'timestep_end'
    positions = '0 0 0'
    max_procs_per_app = 1
    output_in_position = true
    bounding_box_padding = '0 0 0.1'
  []
[]
[Transfers]
  # active = ''
  [pressure_drop_transfer] # Get pressure drop to THM from subchannel
    type = MultiAppPostprocessorTransfer
    from_multi_app = subchannel
    from_postprocessor = total_pressure_drop_SC
    to_postprocessor = core_delta_p_tgt
    reduction_type = average
    execute_on = 'timestep_end'
  []
  [power_transfer] # Get Total power to THM from subchannel
    type = MultiAppPostprocessorTransfer
    from_multi_app = subchannel
    from_postprocessor = Total_power
    to_postprocessor = core_power
    reduction_type = average
    execute_on = 'timestep_end'
  []
  [mass_flux_tranfer] # Send mass_flux at the inlet of THM core to subchannel
    type = MultiAppPostprocessorTransfer
    to_multi_app = subchannel
    from_postprocessor = inlet_mass_flux
    to_postprocessor = report_mass_flux_inlet
    execute_on = 'timestep_end'
  []
  [outlet_pressure_tranfer] # Send pressure at the outlet of THM core to subchannel
    type = MultiAppPostprocessorTransfer
    to_multi_app = subchannel
    from_postprocessor = outlet_pressure
    to_postprocessor = report_pressure_outlet
    execute_on = 'timestep_end'
  []
  [inlet_temperature_transfer]
    type = MultiAppPostprocessorTransfer
    to_multi_app = subchannel
    from_postprocessor = inlet_temperature
    to_postprocessor = report_temperature_inlet
    execute_on = 'timestep_end'
  []
[]
(modules/thermal_hydraulics/test/tests/closures/THM_1phase/thm1phase.i)
D = 0.1
A = '${fparse (1./4.)*pi*D^2}'
P_hf = '${fparse pi*D}'
D_h = '${fparse 4*A/P_hf}'
mdot = 0.04
file_base = 'db_churchill'
[GlobalParams]
  gravity_vector = '0 0 0'
  initial_vel = 0.003
  initial_p = 1e5
  initial_T = 300
  D_h = ${D_h}
  A = ${A}
  P_hf = ${P_hf}
  m_dot = ${mdot}
  closures = thm
  execute_on = 'initial timestep_begin'
[]
[FluidProperties]
  [water]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    cv = 1816.0
    q = -1.167e6
    p_inf = 1.0e9
    q_prime = 0
    k = 0.56361
    mu = 8.84e-05
  []
[]
[Closures]
  [thm]
    type = Closures1PhaseTHM
    wall_htc_closure = dittus_boelter
    wall_ff_closure = churchill
  []
[]
[Components]
  [pipe]
    type = FlowChannel1Phase
    fp = water
    position = '0 0 0'
    orientation = '1 0 0'
    length = 1
    n_elems = 10
  []
  #--------------Pipe BCs-------------#
  [inlet]
    type = InletMassFlowRateTemperature1Phase
    input = 'pipe:in'
    T = 300
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe:out'
    p = 1e5
  []
  [ht]
    type = HeatTransferFromSpecifiedTemperature1Phase
    flow_channel = 'pipe'
    T_wall = 500
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  num_steps = 1
  dt = 1e-5
[]
[Postprocessors]
  [Hw]
    type = ADElementAverageMaterialProperty
    mat_prop = Hw
  []
  [f]
    type = ADElementAverageMaterialProperty
    mat_prop = f_D
    block = pipe
  []
[]
[Outputs]
  csv = true
  file_base = ${file_base}
[]
(modules/thermal_hydraulics/tutorials/single_phase_flow/04_loop.i)
T_in = 300. # K
m_dot_in = 1e-2 # kg/s
press = 10e5 # Pa
# core parameters
core_length = 1. # m
core_n_elems = 25
core_dia = '${units 2. cm -> m}'
core_pitch = '${units 8.7 cm -> m}'
# pipe parameters
pipe_dia = '${units 10. cm -> m}'
A_pipe = '${fparse 0.25 * pi * pipe_dia^2}'
A_core = '${fparse core_pitch^2 - 0.25 *pi * core_dia^2}'
P_wet_core = '${fparse 4*core_pitch + pi * core_dia}'
Dh_core = '${fparse 4 * A_core / P_wet_core}'
tot_power = 2000 # W
[GlobalParams]
  initial_p = ${press}
  initial_vel = 0.0001
  initial_T = ${T_in}
  initial_vel_x = 0
  initial_vel_y = 0
  initial_vel_z = 0
  gravity_vector = '0 0 0'
  rdg_slope_reconstruction = minmod
  scaling_factor_1phase = '1 1e-2 1e-4'
  scaling_factor_rhoV = 1
  scaling_factor_rhouV = 1e-2
  scaling_factor_rhovV = 1e-2
  scaling_factor_rhowV = 1e-2
  scaling_factor_rhoEV = 1e-4
  closures = simple_closures
  fp = he
[]
[FluidProperties]
  [he]
    type = IdealGasFluidProperties
    molar_mass = 4e-3
    gamma = 1.67
    k = 0.2556
    mu = 3.22639e-5
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseTHM
  []
[]
[SolidProperties]
  [steel]
    type = ThermalFunctionSolidProperties
    rho = 8050
    k = 45
    cp = 466
  []
[]
[Components]
  [total_power]
    type = TotalPower
    power = ${tot_power}
  []
  [up_pipe_1]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '0 0 1'
    length = 0.5
    n_elems = 15
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct1]
    type = JunctionParallelChannels1Phase
    position = '0 0 0.5'
    connections = 'up_pipe_1:out core_chan:in'
    volume = 1e-5
  []
  [core_chan]
    type = FlowChannel1Phase
    position = '0 0 0.5'
    orientation = '0 0 1'
    length = ${core_length}
    n_elems = ${core_n_elems}
    roughness = .0001
    A = '${A_core}'
    D_h = ${Dh_core}
  []
  [core_hs]
    type = HeatStructureCylindrical
    position = '0 0 0.5'
    orientation = '0 0 1'
    length = ${core_length}
    n_elems = ${core_n_elems}
    names = 'block'
    widths = '${fparse core_dia / 2.}'
    solid_properties = 'steel'
    solid_properties_T_ref = '300'
    n_part_elems = 3
  []
  [core_heating]
    type = HeatSourceFromTotalPower
    hs = core_hs
    regions = block
    power = total_power
  []
  [core_ht]
    type = HeatTransferFromHeatStructure1Phase
    flow_channel = core_chan
    hs = core_hs
    hs_side = outer
    P_hf = '${fparse pi * core_dia}'
  []
  [jct2]
    type = JunctionParallelChannels1Phase
    position = '0 0 1.5'
    connections = 'core_chan:out up_pipe_2:in'
    volume = 1e-5
  []
  [up_pipe_2]
    type = FlowChannel1Phase
    position = '0 0 1.5'
    orientation = '0 0 1'
    length = 0.5
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct3]
    type = JunctionOneToOne1Phase
    connections = 'up_pipe_2:out top_pipe_1:in'
  []
  [top_pipe_1]
    type = FlowChannel1Phase
    position = '0 0 2'
    orientation = '1 0 0'
    length = 0.5
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [top_pipe_2]
    type = FlowChannel1Phase
    position = '0.5 0 2'
    orientation = '1 0 0'
    length = 0.5
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct4]
    type = VolumeJunction1Phase
    position = '0.5 0 2'
    volume = 1e-5
    connections = 'top_pipe_1:out top_pipe_2:in press_pipe:in'
  []
  [press_pipe]
    type = FlowChannel1Phase
    position = '0.5 0 2'
    orientation = '0 0 1'
    length = 0.2
    n_elems = 5
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [pressurizer]
    type = InletStagnationPressureTemperature1Phase
    p0 = ${press}
    T0 = ${T_in}
    input = press_pipe:out
  []
  [jct5]
    type = JunctionOneToOne1Phase
    connections = 'top_pipe_2:out down_pipe_1:in'
  []
  [down_pipe_1]
    type = FlowChannel1Phase
    position = '1 0 2'
    orientation = '0 0 -1'
    length = 0.25
    A = ${A_pipe}
    n_elems = 5
  []
  [jct6]
    type = JunctionOneToOne1Phase
    connections = 'down_pipe_1:out cooling_pipe:in'
  []
  [cooling_pipe]
    type = FlowChannel1Phase
    position = '1 0 1.75'
    orientation = '0 0 -1'
    length = 1.5
    n_elems = 25
    A = ${A_pipe}
  []
  [cold_wall]
    type = HeatTransferFromSpecifiedTemperature1Phase
    flow_channel = cooling_pipe
    T_wall = 300
    P_hf = '${fparse pi * pipe_dia}'
  []
  [jct7]
    type = JunctionOneToOne1Phase
    connections = 'cooling_pipe:out down_pipe_2:in'
  []
  [down_pipe_2]
    type = FlowChannel1Phase
    position = '1 0 0.25'
    orientation = '0 0 -1'
    length = 0.25
    n_elems = 10
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct8]
    type = JunctionOneToOne1Phase
    connections = 'down_pipe_2:out bottom_1:in'
  []
  [bottom_1]
    type = FlowChannel1Phase
    position = '1 0 0'
    orientation = '-1 0 0'
    length = 0.5
    n_elems = 5
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [pump]
    type = Pump1Phase
    position = '0.5 0 0'
    connections = 'bottom_1:out bottom_2:in'
    volume = 1e-4
    A_ref = ${A_pipe}
    head = 0
  []
  [bottom_2]
    type = FlowChannel1Phase
    position = '0.5 0 0'
    orientation = '-1 0 0'
    length = 0.5
    n_elems = 5
    A = ${A_pipe}
    D_h = ${pipe_dia}
  []
  [jct10]
    type = JunctionOneToOne1Phase
    connections = 'bottom_2:out up_pipe_1:in'
  []
[]
[ControlLogic]
  [set_point]
    type = GetFunctionValueControl
    function = ${m_dot_in}
  []
  [pid]
    type = PIDControl
    initial_value = 0
    set_point = set_point:value
    input = m_dot_pump
    K_p = 1.
    K_i = 4.
    K_d = 0
  []
  [set_pump_head]
    type = SetComponentRealValueControl
    component = pump
    parameter = head
    value = pid:output
  []
[]
[Postprocessors]
  [power_to_coolant]
    type = ADHeatRateConvection1Phase
    block = core_chan
    P_hf = '${fparse pi *core_dia}'
  []
  [m_dot_pump]
    type = ADFlowJunctionFlux1Phase
    boundary = core_chan:in
    connection_index = 1
    equation = mass
    junction = jct7
  []
  [core_T_out]
    type = SideAverageValue
    boundary = core_chan:out
    variable = T
  []
  [core_p_in]
    type = SideAverageValue
    boundary = core_chan:in
    variable = p
  []
  [core_p_out]
    type = SideAverageValue
    boundary = core_chan:out
    variable = p
  []
  [core_delta_p]
    type = ParsedPostprocessor
    pp_names = 'core_p_in core_p_out'
    expression = 'core_p_in - core_p_out'
  []
  [hx_pri_T_out]
    type = SideAverageValue
    boundary = cooling_pipe:out
    variable = T
  []
  [pump_head]
    type = RealComponentParameterValuePostprocessor
    component = pump
    parameter = head
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  start_time = 0
  [TimeStepper]
    type = IterationAdaptiveDT
    dt = 1
  []
  dtmax = 5
  end_time = 500
  line_search = basic
  solve_type = NEWTON
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  nl_rel_tol = 0
  nl_abs_tol = 1e-8
  nl_max_its = 25
[]
[Outputs]
  exodus = true
  [console]
    type = Console
    max_rows = 1
    outlier_variable_norms = false
  []
  print_linear_residuals = false
[]