1
\$\begingroup\$

I have this simple netlist

First Circuit
R1 1 2 3k
R2 2 0 6k
R3 2 3 4k
R4 3 0 2k
Vs 1 0 DC 9
Is 3 0 DC 5M
.dc
.End

In the past when running a text based SPICE program I get and output file where it tells me all of the node voltages and other simple DC analysis. How do I get ngspice to give me these values or create an output file? I have put

.print dc v(v1)

but I still don't get anything.

\$\endgroup\$
1
\$\begingroup\$

Well I found my own answer. After fiddling with the code, reading a lot of articles on line and reading some of the ngspice users manual the code should look like this:

First Circuit
.op
R1 1 2 3k
R2 2 0 6k
R3 2 3 4k
R4 3 0 2k 
Vs 1 0 DC 9
Is 3 0 DC 5M
.End

I run the command

ngspice -o mine -b first.cir

That runs first.cir in ngspice in batch mode and produces an output file named mine. The file looks like this:

Circuit: first circuit

Doing analysis at TEMP = 27.000000 and TNOM = 27.000000

No. of Data Rows : 1
Node                                  Voltage
----                                  -------
----    -------
V(3)                                  -6.00000e+00
V(2)                                   2.000000e+00
V(1)                                   9.000000e+00

Source  Current
------  -------

vs#branch                        -2.33333e-03

There is a bunch other output but it is not germane to the answer.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.