- T0Prescribed stagnation temperature [K]
C++ Type:double
Unit:(no unit assumed)
Controllable:Yes
Description:Prescribed stagnation temperature [K]
 - inputName of the input
C++ Type:BoundaryName
Controllable:No
Description:Name of the input
 - p0Prescribed stagnation pressure [Pa]
C++ Type:double
Unit:(no unit assumed)
Controllable:Yes
Description:Prescribed stagnation pressure [Pa]
 
InletStagnationPressureTemperature1Phase
This is a single-phase 1-D flow boundary component in which the stagnation pressure and temperature are specified. This boundary is typically used when fluid is expected to flow from an infinitely large tank where the pressure and temperature are known.
Usage
This component must be connected to a FlowChannel1Phase. See how to connect a flow boundary component.
The user specifies the following parameters:
The formulation of this boundary condition assumes flow entering the flow channel at this boundary.
Reversible flow: If exit conditions are encountered, then the boundary condition is automatically changed to an outlet formulation. This behavior can be disabled by setting the "reversible" parameter to false.
Input Parameters
- reversibleTrueTrue for reversible, false for pure inlet
Default:True
C++ Type:bool
Controllable:No
Description:True for reversible, false for pure inlet
 
Optional 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/test/tests/components/pump_1phase/pump_loop.i)
 - (modules/thermal_hydraulics/test/tests/components/inlet_stagnation_p_t_1phase/clg.ctrl_T0_3eqn.i)
 - (modules/thermal_hydraulics/test/tests/components/volume_junction_1phase/err.missing_ics.i)
 - (modules/thermal_hydraulics/tutorials/single_phase_flow/05_secondary_side.i)
 - (modules/thermal_hydraulics/test/tests/controls/copy_postprocessor_value_control/test.i)
 - (modules/thermal_hydraulics/test/tests/controls/set_bool_value_control/test.i)
 - (modules/combined/test/tests/subchannel_thm_coupling/THM_SCM_coupling_pump.i)
 - (modules/thermal_hydraulics/test/tests/components/heat_transfer_from_heat_structure_1phase/err.not_a_hs.i)
 - (modules/thermal_hydraulics/test/tests/components/flow_channel_1phase/err.wrong_fp.i)
 - (modules/thermal_hydraulics/test/tests/components/outlet_1phase/clg.ctrl_p_3eqn.i)
 - (modules/thermal_hydraulics/test/tests/problems/brayton_cycle/open_brayton_cycle.i)
 - (modules/thermal_hydraulics/tutorials/single_phase_flow/04_loop.i)
 - (modules/thermal_hydraulics/test/tests/components/volume_junction_1phase/equal_area_no_junction.i)
 - (modules/thermal_hydraulics/test/tests/components/inlet_stagnation_p_t_1phase/clg.ctrl_p0_3eqn.i)
 - (modules/thermal_hydraulics/test/tests/components/junction_parallel_channels_1phase/equal_area_no_junction.i)
 - (modules/thermal_hydraulics/test/tests/postprocessors/real_component_parameter_value/non_existent_par_name.i)
 - (modules/thermal_hydraulics/test/tests/components/junction_parallel_channels_1phase/equal_area_with_junction.i)
 - (modules/thermal_hydraulics/test/tests/components/inlet_mass_flow_rate_1phase/phy.reversed_flow.i)
 - (modules/thermal_hydraulics/test/tests/problems/brayton_cycle/recuperated_brayton_cycle.i)
 - (modules/thermal_hydraulics/test/tests/components/junction_parallel_channels_1phase/jac.test.i)
 - (modules/thermal_hydraulics/test/tests/controls/set_component_real_value_control/test.i)
 - (modules/thermal_hydraulics/test/tests/components/heat_transfer_from_heat_structure_1phase/err.1phase.i)
 - (modules/thermal_hydraulics/test/tests/controls/dependency/test.i)
 - (modules/thermal_hydraulics/test/tests/components/inlet_stagnation_p_t_1phase/phy.stagnation_p_T_transient_3eqn.i)
 - (modules/thermal_hydraulics/test/tests/controls/pid_control/test.i)
 - (modules/thermal_hydraulics/test/tests/controls/delay_control/test.i)
 - (modules/thermal_hydraulics/test/tests/components/flow_channel_1phase/err.wrong_end.i)
 - (modules/thermal_hydraulics/test/tests/controls/set_real_value_control/test.i)
 - (modules/thermal_hydraulics/test/tests/components/inlet_stagnation_p_t_1phase/phy.stagnation_p_T_steady_3eqn.i)
 - (modules/thermal_hydraulics/test/tests/components/flow_channel_1phase/err.overspecified.i)
 - (modules/thermal_hydraulics/test/tests/controls/set_component_bool_value_control/test.i)
 - (modules/thermal_hydraulics/test/tests/components/inlet_stagnation_p_t_1phase/phy.p0T0_3eqn.i)
 - (modules/thermal_hydraulics/test/tests/components/volume_junction_1phase/equal_area_with_junction.i)
 - (modules/thermal_hydraulics/test/tests/components/inlet_velocity_t_1phase/phy.reversed_flow.i)
 - (modules/thermal_hydraulics/test/tests/controls/get_function_value_control/test.i)
 - (modules/thermal_hydraulics/test/tests/closures/simple_1phase/err.missing_f_1phase.i)
 - (modules/thermal_hydraulics/test/tests/components/junction_parallel_channels_1phase/err.missing_ics.i)
 - (modules/thermal_hydraulics/test/tests/misc/adapt/multiple_blocks.i)
 - (modules/thermal_hydraulics/tutorials/single_phase_flow/06_custom_closures.i)
 - (modules/thermal_hydraulics/test/tests/controls/error_checking/non_existent_control_data.i)
 
Formulation
This boundary condition uses a ghost cell formulation, where the ghost cell solution is computed from the following quantities:
, the provided exterior stagnation pressure,
, the provided exterior stagnation temperature, and
, the interior velocity.
If the boundary is specified to be reversible ("reversible" set to true) and the flow is exiting, the ghost cell is instead computed with the following quantities:
, the exterior pressure, assumed to be equal to the provided exterior stagnation pressure ,
, the interior density, and
, the interior velocity.
p0
C++ Type:double
Unit:(no unit assumed)
Controllable:Yes
Description:Prescribed stagnation pressure [Pa]
T0
C++ Type:double
Unit:(no unit assumed)
Controllable:Yes
Description:Prescribed stagnation temperature [K]
reversible
Default:True
C++ Type:bool
Controllable:No
Description:True for reversible, false for pure inlet
(modules/thermal_hydraulics/test/tests/components/pump_1phase/pump_loop.i)
[GlobalParams]
  initial_T = 300
  initial_p = 1e5
  initial_vel = 0
  initial_vel_x = 0
  initial_vel_y = 0
  initial_vel_z = 0
  scaling_factor_1phase = '1 1 1'
  scaling_factor_rhoV  = 1
  scaling_factor_rhouV = 1
  scaling_factor_rhovV = 1
  scaling_factor_rhowV = 1
  scaling_factor_rhoEV = 1
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    q = -1167e3
    q_prime = 0
    p_inf = 1.e9
    cv = 1816
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe1a]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 0'
    orientation = '1 0 0'
    A = 0.785398163e-4    #1.0 cm (0.01 m) in diameter, A = 1/4 * PI * d^2
    D_h = 0.01
    f = 0.01
    length = 0.5
    n_elems = 2
  []
  [pipe1b]
    type = FlowChannel1Phase
    fp = fp
    position = '0.5 0 0'
    orientation = '1 0 0'
    A = 0.785398163e-4    #1.0 cm (0.01 m) in diameter, A = 1/4 * PI * d^2
    D_h = 0.01
    f = 0.01
    length = 0.5
    n_elems = 2
  []
  [pipe2]
    type = FlowChannel1Phase
    fp = fp
    position = '1 0 0'
    orientation = '0 1 0'
    A = 0.785398163e-4    #1.0 cm (0.01 m) in diameter, A = 1/4 * PI * d^2
    D_h = 0.01
    f = 0.01
    length = 1
    n_elems = 3
  []
  [pipe3]
    type = FlowChannel1Phase
    fp = fp
    position = '1 1 0'
    orientation = '-1 0 0'
    A = 0.785398163e-4    #1.0 cm (0.01 m) in diameter, A = 1/4 * PI * d^2
    D_h = 0.01
    f = 0.01
    length = 1
    n_elems = 3
  []
  [pipe4]
    type = FlowChannel1Phase
    fp = fp
    position = '0 1 0'
    orientation = '0 -1 0'
    A = 0.785398163e-4    #1.0 cm (0.01 m) in diameter, A = 1/4 * PI * d^2
    D_h = 0.01
    f = 0.01
    length = 1
    n_elems = 3
  []
  [pipe5]
    type = FlowChannel1Phase
    fp = fp
    position = '1 1 0'
    orientation = '0 1 0'
    A = 0.785398163e-4    #1.0 cm (0.01 m) in diameter, A = 1/4 * PI * d^2
    D_h = 0.01
    f = 0.01
    length = 0.5
    n_elems = 3
  []
  [pump]
    type = Pump1Phase
    connections = 'pipe1a:out pipe1b:in'
    head = 1.0
    position = '0.5 0 0'
    volume = 0.785398163e-3
    A_ref = 0.785398163e-4
  []
  [junction1]
    type = VolumeJunction1Phase
    connections = 'pipe1b:out pipe2:in'
    volume = 0.785398163e-3
    position = '1 0 0'
  []
  [junction2]
    type = VolumeJunction1Phase
    connections = 'pipe2:out pipe3:in pipe5:in'
    volume = 0.785398163e-3
    position = '1 1 0'
  []
  [junction3]
    type = VolumeJunction1Phase
    connections = 'pipe3:out pipe4:in'
    volume = 0.785398163e-3
    position = '0 1 0'
  []
  [junction4]
    type = VolumeJunction1Phase
    connections = 'pipe4:out pipe1a:in'
    volume = 0.785398163e-3
    position = '0 0 0'
  []
  [outlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe5:out'
    p0 = 1.e5
    T0 = 300
  []
[]
[Preconditioning]
  [SMP_PJFNK]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  start_time = 0
  num_steps = 10
  dt = 1
  abort_on_solve_fail = true
  solve_type = 'PJFNK'
  line_search = 'basic'
  nl_rel_tol = 1e-6
  nl_abs_tol = 1e-7
  nl_max_its = 10
  l_tol = 1e-3
  l_max_its = 100
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  [Quadrature]
    type = gauss
    order = second
  []
[]
[Outputs]
  [out]
    type = Exodus
    show = 'rhouA p'
    execute_on = 'initial final'
  []
[]
(modules/thermal_hydraulics/test/tests/components/inlet_stagnation_p_t_1phase/clg.ctrl_T0_3eqn.i)
[GlobalParams]
  gravity_vector = '0 0 0'
  initial_p = 1e5
  initial_T = 300
  initial_vel = 0.0
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    cv = 1816.0
    q = -1.167e6
    p_inf = 1.0e9
    q_prime = 0
    k = 0.5
    mu = 281.8e-6
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '1 0 0'
    length = 1
    n_elems = 50
    A   = 1.0000000000e-04
    D_h = 1.1283791671e-02
    f = 0.0
    fp = fp
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe:in'
    p0 = 1.01e5
    T0 = 300
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe:out'
    p = 1e5
  []
[]
[Functions]
  [inlet_T0_fn]
    type = PiecewiseLinear
    x = '0   1'
    y = '300 350'
  []
[]
[ControlLogic]
  [set_inlet_value]
    type = TimeFunctionComponentControl
    component = inlet
    parameter = T0
    function = inlet_T0_fn
  []
[]
[Postprocessors]
  [inlet_T0]
    type = RealComponentParameterValuePostprocessor
    component = inlet
    parameter = T0
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  start_time = 0.0
  dt = 0.25
  num_steps = 5
  abort_on_solve_fail = true
  solve_type = 'NEWTON'
  line_search = 'basic'
  nl_rel_tol = 1e-5
  nl_abs_tol = 1e-6
  nl_max_its = 30
  l_tol = 1e-3
  l_max_its = 100
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  automatic_scaling = true
[]
[Outputs]
  csv = true
[]
(modules/thermal_hydraulics/test/tests/components/volume_junction_1phase/err.missing_ics.i)
[GlobalParams]
  gravity_vector = '0 0 0'
  A = 1e-4
  f = 0
  fp = fp
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 1.4
    cv = 725
    p_inf = 0
    q = 0
    q_prime = 0
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe1:in'
    # Stagnation property with p = 1e5 Pa, T = 250 K, vel = 1 m/s
    p0 = 100000.68965687
    T0 = 250.00049261084
  []
  [pipe1]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '1 0 0'
    length = 1
    n_elems = 2
    initial_p = 1e5
    initial_T = 250
    initial_vel = 0
  []
  [junction]
    type = VolumeJunction1Phase
    connections = 'pipe1:out pipe2:in'
    position = '1.02 0 0'
    volume = 0.1
  []
  [pipe2]
    type = FlowChannel1Phase
    position = '1.04 0 0'
    orientation = '1 0 0'
    length = 0.96
    n_elems = 2
    initial_p = 1e5
    initial_T = 250
    initial_vel = 0
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe2:out'
    p = 1e5
  []
[]
[Executioner]
  type = Transient
  abort_on_solve_fail = true
[]
(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/controls/copy_postprocessor_value_control/test.i)
# This is testing that the values copied by CopyPostprocessorValueControl are used.
# A postprocessor T_pt samples value at point (0, 0, 0), those values are then
# read in by CopyPostprocessorValueControl and then we output this value. The values
# are lagged by one time step, because controls are executed at the beginning
# of the time step and postprocessors at the end of the time step. Note that
# CopyPostprocessorValueControl is added when a postprocessor is created. That's why
# you do not see the object in this input file.
[GlobalParams]
  initial_p = 100.e3
  initial_vel = 1.0
  initial_T = 350.
  scaling_factor_1phase = '1 1e-2 1e-4'
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    q = -1167e3
    q_prime = 0
    p_inf = 1.e9
    cv = 1816
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe1]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 0'
    orientation = '1 0 0'
    length = 15.0
    n_elems = 10
    A    = 0.01
    D_h  = 0.1
    f = 0.01
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe1:in'
    p0 = 100.e3
    T0 = 340.
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe1:out'
    p = 100.0e3
  []
