Added ASRC Model to KLU
This commit is contained in:
parent
7e392e9ce0
commit
6d747ebb04
|
|
@ -23,6 +23,10 @@ libasrc_la_SOURCES = \
|
||||||
asrctemp.c
|
asrctemp.c
|
||||||
|
|
||||||
|
|
||||||
|
if KLU_WANTED
|
||||||
|
libasrc_la_SOURCES += asrcbindCSC.c
|
||||||
|
endif
|
||||||
|
|
||||||
AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include
|
AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(top_srcdir)/src/include
|
||||||
AM_CFLAGS = $(STATIC)
|
AM_CFLAGS = $(STATIC)
|
||||||
MAINTAINERCLEANFILES = Makefile.in
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,179 @@
|
||||||
|
/**********
|
||||||
|
Author: 2015 Francesco Lannutti
|
||||||
|
**********/
|
||||||
|
|
||||||
|
#include "ngspice/ngspice.h"
|
||||||
|
#include "ngspice/cktdefs.h"
|
||||||
|
#include "asrcdefs.h"
|
||||||
|
#include "ngspice/sperror.h"
|
||||||
|
#include "ngspice/klu-binding.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
|
||||||
|
ASRCbindCSC (GENmodel *inModel, CKTcircuit *ckt)
|
||||||
|
{
|
||||||
|
ASRCmodel *model = (ASRCmodel *)inModel ;
|
||||||
|
ASRCinstance *here ;
|
||||||
|
double *i ;
|
||||||
|
BindElement *matched, *BindStruct ;
|
||||||
|
size_t nz ;
|
||||||
|
int j, k ;
|
||||||
|
|
||||||
|
BindStruct = ckt->CKTmatrix->CKTbindStruct ;
|
||||||
|
nz = (size_t)ckt->CKTmatrix->CKTklunz ;
|
||||||
|
|
||||||
|
/* loop through all the ASRC models */
|
||||||
|
for ( ; model != NULL ; model = model->ASRCnextModel)
|
||||||
|
{
|
||||||
|
/* loop through all the instances of the model */
|
||||||
|
for (here = model->ASRCinstances ; here != NULL ; here = here->ASRCnextInstance)
|
||||||
|
{
|
||||||
|
j = 0 ;
|
||||||
|
if (here->ASRCtype == ASRC_VOLTAGE)
|
||||||
|
{
|
||||||
|
CREATE_KLU_BINDING_TABLE(ASRCposPtr [j], ASRCposBinding [j], ASRCposNode, ASRCbranch);
|
||||||
|
j++ ;
|
||||||
|
|
||||||
|
CREATE_KLU_BINDING_TABLE(ASRCposPtr [j], ASRCposBinding [j], ASRCnegNode, ASRCbranch);
|
||||||
|
j++ ;
|
||||||
|
|
||||||
|
CREATE_KLU_BINDING_TABLE(ASRCposPtr [j], ASRCposBinding [j], ASRCbranch, ASRCnegNode);
|
||||||
|
j++ ;
|
||||||
|
|
||||||
|
CREATE_KLU_BINDING_TABLE(ASRCposPtr [j], ASRCposBinding [j], ASRCbranch, ASRCposNode);
|
||||||
|
j++ ;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (k = 0 ; k < here->ASRCtree->numVars ; k++)
|
||||||
|
{
|
||||||
|
if (here->ASRCtype == ASRC_VOLTAGE)
|
||||||
|
{
|
||||||
|
CREATE_KLU_BINDING_TABLE(ASRCposPtr [j], ASRCposBinding [j], ASRCbranch, ASRCvars [k]);
|
||||||
|
j++ ;
|
||||||
|
} else {
|
||||||
|
CREATE_KLU_BINDING_TABLE(ASRCposPtr [j], ASRCposBinding [j], ASRCposNode, ASRCvars [k]);
|
||||||
|
j++ ;
|
||||||
|
|
||||||
|
CREATE_KLU_BINDING_TABLE(ASRCposPtr [j], ASRCposBinding [j], ASRCnegNode, ASRCvars [k]);
|
||||||
|
j++ ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (OK) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ASRCbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt)
|
||||||
|
{
|
||||||
|
ASRCmodel *model = (ASRCmodel *)inModel ;
|
||||||
|
ASRCinstance *here ;
|
||||||
|
int j, k ;
|
||||||
|
|
||||||
|
NG_IGNORE (ckt) ;
|
||||||
|
|
||||||
|
/* loop through all the ASRC models */
|
||||||
|
for ( ; model != NULL ; model = model->ASRCnextModel)
|
||||||
|
{
|
||||||
|
/* loop through all the instances of the model */
|
||||||
|
for (here = model->ASRCinstances ; here != NULL ; here = here->ASRCnextInstance)
|
||||||
|
{
|
||||||
|
j = 0 ;
|
||||||
|
if (here->ASRCtype == ASRC_VOLTAGE)
|
||||||
|
{
|
||||||
|
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX(ASRCposPtr [j], ASRCposBinding [j], ASRCposNode, ASRCbranch);
|
||||||
|
j++ ;
|
||||||
|
|
||||||
|
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX(ASRCposPtr [j], ASRCposBinding [j], ASRCnegNode, ASRCbranch);
|
||||||
|
j++ ;
|
||||||
|
|
||||||
|
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX(ASRCposPtr [j], ASRCposBinding [j], ASRCbranch, ASRCnegNode);
|
||||||
|
j++ ;
|
||||||
|
|
||||||
|
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX(ASRCposPtr [j], ASRCposBinding [j], ASRCbranch, ASRCposNode);
|
||||||
|
j++ ;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (k = 0 ; k < here->ASRCtree->numVars ; k++)
|
||||||
|
{
|
||||||
|
if (here->ASRCtype == ASRC_VOLTAGE)
|
||||||
|
{
|
||||||
|
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX(ASRCposPtr [j], ASRCposBinding [j], ASRCbranch, ASRCvars [k]);
|
||||||
|
j++ ;
|
||||||
|
} else {
|
||||||
|
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX(ASRCposPtr [j], ASRCposBinding [j], ASRCposNode, ASRCvars [k]);
|
||||||
|
j++ ;
|
||||||
|
|
||||||
|
CONVERT_KLU_BINDING_TABLE_TO_COMPLEX(ASRCposPtr [j], ASRCposBinding [j], ASRCnegNode, ASRCvars [k]);
|
||||||
|
j++ ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (OK) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ASRCbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt)
|
||||||
|
{
|
||||||
|
ASRCmodel *model = (ASRCmodel *)inModel ;
|
||||||
|
ASRCinstance *here ;
|
||||||
|
int j, k ;
|
||||||
|
|
||||||
|
NG_IGNORE (ckt) ;
|
||||||
|
|
||||||
|
/* loop through all the ASRC models */
|
||||||
|
for ( ; model != NULL ; model = model->ASRCnextModel)
|
||||||
|
{
|
||||||
|
/* loop through all the instances of the model */
|
||||||
|
for (here = model->ASRCinstances ; here != NULL ; here = here->ASRCnextInstance)
|
||||||
|
{
|
||||||
|
j = 0 ;
|
||||||
|
if (here->ASRCtype == ASRC_VOLTAGE)
|
||||||
|
{
|
||||||
|
CONVERT_KLU_BINDING_TABLE_TO_REAL(ASRCposPtr [j], ASRCposBinding [j], ASRCposNode, ASRCbranch);
|
||||||
|
j++ ;
|
||||||
|
|
||||||
|
CONVERT_KLU_BINDING_TABLE_TO_REAL(ASRCposPtr [j], ASRCposBinding [j], ASRCnegNode, ASRCbranch);
|
||||||
|
j++ ;
|
||||||
|
|
||||||
|
CONVERT_KLU_BINDING_TABLE_TO_REAL(ASRCposPtr [j], ASRCposBinding [j], ASRCbranch, ASRCnegNode);
|
||||||
|
j++ ;
|
||||||
|
|
||||||
|
CONVERT_KLU_BINDING_TABLE_TO_REAL(ASRCposPtr [j], ASRCposBinding [j], ASRCbranch, ASRCposNode);
|
||||||
|
j++ ;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (k = 0 ; k < here->ASRCtree->numVars ; k++)
|
||||||
|
{
|
||||||
|
if (here->ASRCtype == ASRC_VOLTAGE)
|
||||||
|
{
|
||||||
|
CONVERT_KLU_BINDING_TABLE_TO_REAL(ASRCposPtr [j], ASRCposBinding [j], ASRCbranch, ASRCvars [k]);
|
||||||
|
j++ ;
|
||||||
|
} else {
|
||||||
|
CONVERT_KLU_BINDING_TABLE_TO_REAL(ASRCposPtr [j], ASRCposBinding [j], ASRCposNode, ASRCvars [k]);
|
||||||
|
j++ ;
|
||||||
|
|
||||||
|
CONVERT_KLU_BINDING_TABLE_TO_REAL(ASRCposPtr [j], ASRCposBinding [j], ASRCnegNode, ASRCvars [k]);
|
||||||
|
j++ ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (OK) ;
|
||||||
|
}
|
||||||
|
|
@ -47,6 +47,10 @@ typedef struct sASRCinstance {
|
||||||
unsigned ASRCtc2Given : 1; /* indicates tc2 parameter specified */
|
unsigned ASRCtc2Given : 1; /* indicates tc2 parameter specified */
|
||||||
unsigned ASRCreciproctcGiven : 1; /* indicates reciproctc flag parameter specified */
|
unsigned ASRCreciproctcGiven : 1; /* indicates reciproctc flag parameter specified */
|
||||||
|
|
||||||
|
#ifdef KLU
|
||||||
|
BindElement **ASRCposBinding ;
|
||||||
|
#endif
|
||||||
|
|
||||||
} ASRCinstance;
|
} ASRCinstance;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,3 +16,9 @@ extern int ASRCacLoad(GENmodel *, CKTcircuit *);
|
||||||
extern int ASRCsetup(SMPmatrix *, GENmodel *, CKTcircuit *, int *);
|
extern int ASRCsetup(SMPmatrix *, GENmodel *, CKTcircuit *, int *);
|
||||||
extern int ASRCunsetup(GENmodel *, CKTcircuit *);
|
extern int ASRCunsetup(GENmodel *, CKTcircuit *);
|
||||||
extern int ASRCtemp(GENmodel *, CKTcircuit *);
|
extern int ASRCtemp(GENmodel *, CKTcircuit *);
|
||||||
|
|
||||||
|
#ifdef KLU
|
||||||
|
extern int ASRCbindCSC (GENmodel *, CKTcircuit *) ;
|
||||||
|
extern int ASRCbindCSCComplex (GENmodel *, CKTcircuit *) ;
|
||||||
|
extern int ASRCbindCSCComplexToReal (GENmodel *, CKTcircuit *) ;
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -77,9 +77,9 @@ SPICEdev ASRCinfo = {
|
||||||
/* DEVmodSize */ &ASRCmSize,
|
/* DEVmodSize */ &ASRCmSize,
|
||||||
|
|
||||||
#ifdef KLU
|
#ifdef KLU
|
||||||
/* DEVbindCSC */ NULL,
|
/* DEVbindCSC */ ASRCbindCSC,
|
||||||
/* DEVbindCSCComplex */ NULL,
|
/* DEVbindCSCComplex */ ASRCbindCSCComplex,
|
||||||
/* DEVbindCSCComplexToReal */ NULL,
|
/* DEVbindCSCComplexToReal */ ASRCbindCSCComplexToReal,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,10 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
here->ASRCvars = TMALLOC(int, here->ASRCtree->numVars);
|
here->ASRCvars = TMALLOC(int, here->ASRCtree->numVars);
|
||||||
here->ASRCacValues = TMALLOC(double, here->ASRCtree->numVars + 1);
|
here->ASRCacValues = TMALLOC(double, here->ASRCtree->numVars + 1);
|
||||||
|
|
||||||
|
#ifdef KLU
|
||||||
|
here->ASRCposBinding = TMALLOC (BindElement *, j) ;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* For each controlling variable set the entries
|
/* For each controlling variable set the entries
|
||||||
in the vector of the positions of the SMP */
|
in the vector of the positions of the SMP */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue