Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

modeling error

modeling error

Hi everyone,

I'm new to the Modelica,
I'm trying to make a simple model for two connected liquid tanks (from tank1 to tank2). In this model, we can only open or close the output valve of a tank, according to the liquid level in the relevant tank. here is the model.

package SimplefiedTwoTanks
block Tank
  parameter Real area(unit="m2");
  parameter Real capacity(unit="m3");
  parameter Real max=80;
  parameter Real min=20;
  Real h(start=0,unit="m");
  FlowConnector rateIn;
  FlowConnector rateOut;
equation
  if h>= max then rateIn.rate=0;
  elseif h<=min then rateIn.rate=1;
  else rateIn.rate=1; end if;
  der(h)=(rateIn.rate - rateOut.rate)/area;
end Tank;

block Source
  FlowConnector rate;
end Source;

connector FlowConnector
  Real rate; //flow rate of the connector
end FlowConnector;

block TwoTanks
  Tank tank1(area=10,capacity=100,h=0); // the first tank (the provider tank)
  Tank tank2(area=10,capacity=100,h=0,rateOut.rate=0.5,rateIn.rate=1); // the second tank (the receipient tank)
  Source source(rate.rate=1); // the liquid source
equation
  connect(source.rate, tank1.rateIn);
  connect(tank1.rateOut, tank2.rateIn);
end TwoTanks;

I received error :
Too many equations, over-determined system. The model has 11 equation(s) and 7 variable(s).
as well as, warning that the first (of two) equation in the tank block is not enough big enough to solve for enough variables.

- What am I doing wrong?.
- What are the changes to do to make it works?.

Thank you.

Re: modeling error

Connectors have to be defined with a balanced set of potential variables and flow variables (defined with the flow keyword). In OMEdit you should also get this warning:

Code:

Translation Warning

[SimplefiedTwoTanks: 21:1-23:18]: Connector .SimplefiedTwoTanks.FlowConnector is not balanced: The number of potential variables (1) is not equal to the number of flow variables (0).

As the flow rate depends on the pressure, your connector should implement the pressure as a potential variable and the rate as flow variable, e.g.

Code:


connector FlowConnector
    flow Real rate; //flow rate of the connector
    Real p; // pressure
end FlowConnector;

You could find an introduction about connectors at Modelica by Example.

Re: modeling error

Hi spinnau,

I'm aware of the fact that connectors in Modelica implemented with balance between potential and flow variables in mind, but this is not the source of the problem because after all it is just a warning.

Thank you, for your reply.

There are 0 guests and 0 other users also viewing this topic