我正在开发一个模型来描述双管网络的行为。该网络连接到一个水箱,根据外部质量流速从该水箱中注入或提取热量。任意假设加热和冷却的质量流速随时间变化。CCD_ 1的初始值与参数CCD_ 2相关联。然而,在不同的时间点,PipeTemp
是根据最大函数来计算的。
问题是,由于变量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
、HeatFlowRate
、CoolFlowRate
和TankVol
都是非负PipeTemp
0大于DecreasingTemp
,因此方程折叠为:
PipeTemp=PipeTemp+dTPipe*HeatFlowRate/TankVol;
并且你不能从中计算CCD_ 12。
最接近的变体是,在每个采样点,我们计算一个新的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;