From f12592871aae6f6bb1f88dab333e6bbdf7a4cdd8 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sun, 30 May 2021 00:00:26 +0200 Subject: [PATCH] Set derivative d out/d contrl to 0 if outside of switching range. Disable auto derivatives. Enable algorithmic derivatives. --- src/xspice/icm/xtradev/pswitch/cfunc.mod | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/xspice/icm/xtradev/pswitch/cfunc.mod b/src/xspice/icm/xtradev/pswitch/cfunc.mod index 50b9e4665..f00a0d8ba 100644 --- a/src/xspice/icm/xtradev/pswitch/cfunc.mod +++ b/src/xspice/icm/xtradev/pswitch/cfunc.mod @@ -231,6 +231,10 @@ void cm_pswitch(ARGS) /* structure holding parms, } pi_pcntl = INPUT(out) / r * (loc->c2 * inmean * inmean - loc->c1); + if(r == r_on) + pi_pcntl = 0; + if(r == r_off) + pi_pcntl = 0; pi_pvout = 1.0 / r; } @@ -246,9 +250,9 @@ void cm_pswitch(ARGS) /* structure holding parms, if(ANALYSIS != MIF_AC) { /* Output DC & Transient Values */ OUTPUT(out) = INPUT(out) / r; -// PARTIAL(out,out) = pi_pvout; -// PARTIAL(out,cntl_in) = pi_pcntl; - cm_analog_auto_partial(); + PARTIAL(out,out) = pi_pvout; + PARTIAL(out,cntl_in) = pi_pcntl; +// cm_analog_auto_partial(); /* Note that the minus signs are required because current is positive flowing INTO rather than OUT OF a component node. */