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

How to define connect() by myself

How to define connect() by myself

I descripted the model what I defined the connect() by myself as below.
This is very simple sample.
When I simulate this model,  I get some errors from OM simulator.
Where should I modify this model ?
----------------------------------------------------------
  model aaa
    Modelica.Electrical.Analog.Basic.Resistor resistor1(R = 10);
    Modelica.Electrical.Analog.Basic.Ground ground1;
    Modelica.Electrical.Analog.Sources.SineVoltage sineVoltage1;

  equation
    //<connection definition 1>
    sineVoltage1.n.v =  ground1.p.v;
    sineVoltage1.p.v = resistor1.p.v;
    resistor1.n.v = ground1.p.v;
 
    resistor1.p.i + sineVoltage1.p.i = 0;
    resistor1.n.i + sineVoltage1.n.i + ground1.p.i = 0;
 
  end aaa;
----------------------------------------------------------
If I change the equations as below, I have no errors.
  equation
    //<connection definition 2>
   connect( sineVoltage1.p, resistor1.p );
   connect( resistor1.n, ground1.p );
   connect( sineVoltage1.n, ground1.p );
I think  <connection definition 1> and <connection definition 2> are same....
My understanding is wrong ?

Edited by: sat_2251 - Feb-05-17 14:33:31

Re: How to define connect() by myself

Each flow-variable which is not connected as an inside connector will be set to 0. I.e. a model such as this:

Code:


model M
  connector C
    Real e;
    flow Real f;
  end C;

  C c;
end M;

will result in the flattened model:

Code:


class M
  Real c.e;
  Real c.f;
equation
  c.f = 0.0; // Automatically generated by the compiler because c.f is not connected to anything.
end M;

So writing the equations manually and using connect is not the same thing, because a connector is not considered to be connected to anything unless you actually use connect. Not using connect will usually introduce extra equations which makes the model unbalanced.

Re: How to define connect() by myself

Thank you so much for quick reply.

Please let me know "Extra equation" sample , if it is possible...

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