[]
[Postprocessors]
  [T_pt]
    type = SideAverageValue
    boundary = pipe1:in
    variable = T
    execute_on = 'initial timestep_end'
  []
  [T_ctrl]
    type = RealControlDataValuePostprocessor
    control_data_name = T_pt
    execute_on = timestep_end
  []
[]
[Preconditioning]
  [SMP_PJFNK]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  start_time = 0
  dt = 1e-5
  num_steps = 3
  abort_on_solve_fail = true
  solve_type = 'PJFNK'
  line_search = 'basic'
  nl_rel_tol = 1e-6
  nl_abs_tol = 1e-6
  nl_max_its = 20
  l_tol = 1e-3
  l_max_its = 5
[]
[Outputs]
  csv = true
[]
(modules/thermal_hydraulics/test/tests/controls/set_bool_value_control/test.i)
# This is testing that the values set by SetBoolValueControl are used.
# The values of function T0_fn are compared to a threshold and the boolean
# result is stored into an aux field via `BooleanValueTestAux`.
[GlobalParams]
  initial_p = 100.e3
  initial_vel = 1.0
  initial_T = 350.
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    q = -1167e3
    q_prime = 0
    p_inf = 1.e9
    cv = 1816
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe1]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 0'
    orientation = '1 0 0'
    length = 15.0
    n_elems = 10
    A    = 0.01
    D_h  = 0.1
    f = 0.01
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe1:in'
    p0 = 100.e3
    T0 = 350.
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe1:out'
    p = 100.0e3
  []
[]
[AuxVariables]
  [aux]
  []
[]
[AuxKernels]
  [aux_kernel]
    type = BooleanValueTestAux
    variable = aux
    value = 1
    execute_on = 'INITIAL TIMESTEP_END'
  []
[]
[Functions]
  [T0_fn]
    type = PiecewiseLinear
    x = '0 1'
    y = '350 345'
  []
[]
[ControlLogic]
  [T_inlet_fn]
    type = GetFunctionValueControl
    function = T0_fn
  []
  [threshold_ctrl]
    type = UnitTripControl
    condition = 'T > 347.5'
    symbol_names = 'T'
    symbol_values = 'T_inlet_fn:value'
  []
  [set_bool_value]
    type = SetBoolValueControl
    parameter = AuxKernels/aux_kernel/value
    value = 'threshold_ctrl:state'
  []
[]
[Postprocessors]
  [aux]
    type = ElementAverageValue
    variable = aux
    execute_on = 'INITIAL TIMESTEP_END'
  []
[]
[Preconditioning]
  [SMP_PJFNK]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  dt = 0.1
  abort_on_solve_fail = true
  solve_type = 'PJFNK'
  line_search = 'basic'
  nl_rel_tol = 1e-6
  nl_abs_tol = 1e-6
  nl_max_its = 20
  l_tol = 1e-3
  l_max_its = 5
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  start_time = 0.0
  end_time = 1
  automatic_scaling = true
[]
[Outputs]
  csv = true
[]
(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/test/tests/components/heat_transfer_from_heat_structure_1phase/err.not_a_hs.i)
[GlobalParams]
  initial_p = 15.5e6
  initial_vel = 2
  initial_T = 560
  scaling_factor_1phase = '1 1 1'
  scaling_factor_temperature = '1'
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    q = -1167e3
    q_prime = 0
    p_inf = 1.e9
    cv = 1816
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '0 0 1'
    length = 3.865
    n_elems = 1
    A = 8.78882e-5
    D_h = 0.01179
    f = 0.01
    fp = fp
  []
  [hx]
    type = HeatTransferFromHeatStructure1Phase
    hs = inlet # wrong
    hs_side = outer
    flow_channel = pipe
    Hw = 5.33e4
    P_hf = 0.029832559676
  []
  [hx2]
    type = HeatTransferFromHeatStructure1Phase
    hs = asdf # wrong
    hs_side = outer
    flow_channel = pipe
    Hw = 5.33e4
    P_hf = 0.029832559676
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe:in'
    p0 = 15.5e6
    T0 = 560
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe:out'
    p = 15e6
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  dt = 1.e-2
  dtmin = 1.e-2
  solve_type = 'NEWTON'
  nl_rel_tol = 1e-9
  nl_abs_tol = 1e-8
  nl_max_its = 1
  l_tol = 1e-3
  l_max_its = 30
  start_time = 0.0
  num_steps = 20
[]
(modules/thermal_hydraulics/test/tests/components/flow_channel_1phase/err.wrong_fp.i)
[GlobalParams]
  closures = simple_closures
  initial_p = 1e5
  initial_T = 300
  initial_vel = 0
[]
[FluidProperties]
  [fp_2phase]
    type = StiffenedGasTwoPhaseFluidProperties
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '1 0 0'
    A = 1.
    D_h = 1.12837916709551
    f = 0.01
    length = 1
    n_elems = 100
    fp = fp_2phase   # this is wrong
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe:in'
    p0 = 1e5
    T0 = 300
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe:out'
    p = 9.5e4
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  dt = 1e-4
  dtmin = 1.e-7
  solve_type = 'PJFNK'
  nl_rel_tol = 1e-9
  nl_abs_tol = 1e-8
  nl_max_its = 10
  l_tol = 1e-8
  l_max_its = 100
  start_time = 0.0
  num_steps = 1
[]
(modules/thermal_hydraulics/test/tests/components/outlet_1phase/clg.ctrl_p_3eqn.i)
[GlobalParams]
  gravity_vector = '0 0 0'
  initial_p = 1e5
  initial_T = 300
  initial_vel = 0.0
  scaling_factor_1phase = '1 1 1e-5'
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    cv = 1816.0
    q = -1.167e6
    p_inf = 1.0e9
    q_prime = 0
    k = 0.5
    mu = 281.8e-6
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '1 0 0'
    length = 1
    n_elems = 50
    A   = 1.0000000000e-04
    D_h = 1.1283791671e-02
    f = 0.0
    fp = fp
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe:in'
    p0 = 1e5
    T0 = 300
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe:out'
    p = 1e5
  []
[]
[Functions]
  [outlet_p_fn]
    type = PiecewiseLinear
    x = '0   1'
    y = '1e5 1.001e5'
  []
[]
[ControlLogic]
  [set_outlet_value]
    type = TimeFunctionComponentControl
    component = outlet
    parameter = p
    function = outlet_p_fn
  []
[]
[Postprocessors]
  [outlet_p]
    type = RealComponentParameterValuePostprocessor
    component = outlet
    parameter = p
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  start_time = 0.0
  dt = 0.25
  num_steps = 5
  abort_on_solve_fail = true
  solve_type = 'NEWTON'
  line_search = 'basic'
  nl_rel_tol = 1e-5
  nl_abs_tol = 1e-6
  nl_max_its = 30
  l_tol = 1e-3
  l_max_its = 100
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  [Quadrature]
    type = GAUSS
    order = SECOND
  []
[]
[Outputs]
  csv = true
[]
(modules/thermal_hydraulics/test/tests/problems/brayton_cycle/open_brayton_cycle.i)
# This input file is used to demonstrate a simple open-air Brayton cycle using
# a compressor, turbine, shaft, motor, and generator.
# The flow length is divided into 5 segments as illustrated below, where
#   - "(I)" denotes the inlet
#   - "(C)" denotes the compressor
#   - "(T)" denotes the turbine
#   - "(O)" denotes the outlet
#   - "*" denotes a fictitious junction
#
#                  Heated section
# (I)-----(C)-----*--------------*-----(T)-----(O)
#      1       2         3          4       5
#
# Initially the fluid is at rest at ambient conditions, the shaft speed is zero,
# and no heat transfer occurs with the system.
# The transient is controlled as follows:
#   * 0   - 100 s: motor ramps up torque linearly from zero
#   * 100 - 200 s: motor ramps down torque linearly to zero, HTC ramps up linearly from zero.
#   * 200 - 300 s: (no changes; should approach steady condition)
I_motor = 1.0
motor_torque_max = 400.0
I_generator = 1.0
generator_torque_per_shaft_speed = -0.00025
motor_ramp_up_duration = 100.0
motor_ramp_down_duration = 100.0
post_motor_time = 100.0
t1 = ${motor_ramp_up_duration}
t2 = ${fparse t1 + motor_ramp_down_duration}
t3 = ${fparse t2 + post_motor_time}
D1 = 0.15
D2 = ${D1}
D3 = ${D1}
D4 = ${D1}
D5 = ${D1}
A1 = ${fparse 0.25 * pi * D1^2}
A2 = ${fparse 0.25 * pi * D2^2}
A3 = ${fparse 0.25 * pi * D3^2}
A4 = ${fparse 0.25 * pi * D4^2}
A5 = ${fparse 0.25 * pi * D5^2}
L1 = 10.0
L2 = ${L1}
L3 = ${L1}
L4 = ${L1}
L5 = ${L1}
x1 = 0.0
x2 = ${fparse x1 + L1}
x3 = ${fparse x2 + L2}
x4 = ${fparse x3 + L3}
x5 = ${fparse x4 + L4}
x2_minus = ${fparse x2 - 0.001}
x2_plus = ${fparse x2 + 0.001}
x5_minus = ${fparse x5 - 0.001}
x5_plus = ${fparse x5 + 0.001}
n_elems1 = 10
n_elems2 = ${n_elems1}
n_elems3 = ${n_elems1}
n_elems4 = ${n_elems1}
n_elems5 = ${n_elems1}
A_ref_comp = ${fparse 0.5 * (A1 + A2)}
V_comp = ${fparse A_ref_comp * 1.0}
I_comp = 1.0
A_ref_turb = ${fparse 0.5 * (A4 + A5)}
V_turb = ${fparse A_ref_turb * 1.0}
I_turb = 1.0
c0_rated_comp = 351.6925137
rho0_rated_comp = 1.146881112
rated_mfr = 0.25
speed_rated_rpm = 96000
speed_rated = ${fparse speed_rated_rpm * 2 * pi / 60.0}
speed_initial = 0
eff_comp = 0.79
eff_turb = 0.843
T_hot = 1000
T_ambient = 300
p_ambient = 1e5
[GlobalParams]
  orientation = '1 0 0'
  gravity_vector = '0 0 0'
  initial_p = ${p_ambient}
  initial_T = ${T_ambient}
  initial_vel = 0
  initial_vel_x = 0
  initial_vel_y = 0
  initial_vel_z = 0
  fp = fp_air
  closures = closures
  f = 0
  scaling_factor_1phase = '1 1 1e-5'
  scaling_factor_rhoV = 1
  scaling_factor_rhouV = 1
  scaling_factor_rhovV = 1
  scaling_factor_rhowV = 1
  scaling_factor_rhoEV = 1e-5
  rdg_slope_reconstruction = none
[]
[Functions]
  [motor_torque_fn]
    type = PiecewiseLinear
    x = '0 ${t1} ${t2}'
    y = '0 ${motor_torque_max} 0'
  []
  [motor_power_fn]
    type = ParsedFunction
    expression = 'torque * speed'
    symbol_names = 'torque speed'
    symbol_values = 'motor_torque shaft:omega'
  []
  [generator_torque_fn]
    type = ParsedFunction
    expression = 'slope * t'
    symbol_names = 'slope'
    symbol_values = '${generator_torque_per_shaft_speed}'
  []
  [generator_power_fn]
    type = ParsedFunction
    expression = 'torque * speed'
    symbol_names = 'torque speed'
    symbol_values = 'generator_torque shaft:omega'
  []
  [htc_wall_fn]
    type = PiecewiseLinear
    x = '0 ${t1} ${t2}'
    y = '0 0 1e3'
  []
[]
[FluidProperties]
  [fp_air]
    type = IdealGasFluidProperties
    emit_on_nan = none
  []
