Skip to content

Failed

tests / 04 testsuite-clang 1/3 / openmodelica_interactive-API.Bug2871.mos (from (result.xml))

Failing for the past 1 build (Since #2 )
Took 3 sec.

Stacktrace

Output mismatch (see stdout for details)

Standard Output

 + Bug2871.mos [BUG #2871]                                                           ... equation mismatch [time: 3]

==== Log /tmp/omc-rtest-omtmpuser/openmodelica/interactive-API/Bug2871.mos_temp1703/log-Bug2871.mos
true
""
true
"model"
{}
1
Modelica.Fluid.Pipes.BaseClasses.PartialStraightPipe
"model"
{-100.0,-100.0,100.0,100.0,false,-,-,,{Rectangle(true, {0.0, 0.0}, 0.0, {0, 0, 0}, {95, 95, 95}, LinePattern.None, FillPattern.Solid, 0.25, BorderPattern.None, {{-100.0, 40.0}, {100.0, -40.0}}, 0.0), Rectangle(true, {0.0, 0.0}, 0.0, {0, 0, 0}, {0, 127, 255}, LinePattern.Solid, FillPattern.HorizontalCylinder, 0.25, BorderPattern.None, {{-100.0, 44.0}, {100.0, -44.0}}, 0.0)}}
1
Modelica.Fluid.Interfaces.PartialTwoPort
"model"
{-100.0,-100.0,100.0,100.0,true,-,-,,{Polygon(true, {0.0, 0.0}, 0.0, {0, 128, 255}, {0, 128, 255}, LinePattern.Solid, FillPattern.Solid, 0.25, {{20.0, -70.0}, {60.0, -85.0}, {20.0, -100.0}, {20.0, -70.0}}, Smooth.None), Polygon(true, {0.0, 0.0}, 0.0, {255, 255, 255}, {255, 255, 255}, LinePattern.Solid, FillPattern.Solid, 0.25, {{20.0, -75.0}, {50.0, -85.0}, {20.0, -95.0}, {20.0, -75.0}}, Smooth.None), Line(true, {0.0, 0.0}, 0.0, {{55.0, -85.0}, {-60.0, -85.0}}, {0, 128, 255}, LinePattern.Solid, 0.25, {Arrow.None, Arrow.None}, 3.0, Smooth.None), Text(true, {0.0, 0.0}, 0.0, {0, 0, 255}, {0, 0, 0}, LinePattern.Solid, FillPattern.None, 0.25, {{-149.0, -114.0}, {151.0, -154.0}}, "%name", 0.0, {-1, -1, -1}, "", {}, TextAlignment.Center), Ellipse(false, {0.0, 0.0}, 0.0, {0, 0, 0}, {0, 0, 0}, LinePattern.Solid, FillPattern.Solid, 0.25, {{-110.0, 26.0}, {-90.0, -24.0}}, 0.0, 360.0, EllipseClosure.Chord), Ellipse(false, {0.0, 0.0}, 0.0, {0, 0, 0}, {0, 0, 0}, LinePattern.Solid, FillPattern.Solid, 0.25, {{90.0, 25.0}, {110.0, -25.0}}, 0.0, 360.0, EllipseClosure.Chord)}}
0
true
{{"Modelica.Fluid.System", "system", "System wide properties", "public", "false", "false", "false", "false", "unspecified", "outer", "unspecified", "{}"},{"Boolean", "allowFlowReversal", "= true to allow flow reversal, false restricts to design direction (port_a -> port_b)", "public", "false", "false", "false", "false", "parameter", "none", "unspecified", "{}"},{"Modelica.Fluid.Interfaces.FluidPort_a", "port_a", "Fluid connector a (positive design flow direction is from port_a to port_b)", "public", "false", "false", "false", "false", "unspecified", "none", "unspecified", "{}"},{"Modelica.Fluid.Interfaces.FluidPort_b", "port_b", "Fluid connector b (positive design flow direction is from port_a to port_b)", "public", "false", "false", "false", "false", "unspecified", "none", "unspecified", "{}"},{"Boolean", "port_a_exposesState", "= true if port_a exposes the state of a fluid volume", "protected", "false", "false", "false", "false", "parameter", "none", "unspecified", "{}"},{"Boolean", "port_b_exposesState", "= true if port_b.p exposes the state of a fluid volume", "protected", "false", "false", "false", "false", "parameter", "none", "unspecified", "{}"},{"Boolean", "showDesignFlowDirection", "= false to hide the arrow in the model icon", "protected", "false", "false", "false", "false", "parameter", "none", "unspecified", "{}"}}
{{},{Dialog("Assumptions","Parameters",true,false,false,-,-,-,-,"",false), Evaluate=true},{Placement(true,-,-,-110.0,-10.0,-90.0,10.0,-,-,-,-,-,-,-,)},{Placement(true,-,-,110.0,-10.0,90.0,10.0,-,-,-,110.0,-10.0,90.0,10.0,)},{},{},{}}
true
{-100.0,-100.0,100.0,100.0,false,-,-,,{Ellipse(true, {0.0, 0.0}, 0.0, {0, 127, 255}, {0, 127, 255}, LinePattern.Solid, FillPattern.Solid, 0.25, {{-100.0, 100.0}, {100.0, -100.0}}, 0.0, 360.0, EllipseClosure.Chord), Ellipse(true, {0.0, 0.0}, 0.0, {0, 0, 0}, {0, 127, 255}, LinePattern.Solid, FillPattern.Solid, 0.25, {{-100.0, 100.0}, {100.0, -100.0}}, 0.0, 360.0, EllipseClosure.Chord)}}
1
Modelica.Fluid.Interfaces.FluidPort
true
{-100.0,-100.0,100.0,100.0,false,-,-,,{Ellipse(true, {0.0, 0.0}, 0.0, {0, 127, 255}, {0, 127, 255}, LinePattern.Solid, FillPattern.Solid, 0.25, {{-100.0, 100.0}, {100.0, -100.0}}, 0.0, 360.0, EllipseClosure.Chord), Ellipse(true, {0.0, 0.0}, 0.0, {0, 0, 0}, {0, 127, 255}, LinePattern.Solid, FillPattern.Solid, 0.25, {{-100.0, 100.0}, {100.0, -100.0}}, 0.0, 360.0, EllipseClosure.Chord), Ellipse(true, {0.0, 0.0}, 0.0, {0, 127, 255}, {255, 255, 255}, LinePattern.Solid, FillPattern.Solid, 0.25, {{-80.0, 80.0}, {80.0, -80.0}}, 0.0, 360.0, EllipseClosure.Chord)}}
1
{{"Real", "nParallel", "Number of identical parallel pipes", "public", "false", "false", "false", "false", "parameter", "none", "unspecified", "{}"},{"Modelica.SIunits.Length", "length", "Length", "public", "false", "false", "false", "false", "parameter", "none", "unspecified", "{}"},{"Boolean", "isCircular", "= true if cross sectional area is circular", "public", "false", "false", "false", "false", "parameter", "none", "unspecified", "{}"},{"Modelica.SIunits.Diameter", "diameter", "Diameter of circular pipe", "public", "false", "false", "false", "false", "parameter", "none", "unspecified", "{}"},{"Modelica.SIunits.Area", "crossArea", "Inner cross section area", "public", "false", "false", "false", "false", "parameter", "none", "unspecified", "{}"},{"Modelica.SIunits.Length", "perimeter", "Inner perimeter", "public", "false", "false", "false", "false", "parameter", "none", "unspecified", "{}"},{"Modelica.SIunits.Height", "roughness", "Average height of surface asperities (default: smooth steel pipe)", "public", "false", "false", "false", "false", "parameter", "none", "unspecified", "{}"},{"Modelica.SIunits.Volume", "V", "volume size", "public", "true", "false", "false", "false", "parameter", "none", "unspecified", "{}"},{"Modelica.SIunits.Length", "height_ab", "Height(port_b) - Height(port_a)", "public", "false", "false", "false", "false", "parameter", "none", "unspecified", "{}"}}
{{Dialog("General","Geometry",true,false,false,-,-,-,-,"",false)},{Dialog("General","Geometry",true,false,false,-,-,-,-,"",false)},{Evaluate("error evaluating: annotation(Evaluate)"), Dialog("General","Geometry",true,false,false,-,-,-,-,"",false)},{Dialog("General","Geometry",isCircular,false,false,-,-,-,-,"",false)},{Dialog("General","Geometry",not isCircular,false,false,-,-,-,-,"",false)},{Dialog("General","Geometry",not isCircular,false,false,-,-,-,-,"",false)},{Dialog("General","Geometry",true,false,false,-,-,-,-,"",false)},{},{Dialog("General","Static head",true,false,false,-,-,-,-,"",false)}}
{{"Medium.AbsolutePressure", "p_a_start", "Start value of pressure at port a", "public", "false", "false", "false", "false", "parameter", "none", "unspecified", "{}"},{"Medium.AbsolutePressure", "p_b_start", "Start value of pressure at port b", "public", "false", "false", "false", "false", "parameter", "none", "unspecified", "{}"},{"Medium.MassFlowRate", "m_flow_start", "Start value for mass flow rate", "public", "false", "false", "false", "false", "parameter", "none", "unspecified", "{}"},{"FlowModel", "flowModel", "Flow model", "public", "false", "false", "false", "false", "unspecified", "none", "unspecified", "{}"}}
{{Dialog("Initialization","Parameters",true,false,false,-,-,-,-,"",false)},{Dialog("Initialization","Parameters",true,false,false,-,-,-,-,"",false)},{Evaluate=true, Dialog("Initialization","Parameters",true,false,false,-,-,-,-,"",false)},{Placement(true,-,-,-38.0,-18.0,38.0,18.0,-,-,-,-,-,-,-,)}}
true
true
0
5
{"pipe1.port_a","pipe2.port_a",""}
"model"
true
"model"
true
{Line(true, {0.0, 0.0}, 0, {{-60, -20}, {-60, -40}, {0, -40}, {0, -30}, {0, -20}}, {0, 127, 255}, LinePattern.Solid, 0.25, {Arrow.None, Arrow.None}, 3, Smooth.None)}
{"pipe2.port_a","pipe3.port_a",""}
"model"
true
"model"
true
{Line(true, {0.0, 0.0}, 0, {{0, -20}, {0, -20}, {0, -40}, {60, -40}, {60, -30}}, {0, 127, 255}, LinePattern.Solid, 0.25, {Arrow.None, Arrow.None}, 3, Smooth.None)}
{"pipe3.port_b","tank3.ports[1]",""}
"model"
true
"model"
true
{Line(true, {0.0, 0.0}, 0, {{60, -10}, {60, -10}, {60, 10}}, {0, 127, 255}, LinePattern.Solid, 0.25, {Arrow.None, Arrow.None}, 3, Smooth.None)}
{"pipe1.port_b","tank1.ports[1]",""}
"model"
true
{Line(true, {0.0, 0.0}, 0, {{-60, 0}, {-60, 10}, {-60, 20}}, {0, 127, 255}, LinePattern.Solid, 0.25, {Arrow.None, Arrow.None}, 3, Smooth.None)}
{"pipe2.port_b","tank2.ports[1]",""}
"model"
true
"model"
true
{Line(true, {0.0, 0.0}, 0, {{0, 0}, {0, 20}}, {0, 127, 255}, LinePattern.Solid, 0.25, {Arrow.None, Arrow.None}, 3, Smooth.None)}
{}
true
(0.0,200.0,1e-4,500,0.4)
true
""
is no flow -1e5: false
is no flow -1e5: false
is no flow -1e5: false
is no flow -1e5: false
is no flow -1e5: false
is no flow -1e5: false
is no flow -1e60: false
is no flow -1e60: false
is no flow -1e60: false
is no flow -1e5: false
is no flow -1e5: false
is no flow -1e5: false
is no flow -1e5: false
is no flow -1e5: false
is no flow -1e5: false
is no flow -1e5: false
is no flow -1e5: false
is no flow -1e5: false
is no flow -1e5: false
is no flow -1e5: false
is no flow -1e5: false
is no flow -1e60: false
is no flow -1e60: false
is no flow -1e5: false
is no flow -1e60: false
is no flow -1e60: false
is no flow -1e5: false
is no flow -1e60: false
is no flow -1e60: false
is no flow -1e5: false
is no flow -1e60: false
is no flow -1e60: false
is no flow -1e5: false
is no flow -1e60: false
is no flow -1e60: false
is no flow -1e5: false
is no flow -1e60: false
is no flow -1e60: false
is no flow -1e5: false
"function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.Medium.ThermodynamicState \"Automatically generated record constructor for Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.Medium.ThermodynamicState\"
  input Real p;
  input Real T;
  output ThermodynamicState res;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.Medium.ThermodynamicState;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.Medium.density \"Return density\"
  input Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.Medium.ThermodynamicState state \"Thermodynamic state record\";
  output Real d(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0, max = 1e5, start = 1.0, nominal = 1.0) \"Density\";
algorithm
  d := 995.586;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.Medium.density;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.Medium.setState_phX \"Return thermodynamic state from p, h, and X or Xi\"
  input Real p(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, max = 1e8, start = 1e5, nominal = 1e5) \"Pressure\";
  input Real h(quantity = \"SpecificEnergy\", unit = \"J/kg\", min = -1e10, max = 1e10, nominal = 1e6) \"Specific enthalpy\";
  input Real[:] X(quantity = fill(\"MassFraction\", size(X, 1)), unit = fill(\"kg/kg\", size(X, 1)), min = fill(0.0, size(X, 1)), max = fill(1.0, size(X, 1)), nominal = fill(0.1, size(X, 1))) = {1.0} \"Mass fractions\";
  output Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.Medium.ThermodynamicState state \"Thermodynamic state record\";
algorithm
  state := Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.Medium.ThermodynamicState(p, 273.15 + h / 4184.0);
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.Medium.setState_phX;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.Medium.ThermodynamicState \"Automatically generated record constructor for Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.Medium.ThermodynamicState\"
  input Real p;
  input Real T;
  output ThermodynamicState res;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.Medium.ThermodynamicState;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.Medium.density \"Return density\"
  input Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.Medium.ThermodynamicState state \"Thermodynamic state record\";
  output Real d(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0, max = 1e5, start = 1.0, nominal = 1.0) \"Density\";
algorithm
  d := 995.586;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.Medium.density;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.Medium.dynamicViscosity \"Return dynamic viscosity\"
  input Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.Medium.ThermodynamicState state \"Thermodynamic state record\";
  output Real eta(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0, max = 1e8, start = 0.001, nominal = 0.001) \"Dynamic viscosity\";
algorithm
  eta := 0.001;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.Medium.dynamicViscosity;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.Medium.pressure \"Return pressure\"
  input Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.Medium.ThermodynamicState state \"Thermodynamic state record\";
  output Real p(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, max = 1e8, start = 1e5, nominal = 1e5) \"Pressure\";
algorithm
  p := state.p;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.Medium.pressure;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.WallFriction.Internal.m_flow_of_dp_fric \"Calculate mass flow rate as function of pressure drop due to friction\"
  input Real dp_fric(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\") \"Pressure loss due to friction (dp = port_a.p - port_b.p)\";
  input Real rho_a(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0) \"Density at port_a\";
  input Real rho_b(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0) \"Density at port_b\";
  input Real mu_a(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0) \"Dynamic viscosity at port_a (dummy if use_mu = false)\";
  input Real mu_b(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0) \"Dynamic viscosity at port_b (dummy if use_mu = false)\";
  input Real length(quantity = \"Length\", unit = \"m\") \"Length of pipe\";
  input Real diameter(quantity = \"Length\", unit = \"m\", min = 0.0) \"Inner (hydraulic) diameter of pipe\";
  input Real crossArea(quantity = \"Area\", unit = \"m2\") \"Inner cross section area\";
  input Real Re1(quantity = \"ReynoldsNumber\", unit = \"1\") \"Boundary between laminar regime and transition\";
  input Real Re2(quantity = \"ReynoldsNumber\", unit = \"1\") \"Boundary between transition and turbulent regime\";
  input Real Delta \"Relative roughness\";
  output Real m_flow(quantity = \"MassFlowRate\", unit = \"kg/s\") \"Mass flow rate from port_a to port_b\";
  output Real dm_flow_ddp_fric \"Derivative of mass flow rate with dp_fric\";
  protected Real mu(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0) \"Upstream viscosity\";
  protected Real rho(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0) \"Upstream density\";
  protected Real lambda2 \"Modified friction coefficient (= lambda*Re^2)\";
  protected Real Re(quantity = \"ReynoldsNumber\", unit = \"1\") \"Reynolds number\";
  protected Real dRe_ddp \"dRe/ddp\";
  protected Real aux1;
  protected Real aux2;
algorithm
  if dp_fric >= 0.0 then
    rho := rho_a;
    mu := mu_a;
  else
    rho := rho_b;
    mu := mu_b;
  end if;
  lambda2 := abs(dp_fric) * 2.0 * diameter ^ 3.0 * rho / (length * mu * mu) \"Known as lambda2=f(dp)\";
  aux1 := 2.0 * diameter ^ 3.0 * rho / (length * mu ^ 2.0);
  Re := lambda2 / 64.0 \"Hagen-Poiseuille\";
  dRe_ddp := aux1 / 64.0 \"Hagen-Poiseuille\";
  if Re > Re1 then
    Re := -2.0 * sqrt(lambda2) * log10(2.51 / sqrt(lambda2) + 0.27 * Delta) \"Colebrook-White\";
    aux2 := sqrt(aux1 * abs(dp_fric));
    dRe_ddp := 0.43429448190325176 * (5.02 / (2.0 * abs(dp_fric) * (2.51 / aux2 + 0.27 * Delta)) - 2.0 * log(2.51 / aux2 + 0.27 * Delta) * aux1 / (2.0 * aux2));
    if Re < Re2 then
      (Re, dRe_ddp) := Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.WallFriction.Internal.m_flow_of_dp_fric.interpolateInRegion2_withDerivative(lambda2, Re1, Re2, Delta, dp_fric);
    end if;
  end if;
  m_flow := crossArea / diameter * mu * (if dp_fric >= 0.0 then Re else -Re);
  dm_flow_ddp_fric := crossArea / diameter * mu * dRe_ddp;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.WallFriction.Internal.m_flow_of_dp_fric;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.WallFriction.Internal.m_flow_of_dp_fric.interpolateInRegion2_withDerivative \"Interpolation in log-log space using a cubic Hermite polynomial, where x=log10(lambda2), y=log10(Re)\"
  input Real lambda2 \"Known independent variable\";
  input Real Re1(quantity = \"ReynoldsNumber\", unit = \"1\") \"Boundary between laminar regime and transition\";
  input Real Re2(quantity = \"ReynoldsNumber\", unit = \"1\") \"Boundary between transition and turbulent regime\";
  input Real Delta \"Relative roughness\";
  input Real dp_fric(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\") \"Pressure loss due to friction (dp = port_a.p - port_b.p)\";
  output Real Re(quantity = \"ReynoldsNumber\", unit = \"1\") \"Unknown return variable\";
  output Real dRe_ddp \"Derivative of return value\";
  protected Real x1 = log10(64.0 * Re1);
  protected Real y1 = log10(Re1);
  protected Real y1d = 1.0;
  protected Real aux2 = Delta / 3.7 + 5.74 / Re2 ^ 0.9;
  protected Real x = log10(lambda2);
  protected Real y;
  protected Real dy_dx \"Derivative in transformed space\";
  protected Real aux3 = log10(aux2);
  protected Real L2 = 0.25 * (Re2 / aux3) ^ 2.0;
  protected Real aux4 = 2.51 / sqrt(L2) + 0.27 * Delta;
  protected Real x2 = log10(L2);
  protected Real aux5 = -2.0 * sqrt(L2) * log10(aux4);
  protected Real y2 = log10(aux5);
  protected Real y2d = 0.5 + 1.0900791495771618 / (aux5 * aux4);
algorithm
  (y, dy_dx) := Modelica.Fluid.Utilities.cubicHermite_withDerivative(x, x1, x2, y1, y2, y1d, y2d);
  Re := 10.0 ^ y;
  dRe_ddp := Re / abs(dp_fric) * dy_dx;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.WallFriction.Internal.m_flow_of_dp_fric.interpolateInRegion2_withDerivative;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.WallFriction.massFlowRate_dp_staticHead \"Return mass flow rate m_flow as function of pressure loss dp, i.e., m_flow = f(dp), due to wall friction and static head\"
  input Real dp(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\") \"Pressure loss (dp = port_a.p - port_b.p)\";
  input Real rho_a(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0) \"Density at port_a\";
  input Real rho_b(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0) \"Density at port_b\";
  input Real mu_a(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0) \"Dynamic viscosity at port_a (dummy if use_mu = false)\";
  input Real mu_b(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0) \"Dynamic viscosity at port_b (dummy if use_mu = false)\";
  input Real length(quantity = \"Length\", unit = \"m\") \"Length of pipe\";
  input Real diameter(quantity = \"Length\", unit = \"m\", min = 0.0) \"Inner (hydraulic) diameter of pipe\";
  input Real g_times_height_ab \"Gravity times (Height(port_b) - Height(port_a))\";
  input Real crossArea(quantity = \"Area\", unit = \"m2\") = 3.141592653589793 * diameter ^ 2.0 / 4.0 \"Inner cross section area\";
  input Real roughness(quantity = \"Length\", unit = \"m\", min = 0.0) = 2.5e-5 \"Absolute roughness of pipe, with a default for a smooth steel pipe (dummy if use_roughness = false)\";
  input Real dp_small(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, nominal = 1e5) = 1.0 \"Regularization of zero flow if |dp| < dp_small (dummy if use_dp_small = false)\";
  input Real Re_turbulent(quantity = \"ReynoldsNumber\", unit = \"1\") = 4000.0 \"Turbulent flow if Re >= Re_turbulent (dummy if use_Re_turbulent = false)\";
  output Real m_flow(quantity = \"MassFlowRate\", unit = \"kg/s\") \"Mass flow rate from port_a to port_b\";
  protected Real Delta = roughness / diameter \"Relative roughness\";
  protected Real Re(quantity = \"ReynoldsNumber\", unit = \"1\") \"Reynolds number\";
  protected Real Re2(quantity = \"ReynoldsNumber\", unit = \"1\") = Re_turbulent \"Boundary between transition and turbulent regime\";
  protected Real dp_a(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\") \"Upper end of regularization domain of the m_flow(dp) relation\";
  protected Real dp_b(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\") \"Lower end of regularization domain of the m_flow(dp) relation\";
  protected Real m_flow_a(quantity = \"MassFlowRate\", unit = \"kg/s\") \"Value at upper end of regularization domain\";
  protected Real m_flow_b(quantity = \"MassFlowRate\", unit = \"kg/s\") \"Value at lower end of regularization domain\";
  protected Real dm_flow_ddp_fric_a(quantity = \"MassFlowRate\", unit = \"kg/s\") \"Derivative at upper end of regularization domain\";
  protected Real dm_flow_ddp_fric_b(quantity = \"MassFlowRate\", unit = \"kg/s\") \"Derivative at lower end of regularization domain\";
  protected Real dp_grav_a(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\") = g_times_height_ab * rho_a \"Static head if mass flows in design direction (a to b)\";
  protected Real dp_grav_b(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\") = g_times_height_ab * rho_b \"Static head if mass flows against design direction (b to a)\";
  protected Real m_flow_zero(quantity = \"MassFlowRate\", unit = \"kg/s\") = 0.0;
  protected Real dm_flow_ddp_fric_zero;
  protected Real Re1(quantity = \"ReynoldsNumber\", unit = \"1\") = min((745.0 * exp(if Delta <= 0.0065 then 1.0 else 0.0065 / Delta)) ^ 0.97, Re_turbulent) \"Boundary between laminar regime and transition\";
  protected Real dp_zero(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\") = (dp_grav_a + dp_grav_b) / 2.0;
algorithm
  dp_a := max(dp_grav_a, dp_grav_b) + dp_small;
  dp_b := min(dp_grav_a, dp_grav_b) - dp_small;
  if dp >= dp_a then
    m_flow := Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.WallFriction.Internal.m_flow_of_dp_fric(dp - dp_grav_a, rho_a, rho_b, mu_a, mu_b, length, diameter, crossArea, Re1, Re2, Delta)[1];
  elseif dp <= dp_b then
    m_flow := Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.WallFriction.Internal.m_flow_of_dp_fric(dp - dp_grav_b, rho_a, rho_b, mu_a, mu_b, length, diameter, crossArea, Re1, Re2, Delta)[1];
  else
    (m_flow_a, dm_flow_ddp_fric_a) := Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.WallFriction.Internal.m_flow_of_dp_fric(dp_a - dp_grav_a, rho_a, rho_b, mu_a, mu_b, length, diameter, crossArea, Re1, Re2, Delta);
    (m_flow_b, dm_flow_ddp_fric_b) := Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.WallFriction.Internal.m_flow_of_dp_fric(dp_b - dp_grav_b, rho_a, rho_b, mu_a, mu_b, length, diameter, crossArea, Re1, Re2, Delta);
    (m_flow, dm_flow_ddp_fric_zero) := Modelica.Fluid.Utilities.regFun3(dp_zero, dp_b, dp_a, m_flow_b, m_flow_a, dm_flow_ddp_fric_b, dm_flow_ddp_fric_a);
    if dp > dp_zero then
      m_flow := Modelica.Fluid.Utilities.regFun3(dp, dp_zero, dp_a, m_flow_zero, m_flow_a, dm_flow_ddp_fric_zero, dm_flow_ddp_fric_a)[1];
    else
      m_flow := Modelica.Fluid.Utilities.regFun3(dp, dp_b, dp_zero, m_flow_b, m_flow_zero, dm_flow_ddp_fric_b, dm_flow_ddp_fric_zero)[1];
    end if;
  end if;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.WallFriction.massFlowRate_dp_staticHead;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.WallFriction.pressureLoss_m_flow \"Return pressure loss dp as function of mass flow rate m_flow, i.e., dp = f(m_flow), due to wall friction\"
  input Real m_flow(quantity = \"MassFlowRate\", unit = \"kg/s\") \"Mass flow rate from port_a to port_b\";
  input Real rho_a(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0) \"Density at port_a\";
  input Real rho_b(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0) \"Density at port_b\";
  input Real mu_a(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0) \"Dynamic viscosity at port_a (dummy if use_mu = false)\";
  input Real mu_b(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0) \"Dynamic viscosity at port_b (dummy if use_mu = false)\";
  input Real length(quantity = \"Length\", unit = \"m\") \"Length of pipe\";
  input Real diameter(quantity = \"Length\", unit = \"m\", min = 0.0) \"Inner (hydraulic) diameter of pipe\";
  input Real crossArea(quantity = \"Area\", unit = \"m2\") = 3.141592653589793 * diameter ^ 2.0 / 4.0 \"Inner cross section area\";
  input Real roughness(quantity = \"Length\", unit = \"m\", min = 0.0) = 2.5e-5 \"Absolute roughness of pipe, with a default for a smooth steel pipe (dummy if use_roughness = false)\";
  input Real m_flow_small(quantity = \"MassFlowRate\", unit = \"kg/s\") = 0.01 \"Regularization of zero flow if |m_flow| < m_flow_small (dummy if use_m_flow_small = false)\";
  input Real Re_turbulent(quantity = \"ReynoldsNumber\", unit = \"1\") = 4000.0 \"Turbulent flow if Re >= Re_turbulent (dummy if use_Re_turbulent = false)\";
  output Real dp(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\") \"Pressure loss (dp = port_a.p - port_b.p)\";
  protected Real Delta = roughness / diameter \"Relative roughness\";
  protected Real Re2(quantity = \"ReynoldsNumber\", unit = \"1\") = Re_turbulent \"Re entering turbulent curve\";
  protected Real mu(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0) \"Upstream viscosity\";
  protected Real rho(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0) \"Upstream density\";
  protected Real Re(quantity = \"ReynoldsNumber\", unit = \"1\") \"Reynolds number\";
  protected Real lambda2 \"Modified friction coefficient (= lambda*Re^2)\";
  protected Real Re1(quantity = \"ReynoldsNumber\", unit = \"1\") = min(745.0 * exp(if Delta <= 0.0065 then 1.0 else 0.0065 / Delta), Re_turbulent) \"Re leaving laminar curve\";
algorithm
  rho := if m_flow >= 0.0 then rho_a else rho_b;
  mu := if m_flow >= 0.0 then mu_a else mu_b;
  Re := diameter * abs(m_flow) / (crossArea * mu);
  lambda2 := if Re <= Re1 then 64.0 * Re else if Re >= Re2 then 0.25 * (Re / log10(Delta / 3.7 + 5.74 / Re ^ 0.9)) ^ 2.0 else Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.WallFriction.pressureLoss_m_flow.interpolateInRegion2(Re, Re1, Re2, Delta);
  dp := length * mu * mu / (2.0 * rho * diameter * diameter * diameter) * (if m_flow >= 0.0 then lambda2 else -lambda2);
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.WallFriction.pressureLoss_m_flow;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.WallFriction.pressureLoss_m_flow.interpolateInRegion2
  input Real Re(quantity = \"ReynoldsNumber\", unit = \"1\");
  input Real Re1(quantity = \"ReynoldsNumber\", unit = \"1\");
  input Real Re2(quantity = \"ReynoldsNumber\", unit = \"1\");
  input Real Delta;
  output Real lambda2;
  protected Real x1 = log10(Re1);
  protected Real y1 = log10(64.0 * Re1);
  protected Real yd1 = 1.0;
  protected Real aux1 = 1.1217826467560994;
  protected Real aux2 = Delta / 3.7 + 5.74 / Re2 ^ 0.9;
  protected Real x2 = log10(Re2);
  protected Real dx;
  protected Real aux3 = log10(aux2);
  protected Real diff_x = x2 - x1;
  protected Real L2 = 0.25 * (Re2 / aux3) ^ 2.0;
  protected Real yd2 = 2.0 + 4.0 * aux1 / (aux2 * aux3 * Re2 ^ 0.9);
  protected Real aux4 = 2.51 / sqrt(L2) + 0.27 * Delta;
  protected Real y2 = log10(L2);
  protected Real aux5 = -2.0 * sqrt(L2) * log10(aux4);
  protected Real m = (y2 - y1) / diff_x;
  protected Real c2 = (3.0 * m - 2.0 * yd1 - yd2) / diff_x;
  protected Real c3 = (yd1 + yd2 - 2.0 * m) / (diff_x * diff_x);
algorithm
  dx := log10(Re / Re1);
  lambda2 := 64.0 * Re1 * (Re / Re1) ^ (1.0 + dx * (c2 + dx * c3));
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.WallFriction.pressureLoss_m_flow.interpolateInRegion2;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.Medium.ThermodynamicState \"Automatically generated record constructor for Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.Medium.ThermodynamicState\"
  input Real p;
  input Real T;
  output ThermodynamicState res;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.Medium.ThermodynamicState;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.Medium.density \"Return density\"
  input Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.Medium.ThermodynamicState state \"Thermodynamic state record\";
  output Real d(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0, max = 1e5, start = 1.0, nominal = 1.0) \"Density\";
algorithm
  d := 995.586;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.Medium.density;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.Medium.setState_phX \"Return thermodynamic state from p, h, and X or Xi\"
  input Real p(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, max = 1e8, start = 1e5, nominal = 1e5) \"Pressure\";
  input Real h(quantity = \"SpecificEnergy\", unit = \"J/kg\", min = -1e10, max = 1e10, nominal = 1e6) \"Specific enthalpy\";
  input Real[:] X(quantity = fill(\"MassFraction\", size(X, 1)), unit = fill(\"kg/kg\", size(X, 1)), min = fill(0.0, size(X, 1)), max = fill(1.0, size(X, 1)), nominal = fill(0.1, size(X, 1))) = {1.0} \"Mass fractions\";
  output Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.Medium.ThermodynamicState state \"Thermodynamic state record\";
algorithm
  state := Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.Medium.ThermodynamicState(p, 273.15 + h / 4184.0);
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.Medium.setState_phX;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.Medium.ThermodynamicState \"Automatically generated record constructor for Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.Medium.ThermodynamicState\"
  input Real p;
  input Real T;
  output ThermodynamicState res;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.Medium.ThermodynamicState;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.Medium.density \"Return density\"
  input Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.Medium.ThermodynamicState state \"Thermodynamic state record\";
  output Real d(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0, max = 1e5, start = 1.0, nominal = 1.0) \"Density\";
algorithm
  d := 995.586;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.Medium.density;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.Medium.dynamicViscosity \"Return dynamic viscosity\"
  input Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.Medium.ThermodynamicState state \"Thermodynamic state record\";
  output Real eta(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0, max = 1e8, start = 0.001, nominal = 0.001) \"Dynamic viscosity\";
algorithm
  eta := 0.001;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.Medium.dynamicViscosity;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.Medium.pressure \"Return pressure\"
  input Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.Medium.ThermodynamicState state \"Thermodynamic state record\";
  output Real p(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, max = 1e8, start = 1e5, nominal = 1e5) \"Pressure\";
algorithm
  p := state.p;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.Medium.pressure;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.WallFriction.Internal.m_flow_of_dp_fric \"Calculate mass flow rate as function of pressure drop due to friction\"
  input Real dp_fric(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\") \"Pressure loss due to friction (dp = port_a.p - port_b.p)\";
  input Real rho_a(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0) \"Density at port_a\";
  input Real rho_b(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0) \"Density at port_b\";
  input Real mu_a(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0) \"Dynamic viscosity at port_a (dummy if use_mu = false)\";
  input Real mu_b(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0) \"Dynamic viscosity at port_b (dummy if use_mu = false)\";
  input Real length(quantity = \"Length\", unit = \"m\") \"Length of pipe\";
  input Real diameter(quantity = \"Length\", unit = \"m\", min = 0.0) \"Inner (hydraulic) diameter of pipe\";
  input Real crossArea(quantity = \"Area\", unit = \"m2\") \"Inner cross section area\";
  input Real Re1(quantity = \"ReynoldsNumber\", unit = \"1\") \"Boundary between laminar regime and transition\";
  input Real Re2(quantity = \"ReynoldsNumber\", unit = \"1\") \"Boundary between transition and turbulent regime\";
  input Real Delta \"Relative roughness\";
  output Real m_flow(quantity = \"MassFlowRate\", unit = \"kg/s\") \"Mass flow rate from port_a to port_b\";
  output Real dm_flow_ddp_fric \"Derivative of mass flow rate with dp_fric\";
  protected Real mu(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0) \"Upstream viscosity\";
  protected Real rho(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0) \"Upstream density\";
  protected Real lambda2 \"Modified friction coefficient (= lambda*Re^2)\";
  protected Real Re(quantity = \"ReynoldsNumber\", unit = \"1\") \"Reynolds number\";
  protected Real dRe_ddp \"dRe/ddp\";
  protected Real aux1;
  protected Real aux2;
algorithm
  if dp_fric >= 0.0 then
    rho := rho_a;
    mu := mu_a;
  else
    rho := rho_b;
    mu := mu_b;
  end if;
  lambda2 := abs(dp_fric) * 2.0 * diameter ^ 3.0 * rho / (length * mu * mu) \"Known as lambda2=f(dp)\";
  aux1 := 2.0 * diameter ^ 3.0 * rho / (length * mu ^ 2.0);
  Re := lambda2 / 64.0 \"Hagen-Poiseuille\";
  dRe_ddp := aux1 / 64.0 \"Hagen-Poiseuille\";
  if Re > Re1 then
    Re := -2.0 * sqrt(lambda2) * log10(2.51 / sqrt(lambda2) + 0.27 * Delta) \"Colebrook-White\";
    aux2 := sqrt(aux1 * abs(dp_fric));
    dRe_ddp := 0.43429448190325176 * (5.02 / (2.0 * abs(dp_fric) * (2.51 / aux2 + 0.27 * Delta)) - 2.0 * log(2.51 / aux2 + 0.27 * Delta) * aux1 / (2.0 * aux2));
    if Re < Re2 then
      (Re, dRe_ddp) := Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.WallFriction.Internal.m_flow_of_dp_fric.interpolateInRegion2_withDerivative(lambda2, Re1, Re2, Delta, dp_fric);
    end if;
  end if;
  m_flow := crossArea / diameter * mu * (if dp_fric >= 0.0 then Re else -Re);
  dm_flow_ddp_fric := crossArea / diameter * mu * dRe_ddp;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.WallFriction.Internal.m_flow_of_dp_fric;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.WallFriction.Internal.m_flow_of_dp_fric.interpolateInRegion2_withDerivative \"Interpolation in log-log space using a cubic Hermite polynomial, where x=log10(lambda2), y=log10(Re)\"
  input Real lambda2 \"Known independent variable\";
  input Real Re1(quantity = \"ReynoldsNumber\", unit = \"1\") \"Boundary between laminar regime and transition\";
  input Real Re2(quantity = \"ReynoldsNumber\", unit = \"1\") \"Boundary between transition and turbulent regime\";
  input Real Delta \"Relative roughness\";
  input Real dp_fric(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\") \"Pressure loss due to friction (dp = port_a.p - port_b.p)\";
  output Real Re(quantity = \"ReynoldsNumber\", unit = \"1\") \"Unknown return variable\";
  output Real dRe_ddp \"Derivative of return value\";
  protected Real x1 = log10(64.0 * Re1);
  protected Real y1 = log10(Re1);
  protected Real y1d = 1.0;
  protected Real aux2 = Delta / 3.7 + 5.74 / Re2 ^ 0.9;
  protected Real x = log10(lambda2);
  protected Real y;
  protected Real dy_dx \"Derivative in transformed space\";
  protected Real aux3 = log10(aux2);
  protected Real L2 = 0.25 * (Re2 / aux3) ^ 2.0;
  protected Real aux4 = 2.51 / sqrt(L2) + 0.27 * Delta;
  protected Real x2 = log10(L2);
  protected Real aux5 = -2.0 * sqrt(L2) * log10(aux4);
  protected Real y2 = log10(aux5);
  protected Real y2d = 0.5 + 1.0900791495771618 / (aux5 * aux4);
algorithm
  (y, dy_dx) := Modelica.Fluid.Utilities.cubicHermite_withDerivative(x, x1, x2, y1, y2, y1d, y2d);
  Re := 10.0 ^ y;
  dRe_ddp := Re / abs(dp_fric) * dy_dx;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.WallFriction.Internal.m_flow_of_dp_fric.interpolateInRegion2_withDerivative;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.WallFriction.massFlowRate_dp_staticHead \"Return mass flow rate m_flow as function of pressure loss dp, i.e., m_flow = f(dp), due to wall friction and static head\"
  input Real dp(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\") \"Pressure loss (dp = port_a.p - port_b.p)\";
  input Real rho_a(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0) \"Density at port_a\";
  input Real rho_b(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0) \"Density at port_b\";
  input Real mu_a(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0) \"Dynamic viscosity at port_a (dummy if use_mu = false)\";
  input Real mu_b(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0) \"Dynamic viscosity at port_b (dummy if use_mu = false)\";
  input Real length(quantity = \"Length\", unit = \"m\") \"Length of pipe\";
  input Real diameter(quantity = \"Length\", unit = \"m\", min = 0.0) \"Inner (hydraulic) diameter of pipe\";
  input Real g_times_height_ab \"Gravity times (Height(port_b) - Height(port_a))\";
  input Real crossArea(quantity = \"Area\", unit = \"m2\") = 3.141592653589793 * diameter ^ 2.0 / 4.0 \"Inner cross section area\";
  input Real roughness(quantity = \"Length\", unit = \"m\", min = 0.0) = 2.5e-5 \"Absolute roughness of pipe, with a default for a smooth steel pipe (dummy if use_roughness = false)\";
  input Real dp_small(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, nominal = 1e5) = 1.0 \"Regularization of zero flow if |dp| < dp_small (dummy if use_dp_small = false)\";
  input Real Re_turbulent(quantity = \"ReynoldsNumber\", unit = \"1\") = 4000.0 \"Turbulent flow if Re >= Re_turbulent (dummy if use_Re_turbulent = false)\";
  output Real m_flow(quantity = \"MassFlowRate\", unit = \"kg/s\") \"Mass flow rate from port_a to port_b\";
  protected Real Delta = roughness / diameter \"Relative roughness\";
  protected Real Re(quantity = \"ReynoldsNumber\", unit = \"1\") \"Reynolds number\";
  protected Real Re2(quantity = \"ReynoldsNumber\", unit = \"1\") = Re_turbulent \"Boundary between transition and turbulent regime\";
  protected Real dp_a(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\") \"Upper end of regularization domain of the m_flow(dp) relation\";
  protected Real dp_b(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\") \"Lower end of regularization domain of the m_flow(dp) relation\";
  protected Real m_flow_a(quantity = \"MassFlowRate\", unit = \"kg/s\") \"Value at upper end of regularization domain\";
  protected Real m_flow_b(quantity = \"MassFlowRate\", unit = \"kg/s\") \"Value at lower end of regularization domain\";
  protected Real dm_flow_ddp_fric_a(quantity = \"MassFlowRate\", unit = \"kg/s\") \"Derivative at upper end of regularization domain\";
  protected Real dm_flow_ddp_fric_b(quantity = \"MassFlowRate\", unit = \"kg/s\") \"Derivative at lower end of regularization domain\";
  protected Real dp_grav_a(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\") = g_times_height_ab * rho_a \"Static head if mass flows in design direction (a to b)\";
  protected Real dp_grav_b(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\") = g_times_height_ab * rho_b \"Static head if mass flows against design direction (b to a)\";
  protected Real m_flow_zero(quantity = \"MassFlowRate\", unit = \"kg/s\") = 0.0;
  protected Real dm_flow_ddp_fric_zero;
  protected Real Re1(quantity = \"ReynoldsNumber\", unit = \"1\") = min((745.0 * exp(if Delta <= 0.0065 then 1.0 else 0.0065 / Delta)) ^ 0.97, Re_turbulent) \"Boundary between laminar regime and transition\";
  protected Real dp_zero(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\") = (dp_grav_a + dp_grav_b) / 2.0;
algorithm
  dp_a := max(dp_grav_a, dp_grav_b) + dp_small;
  dp_b := min(dp_grav_a, dp_grav_b) - dp_small;
  if dp >= dp_a then
    m_flow := Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.WallFriction.Internal.m_flow_of_dp_fric(dp - dp_grav_a, rho_a, rho_b, mu_a, mu_b, length, diameter, crossArea, Re1, Re2, Delta)[1];
  elseif dp <= dp_b then
    m_flow := Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.WallFriction.Internal.m_flow_of_dp_fric(dp - dp_grav_b, rho_a, rho_b, mu_a, mu_b, length, diameter, crossArea, Re1, Re2, Delta)[1];
  else
    (m_flow_a, dm_flow_ddp_fric_a) := Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.WallFriction.Internal.m_flow_of_dp_fric(dp_a - dp_grav_a, rho_a, rho_b, mu_a, mu_b, length, diameter, crossArea, Re1, Re2, Delta);
    (m_flow_b, dm_flow_ddp_fric_b) := Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.WallFriction.Internal.m_flow_of_dp_fric(dp_b - dp_grav_b, rho_a, rho_b, mu_a, mu_b, length, diameter, crossArea, Re1, Re2, Delta);
    (m_flow, dm_flow_ddp_fric_zero) := Modelica.Fluid.Utilities.regFun3(dp_zero, dp_b, dp_a, m_flow_b, m_flow_a, dm_flow_ddp_fric_b, dm_flow_ddp_fric_a);
    if dp > dp_zero then
      m_flow := Modelica.Fluid.Utilities.regFun3(dp, dp_zero, dp_a, m_flow_zero, m_flow_a, dm_flow_ddp_fric_zero, dm_flow_ddp_fric_a)[1];
    else
      m_flow := Modelica.Fluid.Utilities.regFun3(dp, dp_b, dp_zero, m_flow_b, m_flow_zero, dm_flow_ddp_fric_b, dm_flow_ddp_fric_zero)[1];
    end if;
  end if;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.WallFriction.massFlowRate_dp_staticHead;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.WallFriction.pressureLoss_m_flow \"Return pressure loss dp as function of mass flow rate m_flow, i.e., dp = f(m_flow), due to wall friction\"
  input Real m_flow(quantity = \"MassFlowRate\", unit = \"kg/s\") \"Mass flow rate from port_a to port_b\";
  input Real rho_a(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0) \"Density at port_a\";
  input Real rho_b(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0) \"Density at port_b\";
  input Real mu_a(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0) \"Dynamic viscosity at port_a (dummy if use_mu = false)\";
  input Real mu_b(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0) \"Dynamic viscosity at port_b (dummy if use_mu = false)\";
  input Real length(quantity = \"Length\", unit = \"m\") \"Length of pipe\";
  input Real diameter(quantity = \"Length\", unit = \"m\", min = 0.0) \"Inner (hydraulic) diameter of pipe\";
  input Real crossArea(quantity = \"Area\", unit = \"m2\") = 3.141592653589793 * diameter ^ 2.0 / 4.0 \"Inner cross section area\";
  input Real roughness(quantity = \"Length\", unit = \"m\", min = 0.0) = 2.5e-5 \"Absolute roughness of pipe, with a default for a smooth steel pipe (dummy if use_roughness = false)\";
  input Real m_flow_small(quantity = \"MassFlowRate\", unit = \"kg/s\") = 0.01 \"Regularization of zero flow if |m_flow| < m_flow_small (dummy if use_m_flow_small = false)\";
  input Real Re_turbulent(quantity = \"ReynoldsNumber\", unit = \"1\") = 4000.0 \"Turbulent flow if Re >= Re_turbulent (dummy if use_Re_turbulent = false)\";
  output Real dp(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\") \"Pressure loss (dp = port_a.p - port_b.p)\";
  protected Real Delta = roughness / diameter \"Relative roughness\";
  protected Real Re2(quantity = \"ReynoldsNumber\", unit = \"1\") = Re_turbulent \"Re entering turbulent curve\";
  protected Real mu(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0) \"Upstream viscosity\";
  protected Real rho(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0) \"Upstream density\";
  protected Real Re(quantity = \"ReynoldsNumber\", unit = \"1\") \"Reynolds number\";
  protected Real lambda2 \"Modified friction coefficient (= lambda*Re^2)\";
  protected Real Re1(quantity = \"ReynoldsNumber\", unit = \"1\") = min(745.0 * exp(if Delta <= 0.0065 then 1.0 else 0.0065 / Delta), Re_turbulent) \"Re leaving laminar curve\";
algorithm
  rho := if m_flow >= 0.0 then rho_a else rho_b;
  mu := if m_flow >= 0.0 then mu_a else mu_b;
  Re := diameter * abs(m_flow) / (crossArea * mu);
  lambda2 := if Re <= Re1 then 64.0 * Re else if Re >= Re2 then 0.25 * (Re / log10(Delta / 3.7 + 5.74 / Re ^ 0.9)) ^ 2.0 else Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.WallFriction.pressureLoss_m_flow.interpolateInRegion2(Re, Re1, Re2, Delta);
  dp := length * mu * mu / (2.0 * rho * diameter * diameter * diameter) * (if m_flow >= 0.0 then lambda2 else -lambda2);
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.WallFriction.pressureLoss_m_flow;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.WallFriction.pressureLoss_m_flow.interpolateInRegion2
  input Real Re(quantity = \"ReynoldsNumber\", unit = \"1\");
  input Real Re1(quantity = \"ReynoldsNumber\", unit = \"1\");
  input Real Re2(quantity = \"ReynoldsNumber\", unit = \"1\");
  input Real Delta;
  output Real lambda2;
  protected Real x1 = log10(Re1);
  protected Real y1 = log10(64.0 * Re1);
  protected Real yd1 = 1.0;
  protected Real aux1 = 1.1217826467560994;
  protected Real aux2 = Delta / 3.7 + 5.74 / Re2 ^ 0.9;
  protected Real x2 = log10(Re2);
  protected Real dx;
  protected Real aux3 = log10(aux2);
  protected Real diff_x = x2 - x1;
  protected Real L2 = 0.25 * (Re2 / aux3) ^ 2.0;
  protected Real yd2 = 2.0 + 4.0 * aux1 / (aux2 * aux3 * Re2 ^ 0.9);
  protected Real aux4 = 2.51 / sqrt(L2) + 0.27 * Delta;
  protected Real y2 = log10(L2);
  protected Real aux5 = -2.0 * sqrt(L2) * log10(aux4);
  protected Real m = (y2 - y1) / diff_x;
  protected Real c2 = (3.0 * m - 2.0 * yd1 - yd2) / diff_x;
  protected Real c3 = (yd1 + yd2 - 2.0 * m) / (diff_x * diff_x);
algorithm
  dx := log10(Re / Re1);
  lambda2 := 64.0 * Re1 * (Re / Re1) ^ (1.0 + dx * (c2 + dx * c3));
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.WallFriction.pressureLoss_m_flow.interpolateInRegion2;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.Medium.ThermodynamicState \"Automatically generated record constructor for Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.Medium.ThermodynamicState\"
  input Real p;
  input Real T;
  output ThermodynamicState res;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.Medium.ThermodynamicState;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.Medium.density \"Return density\"
  input Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.Medium.ThermodynamicState state \"Thermodynamic state record\";
  output Real d(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0, max = 1e5, start = 1.0, nominal = 1.0) \"Density\";
algorithm
  d := 995.586;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.Medium.density;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.Medium.setState_phX \"Return thermodynamic state from p, h, and X or Xi\"
  input Real p(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, max = 1e8, start = 1e5, nominal = 1e5) \"Pressure\";
  input Real h(quantity = \"SpecificEnergy\", unit = \"J/kg\", min = -1e10, max = 1e10, nominal = 1e6) \"Specific enthalpy\";
  input Real[:] X(quantity = fill(\"MassFraction\", size(X, 1)), unit = fill(\"kg/kg\", size(X, 1)), min = fill(0.0, size(X, 1)), max = fill(1.0, size(X, 1)), nominal = fill(0.1, size(X, 1))) = {1.0} \"Mass fractions\";
  output Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.Medium.ThermodynamicState state \"Thermodynamic state record\";
algorithm
  state := Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.Medium.ThermodynamicState(p, 273.15 + h / 4184.0);
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.Medium.setState_phX;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.flowModel.Medium.ThermodynamicState \"Automatically generated record constructor for Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.flowModel.Medium.ThermodynamicState\"
  input Real p;
  input Real T;
  output ThermodynamicState res;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.flowModel.Medium.ThermodynamicState;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.flowModel.Medium.density \"Return density\"
  input Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.flowModel.Medium.ThermodynamicState state \"Thermodynamic state record\";
  output Real d(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0, max = 1e5, start = 1.0, nominal = 1.0) \"Density\";
algorithm
  d := 995.586;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.flowModel.Medium.density;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.flowModel.Medium.dynamicViscosity \"Return dynamic viscosity\"
  input Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.flowModel.Medium.ThermodynamicState state \"Thermodynamic state record\";
  output Real eta(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0, max = 1e8, start = 0.001, nominal = 0.001) \"Dynamic viscosity\";
algorithm
  eta := 0.001;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.flowModel.Medium.dynamicViscosity;

function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.flowModel.Medium.pressure \"Return pressure\"
  input Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.flowModel.Medium.ThermodynamicState state \"Thermodynamic state record\";
  output Real p(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, max = 1e8, start = 1e5, nominal = 1e5) \"Pressure\";
algorithm
  p := state.p;
end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.flowModel.Medium.pressure;

function Modelica.Fluid
...[truncated 95528 chars]...
ue for p[n+1] at design outflow\";
  final parameter Integer pipe2.flowModel.m = 1 \"Number of flow segments\";
  final Real pipe2.flowModel.pathLengths[1](quantity = \"Length\", unit = \"m\") \"Lengths along flow path\";
  Real pipe2.flowModel.m_flows[1](quantity = \"MassFlowRate.SimpleLiquidWater\", unit = \"kg/s\", min = -1e60, max = 1e5, start = 0.0, stateSelect = StateSelect.default) \"mass flow rates between states\";
  Real pipe2.flowModel.Is[1](quantity = \"Momentum\", unit = \"kg.m/s\") \"Momenta of flow segments\";
  Real pipe2.flowModel.Ib_flows[1](quantity = \"Force\", unit = \"N\") \"Flow of momentum across boundaries\";
  Real pipe2.flowModel.Fs_p[1](quantity = \"Force\", unit = \"N\") \"Pressure forces\";
  Real pipe2.flowModel.Fs_fg[1](quantity = \"Force\", unit = \"N\") \"Friction and gravity forces\";
  final parameter Boolean pipe2.flowModel.useUpstreamScheme = true \"= false to average upstream and downstream properties across flow segments\";
  final parameter Boolean pipe2.flowModel.use_Ib_flows = false \"= true to consider differences in flow of momentum through boundaries\";
  Real pipe2.flowModel.rhos[1](quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0, max = 1e5, start = 1.0, nominal = 1.0);
  Real pipe2.flowModel.rhos[2](quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0, max = 1e5, start = 1.0, nominal = 1.0);
  Real pipe2.flowModel.rhos_act[1](quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0, max = 1e5, start = 1.0, nominal = 1.0) \"Actual density per segment\";
  Real pipe2.flowModel.mus[1](quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0, max = 1e8, start = 0.001, nominal = 0.001);
  Real pipe2.flowModel.mus[2](quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0, max = 1e8, start = 0.001, nominal = 0.001);
  Real pipe2.flowModel.mus_act[1](quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0, max = 1e8, start = 0.001, nominal = 0.001) \"Actual viscosity per segment\";
  Real pipe2.flowModel.dps_fg[1](quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", start = pipe2.flowModel.p_a_start - pipe2.flowModel.p_b_start) \"pressure drop between states\";
  final parameter Real pipe2.flowModel.Re_turbulent(quantity = \"ReynoldsNumber\", unit = \"1\") = 4000.0 \"Start of turbulent regime, depending on type of flow device\";
  final parameter Boolean pipe2.flowModel.show_Res = false \"= true, if Reynolds numbers are included for plotting\";
  protected final parameter Boolean pipe2.flowModel.use_rho_nominal = false \"= true, if rho_nominal is used, otherwise computed from medium\";
  protected parameter Real pipe2.flowModel.rho_nominal(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0) = 995.586 \"Nominal density (e.g., rho_liquidWater = 995, rho_air = 1.2)\";
  protected final parameter Boolean pipe2.flowModel.use_mu_nominal = false \"= true, if mu_nominal is used, otherwise computed from medium\";
  protected parameter Real pipe2.flowModel.mu_nominal(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0) = 0.001 \"Nominal dynamic viscosity (e.g., mu_liquidWater = 1e-3, mu_air = 1.8e-5)\";
  Real pipe2.flowModel.pathLengths_internal[1](quantity = \"Length\", unit = \"m\") \"pathLengths used internally; to be defined by extending class\";
  Real pipe2.flowModel.Res_turbulent_internal[1](quantity = \"ReynoldsNumber\", unit = \"1\") \"Re_turbulent used internally; to be defined by extending class\";
  parameter Real pipe2.flowModel.dp_nominal(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, start = 1.0, fixed = false, nominal = 1e5) \"Nominal pressure loss (only for nominal models)\";
  parameter Real pipe2.flowModel.m_flow_nominal(quantity = \"MassFlowRate\", unit = \"kg/s\") = 100.0 * pipe2.flowModel.m_flow_small \"Nominal mass flow rate\";
  parameter Real pipe2.flowModel.m_flow_small(quantity = \"MassFlowRate\", unit = \"kg/s\") = system.m_flow_small \"Within regularization if |m_flows| < m_flow_small (may be wider for large discontinuities in static head)\";
  protected parameter Real pipe2.flowModel.dp_small(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, start = 1.0, fixed = false, nominal = 1e5) \"Within regularization if |dp| < dp_small (may be wider for large discontinuities in static head)\";
  protected final parameter Boolean pipe2.flowModel.constantPressureLossCoefficient = false \"= true if the pressure loss does not depend on fluid states\";
  protected final parameter Boolean pipe2.flowModel.continuousFlowReversal = false \"= true if the pressure loss is continuous around zero flow\";
  protected Real pipe2.flowModel.diameters[1](quantity = \"Length\", unit = \"m\") \"mean diameters between segments\";
  protected Real pipe2.flowModel.dp_fric_nominal(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, nominal = 1e5) = Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.WallFriction.pressureLoss_m_flow(pipe2.flowModel.m_flow_nominal / pipe2.flowModel.nParallel, pipe2.flowModel.rho_nominal, pipe2.flowModel.rho_nominal, pipe2.flowModel.mu_nominal, pipe2.flowModel.mu_nominal, pipe2.flowModel.pathLengths_internal[1], pipe2.flowModel.diameters[1], (pipe2.flowModel.crossAreas[1] + pipe2.flowModel.crossAreas[2]) / 2.0, (pipe2.flowModel.roughnesses[1] + pipe2.flowModel.roughnesses[2]) / 2.0, pipe2.flowModel.m_flow_small / pipe2.flowModel.nParallel, pipe2.flowModel.Res_turbulent_internal[1]) \"pressure loss for nominal conditions\";
  final parameter Boolean pipe3.allowFlowReversal = true \"= true to allow flow reversal, false restricts to design direction (port_a -> port_b)\";
  Real pipe3.port_a.m_flow(quantity = \"MassFlowRate.SimpleLiquidWater\", unit = \"kg/s\", min = -1e60, max = 1e5) \"Mass flow rate from the connection point into the component\";
  Real pipe3.port_a.p(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, max = 1e8, start = 1e5, nominal = 1e5) \"Thermodynamic pressure in the connection point\";
  Real pipe3.port_a.h_outflow(quantity = \"SpecificEnergy\", unit = \"J/kg\", min = -1e10, max = 1e10, nominal = 1e6) \"Specific thermodynamic enthalpy close to the connection point if m_flow < 0\";
  Real pipe3.port_b.m_flow(quantity = \"MassFlowRate.SimpleLiquidWater\", unit = \"kg/s\", min = -1e5, max = 1e60) \"Mass flow rate from the connection point into the component\";
  Real pipe3.port_b.p(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, max = 1e8, start = 1e5, nominal = 1e5) \"Thermodynamic pressure in the connection point\";
  Real pipe3.port_b.h_outflow(quantity = \"SpecificEnergy\", unit = \"J/kg\", min = -1e10, max = 1e10, nominal = 1e6) \"Specific thermodynamic enthalpy close to the connection point if m_flow < 0\";
  protected parameter Boolean pipe3.port_a_exposesState = false \"= true if port_a exposes the state of a fluid volume\";
  protected parameter Boolean pipe3.port_b_exposesState = false \"= true if port_b.p exposes the state of a fluid volume\";
  protected parameter Boolean pipe3.showDesignFlowDirection = true \"= false to hide the arrow in the model icon\";
  parameter Real pipe3.nParallel(min = 1.0) = 1.0 \"Number of identical parallel pipes\";
  parameter Real pipe3.length(quantity = \"Length\", unit = \"m\") = 2.0 \"Length\";
  parameter Boolean pipe3.isCircular = true \"= true if cross sectional area is circular\";
  parameter Real pipe3.diameter(quantity = \"Length\", unit = \"m\", min = 0.0) = 0.1 \"Diameter of circular pipe\";
  parameter Real pipe3.crossArea(quantity = \"Area\", unit = \"m2\") = 3.141592653589793 * pipe3.diameter * pipe3.diameter / 4.0 \"Inner cross section area\";
  parameter Real pipe3.perimeter(quantity = \"Length\", unit = \"m\") = 3.141592653589793 * pipe3.diameter \"Inner perimeter\";
  parameter Real pipe3.roughness(quantity = \"Length\", unit = \"m\", min = 0.0) = 2.5e-5 \"Average height of surface asperities (default: smooth steel pipe)\";
  final parameter Real pipe3.V(quantity = \"Volume\", unit = \"m3\") = pipe3.crossArea * pipe3.length * pipe3.nParallel \"volume size\";
  parameter Real pipe3.height_ab(quantity = \"Length\", unit = \"m\") = -1.0 \"Height(port_b) - Height(port_a)\";
  parameter Real pipe3.p_a_start(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, max = 1e8, start = 1e5, nominal = 1e5) = system.p_start \"Start value of pressure at port a\";
  parameter Real pipe3.p_b_start(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, max = 1e8, start = 1e5, nominal = 1e5) = pipe3.p_a_start \"Start value of pressure at port b\";
  final parameter Real pipe3.m_flow_start(quantity = \"MassFlowRate.SimpleLiquidWater\", unit = \"kg/s\", min = -1e5, max = 1e5) = 0.0 \"Start value for mass flow rate\";
  final parameter Boolean pipe3.flowModel.from_dp = true \"= true, use m_flow = f(dp), otherwise dp = f(m_flow)\";
  final parameter Integer pipe3.flowModel.n = 2 \"Number of discrete flow volumes\";
  Real pipe3.flowModel.states[1].p(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, max = 1e8, start = 1e5, nominal = 1e5) \"Absolute pressure of medium\";
  Real pipe3.flowModel.states[1].T(quantity = \"ThermodynamicTemperature\", unit = \"K\", displayUnit = \"degC\", min = 1.0, max = 1e4, start = 300.0, nominal = 300.0) \"Temperature of medium\";
  Real pipe3.flowModel.states[2].p(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, max = 1e8, start = 1e5, nominal = 1e5) \"Absolute pressure of medium\";
  Real pipe3.flowModel.states[2].T(quantity = \"ThermodynamicTemperature\", unit = \"K\", displayUnit = \"degC\", min = 1.0, max = 1e4, start = 300.0, nominal = 300.0) \"Temperature of medium\";
  Real pipe3.flowModel.vs[1](quantity = \"Velocity\", unit = \"m/s\") \"Mean velocities of fluid flow\";
  Real pipe3.flowModel.vs[2](quantity = \"Velocity\", unit = \"m/s\") \"Mean velocities of fluid flow\";
  final parameter Real pipe3.flowModel.nParallel = pipe3.nParallel \"number of identical parallel flow devices\";
  final Real pipe3.flowModel.crossAreas[1](quantity = \"Area\", unit = \"m2\") \"Cross flow areas at segment boundaries\";
  final Real pipe3.flowModel.crossAreas[2](quantity = \"Area\", unit = \"m2\") \"Cross flow areas at segment boundaries\";
  final Real pipe3.flowModel.dimensions[1](quantity = \"Length\", unit = \"m\") \"Characteristic dimensions for fluid flow (diameters for pipe flow)\";
  final Real pipe3.flowModel.dimensions[2](quantity = \"Length\", unit = \"m\") \"Characteristic dimensions for fluid flow (diameters for pipe flow)\";
  final Real pipe3.flowModel.roughnesses[1](quantity = \"Length\", unit = \"m\", min = 0.0) \"Average height of surface asperities\";
  final Real pipe3.flowModel.roughnesses[2](quantity = \"Length\", unit = \"m\", min = 0.0) \"Average height of surface asperities\";
  final Real pipe3.flowModel.dheights[1](quantity = \"Length\", unit = \"m\") \"Height(states[2:n]) - Height(states[1:n-1])\";
  final parameter Real pipe3.flowModel.g(quantity = \"Acceleration\", unit = \"m/s2\") = system.g \"Constant gravity acceleration\";
  final parameter Boolean pipe3.flowModel.allowFlowReversal = true \"= true to allow flow reversal, false restricts to design direction (states[1] -> states[n+1])\";
  final parameter enumeration(DynamicFreeInitial, FixedInitial, SteadyStateInitial, SteadyState) pipe3.flowModel.momentumDynamics = Modelica.Fluid.Types.Dynamics.SteadyState \"Formulation of momentum balance\";
  final parameter Real pipe3.flowModel.m_flow_start(quantity = \"MassFlowRate.SimpleLiquidWater\", unit = \"kg/s\", min = -1e5, max = 1e5) = 0.0 \"Start value of mass flow rates\";
  final parameter Real pipe3.flowModel.p_a_start(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, max = 1e8, start = 1e5, nominal = 1e5) = pipe3.p_a_start \"Start value for p[1] at design inflow\";
  final parameter Real pipe3.flowModel.p_b_start(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, max = 1e8, start = 1e5, nominal = 1e5) = pipe3.p_b_start \"Start value for p[n+1] at design outflow\";
  final parameter Integer pipe3.flowModel.m = 1 \"Number of flow segments\";
  final Real pipe3.flowModel.pathLengths[1](quantity = \"Length\", unit = \"m\") \"Lengths along flow path\";
  Real pipe3.flowModel.m_flows[1](quantity = \"MassFlowRate.SimpleLiquidWater\", unit = \"kg/s\", min = -1e60, max = 1e5, start = 0.0, stateSelect = StateSelect.default) \"mass flow rates between states\";
  Real pipe3.flowModel.Is[1](quantity = \"Momentum\", unit = \"kg.m/s\") \"Momenta of flow segments\";
  Real pipe3.flowModel.Ib_flows[1](quantity = \"Force\", unit = \"N\") \"Flow of momentum across boundaries\";
  Real pipe3.flowModel.Fs_p[1](quantity = \"Force\", unit = \"N\") \"Pressure forces\";
  Real pipe3.flowModel.Fs_fg[1](quantity = \"Force\", unit = \"N\") \"Friction and gravity forces\";
  final parameter Boolean pipe3.flowModel.useUpstreamScheme = true \"= false to average upstream and downstream properties across flow segments\";
  final parameter Boolean pipe3.flowModel.use_Ib_flows = false \"= true to consider differences in flow of momentum through boundaries\";
  Real pipe3.flowModel.rhos[1](quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0, max = 1e5, start = 1.0, nominal = 1.0);
  Real pipe3.flowModel.rhos[2](quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0, max = 1e5, start = 1.0, nominal = 1.0);
  Real pipe3.flowModel.rhos_act[1](quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0, max = 1e5, start = 1.0, nominal = 1.0) \"Actual density per segment\";
  Real pipe3.flowModel.mus[1](quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0, max = 1e8, start = 0.001, nominal = 0.001);
  Real pipe3.flowModel.mus[2](quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0, max = 1e8, start = 0.001, nominal = 0.001);
  Real pipe3.flowModel.mus_act[1](quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0, max = 1e8, start = 0.001, nominal = 0.001) \"Actual viscosity per segment\";
  Real pipe3.flowModel.dps_fg[1](quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", start = pipe3.flowModel.p_a_start - pipe3.flowModel.p_b_start) \"pressure drop between states\";
  final parameter Real pipe3.flowModel.Re_turbulent(quantity = \"ReynoldsNumber\", unit = \"1\") = 4000.0 \"Start of turbulent regime, depending on type of flow device\";
  final parameter Boolean pipe3.flowModel.show_Res = false \"= true, if Reynolds numbers are included for plotting\";
  protected final parameter Boolean pipe3.flowModel.use_rho_nominal = false \"= true, if rho_nominal is used, otherwise computed from medium\";
  protected parameter Real pipe3.flowModel.rho_nominal(quantity = \"Density\", unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0) = 995.586 \"Nominal density (e.g., rho_liquidWater = 995, rho_air = 1.2)\";
  protected final parameter Boolean pipe3.flowModel.use_mu_nominal = false \"= true, if mu_nominal is used, otherwise computed from medium\";
  protected parameter Real pipe3.flowModel.mu_nominal(quantity = \"DynamicViscosity\", unit = \"Pa.s\", min = 0.0) = 0.001 \"Nominal dynamic viscosity (e.g., mu_liquidWater = 1e-3, mu_air = 1.8e-5)\";
  Real pipe3.flowModel.pathLengths_internal[1](quantity = \"Length\", unit = \"m\") \"pathLengths used internally; to be defined by extending class\";
  Real pipe3.flowModel.Res_turbulent_internal[1](quantity = \"ReynoldsNumber\", unit = \"1\") \"Re_turbulent used internally; to be defined by extending class\";
  parameter Real pipe3.flowModel.dp_nominal(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, start = 1.0, fixed = false, nominal = 1e5) \"Nominal pressure loss (only for nominal models)\";
  parameter Real pipe3.flowModel.m_flow_nominal(quantity = \"MassFlowRate\", unit = \"kg/s\") = 100.0 * pipe3.flowModel.m_flow_small \"Nominal mass flow rate\";
  parameter Real pipe3.flowModel.m_flow_small(quantity = \"MassFlowRate\", unit = \"kg/s\") = system.m_flow_small \"Within regularization if |m_flows| < m_flow_small (may be wider for large discontinuities in static head)\";
  protected parameter Real pipe3.flowModel.dp_small(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, start = 1.0, fixed = false, nominal = 1e5) \"Within regularization if |dp| < dp_small (may be wider for large discontinuities in static head)\";
  protected final parameter Boolean pipe3.flowModel.constantPressureLossCoefficient = false \"= true if the pressure loss does not depend on fluid states\";
  protected final parameter Boolean pipe3.flowModel.continuousFlowReversal = false \"= true if the pressure loss is continuous around zero flow\";
  protected Real pipe3.flowModel.diameters[1](quantity = \"Length\", unit = \"m\") \"mean diameters between segments\";
  protected Real pipe3.flowModel.dp_fric_nominal(quantity = \"Pressure\", unit = \"Pa\", displayUnit = \"bar\", min = 0.0, nominal = 1e5) = Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.flowModel.WallFriction.pressureLoss_m_flow(pipe3.flowModel.m_flow_nominal / pipe3.flowModel.nParallel, pipe3.flowModel.rho_nominal, pipe3.flowModel.rho_nominal, pipe3.flowModel.mu_nominal, pipe3.flowModel.mu_nominal, pipe3.flowModel.pathLengths_internal[1], pipe3.flowModel.diameters[1], (pipe3.flowModel.crossAreas[1] + pipe3.flowModel.crossAreas[2]) / 2.0, (pipe3.flowModel.roughnesses[1] + pipe3.flowModel.roughnesses[2]) / 2.0, pipe3.flowModel.m_flow_small / pipe3.flowModel.nParallel, pipe3.flowModel.Res_turbulent_internal[1]) \"pressure loss for nominal conditions\";
initial equation
  tank1.level = tank1.level_start_eps;
  tank1.medium.T = tank1.T_start;
  tank2.level = tank2.level_start_eps;
  tank2.medium.T = tank2.T_start;
  tank3.level = tank3.level_start_eps;
  tank3.medium.T = tank3.T_start;
  pipe1.flowModel.dp_nominal = 1000.0 * pipe1.flowModel.dp_small;
  pipe1.flowModel.dp_small = system.dp_small;
  pipe2.flowModel.dp_nominal = 1000.0 * pipe2.flowModel.dp_small;
  pipe2.flowModel.dp_small = system.dp_small;
  pipe3.flowModel.dp_nominal = 1000.0 * pipe3.flowModel.dp_small;
  pipe3.flowModel.dp_small = system.dp_small;
equation
  tank1.portsData_diameter[1] = tank1.portsData_diameter_internal[1];
  tank1.portsData_height[1] = tank1.portsData_height_internal[1];
  tank1.portsData_zeta_in[1] = tank1.portsData_zeta_in_internal[1];
  tank1.portsData_zeta_out[1] = tank1.portsData_zeta_out_internal[1];
  tank2.portsData_diameter[1] = tank2.portsData_diameter_internal[1];
  tank2.portsData_height[1] = tank2.portsData_height_internal[1];
  tank2.portsData_zeta_in[1] = tank2.portsData_zeta_in_internal[1];
  tank2.portsData_zeta_out[1] = tank2.portsData_zeta_out_internal[1];
  tank3.portsData_diameter[1] = tank3.portsData_diameter_internal[1];
  tank3.portsData_height[1] = tank3.portsData_height_internal[1];
  tank3.portsData_zeta_in[1] = tank3.portsData_zeta_in_internal[1];
  tank3.portsData_zeta_out[1] = tank3.portsData_zeta_out_internal[1];
  pipe2.port_a.p = pipe3.port_a.p;
  pipe2.port_a.p = pipe1.port_a.p;
  pipe3.port_b.p = tank3.ports[1].p;
  pipe1.port_b.p = tank1.ports[1].p;
  pipe2.port_b.p = tank2.ports[1].p;
  tank1.heatTransfer.heatPorts[1].Q_flow = 0.0;
  tank2.heatTransfer.heatPorts[1].Q_flow = 0.0;
  tank3.heatTransfer.heatPorts[1].Q_flow = 0.0;
  pipe3.port_a.m_flow + pipe2.port_a.m_flow + pipe1.port_a.m_flow = 0.0;
  pipe1.port_b.m_flow + tank1.ports[1].m_flow = 0.0;
  pipe2.port_b.m_flow + tank2.ports[1].m_flow = 0.0;
  pipe3.port_b.m_flow + tank3.ports[1].m_flow = 0.0;
  assert(tank1.medium.T >= 272.15 and tank1.medium.T <= 403.15, \"
  Temperature T (= \" + String(tank1.medium.T, 6, 0, true) + \" K) is not
  in the allowed range (\" + String(272.15, 6, 0, true) + \" K <= T <= \" + String(403.15, 6, 0, true) + \" K)
  required from medium model \\\"\" + \"SimpleLiquidWater\" + \"\\\".
  \");
  tank1.medium.h = Modelica.Fluid.Examples.Tanks.ThreeTanks.tank1.Medium.specificEnthalpy_pTX(tank1.medium.p, tank1.medium.T, tank1.medium.X);
  tank1.medium.u = 4184.0 * (tank1.medium.T - 273.15);
  tank1.medium.d = 995.586;
  tank1.medium.R = 0.0;
  tank1.medium.MM = 0.018015268;
  tank1.medium.state.T = tank1.medium.T;
  tank1.medium.state.p = tank1.medium.p;
  tank1.medium.X[1] = 1.0;
  assert(tank1.medium.X[1] >= -1e-5 and tank1.medium.X[1] <= 1.00001, \"Mass fraction X[\" + String(1, 0, true) + \"] = \" + String(tank1.medium.X[1], 6, 0, true) + \"of substance \" + \"SimpleLiquidWater\" + \"
  of medium \" + \"SimpleLiquidWater\" + \" is not in the range 0..1\");
  assert(tank1.medium.p >= 0.0, \"Pressure (= \" + String(tank1.medium.p, 6, 0, true) + \" Pa) of medium \\\"\" + \"SimpleLiquidWater\" + \"\\\" is negative
  (Temperature = \" + String(tank1.medium.T, 6, 0, true) + \" K)\");
  tank1.heatTransfer.surfaceAreas = {tank1.crossArea + 2.0 * sqrt(tank1.crossArea * 3.141592653589793) * tank1.level};
  tank1.heatTransfer.Ts = {Modelica.Fluid.Examples.Tanks.ThreeTanks.tank1.heatTransfer.Medium.temperature(tank1.heatTransfer.states[1])};
  tank1.heatTransfer.Ts[1] = tank1.heatTransfer.heatPorts[1].T;
  tank1.heatTransfer.Q_flows[1] = tank1.heatTransfer.heatPorts[1].Q_flow;
  tank1.portAreas = {0.7853981633974483 * tank1.portsData_diameter[1] ^ 2.0};
  tank1.portsData_diameter_internal = {tank1.portsData[1].diameter};
  tank1.portsData_height_internal = {tank1.portsData[1].height};
  tank1.portsData_zeta_in_internal = {tank1.portsData[1].zeta_in};
  tank1.portsData_zeta_out_internal = {tank1.portsData[1].zeta_out};
  tank1.V = tank1.crossArea * tank1.level \"Volume of fluid\";
  tank1.medium.p = tank1.p_ambient;
  tank1.Wb_flow = 0.0 \"Mechanical work is neglected, since also neglected in medium model (otherwise unphysical small temperature change, if tank level changes)\";
  tank1.vessel_ps_static[1] = max(0.0, tank1.level - tank1.portsData_height[1]) * system.g * tank1.medium.d + tank1.p_ambient;
  tank1.mb_flow = tank1.ports[1].m_flow;
  tank1.Hb_flow = tank1.ports_H_flow[1] + tank1.ports_E_flow[1];
  tank1.Qb_flow = tank1.heatTransfer.Q_flows[1];
  assert(tank1.fluidLevel <= tank1.fluidLevel_max, \"Vessel is overflowing (fluidLevel > fluidLevel_max = \" + String(tank1.fluidLevel, 6, 0, true) + \")\");
  assert(tank1.fluidLevel > (-1e-6 * tank1.fluidLevel_max), \"Fluid level (= \" + String(tank1.fluidLevel, 6, 0, true) + \") is below zero meaning that the solution failed.\");
  tank1.portInDensities[1] = Modelica.Fluid.Examples.Tanks.ThreeTanks.tank1.Medium.density(Modelica.Fluid.Examples.Tanks.ThreeTanks.tank1.Medium.setState_phX(tank1.vessel_ps_static[1], pipe1.port_b.h_outflow, {}));
  tank1.portVelocities[1] = smooth(0, tank1.ports[1].m_flow / tank1.portAreas[1] / Modelica.Fluid.Examples.Tanks.ThreeTanks.tank1.Medium.density(Modelica.Fluid.Examples.Tanks.ThreeTanks.tank1.Medium.setState_phX(tank1.vessel_ps_static[1], if tank1.ports[1].m_flow > 0.0 then pipe1.port_b.h_outflow else tank1.ports[1].h_outflow, {})));
  tank1.ports_penetration[1] = Modelica.Fluid.Utilities.regStep(tank1.fluidLevel - tank1.portsData_height[1] - 0.1 * tank1.portsData_diameter[1], 1.0, 0.001, 0.1 * tank1.portsData_diameter[1]);
  tank1.m_flow_turbulent[1] = tank1.m_flow_small;
  tank1.regularFlow[1] = tank1.fluidLevel >= tank1.portsData_height[1];
  tank1.inFlow[1] = not tank1.regularFlow[1] and (tank1.s[1] > 0.0 or tank1.portsData_height[1] >= tank1.fluidLevel_max);
  if tank1.regularFlow[1] then
    tank1.ports[1].p = homotopy(tank1.vessel_ps_static[1] + 0.5 / tank1.portAreas[1] ^ 2.0 * Modelica.Fluid.Utilities.regSquare2(tank1.ports[1].m_flow, tank1.m_flow_turbulent[1], (tank1.portsData_zeta_in[1] - 1.0 + tank1.portAreas[1] ^ 2.0 / tank1.vesselArea ^ 2.0) / tank1.portInDensities[1] * tank1.ports_penetration[1], (tank1.portsData_zeta_out[1] + 1.0 - tank1.portAreas[1] ^ 2.0 / tank1.vesselArea ^ 2.0) / tank1.medium.d / tank1.ports_penetration[1], false, 1.0), tank1.vessel_ps_static[1]);
    tank1.s[1] = tank1.fluidLevel - tank1.portsData_height[1];
  elseif tank1.inFlow[1] then
    tank1.ports[1].p = tank1.vessel_ps_static[1];
    tank1.s[1] = tank1.ports[1].m_flow;
  else
    tank1.ports[1].m_flow = 0.0;
    tank1.s[1] = (tank1.ports[1].p - tank1.vessel_ps_static[1]) / 101325.0 * (tank1.portsData_height[1] - tank1.fluidLevel);
  end if;
  tank1.ports[1].h_outflow = tank1.medium.h;
  tank1.ports_H_flow[1] = smooth(0, tank1.ports[1].m_flow * (if tank1.ports[1].m_flow > 0.0 then pipe1.port_b.h_outflow else tank1.ports[1].h_outflow)) \"Enthalpy flow\";
  tank1.ports_E_flow[1] = tank1.ports[1].m_flow * (0.5 * tank1.portVelocities[1] * tank1.portVelocities[1] + system.g * tank1.portsData_height[1]) \"Flow of kinetic and potential energy\";
  tank1.m = tank1.fluidVolume * tank1.medium.d;
  tank1.U = tank1.m * tank1.medium.u;
  der(tank1.U) = tank1.Hb_flow + tank1.Qb_flow + tank1.Wb_flow;
  der(tank1.m) = tank1.mb_flow;
  assert(tank2.medium.T >= 272.15 and tank2.medium.T <= 403.15, \"
  Temperature T (= \" + String(tank2.medium.T, 6, 0, true) + \" K) is not
  in the allowed range (\" + String(272.15, 6, 0, true) + \" K <= T <= \" + String(403.15, 6, 0, true) + \" K)
  required from medium model \\\"\" + \"SimpleLiquidWater\" + \"\\\".
  \");
  tank2.medium.h = Modelica.Fluid.Examples.Tanks.ThreeTanks.tank2.Medium.specificEnthalpy_pTX(tank2.medium.p, tank2.medium.T, tank2.medium.X);
  tank2.medium.u = 4184.0 * (tank2.medium.T - 273.15);
  tank2.medium.d = 995.586;
  tank2.medium.R = 0.0;
  tank2.medium.MM = 0.018015268;
  tank2.medium.state.T = tank2.medium.T;
  tank2.medium.state.p = tank2.medium.p;
  tank2.medium.X[1] = 1.0;
  assert(tank2.medium.X[1] >= -1e-5 and tank2.medium.X[1] <= 1.00001, \"Mass fraction X[\" + String(1, 0, true) + \"] = \" + String(tank2.medium.X[1], 6, 0, true) + \"of substance \" + \"SimpleLiquidWater\" + \"
  of medium \" + \"SimpleLiquidWater\" + \" is not in the range 0..1\");
  assert(tank2.medium.p >= 0.0, \"Pressure (= \" + String(tank2.medium.p, 6, 0, true) + \" Pa) of medium \\\"\" + \"SimpleLiquidWater\" + \"\\\" is negative
  (Temperature = \" + String(tank2.medium.T, 6, 0, true) + \" K)\");
  tank2.heatTransfer.surfaceAreas = {tank2.crossArea + 2.0 * sqrt(tank2.crossArea * 3.141592653589793) * tank2.level};
  tank2.heatTransfer.Ts = {Modelica.Fluid.Examples.Tanks.ThreeTanks.tank2.heatTransfer.Medium.temperature(tank2.heatTransfer.states[1])};
  tank2.heatTransfer.Ts[1] = tank2.heatTransfer.heatPorts[1].T;
  tank2.heatTransfer.Q_flows[1] = tank2.heatTransfer.heatPorts[1].Q_flow;
  tank2.portAreas = {0.7853981633974483 * tank2.portsData_diameter[1] ^ 2.0};
  tank2.portsData_diameter_internal = {tank2.portsData[1].diameter};
  tank2.portsData_height_internal = {tank2.portsData[1].height};
  tank2.portsData_zeta_in_internal = {tank2.portsData[1].zeta_in};
  tank2.portsData_zeta_out_internal = {tank2.portsData[1].zeta_out};
  tank2.V = tank2.crossArea * tank2.level \"Volume of fluid\";
  tank2.medium.p = tank2.p_ambient;
  tank2.Wb_flow = 0.0 \"Mechanical work is neglected, since also neglected in medium model (otherwise unphysical small temperature change, if tank level changes)\";
  tank2.vessel_ps_static[1] = max(0.0, tank2.level - tank2.portsData_height[1]) * system.g * tank2.medium.d + tank2.p_ambient;
  tank2.mb_flow = tank2.ports[1].m_flow;
  tank2.Hb_flow = tank2.ports_H_flow[1] + tank2.ports_E_flow[1];
  tank2.Qb_flow = tank2.heatTransfer.Q_flows[1];
  assert(tank2.fluidLevel <= tank2.fluidLevel_max, \"Vessel is overflowing (fluidLevel > fluidLevel_max = \" + String(tank2.fluidLevel, 6, 0, true) + \")\");
  assert(tank2.fluidLevel > (-1e-6 * tank2.fluidLevel_max), \"Fluid level (= \" + String(tank2.fluidLevel, 6, 0, true) + \") is below zero meaning that the solution failed.\");
  tank2.portInDensities[1] = Modelica.Fluid.Examples.Tanks.ThreeTanks.tank2.Medium.density(Modelica.Fluid.Examples.Tanks.ThreeTanks.tank2.Medium.setState_phX(tank2.vessel_ps_static[1], pipe2.port_b.h_outflow, {}));
  tank2.portVelocities[1] = smooth(0, tank2.ports[1].m_flow / tank2.portAreas[1] / Modelica.Fluid.Examples.Tanks.ThreeTanks.tank2.Medium.density(Modelica.Fluid.Examples.Tanks.ThreeTanks.tank2.Medium.setState_phX(tank2.vessel_ps_static[1], if tank2.ports[1].m_flow > 0.0 then pipe2.port_b.h_outflow else tank2.ports[1].h_outflow, {})));
  tank2.ports_penetration[1] = Modelica.Fluid.Utilities.regStep(tank2.fluidLevel - tank2.portsData_height[1] - 0.1 * tank2.portsData_diameter[1], 1.0, 0.001, 0.1 * tank2.portsData_diameter[1]);
  tank2.m_flow_turbulent[1] = tank2.m_flow_small;
  tank2.regularFlow[1] = tank2.fluidLevel >= tank2.portsData_height[1];
  tank2.inFlow[1] = not tank2.regularFlow[1] and (tank2.s[1] > 0.0 or tank2.portsData_height[1] >= tank2.fluidLevel_max);
  if tank2.regularFlow[1] then
    tank2.ports[1].p = homotopy(tank2.vessel_ps_static[1] + 0.5 / tank2.portAreas[1] ^ 2.0 * Modelica.Fluid.Utilities.regSquare2(tank2.ports[1].m_flow, tank2.m_flow_turbulent[1], (tank2.portsData_zeta_in[1] - 1.0 + tank2.portAreas[1] ^ 2.0 / tank2.vesselArea ^ 2.0) / tank2.portInDensities[1] * tank2.ports_penetration[1], (tank2.portsData_zeta_out[1] + 1.0 - tank2.portAreas[1] ^ 2.0 / tank2.vesselArea ^ 2.0) / tank2.medium.d / tank2.ports_penetration[1], false, 1.0), tank2.vessel_ps_static[1]);
    tank2.s[1] = tank2.fluidLevel - tank2.portsData_height[1];
  elseif tank2.inFlow[1] then
    tank2.ports[1].p = tank2.vessel_ps_static[1];
    tank2.s[1] = tank2.ports[1].m_flow;
  else
    tank2.ports[1].m_flow = 0.0;
    tank2.s[1] = (tank2.ports[1].p - tank2.vessel_ps_static[1]) / 101325.0 * (tank2.portsData_height[1] - tank2.fluidLevel);
  end if;
  tank2.ports[1].h_outflow = tank2.medium.h;
  tank2.ports_H_flow[1] = smooth(0, tank2.ports[1].m_flow * (if tank2.ports[1].m_flow > 0.0 then pipe2.port_b.h_outflow else tank2.ports[1].h_outflow)) \"Enthalpy flow\";
  tank2.ports_E_flow[1] = tank2.ports[1].m_flow * (0.5 * tank2.portVelocities[1] * tank2.portVelocities[1] + system.g * tank2.portsData_height[1]) \"Flow of kinetic and potential energy\";
  tank2.m = tank2.fluidVolume * tank2.medium.d;
  tank2.U = tank2.m * tank2.medium.u;
  der(tank2.U) = tank2.Hb_flow + tank2.Qb_flow + tank2.Wb_flow;
  der(tank2.m) = tank2.mb_flow;
  assert(tank3.medium.T >= 272.15 and tank3.medium.T <= 403.15, \"
  Temperature T (= \" + String(tank3.medium.T, 6, 0, true) + \" K) is not
  in the allowed range (\" + String(272.15, 6, 0, true) + \" K <= T <= \" + String(403.15, 6, 0, true) + \" K)
  required from medium model \\\"\" + \"SimpleLiquidWater\" + \"\\\".
  \");
  tank3.medium.h = Modelica.Fluid.Examples.Tanks.ThreeTanks.tank3.Medium.specificEnthalpy_pTX(tank3.medium.p, tank3.medium.T, tank3.medium.X);
  tank3.medium.u = 4184.0 * (tank3.medium.T - 273.15);
  tank3.medium.d = 995.586;
  tank3.medium.R = 0.0;
  tank3.medium.MM = 0.018015268;
  tank3.medium.state.T = tank3.medium.T;
  tank3.medium.state.p = tank3.medium.p;
  tank3.medium.X[1] = 1.0;
  assert(tank3.medium.X[1] >= -1e-5 and tank3.medium.X[1] <= 1.00001, \"Mass fraction X[\" + String(1, 0, true) + \"] = \" + String(tank3.medium.X[1], 6, 0, true) + \"of substance \" + \"SimpleLiquidWater\" + \"
  of medium \" + \"SimpleLiquidWater\" + \" is not in the range 0..1\");
  assert(tank3.medium.p >= 0.0, \"Pressure (= \" + String(tank3.medium.p, 6, 0, true) + \" Pa) of medium \\\"\" + \"SimpleLiquidWater\" + \"\\\" is negative
  (Temperature = \" + String(tank3.medium.T, 6, 0, true) + \" K)\");
  tank3.heatTransfer.surfaceAreas = {tank3.crossArea + 2.0 * sqrt(tank3.crossArea * 3.141592653589793) * tank3.level};
  tank3.heatTransfer.Ts = {Modelica.Fluid.Examples.Tanks.ThreeTanks.tank3.heatTransfer.Medium.temperature(tank3.heatTransfer.states[1])};
  tank3.heatTransfer.Ts[1] = tank3.heatTransfer.heatPorts[1].T;
  tank3.heatTransfer.Q_flows[1] = tank3.heatTransfer.heatPorts[1].Q_flow;
  tank3.portAreas = {0.7853981633974483 * tank3.portsData_diameter[1] ^ 2.0};
  tank3.portsData_diameter_internal = {tank3.portsData[1].diameter};
  tank3.portsData_height_internal = {tank3.portsData[1].height};
  tank3.portsData_zeta_in_internal = {tank3.portsData[1].zeta_in};
  tank3.portsData_zeta_out_internal = {tank3.portsData[1].zeta_out};
  tank3.V = tank3.crossArea * tank3.level \"Volume of fluid\";
  tank3.medium.p = tank3.p_ambient;
  tank3.Wb_flow = 0.0 \"Mechanical work is neglected, since also neglected in medium model (otherwise unphysical small temperature change, if tank level changes)\";
  tank3.vessel_ps_static[1] = max(0.0, tank3.level - tank3.portsData_height[1]) * system.g * tank3.medium.d + tank3.p_ambient;
  tank3.mb_flow = tank3.ports[1].m_flow;
  tank3.Hb_flow = tank3.ports_H_flow[1] + tank3.ports_E_flow[1];
  tank3.Qb_flow = tank3.heatTransfer.Q_flows[1];
  assert(tank3.fluidLevel <= tank3.fluidLevel_max, \"Vessel is overflowing (fluidLevel > fluidLevel_max = \" + String(tank3.fluidLevel, 6, 0, true) + \")\");
  assert(tank3.fluidLevel > (-1e-6 * tank3.fluidLevel_max), \"Fluid level (= \" + String(tank3.fluidLevel, 6, 0, true) + \") is below zero meaning that the solution failed.\");
  tank3.portInDensities[1] = Modelica.Fluid.Examples.Tanks.ThreeTanks.tank3.Medium.density(Modelica.Fluid.Examples.Tanks.ThreeTanks.tank3.Medium.setState_phX(tank3.vessel_ps_static[1], pipe3.port_b.h_outflow, {}));
  tank3.portVelocities[1] = smooth(0, tank3.ports[1].m_flow / tank3.portAreas[1] / Modelica.Fluid.Examples.Tanks.ThreeTanks.tank3.Medium.density(Modelica.Fluid.Examples.Tanks.ThreeTanks.tank3.Medium.setState_phX(tank3.vessel_ps_static[1], if tank3.ports[1].m_flow > 0.0 then pipe3.port_b.h_outflow else tank3.ports[1].h_outflow, {})));
  tank3.ports_penetration[1] = Modelica.Fluid.Utilities.regStep(tank3.fluidLevel - tank3.portsData_height[1] - 0.1 * tank3.portsData_diameter[1], 1.0, 0.001, 0.1 * tank3.portsData_diameter[1]);
  tank3.m_flow_turbulent[1] = tank3.m_flow_small;
  tank3.regularFlow[1] = tank3.fluidLevel >= tank3.portsData_height[1];
  tank3.inFlow[1] = not tank3.regularFlow[1] and (tank3.s[1] > 0.0 or tank3.portsData_height[1] >= tank3.fluidLevel_max);
  if tank3.regularFlow[1] then
    tank3.ports[1].p = homotopy(tank3.vessel_ps_static[1] + 0.5 / tank3.portAreas[1] ^ 2.0 * Modelica.Fluid.Utilities.regSquare2(tank3.ports[1].m_flow, tank3.m_flow_turbulent[1], (tank3.portsData_zeta_in[1] - 1.0 + tank3.portAreas[1] ^ 2.0 / tank3.vesselArea ^ 2.0) / tank3.portInDensities[1] * tank3.ports_penetration[1], (tank3.portsData_zeta_out[1] + 1.0 - tank3.portAreas[1] ^ 2.0 / tank3.vesselArea ^ 2.0) / tank3.medium.d / tank3.ports_penetration[1], false, 1.0), tank3.vessel_ps_static[1]);
    tank3.s[1] = tank3.fluidLevel - tank3.portsData_height[1];
  elseif tank3.inFlow[1] then
    tank3.ports[1].p = tank3.vessel_ps_static[1];
    tank3.s[1] = tank3.ports[1].m_flow;
  else
    tank3.ports[1].m_flow = 0.0;
    tank3.s[1] = (tank3.ports[1].p - tank3.vessel_ps_static[1]) / 101325.0 * (tank3.portsData_height[1] - tank3.fluidLevel);
  end if;
  tank3.ports[1].h_outflow = tank3.medium.h;
  tank3.ports_H_flow[1] = smooth(0, tank3.ports[1].m_flow * (if tank3.ports[1].m_flow > 0.0 then pipe3.port_b.h_outflow else tank3.ports[1].h_outflow)) \"Enthalpy flow\";
  tank3.ports_E_flow[1] = tank3.ports[1].m_flow * (0.5 * tank3.portVelocities[1] * tank3.portVelocities[1] + system.g * tank3.portsData_height[1]) \"Flow of kinetic and potential energy\";
  tank3.m = tank3.fluidVolume * tank3.medium.d;
  tank3.U = tank3.m * tank3.medium.u;
  der(tank3.U) = tank3.Hb_flow + tank3.Qb_flow + tank3.Wb_flow;
  der(tank3.m) = tank3.mb_flow;
  pipe1.flowModel.states[1] = Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.Medium.setState_phX(pipe1.port_a.p, ($OMC$PositiveMax(-pipe3.port_a.m_flow, 1e-7) * pipe3.port_a.h_outflow + $OMC$PositiveMax(-pipe2.port_a.m_flow, 1e-7) * pipe2.port_a.h_outflow) / ($OMC$PositiveMax(-pipe3.port_a.m_flow, 1e-7) + $OMC$PositiveMax(-pipe2.port_a.m_flow, 1e-7)), {});
  pipe1.flowModel.states[2] = Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.Medium.setState_phX(pipe1.port_b.p, tank1.ports[1].h_outflow, {});
  pipe1.flowModel.vs = {pipe1.port_a.m_flow / Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.Medium.density(pipe1.flowModel.states[1]) / pipe1.flowModel.crossAreas[1] / pipe1.nParallel, pipe1.port_b.m_flow / Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.Medium.density(pipe1.flowModel.states[2]) / pipe1.flowModel.crossAreas[2] / (-pipe1.nParallel)};
  pipe1.flowModel.crossAreas = {pipe1.crossArea, pipe1.crossArea};
  pipe1.flowModel.dimensions = {4.0 * pipe1.crossArea / pipe1.perimeter, 4.0 * pipe1.crossArea / pipe1.perimeter};
  pipe1.flowModel.roughnesses = {pipe1.roughness, pipe1.roughness};
  pipe1.flowModel.dheights = {pipe1.height_ab};
  pipe1.flowModel.pathLengths = {pipe1.length};
  pipe1.flowModel.rhos = array(Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.Medium.density(pipe1.flowModel.states[$i1]) for $i1 in 1:2);
  pipe1.flowModel.mus = array(Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.Medium.dynamicViscosity(pipe1.flowModel.states[$i1]) for $i1 in 1:2);
  pipe1.flowModel.pathLengths_internal = pipe1.flowModel.pathLengths;
  pipe1.flowModel.Res_turbulent_internal = {pipe1.flowModel.Re_turbulent};
  pipe1.flowModel.diameters = {0.5 * (pipe1.flowModel.dimensions[1] + pipe1.flowModel.dimensions[2])};
  pipe1.flowModel.m_flows[1] = homotopy(Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.WallFriction.massFlowRate_dp_staticHead(pipe1.flowModel.dps_fg[1], pipe1.flowModel.rhos[1], pipe1.flowModel.rhos[2], pipe1.flowModel.mus[1], pipe1.flowModel.mus[2], pipe1.flowModel.pathLengths_internal[1], pipe1.flowModel.diameters[1], pipe1.flowModel.g * pipe1.flowModel.dheights[1], (pipe1.flowModel.crossAreas[1] + pipe1.flowModel.crossAreas[2]) / 2.0, (pipe1.flowModel.roughnesses[1] + pipe1.flowModel.roughnesses[2]) / 2.0, pipe1.flowModel.dp_small, pipe1.flowModel.Res_turbulent_internal[1]) * pipe1.flowModel.nParallel, pipe1.flowModel.m_flow_nominal / pipe1.flowModel.dp_nominal * (pipe1.flowModel.dps_fg[1] - pipe1.flowModel.g * pipe1.flowModel.dheights[1] * pipe1.flowModel.rho_nominal));
  pipe1.flowModel.rhos_act[1] = noEvent(if pipe1.flowModel.m_flows[1] > 0.0 then pipe1.flowModel.rhos[1] else pipe1.flowModel.rhos[2]);
  pipe1.flowModel.mus_act[1] = noEvent(if pipe1.flowModel.m_flows[1] > 0.0 then pipe1.flowModel.mus[1] else pipe1.flowModel.mus[2]);
  pipe1.flowModel.Ib_flows[1] = 0.0;
  pipe1.flowModel.Fs_p[1] = pipe1.flowModel.nParallel * 0.5 * (pipe1.flowModel.crossAreas[1] + pipe1.flowModel.crossAreas[2]) * (Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.Medium.pressure(pipe1.flowModel.states[2]) - Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.flowModel.Medium.pressure(pipe1.flowModel.states[1]));
  pipe1.flowModel.dps_fg[1] = pipe1.flowModel.Fs_fg[1] / pipe1.flowModel.nParallel * 2.0 / (pipe1.flowModel.crossAreas[1] + pipe1.flowModel.crossAreas[2]);
  pipe1.flowModel.Is[1] = pipe1.flowModel.m_flows[1] * pipe1.flowModel.pathLengths[1];
  0.0 = pipe1.flowModel.Ib_flows[1] - pipe1.flowModel.Fs_p[1] - pipe1.flowModel.Fs_fg[1];
  pipe1.port_a.m_flow = pipe1.flowModel.m_flows[1];
  0.0 = pipe1.port_a.m_flow + pipe1.port_b.m_flow;
  pipe1.port_b.h_outflow = ($OMC$PositiveMax(-pipe3.port_a.m_flow, 1e-7) * pipe3.port_a.h_outflow + $OMC$PositiveMax(-pipe2.port_a.m_flow, 1e-7) * pipe2.port_a.h_outflow) / ($OMC$PositiveMax(-pipe3.port_a.m_flow, 1e-7) + $OMC$PositiveMax(-pipe2.port_a.m_flow, 1e-7)) - system.g * pipe1.height_ab;
  pipe1.port_a.h_outflow = tank1.ports[1].h_outflow + system.g * pipe1.height_ab;
  assert(pipe1.length >= pipe1.height_ab, \"Parameter length must be greater or equal height_ab.\");
  pipe2.flowModel.states[1] = Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.Medium.setState_phX(pipe2.port_a.p, ($OMC$PositiveMax(-pipe1.port_a.m_flow, 1e-7) * pipe1.port_a.h_outflow + $OMC$PositiveMax(-pipe3.port_a.m_flow, 1e-7) * pipe3.port_a.h_outflow) / ($OMC$PositiveMax(-pipe1.port_a.m_flow, 1e-7) + $OMC$PositiveMax(-pipe3.port_a.m_flow, 1e-7)), {});
  pipe2.flowModel.states[2] = Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.Medium.setState_phX(pipe2.port_b.p, tank2.ports[1].h_outflow, {});
  pipe2.flowModel.vs = {pipe2.port_a.m_flow / Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.Medium.density(pipe2.flowModel.states[1]) / pipe2.flowModel.crossAreas[1] / pipe2.nParallel, pipe2.port_b.m_flow / Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.Medium.density(pipe2.flowModel.states[2]) / pipe2.flowModel.crossAreas[2] / (-pipe2.nParallel)};
  pipe2.flowModel.crossAreas = {pipe2.crossArea, pipe2.crossArea};
  pipe2.flowModel.dimensions = {4.0 * pipe2.crossArea / pipe2.perimeter, 4.0 * pipe2.crossArea / pipe2.perimeter};
  pipe2.flowModel.roughnesses = {pipe2.roughness, pipe2.roughness};
  pipe2.flowModel.dheights = {pipe2.height_ab};
  pipe2.flowModel.pathLengths = {pipe2.length};
  pipe2.flowModel.rhos = array(Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.Medium.density(pipe2.flowModel.states[$i1]) for $i1 in 1:2);
  pipe2.flowModel.mus = array(Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.Medium.dynamicViscosity(pipe2.flowModel.states[$i1]) for $i1 in 1:2);
  pipe2.flowModel.pathLengths_internal = pipe2.flowModel.pathLengths;
  pipe2.flowModel.Res_turbulent_internal = {pipe2.flowModel.Re_turbulent};
  pipe2.flowModel.diameters = {0.5 * (pipe2.flowModel.dimensions[1] + pipe2.flowModel.dimensions[2])};
  pipe2.flowModel.m_flows[1] = homotopy(Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.WallFriction.massFlowRate_dp_staticHead(pipe2.flowModel.dps_fg[1], pipe2.flowModel.rhos[1], pipe2.flowModel.rhos[2], pipe2.flowModel.mus[1], pipe2.flowModel.mus[2], pipe2.flowModel.pathLengths_internal[1], pipe2.flowModel.diameters[1], pipe2.flowModel.g * pipe2.flowModel.dheights[1], (pipe2.flowModel.crossAreas[1] + pipe2.flowModel.crossAreas[2]) / 2.0, (pipe2.flowModel.roughnesses[1] + pipe2.flowModel.roughnesses[2]) / 2.0, pipe2.flowModel.dp_small, pipe2.flowModel.Res_turbulent_internal[1]) * pipe2.flowModel.nParallel, pipe2.flowModel.m_flow_nominal / pipe2.flowModel.dp_nominal * (pipe2.flowModel.dps_fg[1] - pipe2.flowModel.g * pipe2.flowModel.dheights[1] * pipe2.flowModel.rho_nominal));
  pipe2.flowModel.rhos_act[1] = noEvent(if pipe2.flowModel.m_flows[1] > 0.0 then pipe2.flowModel.rhos[1] else pipe2.flowModel.rhos[2]);
  pipe2.flowModel.mus_act[1] = noEvent(if pipe2.flowModel.m_flows[1] > 0.0 then pipe2.flowModel.mus[1] else pipe2.flowModel.mus[2]);
  pipe2.flowModel.Ib_flows[1] = 0.0;
  pipe2.flowModel.Fs_p[1] = pipe2.flowModel.nParallel * 0.5 * (pipe2.flowModel.crossAreas[1] + pipe2.flowModel.crossAreas[2]) * (Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.Medium.pressure(pipe2.flowModel.states[2]) - Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe2.flowModel.Medium.pressure(pipe2.flowModel.states[1]));
  pipe2.flowModel.dps_fg[1] = pipe2.flowModel.Fs_fg[1] / pipe2.flowModel.nParallel * 2.0 / (pipe2.flowModel.crossAreas[1] + pipe2.flowModel.crossAreas[2]);
  pipe2.flowModel.Is[1] = pipe2.flowModel.m_flows[1] * pipe2.flowModel.pathLengths[1];
  0.0 = pipe2.flowModel.Ib_flows[1] - pipe2.flowModel.Fs_p[1] - pipe2.flowModel.Fs_fg[1];
  pipe2.port_a.m_flow = pipe2.flowModel.m_flows[1];
  0.0 = pipe2.port_a.m_flow + pipe2.port_b.m_flow;
  pipe2.port_b.h_outflow = ($OMC$PositiveMax(-pipe1.port_a.m_flow, 1e-7) * pipe1.port_a.h_outflow + $OMC$PositiveMax(-pipe3.port_a.m_flow, 1e-7) * pipe3.port_a.h_outflow) / ($OMC$PositiveMax(-pipe1.port_a.m_flow, 1e-7) + $OMC$PositiveMax(-pipe3.port_a.m_flow, 1e-7)) - system.g * pipe2.height_ab;
  pipe2.port_a.h_outflow = tank2.ports[1].h_outflow + system.g * pipe2.height_ab;
  assert(pipe2.length >= pipe2.height_ab, \"Parameter length must be greater or equal height_ab.\");
  pipe3.flowModel.states[1] = Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.Medium.setState_phX(pipe3.port_a.p, ($OMC$PositiveMax(-pipe1.port_a.m_flow, 1e-7) * pipe1.port_a.h_outflow + $OMC$PositiveMax(-pipe2.port_a.m_flow, 1e-7) * pipe2.port_a.h_outflow) / ($OMC$PositiveMax(-pipe1.port_a.m_flow, 1e-7) + $OMC$PositiveMax(-pipe2.port_a.m_flow, 1e-7)), {});
  pipe3.flowModel.states[2] = Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.Medium.setState_phX(pipe3.port_b.p, tank3.ports[1].h_outflow, {});
  pipe3.flowModel.vs = {pipe3.port_a.m_flow / Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.Medium.density(pipe3.flowModel.states[1]) / pipe3.flowModel.crossAreas[1] / pipe3.nParallel, pipe3.port_b.m_flow / Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.Medium.density(pipe3.flowModel.states[2]) / pipe3.flowModel.crossAreas[2] / (-pipe3.nParallel)};
  pipe3.flowModel.crossAreas = {pipe3.crossArea, pipe3.crossArea};
  pipe3.flowModel.dimensions = {4.0 * pipe3.crossArea / pipe3.perimeter, 4.0 * pipe3.crossArea / pipe3.perimeter};
  pipe3.flowModel.roughnesses = {pipe3.roughness, pipe3.roughness};
  pipe3.flowModel.dheights = {pipe3.height_ab};
  pipe3.flowModel.pathLengths = {pipe3.length};
  pipe3.flowModel.rhos = array(Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.flowModel.Medium.density(pipe3.flowModel.states[$i1]) for $i1 in 1:2);
  pipe3.flowModel.mus = array(Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.flowModel.Medium.dynamicViscosity(pipe3.flowModel.states[$i1]) for $i1 in 1:2);
  pipe3.flowModel.pathLengths_internal = pipe3.flowModel.pathLengths;
  pipe3.flowModel.Res_turbulent_internal = {pipe3.flowModel.Re_turbulent};
  pipe3.flowModel.diameters = {0.5 * (pipe3.flowModel.dimensions[1] + pipe3.flowModel.dimensions[2])};
  pipe3.flowModel.m_flows[1] = homotopy(Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.flowModel.WallFriction.massFlowRate_dp_staticHead(pipe3.flowModel.dps_fg[1], pipe3.flowModel.rhos[1], pipe3.flowModel.rhos[2], pipe3.flowModel.mus[1], pipe3.flowModel.mus[2], pipe3.flowModel.pathLengths_internal[1], pipe3.flowModel.diameters[1], pipe3.flowModel.g * pipe3.flowModel.dheights[1], (pipe3.flowModel.crossAreas[1] + pipe3.flowModel.crossAreas[2]) / 2.0, (pipe3.flowModel.roughnesses[1] + pipe3.flowModel.roughnesses[2]) / 2.0, pipe3.flowModel.dp_small, pipe3.flowModel.Res_turbulent_internal[1]) * pipe3.flowModel.nParallel, pipe3.flowModel.m_flow_nominal / pipe3.flowModel.dp_nominal * (pipe3.flowModel.dps_fg[1] - pipe3.flowModel.g * pipe3.flowModel.dheights[1] * pipe3.flowModel.rho_nominal));
  pipe3.flowModel.rhos_act[1] = noEvent(if pipe3.flowModel.m_flows[1] > 0.0 then pipe3.flowModel.rhos[1] else pipe3.flowModel.rhos[2]);
  pipe3.flowModel.mus_act[1] = noEvent(if pipe3.flowModel.m_flows[1] > 0.0 then pipe3.flowModel.mus[1] else pipe3.flowModel.mus[2]);
  pipe3.flowModel.Ib_flows[1] = 0.0;
  pipe3.flowModel.Fs_p[1] = pipe3.flowModel.nParallel * 0.5 * (pipe3.flowModel.crossAreas[1] + pipe3.flowModel.crossAreas[2]) * (Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.flowModel.Medium.pressure(pipe3.flowModel.states[2]) - Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe3.flowModel.Medium.pressure(pipe3.flowModel.states[1]));
  pipe3.flowModel.dps_fg[1] = pipe3.flowModel.Fs_fg[1] / pipe3.flowModel.nParallel * 2.0 / (pipe3.flowModel.crossAreas[1] + pipe3.flowModel.crossAreas[2]);
  pipe3.flowModel.Is[1] = pipe3.flowModel.m_flows[1] * pipe3.flowModel.pathLengths[1];
  0.0 = pipe3.flowModel.Ib_flows[1] - pipe3.flowModel.Fs_p[1] - pipe3.flowModel.Fs_fg[1];
  pipe3.port_a.m_flow = pipe3.flowModel.m_flows[1];
  0.0 = pipe3.port_a.m_flow + pipe3.port_b.m_flow;
  pipe3.port_b.h_outflow = ($OMC$PositiveMax(-pipe1.port_a.m_flow, 1e-7) * pipe1.port_a.h_outflow + $OMC$PositiveMax(-pipe2.port_a.m_flow, 1e-7) * pipe2.port_a.h_outflow) / ($OMC$PositiveMax(-pipe1.port_a.m_flow, 1e-7) + $OMC$PositiveMax(-pipe2.port_a.m_flow, 1e-7)) - system.g * pipe3.height_ab;
  pipe3.port_a.h_outflow = tank3.ports[1].h_outflow + system.g * pipe3.height_ab;
  assert(pipe3.length >= pipe3.height_ab, \"Parameter length must be greater or equal height_ab.\");
end Modelica.Fluid.Examples.Tanks.ThreeTanks;
"
""

Equation mismatch: diff says:
--- /tmp/omc-rtest-omtmpuser/openmodelica/interactive-API/Bug2871.mos_temp1703/equations-expected2024-06-14 13:51:58.262589728 +0000
+++ /tmp/omc-rtest-omtmpuser/openmodelica/interactive-API/Bug2871.mos_temp1703/equations-got2024-06-14 13:52:01.846589825 +0000
@@ -61,10 +61,49 @@
 {}
 true
 (0.0,200.0,1e-4,500,0.4)
 true
 ""
+is no flow -1e5: false
+is no flow -1e5: false
+is no flow -1e5: false
+is no flow -1e5: false
+is no flow -1e5: false
+is no flow -1e5: false
+is no flow -1e60: false
+is no flow -1e60: false
+is no flow -1e60: false
+is no flow -1e5: false
+is no flow -1e5: false
+is no flow -1e5: false
+is no flow -1e5: false
+is no flow -1e5: false
+is no flow -1e5: false
+is no flow -1e5: false
+is no flow -1e5: false
+is no flow -1e5: false
+is no flow -1e5: false
+is no flow -1e5: false
+is no flow -1e5: false
+is no flow -1e60: false
+is no flow -1e60: false
+is no flow -1e5: false
+is no flow -1e60: false
+is no flow -1e60: false
+is no flow -1e5: false
+is no flow -1e60: false
+is no flow -1e60: false
+is no flow -1e5: false
+is no flow -1e60: false
+is no flow -1e60: false
+is no flow -1e5: false
+is no flow -1e60: false
+is no flow -1e60: false
+is no flow -1e5: false
+is no flow -1e60: false
+is no flow -1e60: false
+is no flow -1e5: false
 "function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.Medium.ThermodynamicState \"Automatically generated record constructor for Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.Medium.ThermodynamicState\"
 input Real p;
 input Real T;
 output ThermodynamicState res;
 end Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe1.Medium.ThermodynamicState;

Equation mismatch: omc-diff says:
Failed '"' 'i'
Line 66: Text differs:
expected: "function Modelica.Fluid.Examples.Tanks.ThreeTanks.pipe
got:      is no flow 

== 1 out of 1 tests failed [openmodelica/interactive-API/Bug2871.mos_temp1703, time: 3]