From 45e2155e5773e3c91590be4c391ca5fbc647f4c5 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sun, 7 Jul 2019 13:55:41 +0200 Subject: [PATCH] Instead of the reverted commit 5542f2ec1 ("dio/diotemp.c, drop DIOgradingCoeff limit", 2017-07-18) allow setting a new limit for the diode grading coefficient by set DIOgradingCoeffMax=0.85 Default is 0.9 --- src/spicelib/devices/dio/diotemp.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/spicelib/devices/dio/diotemp.c b/src/spicelib/devices/dio/diotemp.c index 8853d70ec..f13d91faa 100644 --- a/src/spicelib/devices/dio/diotemp.c +++ b/src/spicelib/devices/dio/diotemp.c @@ -13,6 +13,7 @@ Modified by Paolo Nenzi 2003 and Dietmar Warning 2012 #include "ngspice/const.h" #include "ngspice/sperror.h" #include "ngspice/suffix.h" +#include "ngspice/cpdefs.h" int DIOtemp(GENmodel *inModel, CKTcircuit *ckt) @@ -32,18 +33,23 @@ DIOtemp(GENmodel *inModel, CKTcircuit *ckt) double factor; double tBreakdownVoltage; + double gclimit; + + if (!cp_getvar("DIOgradingCoeffMax", CP_REAL, &gclimit, 0)) + gclimit = 0.9; + /* loop through all the diode models */ for( ; model != NULL; model = DIOnextModel(model)) { if(!model->DIOnomTempGiven) { model->DIOnomTemp = ckt->CKTnomTemp; } vtnom = CONSTKoverQ * model->DIOnomTemp; - /* limit grading coeff to max of .9 */ - if(model->DIOgradingCoeff>.9) { + /* limit grading coeff to max of .9, set new limit with variable DIOgradingCoeffMax */ + if(model->DIOgradingCoeff>gclimit) { SPfrontEnd->IFerrorf (ERR_WARNING, - "%s: grading coefficient too large, limited to 0.9", - model->DIOmodName); - model->DIOgradingCoeff=.9; + "%s: grading coefficient too large, limited to %g", + model->DIOmodName, gclimit); + model->DIOgradingCoeff=gclimit; } /* limit activation energy to min of .1 */ if(model->DIOactivationEnergy<.1) { @@ -95,13 +101,13 @@ DIOtemp(GENmodel *inModel, CKTcircuit *ckt) here->DIOtGradingCoeff = model->DIOgradingCoeff * factor; /* limit temperature adjusted grading coeff - * to max of .9 + * to max of .9, or set new limit with variable DIOgradingCoeffMax */ - if(here->DIOtGradingCoeff>.9) { + if(here->DIOtGradingCoeff>gclimit) { SPfrontEnd->IFerrorf (ERR_WARNING, - "%s: temperature adjusted grading coefficient too large, limited to 0.9", - here->DIOname); - here->DIOtGradingCoeff=.9; + "%s: temperature adjusted grading coefficient too large, limited to %g", + here->DIOname, gclimit); + here->DIOtGradingCoeff=gclimit; } vt = CONSTKoverQ * here->DIOtemp;