[]
[Closures]
  [closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [shaft]
    type = Shaft
    connected_components = 'motor compressor turbine generator'
    initial_speed = ${speed_initial}
  []
  [motor]
    type = ShaftConnectedMotor
    inertia = ${I_motor}
    torque = 0 # controlled
  []
  [generator]
    type = ShaftConnectedMotor
    inertia = ${I_generator}
    torque = generator_torque_fn
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe1:in'
    p0 = ${p_ambient}
    T0 = ${T_ambient}
  []
  [pipe1]
    type = FlowChannel1Phase
    position = '${x1} 0 0'
    length = ${L1}
    n_elems = ${n_elems1}
    A = ${A1}
  []
  [compressor]
    type = ShaftConnectedCompressor1Phase
    position = '${x2} 0 0'
    inlet = 'pipe1:out'
    outlet = 'pipe2:in'
    A_ref = ${A_ref_comp}
    volume = ${V_comp}
    omega_rated = ${speed_rated}
    mdot_rated = ${rated_mfr}
    c0_rated = ${c0_rated_comp}
    rho0_rated = ${rho0_rated_comp}
    speeds = '0.5208 0.6250 0.7292 0.8333 0.9375'
    Rp_functions = 'rp_comp1 rp_comp2 rp_comp3 rp_comp4 rp_comp5'
    eff_functions = 'eff_comp1 eff_comp2 eff_comp3 eff_comp4 eff_comp5'
    min_pressure_ratio = 1.0
    speed_cr_I = 0
    inertia_const = ${I_comp}
    inertia_coeff = '${I_comp} 0 0 0'
    # assume no shaft friction
    speed_cr_fr = 0
    tau_fr_const = 0
    tau_fr_coeff = '0 0 0 0'
  []
  [pipe2]
    type = FlowChannel1Phase
    position = '${x2} 0 0'
    length = ${L2}
    n_elems = ${n_elems2}
    A = ${A2}
  []
  [junction2_3]
    type = JunctionOneToOne1Phase
    connections = 'pipe2:out pipe3:in'
  []
  [pipe3]
    type = FlowChannel1Phase
    position = '${x3} 0 0'
    length = ${L3}
    n_elems = ${n_elems3}
    A = ${A3}
  []
  [junction3_4]
    type = JunctionOneToOne1Phase
    connections = 'pipe3:out pipe4:in'
  []
  [pipe4]
    type = FlowChannel1Phase
    position = '${x4} 0 0'
    length = ${L4}
    n_elems = ${n_elems4}
    A = ${A4}
  []
  [turbine]
    type = ShaftConnectedCompressor1Phase
    position = '${x5} 0 0'
    inlet = 'pipe4:out'
    outlet = 'pipe5:in'
    A_ref = ${A_ref_turb}
    volume = ${V_turb}
    treat_as_turbine = true
    omega_rated = ${speed_rated}
    mdot_rated = ${rated_mfr}
    c0_rated = ${c0_rated_comp}
    rho0_rated = ${rho0_rated_comp}
    speeds = '0 0.5208 0.6250 0.7292 0.8333 0.9375'
    Rp_functions = 'rp_turb0 rp_turb1 rp_turb2 rp_turb3 rp_turb4 rp_turb5'
    eff_functions = 'eff_turb1 eff_turb1 eff_turb2 eff_turb3 eff_turb4 eff_turb5'
    min_pressure_ratio = 1.0
    speed_cr_I = 0
    inertia_const = ${I_turb}
    inertia_coeff = '${I_turb} 0 0 0'
    # assume no shaft friction
    speed_cr_fr = 0
    tau_fr_const = 0
    tau_fr_coeff = '0 0 0 0'
  []
  [pipe5]
    type = FlowChannel1Phase
    position = '${x5} 0 0'
    length = ${L5}
    n_elems = ${n_elems5}
    A = ${A5}
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe5:out'
    p = ${p_ambient}
  []
  [heating]
    type = HeatTransferFromSpecifiedTemperature1Phase
    flow_channel = pipe3
    T_wall = ${T_hot}
    Hw = htc_wall_fn
  []
[]
[ControlLogic]
  [motor_ctrl]
    type = TimeFunctionComponentControl
    component = motor
    parameter = torque
    function = motor_torque_fn
  []
[]
[Postprocessors]
  [heating_rate]
    type = ADHeatRateConvection1Phase
    block = 'pipe3'
    T = T
    T_wall = T_wall
    Hw = Hw
    P_hf = P_hf
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [motor_torque]
    type = RealComponentParameterValuePostprocessor
    component = motor
    parameter = torque
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [motor_power]
    type = FunctionValuePostprocessor
    function = motor_power_fn
    execute_on = 'INITIAL TIMESTEP_END'
    indirect_dependencies = 'motor_torque shaft:omega'
  []
  [generator_torque]
    type = ShaftConnectedComponentPostprocessor
    quantity = torque
    shaft_connected_component_uo = generator:shaftconnected_uo
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [generator_power]
    type = FunctionValuePostprocessor
    function = generator_power_fn
    execute_on = 'INITIAL TIMESTEP_END'
    indirect_dependencies = 'generator_torque shaft:omega'
  []
  [shaft_speed]
    type = ScalarVariable
    variable = 'shaft:omega'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [p_in_comp]
    type = PointValue
    variable = p
    point = '${x2_minus} 0 0'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [p_out_comp]
    type = PointValue
    variable = p
    point = '${x2_plus} 0 0'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [p_ratio_comp]
    type = ParsedPostprocessor
    pp_names = 'p_in_comp p_out_comp'
    expression = 'p_out_comp / p_in_comp'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [p_in_turb]
    type = PointValue
    variable = p
    point = '${x5_minus} 0 0'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [p_out_turb]
    type = PointValue
    variable = p
    point = '${x5_plus} 0 0'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [p_ratio_turb]
    type = ParsedPostprocessor
    pp_names = 'p_in_turb p_out_turb'
    expression = 'p_in_turb / p_out_turb'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [mfr_comp]
    type = ADFlowJunctionFlux1Phase
    boundary = pipe1:out
    connection_index = 0
    equation = mass
    junction = compressor
  []
  [mfr_turb]
    type = ADFlowJunctionFlux1Phase
    boundary = pipe4:out
    connection_index = 0
    equation = mass
    junction = turbine
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  end_time = ${t3}
  dt = 0.1
  abort_on_solve_fail = true
  solve_type = NEWTON
  nl_rel_tol = 1e-50
  nl_abs_tol = 1e-11
  nl_max_its = 15
  l_tol = 1e-4
  l_max_its = 10
[]
[Outputs]
  [csv]
    type = CSV
    file_base = 'open_brayton_cycle'
    execute_vector_postprocessors_on = 'INITIAL'
  []
  [console]
    type = Console
    show = 'shaft_speed p_ratio_comp p_ratio_turb compressor:pressure_ratio turbine:pressure_ratio'
  []
[]
[Functions]
  # compressor pressure ratio
  [rp_comp1]
    type = PiecewiseLinear
    data_file = 'rp_comp1.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  [rp_comp2]
    type = PiecewiseLinear
    data_file = 'rp_comp2.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  [rp_comp3]
    type = PiecewiseLinear
    data_file = 'rp_comp3.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  [rp_comp4]
    type = PiecewiseLinear
    data_file = 'rp_comp4.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  [rp_comp5]
    type = PiecewiseLinear
    data_file = 'rp_comp5.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  # compressor efficiency
  [eff_comp1]
    type = ConstantFunction
    value = ${eff_comp}
  []
  [eff_comp2]
    type = ConstantFunction
    value = ${eff_comp}
  []
  [eff_comp3]
    type = ConstantFunction
    value = ${eff_comp}
  []
  [eff_comp4]
    type = ConstantFunction
    value = ${eff_comp}
  []
  [eff_comp5]
    type = ConstantFunction
    value = ${eff_comp}
  []
  # turbine pressure ratio
  [rp_turb0]
    type = ConstantFunction
    value = 1
  []
  [rp_turb1]
    type = PiecewiseLinear
    data_file = 'rp_turb1.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  [rp_turb2]
    type = PiecewiseLinear
    data_file = 'rp_turb2.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  [rp_turb3]
    type = PiecewiseLinear
    data_file = 'rp_turb3.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  [rp_turb4]
    type = PiecewiseLinear
    data_file = 'rp_turb4.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  [rp_turb5]
    type = PiecewiseLinear
    data_file = 'rp_turb5.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  # turbine efficiency
  [eff_turb1]
    type = ConstantFunction
    value = ${eff_turb}
  []
  [eff_turb2]
    type = ConstantFunction
    value = ${eff_turb}
  []
  [eff_turb3]
    type = ConstantFunction
    value = ${eff_turb}
  []
  [eff_turb4]
    type = ConstantFunction
    value = ${eff_turb}
  []
  [eff_turb5]
    type = ConstantFunction
    value = ${eff_turb}
  []
[]
(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
[]
(modules/thermal_hydraulics/test/tests/components/volume_junction_1phase/equal_area_no_junction.i)
# Tests a junction between 2 flow channels of equal area and orientation. A
# sinusoidal density shape is advected to the right and should not be affected
# by the junction; the solution should be identical to the equivalent
# no-junction solution.
#
# This input file has no junction and is used for comparison to the results with
# a junction.
[GlobalParams]
  gravity_vector = '0 0 0'
  initial_p = 1e5
  initial_vel = 1
  A = 25
  f = 0
  fp = fp
  scaling_factor_1phase = '0.04 0.04 0.04e-5'
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 1.4
    cv = 725
    p_inf = 0
    q = 0
    q_prime = 0
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Functions]
  [T0]
    type = CosineHumpFunction
    axis = x
    hump_center_position = 1
    hump_width = 0.5
    hump_begin_value = 250
    hump_center_value = 300
  []
[]
[Components]
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe1:in'
    # Stagnation property with p = 1e5 Pa, T = 250 K, vel = 1 m/s
    p0 = 100000.68965687
    T0 = 250.00049261084
  []
  [pipe1]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '1 0 0'
    length = 2
    initial_T = T0
    n_elems = 50
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe1:out'
    p = 1e5
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  start_time = 0
  dt = 0.01
  num_steps = 5
  abort_on_solve_fail = true
  solve_type = 'PJFNK'
  line_search = 'basic'
  nl_rel_tol = 0
  nl_abs_tol = 1e-6
  nl_max_its = 10
  l_tol = 1e-3
  l_max_its = 10
  [Quadrature]
    type = GAUSS
    order = SECOND
  []
[]
[Postprocessors]
  [junction_rhoA]
    type = PointValue
    variable = rhoA
    point = '1.02 0 0'
    execute_on = 'initial timestep_end'
  []
  [junction_rhouA]
    type = PointValue
    variable = rhouA
    point = '1.02 0 0'
    execute_on = 'initial timestep_end'
  []
  [junction_rhoEA]
    type = PointValue
    variable = rhoEA
    point = '1.02 0 0'
    execute_on = 'initial timestep_end'
  []
  [junction_rho]
    type = ScalePostprocessor
    value = junction_rhoA
    scaling_factor = 0.04
    execute_on = 'initial timestep_end'
  []
  [junction_rhou]
    type = ScalePostprocessor
    value = junction_rhouA
    scaling_factor = 0.04
    execute_on = 'initial timestep_end'
  []
  [junction_rhoE]
    type = ScalePostprocessor
    value = junction_rhoEA
    scaling_factor = 0.04
    execute_on = 'initial timestep_end'
  []
[]
[Outputs]
  [out]
    type = CSV
    show = 'junction_rho junction_rhou junction_rhoE'
    execute_scalars_on = 'none'
    execute_on = 'initial timestep_end'
  []
[]
(modules/thermal_hydraulics/test/tests/components/inlet_stagnation_p_t_1phase/clg.ctrl_p0_3eqn.i)
[GlobalParams]
  gravity_vector = '0 0 0'
  initial_p = 1e5
  initial_T = 300
  initial_vel = 0.0
  scaling_factor_1phase = '1 1 1e-5'
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    cv = 1816.0
    q = -1.167e6
    p_inf = 1.0e9
    q_prime = 0
    k = 0.5
    mu = 281.8e-6
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '1 0 0'
    length = 1
    n_elems = 50
    A   = 1.0000000000e-04
    D_h = 1.1283791671e-02
    f = 0.0
    fp = fp
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe:in'
    p0 = 1e5
    T0 = 300
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe:out'
    p = 1e5
  []
[]
[Functions]
  [inlet_p0_fn]
    type = PiecewiseLinear
    x = '0   1'
    y = '1e5 1.001e5'
  []
[]
[ControlLogic]
  [set_inlet_value]
    type = TimeFunctionComponentControl
    component = inlet
    parameter = p0
    function = inlet_p0_fn
  []
[]
[Postprocessors]
  [inlet_p0]
    type = RealComponentParameterValuePostprocessor
    component = inlet
    parameter = p0
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  start_time = 0.0
  dt = 0.25
  num_steps = 5
  abort_on_solve_fail = true
  solve_type = 'NEWTON'
  line_search = 'basic'
  nl_rel_tol = 1e-5
  nl_abs_tol = 1e-6
  nl_max_its = 30
  l_tol = 1e-3
  l_max_its = 100
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  [Quadrature]
    type = GAUSS
    order = SECOND
  []
[]
[Outputs]
  csv = true
[]
(modules/thermal_hydraulics/test/tests/components/junction_parallel_channels_1phase/equal_area_no_junction.i)
# Tests a junction between 2 flow channels of equal area and orientation. A
# sinusoidal density shape is advected to the right and should not be affected
# by the junction; the solution should be identical to the equivalent
# no-junction solution.
#
# This input file has no junction and is used for comparison to the results with
# a junction.
[GlobalParams]
  gravity_vector = '0 0 0'
  initial_p = 1e5
  initial_vel = 1
  A = 25
  f = 0
  fp = fp
  scaling_factor_1phase = '0.04 0.04 0.04e-5'
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 1.4
    cv = 725
    p_inf = 0
    q = 0
    q_prime = 0
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Functions]
  [T0]
    type = CosineHumpFunction
    axis = x
    hump_center_position = 1
    hump_width = 0.5
    hump_begin_value = 250
    hump_center_value = 300
  []
[]
[Components]
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe1:in'
    # Stagnation property with p = 1e5 Pa, T = 250 K, vel = 1 m/s
    p0 = 100000.68965687
    T0 = 250.00049261084
  []
  [pipe1]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '1 0 0'
    length = 2
    initial_T = T0
    n_elems = 50
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe1:out'
    p = 1e5
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  start_time = 0
  dt = 0.01
  num_steps = 5
  abort_on_solve_fail = true
  solve_type = 'PJFNK'
  line_search = 'basic'
  nl_rel_tol = 0
  nl_abs_tol = 1e-6
  nl_max_its = 10
  l_tol = 1e-3
  l_max_its = 10
  [Quadrature]
    type = GAUSS
    order = SECOND
  []
[]
[Postprocessors]
  [junction_rhoA]
    type = PointValue
    variable = rhoA
    point = '1.02 0 0'
    execute_on = 'initial timestep_end'
  []
  [junction_rhouA]
    type = PointValue
    variable = rhouA
    point = '1.02 0 0'
    execute_on = 'initial timestep_end'
  []
  [junction_rhoEA]
    type = PointValue
    variable = rhoEA
    point = '1.02 0 0'
    execute_on = 'initial timestep_end'
  []
  [junction_rho]
    type = ScalePostprocessor
    value = junction_rhoA
    scaling_factor = 0.04
    execute_on = 'initial timestep_end'
  []
  [junction_rhou]
    type = ScalePostprocessor
    value = junction_rhouA
    scaling_factor = 0.04
    execute_on = 'initial timestep_end'
  []
  [junction_rhoE]
    type = ScalePostprocessor
    value = junction_rhoEA
    scaling_factor = 0.04
    execute_on = 'initial timestep_end'
  []
[]
[Outputs]
  [out]
    type = CSV
    show = 'junction_rho junction_rhou junction_rhoE'
    execute_scalars_on = 'none'
    execute_on = 'initial timestep_end'
  []
[]
(modules/thermal_hydraulics/test/tests/postprocessors/real_component_parameter_value/non_existent_par_name.i)
[GlobalParams]
  gravity_vector = '0 0 0'
  initial_p = 1e5
  initial_T = 300
  initial_vel = 0.0
  scaling_factor_1phase = '1 1 1e-5'
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    cv = 1816.0
    q = -1.167e6
    p_inf = 1.0e9
    q_prime = 0
    k = 0.5
    mu = 281.8e-6
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '1 0 0'
    length = 1
    n_elems = 50
    A   = 1.0000000000e-04
    D_h = 1.1283791671e-02
    f = 0.0
    fp = fp
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe:in'
    p0 = 1e5
    T0 = 300
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe:out'
    p = 1e5
  []
[]
[Functions]
  [p_fn]
    type = PiecewiseLinear
    x = '0   1'
    y = '1e5 1.001e5'
  []
[]
[ControlLogic]
  [outlet_p_fn]
    type = GetFunctionValueControl
    function = p_fn
  []
  [set_outlet_value]
    type = SetComponentRealValueControl
    component = outlet
    parameter = p
    value = outlet_p_fn:value
  []
[]
[Postprocessors]
  [outlet_p]
    type = RealComponentParameterValuePostprocessor
    component = inlet
    parameter = p
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  start_time = 0.0
  dt = 0.25
  num_steps = 5
  abort_on_solve_fail = true
  solve_type = 'NEWTON'
  line_search = 'basic'
  nl_rel_tol = 1e-5
  nl_abs_tol = 1e-6
  nl_max_its = 30
  l_tol = 1e-3
  l_max_its = 100
  [Quadrature]
    type = GAUSS
    order = SECOND
  []
[]
(modules/thermal_hydraulics/test/tests/components/junction_parallel_channels_1phase/equal_area_with_junction.i)
# Tests a junction between 2 flow channels of equal area and orientation. A
# sinusoidal density shape is advected to the right and should not be affected
# by the junction; the solution should be identical to the equivalent
# no-junction solution.
[GlobalParams]
  gravity_vector = '0 0 0'
  initial_p = 1e5
  initial_vel = 1
  A = 25
  f = 0
  fp = fp
  scaling_factor_1phase = '0.04 0.04 0.04e-5'
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 1.4
    cv = 725
    p_inf = 0
    q = 0
    q_prime = 0
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Functions]
  [T0]
    type = CosineHumpFunction
    axis = x
    hump_center_position = 1
    hump_width = 0.5
    hump_begin_value = 250
    hump_center_value = 300
  []
[]
[Components]
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe1:in'
    # Stagnation property with p = 1e5 Pa, T = 250 K, vel = 1 m/s
    p0 = 100000.68965687
    T0 = 250.00049261084
  []
  [pipe1]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '1 0 0'
    length = 1
    initial_T = T0
    n_elems = 25
  []
  [junction]
    type = JunctionParallelChannels1Phase
    connections = 'pipe1:out pipe2:in'
    position = '1.02 0 0'
    volume = 1.0
    initial_T = T0
    initial_vel_x = 1
    initial_vel_y = 0
    initial_vel_z = 0
    scaling_factor_rhoV  = 1
    scaling_factor_rhouV = 1
    scaling_factor_rhovV = 1
    scaling_factor_rhowV = 1
    scaling_factor_rhoEV = 1e-5
  []
  [pipe2]
    type = FlowChannel1Phase
    position = '1.04 0 0'
    orientation = '1 0 0'
    length = 0.96
    initial_T = T0
    n_elems = 24
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe2:out'
    p = 1e5
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  start_time = 0
  dt = 0.01
  num_steps = 5
  abort_on_solve_fail = true
  solve_type = 'NEWTON'
  petsc_options_iname = '-pc_type'
  petsc_options_value = ' lu'
  line_search = 'basic'
  nl_rel_tol = 0
  nl_abs_tol = 1e-6
  nl_max_its = 10
  l_tol = 1e-3
  l_max_its = 10
  [Quadrature]
    type = GAUSS
    order = SECOND
  []
[]
[Postprocessors]
  [junction_rho]
    type = ElementAverageValue
    variable = rhoV
    block = 'junction'
    execute_on = 'initial timestep_end'
  []
  [junction_rhou]
    type = ElementAverageValue
    variable = rhouV
    block = 'junction'
    execute_on = 'initial timestep_end'
  []
  [junction_rhoE]
    type = ElementAverageValue
    variable = rhoEV
    block = 'junction'
    execute_on = 'initial timestep_end'
  []
[]
[Outputs]
  [out]
    type = CSV
    execute_scalars_on = 'none'
    execute_on = 'initial timestep_end'
  []
[]
(modules/thermal_hydraulics/test/tests/components/inlet_mass_flow_rate_1phase/phy.reversed_flow.i)
[GlobalParams]
  gravity_vector = '0 0 0'
  initial_T = 444.447
  initial_p = 7e6
  initial_vel = 0
  closures = simple_closures
[]
[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]
  [pipe]
    type = FlowChannel1Phase
    fp = fp
    # geometry
    position = '0 0 0'
    orientation = '1 0 0'
    A   = 1.0000000000e-04
    D_h  = 1.1283791671e-02
    f = 0.1
    length = 1
    n_elems = 20
  []
  [in]
    type = InletMassFlowRateTemperature1Phase
    input = 'pipe:in'
    m_dot = -0.18
    T     = 444.447
  []
  [out]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe:out'
    p0 = 7e6
    T0 = 444.447
  []
[]
[Preconditioning]
  [SMP_PJFNK]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  dt = 0.1
  start_time = 0.0
  num_steps = 30
  solve_type = 'NEWTON'
  line_search = 'basic'
  nl_rel_tol = 0
  nl_abs_tol = 1e-6
  nl_max_its = 10
  l_tol = 1e-3
  l_max_its = 100
  abort_on_solve_fail = true
[]
[Outputs]
  [exodus]
    type = Exodus
    file_base = phy.reversed_flow
    show = 'rhouA T p'
  []
[]
(modules/thermal_hydraulics/test/tests/problems/brayton_cycle/recuperated_brayton_cycle.i)
# This input file models an open, recuperated Brayton cycle with a PID
# controlled start up using a coupled motor.
#
# Heat is supplied to the system by a volumetric heat source, and a second heat
# source is used to model a recuperator. The recuperator transfers heat from the
# turbine exhaust gas to the compressor outlet gas.
#
# Initially the fluid and heat structures are at rest at ambient conditions,
# and the shaft speed is zero.
# The transient is controlled as follows:
#   * 0   - 2000 s: Motor increases shaft speed to approx. 85,000 RPM by PID control
#   * 1000 - 8600 s: Power in main heat source increases from 0 - 104 kW
#   * 2000 - 200000 s: Torque supplied by turbine increases to steady state level
#                      as working fluid temperature increases. Torque supplied by
#                      the motor is ramped down to 0 N-m transitioning shaft control
#                      to the turbine at its rated speed of 96,000 RPM.
I_motor = 1.0
I_generator = 1.0
generator_torque_per_shaft_speed = -0.00025
motor_ramp_up_duration = 3605
motor_ramp_down_duration = 1800
post_motor_time = 2160000
t1 = ${motor_ramp_up_duration}
t2 = ${fparse t1 + motor_ramp_down_duration}
t3 = ${fparse t2 + post_motor_time}
D1 = 0.15
D2 = ${D1}
D3 = ${D1}
D4 = ${D1}
D5 = ${D1}
D6 = ${D1}
D7 = ${D1}
D8 = ${D1}
A1 = ${fparse 0.25 * pi * D1^2}
A2 = ${fparse 0.25 * pi * D2^2}
A3 = ${fparse 0.25 * pi * D3^2}
A4 = ${fparse 0.25 * pi * D4^2}
A5 = ${fparse 0.25 * pi * D5^2}
A6 = ${fparse 0.25 * pi * D6^2}
A7 = ${fparse 0.25 * pi * D7^2}
A8 = ${fparse 0.25 * pi * D8^2}
recuperator_width = 0.15
L1 = 5.0
L2 = ${L1}
L3 = ${fparse 2 * L1}
L4 = ${fparse 2 * L1}
L5 = ${L1}
L6 = ${L1}
L7 = ${fparse L1 + recuperator_width}
L8 = ${L1}
x1 = 0.0
x2 = ${fparse x1 + L1}
x3 = ${fparse x2 + L2}
x4 = ${x3}
x5 = ${fparse x4 - L4}
x6 = ${x5}
x7 = ${fparse x6 + L6}
x8 = ${fparse x7 + L7}
y1 = 0
y2 = ${y1}
y3 = ${y2}
y4 = ${fparse y3 - L3}
y5 = ${y4}
y6 = ${fparse y5 + L5}
y7 = ${y6}
y8 = ${y7}
x1_out = ${fparse x1 + L1 - 0.001}
x2_in = ${fparse x2 + 0.001}
y5_in = ${fparse y5 + 0.001}
x6_out = ${fparse x6 + L6 - 0.001}
x7_in = ${fparse x7 + 0.001}
y8_in = ${fparse y8 + 0.001}
y8_out = ${fparse y8 + L8 - 0.001}
hot_leg_in = ${y8_in}
hot_leg_out = ${y8_out}
cold_leg_in = ${fparse y3 - 0.001}
cold_leg_out = ${fparse y3 - (L3/2) - 0.001}
n_elems1 = 5
n_elems2 = ${n_elems1}
n_elems3 = ${fparse 2 * n_elems1}
n_elems4 = ${fparse 2 * n_elems1}
n_elems5 = ${n_elems1}
n_elems6 = ${n_elems1}
n_elems7 = ${n_elems1}
n_elems8 = ${n_elems1}
A_ref_comp = ${fparse 0.5 * (A1 + A2)}
V_comp = ${fparse A_ref_comp * 1.0}
I_comp = 1.0
A_ref_turb = ${fparse 0.5 * (A4 + A5)}
V_turb = ${fparse A_ref_turb * 1.0}
I_turb = 1.0
c0_rated_comp = 351.6925137
rho0_rated_comp = 1.146881112
rated_mfr = 0.25
speed_rated_rpm = 96000
speed_rated = ${fparse speed_rated_rpm * 2 * pi / 60.0}
speed_initial = 0
eff_comp = 0.79
eff_turb = 0.843
T_ambient = 300
p_ambient = 1e5
hs_power = 105750
[GlobalParams]
  gravity_vector = '0 0 0'
  initial_p = ${p_ambient}
  initial_T = ${T_ambient}
  initial_vel = 0
  initial_vel_x = 0
  initial_vel_y = 0
  initial_vel_z = 0
  fp = fp_air
  closures = closures
  f = 0
  scaling_factor_1phase = '1 1 1e-5'
  scaling_factor_rhoV = 1
  scaling_factor_rhouV = 1e-2
  scaling_factor_rhovV = 1e-2
  scaling_factor_rhowV = 1e-2
  scaling_factor_rhoEV = 1e-5
  scaling_factor_temperature = 1e-2
  rdg_slope_reconstruction = none
[]
[FluidProperties]
  [fp_air]
    type = IdealGasFluidProperties
    emit_on_nan = none
  []
[]
[SolidProperties]
  [steel]
    type = ThermalFunctionSolidProperties
    rho = 8050
    k = 45
    cp = 466
  []
[]
[Closures]
  [closures]
    type = Closures1PhaseSimple
  []
[]
[Functions]
  ##########################
  # Motor
  ##########################
  # Functions for control logic that determines when to shut off the PID system
  [is_tripped_fn]
    type = ParsedFunction
    symbol_names = 'motor_torque turbine_torque'
    symbol_values = 'motor_torque turbine_torque'
    expression = 'turbine_torque > motor_torque'
  []
  [PID_tripped_constant_value]
    type = ConstantFunction
    value = 1
  []
  [PID_tripped_status_fn]
    type = ParsedFunction
    symbol_values = 'PID_trip_status'
    symbol_names = 'PID_trip_status'
    expression = 'PID_trip_status'
  []
  [time_fn]
    type = ParsedFunction
    expression = t
  []
  # Shutdown function which ramps down the motor once told by the control logic
  [motor_torque_fn_shutdown]
    type = ParsedFunction
    symbol_values = 'PID_trip_status time_trip'
    symbol_names = 'PID_trip_status time_trip'
    expression = 'if(PID_trip_status = 1, max(2.4 - (2.4 * ((t - time_trip) / 35000)),0.0), 1)'
  []
  # Generates motor power curve
  [motor_power_fn]
    type = ParsedFunction
    expression = 'torque * speed'
    symbol_names = 'torque speed'
    symbol_values = 'motor_torque shaft:omega'
  []
  ##########################
  # Generator
  ##########################
  # Generates generator torque curve
  [generator_torque_fn]
    type = ParsedFunction
    expression = 'slope * t'
    symbol_names = 'slope'
    symbol_values = '${generator_torque_per_shaft_speed}'
  []
  # Generates generator power curve
  [generator_power_fn]
    type = ParsedFunction
    expression = 'torque * speed'
    symbol_names = 'torque speed'
    symbol_values = 'generator_torque shaft:omega'
  []
  ##########################
  # Reactor
  ##########################
  # Ramps up reactor power when activated by control logic
  [power_fn]
    type = PiecewiseLinear
    x = '0 1000 8600'
    y = '0 0 ${hs_power}'
  []
  ##########################
  # Compressor
  ##########################
  # compressor pressure ratios
  [rp_comp1]
    type = PiecewiseLinear
    data_file = 'rp_comp1.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  [rp_comp2]
    type = PiecewiseLinear
    data_file = 'rp_comp2.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  [rp_comp3]
    type = PiecewiseLinear
    data_file = 'rp_comp3.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  [rp_comp4]
    type = PiecewiseLinear
    data_file = 'rp_comp4.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  [rp_comp5]
    type = PiecewiseLinear
    data_file = 'rp_comp5.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  # compressor efficiencies
  [eff_comp1]
    type = ConstantFunction
    value = ${eff_comp}
  []
  [eff_comp2]
    type = ConstantFunction
    value = ${eff_comp}
  []
  [eff_comp3]
    type = ConstantFunction
    value = ${eff_comp}
  []
  [eff_comp4]
    type = ConstantFunction
    value = ${eff_comp}
  []
  [eff_comp5]
    type = ConstantFunction
    value = ${eff_comp}
  []
  ##########################
  # Turbine
  ##########################
  # turbine pressure ratios
  [rp_turb0]
    type = ConstantFunction
    value = 1
  []
  [rp_turb1]
    type = PiecewiseLinear
    data_file = 'rp_turb1.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  [rp_turb2]
    type = PiecewiseLinear
    data_file = 'rp_turb2.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  [rp_turb3]
    type = PiecewiseLinear
    data_file = 'rp_turb3.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  [rp_turb4]
    type = PiecewiseLinear
    data_file = 'rp_turb4.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  [rp_turb5]
    type = PiecewiseLinear
    data_file = 'rp_turb5.csv'
    x_index_in_file = 0
    y_index_in_file = 1
    format = columns
    extrap = true
  []
  # turbine efficiency
  [eff_turb1]
    type = ConstantFunction
    value = ${eff_turb}
  []
  [eff_turb2]
    type = ConstantFunction
    value = ${eff_turb}
  []
  [eff_turb3]
    type = ConstantFunction
    value = ${eff_turb}
  []
  [eff_turb4]
    type = ConstantFunction
    value = ${eff_turb}
  []
  [eff_turb5]
    type = ConstantFunction
    value = ${eff_turb}
  []
[]
[Components]
  # system inlet pulling air from the open atmosphere
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe1:in'
    p0 = ${p_ambient}
    T0 = ${T_ambient}
  []
  # Inlet pipe
  [pipe1]
    type = FlowChannel1Phase
    position = '${x1} ${y1} 0'
    orientation = '1 0 0'
    length = ${L1}
    n_elems = ${n_elems1}
    A = ${A1}
  []
  # Compressor as defined in MAGNET PCU document (Guillen 2020)
  [compressor]
    type = ShaftConnectedCompressor1Phase
    position = '${x2} ${y2} 0'
    inlet = 'pipe1:out'
    outlet = 'pipe2:in'
    A_ref = ${A_ref_comp}
    volume = ${V_comp}
    omega_rated = ${speed_rated}
    mdot_rated = ${rated_mfr}
    c0_rated = ${c0_rated_comp}
    rho0_rated = ${rho0_rated_comp}
    # Determines which compression ratio curve and efficiency curve to use depending on ratio of speed/rated_speed
    speeds = '0.5208 0.6250 0.7292 0.8333 0.9375'
    Rp_functions = 'rp_comp1 rp_comp2 rp_comp3 rp_comp4 rp_comp5'
    eff_functions = 'eff_comp1 eff_comp2 eff_comp3 eff_comp4 eff_comp5'
    min_pressure_ratio = 1.0
    speed_cr_I = 0
    inertia_const = ${I_comp}
    inertia_coeff = '${I_comp} 0 0 0'
    # assume no shaft friction
    speed_cr_fr = 0
    tau_fr_const = 0
    tau_fr_coeff = '0 0 0 0'
  []
  # Outlet pipe from the compressor
  [pipe2]
    type = FlowChannel1Phase
    position = '${x2} ${y2} 0'
    orientation = '1 0 0'
    length = ${L2}
    n_elems = ${n_elems2}
    A = ${A2}
  []
  # 90 degree connection between pipe 2 and 3
  [junction2_cold_leg]
    type = VolumeJunction1Phase
    connections = 'pipe2:out cold_leg:in'
    position = '${x3} ${y3} 0'
    volume = ${fparse A2*0.1}
  []
  # Cold leg of the recuperator
  [cold_leg]
    type = FlowChannel1Phase
    position = '${x3} ${y3} 0'
    orientation = '0 -1 0'
    length = ${fparse L3/2}
    n_elems = ${fparse n_elems3/2}
    A = ${A3}
  []
  # Recuperator which transfers heat from exhaust gas to reactor inlet gas to improve thermal efficency
  [recuperator]
    type = HeatStructureCylindrical
    orientation = '0 -1 0'
    position = '${x3} ${y3} 0'
    length = ${fparse L3/2}
    widths = ${recuperator_width}
    n_elems = ${fparse n_elems3/2}
    n_part_elems = 2
    names = recuperator
    solid_properties = steel
    solid_properties_T_ref = '300'
    inner_radius = ${D1}
  []
  # heat transfer from recuperator to cold leg
  [heat_transfer_cold_leg]
    type = HeatTransferFromHeatStructure1Phase
    flow_channel = cold_leg
    hs = recuperator
    hs_side = OUTER
    Hw = 10000
  []
  # heat transfer from hot leg to recuperator
  [heat_transfer_hot_leg]
    type = HeatTransferFromHeatStructure1Phase
    flow_channel = hot_leg
    hs = recuperator
    hs_side = INNER
    Hw = 10000
  []
  [junction_cold_leg_3]
    type = JunctionOneToOne1Phase
    connections = 'cold_leg:out pipe3:in'
  []
  [pipe3]
    type = FlowChannel1Phase
    position = '${x3} ${fparse y3 - (L3/2)} 0'
    orientation = '0 -1 0'
    length = ${fparse L3/2}
    n_elems = ${fparse n_elems3/2}
    A = ${A3}
  []
  # 90 degree connection between pipe 3 and 4
  [junction3_4]
    type = VolumeJunction1Phase
    connections = 'pipe3:out pipe4:in'
    position = '${x4} ${y4} 0'
    volume = ${fparse A3*0.1}
  []
  # Pipe through the "reactor core"
  [pipe4]
    type = FlowChannel1Phase
    position = '${x4} ${y4} 0'
    orientation = '-1 0 0'
    length = ${L4}
    n_elems = ${n_elems4}
    A = ${A4}
  []
  # "Reactor Core" and it's associated heat transfer to pipe 4
  [reactor]
    type = HeatStructureCylindrical
    orientation = '-1 0 0'
    position = '${x4} ${y4} 0'
    length = ${L4}
    widths = 0.15
    n_elems = ${n_elems4}
    n_part_elems = 2
    names = core
    solid_properties = steel
    solid_properties_T_ref = '300'
  []
  [total_power]
    type = TotalPower
    power = 0
  []
  [heat_generation]
    type = HeatSourceFromTotalPower
    power = total_power
    hs = reactor
    regions = core
  []
  [heat_transfer]
    type = HeatTransferFromHeatStructure1Phase
    flow_channel = pipe4
    hs = reactor
    hs_side = OUTER
    Hw = 10000
  []
  # 90 degree connection between pipe 4 and 5
  [junction4_5]
    type = VolumeJunction1Phase
    connections = 'pipe4:out pipe5:in'
    position = '${x5} ${y5} 0'
    volume = ${fparse A4*0.1}
  []
  # Pipe carrying hot gas back to the PCU
  [pipe5]
    type = FlowChannel1Phase
    position = '${x5} ${y5} 0'
    orientation = '0 1 0'
    length = ${L5}
    n_elems = ${n_elems5}
    A = ${A5}
  []
  # 90 degree connection between pipe 5 and 6
  [junction5_6]
    type = VolumeJunction1Phase
    connections = 'pipe5:out pipe6:in'
    position = '${x6} ${y6} 0'
    volume = ${fparse A5*0.1}
  []
  # Inlet pipe to the turbine
  [pipe6]
    type = FlowChannel1Phase
    position = '${x6} ${y6} 0'
    orientation = '1 0 0'
    length = ${L6}
    n_elems = ${n_elems6}
    A = ${A6}
  []
  # Turbine as defined in MAGNET PCU document (Guillen 2020) and (Wright 2006)
  [turbine]
    type = ShaftConnectedCompressor1Phase
    position = '${x7} ${y7} 0'
    inlet = 'pipe6:out'
    outlet = 'pipe7:in'
    A_ref = ${A_ref_turb}
    volume = ${V_turb}
    # A turbine is treated as an "inverse" compressor, this value determines if component is to be treated as turbine or compressor
    # If treat_as_turbine is omitted, code automatically assumes it is a compressor
    treat_as_turbine = true
    omega_rated = ${speed_rated}
    mdot_rated = ${rated_mfr}
    c0_rated = ${c0_rated_comp}
    rho0_rated = ${rho0_rated_comp}
    # Determines which compression ratio curve and efficiency curve to use depending on ratio of speed/rated_speed
    speeds = '0 0.5208 0.6250 0.7292 0.8333 0.9375'
    Rp_functions = 'rp_turb0 rp_turb1 rp_turb2 rp_turb3 rp_turb4 rp_turb5'
    eff_functions = 'eff_turb1 eff_turb1 eff_turb2 eff_turb3 eff_turb4 eff_turb5'
    min_pressure_ratio = 1.0
    speed_cr_I = 0
    inertia_const = ${I_turb}
    inertia_coeff = '${I_turb} 0 0 0'
    # assume no shaft friction
    speed_cr_fr = 0
    tau_fr_const = 0
    tau_fr_coeff = '0 0 0 0'
  []
  # Outlet pipe from turbine
  [pipe7]
    type = FlowChannel1Phase
    position = '${x7} ${y7} 0'
    orientation = '1 0 0'
    length = ${L7}
    n_elems = ${n_elems7}
    A = ${A7}
  []
  # 90 degree connection between pipe 7 and 8
  [junction7_hot_leg]
    type = VolumeJunction1Phase
    connections = 'pipe7:out hot_leg:in'
    position = '${x8} ${y8} 0'
    volume = ${fparse A7*0.1}
  []
  # Hot leg of the recuperator
  [hot_leg]
    type = FlowChannel1Phase
    position = '${x8} ${y8} 0'
    orientation = '0 1 0'
    length = ${L8}
    n_elems = ${n_elems8}
    A = ${A8}
  []
  # System outlet dumping exhaust gas to the atmosphere
  [outlet]
    type = Outlet1Phase
    input = 'hot_leg:out'
    p = ${p_ambient}
  []
  # Roatating shaft connecting motor, compressor, turbine, and generator
  [shaft]
    type = Shaft
    connected_components = 'motor compressor turbine generator'
    initial_speed = ${speed_initial}
  []
  # 3-Phase electircal motor used for system start-up, controlled by PID
  [motor]
    type = ShaftConnectedMotor
    inertia = ${I_motor}
    torque = 0 # controlled
  []
  # Electric generator supplying power to the grid
  [generator]
    type = ShaftConnectedMotor
    inertia = ${I_generator}
    torque = generator_torque_fn
  []
[]
# Control logics which govern startup of the motor, startup of the "reactor core", and shutdown of the motor
[ControlLogic]
  # Sets desired shaft speed to be reached by motor NOTE: SHOULD BE SET LOWER THAN RATED TURBINE RPM
  [set_point]
    type = GetFunctionValueControl
    function = ${fparse speed_rated_rpm - 9000}
  []
  # PID with gains determined by iterative process NOTE: Gain values are system specific
  [initial_motor_PID]
    type = PIDControl
    set_point = set_point:value
    input = shaft_RPM
    initial_value = 0
    K_p = 0.0011
    K_i = 0.00000004
    K_d = 0
  []
  # Determines when the PID system should be running and when it should begin the shutdown cycle. If needed: PID output, else: shutdown function
  [logic]
    type = ParsedFunctionControl
    function = 'if(motor+0.5 > turb, PID, shutdown_fn)'
    symbol_names = 'motor turb PID shutdown_fn'
    symbol_values = 'motor_torque turbine_torque initial_motor_PID:output motor_torque_fn_shutdown'
  []
  # Takes the output generated in [logic] and applies it to the motor torque
  [motor_PID]
    type = SetComponentRealValueControl
    component = motor
    parameter = torque
    value = logic:value
  []
  # Determines when to turn on heat source
  [power_logic]
    type = ParsedFunctionControl
    function = 'power_fn'
    symbol_names = 'power_fn'
    symbol_values = 'power_fn'
  []
  # Applies heat source to the total_power block
  [power_applied]
    type = SetComponentRealValueControl
    component = total_power
    parameter = power
    value = power_logic:value
  []
[]
[Controls]
  # Enables set_PID_tripped
  [PID_trip_status]
    type = ConditionalFunctionEnableControl
    conditional_function = is_tripped_fn
    enable_objects = 'AuxScalarKernels::PID_trip_status_aux'
    execute_on = 'TIMESTEP_END'
  []
  # Enables set_time_PID
  [time_PID]
    type = ConditionalFunctionEnableControl
    conditional_function = PID_tripped_status_fn
    disable_objects = 'AuxScalarKernels::time_trip_aux'
    execute_on = 'TIMESTEP_END'
  []
[]
[AuxVariables]
  # Creates a variable that will later be set to the time when tau_turbine > tau_motor
  [time_trip]
    order = FIRST
    family = SCALAR
  []
  # Creates variable which indicates if tau_turbine > tau_motor....... If tau_motor > tau_turbine, 0, else 1
  [PID_trip_status]
    order = FIRST
    family = SCALAR
    initial_condition = 0
  []
[]
[AuxScalarKernels]
  # Creates variable from time_fn which indicates when tau_turbine > tau_motor
  [time_trip_aux]
    type = FunctionScalarAux
    function = time_fn
    variable = time_trip
    execute_on = 'TIMESTEP_END'
  []
  # Overwrites variable PID_trip_status to the value from PID_tripped_constant_value (changes 0 to 1)
  [PID_trip_status_aux]
    type = FunctionScalarAux
    function = PID_tripped_constant_value
    variable = PID_trip_status
    execute_on = 'TIMESTEP_END'
    enable = false
  []
[]
[Postprocessors]
  # Indicates when tau_turbine > tau_motor
  [trip_time]
    type = ScalarVariable
    variable = time_trip
    execute_on = 'TIMESTEP_END'
  []
  ##########################
  # Motor
  ##########################
  [motor_torque]
    type = RealComponentParameterValuePostprocessor
    component = motor
    parameter = torque
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [motor_power]
    type = FunctionValuePostprocessor
    function = motor_power_fn
    execute_on = 'INITIAL TIMESTEP_END'
  []
  ##########################
  # generator
  ##########################
  [generator_torque]
    type = ShaftConnectedComponentPostprocessor
    quantity = torque
    shaft_connected_component_uo = generator:shaftconnected_uo
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [generator_power]
    type = FunctionValuePostprocessor
    function = generator_power_fn
    execute_on = 'INITIAL TIMESTEP_END'
  []
  ##########################
  # Shaft
  ##########################
  # Speed in rad/s
  [shaft_speed]
    type = ScalarVariable
    variable = 'shaft:omega'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  # speed in RPM
  [shaft_RPM]
    type = ParsedPostprocessor
    pp_names = 'shaft_speed'
    expression = '(shaft_speed * 60) /( 2 * ${fparse pi})'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  ##########################
  # Compressor
  ##########################
  [comp_dissipation_torque]
    type = ElementAverageValue
    variable = dissipation_torque
    block = 'compressor'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [comp_isentropic_torque]
    type = ElementAverageValue
    variable = isentropic_torque
    block = 'compressor'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [comp_friction_torque]
    type = ElementAverageValue
    variable = friction_torque
    block = 'compressor'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [compressor_torque]
    type = ParsedPostprocessor
    pp_names = 'comp_dissipation_torque comp_isentropic_torque comp_friction_torque'
    expression = 'comp_dissipation_torque + comp_isentropic_torque + comp_friction_torque'
  []
  [p_in_comp]
    type = PointValue
    variable = p
    point = '${x1_out} ${y1} 0'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [p_out_comp]
    type = PointValue
    variable = p
    point = '${x2_in} ${y2} 0'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [p_ratio_comp]
    type = ParsedPostprocessor
    pp_names = 'p_in_comp p_out_comp'
    expression = 'p_out_comp / p_in_comp'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [T_in_comp]
    type = PointValue
    variable = T
    point = '${x1_out} ${y1} 0'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [T_out_comp]
    type = PointValue
    variable = T
    point = '${x2_in} ${y2} 0'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [T_ratio_comp]
    type = ParsedPostprocessor
    pp_names = 'T_in_comp T_out_comp'
    expression = '(T_out_comp - T_in_comp) / T_out_comp'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [mfr_comp]
    type = ADFlowJunctionFlux1Phase
    boundary = pipe1:out
    connection_index = 0
    equation = mass
    junction = compressor
  []
  ##########################
  # turbine
  ##########################
  [turb_dissipation_torque]
    type = ElementAverageValue
    variable = dissipation_torque
    block = 'turbine'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [turb_isentropic_torque]
    type = ElementAverageValue
    variable = isentropic_torque
    block = 'turbine'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [turb_friction_torque]
    type = ElementAverageValue
    variable = friction_torque
    block = 'turbine'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [turbine_torque]
    type = ParsedPostprocessor
    pp_names = 'turb_dissipation_torque turb_isentropic_torque turb_friction_torque'
    expression = 'turb_dissipation_torque + turb_isentropic_torque + turb_friction_torque'
  []
  [p_in_turb]
    type = PointValue
    variable = p
    point = '${x6_out} ${y6} 0'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [p_out_turb]
    type = PointValue
    variable = p
    point = '${x7_in} ${y7} 0'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [p_ratio_turb]
    type = ParsedPostprocessor
    pp_names = 'p_in_turb p_out_turb'
    expression = 'p_in_turb / p_out_turb'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [T_in_turb]
    type = PointValue
    variable = T
    point = '${x6_out} ${y6} 0'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [T_out_turb]
    type = PointValue
    variable = T
    point = '${x7_in} ${y7} 0'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [mfr_turb]
    type = ADFlowJunctionFlux1Phase
    boundary = pipe6:out
    connection_index = 0
    equation = mass
    junction = turbine
  []
  ##########################
  # Recuperator
  ##########################
  [cold_leg_in]
    type = PointValue
    variable = T
    point = '${x3} ${cold_leg_in} 0'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [cold_leg_out]
    type = PointValue
    variable = T
    point = '${x3} ${cold_leg_out} 0'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [hot_leg_in]
    type = PointValue
    variable = T
    point = '${x8} ${hot_leg_in} 0'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [hot_leg_out]
    type = PointValue
    variable = T
    point = '${x8} ${hot_leg_out} 0'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  ##########################
  # Reactor
  ##########################
  [reactor_inlet]
    type = PointValue
    variable = T
    point = '${x4} ${y4} 0'
    execute_on = 'INITIAL TIMESTEP_END'
  []
  [reactor_outlet]
    type = PointValue
    variable = T
    point = '${x5} ${y5_in} 0'
    execute_on = 'INITIAL TIMESTEP_END'
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  end_time = ${t3}
  [TimeStepper]
    type = IterationAdaptiveDT
    dt = 0.01
    growth_factor = 1.1
    cutback_factor = 0.9
  []
  dtmin = 1e-5
  dtmax = 1000
  steady_state_detection = true
  steady_state_start_time = 200000
  solve_type = NEWTON
  nl_rel_tol = 1e-8
  nl_abs_tol = 1e-8
  nl_max_its = 15
  l_tol = 1e-4
  l_max_its = 10
  petsc_options_iname  = '-pc_type'
  petsc_options_value  = ' lu     '
[]
[Outputs]
  [e]
    type = Exodus
    file_base = 'recuperated_brayton_cycle_out'
  []
  [csv]
    type = CSV
    file_base = 'recuperated_brayton_cycle'
    execute_vector_postprocessors_on = 'INITIAL'
  []
  [console]
    type = Console
    show = 'shaft_speed p_ratio_comp p_ratio_turb pressure_ratio pressure_ratio'
  []
[]
(modules/thermal_hydraulics/test/tests/components/junction_parallel_channels_1phase/jac.test.i)
# Pump data used in this test comes from the LOFT Systems Tests, described in NUREG/CR-0247
[GlobalParams]
  initial_p = 1e5
  initial_T = 300
  initial_vel = 1
  closures = simple_closures
  fp = fp
  f = 0
  scaling_factor_1phase = '1e-2 1e-2 1e-5'
  scaling_factor_rhoEV = 1e-5
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    q = -1167e3
    q_prime = 0
    p_inf = 1.e9
    cv = 1816
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [in]
    type = InletStagnationPressureTemperature1Phase
    input = fch1:in
    p0 = 1.1e5
    T0 = 300
  []
  [fch1]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '1 0 0'
    length = 1
    n_elems = 1
    A = 1
  []
  [junction]
    type = JunctionParallelChannels1Phase
    connections = 'fch1:out fch2:in'
    position = '1 0 0'
    volume = 0.3
    initial_vel_x = 1
    initial_vel_y = 0
    initial_vel_z = 0
  []
  [fch2]
    type = FlowChannel1Phase
    position = '1 0 0'
    orientation = '1 0 0'
    length = 1
    n_elems = 1
    A = 1.5
  []
  [out]
    type = Outlet1Phase
    input = fch2:out
    p = 1e5
  []
[]
[Preconditioning]
  [SMP_PJFNK]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  start_time = 0
  num_steps = 1
  abort_on_solve_fail = true
  dt = 0.1
  solve_type = 'newton'
  line_search = 'basic'
  petsc_options_iname = '-snes_test_err'
  petsc_options_value = '1e-9'
  nl_rel_tol = 1e-8
  nl_abs_tol = 1e-6
  nl_max_its = 15
  l_tol = 1e-4
  l_max_its = 10
[]
(modules/thermal_hydraulics/test/tests/controls/set_component_real_value_control/test.i)
# This is testing that the values set by SetComponentRealValueControl are used.
# Function T0_fn prescribes values for T0 at inlet. We output the function
# values via a postprocessor `T_fn` and the inlet values via another
# postprocessor `T_ctrl`. Those two values have to be equal.
[GlobalParams]
  initial_p = 100.e3
  initial_vel = 1.0
  initial_T = 350.
  scaling_factor_1phase = '1 1e-2 1e-4'
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    q = -1167e3
    q_prime = 0
    p_inf = 1.e9
    cv = 1816
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe1]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 0'
    orientation = '1 0 0'
    length = 15.0
    n_elems = 10
    A    = 0.01
    D_h  = 0.1
    f = 0.01
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe1:in'
    p0 = 100.e3
    T0 = 350.
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe1:out'
    p = 100.0e3
  []
[]
[Functions]
  [T0_fn]
    type = PiecewiseLinear
    x = '0 1'
    y = '350 345'
  []
[]
[ControlLogic]
  [T_inlet_fn]
    type = GetFunctionValueControl
    function = T0_fn
  []
  [set_inlet_value]
    type = SetComponentRealValueControl
    component = inlet
    parameter = T0
    value = T_inlet_fn:value
  []
[]
[Postprocessors]
  [T_fn]
    type = FunctionValuePostprocessor
    function = T0_fn
  []
  [T_ctrl]
    type = RealComponentParameterValuePostprocessor
    component = inlet
    parameter = T0
  []
[]
[Preconditioning]
  [SMP_PJFNK]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  dt = 0.1
  abort_on_solve_fail = true
  solve_type = 'PJFNK'
  line_search = 'basic'
  nl_rel_tol = 1e-6
  nl_abs_tol = 1e-6
  nl_max_its = 20
  l_tol = 1e-3
  l_max_its = 5
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  start_time = 0.0
  end_time = 1
[]
[Outputs]
  csv = true
[]
(modules/thermal_hydraulics/test/tests/components/heat_transfer_from_heat_structure_1phase/err.1phase.i)
[GlobalParams]
  initial_p = 1e5
  initial_vel = 0
  initial_T = 300
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = IdealGasFluidProperties
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[SolidProperties]
  [fuel-mat]
    type = ThermalFunctionSolidProperties
    k = 2.5
    cp = 300.
    rho = 1.032e4
  []
[]
[Components]
  [pipe]
    type = FlowChannel1Phase
    position = '0 0.1 0'
    orientation = '0 0 1'
    length = 4
    n_elems = 2
    A = 8.78882e-5
    D_h = 0.01179
    f = 0.01
    fp = fp
  []
  [hs]
    type = HeatStructureCylindrical
    position = '0 0 0'
    orientation = '0 0 1'
    length = 4
    n_elems = 2
    names = 'fuel'
    widths = '0.1'
    n_part_elems = '1'
    solid_properties = 'fuel-mat'
    solid_properties_T_ref = '300'
    initial_T = 300
  []
  [hx]
    type = HeatTransferFromHeatStructure1Phase
    hs = hs
    hs_side = outer
    flow_channel = pipe
    P_hf = 0.029832559676
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe:in'
    p0 = 1e5
    T0 = 300
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe:out'
    p = 1e5
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  dt = 1.e-5
  solve_type = 'NEWTON'
  num_steps = 1
  abort_on_solve_fail = true
[]
(modules/thermal_hydraulics/test/tests/controls/dependency/test.i)
# This is testing that controls are executed in the correct order
#
# If controls are executed in the right order, then T_inlet_ctrl
# reads the value of temperature (T = 345 K) from a function. Then
# this value is set into the BC and then is it sampled by a
# postprocessor whose value is then written into a CSV file.
#
# If controls were executed in the wrong order, we would sample the
# stagnation temperature function at time t = 0, which would give
# T = 360 K back, and we would see this value in the CSV file instead.
[GlobalParams]
  initial_p = 100.e3
  initial_vel = 1.0
  initial_T = 350.
  scaling_factor_1phase = '1 1e-2 1e-4'
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    q = -1167e3
    q_prime = 0
    p_inf = 1.e9
    cv = 1816
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe1]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 0'
    orientation = '1 0 0'
    length = 15.0
    n_elems = 10
    A    = 0.01
    D_h  = 0.1
    f = 0.01
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe1:in'
    p0 = 100.e3
    T0 = 355.
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe1:out'
    p = 100.0e3
  []
[]
[Functions]
  # Stagnation temperature in time
  [T0_fn]
    type = PiecewiseLinear
    x = '0   1e-5'
    y = '360 345'
  []
[]
[ControlLogic]
  [set_inlet_value_ctrl]
    type = SetComponentRealValueControl
    component = inlet
    parameter = T0
    value = T_inlet_ctrl:value
  []
  [T_inlet_ctrl]
    type = GetFunctionValueControl
    function = T0_fn
  []
[]
[Postprocessors]
  [T_ctrl]
    type = RealComponentParameterValuePostprocessor
    component = inlet
    parameter = T0
  []
[]
[Preconditioning]
  [SMP_PJFNK]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  start_time = 0
  dt = 1e-5
  num_steps = 1
  abort_on_solve_fail = true
  solve_type = 'PJFNK'
  line_search = 'basic'
  nl_rel_tol = 1e-6
  nl_abs_tol = 1e-6
  nl_max_its = 20
  l_tol = 1e-3
  l_max_its = 5
[]
[Outputs]
  csv = true
[]
(modules/thermal_hydraulics/test/tests/components/inlet_stagnation_p_t_1phase/phy.stagnation_p_T_transient_3eqn.i)
[GlobalParams]
  gravity_vector = '0 0 0'
  initial_p = 101325
  initial_T = 300
  initial_vel = 0
  scaling_factor_1phase = '1 1 1e-4'
  closures = simple_closures
