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

Why do I get negative values though the connector?

Why do I get negative values though the connector?

Hi!

This is my model. It's a pump, hydraulic cylinder and two tanks.

The problem is that if the pump pumps out 9 l/min, then the cylinder is going to observe those flow values as -9 l/min. How can I "by pass" this problem?


https://openmodelica.org/images/agorapro/attachments/5412/mini_Markering-010.png

The code for the pump has those equations

Code:


C1.Q = D * n * ve / 1000;
C2.Q = C1.Q;

The connector C2(input) and C1(output) has two variables: P(pressure) and Q(flow).

The cylinder has those equations

Code:


// Velocity equation of piston
  v = C2.Q * ve / (A2 * 6);
// Compute with area A2 and flow C2.Q
// Input flow equation
  C1.Q = C2.Q * A1 / A2;
// Saturation - Piston position equation
  if v * time > L then
    s = L;
  elseif v * time < 0 then
    s = 0;
  else
    s = v * time;
  end if;
// set position at piston
  piston.s = s;
// ODE equation of the cylinder
  M * der(v) = 10 * A1 * C1.P * me - piston.f - 10 * A2 * C2.P * me;

Where C2 is output and C1 is input.


https://openmodelica.org/images/agorapro/attachments/5412/mini_Markering-011.png

I have attached my library.


1510783475_EasyHydraulics.mo

Re: Why do I get negative values though the connector?

I think you're a bit confused about how Modelica connections work. If your pump is sending 9 l/min from pump.C.Q, then from the cylinder's perspective, cylinder.C1.Q must be -9 l/min (it is receiving 9 l/min from some other component); because connections are zero-sum. If you check for example a simple electrical circuit in the standard library, and connect a constant source of 1V to a 1Ohm resistor, then one port of the resistor will be -1A and the other port will be 1A; but the component will also calculate an internal parameter i which is 1A and is the actual flow through the resistor. You could naturally calculate such a flow for the component itself if you'd like and think that's more natural than "+ is outgoing, - is incoming".

Re: Why do I get negative values though the connector?

sjoelund.se wrote:


I think you're a bit confused about how Modelica connections work. If your pump is sending 9 l/min from pump.C.Q, then from the cylinder's perspective, cylinder.C1.Q must be -9 l/min (it is receiving 9 l/min from some other component); because connections are zero-sum. If you check for example a simple electrical circuit in the standard library, and connect a constant source of 1V to a 1Ohm resistor, then one port of the resistor will be -1A and the other port will be 1A; but the component will also calculate an internal parameter i which is 1A and is the actual flow through the resistor. You could naturally calculate such a flow for the component itself if you'd like and think that's more natural than "+ is outgoing, - is incoming".

Thank you. That was a good answer on my question. Kirchhoff strömlag.

There are 0 guests and 0 other users also viewing this topic
You are here: