Limit tank flow when level <= 0 in Modelica

时光毁灭记忆、已成空白 提交于 2019-12-11 06:47:22

问题


I have a model of a tank that I am creating as follows:

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;

How can I make it so that when the level <=0 the tank will not allow any flows with a negative value (no ports can have fluid leaving, but fluid can still enter)? I feel like I am missing something trivial, but can't seem to find a way without having too many equations (over-determined system).

Thanks


回答1:


You could try with a when equation:

when level < 0 then
  reinit(level, 0)
end when;


来源:https://stackoverflow.com/questions/29038528/limit-tank-flow-when-level-0-in-modelica

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!