[]
[FluidProperties]
  [eos]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    cv = 1816.0
    q = -1.167e6
    p_inf = 1.0e9
    q_prime = 0
    k = 0.5
    mu = 281.8e-6
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe]
    type = FlowChannel1Phase
    fp = eos
    # geometry
    position = '0 0 0'
    orientation = '1 0 0'
    A = 1.
    f = 0.0
    length = 1
    n_elems = 10
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe:in'
    p0 = 102041.128
    T0 = 300.615
    reversible = false
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe:out'
    p = 101325
  []
[]
[Preconditioning]
  [SMP_PJFNK]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  start_time = 0
  dt = 1e-4
  num_steps = 10
  abort_on_solve_fail = true
  solve_type = 'NEWTON'
  nl_rel_tol = 1e-8
  nl_abs_tol = 1e-7
  nl_max_its = 30
  l_tol = 1e-3
  l_max_its = 100
[]
[Outputs]
  [out]
    type = Exodus
  []
  velocity_as_vector = false
[]
(modules/thermal_hydraulics/test/tests/controls/pid_control/test.i)
# This test "measures" the liquid temperature at location (10, 0, 0) on a 15 meters
# long pipe and adjusts the inlet stagnation temperature using a PID controller with
# set point at 340 K.  The pipe is filled with water at T = 350 K. The purpose is to
# make sure that the channel fills with colder liquid and levels at the set point
# value. In steady state there should be a flat temperature profile at ~340 K.
[GlobalParams]
  initial_p = 100.e3
  initial_vel = 1.0
  initial_T = 350.
  scaling_factor_1phase = '1 1e-2 1e-4'
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    q = -1167e3
    q_prime = 0
    p_inf = 1.e9
    cv = 1816
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe1]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 0'
    orientation = '1 0 0'
    length = 15.0
    n_elems = 10
    A   = 0.01
    D_h = 0.1
    f = 0.01
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe1:in'
    p0 = 105.e3
    T0 = 300.
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe1:out'
    p = 100.0e3
  []
[]
[ControlLogic]
  [T_set_point]
    type = GetFunctionValueControl
    function = 340
  []
  [pid_ctrl]
    type = PIDControl
    input = T_reading
    set_point = T_set_point:value
    K_i = 0.05
    K_p = 0.2
    K_d = 0.1
    initial_value = 340
  []
  [set_inlet_value]
    type = SetComponentRealValueControl
    component = inlet
    parameter = T0
    value = pid_ctrl:output
  []
[]
[Postprocessors]
  [T_reading]
    type = PointValue
    point = '10 0 0'
    variable = T
    execute_on = timestep_begin
  []
  [T_inlet]
    type = PointValue
    point = '0 0 0'
    variable = T
    execute_on = timestep_begin
  []
[]
[Preconditioning]
  [SMP_PJFNK]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  dt = 5
  abort_on_solve_fail = true
  solve_type = 'NEWTON'
  line_search = 'basic'
  nl_rel_tol = 1e-6
  nl_abs_tol = 1e-6
  nl_max_its = 20
  l_tol = 1e-3
  l_max_its = 5
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  start_time = 0.0
  end_time = 300.0
[]
[Outputs]
  [out]
    type = CSV
    execute_on = 'final'
  []
  [console]
    type = Console
    max_rows = 1
  []
[]
(modules/thermal_hydraulics/test/tests/controls/delay_control/test.i)
[GlobalParams]
  initial_p = 100.e3
  initial_vel = 0
  initial_T = 300.
  closures = simple_closures
[]
[Functions]
  [p0_fn]
    type = PiecewiseLinear
    x = '0   0.2     0.4     0.6     0.8'
    y = '1e5 1.002e5 1.002e5 1.001e5 1.001e5'
  []
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    q = -1167e3
    q_prime = 0
    p_inf = 1.e9
    cv = 1816
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe1]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 0'
    orientation = '1 0 0'
    length = 1.0
    n_elems = 5
    A   = 0.01
    D_h = 0.1
    f = 0
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe1:in'
    p0 = 100.e3
    T0 = 300.
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe1:out'
    p = 100.0e3
  []
[]
[ControlLogic]
  [p0_fn_ctrl]
    type = TimeFunctionComponentControl
    component = inlet
    parameter = p0
    function = p0_fn
  []
  [delay_ctrl]
    type = DelayControl
    input = p0_inlet
    tau = 0.3
    initial_value = 1e5
  []
[]
[Postprocessors]
  [p0_inlet_delayed]
    type = RealControlDataValuePostprocessor
    control_data_name = delay_ctrl:value
    execute_on = 'initial timestep_end'
  []
  [p0_inlet]
    type = FunctionValuePostprocessor
    function = p0_fn
    execute_on = 'initial timestep_begin'
  []
[]
[Preconditioning]
  [SMP_PJFNK]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  dt = 0.1
  start_time = 0.0
  end_time = 1.0
  abort_on_solve_fail = true
  solve_type = 'PJFNK'
  line_search = 'basic'
  nl_rel_tol = 1e-6
  nl_abs_tol = 1e-6
  nl_max_its = 20
  l_tol = 1e-3
  l_max_its = 5
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  automatic_scaling = true
[]
[Outputs]
  csv = true
[]
(modules/thermal_hydraulics/test/tests/components/flow_channel_1phase/err.wrong_end.i)
[GlobalParams]
  gravity_vector = '0 0 0'
  scaling_factor_1phase = '1. 1e-4'
  closures = simple_closures
[]
[FluidProperties]
  [barotropic]
    type = LinearFluidProperties
    p_0 = 1.e5     # Pa
    rho_0 = 1.e3   # kg/m^3
    a2 = 1.e7      # m^2/s^2
    beta = .46e-3 # K^{-1}
    cv = 4.18e3    # J/kg-K, could be a global parameter?
    e_0 = 1.254e6  # J/kg
    T_0 = 300      # K
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe]
    type = FlowChannel1Phase
    fp = barotropic
    # geometry
    position = '0 0 0'
    orientation = '1 0 0'
    A = 1.
    D_h = 1.12837916709551
    f = 0.01
    length = 1
    n_elems = 100
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe:asdf'      # this is an error we are checking for
    p0 = 1e5
    T0 = 300
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe:out'
    p = 9.5e4
  []
[]
[Preconditioning]
  [FDP_PJFNK]
    type = FDP
    full = true
    petsc_options_iname = '-mat_fd_coloring_err'
    petsc_options_value = '1.e-10'
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  dt = 1e-4
  dtmin = 1.e-7
  solve_type = 'PJFNK'
  nl_rel_tol = 1e-9
  nl_abs_tol = 1e-8
  nl_max_its = 10
  l_tol = 1e-8
  l_max_its = 100
  start_time = 0.0
  num_steps = 10
[]
[Outputs]
  [out]
    type = Exodus
  []
[]
(modules/thermal_hydraulics/test/tests/controls/set_real_value_control/test.i)
# This is testing that the values set by SetRealValueControl are used.
# The values of function T0_fn are set into an aux-field `aux`. Then,
# we compute the average value of this field in a postprocessor. It
# should be equal to the value of T0_fn.
[GlobalParams]
  initial_p = 100.e3
  initial_vel = 1.0
  initial_T = 350.
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    q = -1167e3
    q_prime = 0
    p_inf = 1.e9
    cv = 1816
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe1]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 0'
    orientation = '1 0 0'
    length = 15.0
    n_elems = 10
    A    = 0.01
    D_h  = 0.1
    f = 0.01
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe1:in'
    p0 = 100.e3
    T0 = 350.
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe1:out'
    p = 100.0e3
  []
[]
[AuxVariables]
  [aux]
  []
[]
[AuxKernels]
  [aux_kernel]
    type = ConstantAux
    variable = aux
    value = 350
    execute_on = 'INITIAL TIMESTEP_END'
  []
[]
[Functions]
  [T0_fn]
    type = PiecewiseLinear
    x = '0 1'
    y = '350 345'
  []
[]
[ControlLogic]
  [T_inlet_fn]
    type = GetFunctionValueControl
    function = T0_fn
  []
  [set_inlet_value]
    type = SetRealValueControl
    parameter = AuxKernels/aux_kernel/value
    value = T_inlet_fn:value
  []
[]
[Postprocessors]
  [aux]
    type = ElementAverageValue
    variable = aux
    execute_on = 'INITIAL TIMESTEP_END'
  []
[]
[Preconditioning]
  [SMP_PJFNK]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  dt = 0.1
  abort_on_solve_fail = true
  solve_type = 'PJFNK'
  line_search = 'basic'
  nl_rel_tol = 1e-6
  nl_abs_tol = 1e-6
  nl_max_its = 20
  l_tol = 1e-3
  l_max_its = 5
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  start_time = 0.0
  end_time = 1
  automatic_scaling = true
[]
[Outputs]
  csv = true
[]
(modules/thermal_hydraulics/test/tests/components/inlet_stagnation_p_t_1phase/phy.stagnation_p_T_steady_3eqn.i)
[GlobalParams]
  gravity_vector = '0 0 0'
  initial_p = 101325
  initial_T = 300
  initial_vel = 34.84507
  scaling_factor_1phase = '1 1 1e-4'
  closures = simple_closures
[]
[FluidProperties]
  [eos]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    cv = 1816.0
    q = -1.167e6
    p_inf = 1.0e9
    q_prime = 0
    k = 0.5
    mu = 281.8e-6
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe]
    type = FlowChannel1Phase
    fp = eos
    # geometry
    position = '0 0 0'
    orientation = '1 0 0'
    A = 1.
    f = 0.0
    length = 1
    n_elems = 10
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe:in'
    p0 = 102041.128
    T0 = 300.615
    reversible = false
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe:out'
    p = 101325
  []
[]
[Preconditioning]
  [SMP_PJFNK]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  start_time = 0
  dt = 1e-4
  num_steps = 10
  abort_on_solve_fail = true
  solve_type = 'NEWTON'
  nl_rel_tol = 1e-9
  nl_abs_tol = 1e-8
  nl_max_its = 30
  l_tol = 1e-3
  l_max_its = 100
[]
[Outputs]
  [out]
    type = Exodus
  []
  velocity_as_vector = false
[]
(modules/thermal_hydraulics/test/tests/components/flow_channel_1phase/err.overspecified.i)
[GlobalParams]
  gravity_vector = '0 0 0'
  initial_vel = 0
  initial_p = 1e5
  initial_T = 300
  closures = simple_closures
[]
[FluidProperties]
  [water]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    cv = 1816.0
    q = -1.167e6
    p_inf = 1.0e9
    q_prime = 0
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe]
    type = FlowChannel1Phase
    fp = water
    # geometry
    position = '0 0 0'
    orientation = '1 0 0'
    A = 1.
    D_h = 1.12837916709551
    f = 0.01
    length = 1
    n_elems = 100
  []
  [inlet1]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe:in'
    p0 = 10
    T0 = 10
  []
  [inlet2]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe:in'
    p0 = 11
    T0 = 10
  []
  [outlet1]
    type = Outlet1Phase
    input = 'pipe:out'
    p = 10
  []
  [outlet2]
    type = Outlet1Phase
    input = 'pipe:out'
    p = 11
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  dt = 1e-4
  dtmin = 1.e-7
  solve_type = 'PJFNK'
  nl_rel_tol = 1e-9
  nl_abs_tol = 1e-8
  nl_max_its = 10
  l_tol = 1e-8
  l_max_its = 100
  start_time = 0.0
  num_steps = 10
[]
[Outputs]
  [out]
    type = Exodus
  []
[]
(modules/thermal_hydraulics/test/tests/controls/set_component_bool_value_control/test.i)
# This is testing that the values set by SetComponentBoolValueControl are used.
# The `trip_ctrl` component produces a boolean value that is set in the
# `turbine` component to switch it on/off.
[GlobalParams]
  initial_p = 100.e3
  initial_vel = 1.0
  initial_T = 350.
  initial_vel_x = 0
  initial_vel_y = 0
  initial_vel_z = 0
  scaling_factor_1phase = '1 1e-2 1e-4'
  closures = simple_closures
