New Binding Method extended to SW device
This commit is contained in:
parent
476542e754
commit
07d64a68b5
|
|
@ -1,5 +1,5 @@
|
||||||
/**********
|
/**********
|
||||||
Author: 2012 Francesco Lannutti
|
Author: 2013 Francesco Lannutti
|
||||||
**********/
|
**********/
|
||||||
|
|
||||||
#include "ngspice/ngspice.h"
|
#include "ngspice/ngspice.h"
|
||||||
|
|
@ -7,82 +7,105 @@ Author: 2012 Francesco Lannutti
|
||||||
#include "swdefs.h"
|
#include "swdefs.h"
|
||||||
#include "ngspice/sperror.h"
|
#include "ngspice/sperror.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static
|
||||||
int
|
int
|
||||||
SWbindCSC(GENmodel *inModel, CKTcircuit *ckt)
|
BindCompare (const void *a, const void *b)
|
||||||
{
|
{
|
||||||
SWmodel *model = (SWmodel *)inModel;
|
BindElement *A, *B ;
|
||||||
int i ;
|
A = (BindElement *)a ;
|
||||||
|
B = (BindElement *)b ;
|
||||||
|
|
||||||
/* loop through all the sw models */
|
return ((int)(A->Sparse - B->Sparse)) ;
|
||||||
for( ; model != NULL; model = model->SWnextModel ) {
|
|
||||||
SWinstance *here;
|
|
||||||
|
|
||||||
/* loop through all the instances of the model */
|
|
||||||
for (here = model->SWinstances; here != NULL ;
|
|
||||||
here = here->SWnextInstance) {
|
|
||||||
|
|
||||||
i = 0 ;
|
|
||||||
if ((here-> SWposNode != 0) && (here-> SWposNode != 0)) {
|
|
||||||
while (here->SWposPosptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
|
||||||
here->SWposPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
i = 0 ;
|
|
||||||
if ((here-> SWposNode != 0) && (here-> SWnegNode != 0)) {
|
|
||||||
while (here->SWposNegptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
|
||||||
here->SWposNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
i = 0 ;
|
|
||||||
if ((here-> SWnegNode != 0) && (here-> SWposNode != 0)) {
|
|
||||||
while (here->SWnegPosptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
|
||||||
here->SWnegPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
i = 0 ;
|
|
||||||
if ((here-> SWnegNode != 0) && (here-> SWnegNode != 0)) {
|
|
||||||
while (here->SWnegNegptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
|
||||||
here->SWnegNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(OK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
SWbindCSCComplex(GENmodel *inModel, CKTcircuit *ckt)
|
SWbindCSC (GENmodel *inModel, CKTcircuit *ckt)
|
||||||
{
|
{
|
||||||
SWmodel *model = (SWmodel *)inModel;
|
SWmodel *model = (SWmodel *)inModel ;
|
||||||
int i ;
|
SWinstance *here ;
|
||||||
|
double *i ;
|
||||||
|
BindElement *matched, *BindStruct ;
|
||||||
|
size_t nz ;
|
||||||
|
|
||||||
/* loop through all the sw models */
|
BindStruct = ckt->CKTmatrix->CKTbindStruct ;
|
||||||
for( ; model != NULL; model = model->SWnextModel ) {
|
nz = (size_t)ckt->CKTmatrix->CKTklunz ;
|
||||||
SWinstance *here;
|
|
||||||
|
|
||||||
|
/* loop through all the SW models */
|
||||||
|
for ( ; model != NULL ; model = model->SWnextModel)
|
||||||
|
{
|
||||||
/* loop through all the instances of the model */
|
/* loop through all the instances of the model */
|
||||||
for (here = model->SWinstances; here != NULL ;
|
for (here = model->SWinstances ; here != NULL ; here = here->SWnextInstance)
|
||||||
here = here->SWnextInstance) {
|
{
|
||||||
|
if ((here-> SWposNode != 0) && (here-> SWposNode != 0))
|
||||||
|
{
|
||||||
|
i = here->SWposPosptr ;
|
||||||
|
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||||
|
here->SWposPosptrStructPtr = matched ;
|
||||||
|
here->SWposPosptr = matched->CSC ;
|
||||||
|
}
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> SWposNode != 0) && (here-> SWnegNode != 0))
|
||||||
if ((here-> SWposNode != 0) && (here-> SWposNode != 0)) {
|
{
|
||||||
while (here->SWposPosptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
i = here->SWposNegptr ;
|
||||||
here->SWposPosptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||||
}
|
here->SWposNegptrStructPtr = matched ;
|
||||||
i = 0 ;
|
here->SWposNegptr = matched->CSC ;
|
||||||
if ((here-> SWposNode != 0) && (here-> SWnegNode != 0)) {
|
}
|
||||||
while (here->SWposNegptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
|
||||||
here->SWposNegptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
if ((here-> SWnegNode != 0) && (here-> SWposNode != 0))
|
||||||
}
|
{
|
||||||
i = 0 ;
|
i = here->SWnegPosptr ;
|
||||||
if ((here-> SWnegNode != 0) && (here-> SWposNode != 0)) {
|
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||||
while (here->SWnegPosptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
here->SWnegPosptrStructPtr = matched ;
|
||||||
here->SWnegPosptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
here->SWnegPosptr = matched->CSC ;
|
||||||
}
|
}
|
||||||
i = 0 ;
|
|
||||||
if ((here-> SWnegNode != 0) && (here-> SWnegNode != 0)) {
|
if ((here-> SWnegNode != 0) && (here-> SWnegNode != 0))
|
||||||
while (here->SWnegNegptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
{
|
||||||
here->SWnegNegptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
i = here->SWnegNegptr ;
|
||||||
}
|
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||||
}
|
here->SWnegNegptrStructPtr = matched ;
|
||||||
|
here->SWnegNegptr = matched->CSC ;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return(OK);
|
|
||||||
|
return (OK) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
SWbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt)
|
||||||
|
{
|
||||||
|
SWmodel *model = (SWmodel *)inModel ;
|
||||||
|
SWinstance *here ;
|
||||||
|
|
||||||
|
NG_IGNORE (ckt) ;
|
||||||
|
|
||||||
|
/* loop through all the SW models */
|
||||||
|
for ( ; model != NULL ; model = model->SWnextModel)
|
||||||
|
{
|
||||||
|
/* loop through all the instances of the model */
|
||||||
|
for (here = model->SWinstances ; here != NULL ; here = here->SWnextInstance)
|
||||||
|
{
|
||||||
|
if ((here-> SWposNode != 0) && (here-> SWposNode != 0))
|
||||||
|
here->SWposPosptr = here->SWposPosptrStructPtr->CSC_Complex ;
|
||||||
|
|
||||||
|
if ((here-> SWposNode != 0) && (here-> SWnegNode != 0))
|
||||||
|
here->SWposNegptr = here->SWposNegptrStructPtr->CSC_Complex ;
|
||||||
|
|
||||||
|
if ((here-> SWnegNode != 0) && (here-> SWposNode != 0))
|
||||||
|
here->SWnegPosptr = here->SWnegPosptrStructPtr->CSC_Complex ;
|
||||||
|
|
||||||
|
if ((here-> SWnegNode != 0) && (here-> SWnegNode != 0))
|
||||||
|
here->SWnegNegptr = here->SWnegNegptrStructPtr->CSC_Complex ;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (OK) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
@ -90,43 +113,29 @@ SWbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt)
|
||||||
{
|
{
|
||||||
SWmodel *model = (SWmodel *)inModel ;
|
SWmodel *model = (SWmodel *)inModel ;
|
||||||
SWinstance *here ;
|
SWinstance *here ;
|
||||||
int i ;
|
|
||||||
|
|
||||||
/* loop through all the sw models */
|
NG_IGNORE (ckt) ;
|
||||||
|
|
||||||
|
/* loop through all the SW models */
|
||||||
for ( ; model != NULL ; model = model->SWnextModel)
|
for ( ; model != NULL ; model = model->SWnextModel)
|
||||||
{
|
{
|
||||||
/* loop through all the instances of the model */
|
/* loop through all the instances of the model */
|
||||||
for (here = model->SWinstances ; here != NULL ; here = here->SWnextInstance)
|
for (here = model->SWinstances ; here != NULL ; here = here->SWnextInstance)
|
||||||
{
|
{
|
||||||
i = 0 ;
|
if ((here-> SWposNode != 0) && (here-> SWposNode != 0))
|
||||||
if ((here->SWposNode != 0) && (here->SWposNode != 0))
|
here->SWposPosptr = here->SWposPosptrStructPtr->CSC ;
|
||||||
{
|
|
||||||
while (here->SWposPosptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
|
||||||
here->SWposPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> SWposNode != 0) && (here-> SWnegNode != 0))
|
||||||
if ((here->SWposNode != 0) && (here->SWnegNode != 0))
|
here->SWposNegptr = here->SWposNegptrStructPtr->CSC ;
|
||||||
{
|
|
||||||
while (here->SWposNegptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
|
||||||
here->SWposNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> SWnegNode != 0) && (here-> SWposNode != 0))
|
||||||
if ((here->SWnegNode != 0) && (here->SWposNode != 0))
|
here->SWnegPosptr = here->SWnegPosptrStructPtr->CSC ;
|
||||||
{
|
|
||||||
while (here->SWnegPosptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
if ((here-> SWnegNode != 0) && (here-> SWnegNode != 0))
|
||||||
here->SWnegPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
here->SWnegNegptr = here->SWnegNegptrStructPtr->CSC ;
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
|
||||||
if ((here->SWnegNode != 0) && (here->SWnegNode != 0))
|
|
||||||
{
|
|
||||||
while (here->SWnegNegptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
|
||||||
here->SWnegNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (OK) ;
|
return (OK) ;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,14 @@ typedef struct sSWinstance {
|
||||||
#else /* NONOISE */
|
#else /* NONOISE */
|
||||||
double *SWnVar;
|
double *SWnVar;
|
||||||
#endif /* NONOISE */
|
#endif /* NONOISE */
|
||||||
|
|
||||||
|
#ifdef KLU
|
||||||
|
BindElement *SWposPosptrStructPtr ;
|
||||||
|
BindElement *SWposNegptrStructPtr ;
|
||||||
|
BindElement *SWnegPosptrStructPtr ;
|
||||||
|
BindElement *SWnegNegptrStructPtr ;
|
||||||
|
#endif
|
||||||
|
|
||||||
} SWinstance ;
|
} SWinstance ;
|
||||||
|
|
||||||
/* data per model */
|
/* data per model */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue