New Binding Method extended to NUMD device
This commit is contained in:
parent
7b0d5f00d6
commit
8ec125dce4
|
|
@ -24,6 +24,18 @@ libnumd_la_SOURCES = \
|
|||
numdtrun.c
|
||||
|
||||
|
||||
if KLU_WANTED
|
||||
libnumd_la_SOURCES += numdbindCSC.c
|
||||
endif
|
||||
|
||||
if SuperLU_WANTED
|
||||
libnumd_la_SOURCES += numdbindCSC.c
|
||||
endif
|
||||
|
||||
if UMFPACK_WANTED
|
||||
libnumd_la_SOURCES += numdbindCSC.c
|
||||
endif
|
||||
|
||||
AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include
|
||||
AM_CFLAGS = $(STATIC)
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,141 @@
|
|||
/**********
|
||||
Author: 2013 Francesco Lannutti
|
||||
**********/
|
||||
|
||||
#include "ngspice/ngspice.h"
|
||||
#include "ngspice/cktdefs.h"
|
||||
#include "numddefs.h"
|
||||
#include "ngspice/sperror.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
static
|
||||
int
|
||||
BindCompare (const void *a, const void *b)
|
||||
{
|
||||
BindElement *A, *B ;
|
||||
A = (BindElement *)a ;
|
||||
B = (BindElement *)b ;
|
||||
|
||||
return ((int)(A->Sparse - B->Sparse)) ;
|
||||
}
|
||||
|
||||
int
|
||||
NUMDbindCSC (GENmodel *inModel, CKTcircuit *ckt)
|
||||
{
|
||||
NUMDmodel *model = (NUMDmodel *)inModel ;
|
||||
NUMDinstance *here ;
|
||||
double *i ;
|
||||
BindElement *matched, *BindStruct ;
|
||||
size_t nz ;
|
||||
|
||||
BindStruct = ckt->CKTmatrix->CKTbindStruct ;
|
||||
nz = (size_t)ckt->CKTmatrix->CKTklunz ;
|
||||
|
||||
/* loop through all the NUMD models */
|
||||
for ( ; model != NULL ; model = model->NUMDnextModel)
|
||||
{
|
||||
/* loop through all the instances of the model */
|
||||
for (here = model->NUMDinstances ; here != NULL ; here = here->NUMDnextInstance)
|
||||
{
|
||||
if ((here-> NUMDposNode != 0) && (here-> NUMDposNode != 0))
|
||||
{
|
||||
i = here->NUMDposPosPtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMDposPosStructPtr = matched ;
|
||||
here->NUMDposPosPtr = matched->CSC ;
|
||||
}
|
||||
|
||||
if ((here-> NUMDnegNode != 0) && (here-> NUMDnegNode != 0))
|
||||
{
|
||||
i = here->NUMDnegNegPtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMDnegNegStructPtr = matched ;
|
||||
here->NUMDnegNegPtr = matched->CSC ;
|
||||
}
|
||||
|
||||
if ((here-> NUMDnegNode != 0) && (here-> NUMDposNode != 0))
|
||||
{
|
||||
i = here->NUMDnegPosPtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMDnegPosStructPtr = matched ;
|
||||
here->NUMDnegPosPtr = matched->CSC ;
|
||||
}
|
||||
|
||||
if ((here-> NUMDposNode != 0) && (here-> NUMDnegNode != 0))
|
||||
{
|
||||
i = here->NUMDposNegPtr ;
|
||||
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||
here->NUMDposNegStructPtr = matched ;
|
||||
here->NUMDposNegPtr = matched->CSC ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return (OK) ;
|
||||
}
|
||||
|
||||
int
|
||||
NUMDbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt)
|
||||
{
|
||||
NUMDmodel *model = (NUMDmodel *)inModel ;
|
||||
NUMDinstance *here ;
|
||||
|
||||
NG_IGNORE (ckt) ;
|
||||
|
||||
/* loop through all the NUMD models */
|
||||
for ( ; model != NULL ; model = model->NUMDnextModel)
|
||||
{
|
||||
/* loop through all the instances of the model */
|
||||
for (here = model->NUMDinstances ; here != NULL ; here = here->NUMDnextInstance)
|
||||
{
|
||||
if ((here-> NUMDposNode != 0) && (here-> NUMDposNode != 0))
|
||||
here->NUMDposPosPtr = here->NUMDposPosStructPtr->CSC_Complex ;
|
||||
|
||||
if ((here-> NUMDnegNode != 0) && (here-> NUMDnegNode != 0))
|
||||
here->NUMDnegNegPtr = here->NUMDnegNegStructPtr->CSC_Complex ;
|
||||
|
||||
if ((here-> NUMDnegNode != 0) && (here-> NUMDposNode != 0))
|
||||
here->NUMDnegPosPtr = here->NUMDnegPosStructPtr->CSC_Complex ;
|
||||
|
||||
if ((here-> NUMDposNode != 0) && (here-> NUMDnegNode != 0))
|
||||
here->NUMDposNegPtr = here->NUMDposNegStructPtr->CSC_Complex ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return (OK) ;
|
||||
}
|
||||
|
||||
int
|
||||
NUMDbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt)
|
||||
{
|
||||
NUMDmodel *model = (NUMDmodel *)inModel ;
|
||||
NUMDinstance *here ;
|
||||
|
||||
NG_IGNORE (ckt) ;
|
||||
|
||||
/* loop through all the NUMD models */
|
||||
for ( ; model != NULL ; model = model->NUMDnextModel)
|
||||
{
|
||||
/* loop through all the instances of the model */
|
||||
for (here = model->NUMDinstances ; here != NULL ; here = here->NUMDnextInstance)
|
||||
{
|
||||
if ((here-> NUMDposNode != 0) && (here-> NUMDposNode != 0))
|
||||
here->NUMDposPosPtr = here->NUMDposPosStructPtr->CSC ;
|
||||
|
||||
if ((here-> NUMDnegNode != 0) && (here-> NUMDnegNode != 0))
|
||||
here->NUMDnegNegPtr = here->NUMDnegNegStructPtr->CSC ;
|
||||
|
||||
if ((here-> NUMDnegNode != 0) && (here-> NUMDposNode != 0))
|
||||
here->NUMDnegPosPtr = here->NUMDnegPosStructPtr->CSC ;
|
||||
|
||||
if ((here-> NUMDposNode != 0) && (here-> NUMDnegNode != 0))
|
||||
here->NUMDposNegPtr = here->NUMDposNegStructPtr->CSC ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return (OK) ;
|
||||
}
|
||||
|
|
@ -62,6 +62,14 @@ typedef struct sNUMDinstance {
|
|||
unsigned NUMDicFileGiven:1; /* flag to indicate init. cond. file given */
|
||||
unsigned NUMDtempGiven:1; /* flag to indicate temp was specified */
|
||||
unsigned NUMDprintGiven:1; /* flag to indicate if print was specified */
|
||||
|
||||
#ifdef KLU
|
||||
BindElement *NUMDposPosStructPtr ;
|
||||
BindElement *NUMDnegNegStructPtr ;
|
||||
BindElement *NUMDnegPosStructPtr ;
|
||||
BindElement *NUMDposNegStructPtr ;
|
||||
#endif
|
||||
|
||||
} NUMDinstance;
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue