- Index
- » Programming
- » Modelica Language
- » Integral of electrical current
Integral of electrical current
Integral of electrical current
I have been having trouble coming up with a way to take the integral of current and voltage at a specific node in a circuit. I have tried using the Block Integrator but it can not handle flow variables such as current. Is there a way this can be done?
thanks in advance
Re: Integral of electrical current
Hi,
Why don't you just add the relevant formulae by hand into your model? Just adding the code by hand, without using any part of the library...
Like this:
model MyCircuit
... (stuff)
Real integ_iv(start=0) "Integral over current and voltage at node X";
equation
...(stuff)
der(integ_iv) = Submodel.Subsubmodel.p.i * Submodel.Subsubmodel.p.v ;
end MyCircuit;
Re: Integral of electrical current
to get an integration of current I had to cast current (a flow variable) as a Real, then Modelica was happy.
ex.
model simple
Real IN,OUT;
INT intx;
equation
IN = vin.i;
intx.u = IN;
OUT = intx.y;
end simple;
--------------------------------------------------
block INT
parameter Real k = 1;
Modelica.Blocks.Interfaces.RealInput u;
Modelica.Blocks.Interfaces.RealOutput y(start = 0);
equation
der(y) = k * u;
end INT;
- Index
- » Programming
- » Modelica Language
- » Integral of electrical current