Electrical – Running ngspice from command line on a Linux and Windows machine.

ngspicespice

I have a spice file, SPICE.cir, that I am able to run on a Linux machine from the command line using the command

ngspice< SPICE.cir > out.txt

where ngspice executes SPICE.cir and returns the results to the file out.txt However, if I run this same command on my windows machine an interactive ngspice terminal opens and the file out.txt is created, however, it is empty. What would be the best way to get have this code execute on both a Linux and Windows PC?

The following is a sample of a .cir file that I am using.

* SPICE code for sample

* define the resistor network


* Resistors in the X and Y
R_0 1 2 -32.9246383101
R_1 2 3 -36.8268175281
R_2 3 4 -18.5121699765
R_3 4 5 291.380742133
R_4 5 6 76.4701801649
R_5 1 7 260.192753419
R_6 2 8 28.6864653108
R_7 3 9 656.638760076
R_8 4 10 425.0948754
R_9 5 11 278.649240592
R_10 6 12 115.584603068
R_11 7 8 112.251132823
R_12 8 9 521.327416669
R_13 9 10 709.889775483
R_14 10 11 527.612868655
R_15 11 12 297.236159555
R_16 7 13 585.861592327
R_17 8 14 537.007183375
R_18 9 15 -39.0
R_19 10 16 652.328931117
R_20 11 17 409.056663689
R_21 12 18 1023.34074647
R_22 13 14 -14.8112103324
R_23 14 15 -34.0983085814
R_24 15 16 206.790871121
R_25 16 17 491.121230202
R_26 17 18 424.06856969
R_27 13 19 1307.88023391
R_28 14 20 1284.20493739
R_29 15 21 105.1430004
R_30 16 22 331.132043181
R_31 17 23 238.399912228
R_32 18 24 -39.0
R_33 19 20 37.0178415877
R_34 20 21 1042.32981711
R_35 21 22 187.339576302
R_36 22 23 758.125067173
R_37 23 24 -33.9145746511
R_38 19 25 433.259937648
R_39 20 26 10.0395200695
R_40 21 27 255.090530242
R_41 22 28 -39.0
R_42 23 29 188.752475275
R_43 24 30 -37.7244641078
R_44 25 26 127.369981119
R_45 26 27 838.065446045
R_46 27 28 783.347418275
R_47 28 29 641.379289071
R_48 29 30 -37.8986271113
R_49 25 31 173.342625045
R_50 26 32 237.449912364
R_51 27 33 1131.95881674
R_52 28 34 -14.282088485
R_53 29 35 -37.7976905623
R_54 30 36 10.7859147165
R_55 31 32 60.283289338
R_56 32 33 -39.0
R_57 33 34 1474.64791327
R_58 34 35 558.775756511
R_59 35 36 186.602454477

* contact Resistors
R_contact_V 6 37 8072.59067728
R_contact_GND 0 31 8609.51652548

* Add the voltage probe steps
v1 0 37 dc -9.86201143

* add operators
.op
.end

Best Answer

Here is an excerpt from chapter 15 of the user manual which I found on sourceforge:

If ngspice is started in interactive mode (see chapt. 16.4.2), like

ngspice circuitfile.cir

and no control section (.control ... .endc, see 16.4.3) is provided in the circuit file, the dot commands are not executed immediately, but are waiting for manually receiving the command “run”.

Chapter 16 is full of all kinds of useful information about invoking ngspice from the command line. You should probably read chapter 16. I found it here: http://ngspice.sourceforge.net/docs/ngspice-manual.pdf

When in doubt, read the manual.

Related Topic