Implemented a new check for the KCL Verification, based on the maximum of the unknown current branches at each voltage node.

Please note that this check introduces the theoretically correct check, but, since achieving this target involves the perfect knowledge of every model,
 we can use this suboptimal and practical check (to be extended with the other possible unknown current branches)
This commit is contained in:
Francesco Lannutti 2013-06-06 08:05:27 +02:00
parent 8d166ebcc9
commit e102ebebe3
3 changed files with 79 additions and 0 deletions

View File

@ -0,0 +1,21 @@
/**********
Author: 2013 Francesco Lannutti
**********/
#include "ngspice/ngspice.h"
#include "ngspice/sperror.h"
#include "ngspice/cktdefs.h"
int
CKTmkCurKCL (CKTcircuit *ckt, int i, double **node)
{
CKTmkCurKCLnode *tempNode ;
tempNode = TMALLOC (CKTmkCurKCLnode, 1) ;
tempNode->KCLcurrent = 0.0 ;
tempNode->next = ckt->CKTmkCurKCLarray [i] ;
ckt->CKTmkCurKCLarray [i] = tempNode ;
*node = &(tempNode->KCLcurrent) ;
return (OK) ;
}

View File

@ -0,0 +1,29 @@
/**********
Author: 2013 Francesco Lannutti
**********/
#include "ngspice/ngspice.h"
#include "ngspice/cktdefs.h"
#include "inddefs.h"
#include "ngspice/sperror.h"
int
INDnodeIsNonLinear (GENmodel *inModel, CKTcircuit *ckt)
{
INDmodel *model = (INDmodel *)inModel ;
INDinstance *here ;
int error ;
/* loop through all the IND models */
for ( ; model != NULL ; model = model->INDnextModel)
{
/* loop through all the instances of the model */
for (here = model->INDinstances ; here != NULL ; here = here->INDnextInstance)
{
error = CKTmkCurKCL (ckt, here->INDposNode, &(here->KCLcurrentPos)) ;
error = CKTmkCurKCL (ckt, here->INDnegNode, &(here->KCLcurrentNeg)) ;
}
}
return (OK) ;
}

View File

@ -0,0 +1,29 @@
/**********
Author: 2013 Francesco Lannutti
**********/
#include "ngspice/ngspice.h"
#include "ngspice/cktdefs.h"
#include "vsrcdefs.h"
#include "ngspice/sperror.h"
int
VSRCnodeIsNonLinear (GENmodel *inModel, CKTcircuit *ckt)
{
VSRCmodel *model = (VSRCmodel *)inModel ;
VSRCinstance *here ;
int error ;
/* loop through all the VSRC models */
for ( ; model != NULL ; model = model->VSRCnextModel)
{
/* loop through all the instances of the model */
for (here = model->VSRCinstances ; here != NULL ; here = here->VSRCnextInstance)
{
error = CKTmkCurKCL (ckt, here->VSRCposNode, &(here->KCLcurrentPos)) ;
error = CKTmkCurKCL (ckt, here->VSRCnegNode, &(here->KCLcurrentNeg)) ;
}
}
return (OK) ;
}