function Design_HX
import SI = Modelica.SIunits;
import CN = Modelica.Constants;
import MA = Modelica.Math;
import SolarTherm.{Models,Media};
import Modelica.Math.Vectors;
import FI = SolarTherm.Models.Analysis.Finances;
import SolarTherm.Types.Currency;
replaceable package Medium1 = Media.Sodium.Sodium_pT "Medium props for Sodium";
replaceable package Medium2 = Media.ChlorideSalt.ChlorideSalt_pT "Medium props for Molten Salt";
input SI.HeatFlowRate Q_d "Design Heat Flow Rate";
input SI.Temperature T_Na1 "Desing Sodium Hot Fluid Temperature";
input SI.Temperature T_MS1 "Desing Molten Salt Cold Fluid Temperature";
input SI.Temperature T_MS2 "Desing Molten Salt Hot Fluid Temperature";
input SI.Length d_o "Outer Tube diameter";
input Integer N_p "Number of passes";
input Integer N_sp "Number of passes";
input Integer layout "Tube layout";
input SI.Temperature T_Na2 "Sodium Cold Fluid Temperature";
input SI.Pressure p_Na1 "Sodium Inlet Pressure";
input SI.Pressure p_MS1 "Molten Salt Inlet Pressure";
input FI.EnergyPrice_kWh c_e "Power cost";
input Real r "Real interest rate";
input Real H_y(unit = "h") "Operating hours";
input Integer n(unit = "h") "Operating years";
input Real ratio_max "Maximum L/D_s ratio";
input Boolean ratio_cond "Activate ratio constraint";
input Boolean L_max_cond "Activate maximum HX length constraint";
input SI.Length L_max_input "Maximum HX length";
output SI.MassFlowRate m_flow_Na "Sodium mass flow rate";
output SI.MassFlowRate m_flow_MS "Molten-Salt mass flow rate";
output Real F(unit = "") "Temperature correction factor";
output SI.ThermalConductance UA "UA";
output SI.Area A_tot "Exchange Area";
output SI.CoefficientOfHeatTransfer U "Heat tranfer coefficient";
output Integer N_t "Number of tubes";
output SI.Pressure Dp_tube "Tube-side pressure drop";
output SI.Pressure Dp_shell "Shell-side pressure drop";
output SI.CoefficientOfHeatTransfer h_s "Shell-side Heat tranfer coefficient";
output SI.CoefficientOfHeatTransfer h_t "Tube-side Heat tranfer coefficient";
output SI.Length D_s "Shell Diameter";
output SI.Length D_s_out "Outer Shell Diameter";
output Integer N_baffles "Number of baffles";
output SI.Length l_b "Baffle spacing";
output SI.Velocity v_Na "Sodium velocity in tubes";
output SI.Velocity v_max_MS "Molten Salt velocity in shell";
output SI.Volume V_HX "Heat-Exchanger Total Volume";
output SI.Mass m_HX "Heat-Exchanger Total Mass";
output SI.Mass m_material_HX "Heat-Exchanger Material Mass";
output FI.Money_USD C_BEC "Bare cost @2018";
output FI.MoneyPerYear C_pump "Annual pumping cost";
output FI.MoneyPerYear TAC "Total Annualized Cost";
output Real ex_eff(unit = "") "HX Exergetic Efficiency";
output Real en_eff(unit = "") "HX Energetic Efficiency";
output SI.Length L "Tube length";
output Real ratio;
output Real penalty;
end Design_HX;