Modelica 变量的相互依赖性终止了Dymola模拟,并产生了非线性方程组

Modelica 变量的相互依赖性终止了Dymola模拟,并产生了非线性方程组,modelica,dymola,Modelica,Dymola,我正在开发一个模型来描述双管网的行为。该网络连接到一个储罐,在该储罐中,根据外部质量流量从系统中注入或提取热量。加热和冷却的质量流量可任意假设随时间变化。 PipeTemp的初始值与参数StartTemp关联。但是,在不同的时间点,PipeTemp是通过max函数计算的 问题在于,由于变量PipeTemp依赖于使用PipeTemp值计算的其他时变变量,Dymola终止模拟并产生以下错误:无法使用牛顿解算器求解非线性系统 这个简单的模型可以很容易地在Excel中模拟,因为它能够处理单元变量之间的相

我正在开发一个模型来描述双管网的行为。该网络连接到一个储罐,在该储罐中,根据外部质量流量从系统中注入或提取热量。加热和冷却的质量流量可任意假设随时间变化。
PipeTemp
的初始值与参数
StartTemp
关联。但是,在不同的时间点,
PipeTemp
是通过max函数计算的

问题在于,由于变量
PipeTemp
依赖于使用
PipeTemp
值计算的其他时变变量,Dymola终止模拟并产生以下错误:无法使用牛顿解算器求解非线性系统

这个简单的模型可以很容易地在Excel中模拟,因为它能够处理单元变量之间的相互依赖关系。为了避免非线性方程组,Dymola中该模型的解决方法是什么

model FullyMixedTemperature

  parameter Real StartTemp = 20;      //Assumed mixed temperature in the pipes
  parameter Real dTpipe = 10;        //Temperature difference between the two pipes
  parameter Real TankVol = 150;      //Total volume
  Real DecreasingTemp;               //Mixed temperature in the pipe due to additional cooling mass flow rate
  Real IncreasingTemp;               //Mixed temperature in the pipe due to additional heating mass flow rate
  Real PipeTemp(start=StartTemp);    //Mixed temperature in the pipe
  Real CoolFlowRate;                 //Additional cooling flow rate from external sources
  Real HeatFlowRate;                 //Additional heating flow rate from external sources

equation 

  CoolFlowRate=0.5*time;
  HeatFlowRate=2*time;
  PipeTemp = max(DecreasingTemp, IncreasingTemp);
  DecreasingTemp= PipeTemp-(dTpipe*CoolFlowRate/TankVol);
  IncreasingTemp= PipeTemp+(dTpipe*HeatFlowRate/TankVol);

end FullyMixedTemperature;

所写的模型没有意义

由于
dTPipe
热流量
冷流量
TankVol
都是非负的
递增温度
大于
递减温度
,因此方程可简化为:

PipeTemp=PipeTemp+dTPipe*HeatFlowRate/TankVol;
您无法从中计算出
PipeTemp

最接近的变量是,在每个采样点,我们计算一个新的PipeTemp,即:

model FullyMixedTemperature

  parameter Real StartTemp = 20;      //Assumed mixed temperature in the pipes
  parameter Real dTpipe = 10;        //Temperature difference between the two pipes
  parameter Real TankVol = 150;      //Total volume
  Real DecreasingTemp;               //Mixed temperature in the pipe due to additional cooling mass flow rate
  Real IncreasingTemp;               //Mixed temperature in the pipe due to additional heating mass flow rate
  Real PipeTemp(start=StartTemp);    //Mixed temperature in the pipe
  Real CoolFlowRate;                 //Additional cooling flow rate from external sources
  Real HeatFlowRate;                 //Additional heating flow rate from external sources

equation 

  CoolFlowRate=0.5*time;
  HeatFlowRate=2*time;
  when sample(1,1) then
    PipeTemp = max(pre(DecreasingTemp), pre(IncreasingTemp));
  end when;
  DecreasingTemp= PipeTemp-(dTpipe*CoolFlowRate/TankVol);
  IncreasingTemp= PipeTemp+(dTpipe*HeatFlowRate/TankVol);

end FullyMixedTemperature;
但在我看来,你更可能想要一个微分方程,其中两个流都有贡献:

model FullyMixedTemperature

  parameter Real StartTemp = 20;      //Assumed mixed temperature in the pipes
  parameter Real dTpipe = 10;        //Temperature difference between the two pipes
  parameter Real TankVol = 150;      //Total volume
  Real PipeTemp(start=StartTemp);    //Mixed temperature in the pipe
  Real CoolFlowRate;                 //Additional cooling flow rate from external sources
  Real HeatFlowRate;                 //Additional heating flow rate from external sources

equation 

  CoolFlowRate=0.5*time;
  HeatFlowRate=2*time;
  der(PipeTemp) =(dTpipe*HeatFlowRate/TankVol)-(dTpipe*CoolFlowRate/TankVol);

end FullyMixedTemperature;

所写的模型没有意义

由于
dTPipe
热流量
冷流量
TankVol
都是非负的
递增温度
大于
递减温度
,因此方程可简化为:

PipeTemp=PipeTemp+dTPipe*HeatFlowRate/TankVol;
您无法从中计算出
PipeTemp

最接近的变量是,在每个采样点,我们计算一个新的PipeTemp,即:

model FullyMixedTemperature

  parameter Real StartTemp = 20;      //Assumed mixed temperature in the pipes
  parameter Real dTpipe = 10;        //Temperature difference between the two pipes
  parameter Real TankVol = 150;      //Total volume
  Real DecreasingTemp;               //Mixed temperature in the pipe due to additional cooling mass flow rate
  Real IncreasingTemp;               //Mixed temperature in the pipe due to additional heating mass flow rate
  Real PipeTemp(start=StartTemp);    //Mixed temperature in the pipe
  Real CoolFlowRate;                 //Additional cooling flow rate from external sources
  Real HeatFlowRate;                 //Additional heating flow rate from external sources

equation 

  CoolFlowRate=0.5*time;
  HeatFlowRate=2*time;
  when sample(1,1) then
    PipeTemp = max(pre(DecreasingTemp), pre(IncreasingTemp));
  end when;
  DecreasingTemp= PipeTemp-(dTpipe*CoolFlowRate/TankVol);
  IncreasingTemp= PipeTemp+(dTpipe*HeatFlowRate/TankVol);

end FullyMixedTemperature;
但在我看来,你更可能想要一个微分方程,其中两个流都有贡献:

model FullyMixedTemperature

  parameter Real StartTemp = 20;      //Assumed mixed temperature in the pipes
  parameter Real dTpipe = 10;        //Temperature difference between the two pipes
  parameter Real TankVol = 150;      //Total volume
  Real PipeTemp(start=StartTemp);    //Mixed temperature in the pipe
  Real CoolFlowRate;                 //Additional cooling flow rate from external sources
  Real HeatFlowRate;                 //Additional heating flow rate from external sources

equation 

  CoolFlowRate=0.5*time;
  HeatFlowRate=2*time;
  der(PipeTemp) =(dTpipe*HeatFlowRate/TankVol)-(dTpipe*CoolFlowRate/TankVol);

end FullyMixedTemperature;

这两种方法都很有效。随着采样点的增加,模拟性能下降,微分方程更可取。谢谢你的回答,汉斯!这两种方法都很有效。随着采样点的增加,模拟性能下降,微分方程更可取。谢谢你的回答,汉斯!