From 7048a24b74c22490acd53eba210e91232c98c053 Mon Sep 17 00:00:00 2001 From: Francesco Lannutti Date: Sat, 17 Oct 2020 21:49:38 +0200 Subject: [PATCH] Added the KLU support to Noise Analysis --- src/spicelib/analysis/noisean.c | 39 ++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/spicelib/analysis/noisean.c b/src/spicelib/analysis/noisean.c index 3032858ee..3798a4c1c 100644 --- a/src/spicelib/analysis/noisean.c +++ b/src/spicelib/analysis/noisean.c @@ -31,8 +31,13 @@ Modified: 2001 AlansFixes /* gtri - end - wbk */ #endif - // fixme - // ugly hack to work around missing api to specify the "type" of signals +#ifdef KLU +#include "ngspice/devdefs.h" +#endif + +// fixme +// ugly hack to work around missing api to specify the "type" of signals + extern int fixme_onoise_type; extern int fixme_inoise_type; @@ -162,6 +167,7 @@ NOISEan(CKTcircuit* ckt, int restart) return(E_BADPARM); } + #ifdef XSPICE /* gtri - begin - wbk - Call EVTop if event-driven instances exist */ @@ -176,6 +182,19 @@ NOISEan(CKTcircuit* ckt, int restart) } else #endif + +#ifdef KLU + if (ckt->CKTmatrix->CKTkluMODE) + { + /* Conversion from Complex Matrix to Real Matrix */ + for (i = 0 ; i < DEVmaxnum ; i++) + if (DEVices [i] && DEVices [i]->DEVbindCSCComplexToReal && ckt->CKThead [i]) + DEVices [i]->DEVbindCSCComplexToReal (ckt->CKThead [i], ckt) ; + + ckt->CKTmatrix->SMPkluMatrix->KLUmatrixIsComplex = KLUmatrixReal ; + } +#endif + /* If no event-driven instances, do what SPICE normally does */ if (!ckt->CKTnoopac) { /* skip OP if option NOOPAC is set and circuit is linear */ error = CKTop(ckt, @@ -226,7 +245,6 @@ NOISEan(CKTcircuit* ckt, int restart) /* gtri - end - wbk */ #endif - /* Patch to noisean.c by Richard D. McRoberts. */ ckt->CKTmode = (ckt->CKTmode & MODEUIC) | MODEDCOP | MODEINITSMSIG; error = CKTload(ckt); @@ -357,6 +375,21 @@ NOISEan(CKTcircuit* ckt, int restart) /* gtri - end - wbk */ #endif +#ifdef KLU + if (ckt->CKTmatrix->CKTkluMODE) + { + /* Conversion from Real Matrix to Complex Matrix */ + if (!ckt->CKTmatrix->SMPkluMatrix->KLUmatrixIsComplex) + { + for (i = 0 ; i < DEVmaxnum ; i++) + if (DEVices [i] && DEVices [i]->DEVbindCSCComplex && ckt->CKThead [i]) + DEVices [i]->DEVbindCSCComplex (ckt->CKThead [i], ckt) ; + + ckt->CKTmatrix->SMPkluMatrix->KLUmatrixIsComplex = KLUMatrixComplex ; + } + } +#endif + /* do the noise analysis over all frequencies */ while (data->freq <= job->NstopFreq + freqTol) {