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

Overconstrained model.

Overconstrained model.

Hi,

Can somebody of the community help me with an issue I have with a simple motor model.
When I instantiate the model with OMEdit, it forces torque equation to zero. This issue rise only when I use connectors.
Many thanks.
David

Rotor.tau = 0.0;//?
Stator.tau = 0.0;//?

The resulting failure is that I end with too much equations. Below is the full model and the instantiated model.

Model as written:

 Spoiler Show Spoiler Hide Spoiler
 model Motor_simple
  Flange Rotor;
  Flange Stator;
  Flange Friction1;
  Flange Friction2;
  //Torque tau;
  Speed w;
  Angle theta;
  Current i;
  //parameter Real Mf = 0;
  parameter Real V = 10;
  parameter Real K = 0.014;
  parameter Real J = 0.0000001;
  parameter Real R = 10;
initial equation
  der(w) = 0;
  //steadystate
equation
  Rotor.theta - Stator.theta = theta;
  w = der(theta);
  K * i + J * der(w) = Rotor.tau;
  V = R * i + K * w;
  Friction1.tau = 0;
  Friction2.tau = 0;
  connect(Rotor,Friction1);
  connect(Stator,Friction2);
  Stator.theta = 0;
end Motor_simple;
Instantiated model:

 Spoiler Show Spoiler Hide Spoiler
 class mypackage.Motor_simple
  Real Rotor.theta(unit = "rad");
  Real Rotor.tau(unit = "Nm");
  Real Stator.theta(unit = "rad");
  Real Stator.tau(unit = "Nm");
  Real Friction1.theta(unit = "rad");
  Real Friction1.tau(unit = "Nm");
  Real Friction2.theta(unit = "rad");
  Real Friction2.tau(unit = "Nm");
  Real w(unit = "rad/s");
  Real theta(unit = "rad");
  Real i(unit = "A");
  parameter Real V = 10.0;
  parameter Real K = 0.014;
  parameter Real J = 0.0000001;
  parameter Real R = 10.0;
initial equation
  der(w) = 0.0; //steady state
equation
  Rotor.theta - Stator.theta = theta;
  w = der(theta);
  K * i + J * der(w) = Rotor.tau;
  V = R * i + K * w;
  Friction1.tau = 0.0;//?
  Friction2.tau = 0.0;//?
  Stator.theta = 0.0;
  Rotor.tau = 0.0;//?
  Stator.tau = 0.0;//?
  Friction1.tau = 0.0;
  Friction2.tau = 0.0;
  (-Rotor.tau) + (-Friction1.tau) = 0.0;
  Friction1.theta = Rotor.theta;
  (-Stator.tau) + (-Friction2.tau) = 0.0;
  Friction2.theta = Stator.theta;
end mypackage.Motor_simple;

Edited by: Supaswing - Dec-04-13 18:35:26

Re: Overconstrained model.

I did others model and I have always the same issue using connector type Flange, flattening of the model add an equation  xxx.tau=0.0 even if I try to impose another equation.
I am stuck on this problem and I would really appreciate some help

Re: Overconstrained model.

Well, you have   Friction1.tau = 0;  Friction2.tau = 0; in the model, so I don't see what the problem is.

Re: Overconstrained model.

I'm unfortunately not a modeler and can't tell you exactly how to fix your model, but I can try to explain how connectors work in Modelica. In Modelica you have the concept of outside and inside connectors. Outside connectors are connectors declared in the same scope as the connection (or in connectors in that scope), while inside connectors are declared in a non-connector component. For example:

Code:


connector Flange
  flow Real tau;
  Real theta;
end Flange;

model M1
  Flange f1;
end M1;

model M2
  M1 m1;
  Flange f2;
equation
  connect(m1.f1, f2); // m1.f1 is an inside connector because f1 is declared inside non-connector component m1,
                      // f2 is an outside connector because it's declared in the same scope as this connect equation.
end M2;

Zero-equations are automatically generated for flow-variables in connector components which have not been connected as inside. In my example above you would get an equation "f2.tau = 0.0", because f2.tau has not been connected as inside, only outside. This is done to make sure that models are balanced, and if your model becomes unbalanced because of these extra equations it means that your model most likely has some issues. You probably need to remove the zero-equations you've added yourself for those flow-variables, and connect your motor to some other components to make it work correctly.

Re: Overconstrained model.

I could make it work. Thank you
It was a bad understanding of connectors. You can't have connection inside a model. The working model below:


Code:

model Motor_simple

  Rotor1 Rot;
  Stator1 Stat;
  Friction1 F1;
  Friction1 F2;
  Speed w;
  Angle theta;
initial equation
  der(w) = 0;
  //steadystate
equation
  Rot.c.theta - Stat.c.theta = theta;
  w = der(theta);
  connect(Rot.c,F1.c);
  connect(Stat.c,F2.c);
end Motor_simple;

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