- Index
- » Programming
- » Modelica Language
- » How to define connect() by myself
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 ?
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.
- perost
-
-
- 114 Posts
- Index
- » Programming
- » Modelica Language
- » How to define connect() by myself