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

Real time circuit simulation using OM

Real time circuit simulation using OM

Hi,
Basically I am involved in a project of real time circuit simulation in a DSP processor.  We are using OM to model the circuit and load the equations into the DSP processor.
But OM generates huge amout of equations even after optimization.  I need some guidance.  How should I go about?  Can we simplify the equations and reduce the number  further by some means.  Kindly help me...

Thanks

Re: Real time circuit simulation using OM

I'm assuming you don't need to save a result-file then? Would an optimization that reduces the number of equations in functionAlgebraics be helpful (i.e. basically remove all equations in the following model)?

Code:

model M

  Real r = 1.5*time;
  Real y = 5.0*time;
  Real z = r;
end M;

Re: Real time circuit simulation using OM

Sir, Thanks for your response.

suppose this is a simple model model circuit of an RC circuit.
import Modelica.Electrical.Analog.Basic.*;
import Modelica.Electrical.Analog.Sources.*;
Resistor R1(R=100);
Capacitor C1(C=0.000001);
SineVoltage V1(V=1,phase=0,freqHz=500);
Ground G;
equation
connect (V1.p, R1.p);
connect (R1.n, C1.p);
connect (C1.n, G.p);
connect (V1.n, G.p);
end circuit;

after using omc +s +d=bltdump *.mo Modelica > *.txt , I get a text file, having 5 variables and 5 equations(optimized) in addition to other things.  The same circuit if I model by MNA will result in only 3 equations. Here only addln  two equations  When I try to model a transmission line of 20 blocks of RLC  number of equations are around 150, where as by MNA it will be around 50.  So the DSP takes lot of time to solve, and hence could'nt meet the real time criteria.  Does OM converts the hybrid DAE to ODE and solves, can we not make it to solve as DAE itself by replacing the reactive elements by current source and conductance.  Please guid me ...

Thank you

Re: Real time circuit simulation using OM

A better way to make RT deadlines than trying to remove simple equations is to try to reduce the number of non-linear equations. Try for example (but on your real model):

Code:

loadModel(Modelica);

loadString("
model circuit
import Modelica.Electrical.Analog.Basic.*;
import Modelica.Electrical.Analog.Sources.*;
Resistor R1(R=100);
Capacitor C1(C=0.000001);
SineVoltage V1(V=1,phase=0,freqHz=500);
Ground G;
equation
connect (V1.p, R1.p);
connect (R1.n, C1.p);
connect (C1.n, G.p);
connect (V1.n, G.p);
end circuit;
");
simulate(circuit,measureTime=true);

As for MNA, I assume it would change from state equations to algebraic ones as the number of equations and variables need to be the same in Modelica. Since you are using the model for a real-time simulation, the ODE function would be called only once (cannot use DASSL in real-time), so the opcount should be the same regardless (unless MNA somehow simplies the calculation a lot).

As far as I know, we always solve the system as an ODE.

Re: Real time circuit simulation using OM

Sir, once again thanking for your immediete responses.  Sorry for troubling you more...

To be clear, from the text file  I get after compiling and optimizing I extract the equations which will be of form ax = b, extract the 'a' matrix find inv(a) and load into the DSP processor b*inv(a) for calculating.  More the equations size of the matrices will be big....I could'nt understand where you are asking me to apply the above solution.

Thank you..

Re: Real time circuit simulation using OM

Ok. +d=bltdump does not output the (final) optimized version of the dae. It's simply the form of the dae after matching+index reduction (so you would miss late inline, etc). Try +d=dumpindxdae instead; it might help a little.

As for b*inv(a). Are you symbolically inverting the matrix or doing it numerically at each time step?

Re: Real time circuit simulation using OM

Sir ,  Only the inverted 'a' matrix along with 'b' is loaded in to the DSP.  The DSP does only the simple multiplication each time steip. I tried your suggestion, but not much of improvement .  Should I have to give up this method and try some other way, or try to model the circuits as nodes in OM.....will it work.   Kindly guide me.

Thank you

Re: Real time circuit simulation using OM

This is a bit too complicated math to do in my head, trying to figure out if using an inverted matrix causes performance issues. If you have problems then I guess it does (dense matrix scales O(n^2) instead of ~O(n) for a sparse matrix).

Re: Real time circuit simulation using OM

Its Ok sir,  sorry for taking up lot of your time.  Thank you for your patient hearing and quick responses.  I shall try some other approach and find some way to it.  Thank you.

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