[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: Periodic steady state in NGSpice



al davis wrote:
Edy wrote:

I'm trying to program shooting-method with Newton
and/or harmonic balance method for calculation of
periodic steady state of nonlinear circuits in NGSPICE.
Some (more) help would be nice. Is there someone
with a good knowledge about ngspice and C programming?
Have you something of this already done? Is it work?


How about doing it for gnucap instead?

A while back I started to look ito it for gnucap. It doesn't look too hard, but you need to understand how it works first.

As a first cut, which is easy to do manually in gnucap, run a transient analysis with relaxed tolerance for a few cycles until it appears to reach steady state. To see this, run it, run it again, until it settles down. Then tighten the tolerances and pick the exact fundamental frequency, and run a fourier analysis. Then tweek the frequency and run the fourier analysis again. If it is close enough to the same and you didn't change the frequency, you really have the steady state.

This is approximately what the shooting method does. Automating this would be a good start, but slow. Gnucap actually lets you do this as I described. NGspice will fight you.

In gnucap, I am guessing it would take about 20 lines of code to add an option to the fourier command to do this automatically.

I'll ask a naive question here. I thought that the way shooting methods worked were after the initial transient you took a snapshot of the state, and ran for what you believe to be exactly 1 period and then compared the state of the circuit again and if it didn't match, you do sort of newtons method calculation to pick a new starting state.


Or maybe you're just describing a different way of deciding when you've run enough cycles in a transient sim to find the periodic steady state solution.

I don't think I quite understand about the tweaking the frequency and running the fourier analysis again bit.

I'll add a caution that if you're not comparing the state of the entire circuit you have to be very careful to observe a signal which should have the fundamental period of the circuit as a whole and also pick one with the longest time constants. The first is important or you might think you have a periodic solution but suppose there is some block which creates subharmonics (a toggle flip-flop somewhere for example), you may have found a half-period solution instead of the whole period. Also suppose you have some bypassed bias line or some slow control loop. That line may not even have much of the periodic signal on it but it may have a long initial transient that takes a while to die out.


In ngspice, you will need a real Fourier transform, and the ability to do repeat runs, with changes between them in such as way as to not start over every time.

This is a very nice feature of gnucap.

You will also need to find a way to synchronize the data points with the Fourier points, otherwise you will see what appears to be a high noise floor, even if your frequencies are perfectly matched. Also, I question whether the step size control is capable of getting acceptable accuracy. You may need to completely replace the time step control code.

without having looked, does ngspice have a "strobeperiod" parameter like spectre? That basically says "in addition to your usual time step algorithm, output data points every strobeperiod seconds being sure to actually solve the circuit here"


-Dan




_______________________________________________ geda-user mailing list geda-user@xxxxxxxxxxxxxx http://www.seul.org/cgi-bin/mailman/listinfo/geda-user