New Binding Method extended to CCCS device
This commit is contained in:
parent
202c118331
commit
3b2468b9ba
|
|
@ -1,5 +1,5 @@
|
|||
/**********
|
||||
Author: 2012 Francesco Lannutti
|
||||
Author: 2013 Francesco Lannutti
|
||||
**********/
|
||||
|
||||
#include "ngspice/ngspice.h"
|
||||
|
|
@ -7,64 +7,83 @@ Author: 2012 Francesco Lannutti
|
|||
#include "cccsdefs.h"
|
||||
#include "ngspice/sperror.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
static
|
||||
int
|
||||
CCCSbindCSC(GENmodel *inModel, CKTcircuit *ckt)
|
||||
BindCompare (const void *a, const void *b)
|
||||
{
|
||||
CCCSmodel *model = (CCCSmodel *)inModel;
|
||||
int i ;
|
||||
BindElement *A, *B ;
|
||||
A = (BindElement *)a ;
|
||||
B = (BindElement *)b ;
|
||||
|
||||
/* loop through all the cccs models */
|
||||
for( ; model != NULL; model = model->CCCSnextModel ) {
|
||||
CCCSinstance *here;
|
||||
|
||||
/* loop through all the instances of the model */
|
||||
for (here = model->CCCSinstances; here != NULL ;
|
||||
here = here->CCCSnextInstance) {
|
||||
|
||||
i = 0 ;
|
||||
if ((here->CCCSposNode != 0) && (here->CCCScontBranch != 0)) {
|
||||
while (here->CCCSposContBrptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
||||
here->CCCSposContBrptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
||||
}
|
||||
|
||||
i = 0 ;
|
||||
if ((here->CCCSnegNode != 0) && (here->CCCScontBranch != 0)) {
|
||||
while (here->CCCSnegContBrptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
||||
here->CCCSnegContBrptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(OK);
|
||||
return ((int)(A->Sparse - B->Sparse)) ;
|
||||
}
|
||||
|
||||
int
|
||||
CCCSbindCSCComplex(GENmodel *inModel, CKTcircuit *ckt)
|
||||
CCCSbindCSC (GENmodel *inModel, CKTcircuit *ckt)
|
||||
{
|
||||
CCCSmodel *model = (CCCSmodel *)inModel;
|
||||
int i ;
|
||||
CCCSmodel *model = (CCCSmodel *)inModel ;
|
||||
CCCSinstance *here ;
|
||||
double *i ;
|
||||
BindElement *matched, *BindStruct ;
|
||||
size_t nz ;
|
||||
|
||||
/* loop through all the cccs models */
|
||||
for( ; model != NULL; model = model->CCCSnextModel ) {
|
||||
CCCSinstance *here;
|
||||
BindStruct = ckt->CKTmatrix->CKTbindStruct ;
|
||||
nz = (size_t)ckt->CKTmatrix->CKTklunz ;
|
||||
|
||||
/* loop through all the CCCS models */
|
||||
for ( ; model != NULL ; model = model->CCCSnextModel)
|
||||
{
|
||||
/* loop through all the instances of the model */
|
||||
for (here = model->CCCSinstances; here != NULL ;
|
||||
here = here->CCCSnextInstance) {
|
||||
for (here = model->CCCSinstances ; here != NULL ; here = here->CCCSnextInstance)
|
||||
{
|
||||
if ((here->CCCSposNode != 0) && (here->CCCScontBranch != 0))
|
||||
{
|
||||
i = here->CCCSposContBrptr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->CCCSposContBrptrStructPtr = matched ;
|
||||
here->CCCSposContBrptr = matched->CSC ;
|
||||
}
|
||||
|
||||
i = 0 ;
|
||||
if ((here->CCCSposNode != 0) && (here->CCCScontBranch != 0)) {
|
||||
while (here->CCCSposContBrptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
||||
here->CCCSposContBrptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
||||
}
|
||||
if ((here->CCCSnegNode != 0) && (here->CCCScontBranch != 0))
|
||||
{
|
||||
i = here->CCCSnegContBrptr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->CCCSnegContBrptrStructPtr = matched ;
|
||||
here->CCCSnegContBrptr = matched->CSC ;
|
||||
}
|
||||
|
||||
i = 0 ;
|
||||
if ((here->CCCSnegNode != 0) && (here->CCCScontBranch != 0)) {
|
||||
while (here->CCCSnegContBrptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
||||
here->CCCSnegContBrptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(OK);
|
||||
|
||||
return (OK) ;
|
||||
}
|
||||
|
||||
int
|
||||
CCCSbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt)
|
||||
{
|
||||
CCCSmodel *model = (CCCSmodel *)inModel ;
|
||||
CCCSinstance *here ;
|
||||
|
||||
NG_IGNORE (ckt) ;
|
||||
|
||||
/* loop through all the CCCS models */
|
||||
for ( ; model != NULL ; model = model->CCCSnextModel)
|
||||
{
|
||||
/* loop through all the instances of the model */
|
||||
for (here = model->CCCSinstances ; here != NULL ; here = here->CCCSnextInstance)
|
||||
{
|
||||
if ((here->CCCSposNode != 0) && (here->CCCScontBranch != 0))
|
||||
here->CCCSposContBrptr = here->CCCSposContBrptrStructPtr->CSC_Complex ;
|
||||
|
||||
if ((here->CCCSnegNode != 0) && (here->CCCScontBranch != 0))
|
||||
here->CCCSnegContBrptr = here->CCCSnegContBrptrStructPtr->CSC_Complex ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return (OK) ;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -72,29 +91,23 @@ CCCSbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt)
|
|||
{
|
||||
CCCSmodel *model = (CCCSmodel *)inModel ;
|
||||
CCCSinstance *here ;
|
||||
int i ;
|
||||
|
||||
/* loop through all the CurrentControlledCurrentSource models */
|
||||
NG_IGNORE (ckt) ;
|
||||
|
||||
/* loop through all the CCCS models */
|
||||
for ( ; model != NULL ; model = model->CCCSnextModel)
|
||||
{
|
||||
/* loop through all the instances of the model */
|
||||
for (here = model->CCCSinstances ; here != NULL ; here = here->CCCSnextInstance)
|
||||
{
|
||||
i = 0 ;
|
||||
if ((here->CCCSposNode != 0) && (here->CCCScontBranch != 0))
|
||||
{
|
||||
while (here->CCCSposContBrptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
||||
here->CCCSposContBrptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
||||
}
|
||||
here->CCCSposContBrptr = here->CCCSposContBrptrStructPtr->CSC ;
|
||||
|
||||
i = 0 ;
|
||||
if ((here->CCCSnegNode != 0) && (here->CCCScontBranch != 0))
|
||||
{
|
||||
while (here->CCCSnegContBrptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
||||
here->CCCSnegContBrptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
||||
}
|
||||
here->CCCSnegContBrptr = here->CCCSnegContBrptrStructPtr->CSC ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return (OK) ;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,11 @@ typedef struct sCCCSinstance {
|
|||
int CCCSsenParmNo; /* parameter # for sensitivity use;
|
||||
set equal to 0 if not a design parameter*/
|
||||
|
||||
#ifdef KLU
|
||||
BindElement *CCCSposContBrptrStructPtr ;
|
||||
BindElement *CCCSnegContBrptrStructPtr ;
|
||||
#endif
|
||||
|
||||
} CCCSinstance ;
|
||||
|
||||
/* per model data */
|
||||
|
|
|
|||
Loading…
Reference in New Issue