尊敬的 Modelica 用户和开发人员,
我正在使用标准 Modelica.Fluid 库来模拟一个简单的存储传热问题。经过几次不成功的尝试建立一个简单的模型后,我现在尝试修改示例,直到我能够将其用于我的目的。
不幸的是,如果我开始修改和调整事物,我经常会遇到无法解决的错误。
我的模型基于 Modelica.Fluid.Examples.HeatingSystem。我的目标是建立一个模型,其中包含两个罐、两个带热交换的管道和两个循环流体的泵。控制两个泵壳以调节管道中的质量流量,从而为流体提供恒定的温度,然后将其储存在罐中以供进一步使用。从我的角度来看,这个任务应该是一个使用 Modelica.Fluid 库的简单任务。
所以首先的问题是,这个库是否有任何好的文档(除了我已经在使用的官方文档)。我正在寻找某种常见问题解答或类似内容,因为我收到的错误消息差异很大。
如果我引入 PI 控制器来测量温度并控制管道中的质量流量,我经常会收到以下错误消息:(另请参见下面的示例和 1)
Cannot reduce the DAE index and select states.
This is most likely due to non-differentiable functions.
另一个消息是关于使用 modelicas 同养模式和奇异系统:
Solving using global homotopy-method.
The following error was detected at time: 0
Error: Scalar system is always singular for pump.dp_pump = (homotopy(0.0, 0.0)-pump.W_single)/( -homotopy(1.25*pump.V_flow_single, 0.0)) = 0/-0
Error: Failed to start model.
或者我得到类似这样的东西:
[...]abs(y0d) < 1E-015 or abs(y1d) < 1E-015
The following error was detected at time: 0
regFun3(): Derivatives at data points do not allow co-monotone interpolation, as both are non-zero, of opposite sign and have an absolute value larger than machine eps (y0d = -0.000690531, y1d = 0.999503). Please correct arguments.
The stack of functions is:
Modelica.Fluid.Utilities.regFun3
massFlowRate_dp_staticHead_Unique16
massFlowRate_dp_staticHead_Unique16(pipe1.flowModel.dps_fg[3], pipe1.flowModel.rhos[3], pipe1.flowModel.rhos[4], pipe1.flowModel.mus[3], pipe1.flowModel.mus[4], 0.25, pipe1.dimensions[2], 0.0, pipe1.crossAreas[2], pipe1.roughnesses[2], 0.3333333333333333*pipe1.flowModel.dp_small, 4000)
Non-linear solver will attempt to handle this problem.
ERROR: Failed to solve non-linear system using Newton solver.
To get more information: Turn on Simulation/Setup/Debug/Nonlinear solver diagnostics/Details
Solution to systems of equations not found at time = 0
Nonlinear system of equations number = 1
Infinity-norm of residue = 20
Iteration is not making good progress.
Accumulated number of residue calc.: 1332
Accumulated number of symbolic Jacobian calc.: 210
Last values of solution vector:
pipe1.state_b.T = 300
Last values of residual vector:
{ 20 }
Error: could not solve simplified initialization for homotopy method.
Error: could not solve simplified initialization for homotopy method.
Error: Failed to start model.
由于我仍然会称我为 Modelica 的初学者,因此我到达了寻找解决此问题的解决方案的“死点”。此外,很难详细了解流体库的每个模型。也许有人可以评论一些错误消息或就如何进入 Modelica Fluid Lib 提供一些建议。
对于这个问题,我将不胜感激。如果您想让模型文件直接运行它,我可以将它提供给您以指定问题。
如果你能支持我解决这个问题,我会很高兴。
非常感谢,马吕斯
举个例子:这里1是我目前的详细问题之一(这是我现在最大的问题)。如果没有受控的质量流量,该模型可以完美运行。当我介绍 PI 控制器时,我收到错误消息:
无法减少 DAE 索引并选择状态。这很可能是由于不可微函数。
无法减少 DAE 索引并选择状态。这很可能是由于不可微函数。
未能减少 DAE 索引。
模型如图(注释中),代码如下:
model HeatingSystem_modified "Simple model of a heatstorage system"
extends Modelica.Icons.Example;
replaceable package Medium =
CSP.Components.Media.linearMoltenSalt
constrainedby Modelica.Media.Interfaces.PartialMedium;
Modelica.Fluid.Vessels.OpenTank tank(
redeclare package Medium = Medium,
height=2,
level_start=1,
massDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
use_HeatTransfer=true,
redeclare model HeatTransfer =
Modelica.Fluid.Vessels.BaseClasses.HeatTransfer.IdealHeatTransfer (k=10),
ports(each p(start=1e5)),
T_start=Modelica.SIunits.Conversions.from_degC(20),
portsData={Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter=0.01),
Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter=0.01)},
crossArea=1,
nPorts=2) annotation (Placement(transformation(extent={{-40,64},{-20,84}},
rotation=0)));
Modelica.Fluid.Machines.ControlledPump pump(
redeclare package Medium = Medium,
N_nominal=1500,
use_T_start=true,
T_start=Modelica.SIunits.Conversions.from_degC(40),
m_flow_start=0.01,
m_flow_nominal=0.01,
allowFlowReversal=false,
use_m_flow_set=false,
p_a_start=110000,
p_b_start=130000,
p_a_nominal=110000,
p_b_nominal=130000,
control_m_flow=true) annotation (Placement(transformation(extent={{20,50},{40,
70}}, rotation=0)));
public
Modelica.Thermal.HeatTransfer.Sources.FixedHeatFlow burner(
alpha=-0.5,
Q_flow=1.6e4,
T_ref=343.15)
annotation (Placement(transformation(extent={{-122,-10},{-102,10}},
rotation=0)));
inner Modelica.Fluid.System system(
m_flow_small=1e-4, energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyStateInitial)
annotation (Placement(transformation(extent={{80,80},{100,
100}}, rotation=0)));
protected
Modelica.Blocks.Interfaces.RealOutput T_forward
annotation (Placement(transformation(extent={{114,-46},{126,-34}},
rotation=
0)));
public
Modelica.Fluid.Sensors.Temperature sensor_T_cold(redeclare package Medium =
Medium) annotation (Placement(transformation(extent={{92,-50},{112,-30}},
rotation=0)));
Modelica.Fluid.Sensors.Temperature sensor_T_hot(redeclare package Medium =
Medium) annotation (Placement(transformation(extent={{-72,10},{-52,30}},
rotation=0)));
Modelica.Fluid.Vessels.OpenTank tank1(
redeclare package Medium = Medium,
height=2,
level_start=1,
massDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
use_HeatTransfer=true,
redeclare model HeatTransfer =
Modelica.Fluid.Vessels.BaseClasses.HeatTransfer.IdealHeatTransfer (k=10),
ports(each p(start=1e5)),
T_start=Modelica.SIunits.Conversions.from_degC(20),
portsData={Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter=0.01),
Modelica.Fluid.Vessels.BaseClasses.VesselPortsData(diameter=0.01)},
crossArea=1,
nPorts=2) annotation (Placement(transformation(extent={{20,-48},{40,-28}},
rotation=0)));
Modelica.Fluid.Machines.ControlledPump pump1(
redeclare package Medium = Medium,
N_nominal=1500,
use_T_start=true,
T_start=Modelica.SIunits.Conversions.from_degC(40),
m_flow_start=0.01,
allowFlowReversal=false,
m_flow_nominal=0.1,
control_m_flow=true,
p_a_start=110000,
p_b_start=130000,
p_a_nominal=110000,
p_b_nominal=130000,
use_m_flow_set=true)
annotation (Placement(transformation(extent={{-20,-62},{
-40,-42}},
rotation=0)));
Modelica.Fluid.Pipes.DynamicPipe radiator(
use_T_start=true,
redeclare package Medium = Medium,
length=10,
T_start=Modelica.SIunits.Conversions.from_degC(40),
redeclare model HeatTransfer =
Modelica.Fluid.Pipes.BaseClasses.HeatTransfer.IdealFlowHeatTransfer,
diameter=0.01,
nNodes=1,
redeclare model FlowModel =
Modelica.Fluid.Pipes.BaseClasses.FlowModels.DetailedPipeFlow,
use_HeatTransfer=true,
modelStructure=Modelica.Fluid.Types.ModelStructure.a_v_b,
p_a_start=110000) annotation (Placement(transformation(extent={{10,10},{-10,
-10}},
rotation=90,
origin={76,0})));
Modelica.Thermal.HeatTransfer.Sources.FixedTemperature T_ambient(T=system.T_ambient)
annotation (Placement(transformation(extent={{-7,-7},{7,7}}, rotation=180,
origin={127,0})));
Modelica.Thermal.HeatTransfer.Components.ThermalConductor wall(G=1.6e3/20)
annotation (Placement(transformation(
origin={102,0},
extent={{8,-10},{-8,10}},
rotation=180)));
Modelica.Fluid.Pipes.DynamicPipe heater(
redeclare package Medium = Medium,
use_T_start=true,
T_start=Modelica.SIunits.Conversions.from_degC(80),
length=2,
redeclare model HeatTransfer =
Modelica.Fluid.Pipes.BaseClasses.HeatTransfer.IdealFlowHeatTransfer,
diameter=0.01,
nNodes=1,
redeclare model FlowModel =
Modelica.Fluid.Pipes.BaseClasses.FlowModels.DetailedPipeFlow,
use_HeatTransfer=true,
modelStructure=Modelica.Fluid.Types.ModelStructure.a_v_b,
p_a_start=130000) annotation (Placement(transformation(extent={{-10,-10},{10,
10}},
rotation=90,
origin={-80,0})));
Modelica.Blocks.Sources.RealExpression realExpression(y=90)
annotation (Placement(transformation(extent={{-72,36},{-52,56}})));
Modelica.Blocks.Math.Add add(k1=-1, k2=+1)
annotation (Placement(transformation(extent={{-26,16},{-6,36}})));
Modelica.Blocks.Continuous.PI PI(
k=2,
T=1,
x_start=0,
initType=Modelica.Blocks.Types.Init.NoInit)
annotation (Placement(transformation(extent={{2,16},{22,36}})));
equation
connect(radiator.heatPorts[1], wall.port_a) annotation (Line(points={{80.4,-0.1},
{88,-0.1},{88,9.99201e-016},{94,9.99201e-016},{94,0}}, color={127,0,0}));
connect(wall.port_b, T_ambient.port) annotation (Line(points={{110,-9.99201e-016},
{116,-9.99201e-016},{116,0},{120,0}}, color={191,0,0}));
connect(heater.heatPorts[1], burner.port) annotation (Line(points={{-84.4,0.1},
{-94,0.1},{-94,0},{-102,0}}, color={127,0,0}));
connect(pump.port_b, radiator.port_a)
annotation (Line(points={{40,60},{76,60},{76,10}}, color={0,127,255}));
connect(pump1.port_a, tank1.ports[1])
annotation (Line(points={{-20,-52},{28,-52},{28,-48}}, color={0,127,255}));
connect(pump1.port_b, heater.port_a) annotation (Line(points={{-40,-52},{-80,-52},
{-80,-10}}, color={0,127,255}));
connect(sensor_T_cold.T, T_forward)
annotation (Line(points={{109,-40},{120,-40}}, color={0,0,127}));
connect(sensor_T_hot.port, heater.port_b)
annotation (Line(points={{-62,10},{-62,10},{-80,10}}, color={0,127,255}));
connect(sensor_T_cold.port, radiator.port_b) annotation (Line(points={{102,-50},
{82,-50},{82,-10},{76,-10}}, color={0,127,255}));
connect(heater.port_b, tank.ports[1]) annotation (Line(points={{-80,10},{-80,10},
{-80,56},{-80,60},{-32,60},{-32,64}}, color={0,127,255}));
connect(pump.port_a, tank.ports[2]) annotation (Line(points={{20,60},{-6,60},{
-28,60},{-28,64}}, color={0,127,255}));
connect(add.y, PI.u)
annotation (Line(points={{-5,26},{-5,26},{0,26}}, color={0,0,127}));
connect(PI.y, pump1.m_flow_set) annotation (Line(points={{23,26},{30,26},{30,-20},
{-25,-20},{-25,-43.8}}, color={0,0,127}));
connect(sensor_T_hot.T, add.u2)
annotation (Line(points={{-55,20},{-28,20}}, color={0,0,127}));
connect(realExpression.y, add.u1) annotation (Line(points={{-51,46},{-46,46},{
-46,32},{-28,32}}, color={0,0,127}));
connect(radiator.port_b, tank1.ports[2]) annotation (Line(points={{76,-10},{76,
-10},{76,-34},{76,-50},{76,-52},{32,-52},{32,-48}}, color={0,127,255}));
annotation ( Documentation(info="<html>
<p>
Simple heating system with a closed flow cycle.
After 2000s of simulation time the valve fully opens. A simple idealized control is embedded
into the respective components, so that the heating system can be regulated with the valve:
the pump controls the pressure, the burner controls the temperature.
</p>
<p>
One can investigate the temperatures and flows for different settings of <code>system.energyDynamics</code>
(see Assumptions tab of the system object).</p>
<ul>
<li>With <code>system.energyDynamics==Types.Dynamics.FixedInitial</code> the states need to find their steady values during the simulation.</li>
<li>With <code>system.energyDynamics==Types.Dynamics.SteadyStateInitial</code> (default setting) the simulation starts in steady-state.</li>
<li>With <code>system.energyDynamics==Types.Dynamics.SteadyState</code> all but one dynamic states are eliminated.
The left state <code>tank.m</code> is to account for the closed flow cycle. It is constant as outflow and inflow are equal
in a steady-state simulation.</li>
</ul>
<p>
Note that a closed flow cycle generally causes circular equalities for the mass flow rates and leaves the pressure undefined.
This is why the tank.massDynamics, i.e., the tank level determining the port pressure, is modified locally to Types.Dynamics.FixedInitial.
</p>
<p>
Also note that the tank is thermally isolated against its ambient. This way the temperature of the tank is also
well defined for zero flow rate in the heating system, e.g., for valveOpening.offset=0 at the beginning of a simulation.
The pipe however is assumed to be perfectly isolated.
If steady-state values shall be obtained with the valve fully closed, then a thermal
coupling between the pipe and its ambient should be defined as well.
</p>
<p>
Moreover it is worth noting that the idealized direct connection between the heater and the pipe, resulting in equal port pressures,
is treated as high-index DAE, as opposed to a nonlinear equation system for connected pressure loss correlations. A pressure loss correlation
could be additionally introduced to model the fitting between the heater and the pipe, e.g., to adapt different diameters.
</p>
<img src=\"modelica://Modelica/Resources/Images/Fluid/Examples/HeatingSystem.png\" border=\"1\"
alt=\"HeatingSystem.png\">
</html>"), experiment(StopTime=6000),
__Dymola_Commands(file(ensureSimulated=true)=
"modelica://Modelica/Resources/Scripts/Dymola/Fluid/HeatingSystem/plotResults.mos"
"plotResults"));
end HeatingSystem_modified;