About SPICE: Should I use transient analysis or DC linear analysis?

My question is specifically linked to an exam problem where I had to find a function in terms of time for the current on a capacitor and a resistor. The circuit was very simple: A current time-variant current source in series with 2 subcircuits, each composed of a capacitor and a resistor connected in parallel. Please see the figure below:

So, if I want to simulate this circuit with a SPICE software, should I run a transient analysis, a DC linear analysis, or some other type of analysis?

If the current source was sinusoidal, I would use an AC analysis, but the current source runs a current numerically equivalent to t (in Amperes) where t is the time (in seconds) elapsed since the circuit started working.

Below I have written my netlist file. While it is not a valid SPICE netlist, it illustrates what I am trying to do, focus on the current source Iin:

CIRCUIT ANALYSIS
C2 0 2 20m
R2 0 2 3
Iin 0 1 {time}
R1 1 2 2
C1 1 2 50m

.TRAN 1us 100ms
.CONTROL
RUN
PLOT V(1)-V(2)
.ENDC

.END


If you tried to simulate this netlist, you would receive an error similar to the following (which I obtained using ngspice):

Original line no.: 4, new internal line no.: 5:
Undefined number [TIME]
Original line no.: 4, new internal line no.: 5:
Cannot compute substitute
Copies=9 Evals=9 Placeholders=1 Symbols=0 Errors=2


How can I achieve this type of analysis?

-

DC analysis gives you the initial conditions DC steady state values only. You must do a transient analysis to see how the voltages and currents evolve with time. AC analysis is for small-signal sinusoidal steady state only; it is a frequency domain analysis.

I believe you'll need to use a piece-wise linear (PWL) source for your current ramp.

-
The initial conditions could be anything you or the simulator wants. So wouldn't DC be the steady state values? –  Kellenjb Jul 12 '12 at 19:49
You're correct, and I don't know why I wrote that. The DC solution is, of course, the final state after all transients have decayed. Doh! –  Alfred Centauri Jul 12 '12 at 19:51
Great! The PWL analysis let me do exactly what I was planing. And yes, from what I noticed the DC linear analysis seems to plot the final state of the circuit in each point. –  Wolter Hellmund Jul 12 '12 at 21:40

Based on your description of the exam problem, I think a transient analysis is still what you're looking for. In CircuitLab you can just define the current source as having current "T" to generate a linear current ramp proportional to the simulation time: (click here for circuit and simulation)

Open and run the transient simulation:

You can also examine the currents into each element. As you might expect, the currents into C1 and C2 are constant, while the currents into R1 and R2 grow linearly with time.

As far as the ngspice/netlist question, I believe the keywords to be looking for are "behavioral sources". See this page for some examples (one near the end uses TIME as a variable).

-
Hm, sadly ngspice isn't able to run that example using TIME as a parameter. I get the same error I included in my question, it is very unfortunate. –  Wolter Hellmund Jul 12 '12 at 21:36
And I almost forgot, thanks for showing me CircuitLab! I might use it in the future. –  Wolter Hellmund Jul 12 '12 at 21:38

You would be best to use a transient analysis. Rather than using the time parameter you could setup the current source with the pulse attribute, then specify the rise/fall time accordingly if using a standard current source (Ix). Or use an arbitrary source (Bx) and express the signal mathematically using time as a parameter.

For example, here is the netlist for your circuit in LTSPice using an arbitrarily behavioural current source:

* C:\Program Files\LTC\LTspiceIV\current rc.asc
R1 N002 N001 2
C1 N002 N001 50mF
R2 N002 0 3
C2 N002 0 20mF
B1 0 N001 I=time
.tran 0 15 1m uic
.backanno
.end


Here is the simulation with V1 - V2 plotted:

-
Isn't B a refdes for a transistor type? –  Wolter Hellmund Jul 12 '12 at 21:33
Well, after doing some tweaks to the netlist you provided, I was able to use it successfully, it seems that the .backanno command and the .tran syntax vary between LTSpice and ngspice. I would mark your solution as answer as well but I have already accepted one answer :/ –  Wolter Hellmund Jul 12 '12 at 21:48