Restrict the limit for exp function (linear growth when exponent
is larger than 14, commit [93a76d]) to the PSPICE compatibility mode.
This commit is contained in:
parent
8da2f3c16d
commit
e2cf397b6d
|
|
@ -5,6 +5,7 @@ Author: 1987 Wayne A. Christopher, U. C. Berkeley CAD Group
|
|||
//#define TRACE
|
||||
|
||||
#include "ngspice/ngspice.h"
|
||||
#include "ngspice/compatmode.h"
|
||||
#include "ngspice/ifsim.h"
|
||||
#include "ngspice/iferrmsg.h"
|
||||
#include "ngspice/inpdefs.h"
|
||||
|
|
@ -448,11 +449,16 @@ static INPparseNode *PTdifferentiate(INPparseNode * p, int varnum)
|
|||
break;
|
||||
|
||||
case PTF_EXP: /* u > EXPARGMAX -> EXPMAX, that is exp(EXPARGMAX), else exp(u) */
|
||||
arg1 = mkb(PT_TERN,
|
||||
mkf(PTF_GT0, mkb(PT_MINUS, p->left, mkcon(EXPARGMAX))),
|
||||
mkb(PT_COMMA,
|
||||
mkcon(EXPMAX),
|
||||
mkf(PTF_EXP, p->left)));
|
||||
if (newcompat.ps) {
|
||||
arg1 = mkb(PT_TERN,
|
||||
mkf(PTF_GT0, mkb(PT_MINUS, p->left, mkcon(EXPARGMAX))),
|
||||
mkb(PT_COMMA,
|
||||
mkcon(EXPMAX),
|
||||
mkf(PTF_EXP, p->left)));
|
||||
}
|
||||
else { /* exp(u) */
|
||||
arg1 = mkf(PTF_EXP, p->left);
|
||||
}
|
||||
|
||||
#ifdef TRACE1
|
||||
printf("debug exp, %s, returns; ", __func__);
|
||||
|
|
|
|||
|
|
@ -215,11 +215,12 @@ PTcosh(double arg)
|
|||
return (cosh(arg));
|
||||
}
|
||||
|
||||
/* Limit the exp: If arg > EXPARGMAX (arbitrarily selected to 14), continue with linear output */
|
||||
/* Limit the exp: If arg > EXPARGMAX (arbitrarily selected to 14), continue with linear output,
|
||||
if compatmode PSPICE is selected*/
|
||||
double
|
||||
PTexp(double arg)
|
||||
{
|
||||
if (arg > EXPARGMAX)
|
||||
if (newcompat.ps && arg > EXPARGMAX)
|
||||
return EXPMAX * (arg - EXPARGMAX + 1.);
|
||||
else
|
||||
return (exp(arg));
|
||||
|
|
|
|||
Loading…
Reference in New Issue