New Binding Method extended to CSW device
This commit is contained in:
parent
5f065b2e7c
commit
b5a97e6c67
|
|
@ -1,5 +1,5 @@
|
||||||
/**********
|
/**********
|
||||||
Author: 2012 Francesco Lannutti
|
Author: 2013 Francesco Lannutti
|
||||||
**********/
|
**********/
|
||||||
|
|
||||||
#include "ngspice/ngspice.h"
|
#include "ngspice/ngspice.h"
|
||||||
|
|
@ -7,88 +7,105 @@ Author: 2012 Francesco Lannutti
|
||||||
#include "cswdefs.h"
|
#include "cswdefs.h"
|
||||||
#include "ngspice/sperror.h"
|
#include "ngspice/sperror.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static
|
||||||
int
|
int
|
||||||
CSWbindCSC(GENmodel *inModel, CKTcircuit *ckt)
|
BindCompare (const void *a, const void *b)
|
||||||
{
|
{
|
||||||
CSWmodel *model = (CSWmodel *)inModel;
|
BindElement *A, *B ;
|
||||||
int i ;
|
A = (BindElement *)a ;
|
||||||
|
B = (BindElement *)b ;
|
||||||
|
|
||||||
/* loop through all the csw models */
|
return ((int)(A->Sparse - B->Sparse)) ;
|
||||||
for( ; model != NULL; model = model->CSWnextModel ) {
|
|
||||||
CSWinstance *here;
|
|
||||||
|
|
||||||
/* loop through all the instances of the model */
|
|
||||||
for (here = model->CSWinstances; here != NULL ;
|
|
||||||
here = here->CSWnextInstance) {
|
|
||||||
|
|
||||||
i = 0 ;
|
|
||||||
if ((here-> CSWposNode != 0) && (here-> CSWposNode != 0)) {
|
|
||||||
while (here->CSWposPosptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
|
||||||
here->CSWposPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
|
||||||
if ((here-> CSWposNode != 0) && (here-> CSWnegNode != 0)) {
|
|
||||||
while (here->CSWposNegptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
|
||||||
here->CSWposNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
|
||||||
if ((here-> CSWnegNode != 0) && (here-> CSWposNode != 0)) {
|
|
||||||
while (here->CSWnegPosptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
|
||||||
here->CSWnegPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
|
||||||
if ((here-> CSWnegNode != 0) && (here-> CSWnegNode != 0)) {
|
|
||||||
while (here->CSWnegNegptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
|
||||||
here->CSWnegNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(OK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
CSWbindCSCComplex(GENmodel *inModel, CKTcircuit *ckt)
|
CSWbindCSC (GENmodel *inModel, CKTcircuit *ckt)
|
||||||
{
|
{
|
||||||
CSWmodel *model = (CSWmodel *)inModel;
|
CSWmodel *model = (CSWmodel *)inModel ;
|
||||||
int i ;
|
CSWinstance *here ;
|
||||||
|
double *i ;
|
||||||
|
BindElement *matched, *BindStruct ;
|
||||||
|
size_t nz ;
|
||||||
|
|
||||||
/* loop through all the csw models */
|
BindStruct = ckt->CKTmatrix->CKTbindStruct ;
|
||||||
for( ; model != NULL; model = model->CSWnextModel ) {
|
nz = (size_t)ckt->CKTmatrix->CKTklunz ;
|
||||||
CSWinstance *here;
|
|
||||||
|
|
||||||
|
/* loop through all the CSW models */
|
||||||
|
for ( ; model != NULL ; model = model->CSWnextModel)
|
||||||
|
{
|
||||||
/* loop through all the instances of the model */
|
/* loop through all the instances of the model */
|
||||||
for (here = model->CSWinstances; here != NULL ;
|
for (here = model->CSWinstances ; here != NULL ; here = here->CSWnextInstance)
|
||||||
here = here->CSWnextInstance) {
|
{
|
||||||
|
if ((here-> CSWposNode != 0) && (here-> CSWposNode != 0))
|
||||||
|
{
|
||||||
|
i = here->CSWposPosptr ;
|
||||||
|
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||||
|
here->CSWposPosptrStructPtr = matched ;
|
||||||
|
here->CSWposPosptr = matched->CSC ;
|
||||||
|
}
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> CSWposNode != 0) && (here-> CSWnegNode != 0))
|
||||||
if ((here-> CSWposNode != 0) && (here-> CSWposNode != 0)) {
|
{
|
||||||
while (here->CSWposPosptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
i = here->CSWposNegptr ;
|
||||||
here->CSWposPosptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||||
}
|
here->CSWposNegptrStructPtr = matched ;
|
||||||
|
here->CSWposNegptr = matched->CSC ;
|
||||||
|
}
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> CSWnegNode != 0) && (here-> CSWposNode != 0))
|
||||||
if ((here-> CSWposNode != 0) && (here-> CSWnegNode != 0)) {
|
{
|
||||||
while (here->CSWposNegptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
i = here->CSWnegPosptr ;
|
||||||
here->CSWposNegptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||||
}
|
here->CSWnegPosptrStructPtr = matched ;
|
||||||
|
here->CSWnegPosptr = matched->CSC ;
|
||||||
|
}
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> CSWnegNode != 0) && (here-> CSWnegNode != 0))
|
||||||
if ((here-> CSWnegNode != 0) && (here-> CSWposNode != 0)) {
|
{
|
||||||
while (here->CSWnegPosptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
i = here->CSWnegNegptr ;
|
||||||
here->CSWnegPosptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||||
}
|
here->CSWnegNegptrStructPtr = matched ;
|
||||||
|
here->CSWnegNegptr = matched->CSC ;
|
||||||
|
}
|
||||||
|
|
||||||
i = 0 ;
|
}
|
||||||
if ((here-> CSWnegNode != 0) && (here-> CSWnegNode != 0)) {
|
|
||||||
while (here->CSWnegNegptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
|
||||||
here->CSWnegNegptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return(OK);
|
|
||||||
|
return (OK) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
CSWbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt)
|
||||||
|
{
|
||||||
|
CSWmodel *model = (CSWmodel *)inModel ;
|
||||||
|
CSWinstance *here ;
|
||||||
|
|
||||||
|
NG_IGNORE (ckt) ;
|
||||||
|
|
||||||
|
/* loop through all the CSW models */
|
||||||
|
for ( ; model != NULL ; model = model->CSWnextModel)
|
||||||
|
{
|
||||||
|
/* loop through all the instances of the model */
|
||||||
|
for (here = model->CSWinstances ; here != NULL ; here = here->CSWnextInstance)
|
||||||
|
{
|
||||||
|
if ((here-> CSWposNode != 0) && (here-> CSWposNode != 0))
|
||||||
|
here->CSWposPosptr = here->CSWposPosptrStructPtr->CSC_Complex ;
|
||||||
|
|
||||||
|
if ((here-> CSWposNode != 0) && (here-> CSWnegNode != 0))
|
||||||
|
here->CSWposNegptr = here->CSWposNegptrStructPtr->CSC_Complex ;
|
||||||
|
|
||||||
|
if ((here-> CSWnegNode != 0) && (here-> CSWposNode != 0))
|
||||||
|
here->CSWnegPosptr = here->CSWnegPosptrStructPtr->CSC_Complex ;
|
||||||
|
|
||||||
|
if ((here-> CSWnegNode != 0) && (here-> CSWnegNode != 0))
|
||||||
|
here->CSWnegNegptr = here->CSWnegNegptrStructPtr->CSC_Complex ;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (OK) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
@ -96,41 +113,27 @@ CSWbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt)
|
||||||
{
|
{
|
||||||
CSWmodel *model = (CSWmodel *)inModel ;
|
CSWmodel *model = (CSWmodel *)inModel ;
|
||||||
CSWinstance *here ;
|
CSWinstance *here ;
|
||||||
int i ;
|
|
||||||
|
|
||||||
/* loop through all the csw models */
|
NG_IGNORE (ckt) ;
|
||||||
|
|
||||||
|
/* loop through all the CSW models */
|
||||||
for ( ; model != NULL ; model = model->CSWnextModel)
|
for ( ; model != NULL ; model = model->CSWnextModel)
|
||||||
{
|
{
|
||||||
/* loop through all the instances of the model */
|
/* loop through all the instances of the model */
|
||||||
for (here = model->CSWinstances ; here != NULL ; here = here->CSWnextInstance)
|
for (here = model->CSWinstances ; here != NULL ; here = here->CSWnextInstance)
|
||||||
{
|
{
|
||||||
i = 0 ;
|
if ((here-> CSWposNode != 0) && (here-> CSWposNode != 0))
|
||||||
if ((here->CSWposNode != 0) && (here->CSWposNode != 0))
|
here->CSWposPosptr = here->CSWposPosptrStructPtr->CSC ;
|
||||||
{
|
|
||||||
while (here->CSWposPosptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
|
||||||
here->CSWposPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> CSWposNode != 0) && (here-> CSWnegNode != 0))
|
||||||
if ((here->CSWposNode != 0) && (here->CSWnegNode != 0))
|
here->CSWposNegptr = here->CSWposNegptrStructPtr->CSC ;
|
||||||
{
|
|
||||||
while (here->CSWposNegptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
|
||||||
here->CSWposNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> CSWnegNode != 0) && (here-> CSWposNode != 0))
|
||||||
if ((here->CSWnegNode != 0) && (here->CSWposNode != 0))
|
here->CSWnegPosptr = here->CSWnegPosptrStructPtr->CSC ;
|
||||||
{
|
|
||||||
while (here->CSWnegPosptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
if ((here-> CSWnegNode != 0) && (here-> CSWnegNode != 0))
|
||||||
here->CSWnegPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
here->CSWnegNegptr = here->CSWnegNegptrStructPtr->CSC ;
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
|
||||||
if ((here->CSWnegNode != 0) && (here->CSWnegNode != 0))
|
|
||||||
{
|
|
||||||
while (here->CSWnegNegptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
|
||||||
here->CSWnegNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,14 @@ typedef struct sCSWinstance {
|
||||||
#else /* NONOISE */
|
#else /* NONOISE */
|
||||||
double *CSWnVar;
|
double *CSWnVar;
|
||||||
#endif /* NONOISE */
|
#endif /* NONOISE */
|
||||||
|
|
||||||
|
#ifdef KLU
|
||||||
|
BindElement *CSWposPosptrStructPtr ;
|
||||||
|
BindElement *CSWposNegptrStructPtr ;
|
||||||
|
BindElement *CSWnegPosptrStructPtr ;
|
||||||
|
BindElement *CSWnegNegptrStructPtr ;
|
||||||
|
#endif
|
||||||
|
|
||||||
} CSWinstance ;
|
} CSWinstance ;
|
||||||
|
|
||||||
/* data per model */
|
/* data per model */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue