I would like to link a mathematical model to the Electrical connectors, for example, if I want to make a box with just a parallel resistance but with only the programming language (not the graphical representation or any components (except Interface connectors)):
i1 x--------------x i2
|
-
|R| Resistance
-
|
-i1 x--------------x -i2
Code:
model MathBox
parameter Modelica.Units.SI.Resistance R = 1;
extends Modelica.Electrical.Analog.Interfaces.TwoPort();
equation
v1 = v2;
i1 = i2 + v1/R;
end MathBox;
I just cannot make it work, it compiles & simulates but there is no voltage accross v1 and no current flowing at all through after I add this model with a voltage source on v1 side and another resistor on v2 side. I used TwoPort Interface connector after trying Pin or TwoPin with the same result.
I must forget something, any idea ?
Best regards
The model
MathBoxseems to be nearly fine, not exactly equivalent to your circuit though, which seems to cause the error.When setting
v1 = v2you "only" set the voltage difference between the two pins to be equal. Modelica tools usually compute based on potentials, which is not set unless you connect a mass on both sides. So with your current model, the testing circuit should look something like this:I think there is a sign error in the model, and it should be:
which seems to give correct results.
In case you really want to have the circuit depicted above, you need to connect potentials, which can be done in multiple ways, one should be:
Note, that the extends has changed to give the possibility to add some more equations.
Using the ResBox in the testing circuit, you could remove one mass...