qucs_s
qucs_s copied to clipboard
Variables are not allowed in PULSE source parameters
I'm trying to do a simple variable substitution from an equation into a device parameter, but it seems like the variable is being completely ignored. I'm on Qucs-S 0.0.23 using ngspice.
SPICE output
* Qucs 0.0.23 /tmp/test3.sch
.INCLUDE "/tmp/.mount_qucslvIHaR/usr/share/qucs-s/xspice_cmlib/include/ngspice_mathfunc.inc"
* Qucs 0.0.23 /tmp/test3.sch
.PARAM low=1e-3
.PARAM high=1e-3
V1 out 0 DC 0 PULSE( 0 1 0N 1N 1N 0 2e-09) AC 0
V2 out2 0 DC 0 PULSE( 0 1 0N 1N 1N 0.001 0.002) AC 0
.control
echo "" > spice4qucs.cir.noise
echo "" > spice4qucs.cir.pz
let low=1e-3
let high=1e-3
tran 9.90099e-05 0.01 0
write test3_tran.txt v(out) v(out2)
destroy all
reset
exit
.endc
.END
It seems like high
and low
are being ignored on V1 and the default source values are being substituted there.
It is a limitation of the Ngspice. The SIN
and PULSE
sources are defined as vectors. And variables are not allowed inside the vectors. Also related to #53
Do the other engines have this constraint? Which engine do you think is the best?
Do the other engines have this constraint?
Yes, all SPICE engines (XYCE, SpiceOpus) define these sources as vectors.
Which engine do you think is the best?
The Ngspice is the best SPICE engine because of good simulation performance and compatibility with the existing models. Ngspice is set as default simulation kernel since v0.0.23.
Below I will show four methods of changing VSRC pulse source parameters.
substitute vsrc pulse parameters
.param PW=1u PER=2u
V1 1 0 dc 0 pulse (0 1 0 1n 1n {PW} {PER})
.tran 1n 5u
.control
* original data
run
plot V(1)
* substitute via parameters
alterparam PW=0.5u
alterparam PER=2.2u
reset
run
plot tran2.V(1)+1.2 tran1.V(1)
* substitute directly via vectors pw2 per2
let pw2=1.3u
let per2=1.9u
alter @V1[pulse] = [ 0 1 0 1n 1n $&pw2 $&per2 ]
run
plot tran3.V(1)+2.4 tran2.V(1)+1.2 tran1.V(1)
* substitute again via parameters and vectors pw3, per3
let pw3=1.25u
let per3=1.6u
alterparam PW=$&pw3
alterparam PER=$&per3
reset
run
plot tran4.V(1)+3.6 tran3.V(1)+2.4 tran2.V(1)+1.2 tran1.V(1)
.endc
.end
What kind of limitations in ngspice do you still envision?
This issue may be resolved using full SPICE definition of the square voltage source. I have also recently added the alterparam
support #189 which may help to implement parameter sweep on PULSE source. Closing this.