From d269bd380509ef1782d4a5af12172ea801640b50 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Sun, 9 Jun 2013 11:06:05 +0200 Subject: [PATCH] nicomcof.c: xmu used to calculate trap integration coefficient --- src/maths/ni/nicomcof.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/maths/ni/nicomcof.c b/src/maths/ni/nicomcof.c index 7dcd7ed38..2dfb8f64b 100644 --- a/src/maths/ni/nicomcof.c +++ b/src/maths/ni/nicomcof.c @@ -7,6 +7,11 @@ Author: 1985 Thomas L. Quarles #include "ngspice/cktdefs.h" #include "ngspice/sperror.h" +/* xmu=0: Backward Euler, xmu=0.5: trapezoidal (standard), + xmu=0.48: good damping of current ringing, e.g. in R.O.s. + SpiceOpus adapts xmu to lower values if numerical oscillations + of current in capacitors are detected, t.b.d. */ +#define xmu 0.5 int NIcomCof(CKTcircuit *ckt) @@ -17,6 +22,7 @@ NIcomCof(CKTcircuit *ckt) double arg; double arg1; + /* this routine calculates the timestep-dependent terms used in the * numerical integration. */ @@ -35,10 +41,8 @@ NIcomCof(CKTcircuit *ckt) break; case 2: - ckt->CKTag[0]=1.0/ckt->CKTdelta/(1.0-0.5) ; - ckt->CKTag[1]=0.5/(1.0 - 0.5) ; - /* above lines should have 'xmu' instead of .5 eventually */ - /* (in all three places) */ + ckt->CKTag[0] = 1.0 / ckt->CKTdelta/(1.0 - xmu) ; + ckt->CKTag[1] = xmu / (1.0 - xmu) ; break; default: