- boundaryThe list of boundary IDs from the mesh where this object applies
C++ Type:std::vector<BoundaryName>
Controllable:No
Description:The list of boundary IDs from the mesh where this object applies
 - equationEquation for which to query flux vector
C++ Type:MooseEnum
Controllable:No
Description:Equation for which to query flux vector
 
ADFlowBoundaryFlux1Phase
Retrieves an entry of a flux vector for a connection attached to a 1-phase junction
This object can be used to get the flux for either of the mass, momentum and energy equations. The flux is computed by an AD boundary flux user object. The boundary user object is retrieved using the boundary name specified in the "boundary" parameter.
Input Parameters
- variablesrhoA rhouA rhoEA A Single-phase flow variables
Default:rhoA rhouA rhoEA A
C++ Type:std::vector<VariableName>
Unit:(no unit assumed)
Controllable:No
Description:Single-phase flow variables
 
Optional Parameters
- allow_duplicate_execution_on_initialFalseIn the case where this UserObject is depended upon by an initial condition, allow it to be executed twice during the initial setup (once before the IC and again after mesh adaptivity (if applicable).
Default:False
C++ Type:bool
Controllable:No
Description:In the case where this UserObject is depended upon by an initial condition, allow it to be executed twice during the initial setup (once before the IC and again after mesh adaptivity (if applicable).
 - execute_onTIMESTEP_ENDThe list of flag(s) indicating when this object should be executed. For a description of each flag, see https://mooseframework.inl.gov/source/interfaces/SetupInterface.html.
Default:TIMESTEP_END
C++ Type:ExecFlagEnum
Options:XFEM_MARK, FORWARD, ADJOINT, HOMOGENEOUS_FORWARD, ADJOINT_TIMESTEP_BEGIN, ADJOINT_TIMESTEP_END, NONE, INITIAL, LINEAR, LINEAR_CONVERGENCE, NONLINEAR, NONLINEAR_CONVERGENCE, POSTCHECK, TIMESTEP_END, TIMESTEP_BEGIN, MULTIAPP_FIXED_POINT_END, MULTIAPP_FIXED_POINT_BEGIN, MULTIAPP_FIXED_POINT_CONVERGENCE, FINAL, CUSTOM, TRANSFER
Controllable:No
Description:The list of flag(s) indicating when this object should be executed. For a description of each flag, see https://mooseframework.inl.gov/source/interfaces/SetupInterface.html.
 - execution_order_group0Execution order groups are executed in increasing order (e.g., the lowest number is executed first). Note that negative group numbers may be used to execute groups before the default (0) group. Please refer to the user object documentation for ordering of user object execution within a group.
Default:0
C++ Type:int
Controllable:No
Description:Execution order groups are executed in increasing order (e.g., the lowest number is executed first). Note that negative group numbers may be used to execute groups before the default (0) group. Please refer to the user object documentation for ordering of user object execution within a group.
 - force_postauxFalseForces the UserObject to be executed in POSTAUX
Default:False
C++ Type:bool
Controllable:No
Description:Forces the UserObject to be executed in POSTAUX
 - force_preauxFalseForces the UserObject to be executed in PREAUX
Default:False
C++ Type:bool
Controllable:No
Description:Forces the UserObject to be executed in PREAUX
 - force_preicFalseForces the UserObject to be executed in PREIC during initial setup
Default:False
C++ Type:bool
Controllable:No
Description:Forces the UserObject to be executed in PREIC during initial setup
 
Execution Scheduling 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:Yes
Description:Set the enabled status of the MooseObject.
 - outputsVector of output names where you would like to restrict the output of variables(s) associated with this object
C++ Type:std::vector<OutputName>
Controllable:No
Description:Vector of output names where you would like to restrict the output of variables(s) associated with this object
 - use_displaced_meshFalseWhether or not this object should use the displaced mesh for computation. Note that in the case this is true but no displacements are provided in the Mesh block the undisplaced mesh will still be used.
Default:False
C++ Type:bool
Controllable:No
Description:Whether or not this object should use the displaced mesh for computation. Note that in the case this is true but no displacements are provided in the Mesh block the undisplaced mesh will still be used.
 
Advanced Parameters
- prop_getter_suffixAn optional suffix parameter that can be appended to any attempt to retrieve/get material properties. The suffix will be prepended with a '_' character.
C++ Type:MaterialPropertyName
Unit:(no unit assumed)
Controllable:No
Description:An optional suffix parameter that can be appended to any attempt to retrieve/get material properties. The suffix will be prepended with a '_' character.
 - use_interpolated_stateFalseFor the old and older state use projected material properties interpolated at the quadrature points. To set up projection use the ProjectedStatefulMaterialStorageAction.
Default:False
C++ Type:bool
Controllable:No
Description:For the old and older state use projected material properties interpolated at the quadrature points. To set up projection use the ProjectedStatefulMaterialStorageAction.
 
Material Property Retrieval Parameters
Input Files
- (modules/thermal_hydraulics/test/tests/components/heat_transfer_from_heat_structure_3d/phy.conservation_ss.i)
 - (modules/thermal_hydraulics/test/tests/components/heat_transfer_from_heat_structure_1phase/phy.energy_heatstructure_ss_1phase.i)
 - (modules/thermal_hydraulics/test/tests/components/junction_parallel_channels_1phase/junction_with_calorifically_imperfect_gas.i)
 - (modules/combined/test/tests/subchannel_thm_coupling/THM_SCM_coupling.i)
 - (modules/thermal_hydraulics/tutorials/single_phase_flow/05_secondary_side.i)
 - (modules/thermal_hydraulics/test/tests/components/simple_turbine_1phase/phy.conservation.i)
 - (modules/thermal_hydraulics/test/tests/components/volume_junction_1phase/junction_with_calorifically_imperfect_gas.i)
 - (modules/thermal_hydraulics/test/tests/postprocessors/flow_boundary_flux_1phase/test.i)
 - (modules/combined/test/tests/subchannel_thm_coupling/THM_SCM_coupling_pump.i)
 - (modules/thermal_hydraulics/tutorials/single_phase_flow/06_custom_closures.i)
 - (modules/thermal_hydraulics/test/tests/postprocessors/flow_junction_flux_1phase/flow_junction_flux_1phase.i)
 
boundary
C++ Type:std::vector<BoundaryName>
Controllable:No
Description:The list of boundary IDs from the mesh where this object applies
(modules/thermal_hydraulics/test/tests/components/heat_transfer_from_heat_structure_3d/phy.conservation_ss.i)
# Testing energy conservation at steady state
P_hf = ${fparse 0.6 * sin (pi/24)}
[GlobalParams]
  scaling_factor_1phase = '1 1 1e-3'
  gravity_vector = '0 0 0'
[]
[Materials]
  [mat]
    type = ADGenericConstantMaterial
    block = 'blk:0'
    prop_names = 'density specific_heat thermal_conductivity'
    prop_values = '1000 10 30'
  []
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    cv = 1816.0
    q = -1.167e6
    p_inf = 1.0e9
    q_prime = 0
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [in1]
    type = InletVelocityTemperature1Phase
    input = 'fch1:in'
    vel = 1
    T = 300
  []
  [fch1]
    type = FlowChannel1Phase
    position = '0.15 0 0'
    orientation = '0 0 1'
    fp = fp
    n_elems = 10
    length = 1
    initial_T = 300
    initial_p = 1.01e5
    initial_vel = 1
    closures = simple_closures
    A = 0.00314159
    f = 0.0
  []
  [out1]
    type = Outlet1Phase
    input = 'fch1:out'
    p = 1.01e5
  []
  [in2]
    type = InletVelocityTemperature1Phase
    input = 'fch2:in'
    vel = 1
    T = 350
  []
  [fch2]
    type = FlowChannel1Phase
    position = '0 0.15 0'
    orientation = '0 0 1'
    fp = fp
    n_elems = 10
    length = 1
    initial_T = 350
    initial_p = 1.01e5
    initial_vel = 1
    closures = simple_closures
    A = 0.00314159
    f = 0
  []
  [out2]
    type = Outlet1Phase
    input = 'fch2:out'
    p = 1.01e5
  []
  [blk]
    type = HeatStructureFromFile3D
    file = mesh.e
    position = '0 0 0'
    initial_T = 325
  []
  [ht]
    type = HeatTransferFromHeatStructure3D1Phase
    flow_channels = 'fch1 fch2'
    hs = blk
    boundary = blk:rmin
    Hw = 10000
    P_hf = ${P_hf}
  []
[]
[Postprocessors]
  [E_in1]
    type = ADFlowBoundaryFlux1Phase
    boundary = in1
    equation = energy
    execute_on = 'initial timestep_end'
  []
  [E_out1]
    type = ADFlowBoundaryFlux1Phase
    boundary = out1
    equation = energy
    execute_on = 'initial timestep_end'
  []
  [hf_pipe1]
    type = ADHeatRateConvection1Phase
    block = fch1
    T_wall = T_wall
    T = T
    Hw = Hw
    P_hf = ${P_hf}
    execute_on = 'initial timestep_end'
  []
  [E_diff1]
    type = DifferencePostprocessor
    value1 = E_in1
    value2 = E_out1
    execute_on = 'initial timestep_end'
  []
  [E_conservation1]
    type = SumPostprocessor
    values = 'E_diff1 hf_pipe1'
  []
  [E_in2]
    type = ADFlowBoundaryFlux1Phase
    boundary = in2
    equation = energy
    execute_on = 'initial timestep_end'
  []
  [E_out2]
    type = ADFlowBoundaryFlux1Phase
    boundary = out2
    equation = energy
    execute_on = 'initial timestep_end'
  []
  [hf_pipe2]
    type = ADHeatRateConvection1Phase
    block = fch2
    T_wall = T_wall
    T = T
    Hw = Hw
    P_hf = ${P_hf}
    execute_on = 'initial timestep_end'
  []
  [E_diff2]
    type = DifferencePostprocessor
    value1 = E_in2
    value2 = E_out2
    execute_on = 'initial timestep_end'
  []
  [E_conservation2]
    type = SumPostprocessor
    values = 'E_diff2 hf_pipe2'
  []
  [E_conservation_hs]
    type = SumPostprocessor
    values = 'hf_pipe1 hf_pipe2'
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = bdf2
  dt = 5
  end_time = 100
  solve_type = NEWTON
  line_search = basic
  abort_on_solve_fail = true
  nl_abs_tol = 1e-8
[]
[Outputs]
  file_base = 'phy.conservation_ss'
  [csv]
    type = CSV
    show = 'E_conservation1 E_conservation2 E_conservation_hs'
    execute_on = 'FINAL'
  []
[]
(modules/thermal_hydraulics/test/tests/components/heat_transfer_from_heat_structure_1phase/phy.energy_heatstructure_ss_1phase.i)
# This test tests conservation of energy at steady state for 1-phase flow when a
# heat structure is used. Conservation is checked by comparing the integral of
# the heat flux against the difference of the boundary fluxes.
[GlobalParams]
  initial_p = 7.0e6
  initial_vel = 0
  initial_T = 513
  gravity_vector = '0.0 0.0 0.0'
  scaling_factor_1phase = '1 1 1e-4'
  closures = simple_closures
[]
[FluidProperties]
  [eos]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    q = -1167e3
    q_prime = 0
    p_inf = 1.e9
    cv = 1816
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[SolidProperties]
  [fuel-mat]
    type = ThermalFunctionSolidProperties
    k = 3.7
    cp = 3.e2
    rho = 10.42e3
  []
  [gap-mat]
    type = ThermalFunctionSolidProperties
    k = 0.7
    cp = 5e3
    rho = 1.0
  []
  [clad-mat]
    type = ThermalFunctionSolidProperties
    k = 16
    cp = 356.
    rho = 6.551400E+03
  []
[]
[Components]
  [reactor]
    type = TotalPower
    power = 1e3
  []
  [core:pipe]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '0 0 1'
    length = 3.66
    n_elems = 10
    A = 1.907720E-04
    D_h = 1.698566E-02
    f = 0.0
    fp = eos
  []
  [core:solid]
    type = HeatStructureCylindrical
    position = '0 -0.0071501 0'
    orientation = '0 0 1'
    length = 3.66
    n_elems = 10
    names =  'FUEL GAP CLAD'
    widths = '6.057900E-03  1.524000E-04  9.398000E-04'
    n_part_elems = '5 1 2'
    solid_properties = 'fuel-mat gap-mat clad-mat'
    solid_properties_T_ref = '300 300 300'
    initial_T = 513
  []
  [core:hgen]
    type = HeatSourceFromTotalPower
    hs = core:solid
    regions = 'FUEL'
    power = reactor
    power_fraction = 1
  []
  [core:hx]
    type = HeatTransferFromHeatStructure1Phase
    flow_channel = core:pipe
    hs   = core:solid
    hs_side = outer
    Hw = 1.0e4
    P_hf = 4.4925e-2
  []
  [inlet]
    type = InletDensityVelocity1Phase
    input = 'core:pipe:in'
    rho = 817.382210128610836
    vel = 2.4
  []
  [outlet]
    type = Outlet1Phase
    input = 'core:pipe:out'
    p = 7e6
  []
[]
[Postprocessors]
  [E_in]
    type = ADFlowBoundaryFlux1Phase
    boundary = inlet
    equation = energy
    execute_on = 'initial timestep_end'
  []
  [E_out]
    type = ADFlowBoundaryFlux1Phase
    boundary = outlet
    equation = energy
    execute_on = 'initial timestep_end'
  []
  [hf_pipe]
    type = ADHeatRateConvection1Phase
    block = core:pipe
    T_wall = T_wall
    T = T
    Hw = Hw
    P_hf = P_hf
    execute_on = 'initial timestep_end'
  []
  [E_diff]
    type = DifferencePostprocessor
    value1 = E_in
    value2 = E_out
    execute_on = 'initial timestep_end'
  []
  [E_conservation]
    type = SumPostprocessor
    values = 'E_diff hf_pipe'
  []
[]
[Preconditioning]
  [SMP_PJFNK]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  abort_on_solve_fail = true
  dt = 5
  solve_type = 'NEWTON'
  line_search = 'basic'
  nl_rel_tol = 1e-8
  nl_abs_tol = 1e-8
  nl_max_its = 50
  l_tol = 1e-3
  l_max_its = 60
  start_time = 0
  end_time = 260
[]
[Outputs]
  [out]
    type = CSV
    execute_on = final
    show = 'E_conservation'
  []
  [console]
    type = Console
    show = 'E_conservation'
  []
[]
(modules/thermal_hydraulics/test/tests/components/junction_parallel_channels_1phase/junction_with_calorifically_imperfect_gas.i)
# This input file tests compatibility of JunctionParallelChannels1Phase and CaloricallyImperfectGas.
# Loss coefficient is applied in first junction.
# Expected pressure drop from form loss ~0.5*K*rho_in*vel_in^2=0.5*100*3.219603*1 = 160.9 Pa
# Pressure drop from averall flow area change ~ 21.9 Pa
# Expected pressure drop ~ 182.8 Pa
T_in = 523.0
vel = 1
p_out = 7e6
[GlobalParams]
  initial_p = ${p_out}
  initial_vel = ${vel}
  initial_T = ${T_in}
  gravity_vector = '0 0 0'
  closures = simple_closures
  n_elems = 3
  f = 0
  scaling_factor_1phase = '1 1 1e-5'
  scaling_factor_rhoV = '1e2'
  scaling_factor_rhowV = '1e-2'
  scaling_factor_rhoEV = '1e-5'
[]
[Functions]
  [e_fn]
    type = PiecewiseLinear
    x = '100   280 300 350 400 450 500 550 600 700 800 900 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 5000'
    y = '783.9 2742.3 2958.6 3489.2 4012.7 4533.3 5053.8 5574 6095.1 7140.2 8192.9 9256.3 10333.6 12543.9 14836.6 17216.3 19688.4 22273.7 25018.3 28042.3 31544.2 35818.1 41256.5 100756.5'
    scale_factor = 1e3
  []
  [mu_fn]
    type = PiecewiseLinear
    x = '100   280 300 350 400 450 500 550 600 700 800 900 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 5000'
    y = '85.42 85.42 89.53 99.44 108.9 117.98 126.73 135.2 143.43 159.25 174.36 188.9 202.96 229.88 255.5 280.05 303.67 326.45 344.97 366.49 387.87 409.48 431.86 431.86'
    scale_factor = 1e-7
  []
  [k_fn]
    type = PiecewiseLinear
    x = '100 280 300 350 400 450 500 550 600 700 800 900 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 5000'
    y = '186.82 186.82 194.11 212.69 231.55 250.38 268.95 287.19 305.11 340.24 374.92 409.66 444.75 511.13 583.42 656.44 733.32 826.53 961.15 1180.38 1546.31 2135.49 3028.08 3028.08'
    scale_factor = 1e-3
  []
[]
[FluidProperties]
  [fp]
    type = CaloricallyImperfectGas
    molar_mass = 0.002
    e = e_fn
    k = k_fn
    mu = mu_fn
    min_temperature = 100
    max_temperature = 5000
    out_of_bound_error = false
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [inlet_bc]
    type = InletVelocityTemperature1Phase
    input = 'inlet:in'
    vel = ${vel}
    T = ${T_in}
  []
  [inlet]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 11'
    orientation = '0 0 -1'
    length = 1
    A = 3
  []
  [inlet_plenum]
    type = JunctionParallelChannels1Phase
    position = '0 0 10'
    initial_vel_x = 0
    initial_vel_y = 0
    initial_vel_z = ${vel}
    K = 100
    connections = 'inlet:out channel1:in channel2:in'
    volume = 1
  []
  [channel1]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 10'
    orientation = '0 0 -1'
    length = 10
    A = 4
    D_h = 1
  []
  [channel2]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 10'
    orientation = '0 0 -1'
    length = 10
    A = 1
    D_h = 1
  []
  [outlet_plenum]
    type = JunctionParallelChannels1Phase
    position = '0 0 0'
    initial_vel_x = 1
    initial_vel_y = 0
    initial_vel_z = ${vel}
    connections = 'channel1:out channel2:out outlet:in'
    volume = 1
  []
  [outlet]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 0'
    orientation = '0 0 -1'
    length = 1
    A = 1
  []
  [outlet_bc]
    type = Outlet1Phase
    p = ${p_out}
    input = 'outlet:out'
  []
[]
[Postprocessors]
  [p_in]
    type = SideAverageValue
    variable = p
    boundary = inlet:in
  []
  [p_out]
    type = SideAverageValue
    variable = p
    boundary = outlet:out
  []
  [Delta_p]
    type = DifferencePostprocessor
    value1 = p_out
    value2 = p_in
  []
  [inlet_in_m_dot]
    type = ADFlowBoundaryFlux1Phase
    boundary = 'inlet_bc'
    equation = mass
  []
  [inlet_out_m_dot]
    type = ADFlowJunctionFlux1Phase
    boundary = 'inlet:out'
    connection_index = 0
    junction = inlet_plenum
    equation = mass
  []
  [channel1_in_m_dot]
    type = ADFlowJunctionFlux1Phase
    boundary = 'channel1:in'
    connection_index = 1
    junction = inlet_plenum
    equation = mass
  []
  [channel1_out_m_dot]
    type = ADFlowJunctionFlux1Phase
    boundary = 'channel1:out'
    connection_index = 0
    junction = outlet_plenum
    equation = mass
  []
  [channel2_in_m_dot]
    type = ADFlowJunctionFlux1Phase
    boundary = 'channel2:in'
    connection_index = 2
    junction = inlet_plenum
    equation = mass
  []
  [channel2_out_m_dot]
    type = ADFlowJunctionFlux1Phase
    boundary = 'channel2:out'
    connection_index = 1
    junction = outlet_plenum
    equation = mass
  []
  [outlet_in_m_dot]
    type = ADFlowJunctionFlux1Phase
    boundary = 'outlet:in'
    connection_index = 2
    junction = outlet_plenum
    equation = mass
  []
  [outlet_out_m_dot]
    type = ADFlowBoundaryFlux1Phase
    boundary = 'outlet_bc'
    equation = mass
  []
  [net_mass_flow_rate_domain]
    type = LinearCombinationPostprocessor
    pp_names = 'inlet_in_m_dot outlet_out_m_dot'
    pp_coefs = '1 -1'
  []
  [net_mass_flow_rate_volume_junction]
    type = LinearCombinationPostprocessor
    pp_names = 'inlet_out_m_dot channel1_in_m_dot channel2_in_m_dot'
    pp_coefs = '1 -1 -1'
  []
[]
[Preconditioning]
  [smp]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = bdf2
  start_time = 0
  end_time = 20
  [TimeStepper]
    type = IterationAdaptiveDT
    dt = 1
    optimal_iterations = 8
    iteration_window = 2
  []
  timestep_tolerance = 1e-6
  abort_on_solve_fail = true
  line_search = basic
  nl_rel_tol = 1e-8
  nl_abs_tol = 2e-8
  nl_max_its = 25
  l_tol = 1e-3
  l_max_its = 5
  petsc_options = '-snes_converged_reason'
  petsc_options_iname = '-pc_type'
  petsc_options_value = ' lu     '
[]
[Outputs]
  [out]
    type = CSV
    execute_on = 'FINAL'
    show = 'net_mass_flow_rate_domain net_mass_flow_rate_volume_junction Delta_p'
  []
[]
(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'
    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
  []
  ############## 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'
    expression = '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'
    expression = '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'
    expression = '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/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/thermal_hydraulics/test/tests/components/simple_turbine_1phase/phy.conservation.i)
[GlobalParams]
  initial_p = 1e6
  initial_T = 517
  initial_vel = 4.3
  initial_vel_x = 4.3
  initial_vel_y = 0
  initial_vel_z = 0
  fp = fp
  closures = simple_closures
  f = 0
  rdg_slope_reconstruction = minmod
  gravity_vector = '0 0 0'
  scaling_factor_1phase = '1 1 1e-5'
[]
[FluidProperties]
  [fp]
    type = IdealGasFluidProperties
    gamma = 1.4
    molar_mass = 0.01
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [inlet]
    type = InletMassFlowRateTemperature1Phase
    input = 'pipe1:in'
    m_dot = 10
    T = 517
  []
  [pipe1]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '1 0 0'
    length = 1
    n_elems = 10
    A = 1
  []
  [turbine]
    type = SimpleTurbine1Phase
    connections = 'pipe1:out pipe2:in'
    position = '1 0 0'
    volume = 1
    A_ref = 1.0
    K = 0
    on = true
    power = 1000
  []
  [pipe2]
    type = FlowChannel1Phase
    position = '1. 0 0'
    orientation = '1 0 0'
    length = 1
    n_elems = 10
    A = 1
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe2:out'
    p = 1e6
  []
[]
[Postprocessors]
  [mass_in]
    type = ADFlowBoundaryFlux1Phase
    equation = mass
    boundary = inlet
  []
  [mass_out]
    type = ADFlowBoundaryFlux1Phase
    equation = mass
    boundary = outlet
  []
  [mass_diff]
    type = LinearCombinationPostprocessor
    pp_coefs = '1 -1'
    pp_names = 'mass_in mass_out'
  []
  [p_in]
    type = SideAverageValue
    boundary = pipe1:in
    variable = p
  []
  [vel_in]
    type = SideAverageValue
    boundary = pipe1:in
    variable = vel_x
  []
  [momentum_in]
    type = ADFlowBoundaryFlux1Phase
    equation = momentum
    boundary = inlet
  []
  [momentum_out]
    type = ADFlowBoundaryFlux1Phase
    equation = momentum
    boundary = outlet
  []
  [dP]
    type = ParsedPostprocessor
    pp_names = 'p_in W_dot'
    expression = 'p_in * (1 - (1-W_dot/(10*2910.06*517))^(1.4/0.4))'
  []
  [momentum_diff]
    type = LinearCombinationPostprocessor
    pp_coefs = '1 -1 -1'
    pp_names = 'momentum_in momentum_out dP' # momentum source = -dP * A and A=1
  []
  [energy_in]
    type = ADFlowBoundaryFlux1Phase
    equation = energy
    boundary = inlet
  []
  [energy_out]
    type = ADFlowBoundaryFlux1Phase
    equation = energy
    boundary = outlet
  []
  [W_dot]
    type = ElementAverageValue
    variable = W_dot
    block = 'turbine'
  []
  [energy_diff]
    type = LinearCombinationPostprocessor
    pp_coefs = '1 -1 -1'
    pp_names = 'energy_in energy_out W_dot'
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = bdf2
  start_time = 0
  end_time = 10
  dt = 0.5
  abort_on_solve_fail = true
  solve_type = 'newton'
  petsc_options_iname = '-pc_type'
  petsc_options_value = ' lu'
  nl_rel_tol = 0
  nl_abs_tol = 2e-6
  nl_max_its = 10
  l_tol = 1e-3
  # automatic_scaling = true
  # compute_scaling_once = false
  # off_diagonals_in_auto_scaling = true
[]
[Outputs]
  [csv]
    type = CSV
    show = 'mass_diff energy_diff momentum_diff'
    execute_on = 'final'
  []
[]
(modules/thermal_hydraulics/test/tests/components/volume_junction_1phase/junction_with_calorifically_imperfect_gas.i)
# This input file tests compatibility of VolumeJunction1Phase and CaloricallyImperfectGas.
# Loss coefficient is applied in first junction.
# Expected pressure drop ~0.5*K*rho_in*vel_in^2=0.5*100*3.219603*1 = 160.9 Pa
T_in = 523.0
vel = 1
p_out = 7e6
[GlobalParams]
  initial_p = ${p_out}
  initial_vel = ${vel}
  initial_T = ${T_in}
  gravity_vector = '0 0 0'
  closures = simple_closures
  n_elems = 3
  f = 0
  scaling_factor_1phase = '1 1 1e-5'
  scaling_factor_rhoV = '1e2'
  scaling_factor_rhowV = '1e-2'
  scaling_factor_rhoEV = '1e-5'
[]
[Functions]
  [e_fn]
    type = PiecewiseLinear
    x = '100   280 300 350 400 450 500 550 600 700 800 900 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 5000'
    y = '783.9 2742.3 2958.6 3489.2 4012.7 4533.3 5053.8 5574 6095.1 7140.2 8192.9 9256.3 10333.6 12543.9 14836.6 17216.3 19688.4 22273.7 25018.3 28042.3 31544.2 35818.1 41256.5 100756.5'
    scale_factor = 1e3
  []
  [mu_fn]
    type = PiecewiseLinear
    x = '100   280 300 350 400 450 500 550 600 700 800 900 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 5000'
    y = '85.42 85.42 89.53 99.44 108.9 117.98 126.73 135.2 143.43 159.25 174.36 188.9 202.96 229.88 255.5 280.05 303.67 326.45 344.97 366.49 387.87 409.48 431.86 431.86'
    scale_factor = 1e-7
  []
  [k_fn]
    type = PiecewiseLinear
    x = '100 280 300 350 400 450 500 550 600 700 800 900 1000 1200 1400 1600 1800 2000 2200 2400 2600 2800 3000 5000'
    y = '186.82 186.82 194.11 212.69 231.55 250.38 268.95 287.19 305.11 340.24 374.92 409.66 444.75 511.13 583.42 656.44 733.32 826.53 961.15 1180.38 1546.31 2135.49 3028.08 3028.08'
    scale_factor = 1e-3
  []
[]
[FluidProperties]
  [fp]
    type = CaloricallyImperfectGas
    molar_mass = 0.002
    e = e_fn
    k = k_fn
    mu = mu_fn
    min_temperature = 100
    max_temperature = 5000
    out_of_bound_error = false
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [inlet_bc]
    type = InletVelocityTemperature1Phase
    input = 'inlet:in'
    vel = ${vel}
    T = ${T_in}
  []
  [inlet]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 11'
    orientation = '0 0 -1'
    length = 1
    A = 5
  []
  [inlet_plenum]
    type = VolumeJunction1Phase
    position = '0 0 10'
    initial_vel_x = 0
    initial_vel_y = 0
    initial_vel_z = ${vel}
    K = 100
    connections = 'inlet:out channel1:in channel2:in'
    volume = 1
  []
  [channel1]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 10'
    orientation = '0 0 -1'
    length = 10
    A = 4
    D_h = 1
  []
  [channel2]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 10'
    orientation = '0 0 -1'
    length = 10
    A = 1
    D_h = 1
  []
  [outlet_plenum]
    type = VolumeJunction1Phase
    position = '0 0 0'
    initial_vel_x = 0
    initial_vel_y = 0
    initial_vel_z = ${vel}
    connections = 'channel1:out channel2:out outlet:in'
    volume = 1
  []
  [outlet]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 0'
    orientation = '0 0 -1'
    length = 1
    A = 5
  []
  [outlet_bc]
    type = Outlet1Phase
    p = ${p_out}
    input = 'outlet:out'
  []
[]
[Postprocessors]
  [p_in]
    type = SideAverageValue
    variable = p
    boundary = inlet:in
  []
  [p_out]
    type = SideAverageValue
    variable = p
    boundary = outlet:out
  []
  [Delta_p]
    type = DifferencePostprocessor
    value1 = p_out
    value2 = p_in
  []
  [inlet_in_m_dot]
    type = ADFlowBoundaryFlux1Phase
    boundary = 'inlet_bc'
    equation = mass
  []
  [inlet_out_m_dot]
    type = ADFlowJunctionFlux1Phase
    boundary = 'inlet:out'
    connection_index = 0
    junction = inlet_plenum
    equation = mass
  []
  [channel1_in_m_dot]
    type = ADFlowJunctionFlux1Phase
    boundary = 'channel1:in'
    connection_index = 1
    junction = inlet_plenum
    equation = mass
  []
  [channel1_out_m_dot]
    type = ADFlowJunctionFlux1Phase
    boundary = 'channel1:out'
    connection_index = 0
    junction = outlet_plenum
    equation = mass
  []
  [channel2_in_m_dot]
    type = ADFlowJunctionFlux1Phase
    boundary = 'channel2:in'
    connection_index = 2
    junction = inlet_plenum
    equation = mass
  []
  [channel2_out_m_dot]
    type = ADFlowJunctionFlux1Phase
    boundary = 'channel2:out'
    connection_index = 1
    junction = outlet_plenum
    equation = mass
  []
  [outlet_in_m_dot]
    type = ADFlowJunctionFlux1Phase
    boundary = 'outlet:in'
    connection_index = 2
    junction = outlet_plenum
    equation = mass
  []
  [outlet_out_m_dot]
    type = ADFlowBoundaryFlux1Phase
    boundary = 'outlet_bc'
    equation = mass
  []
  [net_mass_flow_rate_domain]
    type = LinearCombinationPostprocessor
    pp_names = 'inlet_in_m_dot outlet_out_m_dot'
    pp_coefs = '1 -1'
  []
  [net_mass_flow_rate_volume_junction]
    type = LinearCombinationPostprocessor
    pp_names = 'inlet_out_m_dot channel1_in_m_dot channel2_in_m_dot'
    pp_coefs = '1 -1 -1'
  []
[]
[Preconditioning]
  [smp]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = bdf2
  start_time = 0
  end_time = 20
  [TimeStepper]
    type = IterationAdaptiveDT
    dt = 1
    optimal_iterations = 8
    iteration_window = 2
  []
  timestep_tolerance = 1e-6
  abort_on_solve_fail = true
  line_search = basic
  nl_rel_tol = 1e-8
  nl_abs_tol = 4e-8
  nl_max_its = 25
  l_tol = 1e-3
  l_max_its = 5
  petsc_options = '-snes_converged_reason'
  petsc_options_iname = '-pc_type'
  petsc_options_value = ' lu     '
[]
[Outputs]
  [out]
    type = CSV
    execute_on = 'FINAL'
    show = 'net_mass_flow_rate_domain net_mass_flow_rate_volume_junction Delta_p'
  []
[]
(modules/thermal_hydraulics/test/tests/postprocessors/flow_boundary_flux_1phase/test.i)
T_in = 300
p_out = 1e5
[GlobalParams]
  initial_p = ${p_out}
  initial_T = ${T_in}
  initial_vel = 0
  gravity_vector = '0 0 0'
  closures = simple_closures
  n_elems = 50
  f = 0
  scaling_factor_1phase = '1 1e-2 1e-4'
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    q = -1167e3
    q_prime = 0
    p_inf = 1.e9
    cv = 1816
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [inlet]
    type = InletMassFlowRateTemperature1Phase
    input = 'channel:in'
    m_dot = 0.1
    T = ${T_in}
  []
  [channel]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 0'
    orientation = '1 0 0'
    length = 1
    A = 3
  []
  [outlet]
    type = Outlet1Phase
    p = ${p_out}
    input = 'channel:out'
  []
[]
[Postprocessors]
  [m_dot_in]
    type = ADFlowBoundaryFlux1Phase
    boundary = 'inlet'
    equation = mass
  []
  [m_dot_out]
    type = ADFlowBoundaryFlux1Phase
    boundary = 'outlet'
    equation = mass
  []
[]
[Preconditioning]
  [smp]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = bdf2
  start_time = 0
  num_steps = 10
  dt = 0.1
  solve_type = NEWTON
  nl_rel_tol = 1e-6
  nl_abs_tol = 1e-6
  nl_max_its = 25
  l_tol = 1e-3
  l_max_its = 5
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
[]
[Outputs]
  [out]
    type = CSV
    show = 'm_dot_in m_dot_out'
    execute_on = 'final'
  []
[]
(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'
    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
  []
  ############## 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'
    expression = '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'
    expression = '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'
    expression = '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/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/test/tests/postprocessors/flow_junction_flux_1phase/flow_junction_flux_1phase.i)
# This input file tests mass conservation at steady-state by looking at the
# net mass flux into the domain.
T_in = 523.0
m_dot = 100
p_out = 7e6
[GlobalParams]
  initial_p = ${p_out}
  initial_vel = 1
  initial_T = ${T_in}
  gravity_vector = '0 0 0'
  closures = simple_closures
  n_elems = 3
  f = 0
  scaling_factor_1phase = '1 1 1e-5'
[]
[FluidProperties]
  [fp]
    type = IdealGasFluidProperties
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [inlet_bc]
    type = InletMassFlowRateTemperature1Phase
    input = 'inlet:in'
    m_dot = ${m_dot}
    T = ${T_in}
  []
  [inlet]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 11'
    orientation = '0 0 -1'
    length = 1
    A = 3
  []
  [inlet_plenum]
    type = VolumeJunction1Phase
    position = '0 0 10'
    initial_vel_x = 0
    initial_vel_y = 0
    initial_vel_z = 1
    connections = 'inlet:out channel1:in channel2:in'
    volume = 1
    scaling_factor_rhoEV = '1e-5'
  []
  [channel1]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 10'
    orientation = '0 0 -1'
    length = 10
    A = 4
    D_h = 1
  []
  [K_bypass]
    type = FormLossFromFunction1Phase
    K_prime = 500
    flow_channel = channel1
  []
  [channel2]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 10'
    orientation = '0 0 -1'
    length = 10
    A = 1
    D_h = 1
  []
  [outlet_plenum]
    type = VolumeJunction1Phase
    position = '0 0 0'
    initial_vel_x = 1
    initial_vel_y = 0
    initial_vel_z = 1
    connections = 'channel1:out channel2:out outlet:in'
    volume = 1
    scaling_factor_rhoEV = '1e-5'
  []
  [outlet]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 0'
    orientation = '0 0 -1'
    length = 1
    A = 1
  []
  [outlet_bc]
    type = Outlet1Phase
    p = ${p_out}
    input = 'outlet:out'
  []
[]
[Postprocessors]
  [inlet_in_m_dot]
    type = ADFlowBoundaryFlux1Phase
    boundary = 'inlet_bc'
    equation = mass
  []
  [inlet_out_m_dot]
    type = ADFlowJunctionFlux1Phase
    boundary = 'inlet:out'
    connection_index = 0
    junction = inlet_plenum
    equation = mass
  []
  [channel1_in_m_dot]
    type = ADFlowJunctionFlux1Phase
    boundary = 'channel1:in'
    connection_index = 1
    junction = inlet_plenum
    equation = mass
  []
  [channel1_out_m_dot]
    type = ADFlowJunctionFlux1Phase
    boundary = 'channel1:out'
    connection_index = 0
    junction = outlet_plenum
    equation = mass
  []
  [channel2_in_m_dot]
    type = ADFlowJunctionFlux1Phase
    boundary = 'channel2:in'
    connection_index = 2
    junction = inlet_plenum
    equation = mass
  []
  [channel2_out_m_dot]
    type = ADFlowJunctionFlux1Phase
    boundary = 'channel2:out'
    connection_index = 1
    junction = outlet_plenum
    equation = mass
  []
  [outlet_in_m_dot]
    type = ADFlowJunctionFlux1Phase
    boundary = 'outlet:in'
    connection_index = 2
    junction = outlet_plenum
    equation = mass
  []
  [outlet_out_m_dot]
    type = ADFlowBoundaryFlux1Phase
    boundary = 'outlet_bc'
    equation = mass
  []
  [net_mass_flow_rate_domain]
    type = LinearCombinationPostprocessor
    pp_names = 'inlet_in_m_dot outlet_out_m_dot'
    pp_coefs = '1 -1'
  []
  [net_mass_flow_rate_volume_junction]
    type = LinearCombinationPostprocessor
    pp_names = 'inlet_out_m_dot channel1_in_m_dot channel2_in_m_dot'
    pp_coefs = '1 -1 -1'
  []
[]
[Preconditioning]
  [smp]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = bdf2
  start_time = 0
  end_time = 10000
  [TimeStepper]
    type = IterationAdaptiveDT
    dt = 0.01
    optimal_iterations = 8
    iteration_window = 2
  []
  timestep_tolerance = 1e-6
  abort_on_solve_fail = true
  line_search = none
  nl_rel_tol = 1e-8
  nl_abs_tol = 2e-8
  nl_max_its = 25
  l_tol = 1e-3
  l_max_its = 5
  petsc_options = '-snes_converged_reason'
  petsc_options_iname = '-pc_type'
  petsc_options_value = ' lu     '
[]
[Outputs]
  [out]
    type = CSV
    execute_on = 'FINAL'
    show = 'net_mass_flow_rate_domain net_mass_flow_rate_volume_junction'
  []
[]