Stefan Schippers
09/11/2022, 5:06 PMngspice 36 -> let x=11
ngspice 37 -> set y=test{$&x}.raw
ngspice 38 -> echo $y
test11.raw
ngspice 39 -> write $y
binary raw file "test11.raw"
Harald Pretl
09/11/2022, 5:08 PMStefan Schippers
09/11/2022, 5:11 PM17.8
or the ngspice user manual. They have so called csh style variables and 'vectors'. the let x=11
creates a 1-length vector. All numeric stuff is done with vectors, including a loop variable. Then you have these csh style variables and assigning a vector to a csh variable is done with $&
. I have struggled myself a lot in this jungle.Harald Pretl
09/11/2022, 5:15 PMlet
and set
? this is where messed up.Stefan Schippers
09/11/2022, 8:47 PMlet
for anything that has a numeric value and you need to do some calculations with (they call these '`vectors`' even for 1-length).
Use set
to create '`variables`'. These are very similar to shell variables, but as far as i know you can't do math on these. On the other hand these '`variables`' can contain anything.
The following lines show how to go back and forth with variables and vectors. Use echo
with $
to get value of variables, use print
to get value of vectors.
Vectors can be operated on as a whole: let power = v(out) * i(vmeasure)
creates a new vector representing a power, this can be plotted like any other simulation variable.
ngspice 270 -> set a=1
ngspice 271 -> echo $a
1
ngspice 272 -> let b=$a
ngspice 273 -> let b = b + 1
ngspice 274 -> print b
b = 2.000000e+00
ngspice 275 -> set c = $&b
ngspice 277 -> echo $c
2