Enable power measurement for W switch

This commit is contained in:
Holger Vogt 2022-08-29 20:30:23 +02:00
parent fe8eb26aaf
commit d39c60542d
2 changed files with 11 additions and 3 deletions

View File

@ -1,6 +1,6 @@
Switch test Switch test
.tran 2us 5ms .tran 2us 5ms
.probe I(w1) I(s1) I(s2) I(s3) ; alli .probe I(w1) I(s1) I(s2) I(s3) P(s2) P(w1); alli
* switch control voltage * switch control voltage
v1 1 0 DC 0.0 PWL (0 0 2e-3 2 4e-3 0) v1 1 0 DC 0.0 PWL (0 0 2e-3 2 4e-3 0)
* switch control voltage starting inside hysteresis window * switch control voltage starting inside hysteresis window
@ -25,7 +25,7 @@ s3 30 0 2 0 switch1 ON
.model switch1 sw vt=1 vh=0.2 ron=1 roff=10k .model switch1 sw vt=1 vh=0.2 ron=1 roff=10k
* *
w1 40 0 vm3 wswitch1 off w1 40 0 vm3 wswitch1 off
.model wswitch1 csw it=1m ih=0.2m ron=1 roff=10k .model wswitch1 csw it=1m ih=0.2m ron=1k roff=10k
* *
.control .control
run run
@ -40,5 +40,6 @@ plot v(30) vs v(2) retraceplot ; <-- get hysteresis loop
plot v(40) vs vm3#branch retraceplot ; <--- current controlled switch hysteresis plot v(40) vs vm3#branch retraceplot ; <--- current controlled switch hysteresis
plot i(s1) i(s2) i(s3) plot i(s1) i(s2) i(s3)
plot i(w1) vs i(vm3) plot i(w1) vs i(vm3)
plot s2:power w1:power
.endc .endc
.end .end

View File

@ -851,7 +851,14 @@ void inp_probe(struct card* deck)
continue; continue;
} }
char* thisline = tmpcard->line; char* thisline = tmpcard->line;
/* special treatment for controlled current sources and switches:
We have three or four tokens until model name, but only the first 2 are relevant nodes. */
if (strchr("fgsw", *instname))
numnodes = 2;
else
numnodes = get_number_terminals(thisline); numnodes = get_number_terminals(thisline);
int err = 0; int err = 0;
/* call fcn with power requested */ /* call fcn with power requested */
err = setallvsources(tmpcard, instances, instname, numnodes, haveall, TRUE); err = setallvsources(tmpcard, instances, instname, numnodes, haveall, TRUE);