I'm just starting out with NGSpice, and so far I have been able to model simple DC circuits with only a voltage source and resistors and have gotten the expected currents and voltages. Now I'm trying to model the transient response of an RC circuit and am having a lot of problems.
Here is my netlist, called test-transient.cir:
Test transient circuit file for NGSpice. 2/4/2017
* Testing transient modelling with a capacitor
* The RC time constant is 680ohms * 1 uF = 0.68ms
v1 1 0 dc 10V
r1 1 2 680ohm
c1 2 0 1u
.end
I start ngspice and type the following commands:
source test-transient.cir
tran 0.5us 2ms 0
let
and I get the following output:
Here are the vectors currently active:
Title: test transient circuit file for ngspice. 2/4/2017
Name: tran1 (Transient Analysis)
Date: Sun Feb 5 20:08:33 2017
V(1) : voltage, real, 4008 long
V(2) : voltage, real, 4008 long
time : time, real, 4008 long [default scale]
v1#branch : current, real, 4008 long
Then I type "print V(2)" and every one of the 4008 elements in the vector is 1.000000e+01, i.e. 10V. This can't be right, I expected to see a charge-up curve of the capacitor from 0 to 10V. I also get the same result from typing "print V(1)", which in this case is expected.
Then I typed
plot v1#branch xlimit 0 2ms
and got this display:
The current drops from 0 to -600 (mA??) in less than 0.1 ms, which also looks wrong.
For the record, I had no problem modelling this circuit using the applet at http://www.falstad.com/circuit/, I got a voltage ramp-up across the capacitor in the expected time of 680us to 6.3V.
Any help would be much appreciated.
TIA,
Carsten
Best Answer
You have V1 as a DC voltage source. There is no transient switching. You can change it to a PWL or pulse source and then you will get the expected response.