Failed
tests / testsuite-clang / openmodelica_interactive-API.saveTotalModel.mos (from (result.xml))
Failing for the past 2 builds
(Since Failed )
Stacktrace
Output mismatch (see stdout for details)
Standard Output
+ SCodeDependency test [BUG: https://trac.openmodelica.org/OpenModelica/ticket/1952]... equation mismatch [time: 0] ==== Log /tmp/omc-rtest-unknown/openmodelica/interactive-API/saveTotalModel.mos_temp8694/log-saveTotalModel.mos false "Error: Failed to load package Modelica (3.2.1) using MODELICAPATH /var/lib/jenkins/workspace/OpenModelica_maintenance_v1.13/build/lib/omlibrary. " false "Error: Failed to load package Modelica (default) using MODELICAPATH /var/lib/jenkins/workspace/OpenModelica_maintenance_v1.13/build/lib/omlibrary. Error: Class Modelica.Fluid.Examples.BranchingDynamicPipes not found in scope . " "" Equation mismatch: diff says: --- /tmp/omc-rtest-unknown/openmodelica/interactive-API/saveTotalModel.mos_temp8694/equations-expected2018-12-16 19:51:36.818484551 +0000 +++ /tmp/omc-rtest-unknown/openmodelica/interactive-API/saveTotalModel.mos_temp8694/equations-got2018-12-16 19:51:36.974482999 +0000 @@ -1,3604 +1,8 @@ -true -"" -true -"" -"package ModelicaServices \"ModelicaServices (OpenModelica implementation) - Models and functions used in the Modelica Standard Library requiring a tool specific implementation\" -extends Modelica.Icons.Package; - -package Machine -extends Modelica.Icons.Package; -final constant Real eps = 1.e-15 \"Biggest number such that 1.0 + eps = 1.0\"; -final constant Real small = 1.e-60 \"Smallest number such that small and -small are representable on the machine\"; -final constant Real inf = 1.e+60 \"Biggest Real number such that inf and -inf are representable on the machine\"; -final constant Integer Integer_inf = OpenModelica.Internal.Architecture.integerMax() \"Biggest Integer number such that Integer_inf and -Integer_inf are representable on the machine\"; -end Machine; -annotation(Protection(access = Access.hide), version = \"3.2.1\", versionBuild = 2, versionDate = \"2013-08-14\", dateModified = \"2013-08-14 08:44:41Z\"); -end ModelicaServices; - -package Modelica \"Modelica Standard Library - Version 3.2.1 (Build 4)\" -extends Modelica.Icons.Package; - -package Blocks \"Library of basic input/output control blocks (continuous, discrete, logical, table blocks)\" -extends Modelica.Icons.Package; - -package Interfaces \"Library of connectors and partial models for input/output blocks\" -extends Modelica.Icons.InterfacesPackage; -connector RealInput = input Real \"'input Real' as connector\"; -connector RealOutput = output Real \"'output Real' as connector\"; - -partial block SO \"Single Output continuous control block\" -extends Modelica.Blocks.Icons.Block; -RealOutput y \"Connector of Real output signal\"; -end SO; -end Interfaces; - -package Sources \"Library of signal source blocks generating Real and Boolean signals\" -extends Modelica.Icons.SourcesPackage; - -block Ramp \"Generate ramp signal\" -parameter Real height = 1 \"Height of ramps\"; -parameter Modelica.SIunits.Time duration(min = 0.0, start = 2) \"Duration of ramp (= 0.0 gives a Step)\"; -parameter Real offset = 0 \"Offset of output signal\"; -parameter Modelica.SIunits.Time startTime = 0 \"Output = offset for time < startTime\"; -extends .Modelica.Blocks.Interfaces.SO; -equation -y = offset + (if time < startTime then 0 else if time < startTime + duration then (time - startTime) * height / duration else height); -end Ramp; -end Sources; - -package Icons \"Icons for Blocks\" -extends Modelica.Icons.IconsPackage; - -partial block Block \"Basic graphical layout of input/output block\" end Block; -end Icons; -end Blocks; - -package Fluid \"Library of 1-dim. thermo-fluid flow models using the Modelica.Media media description\" -extends Modelica.Icons.Package; - -package Examples \"Demonstration of the usage of the library\" -extends Modelica.Icons.ExamplesPackage; - -model BranchingDynamicPipes \"Multi-way connections of pipes with dynamic momentum balance, pressure wave and flow reversal\" -extends Modelica.Icons.Example; -replaceable package Medium = Modelica.Media.Air.MoistAir constrainedby Modelica.Media.Interfaces.PartialMedium; -inner Modelica.Fluid.System system(energyDynamics = Modelica.Fluid.Types.Dynamics.SteadyStateInitial, momentumDynamics = Modelica.Fluid.Types.Dynamics.SteadyStateInitial); -Modelica.Fluid.Sources.Boundary_pT boundary1(nPorts = 1, redeclare package Medium = Medium, p = 150000); -Pipes.DynamicPipe pipe1(redeclare package Medium = Medium, use_T_start = true, nNodes = 5, diameter = 2.54e-2, m_flow_start = 0.02, height_ab = 50, length = 50, p_a_start = 150000, p_b_start = 130000, modelStructure = Modelica.Fluid.Types.ModelStructure.a_v_b); -Pipes.DynamicPipe pipe2(redeclare package Medium = Medium, use_T_start = true, nNodes = 5, redeclare model HeatTransfer = Modelica.Fluid.Pipes.BaseClasses.HeatTransfer.LocalPipeFlowHeatTransfer, use_HeatTransfer = true, diameter = 2.54e-2, m_flow_start = 0.01, length = 50, height_ab = 25, p_a_start = 130000, p_b_start = 120000, modelStructure = Modelica.Fluid.Types.ModelStructure.av_vb); -Pipes.DynamicPipe pipe3(redeclare package Medium = Medium, use_T_start = true, nNodes = 5, diameter = 2.54e-2, m_flow_start = 0.01, length = 25, height_ab = 25, p_a_start = 130000, p_b_start = 120000, modelStructure = Modelica.Fluid.Types.ModelStructure.a_v_b); -Pipes.DynamicPipe pipe4(redeclare package Medium = Medium, use_T_start = true, nNodes = 5, diameter = 2.54e-2, m_flow_start = 0.02, height_ab = 50, length = 50, p_a_start = 120000, p_b_start = 100000, modelStructure = Modelica.Fluid.Types.ModelStructure.a_v_b); -Modelica.Fluid.Sources.Boundary_pT boundary4(nPorts = 1, redeclare package Medium = Medium, use_p_in = true, use_T_in = false, p = 100000); -Modelica.Blocks.Sources.Ramp ramp1(offset = 1e5, startTime = 2, height = 1e5, duration = 0); -Modelica.Thermal.HeatTransfer.Sources.FixedHeatFlow[pipe2.nNodes] heat2(Q_flow = 200 * pipe2.dxs, alpha = -1e-2 * ones(pipe2.n)); -equation -connect(ramp1.y, boundary4.p_in); -connect(boundary1.ports[1], pipe1.port_a); -connect(pipe1.port_b, pipe2.port_a); -connect(pipe1.port_b, pipe3.port_a); -connect(pipe2.port_b, pipe4.port_a); -connect(pipe3.port_b, pipe4.port_a); -connect(pipe4.port_b, boundary4.ports[1]); -connect(heat2.port, pipe2.heatPorts); -annotation(experiment(StopTime = 10), __Dymola_Commands(file(ensureSimulated = true) = \"modelica://Modelica/Resources/Scripts/Dymola/Fluid/BranchingDynamicPipes/plotResults.mos\")); -end BranchingDynamicPipes; -end Examples; - -model System \"System properties and default values (ambient, flow direction, initialization)\" -parameter Modelica.SIunits.AbsolutePressure p_ambient = 101325 \"Default ambient pressure\"; -parameter Modelica.SIunits.Temperature T_ambient = 293.15 \"Default ambient temperature\"; -parameter Modelica.SIunits.Acceleration g = Modelica.Constants.g_n \"Constant gravity acceleration\"; -parameter Boolean allowFlowReversal = true \"= false to restrict to design flow direction (port_a -> port_b)\" annotation(Evaluate = true); -parameter Modelica.Fluid.Types.Dynamics energyDynamics = Types.Dynamics.DynamicFreeInitial \"Default formulation of energy balances\" annotation(Evaluate = true); -parameter Modelica.Fluid.Types.Dynamics massDynamics = energyDynamics \"Default formulation of mass balances\" annotation(Evaluate = true); -final parameter Modelica.Fluid.Types.Dynamics substanceDynamics = massDynamics \"Default formulation of substance balances\" annotation(Evaluate = true); -final parameter Modelica.Fluid.Types.Dynamics traceDynamics = massDynamics \"Default formulation of trace substance balances\" annotation(Evaluate = true); -parameter Modelica.Fluid.Types.Dynamics momentumDynamics = Types.Dynamics.SteadyState \"Default formulation of momentum balances, if options available\" annotation(Evaluate = true); -parameter Modelica.SIunits.MassFlowRate m_flow_start = 0 \"Default start value for mass flow rates\"; -parameter Modelica.SIunits.AbsolutePressure p_start = p_ambient \"Default start value for pressures\"; -parameter Modelica.SIunits.Temperature T_start = T_ambient \"Default start value for temperatures\"; -parameter Boolean use_eps_Re = false \"= true to determine turbulent region automatically using Reynolds number\" annotation(Evaluate = true); -parameter Modelica.SIunits.MassFlowRate m_flow_nominal = if use_eps_Re then 1 else 1e2 * m_flow_small \"Default nominal mass flow rate\"; -parameter Real eps_m_flow(min = 0) = 1e-4 \"Regularization of zero flow for |m_flow| < eps_m_flow*m_flow_nominal\"; -parameter Modelica.SIunits.AbsolutePressure dp_small(min = 0) = 1 \"Default small pressure drop for regularization of laminar and zero flow\"; -parameter Modelica.SIunits.MassFlowRate m_flow_small(min = 0) = 1e-2 \"Default small mass flow rate for regularization of laminar and zero flow\"; -annotation(defaultComponentPrefixes = \"inner\", missingInnerMessage = \" -Your model is using an outer \\\"system\\\" component but -an inner \\\"system\\\" component is not defined. -For simulation drag Modelica.Fluid.System into your model -to specify system properties.\"); -end System; - -package Pipes \"Devices for conveying fluid\" -extends Modelica.Icons.VariantsPackage; - -model DynamicPipe \"Dynamic pipe model with storage of mass and energy\" -extends Modelica.Fluid.Pipes.BaseClasses.PartialStraightPipe(final port_a_exposesState = modelStructure == .Modelica.Fluid.Types.ModelStructure.av_b or modelStructure == .Modelica.Fluid.Types.ModelStructure.av_vb, final port_b_exposesState = modelStructure == .Modelica.Fluid.Types.ModelStructure.a_vb or modelStructure == .Modelica.Fluid.Types.ModelStructure.av_vb); -extends BaseClasses.PartialTwoPortFlow(final lengths = fill(length / n, n), final crossAreas = fill(crossArea, n), final dimensions = fill(4 * crossArea / perimeter, n), final roughnesses = fill(roughness, n), final dheights = height_ab * dxs); -parameter Boolean use_HeatTransfer = false \"= true to use the HeatTransfer model\"; -replaceable model HeatTransfer = Modelica.Fluid.Pipes.BaseClasses.HeatTransfer.IdealFlowHeatTransfer constrainedby Modelica.Fluid.Pipes.BaseClasses.HeatTransfer.PartialFlowHeatTransfer; -Interfaces.HeatPorts_a[nNodes] heatPorts if use_HeatTransfer; -HeatTransfer heatTransfer(redeclare final package Medium = Medium, final n = n, final nParallel = nParallel, final surfaceAreas = perimeter * lengths, final lengths = lengths, final dimensions = dimensions, final roughnesses = roughnesses, final states = mediums.state, final vs = vs, final use_k = use_HeatTransfer) \"Heat transfer model\"; -final parameter Real[n] dxs = lengths / sum(lengths); -equation -Qb_flows = heatTransfer.Q_flows; -if n == 1 or useLumpedPressure then -Wb_flows = dxs * (vs * dxs * (crossAreas * dxs) * (port_b.p - port_a.p + sum(flowModel.dps_fg) - system.g * (dheights * mediums.d))) * nParallel; -else -if modelStructure == .Modelica.Fluid.Types.ModelStructure.av_vb or modelStructure == .Modelica.Fluid.Types.ModelStructure.av_b then -Wb_flows[2:n - 1] = {vs[i] * crossAreas[i] * ((mediums[i + 1].p - mediums[i - 1].p) / 2 + (flowModel.dps_fg[i - 1] + flowModel.dps_fg[i]) / 2 - system.g * dheights[i] * mediums[i].d) for i in 2:n - 1} * nParallel; -else -Wb_flows[2:n - 1] = {vs[i] * crossAreas[i] * ((mediums[i + 1].p - mediums[i - 1].p) / 2 + (flowModel.dps_fg[i] + flowModel.dps_fg[i + 1]) / 2 - system.g * dheights[i] * mediums[i].d) for i in 2:n - 1} * nParallel; -end if; -if modelStructure == .Modelica.Fluid.Types.ModelStructure.av_vb then -Wb_flows[1] = vs[1] * crossAreas[1] * ((mediums[2].p - mediums[1].p) / 2 + flowModel.dps_fg[1] / 2 - system.g * dheights[1] * mediums[1].d) * nParallel; -Wb_flows[n] = vs[n] * crossAreas[n] * ((mediums[n].p - mediums[n - 1].p) / 2 + flowModel.dps_fg[n - 1] / 2 - system.g * dheights[n] * mediums[n].d) * nParallel; -elseif modelStructure == .Modelica.Fluid.Types.ModelStructure.av_b then -Wb_flows[1] = vs[1] * crossAreas[1] * ((mediums[2].p - mediums[1].p) / 2 + flowModel.dps_fg[1] / 2 - system.g * dheights[1] * mediums[1].d) * nParallel; -Wb_flows[n] = vs[n] * crossAreas[n] * ((port_b.p - mediums[n - 1].p) / 1.5 + flowModel.dps_fg[n - 1] / 2 + flowModel.dps_fg[n] - system.g * dheights[n] * mediums[n].d) * nParallel; -elseif modelStructure == .Modelica.Fluid.Types.ModelStructure.a_vb then -Wb_flows[1] = vs[1] * crossAreas[1] * ((mediums[2].p - port_a.p) / 1.5 + flowModel.dps_fg[1] + flowModel.dps_fg[2] / 2 - system.g * dheights[1] * mediums[1].d) * nParallel; -Wb_flows[n] = vs[n] * crossAreas[n] * ((mediums[n].p - mediums[n - 1].p) / 2 + flowModel.dps_fg[n] / 2 - system.g * dheights[n] * mediums[n].d) * nParallel; -elseif modelStructure == .Modelica.Fluid.Types.ModelStructure.a_v_b then -Wb_flows[1] = vs[1] * crossAreas[1] * ((mediums[2].p - port_a.p) / 1.5 + flowModel.dps_fg[1] + flowModel.dps_fg[2] / 2 - system.g * dheights[1] * mediums[1].d) * nParallel; -Wb_flows[n] = vs[n] * crossAreas[n] * ((port_b.p - mediums[n - 1].p) / 1.5 + flowModel.dps_fg[n] / 2 + flowModel.dps_fg[n + 1] - system.g * dheights[n] * mediums[n].d) * nParallel; -else -assert(false, \"Unknown model structure\"); -end if; -end if; -connect(heatPorts, heatTransfer.heatPorts); -end DynamicPipe; - -package BaseClasses \"Base classes used in the Pipes package (only of interest to build new component models)\" -extends Modelica.Icons.BasesPackage; - -partial model PartialStraightPipe \"Base class for straight pipe models\" -extends Modelica.Fluid.Interfaces.PartialTwoPort; -parameter Real nParallel(min = 1) = 1 \"Number of identical parallel pipes\"; -parameter .Modelica.SIunits.Length length \"Length\"; -parameter Boolean isCircular = true \"= true if cross sectional area is circular\"; -parameter .Modelica.SIunits.Diameter diameter \"Diameter of circular pipe\"; -parameter .Modelica.SIunits.Area crossArea = Modelica.Constants.pi * diameter * diameter / 4 \"Inner cross section area\"; -parameter .Modelica.SIunits.Length perimeter = Modelica.Constants.pi * diameter \"Inner perimeter\"; -parameter .Modelica.SIunits.Height roughness = 2.5e-5 \"Average height of surface asperities (default: smooth steel pipe)\"; -final parameter .Modelica.SIunits.Volume V = crossArea * length * nParallel \"volume size\"; -parameter .Modelica.SIunits.Length height_ab = 0 \"Height(port_b) - Height(port_a)\"; -equation -assert(length >= height_ab, \"Parameter length must be greater or equal height_ab.\"); -end PartialStraightPipe; - -partial model PartialTwoPortFlow \"Base class for distributed flow models\" -extends Modelica.Fluid.Interfaces.PartialTwoPort(final port_a_exposesState = modelStructure == .Modelica.Fluid.Types.ModelStructure.av_b or modelStructure == .Modelica.Fluid.Types.ModelStructure.av_vb, final port_b_exposesState = modelStructure == .Modelica.Fluid.Types.ModelStructure.a_vb or modelStructure == .Modelica.Fluid.Types.ModelStructure.av_vb); -extends Modelica.Fluid.Interfaces.PartialDistributedVolume(final n = nNodes, final fluidVolumes = {crossAreas[i] * lengths[i] for i in 1:n} * nParallel); -parameter Real nParallel(min = 1) = 1 \"Number of identical parallel flow devices\"; -parameter .Modelica.SIunits.Length[n] lengths \"lengths of flow segments\"; -parameter .Modelica.SIunits.Area[n] crossAreas \"cross flow areas of flow segments\"; -parameter .Modelica.SIunits.Length[n] dimensions \"hydraulic diameters of flow segments\"; -parameter .Modelica.SIunits.Height[n] roughnesses \"Average heights of surface asperities\"; -parameter .Modelica.SIunits.Length[n] dheights = zeros(n) \"Differences in heights of flow segments\" annotation(Evaluate = true); -parameter Types.Dynamics momentumDynamics = system.momentumDynamics \"Formulation of momentum balances\" annotation(Evaluate = true); -parameter Medium.MassFlowRate m_flow_start = system.m_flow_start \"Start value for mass flow rate\" annotation(Evaluate = true); -parameter Integer nNodes(min = 1) = 2 \"Number of discrete flow volumes\" annotation(Evaluate = true); -parameter Types.ModelStructure modelStructure = Types.ModelStructure.av_vb \"Determines whether flow or volume models are present at the ports\" annotation(Evaluate = true); -parameter Boolean useLumpedPressure = false \"=true to lump pressure states together\" annotation(Evaluate = true); -final parameter Integer nFM = if useLumpedPressure then nFMLumped else nFMDistributed \"number of flow models in flowModel\"; -final parameter Integer nFMDistributed = if modelStructure == Types.ModelStructure.a_v_b then n + 1 else if modelStructure == Types.ModelStructure.a_vb or modelStructure == Types.ModelStructure.av_b then n else n - 1; -final parameter Integer nFMLumped = if modelStructure == Types.ModelStructure.a_v_b then 2 else 1; -final parameter Integer iLumped = integer(n / 2) + 1 \"Index of control volume with representative state if useLumpedPressure\" annotation(Evaluate = true); -parameter Boolean useInnerPortProperties = false \"=true to take port properties for flow models from internal control volumes\" annotation(Evaluate = true); -Medium.ThermodynamicState state_a \"state defined by volume outside port_a\"; -Medium.ThermodynamicState state_b \"state defined by volume outside port_b\"; -Medium.ThermodynamicState[nFM + 1] statesFM \"state vector for flowModel model\"; -replaceable model FlowModel = Modelica.Fluid.Pipes.BaseClasses.FlowModels.DetailedPipeFlow constrainedby Modelica.Fluid.Pipes.BaseClasses.FlowModels.PartialStaggeredFlowModel; -FlowModel flowModel(redeclare final package Medium = Medium, final n = nFM + 1, final states = statesFM, final vs = vsFM, final momentumDynamics = momentumDynamics, final allowFlowReversal = allowFlowReversal, final p_a_start = p_a_start, final p_b_start = p_b_start, final m_flow_start = m_flow_start, final nParallel = nParallel, final pathLengths = pathLengths, final crossAreas = crossAreasFM, final dimensions = dimensionsFM, final roughnesses = roughnessesFM, final dheights = dheightsFM, final g = system.g) \"Flow model\"; -Medium.MassFlowRate[n + 1] m_flows(each min = if allowFlowReversal then -Modelica.Constants.inf else 0, each start = m_flow_start) \"Mass flow rates of fluid across segment boundaries\"; -Medium.MassFlowRate[n + 1, Medium.nXi] mXi_flows \"Independent mass flow rates across segment boundaries\"; -Medium.MassFlowRate[n + 1, Medium.nC] mC_flows \"Trace substance mass flow rates across segment boundaries\"; -Medium.EnthalpyFlowRate[n + 1] H_flows \"Enthalpy flow rates of fluid across segment boundaries\"; -.Modelica.SIunits.Velocity[n] vs = {0.5 * (m_flows[i] + m_flows[i + 1]) / mediums[i].d / crossAreas[i] for i in 1:n} / nParallel \"mean velocities in flow segments\"; -protected -.Modelica.SIunits.Length[nFM] pathLengths \"Lengths along flow path\"; -.Modelica.SIunits.Length[nFM] dheightsFM \"Differences in heights between flow segments\"; -.Modelica.SIunits.Area[nFM + 1] crossAreasFM \"Cross flow areas of flow segments\"; -.Modelica.SIunits.Velocity[nFM + 1] vsFM \"Mean velocities in flow segments\"; -.Modelica.SIunits.Length[nFM + 1] dimensionsFM \"Hydraulic diameters of flow segments\"; -.Modelica.SIunits.Height[nFM + 1] roughnessesFM \"Average heights of surface asperities\"; -equation -assert(nNodes > 1 or modelStructure <> .Modelica.Fluid.Types.ModelStructure.av_vb, \"nNodes needs to be at least 2 for modelStructure av_vb, as flow model disappears otherwise!\"); -if useLumpedPressure then -if modelStructure <> .Modelica.Fluid.Types.ModelStructure.a_v_b then -pathLengths[1] = sum(lengths); -dheightsFM[1] = sum(dheights); -if n == 1 then -crossAreasFM[1:2] = {crossAreas[1], crossAreas[1]}; -dimensionsFM[1:2] = {dimensions[1], dimensions[1]}; -roughnessesFM[1:2] = {roughnesses[1], roughnesses[1]}; -else -crossAreasFM[1:2] = {sum(crossAreas[1:iLumped - 1]) / (iLumped - 1), sum(crossAreas[iLumped:n]) / (n - iLumped + 1)}; -dimensionsFM[1:2] = {sum(dimensions[1:iLumped - 1]) / (iLumped - 1), sum(dimensions[iLumped:n]) / (n - iLumped + 1)}; -roughnessesFM[1:2] = {sum(roughnesses[1:iLumped - 1]) / (iLumped - 1), sum(roughnesses[iLumped:n]) / (n - iLumped + 1)}; -end if; -else -if n == 1 then -pathLengths[1:2] = {lengths[1] / 2, lengths[1] / 2}; -dheightsFM[1:2] = {dheights[1] / 2, dheights[1] / 2}; -crossAreasFM[1:3] = {crossAreas[1], crossAreas[1], crossAreas[1]}; -dimensionsFM[1:3] = {dimensions[1], dimensions[1], dimensions[1]}; -roughnessesFM[1:3] = {roughnesses[1], roughnesses[1], roughnesses[1]}; -else -pathLengths[1:2] = {sum(lengths[1:iLumped - 1]), sum(lengths[iLumped:n])}; -dheightsFM[1:2] = {sum(dheights[1:iLumped - 1]), sum(dheights[iLumped:n])}; -crossAreasFM[1:3] = {sum(crossAreas[1:iLumped - 1]) / (iLumped - 1), sum(crossAreas) / n, sum(crossAreas[iLumped:n]) / (n - iLumped + 1)}; -dimensionsFM[1:3] = {sum(dimensions[1:iLumped - 1]) / (iLumped - 1), sum(dimensions) / n, sum(dimensions[iLumped:n]) / (n - iLumped + 1)}; -roughnessesFM[1:3] = {sum(roughnesses[1:iLumped - 1]) / (iLumped - 1), sum(roughnesses) / n, sum(roughnesses[iLumped:n]) / (n - iLumped + 1)}; -end if; -end if; -else -if modelStructure == .Modelica.Fluid.Types.ModelStructure.av_vb then -if n == 2 then -pathLengths[1] = lengths[1] + lengths[2]; -dheightsFM[1] = dheights[1] + dheights[2]; -else -pathLengths[1:n - 1] = cat(1, {lengths[1] + 0.5 * lengths[2]}, 0.5 * (lengths[2:n - 2] + lengths[3:n - 1]), {0.5 * lengths[n - 1] + lengths[n]}); -dheightsFM[1:n - 1] = cat(1, {dheights[1] + 0.5 * dheights[2]}, 0.5 * (dheights[2:n - 2] + dheights[3:n - 1]), {0.5 * dheights[n - 1] + dheights[n]}); -end if; -crossAreasFM[1:n] = crossAreas; -dimensionsFM[1:n] = dimensions; -roughnessesFM[1:n] = roughnesses; -elseif modelStructure == .Modelica.Fluid.Types.ModelStructure.av_b then -pathLengths[1:n] = lengths; -dheightsFM[1:n] = dheights; -crossAreasFM[1:n + 1] = cat(1, crossAreas[1:n], {crossAreas[n]}); -dimensionsFM[1:n + 1] = cat(1, dimensions[1:n], {dimensions[n]}); -roughnessesFM[1:n + 1] = cat(1, roughnesses[1:n], {roughnesses[n]}); -elseif modelStructure == .Modelica.Fluid.Types.ModelStructure.a_vb then -pathLengths[1:n] = lengths; -dheightsFM[1:n] = dheights; -crossAreasFM[1:n + 1] = cat(1, {crossAreas[1]}, crossAreas[1:n]); -dimensionsFM[1:n + 1] = cat(1, {dimensions[1]}, dimensions[1:n]); -roughnessesFM[1:n + 1] = cat(1, {roughnesses[1]}, roughnesses[1:n]); -elseif modelStructure == .Modelica.Fluid.Types.ModelStructure.a_v_b then -pathLengths[1:n + 1] = cat(1, {0.5 * lengths[1]}, 0.5 * (lengths[1:n - 1] + lengths[2:n]), {0.5 * lengths[n]}); -dheightsFM[1:n + 1] = cat(1, {0.5 * dheights[1]}, 0.5 * (dheights[1:n - 1] + dheights[2:n]), {0.5 * dheights[n]}); -crossAreasFM[1:n + 2] = cat(1, {crossAreas[1]}, crossAreas[1:n], {crossAreas[n]}); -dimensionsFM[1:n + 2] = cat(1, {dimensions[1]}, dimensions[1:n], {dimensions[n]}); -roughnessesFM[1:n + 2] = cat(1, {roughnesses[1]}, roughnesses[1:n], {roughnesses[n]}); -else -assert(false, \"Unknown model structure\"); -end if; -end if; -for i in 1:n loop -mb_flows[i] = m_flows[i] - m_flows[i + 1]; -mbXi_flows[i, :] = mXi_flows[i, :] - mXi_flows[i + 1, :]; -mbC_flows[i, :] = mC_flows[i, :] - mC_flows[i + 1, :]; -Hb_flows[i] = H_flows[i] - H_flows[i + 1]; -end for; -for i in 2:n loop -H_flows[i] = semiLinear(m_flows[i], mediums[i - 1].h, mediums[i].h); -mXi_flows[i, :] = semiLinear(m_flows[i], mediums[i - 1].Xi, mediums[i].Xi); -mC_flows[i, :] = semiLinear(m_flows[i], Cs[i - 1, :], Cs[i, :]); -end for; -H_flows[1] = semiLinear(port_a.m_flow, inStream(port_a.h_outflow), mediums[1].h); -H_flows[n + 1] = -semiLinear(port_b.m_flow, inStream(port_b.h_outflow), mediums[n].h); -mXi_flows[1, :] = semiLinear(port_a.m_flow, inStream(port_a.Xi_outflow), mediums[1].Xi); -mXi_flows[n + 1, :] = -semiLinear(port_b.m_flow, inStream(port_b.Xi_outflow), mediums[n].Xi); -mC_flows[1, :] = semiLinear(port_a.m_flow, inStream(port_a.C_outflow), Cs[1, :]); -mC_flows[n + 1, :] = -semiLinear(port_b.m_flow, inStream(port_b.C_outflow), Cs[n, :]); -port_a.m_flow = m_flows[1]; -port_b.m_flow = -m_flows[n + 1]; -port_a.h_outflow = mediums[1].h; -port_b.h_outflow = mediums[n].h; -port_a.Xi_outflow = mediums[1].Xi; -port_b.Xi_outflow = mediums[n].Xi; -port_a.C_outflow = Cs[1, :]; -port_b.C_outflow = Cs[n, :]; -if useInnerPortProperties and n > 0 then -state_a = Medium.setState_phX(port_a.p, mediums[1].h, mediums[1].Xi); -state_b = Medium.setState_phX(port_b.p, mediums[n].h, mediums[n].Xi); -else -state_a = Medium.setState_phX(port_a.p, inStream(port_a.h_outflow), inStream(port_a.Xi_outflow)); -state_b = Medium.setState_phX(port_b.p, inStream(port_b.h_outflow), inStream(port_b.Xi_outflow)); -end if; -if useLumpedPressure then -if modelStructure <> .Modelica.Fluid.Types.ModelStructure.av_vb then -fill(mediums[1].p, n - 1) = mediums[2:n].p; -elseif n > 2 then -fill(mediums[1].p, iLumped - 2) = mediums[2:iLumped - 1].p; -fill(mediums[n].p, n - iLumped) = mediums[iLumped:n - 1].p; -end if; -if modelStructure == .Modelica.Fluid.Types.ModelStructure.av_vb then -port_a.p = mediums[1].p; -statesFM[1] = mediums[1].state; -m_flows[iLumped] = flowModel.m_flows[1]; -statesFM[2] = mediums[n].state; -port_b.p = mediums[n].p; -vsFM[1] = vs[1:iLumped - 1] * lengths[1:iLumped - 1] / sum(lengths[1:iLumped - 1]); -vsFM[2] = vs[iLumped:n] * lengths[iLumped:n] / sum(lengths[iLumped:n]); -elseif modelStructure == .Modelica.Fluid.Types.ModelStructure.av_b then -port_a.p = mediums[1].p; -statesFM[1] = mediums[iLumped].state; -statesFM[2] = state_b; -m_flows[n + 1] = flowModel.m_flows[1]; -vsFM[1] = vs * lengths / sum(lengths); -vsFM[2] = m_flows[n + 1] / Medium.density(state_b) / crossAreas[n] / nParallel; -elseif modelStructure == .Modelica.Fluid.Types.ModelStructure.a_vb then -m_flows[1] = flowModel.m_flows[1]; -statesFM[1] = state_a; -statesFM[2] = mediums[iLumped].state; -port_b.p = mediums[n].p; -vsFM[1] = m_flows[1] / Medium.density(state_a) / crossAreas[1] / nParallel; -vsFM[2] = vs * lengths / sum(lengths); -elseif modelStructure == .Modelica.Fluid.Types.ModelStructure.a_v_b then -m_flows[1] = flowModel.m_flows[1]; -statesFM[1] = state_a; -statesFM[2] = mediums[iLumped].state; -statesFM[3] = state_b; -m_flows[n + 1] = flowModel.m_flows[2]; -vsFM[1] = m_flows[1] / Medium.density(state_a) / crossAreas[1] / nParallel; -vsFM[2] = vs * lengths / sum(lengths); -vsFM[3] = m_flows[n + 1] / Medium.density(state_b) / crossAreas[n] / nParallel; -else -assert(false, \"Unknown model structure\"); -end if; -else -if modelStructure == .Modelica.Fluid.Types.ModelStructure.av_vb then -statesFM[1:n] = mediums[1:n].state; -m_flows[2:n] = flowModel.m_flows[1:n - 1]; -vsFM[1:n] = vs; -port_a.p = mediums[1].p; -port_b.p = mediums[n].p; -elseif modelStructure == .Modelica.Fluid.Types.ModelStructure.av_b then -statesFM[1:n] = mediums[1:n].state; -statesFM[n + 1] = state_b; -m_flows[2:n + 1] = flowModel.m_flows[1:n]; -vsFM[1:n] = vs; -vsFM[n + 1] = m_flows[n + 1] / Medium.density(state_b) / crossAreas[n] / nParallel; -port_a.p = mediums[1].p; -elseif modelStructure == .Modelica.Fluid.Types.ModelStructure.a_vb then -statesFM[1] = state_a; -statesFM[2:n + 1] = mediums[1:n].state; -m_flows[1:n] = flowModel.m_flows[1:n]; -vsFM[1] = m_flows[1] / Medium.density(state_a) / crossAreas[1] / nParallel; -vsFM[2:n + 1] = vs; -port_b.p = mediums[n].p; -elseif modelStructure == .Modelica.Fluid.Types.ModelStructure.a_v_b then -statesFM[1] = state_a; -statesFM[2:n + 1] = mediums[1:n].state; -statesFM[n + 2] = state_b; -m_flows[1:n + 1] = flowModel.m_flows[1:n + 1]; -vsFM[1] = m_flows[1] / Medium.density(state_a) / crossAreas[1] / nParallel; -vsFM[2:n + 1] = vs; -vsFM[n + 2] = m_flows[n + 1] / Medium.density(state_b) / crossAreas[n] / nParallel; -else -assert(false, \"Unknown model structure\"); -end if; -end if; -end PartialTwoPortFlow; - -package FlowModels \"Flow models for pipes, including wall friction, static head and momentum flow\" -extends Modelica.Icons.Package; - -partial model PartialStaggeredFlowModel \"Base class for momentum balances in flow models\" -replaceable package Medium = Modelica.Media.Interfaces.PartialMedium \"Medium in the component\"; -parameter Integer n = 2 \"Number of discrete flow volumes\"; -input Medium.ThermodynamicState[n] states \"Thermodynamic states along design flow\"; -input Modelica.SIunits.Velocity[n] vs \"Mean velocities of fluid flow\"; -parameter Real nParallel \"number of identical parallel flow devices\"; -input .Modelica.SIunits.Area[n] crossAreas \"Cross flow areas at segment boundaries\"; -input .Modelica.SIunits.Length[n] dimensions \"Characteristic dimensions for fluid flow (diameters for pipe flow)\"; -input .Modelica.SIunits.Height[n] roughnesses \"Average height of surface asperities\"; -input .Modelica.SIunits.Length[n - 1] dheights \"Height(states[2:n]) - Height(states[1:n-1])\"; -parameter .Modelica.SIunits.Acceleration g = system.g \"Constant gravity acceleration\"; -parameter Boolean allowFlowReversal = system.allowFlowReversal \"= true to allow flow reversal, false restricts to design direction (states[1] -> states[n+1])\" annotation(Evaluate = true); -parameter Modelica.Fluid.Types.Dynamics momentumDynamics = system.momentumDynamics \"Formulation of momentum balance\" annotation(Evaluate = true); -parameter Medium.MassFlowRate m_flow_start = system.m_flow_start \"Start value of mass flow rates\"; -parameter Medium.AbsolutePressure p_a_start \"Start value for p[1] at design inflow\"; -parameter Medium.AbsolutePressure p_b_start \"Start value for p[n+1] at design outflow\"; -extends Modelica.Fluid.Interfaces.PartialDistributedFlow(final m = n - 1); -parameter Boolean useUpstreamScheme = true \"= false to average upstream and downstream properties across flow segments\" annotation(Evaluate = true); -parameter Boolean use_Ib_flows = momentumDynamics <> Types.Dynamics.SteadyState \"= true to consider differences in flow of momentum through boundaries\" annotation(Evaluate = true); -Medium.Density[n] rhos = if use_rho_nominal then fill(rho_nominal, n) else Medium.density(states); -Medium.Density[n - 1] rhos_act \"Actual density per segment\"; -Medium.DynamicViscosity[n] mus = if use_mu_nominal then fill(mu_nominal, n) else Medium.dynamicViscosity(states); -Medium.DynamicViscosity[n - 1] mus_act \"Actual viscosity per segment\"; -Modelica.SIunits.Pressure[n - 1] dps_fg(each start = (p_a_start - p_b_start) / (n - 1)) \"pressure drop between states\"; -parameter .Modelica.SIunits.ReynoldsNumber Re_turbulent = 4000 \"Start of turbulent regime, depending on type of flow device\"; -parameter Boolean show_Res = false \"= true, if Reynolds numbers are included for plotting\" annotation(Evaluate = true); -.Modelica.SIunits.ReynoldsNumber[n] Res = Modelica.Fluid.Pipes.BaseClasses.CharacteristicNumbers.ReynoldsNumber(vs, rhos, mus, dimensions) if show_Res \"Reynolds numbers\"; -Medium.MassFlowRate[n - 1] m_flows_turbulent = {nParallel * (crossAreas[i] + crossAreas[i + 1]) / (dimensions[i] + dimensions[i + 1]) * mus_act[i] * Re_turbulent for i in 1:n - 1} if show_Res \"Start of turbulent flow\"; -protected -parameter Boolean use_rho_nominal = false \"= true, if rho_nominal is used, otherwise computed from medium\" annotation(Evaluate = true); -parameter .Modelica.SIunits.Density rho_nominal = Medium.density_pTX(Medium.p_default, Medium.T_default, Medium.X_default) \"Nominal density (e.g., rho_liquidWater = 995, rho_air = 1.2)\"; -parameter Boolean use_mu_nominal = false \"= true, if mu_nominal is used, otherwise computed from medium\" annotation(Evaluate = true); -parameter .Modelica.SIunits.DynamicViscosity mu_nominal = Medium.dynamicViscosity(Medium.setState_pTX(Medium.p_default, Medium.T_default, Medium.X_default)) \"Nominal dynamic viscosity (e.g., mu_liquidWater = 1e-3, mu_air = 1.8e-5)\"; -equation -if not allowFlowReversal then -rhos_act = rhos[1:n - 1]; -mus_act = mus[1:n - 1]; -elseif not useUpstreamScheme then -rhos_act = 0.5 * (rhos[1:n - 1] + rhos[2:n]); -mus_act = 0.5 * (mus[1:n - 1] + mus[2:n]); -else -for i in 1:n - 1 loop -rhos_act[i] = noEvent(if m_flows[i] > 0 then rhos[i] else rhos[i + 1]); -mus_act[i] = noEvent(if m_flows[i] > 0 then mus[i] else mus[i + 1]); -end for; -end if; -if use_Ib_flows then -Ib_flows = nParallel * {rhos[i] * vs[i] * vs[i] * crossAreas[i] - rhos[i + 1] * vs[i + 1] * vs[i + 1] * crossAreas[i + 1] for i in 1:n - 1}; -else -Ib_flows = zeros(n - 1); -end if; -Fs_p = nParallel * {0.5 * (crossAreas[i] + crossAreas[i + 1]) * (Medium.pressure(states[i + 1]) - Medium.pressure(states[i])) for i in 1:n - 1}; -dps_fg = {Fs_fg[i] / nParallel * 2 / (crossAreas[i] + crossAreas[i + 1]) for i in 1:n - 1}; -end PartialStaggeredFlowModel; - -partial model PartialGenericPipeFlow \"GenericPipeFlow: Pipe flow pressure loss and gravity with replaceable WallFriction package\" -parameter Boolean from_dp = momentumDynamics >= Types.Dynamics.SteadyStateInitial \"= true, use m_flow = f(dp), otherwise dp = f(m_flow)\" annotation(Evaluate = true); -extends Modelica.Fluid.Pipes.BaseClasses.FlowModels.PartialStaggeredFlowModel(final Re_turbulent = 4000); -replaceable package WallFriction = Modelica.Fluid.Pipes.BaseClasses.WallFriction.Detailed constrainedby Modelica.Fluid.Pipes.BaseClasses.WallFriction.PartialWallFriction; -input .Modelica.SIunits.Length[n - 1] pathLengths_internal \"pathLengths used internally; to be defined by extending class\"; -input .Modelica.SIunits.ReynoldsNumber[n - 1] Res_turbulent_internal = Re_turbulent * ones(n - 1) \"Re_turbulent used internally; to be defined by extending class\"; -parameter .Modelica.SIunits.AbsolutePressure dp_nominal \"Nominal pressure loss (only for nominal models)\"; -parameter .Modelica.SIunits.MassFlowRate m_flow_nominal \"Nominal mass flow rate\"; -parameter .Modelica.SIunits.MassFlowRate m_flow_small = if system.use_eps_Re then system.eps_m_flow * m_flow_nominal else system.m_flow_small \"Within regularization if |m_flows| < m_flow_small (may be wider for large discontinuities in static head)\"; -protected -parameter .Modelica.SIunits.AbsolutePressure dp_small(start = 1, fixed = false) \"Within regularization if |dp| < dp_small (may be wider for large discontinuities in static head)\"; -final parameter Boolean constantPressureLossCoefficient = use_rho_nominal and (use_mu_nominal or not WallFriction.use_mu) \"= true if the pressure loss does not depend on fluid states\" annotation(Evaluate = true); -final parameter Boolean continuousFlowReversal = not useUpstreamScheme or constantPressureLossCoefficient or not allowFlowReversal \"= true if the pressure loss is continuous around zero flow\" annotation(Evaluate = true); -.Modelica.SIunits.Length[n - 1] diameters = 0.5 * (dimensions[1:n - 1] + dimensions[2:n]) \"mean diameters between segments\"; -.Modelica.SIunits.AbsolutePressure dp_fric_nominal = sum(WallFriction.pressureLoss_m_flow(m_flow_nominal / nParallel, rho_nominal, rho_nominal, mu_nominal, mu_nominal, pathLengths_internal, diameters, (crossAreas[1:n - 1] + crossAreas[2:n]) / 2, (roughnesses[1:n - 1] + roughnesses[2:n]) / 2, m_flow_small / nParallel, Res_turbulent_internal)) \"pressure loss for nominal conditions\"; -initial equation -if system.use_eps_Re then -dp_small = dp_fric_nominal / m_flow_nominal * m_flow_small; -else -dp_small = system.dp_small; -end if; -equation -for i in 1:n - 1 loop -assert(m_flows[i] > (-m_flow_small) or allowFlowReversal, \"Reverting flow occurs even though allowFlowReversal is false\"); -end for; -if continuousFlowReversal then -if from_dp and not WallFriction.dp_is_zero then -m_flows = homotopy(actual = WallFriction.massFlowRate_dp(dps_fg - {g * dheights[i] * rhos_act[i] for i in 1:n - 1}, rhos_act, rhos_act, mus_act, mus_act, pathLengths_internal, diameters, (crossAreas[1:n - 1] + crossAreas[2:n]) / 2, (roughnesses[1:n - 1] + roughnesses[2:n]) / 2, dp_small / (n - 1), Res_turbulent_internal) * nParallel, simplified = m_flow_nominal / dp_nominal * (dps_fg - g * dheights * rho_nominal)); -else -dps_fg = homotopy(actual = WallFriction.pressureLoss_m_flow(m_flows / nParallel, rhos_act, rhos_act, mus_act, mus_act, pathLengths_internal, diameters, (crossAreas[1:n - 1] + crossAreas[2:n]) / 2, (roughnesses[1:n - 1] + roughnesses[2:n]) / 2, m_flow_small / nParallel, Res_turbulent_internal) + {g * dheights[i] * rhos_act[i] for i in 1:n - 1}, simplified = dp_nominal / m_flow_nominal * m_flows + g * dheights * rho_nominal); -end if; -else -if from_dp and not WallFriction.dp_is_zero then -m_flows = homotopy(actual = WallFriction.massFlowRate_dp_staticHead(dps_fg, rhos[1:n - 1], rhos[2:n], mus[1:n - 1], mus[2:n], pathLengths_internal, diameters, g * dheights, (crossAreas[1:n - 1] + crossAreas[2:n]) / 2, (roughnesses[1:n - 1] + roughnesses[2:n]) / 2, dp_small / (n - 1), Res_turbulent_internal) * nParallel, simplified = m_flow_nominal / dp_nominal * (dps_fg - g * dheights * rho_nominal)); -else -dps_fg = homotopy(actual = WallFriction.pressureLoss_m_flow_staticHead(m_flows / nParallel, rhos[1:n - 1], rhos[2:n], mus[1:n - 1], mus[2:n], pathLengths_internal, diameters, g * dheights, (crossAreas[1:n - 1] + crossAreas[2:n]) / 2, (roughnesses[1:n - 1] + roughnesses[2:n]) / 2, m_flow_small / nParallel, Res_turbulent_internal), simplified = dp_nominal / m_flow_nominal * m_flows + g * dheights * rho_nominal); -end if; -end if; -end PartialGenericPipeFlow; - -model DetailedPipeFlow \"DetailedPipeFlow: Detailed characteristic for laminar and turbulent flow\" -extends Modelica.Fluid.Pipes.BaseClasses.FlowModels.PartialGenericPipeFlow(redeclare package WallFriction = Modelica.Fluid.Pipes.BaseClasses.WallFriction.Detailed, pathLengths_internal = pathLengths, dp_nominal(start = 1, fixed = false), m_flow_nominal = if system.use_eps_Re then system.m_flow_nominal else 1e2 * m_flow_small, Res_turbulent_internal = Re_turbulent * ones(n - 1)); -initial equation -if system.use_eps_Re then -dp_nominal = dp_fric_nominal + g * sum(dheights) * rho_nominal; -else -dp_nominal = 1e3 * dp_small; -end if; -end DetailedPipeFlow; -end FlowModels; - -package HeatTransfer \"Heat transfer for flow models\" -extends Modelica.Icons.Package; - -partial model PartialFlowHeatTransfer \"base class for any pipe heat transfer correlation\" -extends Modelica.Fluid.Interfaces.PartialHeatTransfer; -input .Modelica.SIunits.Velocity[n] vs \"Mean velocities of fluid flow in segments\"; -parameter Real nParallel \"number of identical parallel flow devices\"; -input .Modelica.SIunits.Length[n] lengths \"Lengths along flow path\"; -input .Modelica.SIunits.Length[n] dimensions \"Characteristic dimensions for fluid flow (diameter for pipe flow)\"; -input .Modelica.SIunits.Height[n] roughnesses \"Average heights of surface asperities\"; -end PartialFlowHeatTransfer; - -model IdealFlowHeatTransfer \"IdealHeatTransfer: Ideal heat transfer without thermal resistance\" -extends PartialFlowHeatTransfer; -equation -Ts = heatPorts.T; -end IdealFlowHeatTransfer; - -partial model PartialPipeFlowHeatTransfer \"Base class for pipe heat transfer correlation in terms of Nusselt number heat transfer in a circular pipe for laminar and turbulent one-phase flow\" -extends PartialFlowHeatTransfer; -parameter .Modelica.SIunits.CoefficientOfHeatTransfer alpha0 = 100 \"guess value for heat transfer coefficients\"; -.Modelica.SIunits.CoefficientOfHeatTransfer[n] alphas(each start = alpha0) \"CoefficientOfHeatTransfer\"; -Real[n] Res \"Reynolds numbers\"; -Real[n] Prs \"Prandtl numbers\"; -Real[n] Nus \"Nusselt numbers\"; -Medium.Density[n] ds \"Densities\"; -Medium.DynamicViscosity[n] mus \"Dynamic viscosities\"; -Medium.ThermalConductivity[n] lambdas \"Thermal conductivity\"; -.Modelica.SIunits.Length[n] diameters = dimensions \"Hydraulic diameters for pipe flow\"; -equation -ds = Medium.density(states); -mus = Medium.dynamicViscosity(states); -lambdas = Medium.thermalConductivity(states); -Prs = Medium.prandtlNumber(states); -Res = CharacteristicNumbers.ReynoldsNumber(vs, ds, mus, diameters); -Nus = CharacteristicNumbers.NusseltNumber(alphas, diameters, lambdas); -Q_flows = {alphas[i] * surfaceAreas[i] * (heatPorts[i].T - Ts[i]) * nParallel for i in 1:n}; -end PartialPipeFlowHeatTransfer; - -model LocalPipeFlowHeatTransfer \"LocalPipeFlowHeatTransfer: Laminar and turbulent forced convection in pipes, local coefficients\" -extends PartialPipeFlowHeatTransfer; -protected -Real[n] Nus_turb \"Nusselt number for turbulent flow\"; -Real[n] Nus_lam \"Nusselt number for laminar flow\"; -Real Nu_1; -Real[n] Nus_2; -Real[n] Xis; -equation -Nu_1 = 3.66; -for i in 1:n loop -Nus_turb[i] = smooth(0, Xis[i] / 8 * abs(Res[i]) * Prs[i] / (1 + 12.7 * (Xis[i] / 8) ^ 0.5 * (Prs[i] ^ (2 / 3) - 1)) * (1 + 1 / 3 * (diameters[i] / lengths[i] / (if vs[i] >= 0 then i - 0.5 else n - i + 0.5)) ^ (2 / 3))); -Xis[i] = (1.8 * Modelica.Math.log10(max(1e-10, Res[i])) - 1.5) ^ (-2); -Nus_lam[i] = (Nu_1 ^ 3 + 0.7 ^ 3 + (Nus_2[i] - 0.7) ^ 3) ^ (1 / 3); -Nus_2[i] = smooth(0, 1.077 * (abs(Res[i]) * Prs[i] * diameters[i] / lengths[i] / (if vs[i] >= 0 then i - 0.5 else n - i + 0.5)) ^ (1 / 3)); -Nus[i] = Modelica.Media.Air.MoistAir.Utilities.spliceFunction(Nus_turb[i], Nus_lam[i], Res[i] - 6150, 3850); -end for; -end LocalPipeFlowHeatTransfer; -end HeatTransfer; - -package CharacteristicNumbers \"Functions to compute characteristic numbers\" -extends Modelica.Icons.Package; - -function ReynoldsNumber \"Return Reynolds number from v, rho, mu, D\" -extends Modelica.Icons.Function; -input .Modelica.SIunits.Velocity v \"Mean velocity of fluid flow\"; -input .Modelica.SIunits.Density rho \"Fluid density\"; -input .Modelica.SIunits.DynamicViscosity mu \"Dynamic (absolute) viscosity\"; -input .Modelica.SIunits.Length D \"Characteristic dimension (hydraulic diameter of pipes)\"; -output .Modelica.SIunits.ReynoldsNumber Re \"Reynolds number\"; -algorithm -Re := abs(v) * rho * D / mu; -end ReynoldsNumber; - -function NusseltNumber \"Return Nusselt number\" -extends Modelica.Icons.Function; -input .Modelica.SIunits.CoefficientOfHeatTransfer alpha \"Coefficient of heat transfer\"; -input .Modelica.SIunits.Length D \"Characteristic dimension\"; -input .Modelica.SIunits.ThermalConductivity lambda \"Thermal conductivity\"; -output .Modelica.SIunits.NusseltNumber Nu \"Nusselt number\"; -algorithm -Nu := alpha * D / lambda; -end NusseltNumber; -end CharacteristicNumbers; - -package WallFriction \"Different variants for pressure drops due to pipe wall friction\" -extends Modelica.Icons.Package; - -partial package PartialWallFriction \"Partial wall friction characteristic (base package of all wall friction characteristics)\" -extends Modelica.Icons.Package; -constant Boolean use_mu = true \"= true, if mu_a/mu_b are used in function, otherwise value is not used\"; -constant Boolean use_roughness = true \"= true, if roughness is used in function, otherwise value is not used\"; -constant Boolean use_dp_small = true \"= true, if dp_small is used in function, otherwise value is not used\"; -constant Boolean use_m_flow_small = true \"= true, if m_flow_small is used in function, otherwise value is not used\"; -constant Boolean dp_is_zero = false \"= true, if no wall friction is present, i.e., dp = 0 (function massFlowRate_dp() cannot be used)\"; -constant Boolean use_Re_turbulent = true \"= true, if Re_turbulent input is used in function, otherwise value is not used\"; - -replaceable partial function massFlowRate_dp \"Return mass flow rate m_flow as function of pressure loss dp, i.e., m_flow = f(dp), due to wall friction\" -extends Modelica.Icons.Function; -input .Modelica.SIunits.Pressure dp \"Pressure loss (dp = port_a.p - port_b.p)\"; -input .Modelica.SIunits.Density rho_a \"Density at port_a\"; -input .Modelica.SIunits.Density rho_b \"Density at port_b\"; -input .Modelica.SIunits.DynamicViscosity mu_a \"Dynamic viscosity at port_a (dummy if use_mu = false)\"; -input .Modelica.SIunits.DynamicViscosity mu_b \"Dynamic viscosity at port_b (dummy if use_mu = false)\"; -input .Modelica.SIunits.Length length \"Length of pipe\"; -input .Modelica.SIunits.Diameter diameter \"Inner (hydraulic) diameter of pipe\"; -input .Modelica.SIunits.Area crossArea = .Modelica.Constants.pi * diameter ^ 2 / 4 \"Inner cross section area\"; -input .Modelica.SIunits.Length roughness(min = 0) = 2.5e-5 \"Absolute roughness of pipe, with a default for a smooth steel pipe (dummy if use_roughness = false)\"; -input .Modelica.SIunits.AbsolutePressure dp_small = 1 \"Regularization of zero flow if |dp| < dp_small (dummy if use_dp_small = false)\"; -input .Modelica.SIunits.ReynoldsNumber Re_turbulent = 4000 \"Turbulent flow if Re >= Re_turbulent (dummy if use_Re_turbulent = false)\"; -output .Modelica.SIunits.MassFlowRate m_flow \"Mass flow rate from port_a to port_b\"; -end massFlowRate_dp; - -replaceable partial function 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\" -extends Modelica.Icons.Function; -input .Modelica.SIunits.Pressure dp \"Pressure loss (dp = port_a.p - port_b.p)\"; -input .Modelica.SIunits.Density rho_a \"Density at port_a\"; -input .Modelica.SIunits.Density rho_b \"Density at port_b\"; -input .Modelica.SIunits.DynamicViscosity mu_a \"Dynamic viscosity at port_a (dummy if use_mu = false)\"; -input .Modelica.SIunits.DynamicViscosity mu_b \"Dynamic viscosity at port_b (dummy if use_mu = false)\"; -input .Modelica.SIunits.Length length \"Length of pipe\"; -input .Modelica.SIunits.Diameter diameter \"Inner (hydraulic) diameter of pipe\"; -input Real g_times_height_ab \"Gravity times (Height(port_b) - Height(port_a))\"; -input .Modelica.SIunits.Area crossArea = .Modelica.Constants.pi * diameter ^ 2 / 4 \"Inner cross section area\"; -input .Modelica.SIunits.Length roughness(min = 0) = 2.5e-5 \"Absolute roughness of pipe, with a default for a smooth steel pipe (dummy if use_roughness = false)\"; -input .Modelica.SIunits.AbsolutePressure dp_small = 1 \"Regularization of zero flow if |dp| < dp_small (dummy if use_dp_small = false)\"; -input .Modelica.SIunits.ReynoldsNumber Re_turbulent = 4000 \"Turbulent flow if Re >= Re_turbulent (dummy if use_Re_turbulent = false)\"; -output .Modelica.SIunits.MassFlowRate m_flow \"Mass flow rate from port_a to port_b\"; -end massFlowRate_dp_staticHead; - -replaceable partial function 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\" -extends Modelica.Icons.Function; -input .Modelica.SIunits.MassFlowRate m_flow \"Mass flow rate from port_a to port_b\"; -input .Modelica.SIunits.Density rho_a \"Density at port_a\"; -input .Modelica.SIunits.Density rho_b \"Density at port_b\"; -input .Modelica.SIunits.DynamicViscosity mu_a \"Dynamic viscosity at port_a (dummy if use_mu = false)\"; -input .Modelica.SIunits.DynamicViscosity mu_b \"Dynamic viscosity at port_b (dummy if use_mu = false)\"; -input .Modelica.SIunits.Length length \"Length of pipe\"; -input .Modelica.SIunits.Diameter diameter \"Inner (hydraulic) diameter of pipe\"; -input .Modelica.SIunits.Area crossArea = .Modelica.Constants.pi * diameter ^ 2 / 4 \"Inner cross section area\"; -input .Modelica.SIunits.Length roughness(min = 0) = 2.5e-5 \"Absolute roughness of pipe, with a default for a smooth steel pipe (dummy if use_roughness = false)\"; -input .Modelica.SIunits.MassFlowRate m_flow_small = 0.01 \"Regularization of zero flow if |m_flow| < m_flow_small (dummy if use_m_flow_small = false)\"; -input .Modelica.SIunits.ReynoldsNumber Re_turbulent = 4000 \"Turbulent flow if Re >= Re_turbulent (dummy if use_Re_turbulent = false)\"; -output .Modelica.SIunits.Pressure dp \"Pressure loss (dp = port_a.p - port_b.p)\"; -end pressureLoss_m_flow; - -replaceable partial function pressureLoss_m_flow_staticHead \"Return pressure loss dp as function of mass flow rate m_flow, i.e., dp = f(m_flow), due to wall friction and static head\" -extends Modelica.Icons.Function; -input .Modelica.SIunits.MassFlowRate m_flow \"Mass flow rate from port_a to port_b\"; -input .Modelica.SIunits.Density rho_a \"Density at port_a\"; -input .Modelica.SIunits.Density rho_b \"Density at port_b\"; -input .Modelica.SIunits.DynamicViscosity mu_a \"Dynamic viscosity at port_a (dummy if use_mu = false)\"; -input .Modelica.SIunits.DynamicViscosity mu_b \"Dynamic viscosity at port_b (dummy if use_mu = false)\"; -input .Modelica.SIunits.Length length \"Length of pipe\"; -input .Modelica.SIunits.Diameter diameter \"Inner (hydraulic) diameter of pipe\"; -input Real g_times_height_ab \"Gravity times (Height(port_b) - Height(port_a))\"; -input .Modelica.SIunits.Area crossArea = .Modelica.Constants.pi * diameter ^ 2 / 4 \"Inner cross section area\"; -input .Modelica.SIunits.Length roughness(min = 0) = 2.5e-5 \"Absolute roughness of pipe, with a default for a smooth steel pipe (dummy if use_roughness = false)\"; -input .Modelica.SIunits.MassFlowRate m_flow_small = 0.01 \"Regularization of zero flow if |m_flow| < m_flow_small (dummy if use_m_flow_small = false)\"; -input .Modelica.SIunits.ReynoldsNumber Re_turbulent = 4000 \"Turbulent flow if Re >= Re_turbulent (dummy if use_Re_turbulent = false)\"; -output .Modelica.SIunits.Pressure dp \"Pressure loss (dp = port_a.p - port_b.p)\"; -end pressureLoss_m_flow_staticHead; -end PartialWallFriction; - -package Detailed \"Pipe wall friction for laminar and turbulent flow (detailed characteristic)\" -extends PartialWallFriction(final use_mu = true, final use_roughness = true, final use_dp_small = true, final use_m_flow_small = true, final use_Re_turbulent = true); - -redeclare function extends massFlowRate_dp \"Return mass flow rate m_flow as function of pressure loss dp, i.e., m_flow = f(dp), due to wall friction\" -protected -Real Delta = roughness / diameter \"Relative roughness\"; -.Modelica.SIunits.ReynoldsNumber Re1 = min((745 * .Modelica.Math.exp(if Delta <= 0.0065 then 1 else 0.0065 / Delta)) ^ 0.97, Re_turbulent) \"Re leaving laminar curve\"; -.Modelica.SIunits.ReynoldsNumber Re2 = Re_turbulent \"Re entering turbulent curve\"; -.Modelica.SIunits.DynamicViscosity mu \"Upstr ...[truncated 127377 chars]... 23.65898074, -0.002423804419, 4.43139566e-007, -4.35268339e-011, 1.775410633e-015}, bhigh = {88204.2938, -137.1278108}, R = 296.3827247982046); -constant IdealGases.Common.DataRecord C2H6(name = \"C2H6\", MM = 0.03006904, Hf = -2788633.890539904, H0 = 395476.3437741943, Tlimit = 1000, alow = {-186204.4161, 3406.19186, -19.51705092, 0.0756583559, -8.20417322e-005, 5.0611358e-008, -1.319281992e-011}, blow = {-27029.3289, 129.8140496}, ahigh = {5025782.13, -20330.22397, 33.2255293, -0.00383670341, 7.23840586e-007, -7.3191825e-011, 3.065468699e-015}, bhigh = {111596.395, -203.9410584}, R = 276.5127187299628); -constant IdealGases.Common.DataRecord C2H5OH(name = \"C2H5OH\", MM = 0.04606844, Hf = -5100020.751733725, H0 = 315659.1801241805, Tlimit = 1000, alow = {-234279.1392, 4479.18055, -27.44817302, 0.1088679162, -0.0001305309334, 8.437346399999999e-008, -2.234559017e-011}, blow = {-50222.29, 176.4829211}, ahigh = {4694817.65, -19297.98213, 34.4758404, -0.00323616598, 5.78494772e-007, -5.56460027e-011, 2.2262264e-015}, bhigh = {86016.22709999999, -203.4801732}, R = 180.4808671619877); -constant IdealGases.Common.DataRecord C3H6_propylene(name = \"C3H6_propylene\", MM = 0.04207974, Hf = 475288.1077687267, H0 = 322020.9535515191, Tlimit = 1000, alow = {-191246.2174, 3542.07424, -21.14878626, 0.0890148479, -0.0001001429154, 6.267959389999999e-008, -1.637870781e-011}, blow = {-15299.61824, 140.7641382}, ahigh = {5017620.34, -20860.84035, 36.4415634, -0.00388119117, 7.27867719e-007, -7.321204500000001e-011, 3.052176369e-015}, bhigh = {126124.5355, -219.5715757}, R = 197.588483198803); -constant IdealGases.Common.DataRecord C3H8(name = \"C3H8\", MM = 0.04409562, Hf = -2373931.923397381, H0 = 334301.1845620949, Tlimit = 1000, alow = {-243314.4337, 4656.27081, -29.39466091, 0.1188952745, -0.0001376308269, 8.814823909999999e-008, -2.342987994e-011}, blow = {-35403.3527, 184.1749277}, ahigh = {6420731.680000001, -26597.91134, 45.3435684, -0.00502066392, 9.471216939999999e-007, -9.57540523e-011, 4.00967288e-015}, bhigh = {145558.2459, -281.8374734}, R = 188.5555073270316); -constant IdealGases.Common.DataRecord C4H8_1_butene(name = \"C4H8_1_butene\", MM = 0.05610631999999999, Hf = -9624.584182316718, H0 = 305134.9651875226, Tlimit = 1000, alow = {-272149.2014, 5100.079250000001, -31.8378625, 0.1317754442, -0.0001527359339, 9.714761109999999e-008, -2.56020447e-011}, blow = {-25230.96386, 200.6932108}, ahigh = {6257948.609999999, -26603.76305, 47.6492005, -0.00438326711, 7.12883844e-007, -5.991020839999999e-011, 2.051753504e-015}, bhigh = {156925.2657, -291.3869761}, R = 148.1913623991023); -constant IdealGases.Common.DataRecord C4H10_n_butane(name = \"C4H10_n_butane\", MM = 0.0581222, Hf = -2164233.28779709, H0 = 330832.0228759407, Tlimit = 1000, alow = {-317587.254, 6176.331819999999, -38.9156212, 0.1584654284, -0.0001860050159, 1.199676349e-007, -3.20167055e-011}, blow = {-45403.63390000001, 237.9488665}, ahigh = {7682322.45, -32560.5151, 57.3673275, -0.00619791681, 1.180186048e-006, -1.221893698e-010, 5.250635250000001e-015}, bhigh = {177452.656, -358.791876}, R = 143.0515706563069); -constant IdealGases.Common.DataRecord C5H10_1_pentene(name = \"C5H10_1_pentene\", MM = 0.07013290000000001, Hf = -303423.9279995551, H0 = 309127.3852927798, Tlimit = 1000, alow = {-534054.813, 9298.917380000001, -56.6779245, 0.2123100266, -0.000257129829, 1.666834304e-007, -4.43408047e-011}, blow = {-47906.8218, 339.60364}, ahigh = {3744014.97, -21044.85321, 47.3612699, -0.00042442012, -3.89897505e-008, 1.367074243e-011, -9.31319423e-016}, bhigh = {115409.1373, -278.6177449000001}, R = 118.5530899192818); -constant IdealGases.Common.DataRecord C5H12_n_pentane(name = \"C5H12_n_pentane\", MM = 0.07214878, Hf = -2034130.029641527, H0 = 335196.2430965569, Tlimit = 1000, alow = {-276889.4625, 5834.28347, -36.1754148, 0.1533339707, -0.0001528395882, 8.191092e-008, -1.792327902e-011}, blow = {-46653.7525, 226.5544053}, ahigh = {-2530779.286, -8972.59326, 45.3622326, -0.002626989916, 3.135136419e-006, -5.31872894e-010, 2.886896868e-014}, bhigh = {14846.16529, -251.6550384}, R = 115.2406457877736); -constant IdealGases.Common.DataRecord C6H6(name = \"C6H6\", MM = 0.07811184, Hf = 1061042.730525872, H0 = 181735.4577743912, Tlimit = 1000, alow = {-167734.0902, 4404.50004, -37.1737791, 0.1640509559, -0.0002020812374, 1.307915264e-007, -3.4442841e-011}, blow = {-10354.55401, 216.9853345}, ahigh = {4538575.72, -22605.02547, 46.940073, -0.004206676830000001, 7.90799433e-007, -7.9683021e-011, 3.32821208e-015}, bhigh = {139146.4686, -286.8751333}, R = 106.4431717393932); -constant IdealGases.Common.DataRecord C6H12_1_hexene(name = \"C6H12_1_hexene\", MM = 0.08415948000000001, Hf = -498458.4030224521, H0 = 311788.9986962847, Tlimit = 1000, alow = {-666883.165, 11768.64939, -72.70998330000001, 0.2709398396, -0.00033332464, 2.182347097e-007, -5.85946882e-011}, blow = {-62157.8054, 428.682564}, ahigh = {733290.696, -14488.48641, 46.7121549, 0.00317297847, -5.24264652e-007, 4.28035582e-011, -1.472353254e-015}, bhigh = {66977.4041, -262.3643854}, R = 98.79424159940152); -constant IdealGases.Common.DataRecord C6H14_n_hexane(name = \"C6H14_n_hexane\", MM = 0.08617535999999999, Hf = -1936980.593988816, H0 = 333065.0431863586, Tlimit = 1000, alow = {-581592.67, 10790.97724, -66.3394703, 0.2523715155, -0.0002904344705, 1.802201514e-007, -4.617223680000001e-011}, blow = {-72715.4457, 393.828354}, ahigh = {-3106625.684, -7346.087920000001, 46.94131760000001, 0.001693963977, 2.068996667e-006, -4.21214168e-010, 2.452345845e-014}, bhigh = {523.750312, -254.9967718}, R = 96.48317105956971); -constant IdealGases.Common.DataRecord C7H14_1_heptene(name = \"C7H14_1_heptene\", MM = 0.09818605999999999, Hf = -639194.6066478277, H0 = 313588.3036756949, Tlimit = 1000, alow = {-744940.284, 13321.79893, -82.81694379999999, 0.3108065994, -0.000378677992, 2.446841042e-007, -6.488763869999999e-011}, blow = {-72178.8501, 485.667149}, ahigh = {-1927608.174, -9125.024420000002, 47.4817797, 0.00606766053, -8.684859080000001e-007, 5.81399526e-011, -1.473979569e-015}, bhigh = {26009.14656, -256.2880707}, R = 84.68077851377274); -constant IdealGases.Common.DataRecord C7H16_n_heptane(name = \"C7H16_n_heptane\", MM = 0.10020194, Hf = -1874015.612871368, H0 = 331540.487140269, Tlimit = 1000, alow = {-612743.289, 11840.85437, -74.87188599999999, 0.2918466052, -0.000341679549, 2.159285269e-007, -5.65585273e-011}, blow = {-80134.0894, 440.721332}, ahigh = {9135632.469999999, -39233.1969, 78.8978085, -0.00465425193, 2.071774142e-006, -3.4425393e-010, 1.976834775e-014}, bhigh = {205070.8295, -485.110402}, R = 82.97715593131233); -constant IdealGases.Common.DataRecord C8H10_ethylbenz(name = \"C8H10_ethylbenz\", MM = 0.106165, Hf = 281825.4603682946, H0 = 209862.0072528611, Tlimit = 1000, alow = {-469494, 9307.16836, -65.2176947, 0.2612080237, -0.000318175348, 2.051355473e-007, -5.40181735e-011}, blow = {-40738.7021, 378.090436}, ahigh = {5551564.100000001, -28313.80598, 60.6124072, 0.001042112857, -1.327426719e-006, 2.166031743e-010, -1.142545514e-014}, bhigh = {164224.1062, -369.176982}, R = 78.31650732350586); -constant IdealGases.Common.DataRecord C8H18_n_octane(name = \"C8H18_n_octane\", MM = 0.11422852, Hf = -1827477.060895125, H0 = 330740.51909278, Tlimit = 1000, alow = {-698664.715, 13385.01096, -84.1516592, 0.327193666, -0.000377720959, 2.339836988e-007, -6.01089265e-011}, blow = {-90262.2325, 493.922214}, ahigh = {6365406.949999999, -31053.64657, 69.6916234, 0.01048059637, -4.12962195e-006, 5.543226319999999e-010, -2.651436499e-014}, bhigh = {150096.8785, -416.989565}, R = 72.78805678301707); -constant IdealGases.Common.DataRecord CL2(name = \"CL2\", MM = 0.07090600000000001, Hf = 0, H0 = 129482.8364313316, Tlimit = 1000, alow = {34628.1517, -554.7126520000001, 6.20758937, -0.002989632078, 3.17302729e-006, -1.793629562e-009, 4.260043590000001e-013}, blow = {1534.069331, -9.438331107}, ahigh = {6092569.42, -19496.27662, 28.54535795, -0.01449968764, 4.46389077e-006, -6.35852586e-010, 3.32736029e-014}, bhigh = {121211.7724, -169.0778824}, R = 117.2604857134798); -constant IdealGases.Common.DataRecord F2(name = \"F2\", MM = 0.0379968064, Hf = 0, H0 = 232259.1511269747, Tlimit = 1000, alow = {10181.76308, 22.74241183, 1.97135304, 0.008151604010000001, -1.14896009e-005, 7.95865253e-009, -2.167079526e-012}, blow = {-958.6943, 11.30600296}, ahigh = {-2941167.79, 9456.5977, -7.73861615, 0.00764471299, -2.241007605e-006, 2.915845236e-010, -1.425033974e-014}, bhigh = {-60710.0561, 84.23835080000001}, R = 218.8202848542556); -constant IdealGases.Common.DataRecord H2(name = \"H2\", MM = 0.00201588, Hf = 0, H0 = 4200697.462150524, Tlimit = 1000, alow = {40783.2321, -800.918604, 8.21470201, -0.01269714457, 1.753605076e-005, -1.20286027e-008, 3.36809349e-012}, blow = {2682.484665, -30.43788844}, ahigh = {560812.801, -837.150474, 2.975364532, 0.001252249124, -3.74071619e-007, 5.936625200000001e-011, -3.6069941e-015}, bhigh = {5339.82441, -2.202774769}, R = 4124.487568704486); -constant IdealGases.Common.DataRecord H2O(name = \"H2O\", MM = 0.01801528, Hf = -13423382.81725291, H0 = 549760.6476280135, Tlimit = 1000, alow = {-39479.6083, 575.573102, 0.931782653, 0.00722271286, -7.34255737e-006, 4.95504349e-009, -1.336933246e-012}, blow = {-33039.7431, 17.24205775}, ahigh = {1034972.096, -2412.698562, 4.64611078, 0.002291998307, -6.836830479999999e-007, 9.426468930000001e-011, -4.82238053e-015}, bhigh = {-13842.86509, -7.97814851}, R = 461.5233290850878); -constant IdealGases.Common.DataRecord He(name = \"He\", MM = 0.004002602, Hf = 0, H0 = 1548349.798456104, Tlimit = 1000, alow = {0, 0, 2.5, 0, 0, 0, 0}, blow = {-745.375, 0.9287239740000001}, ahigh = {0, 0, 2.5, 0, 0, 0, 0}, bhigh = {-745.375, 0.9287239740000001}, R = 2077.26673798694); -constant IdealGases.Common.DataRecord NH3(name = \"NH3\", MM = 0.01703052, Hf = -2697510.117130892, H0 = 589713.1150428759, Tlimit = 1000, alow = {-76812.26149999999, 1270.951578, -3.89322913, 0.02145988418, -2.183766703e-005, 1.317385706e-008, -3.33232206e-012}, blow = {-12648.86413, 43.66014588}, ahigh = {2452389.535, -8040.89424, 12.71346201, -0.000398018658, 3.55250275e-008, 2.53092357e-012, -3.32270053e-016}, bhigh = {43861.91959999999, -64.62330602}, R = 488.2101075011215); -constant IdealGases.Common.DataRecord NO(name = \"NO\", MM = 0.0300061, Hf = 3041758.509103149, H0 = 305908.1320131574, Tlimit = 1000, alow = {-11439.16503, 153.6467592, 3.43146873, -0.002668592368, 8.48139912e-006, -7.685111050000001e-009, 2.386797655e-012}, blow = {9098.214410000001, 6.72872549}, ahigh = {223901.8716, -1289.651623, 5.43393603, -0.00036560349, 9.880966450000001e-008, -1.416076856e-011, 9.380184619999999e-016}, bhigh = {17503.17656, -8.50166909}, R = 277.0927244793559); -constant IdealGases.Common.DataRecord NO2(name = \"NO2\", MM = 0.0460055, Hf = 743237.6346306421, H0 = 221890.3174620426, Tlimit = 1000, alow = {-56420.3878, 963.308572, -2.434510974, 0.01927760886, -1.874559328e-005, 9.145497730000001e-009, -1.777647635e-012}, blow = {-1547.925037, 40.6785121}, ahigh = {721300.157, -3832.6152, 11.13963285, -0.002238062246, 6.54772343e-007, -7.6113359e-011, 3.32836105e-015}, bhigh = {25024.97403, -43.0513004}, R = 180.7277825477389); -constant IdealGases.Common.DataRecord N2(name = \"N2\", MM = 0.0280134, Hf = 0, H0 = 309498.4543111511, Tlimit = 1000, alow = {22103.71497, -381.846182, 6.08273836, -0.00853091441, 1.384646189e-005, -9.62579362e-009, 2.519705809e-012}, blow = {710.846086, -10.76003744}, ahigh = {587712.406, -2239.249073, 6.06694922, -0.00061396855, 1.491806679e-007, -1.923105485e-011, 1.061954386e-015}, bhigh = {12832.10415, -15.86640027}, R = 296.8033869505308); -constant IdealGases.Common.DataRecord N2O(name = \"N2O\", MM = 0.0440128, Hf = 1854006.107314236, H0 = 217685.1961247637, Tlimit = 1000, alow = {42882.2597, -644.011844, 6.03435143, 0.0002265394436, 3.47278285e-006, -3.62774864e-009, 1.137969552e-012}, blow = {11794.05506, -10.0312857}, ahigh = {343844.804, -2404.557558, 9.125636220000001, -0.000540166793, 1.315124031e-007, -1.4142151e-011, 6.38106687e-016}, bhigh = {21986.32638, -31.47805016}, R = 188.9103169986913); -constant IdealGases.Common.DataRecord Ne(name = \"Ne\", MM = 0.0201797, Hf = 0, H0 = 307111.9986917546, Tlimit = 1000, alow = {0, 0, 2.5, 0, 0, 0, 0}, blow = {-745.375, 3.35532272}, ahigh = {0, 0, 2.5, 0, 0, 0, 0}, bhigh = {-745.375, 3.35532272}, R = 412.0215860493466); -constant IdealGases.Common.DataRecord O2(name = \"O2\", MM = 0.0319988, Hf = 0, H0 = 271263.4223783392, Tlimit = 1000, alow = {-34255.6342, 484.700097, 1.119010961, 0.00429388924, -6.83630052e-007, -2.0233727e-009, 1.039040018e-012}, blow = {-3391.45487, 18.4969947}, ahigh = {-1037939.022, 2344.830282, 1.819732036, 0.001267847582, -2.188067988e-007, 2.053719572e-011, -8.193467050000001e-016}, bhigh = {-16890.10929, 17.38716506}, R = 259.8369938872708); -constant IdealGases.Common.DataRecord SO2(name = \"SO2\", MM = 0.0640638, Hf = -4633037.690552231, H0 = 164650.3485587805, Tlimit = 1000, alow = {-53108.4214, 909.031167, -2.356891244, 0.02204449885, -2.510781471e-005, 1.446300484e-008, -3.36907094e-012}, blow = {-41137.52080000001, 40.45512519}, ahigh = {-112764.0116, -825.226138, 7.61617863, -0.000199932761, 5.65563143e-008, -5.45431661e-012, 2.918294102e-016}, bhigh = {-33513.0869, -16.55776085}, R = 129.7842463294403); -constant IdealGases.Common.DataRecord SO3(name = \"SO3\", MM = 0.0800632, Hf = -4944843.573576874, H0 = 145990.9046852986, Tlimit = 1000, alow = {-39528.5529, 620.857257, -1.437731716, 0.02764126467, -3.144958662e-005, 1.792798e-008, -4.12638666e-012}, blow = {-51841.0617, 33.91331216}, ahigh = {-216692.3781, -1301.022399, 10.96287985, -0.000383710002, 8.466889039999999e-008, -9.70539929e-012, 4.49839754e-016}, bhigh = {-43982.83990000001, -36.55217314}, R = 103.8488594010732); -end SingleGasesData; -end Common; -end IdealGases; - -package Incompressible \"Medium model for T-dependent properties, defined by tables or polynomials\" -extends Modelica.Icons.VariantsPackage; - -package Common \"Common data structures\" -extends Modelica.Icons.Package; - -record BaseProps_Tpoly \"Fluid state record\" -extends Modelica.Icons.Record; -.Modelica.SIunits.Temperature T \"Temperature\"; -.Modelica.SIunits.Pressure p \"Pressure\"; -end BaseProps_Tpoly; -end Common; - -package TableBased \"Incompressible medium properties based on tables\" -extends Modelica.Media.Interfaces.PartialMedium(ThermoStates = if enthalpyOfT then Modelica.Media.Interfaces.Choices.IndependentVariables.T else Modelica.Media.Interfaces.Choices.IndependentVariables.pT, final reducedX = true, final fixedX = true, mediumName = \"tableMedium\", redeclare record ThermodynamicState = Common.BaseProps_Tpoly, singleState = true, reference_p = 1.013e5, Temperature(min = T_min, max = T_max)); -constant Boolean enthalpyOfT = true \"True if enthalpy is approximated as a function of T only, (p-dependence neglected)\"; -constant Boolean densityOfT = size(tableDensity, 1) > 1 \"True if density is a function of temperature\"; -constant Modelica.SIunits.Temperature T_min \"Minimum temperature valid for medium model\"; -constant Modelica.SIunits.Temperature T_max \"Maximum temperature valid for medium model\"; -constant Temperature T0 = 273.15 \"Reference Temperature\"; -constant SpecificEnthalpy h0 = 0 \"Reference enthalpy at T0, reference_p\"; -constant SpecificEntropy s0 = 0 \"Reference entropy at T0, reference_p\"; -constant MolarMass MM_const = 0.1 \"Molar mass\"; -constant Integer npol = 2 \"Degree of polynomial used for fitting\"; -constant Integer npolDensity = npol \"Degree of polynomial used for fitting rho(T)\"; -constant Integer npolHeatCapacity = npol \"Degree of polynomial used for fitting Cp(T)\"; -constant Integer npolViscosity = npol \"Degree of polynomial used for fitting eta(T)\"; -constant Integer npolVaporPressure = npol \"Degree of polynomial used for fitting pVap(T)\"; -constant Integer npolConductivity = npol \"Degree of polynomial used for fitting lambda(T)\"; -constant Integer neta = size(tableViscosity, 1) \"Number of data points for viscosity\"; -constant Real[:, 2] tableDensity \"Table for rho(T)\"; -constant Real[:, 2] tableHeatCapacity \"Table for Cp(T)\"; -constant Real[:, 2] tableViscosity \"Table for eta(T)\"; -constant Real[:, 2] tableVaporPressure \"Table for pVap(T)\"; -constant Real[:, 2] tableConductivity \"Table for lambda(T)\"; -constant Boolean TinK \"True if T[K],Kelvin used for table temperatures\"; -constant Boolean hasDensity = not size(tableDensity, 1) == 0 \"True if table tableDensity is present\"; -constant Boolean hasHeatCapacity = not size(tableHeatCapacity, 1) == 0 \"True if table tableHeatCapacity is present\"; -constant Boolean hasViscosity = not size(tableViscosity, 1) == 0 \"True if table tableViscosity is present\"; -constant Boolean hasVaporPressure = not size(tableVaporPressure, 1) == 0 \"True if table tableVaporPressure is present\"; -final constant Real[neta] invTK = if size(tableViscosity, 1) > 0 then if TinK then 1 ./ tableViscosity[:, 1] else 1 ./ .Modelica.SIunits.Conversions.from_degC(tableViscosity[:, 1]) else fill(0, neta); -final constant Real[:] poly_rho = if hasDensity then Polynomials_Temp.fitting(tableDensity[:, 1], tableDensity[:, 2], npolDensity) else zeros(npolDensity + 1); -final constant Real[:] poly_Cp = if hasHeatCapacity then Polynomials_Temp.fitting(tableHeatCapacity[:, 1], tableHeatCapacity[:, 2], npolHeatCapacity) else zeros(npolHeatCapacity + 1); -final constant Real[:] poly_eta = if hasViscosity then Polynomials_Temp.fitting(invTK, .Modelica.Math.log(tableViscosity[:, 2]), npolViscosity) else zeros(npolViscosity + 1); -final constant Real[:] poly_lam = if size(tableConductivity, 1) > 0 then Polynomials_Temp.fitting(tableConductivity[:, 1], tableConductivity[:, 2], npolConductivity) else zeros(npolConductivity + 1); - -redeclare model extends BaseProperties(final standardOrderComponents = true, p_bar = .Modelica.SIunits.Conversions.to_bar(p), T_degC(start = T_start - 273.15) = .Modelica.SIunits.Conversions.to_degC(T), T(start = T_start, stateSelect = if preferredMediumStates then StateSelect.prefer else StateSelect.default)) \"Base properties of T dependent medium\" -.Modelica.SIunits.SpecificHeatCapacity cp \"Specific heat capacity\"; -parameter .Modelica.SIunits.Temperature T_start = 298.15 \"Initial temperature\"; -equation -assert(hasDensity, \"Medium \" + mediumName + \" can not be used without assigning tableDensity.\"); -assert(T >= T_min and T <= T_max, \"Temperature T (= \" + String(T) + \" K) is not in the allowed range (\" + String(T_min) + \" K <= T <= \" + String(T_max) + \" K) required from medium model \\\"\" + mediumName + \"\\\".\"); -R = Modelica.Constants.R; -cp = Polynomials_Temp.evaluate(poly_Cp, if TinK then T else T_degC); -h = if enthalpyOfT then h_T(T) else h_pT(p, T, densityOfT); -u = h - (if singleState then reference_p / d else state.p / d); -d = Polynomials_Temp.evaluate(poly_rho, if TinK then T else T_degC); -state.T = T; -state.p = p; -MM = MM_const; -end BaseProperties; - -redeclare function extends setState_pTX \"Returns state record, given pressure and temperature\" -algorithm -state := ThermodynamicState(p = p, T = T); -annotation(smoothOrder = 3); -end setState_pTX; - -redeclare function extends setState_dTX \"Returns state record, given pressure and temperature\" -algorithm -assert(false, \"For incompressible media with d(T) only, state can not be set from density and temperature\"); -end setState_dTX; - -redeclare function extends setState_phX \"Returns state record, given pressure and specific enthalpy\" -algorithm -state := ThermodynamicState(p = p, T = T_ph(p, h)); -annotation(Inline = true, smoothOrder = 3); -end setState_phX; - -redeclare function extends setState_psX \"Returns state record, given pressure and specific entropy\" -algorithm -state := ThermodynamicState(p = p, T = T_ps(p, s)); -annotation(Inline = true, smoothOrder = 3); -end setState_psX; - -redeclare function extends setSmoothState \"Return thermodynamic state so that it smoothly approximates: if x > 0 then state_a else state_b\" -algorithm -state := ThermodynamicState(p = Media.Common.smoothStep(x, state_a.p, state_b.p, x_small), T = Media.Common.smoothStep(x, state_a.T, state_b.T, x_small)); -annotation(Inline = true, smoothOrder = 3); -end setSmoothState; - -redeclare function extends specificHeatCapacityCv \"Specific heat capacity at constant volume (or pressure) of medium\" -algorithm -assert(hasHeatCapacity, \"Specific Heat Capacity, Cv, is not defined for medium \" + mediumName + \".\"); -cv := Polynomials_Temp.evaluate(poly_Cp, if TinK then state.T else state.T - 273.15); -annotation(smoothOrder = 2); -end specificHeatCapacityCv; - -redeclare function extends specificHeatCapacityCp \"Specific heat capacity at constant volume (or pressure) of medium\" -algorithm -assert(hasHeatCapacity, \"Specific Heat Capacity, Cv, is not defined for medium \" + mediumName + \".\"); -cp := Polynomials_Temp.evaluate(poly_Cp, if TinK then state.T else state.T - 273.15); -annotation(smoothOrder = 2); -end specificHeatCapacityCp; - -redeclare function extends dynamicViscosity \"Return dynamic viscosity as a function of the thermodynamic state record\" -algorithm -assert(size(tableViscosity, 1) > 0, \"DynamicViscosity, eta, is not defined for medium \" + mediumName + \".\"); -eta := .Modelica.Math.exp(Polynomials_Temp.evaluate(poly_eta, 1 / state.T)); -annotation(smoothOrder = 2); -end dynamicViscosity; - -redeclare function extends thermalConductivity \"Return thermal conductivity as a function of the thermodynamic state record\" -algorithm -assert(size(tableConductivity, 1) > 0, \"ThermalConductivity, lambda, is not defined for medium \" + mediumName + \".\"); -lambda := Polynomials_Temp.evaluate(poly_lam, if TinK then state.T else .Modelica.SIunits.Conversions.to_degC(state.T)); -annotation(smoothOrder = 2); -end thermalConductivity; - -function s_T \"Compute specific entropy\" -extends Modelica.Icons.Function; -input Temperature T \"Temperature\"; -output SpecificEntropy s \"Specific entropy\"; -algorithm -s := s0 + (if TinK then Polynomials_Temp.integralValue(poly_Cp[1:npol], T, T0) else Polynomials_Temp.integralValue(poly_Cp[1:npol], .Modelica.SIunits.Conversions.to_degC(T), .Modelica.SIunits.Conversions.to_degC(T0))) + Modelica.Math.log(T / T0) * Polynomials_Temp.evaluate(poly_Cp, if TinK then 0 else Modelica.Constants.T_zero); -annotation(Inline = true, smoothOrder = 2); -end s_T; - -redeclare function extends specificEntropy \"Return specific entropy -as a function of the thermodynamic state record\" -protected -Integer npol = size(poly_Cp, 1) - 1; -algorithm -assert(hasHeatCapacity, \"Specific Entropy, s(T), is not defined for medium \" + mediumName + \".\"); -s := s_T(state.T); -annotation(smoothOrder = 2); -end specificEntropy; - -function h_T \"Compute specific enthalpy from temperature\" -extends Modelica.Icons.Function; -input .Modelica.SIunits.Temperature T \"Temperature\"; -output .Modelica.SIunits.SpecificEnthalpy h \"Specific enthalpy at p, T\"; -algorithm -h := h0 + Polynomials_Temp.integralValue(poly_Cp, if TinK then T else .Modelica.SIunits.Conversions.to_degC(T), if TinK then T0 else .Modelica.SIunits.Conversions.to_degC(T0)); -annotation(derivative = h_T_der); -end h_T; - -function h_T_der \"Compute specific enthalpy from temperature\" -extends Modelica.Icons.Function; -input .Modelica.SIunits.Temperature T \"Temperature\"; -input Real dT \"Temperature derivative\"; -output Real dh \"Derivative of Specific enthalpy at T\"; -algorithm -dh := Polynomials_Temp.evaluate(poly_Cp, if TinK then T else .Modelica.SIunits.Conversions.to_degC(T)) * dT; -annotation(smoothOrder = 1); -end h_T_der; - -function h_pT \"Compute specific enthalpy from pressure and temperature\" -extends Modelica.Icons.Function; -input .Modelica.SIunits.Pressure p \"Pressure\"; -input .Modelica.SIunits.Temperature T \"Temperature\"; -input Boolean densityOfT = false \"Include or neglect density derivative dependence of enthalpy\"; -output .Modelica.SIunits.SpecificEnthalpy h \"Specific enthalpy at p, T\"; -algorithm -h := h0 + Polynomials_Temp.integralValue(poly_Cp, if TinK then T else .Modelica.SIunits.Conversions.to_degC(T), if TinK then T0 else .Modelica.SIunits.Conversions.to_degC(T0)) + (p - reference_p) / Polynomials_Temp.evaluate(poly_rho, if TinK then T else .Modelica.SIunits.Conversions.to_degC(T)) * (if densityOfT then 1 + T / Polynomials_Temp.evaluate(poly_rho, if TinK then T else .Modelica.SIunits.Conversions.to_degC(T)) * Polynomials_Temp.derivativeValue(poly_rho, if TinK then T else .Modelica.SIunits.Conversions.to_degC(T)) else 1.0); -annotation(smoothOrder = 2); -end h_pT; - -redeclare function extends temperature \"Return temperature as a function of the thermodynamic state record\" -algorithm -T := state.T; -annotation(Inline = true, smoothOrder = 2); -end temperature; - -redeclare function extends pressure \"Return pressure as a function of the thermodynamic state record\" -algorithm -p := state.p; -annotation(Inline = true, smoothOrder = 2); -end pressure; - -redeclare function extends density \"Return density as a function of the thermodynamic state record\" -algorithm -d := Polynomials_Temp.evaluate(poly_rho, if TinK then state.T else .Modelica.SIunits.Conversions.to_degC(state.T)); -annotation(Inline = true, smoothOrder = 2); -end density; - -redeclare function extends specificEnthalpy \"Return specific enthalpy as a function of the thermodynamic state record\" -algorithm -h := if enthalpyOfT then h_T(state.T) else h_pT(state.p, state.T); -annotation(Inline = true, smoothOrder = 2); -end specificEnthalpy; - -redeclare function extends specificInternalEnergy \"Return specific internal energy as a function of the thermodynamic state record\" -algorithm -u := (if enthalpyOfT then h_T(state.T) else h_pT(state.p, state.T)) - (if singleState then reference_p else state.p) / density(state); -annotation(Inline = true, smoothOrder = 2); -end specificInternalEnergy; - -function T_ph \"Compute temperature from pressure and specific enthalpy\" -extends Modelica.Icons.Function; -input AbsolutePressure p \"Pressure\"; -input SpecificEnthalpy h \"Specific enthalpy\"; -output Temperature T \"Temperature\"; - -protected -package Internal \"Solve h(T) for T with given h (use only indirectly via temperature_phX)\" -extends Modelica.Media.Common.OneNonLinearEquation; - -redeclare record extends f_nonlinear_Data \"Superfluous record, fix later when better structure of inverse functions exists\" -constant Real[5] dummy = {1, 2, 3, 4, 5}; -end f_nonlinear_Data; - -redeclare function extends f_nonlinear \"P is smuggled in via vector\" -algorithm -y := if singleState then h_T(x) else h_pT(p, x); -end f_nonlinear; -end Internal; -algorithm -T := Internal.solve(h, T_min, T_max, p, {1}, Internal.f_nonlinear_Data()); -annotation(Inline = false, LateInline = true, inverse(h = h_pT(p, T))); -end T_ph; - -function T_ps \"Compute temperature from pressure and specific enthalpy\" -extends Modelica.Icons.Function; -input AbsolutePressure p \"Pressure\"; -input SpecificEntropy s \"Specific entropy\"; -output Temperature T \"Temperature\"; - -protected -package Internal \"Solve h(T) for T with given h (use only indirectly via temperature_phX)\" -extends Modelica.Media.Common.OneNonLinearEquation; - -redeclare record extends f_nonlinear_Data \"Superfluous record, fix later when better structure of inverse functions exists\" -constant Real[5] dummy = {1, 2, 3, 4, 5}; -end f_nonlinear_Data; - -redeclare function extends f_nonlinear \"P is smuggled in via vector\" -algorithm -y := s_T(x); -end f_nonlinear; -end Internal; -algorithm -T := Internal.solve(s, T_min, T_max, p, {1}, Internal.f_nonlinear_Data()); -end T_ps; - -package Polynomials_Temp \"Temporary Functions operating on polynomials (including polynomial fitting); only to be used in Modelica.Media.Incompressible.TableBased\" -extends Modelica.Icons.Package; - -function evaluate \"Evaluate polynomial at a given abscissa value\" -extends Modelica.Icons.Function; -input Real[:] p \"Polynomial coefficients (p[1] is coefficient of highest power)\"; -input Real u \"Abscissa value\"; -output Real y \"Value of polynomial at u\"; -algorithm -y := p[1]; -for j in 2:size(p, 1) loop -y := p[j] + u * y; -end for; -annotation(derivative(zeroDerivative = p) = evaluate_der); -end evaluate; - -function evaluateWithRange \"Evaluate polynomial at a given abscissa value with linear extrapolation outside of the defined range\" -extends Modelica.Icons.Function; -input Real[:] p \"Polynomial coefficients (p[1] is coefficient of highest power)\"; -input Real uMin \"Polynomial valid in the range uMin .. uMax\"; -input Real uMax \"Polynomial valid in the range uMin .. uMax\"; -input Real u \"Abscissa value\"; -output Real y \"Value of polynomial at u. Outside of uMin,uMax, linear extrapolation is used\"; -algorithm -if u < uMin then -y := evaluate(p, uMin) - evaluate_der(p, uMin, uMin - u); -elseif u > uMax then -y := evaluate(p, uMax) + evaluate_der(p, uMax, u - uMax); -else -y := evaluate(p, u); -end if; -annotation(derivative(zeroDerivative = p, zeroDerivative = uMin, zeroDerivative = uMax) = evaluateWithRange_der); -end evaluateWithRange; - -function derivativeValue \"Value of derivative of polynomial at abscissa value u\" -extends Modelica.Icons.Function; -input Real[:] p \"Polynomial coefficients (p[1] is coefficient of highest power)\"; -input Real u \"Abscissa value\"; -output Real y \"Value of derivative of polynomial at u\"; -protected -Integer n = size(p, 1); -algorithm -y := p[1] * (n - 1); -for j in 2:size(p, 1) - 1 loop -y := p[j] * (n - j) + u * y; -end for; -annotation(derivative(zeroDerivative = p) = derivativeValue_der); -end derivativeValue; - -function secondDerivativeValue \"Value of 2nd derivative of polynomial at abscissa value u\" -extends Modelica.Icons.Function; -input Real[:] p \"Polynomial coefficients (p[1] is coefficient of highest power)\"; -input Real u \"Abscissa value\"; -output Real y \"Value of 2nd derivative of polynomial at u\"; -protected -Integer n = size(p, 1); -algorithm -y := p[1] * (n - 1) * (n - 2); -for j in 2:size(p, 1) - 2 loop -y := p[j] * (n - j) * (n - j - 1) + u * y; -end for; -end secondDerivativeValue; - -function integralValue \"Integral of polynomial p(u) from u_low to u_high\" -extends Modelica.Icons.Function; -input Real[:] p \"Polynomial coefficients\"; -input Real u_high \"High integrand value\"; -input Real u_low = 0 \"Low integrand value, default 0\"; -output Real integral = 0.0 \"Integral of polynomial p from u_low to u_high\"; -protected -Integer n = size(p, 1) \"Degree of integrated polynomial\"; -Real y_low = 0 \"Value at lower integrand\"; -algorithm -for j in 1:n loop -integral := u_high * (p[j] / (n - j + 1) + integral); -y_low := u_low * (p[j] / (n - j + 1) + y_low); -end for; -integral := integral - y_low; -annotation(derivative(zeroDerivative = p) = integralValue_der); -end integralValue; - -function fitting \"Computes the coefficients of a polynomial that fits a set of data points in a least-squares sense\" -extends Modelica.Icons.Function; -input Real[:] u \"Abscissa data values\"; -input Real[size(u, 1)] y \"Ordinate data values\"; -input Integer n(min = 1) \"Order of desired polynomial that fits the data points (u,y)\"; -output Real[n + 1] p \"Polynomial coefficients of polynomial that fits the date points\"; -protected -Real[size(u, 1), n + 1] V \"Vandermonde matrix\"; -algorithm -V[:, n + 1] := ones(size(u, 1)); -for j in n:(-1):1 loop -V[:, j] := {u[i] * V[i, j + 1] for i in 1:size(u, 1)}; -end for; -p := Modelica.Math.Matrices.leastSquares(V, y); -end fitting; - -function evaluate_der \"Evaluate derivative of polynomial at a given abscissa value\" -extends Modelica.Icons.Function; -input Real[:] p \"Polynomial coefficients (p[1] is coefficient of highest power)\"; -input Real u \"Abscissa value\"; -input Real du \"Delta of abscissa value\"; -output Real dy \"Value of derivative of polynomial at u\"; -protected -Integer n = size(p, 1); -algorithm -dy := p[1] * (n - 1); -for j in 2:size(p, 1) - 1 loop -dy := p[j] * (n - j) + u * dy; -end for; -dy := dy * du; -end evaluate_der; - -function evaluateWithRange_der \"Evaluate derivative of polynomial at a given abscissa value with extrapolation outside of the defined range\" -extends Modelica.Icons.Function; -input Real[:] p \"Polynomial coefficients (p[1] is coefficient of highest power)\"; -input Real uMin \"Polynomial valid in the range uMin .. uMax\"; -input Real uMax \"Polynomial valid in the range uMin .. uMax\"; -input Real u \"Abscissa value\"; -input Real du \"Delta of abscissa value\"; -output Real dy \"Value of derivative of polynomial at u\"; -algorithm -if u < uMin then -dy := evaluate_der(p, uMin, du); -elseif u > uMax then -dy := evaluate_der(p, uMax, du); -else -dy := evaluate_der(p, u, du); -end if; -end evaluateWithRange_der; - -function integralValue_der \"Time derivative of integral of polynomial p(u) from u_low to u_high, assuming only u_high as time-dependent (Leibnitz rule)\" -extends Modelica.Icons.Function; -input Real[:] p \"Polynomial coefficients\"; -input Real u_high \"High integrand value\"; -input Real u_low = 0 \"Low integrand value, default 0\"; -input Real du_high \"High integrand value\"; -input Real du_low = 0 \"Low integrand value, default 0\"; -output Real dintegral = 0.0 \"Integral of polynomial p from u_low to u_high\"; -algorithm -dintegral := evaluate(p, u_high) * du_high; -end integralValue_der; - -function derivativeValue_der \"Time derivative of derivative of polynomial\" -extends Modelica.Icons.Function; -input Real[:] p \"Polynomial coefficients (p[1] is coefficient of highest power)\"; -input Real u \"Abscissa value\"; -input Real du \"Delta of abscissa value\"; -output Real dy \"Time-derivative of derivative of polynomial w.r.t. input variable at u\"; -protected -Integer n = size(p, 1); -algorithm -dy := secondDerivativeValue(p, u) * du; -end derivativeValue_der; -end Polynomials_Temp; -end TableBased; -end Incompressible; -end Media; - -package Thermal \"Library of thermal system components to model heat transfer and simple thermo-fluid pipe flow\" -extends Modelica.Icons.Package; - -package HeatTransfer \"Library of 1-dimensional heat transfer with lumped elements\" -extends Modelica.Icons.Package; - -package Sources \"Thermal sources\" -extends Modelica.Icons.SourcesPackage; - -model FixedHeatFlow \"Fixed heat flow boundary condition\" -parameter Modelica.SIunits.HeatFlowRate Q_flow \"Fixed heat flow rate at port\"; -parameter Modelica.SIunits.Temperature T_ref = 293.15 \"Reference temperature\"; -parameter Modelica.SIunits.LinearTemperatureCoefficient alpha = 0 \"Temperature coefficient of heat flow rate\"; -Interfaces.HeatPort_b port; -equation -port.Q_flow = -Q_flow * (1 + alpha * (port.T - T_ref)); -end FixedHeatFlow; -end Sources; - -package Interfaces \"Connectors and partial models\" -extends Modelica.Icons.InterfacesPackage; - -partial connector HeatPort \"Thermal port for 1-dim. heat transfer\" -Modelica.SIunits.Temperature T \"Port temperature\"; -flow Modelica.SIunits.HeatFlowRate Q_flow \"Heat flow rate (positive if flowing from outside into the component)\"; -end HeatPort; - -connector HeatPort_b \"Thermal port for 1-dim. heat transfer (unfilled rectangular icon)\" -extends HeatPort; -end HeatPort_b; -end Interfaces; -end HeatTransfer; -end Thermal; - -package Math \"Library of mathematical functions (e.g., sin, cos) and of functions operating on vectors and matrices\" -extends Modelica.Icons.Package; - -package Icons \"Icons for Math\" -extends Modelica.Icons.IconsPackage; - -partial function AxisLeft \"Basic icon for mathematical function with y-axis on left side\" end AxisLeft; - -partial function AxisCenter \"Basic icon for mathematical function with y-axis in the center\" end AxisCenter; -end Icons; - -package Matrices \"Library of functions operating on matrices\" -extends Modelica.Icons.Package; - -function leastSquares \"Solve linear equation A*x = b (exactly if possible, or otherwise in a least square sense; A may be non-square and may be rank deficient)\" -extends Modelica.Icons.Function; -input Real[:, :] A \"Matrix A\"; -input Real[size(A, 1)] b \"Vector b\"; -input Real rcond = 100 * Modelica.Constants.eps \"Reciprocal condition number to estimate the rank of A\"; -output Real[size(A, 2)] x \"Vector x such that min|A*x-b|^2 if size(A,1) >= size(A,2) or min|x|^2 and A*x=b, if size(A,1) < size(A,2)\"; -output Integer rank \"Rank of A\"; -protected -Integer info; -Real[max(size(A, 1), size(A, 2))] xx; -algorithm -if min(size(A)) > 0 then -(xx, info, rank) := LAPACK.dgelsx_vec(A, b, rcond); -x := xx[1:size(A, 2)]; -assert(info == 0, \"Solving an overdetermined or underdetermined linear system\\n\" + \"of equations with function \\\"Matrices.leastSquares\\\" failed.\"); -else -x := fill(0.0, size(A, 2)); -end if; -end leastSquares; - -package LAPACK \"Interface to LAPACK library (should usually not directly be used but only indirectly via Modelica.Math.Matrices)\" -extends Modelica.Icons.Package; - -function dgelsx_vec \"Computes the minimum-norm solution to a real linear least squares problem with rank deficient A\" -extends Modelica.Icons.Function; -input Real[:, :] A; -input Real[size(A, 1)] b; -input Real rcond = 0.0 \"Reciprocal condition number to estimate rank\"; -output Real[max(size(A, 1), size(A, 2))] x = cat(1, b, zeros(max(nrow, ncol) - nrow)) \"solution is in first size(A,2) rows\"; -output Integer info; -output Integer rank \"Effective rank of A\"; -protected -Integer nrow = size(A, 1); -Integer ncol = size(A, 2); -Integer nx = max(nrow, ncol); -Real[max(min(size(A, 1), size(A, 2)) + 3 * size(A, 2), 2 * min(size(A, 1), size(A, 2)) + 1)] work; -Real[size(A, 1), size(A, 2)] Awork = A; -Integer[size(A, 2)] jpvt = zeros(ncol); -external \"FORTRAN 77\" dgelsx(nrow, ncol, 1, Awork, nrow, x, nx, jpvt, rcond, rank, work, info) annotation(Library = \"lapack\"); -end dgelsx_vec; -end LAPACK; -end Matrices; - -function cos \"Cosine\" -extends Modelica.Math.Icons.AxisLeft; -input .Modelica.SIunits.Angle u; -output Real y; -external \"builtin\" y = cos(u); -end cos; - -function tan \"Tangent (u shall not be -pi/2, pi/2, 3*pi/2, ...)\" -extends Modelica.Math.Icons.AxisCenter; -input .Modelica.SIunits.Angle u; -output Real y; -external \"builtin\" y = tan(u); -end tan; - -function asin \"Inverse sine (-1 <= u <= 1)\" -extends Modelica.Math.Icons.AxisCenter; -input Real u; -output .Modelica.SIunits.Angle y; -external \"builtin\" y = asin(u); -end asin; - -function cosh \"Hyperbolic cosine\" -extends Modelica.Math.Icons.AxisCenter; -input Real u; -output Real y; -external \"builtin\" y = cosh(u); -end cosh; - -function tanh \"Hyperbolic tangent\" -extends Modelica.Math.Icons.AxisCenter; -input Real u; -output Real y; -external \"builtin\" y = tanh(u); -end tanh; - -function exp \"Exponential, base e\" -extends Modelica.Math.Icons.AxisCenter; -input Real u; -output Real y; -external \"builtin\" y = exp(u); -end exp; - -function log \"Natural (base e) logarithm (u shall be > 0)\" -extends Modelica.Math.Icons.AxisLeft; -input Real u; -output Real y; -external \"builtin\" y = log(u); -end log; - -function log10 \"Base 10 logarithm (u shall be > 0)\" -extends Modelica.Math.Icons.AxisLeft; -input Real u; -output Real y; -external \"builtin\" y = log10(u); -end log10; -end Math; - -package Utilities \"Library of utility functions dedicated to scripting (operating on files, streams, strings, system)\" -extends Modelica.Icons.Package; - -package Streams \"Read from files and write to files\" -extends Modelica.Icons.Package; - -function error \"Print error message and cancel all actions\" -extends Modelica.Icons.Function; -input String string \"String to be printed to error message window\"; -external \"C\" ModelicaError(string) annotation(Library = \"ModelicaExternalC\"); -end error; -end Streams; -end Utilities; - -package Constants \"Library of mathematical constants and constants of nature (e.g., pi, eps, R, sigma)\" -extends Modelica.Icons.Package; -final constant Real pi = 2 * Math.asin(1.0); -final constant Real eps = ModelicaServices.Machine.eps \"Biggest number such that 1.0 + eps = 1.0\"; -final constant Real inf = ModelicaServices.Machine.inf \"Biggest Real number such that inf and -inf are representable on the machine\"; -final constant .Modelica.SIunits.Velocity c = 299792458 \"Speed of light in vacuum\"; -final constant .Modelica.SIunits.Acceleration g_n = 9.80665 \"Standard acceleration of gravity on earth\"; -final constant Real R(final unit = \"J/(mol.K)\") = 8.314472 \"Molar gas constant\"; -final constant Real mue_0(final unit = \"N/A2\") = 4 * pi * 1.e-7 \"Magnetic constant\"; -final constant .Modelica.SIunits.Conversions.NonSIunits.Temperature_degC T_zero = -273.15 \"Absolute zero temperature\"; -end Constants; - -package Icons \"Library of icons\" -extends Icons.Package; - -partial package ExamplesPackage \"Icon for packages containing runnable examples\" -extends Modelica.Icons.Package; -end ExamplesPackage; - -partial model Example \"Icon for runnable examples\" end Example; - -partial package Package \"Icon for standard packages\" end Package; - -partial package BasesPackage \"Icon for packages containing base classes\" -extends Modelica.Icons.Package; -end BasesPackage; - -partial package VariantsPackage \"Icon for package containing variants\" -extends Modelica.Icons.Package; -end VariantsPackage; - -partial package InterfacesPackage \"Icon for packages containing interfaces\" -extends Modelica.Icons.Package; -end InterfacesPackage; - -partial package SourcesPackage \"Icon for packages containing sources\" -extends Modelica.Icons.Package; -end SourcesPackage; - -partial package UtilitiesPackage \"Icon for utility packages\" -extends Modelica.Icons.Package; -end UtilitiesPackage; - -partial package TypesPackage \"Icon for packages containing type definitions\" -extends Modelica.Icons.Package; -end TypesPackage; - -partial package IconsPackage \"Icon for packages containing icons\" -extends Modelica.Icons.Package; -end IconsPackage; - -partial package InternalPackage \"Icon for an internal package (indicating that the package should not be directly utilized by user)\" end InternalPackage; - -partial package MaterialPropertiesPackage \"Icon for package containing property classes\" -extends Modelica.Icons.Package; -end MaterialPropertiesPackage; - -partial function Function \"Icon for functions\" end Function; - -partial record Record \"Icon for records\" end Record; -end Icons; - -package SIunits \"Library of type and unit definitions based on SI units according to ISO 31-1992\" -extends Modelica.Icons.Package; - -package Icons \"Icons for SIunits\" -extends Modelica.Icons.IconsPackage; - -partial function Conversion \"Base icon for conversion functions\" end Conversion; -end Icons; - -package Conversions \"Conversion functions to/from non SI units and type definitions of non SI units\" -extends Modelica.Icons.Package; - -package NonSIunits \"Type definitions of non SI units\" -extends Modelica.Icons.Package; -type Temperature_degC = Real(final quantity = \"ThermodynamicTemperature\", final unit = \"degC\") \"Absolute temperature in degree Celsius (for relative temperature use SIunits.TemperatureDifference)\" annotation(absoluteValue = true); -type Pressure_bar = Real(final quantity = \"Pressure\", final unit = \"bar\") \"Absolute pressure in bar\"; -end NonSIunits; - -function to_degC \"Convert from Kelvin to degCelsius\" -extends Modelica.SIunits.Icons.Conversion; -input Temperature Kelvin \"Kelvin value\"; -output NonSIunits.Temperature_degC Celsius \"Celsius value\"; -algorithm -Celsius := Kelvin + Modelica.Constants.T_zero; -annotation(Inline = true); -end to_degC; - -function from_degC \"Convert from degCelsius to Kelvin\" -extends Modelica.SIunits.Icons.Conversion; -input NonSIunits.Temperature_degC Celsius \"Celsius value\"; -output Temperature Kelvin \"Kelvin value\"; -algorithm -Kelvin := Celsius - Modelica.Constants.T_zero; -annotation(Inline = true); -end from_degC; - -function to_bar \"Convert from Pascal to bar\" -extends Modelica.SIunits.Icons.Conversion; -input Pressure Pa \"Pascal value\"; -output NonSIunits.Pressure_bar bar \"bar value\"; -algorithm -bar := Pa / 1e5; -annotation(Inline = true); -end to_bar; -end Conversions; - -type Angle = Real(final quantity = \"Angle\", final unit = \"rad\", displayUnit = \"deg\"); -type Length = Real(final quantity = \"Length\", final unit = \"m\"); -type Height = Length(min = 0); -type Diameter = Length(min = 0); -type Area = Real(final quantity = \"Area\", final unit = \"m2\"); -type Volume = Real(final quantity = \"Volume\", final unit = \"m3\"); -type Time = Real(final quantity = \"Time\", final unit = \"s\"); -type Velocity = Real(final quantity = \"Velocity\", final unit = \"m/s\"); -type Acceleration = Real(final quantity = \"Acceleration\", final unit = \"m/s2\"); -type Mass = Real(quantity = \"Mass\", final unit = \"kg\", min = 0); -type Density = Real(final quantity = \"Density\", final unit = \"kg/m3\", displayUnit = \"g/cm3\", min = 0.0); -type Momentum = Real(final quantity = \"Momentum\", final unit = \"kg.m/s\"); -type Force = Real(final quantity = \"Force\", final unit = \"N\"); -type Pressure = Real(final quantity = \"Pressure\", final unit = \"Pa\", displayUnit = \"bar\"); -type AbsolutePressure = Pressure(min = 0.0, nominal = 1e5); -type DynamicViscosity = Real(final quantity = \"DynamicViscosity\", final unit = \"Pa.s\", min = 0); -type Energy = Real(final quantity = \"Energy\", final unit = \"J\"); -type Power = Real(final quantity = \"Power\", final unit = \"W\"); -type EnthalpyFlowRate = Real(final quantity = \"EnthalpyFlowRate\", final unit = \"W\"); -type MassFlowRate = Real(quantity = \"MassFlowRate\", final unit = \"kg/s\"); -type MomentumFlux = Real(final quantity = \"MomentumFlux\", final unit = \"N\"); -type ThermodynamicTemperature = Real(final quantity = \"ThermodynamicTemperature\", final unit = \"K\", min = 0.0, start = 288.15, nominal = 300, displayUnit = \"degC\") \"Absolute temperature (use type TemperatureDifference for relative temperatures)\" annotation(absoluteValue = true); -type Temperature = ThermodynamicTemperature; -type LinearTemperatureCoefficient = Real(final quantity = \"LinearTemperatureCoefficient\", final unit = \"1/K\"); -type Compressibility = Real(final quantity = \"Compressibility\", final unit = \"1/Pa\"); -type IsothermalCompressibility = Compressibility; -type HeatFlowRate = Real(final quantity = \"Power\", final unit = \"W\"); -type ThermalConductivity = Real(final quantity = \"ThermalConductivity\", final unit = \"W/(m.K)\"); -type CoefficientOfHeatTransfer = Real(final quantity = \"CoefficientOfHeatTransfer\", final unit = \"W/(m2.K)\"); -type SpecificHeatCapacity = Real(final quantity = \"SpecificHeatCapacity\", final unit = \"J/(kg.K)\"); -type RatioOfSpecificHeatCapacities = Real(final quantity = \"RatioOfSpecificHeatCapacities\", final unit = \"1\"); -type Entropy = Real(final quantity = \"Entropy\", final unit = \"J/K\"); -type SpecificEntropy = Real(final quantity = \"SpecificEntropy\", final unit = \"J/(kg.K)\"); -type SpecificEnergy = Real(final quantity = \"SpecificEnergy\", final unit = \"J/kg\"); -type SpecificInternalEnergy = SpecificEnergy; -type SpecificEnthalpy = SpecificEnergy; -type DerDensityByEnthalpy = Real(final unit = \"kg.s2/m5\"); -type DerDensityByPressure = Real(final unit = \"s2/m2\"); -type DerDensityByTemperature = Real(final unit = \"kg/(m3.K)\"); -type AmountOfSubstance = Real(final quantity = \"AmountOfSubstance\", final unit = \"mol\", min = 0); -type MolarMass = Real(final quantity = \"MolarMass\", final unit = \"kg/mol\", min = 0); -type MolarVolume = Real(final quantity = \"MolarVolume\", final unit = \"m3/mol\", min = 0); -type MassFraction = Real(final quantity = \"MassFraction\", final unit = \"1\", min = 0, max = 1); -type MoleFraction = Real(final quantity = \"MoleFraction\", final unit = \"1\", min = 0, max = 1); -type FaradayConstant = Real(final quantity = \"FaradayConstant\", final unit = \"C/mol\"); -type ReynoldsNumber = Real(final quantity = \"ReynoldsNumber\", final unit = \"1\"); -type NusseltNumber = Real(final quantity = \"NusseltNumber\", final unit = \"1\"); -type PrandtlNumber = Real(final quantity = \"PrandtlNumber\", final unit = \"1\"); -end SIunits; -annotation(version = \"3.2.1\", versionBuild = 4, versionDate = \"2013-08-14\", dateModified = \"2015-09-30 09:15:00Z\"); -end Modelica; - -model BranchingDynamicPipes_total \"Multi-way connections of pipes with dynamic momentum balance, pressure wave and flow reversal\" -extends Modelica.Fluid.Examples.BranchingDynamicPipes; -annotation(experiment(StopTime = 10), __Dymola_Commands(file(ensureSimulated = true) = \"modelica://Modelica/Resources/Scripts/Dymola/Fluid/BranchingDynamicPipes/plotResults.mos\")); -end BranchingDynamicPipes_total; +false +"Error: Failed to load package Modelica (3.2.1) using MODELICAPATH /var/lib/jenkins/workspace/OpenModelica_maintenance_v1.13/build/lib/omlibrary. " +false +"Error: Failed to load package Modelica (default) using MODELICAPATH /var/lib/jenkins/workspace/OpenModelica_maintenance_v1.13/build/lib/omlibrary. +Error: Class Modelica.Fluid.Examples.BranchingDynamicPipes not found in scope . +" +"" Equation mismatch: omc-diff says: Failed 't' 'f' Line 1: Text differs: expected: true got: false == 1 out of 1 tests failed [openmodelica/interactive-API/saveTotalModel.mos_temp8694, time: 1]