Question about ODEs in ngspice

Anonymous
2012-11-15
2013-06-12
  • Anonymous - 2012-11-15

    Hi,

    Currently, I'm trying to represent some circuits to their differentials equations. These circuits have some non-linearities which I have some problems, not in ngspice, but in Matlab or Octave when I try to solve them with numerical methods. For instance consider this circuit:

    V1 1 0 SIN(0 10 10)
    L1 1 2 10u
    B1 2 0 V=(1/i(V1))*v(6)

    B3 0 6 I=abs(i(V1))
    C1 6 0 10u
    R1 6 0 10

    .tran 0.1us 100ms UIC
    .end

    Translating this circuit to differentials equations gives

    1)     dx/dt = -x/(RC) + abs(y)/C
    2)     dy/dt = -x/(abs(x)*L) + V1/L

    x is the capactor's voltage and y is the inductor's current. If I try to solve these equations on Matlab, It will give an error because the second equation will have a division by zero with initial conditions set as zero. My question is: Does ngspice set initial conditions different from zero in order to simulate the circuit? because I think the circuit's initial conditions should be zero.

    Thanks for taking the time to read this, I know it is a long post, but I really want to know how ngspice works.

     
  • marcel hendrix

    marcel hendrix - 2012-11-15

    SPICE takes a pragmatic approach and handles numerical exceptions (1/0, sqrt(-1), log(-5) etc.) differently. It will reject the (0,0) initial conditions as infeasible and settle for something 'as near as possible' to that point.

     
  • marcel hendrix

    marcel hendrix - 2012-11-15

    BTW, you should get acceptable results even with

    .tran 10ms 100ms UIC

    With the default accuracy, NGSPICE then needs ~2 ms integration steps (and reports 0 ms elapsed time).

    -marcel

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks