我有一个正在创建的坦克模型,如下所示:
model Tank "Simple model of a tank"
parameter Real volume=1 "tank volume (m^3)";
parameter Integer num_ports=1 "Number of ports";
parameter Real static_pressure=1 "Internal Tank Pressure";
parameter Real initial_level = 0;
Stream[num_ports] ports "Stream Connectors";
Real level "Level in % 0-100";
protected
Real vol "Volume of medium in the tank";
Real pressure(start=static_pressure) "Pressure inside the tank";
initial equation
level = initial_level;
/* Pressure */
equation
pressure = vol * 0.01; // Add correct factor here to get from volume to pressure change (based on height and head)
for i in 1:num_ports loop
ports[i].pressure = static_pressure + pressure;
end for;
/* Volume Flow */
equation
der(vol) = sum(ports.m_flow); // Add density factor to get form mass flow to Volume Flow
level = vol * 100 / volume;
end Tank;
我怎样才能做到这一点,当液位 <= 0 时,水箱将不允许任何负值流动(没有端口可以有流体离开,但流体仍然可以进入)?我觉得我错过了一些微不足道的东西,但如果没有太多方程(超定系统),似乎找不到方法。
谢谢