SPICE RCL-circuit with initial conditions

Per Sundqvist, ABB Corporate Research AB
Email:

This model shows how to set up a SPICE model of a RCL-circuit in COMSOL4.0a with other initial conditions than default.

The SPICE (Electric Circuit, "cir") in COMSOL does not allow you to specify initial voltage of a capacitor or an initial current through an inductor.

This is a way of walking around this problem, using sub-circuits (External IvsU and UvsI) in combination with the equations of state for C and L in an "ODEs and DAEs"-node in COMSOL.

The tricky part is to find out what the variable name for the voltage across the inductor (mod1.cir.UvsI1_v) and the current through the capacitor (mod1.cir.X1_i) are, as these enters in the ODE's. One could find out these from the plot-menu: Results->1D Plot Group 1->Global 1->Expressions->(+)->Electrical Circuit->Voltage across device UvsI1 (mod1.cir.UvsI1_v).

Other Entries by This Contributor

User Comments

JM Aniceto
Oct 13, 2010 at 2:34pm UTC

Very useful for those who want to couple a FEM simulation with an oscillating circuit.
I had this problem too, but luckily the inductance of my circuit was little compare to the simulated element. I used ODEs of a RC circuit.
Thanks Mr. Sundvist it might be very useful in the future.

Heigo Mõlder
Nov 23, 2010 at 8:59am UTC

Can you save this in Comsol 3.5 version ?

JM Aniceto
Dec 8, 2010 at 3:10pm UTC

Hi Heigo,

I do not have 4.0a and for those who work with another older version you won't be able to solve the problem in the same way because those older versions do not support External IvsU and UvsI SPICE elements.

Then you need another solution. After fighting with it, here it goes:

* Include in your SPICE model just the R and the L
* When pressing ok to validate your model, COMSOL becomes automatically the equation governing the SPICE circuit
* In the gloval equations you define I = C*dU/dt (with an initial charge) your variable here is U and I is the same that is defined in the SPICE circuit
* Include in the equation of the SPICE circuit the U of the capacitor


That's all, I hope it helps you!
Bye,
JMAC

Linlin Yu
Jul 21, 2011 at 10:00am UTC

thanks, JM Aniceto.

very impressing and useful work!

:)

Maestro Conalep Conalep Cuernavaca
Sep 10, 2011 at 2:46am UTC

thanks for your aportations...

Lingling Tang
Jun 30, 2013 at 2:35am UTC

The problem " initial voltage of a capacitor or an initial current through an inductor" has been solved in COMSOL 4.3a version, but your work, especially the adoption of sub-circuits like External U vs I and External I vs U is impressive. Good work!
Besides, I wonder how to find out the variable name of sub-circuit? Could you give some tips?

Login to comment on this entry.