# Programming a circuit simulator

Discussion in 'Electrical Engineering' started by sert, Sep 27, 2008.

1. ### sertGuest

I'm programming a circuit simulator for nonlinear circuits. It
uses the nodal method and Newton-Raphson approximation to
calculate the node voltages. But I'm currently facing a problem:
how to treat dynamic elements, capacitor and inductances. I can
approximate the derivatives and integrals on which they depend,
but only if there is a previous value to use. What if it is t=0?

Obviously, we use the initial value supplied by the user, but
simply using the nodal method does not suffice in that case. Is
there some general programmable way to get the program started?

2. ### Pascal J. BourguignonGuest

Well, you will have to start the (emulated) device first. Emulate a
switch on the power line, and start with the circuit open. You will
have 0 A of current everywhere, from t=0 to t=t1 when you close the
circuit.

3. ### osmiumGuest

Nonlinear means the circuit contains an amplifier, such as a transistor.
Ordinary capacitors and inductors are linear, but there is an obscure thing
called a "swinging choke" (an inductor) which may alter something for the
joy of the green eyeshade set. I don't know what the OP was trying to
convey when he said "dynamic"; in my mind there is nothing dynamic about
capacitors and inductors. The _currents_ and _voltages_ change with time,
not the elements.

Nodal analysis depends on Kirchoff's law which says that the algebraic sum
of all currents entering and leaving a junction are zero.

The OP wants to do what is called "transient analysis" using Kirchoff's law.
There must be at least one voltage present to do the analysis and he has
already been told to assume it goes from zero to some known value,
identified in the circuit diagram, at t=0.  