[]
[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 = InletStagnationPressureTemperature1Phase
    input = 'fch1:in'
    p0 = 100.e3
    T0 = 350.
  []
  [fch1]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 0'
    orientation = '1 0 0'
    length = 1.0
    n_elems = 10
    A    = 0.01
    D_h  = 0.1
    f = 0.01
  []
  [turbine]
    type = SimpleTurbine1Phase
    position = '1 0 0'
    connections = 'fch1:out fch2:in'
    volume = 1
    on = false
    power = 1
  []
  [fch2]
    type = FlowChannel1Phase
    fp = fp
    position = '1 0 0'
    orientation = '1 0 0'
    length = 1.0
    n_elems = 10
    A    = 0.01
    D_h  = 0.1
    f = 0.01
  []
  [outlet]
    type = Outlet1Phase
    input = 'fch2:out'
    p = 100.0e3
  []
[]
[Functions]
  [trip_fn]
    type = PiecewiseLinear
    xy_data = '
      0 1
      1 2'
  []
[]
[ControlLogic]
  [trip_ctrl]
    type = UnitTripControl
    condition = 'val > 1.5'
    symbol_names = 'val'
    symbol_values = 'trip_fn'
  []
  [set_comp_value]
    type = SetComponentBoolValueControl
    component = turbine
    parameter = on
    value = trip_ctrl:state
  []
[]
[Postprocessors]
  [on_ctrl]
    type = BoolComponentParameterValuePostprocessor
    component = turbine
    parameter = on
  []
[]
[Preconditioning]
  [SMP_PJFNK]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  dt = 0.1
  abort_on_solve_fail = true
  solve_type = NEWTON
  line_search = 'basic'
  nl_rel_tol = 1e-6
  nl_abs_tol = 1e-5
  nl_max_its = 20
  l_tol = 1e-3
  l_max_its = 5
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  start_time = 0.0
  end_time = 1
[]
[Outputs]
  [out]
    type = CSV
    show = 'on_ctrl'
  []
[]
(modules/thermal_hydraulics/test/tests/components/inlet_stagnation_p_t_1phase/phy.p0T0_3eqn.i)
[GlobalParams]
  gravity_vector = '0 0 0'
  initial_p = 1e6
  initial_T = 453.1
  initial_vel = 0.0
  scaling_factor_1phase = '1 1 1e-5'
  closures = simple_closures
[]
[FluidProperties]
  [eos]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    cv = 1816.0
    q = -1.167e6
    p_inf = 1.0e9
    q_prime = 0
    k = 0.5
    mu = 281.8e-6
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '1 0 0'
    length = 1
    n_elems = 50
    A   = 1.0000000000e-04
    D_h  = 1.1283791671e-02
    f = 0.0
    fp = eos
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe:in'
    p0 = 1e6
    T0 = 453.1
    reversible = false
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe:out'
    p = 0.5e6
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  dt = 1.e-2
  abort_on_solve_fail = true
  solve_type = 'PJFNK'
  line_search = 'basic'
  nl_rel_tol = 1e-5
  nl_abs_tol = 1e-6
  nl_max_its = 30
  l_tol = 1e-3
  l_max_its = 100
  start_time = 0.0
  end_time = 0.6
[]
[Outputs]
  file_base = 'phy.p0T0_3eqn'
  [out]
    type = Exodus
  []
  velocity_as_vector = false
[]
(modules/thermal_hydraulics/test/tests/components/volume_junction_1phase/equal_area_with_junction.i)
# Tests a junction between 2 flow channels of equal area and orientation. A
# sinusoidal density shape is advected to the right and should not be affected
# by the junction; the solution should be identical to the equivalent
# no-junction solution.
[GlobalParams]
  gravity_vector = '0 0 0'
  initial_p = 1e5
  initial_vel = 1
  A = 25
  f = 0
  fp = fp
  scaling_factor_1phase = '0.04 0.04 0.04e-5'
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 1.4
    cv = 725
    p_inf = 0
    q = 0
    q_prime = 0
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Functions]
  [T0]
    type = CosineHumpFunction
    axis = x
    hump_center_position = 1
    hump_width = 0.5
    hump_begin_value = 250
    hump_center_value = 300
  []
[]
[Components]
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe1:in'
    # Stagnation property with p = 1e5 Pa, T = 250 K, vel = 1 m/s
    p0 = 100000.68965687
    T0 = 250.00049261084
  []
  [pipe1]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '1 0 0'
    length = 1
    initial_T = T0
    n_elems = 25
  []
  [junction]
    type = VolumeJunction1Phase
    connections = 'pipe1:out pipe2:in'
    # NOTE: volume parameters are added via command-line arguments by tests file.
    position = '1.02 0 0'
    initial_T = T0
    initial_vel_x = 1
    initial_vel_y = 0
    initial_vel_z = 0
    scaling_factor_rhoV  = 1
    scaling_factor_rhouV = 1
    scaling_factor_rhovV = 1
    scaling_factor_rhowV = 1
    scaling_factor_rhoEV = 1e-5
  []
  [pipe2]
    type = FlowChannel1Phase
    position = '1.04 0 0'
    orientation = '1 0 0'
    length = 0.96
    initial_T = T0
    n_elems = 24
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe2:out'
    p = 1e5
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  start_time = 0
  dt = 0.01
  num_steps = 5
  abort_on_solve_fail = true
  solve_type = 'PJFNK'
  line_search = 'basic'
  nl_rel_tol = 0
  nl_abs_tol = 1e-6
  nl_max_its = 10
  l_tol = 1e-3
  l_max_its = 10
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  [Quadrature]
    type = GAUSS
    order = SECOND
  []
[]
[Postprocessors]
  [junction_rho]
    type = ElementAverageValue
    variable = rhoV
    block = 'junction'
    execute_on = 'initial timestep_end'
  []
  [junction_rhou]
    type = ElementAverageValue
    variable = rhouV
    block = 'junction'
    execute_on = 'initial timestep_end'
  []
  [junction_rhoE]
    type = ElementAverageValue
    variable = rhoEV
    block = 'junction'
    execute_on = 'initial timestep_end'
  []
[]
[Outputs]
  [out]
    type = CSV
    execute_scalars_on = 'none'
    execute_on = 'initial timestep_end'
  []
[]
(modules/thermal_hydraulics/test/tests/components/inlet_velocity_t_1phase/phy.reversed_flow.i)
[GlobalParams]
  gravity_vector = '0 0 0'
  initial_T = 444.447
  initial_p = 7e6
  initial_vel = 0
  scaling_factor_1phase = '1 1 1e-5'
  closures = simple_closures
[]
[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]
  [pipe]
    type = FlowChannel1Phase
    fp = fp
    # geometry
    position = '0 0 0'
    orientation = '1 0 0'
    A   = 1.0000000000e-04
    f = 0.0
    length = 1
    n_elems = 100
  []
  [in]
    type = InletVelocityTemperature1Phase
    input = 'pipe:in'
    vel = -1.0
    T     = 444.447
  []
  [out]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe:out'
    p0 = 7e6
    T0 = 444.447
  []
[]
[Preconditioning]
  [SMP_PJFNK]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  dt = 0.1
  start_time = 0.0
  end_time = 5
  solve_type = 'PJFNK'
  line_search = 'basic'
  nl_rel_tol = 0
  nl_abs_tol = 1e-6
  nl_max_its = 10
  l_tol = 1e-3
  l_max_its = 100
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  abort_on_solve_fail = true
[]
[Outputs]
  [exodus]
    type = Exodus
    file_base = phy.reversed_flow
    show = 'vel T p'
  []
  velocity_as_vector = false
[]
(modules/thermal_hydraulics/test/tests/controls/get_function_value_control/test.i)
# This is testing that the values obtained by GetFunctionValueControl are used.
# Function T0_fn prescribes values for T_inlet_fn control. We output the function
# values via a postprocessor `T_fn` and the control data values via another
# postprocessor `T_ctrl`. Those two values have to be equal.
[GlobalParams]
  initial_p = 100.e3
  initial_vel = 1.0
  initial_T = 350.
  scaling_factor_1phase = '1 1e-2 1e-4'
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    q = -1167e3
    q_prime = 0
    p_inf = 1.e9
    cv = 1816
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe1]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 0'
    orientation = '1 0 0'
    length = 15.0
    n_elems = 10
    A    = 0.01
    D_h  = 0.1
    f = 0.01
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe1:in'
    p0 = 100.e3
    T0 = 350.
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe1:out'
    p = 100.0e3
  []
[]
[Functions]
  [T0_fn]
    type = PiecewiseLinear
    x = '0 1'
    y = '350 345'
  []
[]
[ControlLogic]
  [T_inlet_fn]
    type = GetFunctionValueControl
    function = T0_fn
  []
[]
[Postprocessors]
  [T_fn]
    type = FunctionValuePostprocessor
    function = T0_fn
  []
  [T_ctrl]
    type = RealControlDataValuePostprocessor
    control_data_name = T_inlet_fn:value
  []
[]
[Preconditioning]
  [SMP_PJFNK]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  dt = 0.1
  abort_on_solve_fail = true
  solve_type = 'PJFNK'
  line_search = 'basic'
  nl_rel_tol = 1e-6
  nl_abs_tol = 1e-6
  nl_max_its = 20
  l_tol = 1e-3
  l_max_its = 5
  petsc_options_iname = '-pc_type'
  petsc_options_value = 'lu'
  start_time = 0.0
  end_time = 1
[]
[Outputs]
  csv = true
[]
(modules/thermal_hydraulics/test/tests/closures/simple_1phase/err.missing_f_1phase.i)
[GlobalParams]
  gravity_vector = '0 0 0'
  initial_vel = 0
  initial_p = 1e5
  initial_T = 300
  closures = simple_closures
[]
[FluidProperties]
  [water]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    cv = 1816.0
    q = -1.167e6
    p_inf = 1.0e9
    q_prime = 0
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe]
    type = FlowChannel1Phase
    fp = water
    position = '0 0 0'
    orientation = '1 0 0'
    A = 1.
    length = 1
    n_elems = 10
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe:in'
    p0 = 10
    T0 = 10
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe:out'
    p = 10
  []
[]
[Preconditioning]
  [pc]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  scheme = 'bdf2'
  dt = 1e-4
  dtmin = 1.e-7
  solve_type = 'PJFNK'
  nl_rel_tol = 1e-9
  nl_abs_tol = 1e-8
  nl_max_its = 10
  l_tol = 1e-8
  l_max_its = 100
  start_time = 0.0
  num_steps = 10
  [Quadrature]
    type = GAUSS
    order = SECOND
  []
[]
(modules/thermal_hydraulics/test/tests/components/junction_parallel_channels_1phase/err.missing_ics.i)
[GlobalParams]
  gravity_vector = '0 0 0'
  A = 1e-4
  f = 0
  fp = fp
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 1.4
    cv = 725
    p_inf = 0
    q = 0
    q_prime = 0
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe1:in'
    # Stagnation property with p = 1e5 Pa, T = 250 K, vel = 1 m/s
    p0 = 100000.68965687
    T0 = 250.00049261084
  []
  [pipe1]
    type = FlowChannel1Phase
    position = '0 0 0'
    orientation = '1 0 0'
    length = 1
    n_elems = 2
    initial_p = 1e5
    initial_T = 250
    initial_vel = 0
  []
  [junction]
    type = JunctionParallelChannels1Phase
    connections = 'pipe1:out pipe2:in'
    position = '1.02 0 0'
    volume = 0.1
  []
  [pipe2]
    type = FlowChannel1Phase
    position = '1.04 0 0'
    orientation = '1 0 0'
    length = 0.96
    n_elems = 2
    initial_p = 1e5
    initial_T = 250
    initial_vel = 0
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe2:out'
    p = 1e5
  []
[]
[Executioner]
  type = Transient
  abort_on_solve_fail = true
[]
(modules/thermal_hydraulics/test/tests/misc/adapt/multiple_blocks.i)
[GlobalParams]
  gravity_vector = '0 0 0'
  initial_p = 1e5
  initial_T = 300
  initial_vel = 0
  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
  []
[]
[Components]
  [pipe1]
    type = FlowChannel1Phase
    fp = eos
    position = '0 0 0'
    orientation = '1 0 0'
    length = 1
    n_elems = 10
    A = 1
    f = 0
  []
  [pipe2]
    type = FlowChannel1Phase
    fp = eos
    position = '1 0 0'
    orientation = '1 0 0'
    length = 1
    n_elems = 10
    A = 1
    f = 0
  []
  [junction]
    type = VolumeJunction1Phase
    connections = 'pipe1:out pipe2:in'
    volume = 1e-5
    position = '1 0 0'
    initial_vel_x = 0
    initial_vel_y = 0
    initial_vel_z = 0
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe1:in'
    # (p0, T0) for p = 1e5, T = 300, vel = 1
    p0 = 1.0049827846e+05
    T0 = 300.0000099
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe2:out'
    p = 1e5
  []
[]
[Preconditioning]
  [prec]
    type = SMP
    full = true
    petsc_options = '-pc_factor_shift_nonzero'
    petsc_options_iname = '-mat_fd_coloring_err'
    petsc_options_value = '1.e-10'
  []
[]
[Executioner]
  type = Transient
  start_time = 0
  dt = 1e-4
  num_steps = 5
  abort_on_solve_fail = true
  solve_type = 'PJFNK'
  nl_rel_tol = 0
  nl_abs_tol = 1e-5
  nl_max_its = 10
  l_tol = 1e-3
  l_max_its = 10
  [Adaptivity]
    initial_adaptivity = 0
    refine_fraction = 0.60
    coarsen_fraction = 0.10
    max_h_level = 3
  []
  automatic_scaling = true
[]
[Outputs]
  exodus = true
[]
(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/controls/error_checking/non_existent_control_data.i)
# This test makes sure that we error out when a control object requests a data
# that were not declared
[GlobalParams]
  initial_p = 100.e3
  initial_vel = 1.0
  initial_T = 350.
  scaling_factor_1phase = '1 1e-2 1e-4'
  closures = simple_closures
[]
[FluidProperties]
  [fp]
    type = StiffenedGasFluidProperties
    gamma = 2.35
    q = -1167e3
    q_prime = 0
    p_inf = 1.e9
    cv = 1816
  []
[]
[Closures]
  [simple_closures]
    type = Closures1PhaseSimple
  []
[]
[Components]
  [pipe1]
    type = FlowChannel1Phase
    fp = fp
    position = '0 0 0'
    orientation = '1 0 0'
    length = 15.0
    n_elems = 10
    A    = 0.01
    D_h  = 0.1
    f = 0.01
  []
  [inlet]
    type = InletStagnationPressureTemperature1Phase
    input = 'pipe1:in'
    p0 = 105.e3
    T0 = 300.
  []
  [outlet]
    type = Outlet1Phase
    input = 'pipe1:out'
    p = 100.0e3
  []
[]
[ControlLogic]
  [set_inlet_value]
    type = SetComponentRealValueControl
    component = inlet
    parameter = T0
    value = wrong         # this does not exist
  []
[]
[Preconditioning]
  [SMP_PJFNK]
    type = SMP
    full = true
  []
[]
[Executioner]
  type = Transient
  start_time = 0
  dt = 0.5
  num_steps = 1
  abort_on_solve_fail = true
  solve_type = 'PJFNK'
  line_search = 'basic'
  nl_rel_tol = 1e-6
  nl_abs_tol = 1e-6
  nl_max_its = 20
  l_tol = 1e-3
  l_max_its = 5
[]
reversible
Default:True
C++ Type:bool
Controllable:No
Description:True for reversible, false for pure inlet