New Binding Method extended to CCVS device
This commit is contained in:
parent
3b2468b9ba
commit
5f065b2e7c
|
|
@ -1,5 +1,5 @@
|
||||||
/**********
|
/**********
|
||||||
Author: 2012 Francesco Lannutti
|
Author: 2013 Francesco Lannutti
|
||||||
**********/
|
**********/
|
||||||
|
|
||||||
#include "ngspice/ngspice.h"
|
#include "ngspice/ngspice.h"
|
||||||
|
|
@ -7,100 +7,116 @@ Author: 2012 Francesco Lannutti
|
||||||
#include "ccvsdefs.h"
|
#include "ccvsdefs.h"
|
||||||
#include "ngspice/sperror.h"
|
#include "ngspice/sperror.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static
|
||||||
int
|
int
|
||||||
CCVSbindCSC(GENmodel *inModel, CKTcircuit *ckt)
|
BindCompare (const void *a, const void *b)
|
||||||
{
|
{
|
||||||
CCVSmodel *model = (CCVSmodel *)inModel;
|
BindElement *A, *B ;
|
||||||
int i ;
|
A = (BindElement *)a ;
|
||||||
|
B = (BindElement *)b ;
|
||||||
|
|
||||||
/* loop through all the ccvs models */
|
return ((int)(A->Sparse - B->Sparse)) ;
|
||||||
for( ; model != NULL; model = model->CCVSnextModel ) {
|
|
||||||
CCVSinstance *here;
|
|
||||||
|
|
||||||
/* loop through all the instances of the model */
|
|
||||||
for (here = model->CCVSinstances; here != NULL ;
|
|
||||||
here = here->CCVSnextInstance) {
|
|
||||||
|
|
||||||
i = 0 ;
|
|
||||||
if ((here-> CCVSposNode != 0) && (here-> CCVSbranch != 0)) {
|
|
||||||
while (here->CCVSposIbrptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
|
||||||
here->CCVSposIbrptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
|
||||||
if ((here-> CCVSnegNode != 0) && (here-> CCVSbranch != 0)) {
|
|
||||||
while (here->CCVSnegIbrptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
|
||||||
here->CCVSnegIbrptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
|
||||||
if ((here-> CCVSbranch != 0) && (here-> CCVSnegNode != 0)) {
|
|
||||||
while (here->CCVSibrNegptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
|
||||||
here->CCVSibrNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
|
||||||
if ((here-> CCVSbranch != 0) && (here-> CCVSposNode != 0)) {
|
|
||||||
while (here->CCVSibrPosptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
|
||||||
here->CCVSibrPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
|
||||||
if ((here-> CCVSbranch != 0) && (here-> CCVScontBranch != 0)) {
|
|
||||||
while (here->CCVSibrContBrptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
|
||||||
here->CCVSibrContBrptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(OK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
CCVSbindCSCComplex(GENmodel *inModel, CKTcircuit *ckt)
|
CCVSbindCSC (GENmodel *inModel, CKTcircuit *ckt)
|
||||||
{
|
{
|
||||||
CCVSmodel *model = (CCVSmodel *)inModel;
|
CCVSmodel *model = (CCVSmodel *)inModel ;
|
||||||
int i ;
|
CCVSinstance *here ;
|
||||||
|
double *i ;
|
||||||
|
BindElement *matched, *BindStruct ;
|
||||||
|
size_t nz ;
|
||||||
|
|
||||||
/* loop through all the ccvs models */
|
BindStruct = ckt->CKTmatrix->CKTbindStruct ;
|
||||||
for( ; model != NULL; model = model->CCVSnextModel ) {
|
nz = (size_t)ckt->CKTmatrix->CKTklunz ;
|
||||||
CCVSinstance *here;
|
|
||||||
|
|
||||||
|
/* loop through all the CCVS models */
|
||||||
|
for ( ; model != NULL ; model = model->CCVSnextModel)
|
||||||
|
{
|
||||||
/* loop through all the instances of the model */
|
/* loop through all the instances of the model */
|
||||||
for (here = model->CCVSinstances; here != NULL ;
|
for (here = model->CCVSinstances ; here != NULL ; here = here->CCVSnextInstance)
|
||||||
here = here->CCVSnextInstance) {
|
{
|
||||||
|
if ((here-> CCVSposNode != 0) && (here-> CCVSbranch != 0))
|
||||||
|
{
|
||||||
|
i = here->CCVSposIbrptr ;
|
||||||
|
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||||
|
here->CCVSposIbrptrStructPtr = matched ;
|
||||||
|
here->CCVSposIbrptr = matched->CSC ;
|
||||||
|
}
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> CCVSnegNode != 0) && (here-> CCVSbranch != 0))
|
||||||
if ((here-> CCVSposNode != 0) && (here-> CCVSbranch != 0)) {
|
{
|
||||||
while (here->CCVSposIbrptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
i = here->CCVSnegIbrptr ;
|
||||||
here->CCVSposIbrptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||||
}
|
here->CCVSnegIbrptrStructPtr = matched ;
|
||||||
|
here->CCVSnegIbrptr = matched->CSC ;
|
||||||
|
}
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> CCVSbranch != 0) && (here-> CCVSnegNode != 0))
|
||||||
if ((here-> CCVSnegNode != 0) && (here-> CCVSbranch != 0)) {
|
{
|
||||||
while (here->CCVSnegIbrptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
i = here->CCVSibrNegptr ;
|
||||||
here->CCVSnegIbrptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||||
}
|
here->CCVSibrNegptrStructPtr = matched ;
|
||||||
|
here->CCVSibrNegptr = matched->CSC ;
|
||||||
|
}
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> CCVSbranch != 0) && (here-> CCVSposNode != 0))
|
||||||
if ((here-> CCVSbranch != 0) && (here-> CCVSnegNode != 0)) {
|
{
|
||||||
while (here->CCVSibrNegptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
i = here->CCVSibrPosptr ;
|
||||||
here->CCVSibrNegptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||||
}
|
here->CCVSibrPosptrStructPtr = matched ;
|
||||||
|
here->CCVSibrPosptr = matched->CSC ;
|
||||||
|
}
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> CCVSbranch != 0) && (here-> CCVScontBranch != 0))
|
||||||
if ((here-> CCVSbranch != 0) && (here-> CCVSposNode != 0)) {
|
{
|
||||||
while (here->CCVSibrPosptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
i = here->CCVSibrContBrptr ;
|
||||||
here->CCVSibrPosptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||||
}
|
here->CCVSibrContBrptrStructPtr = matched ;
|
||||||
|
here->CCVSibrContBrptr = matched->CSC ;
|
||||||
|
}
|
||||||
|
|
||||||
i = 0 ;
|
}
|
||||||
if ((here-> CCVSbranch != 0) && (here-> CCVScontBranch != 0)) {
|
|
||||||
while (here->CCVSibrContBrptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
|
||||||
here->CCVSibrContBrptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return(OK);
|
|
||||||
|
return (OK) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
CCVSbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt)
|
||||||
|
{
|
||||||
|
CCVSmodel *model = (CCVSmodel *)inModel ;
|
||||||
|
CCVSinstance *here ;
|
||||||
|
|
||||||
|
NG_IGNORE (ckt) ;
|
||||||
|
|
||||||
|
/* loop through all the CCVS models */
|
||||||
|
for ( ; model != NULL ; model = model->CCVSnextModel)
|
||||||
|
{
|
||||||
|
/* loop through all the instances of the model */
|
||||||
|
for (here = model->CCVSinstances ; here != NULL ; here = here->CCVSnextInstance)
|
||||||
|
{
|
||||||
|
if ((here-> CCVSposNode != 0) && (here-> CCVSbranch != 0))
|
||||||
|
here->CCVSposIbrptr = here->CCVSposIbrptrStructPtr->CSC_Complex ;
|
||||||
|
|
||||||
|
if ((here-> CCVSnegNode != 0) && (here-> CCVSbranch != 0))
|
||||||
|
here->CCVSnegIbrptr = here->CCVSnegIbrptrStructPtr->CSC_Complex ;
|
||||||
|
|
||||||
|
if ((here-> CCVSbranch != 0) && (here-> CCVSnegNode != 0))
|
||||||
|
here->CCVSibrNegptr = here->CCVSibrNegptrStructPtr->CSC_Complex ;
|
||||||
|
|
||||||
|
if ((here-> CCVSbranch != 0) && (here-> CCVSposNode != 0))
|
||||||
|
here->CCVSibrPosptr = here->CCVSibrPosptrStructPtr->CSC_Complex ;
|
||||||
|
|
||||||
|
if ((here-> CCVSbranch != 0) && (here-> CCVScontBranch != 0))
|
||||||
|
here->CCVSibrContBrptr = here->CCVSibrContBrptrStructPtr->CSC_Complex ;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (OK) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
@ -108,48 +124,30 @@ CCVSbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt)
|
||||||
{
|
{
|
||||||
CCVSmodel *model = (CCVSmodel *)inModel ;
|
CCVSmodel *model = (CCVSmodel *)inModel ;
|
||||||
CCVSinstance *here ;
|
CCVSinstance *here ;
|
||||||
int i ;
|
|
||||||
|
|
||||||
/* loop through all the CurrentControlledVoltageSource models */
|
NG_IGNORE (ckt) ;
|
||||||
|
|
||||||
|
/* loop through all the CCVS models */
|
||||||
for ( ; model != NULL ; model = model->CCVSnextModel)
|
for ( ; model != NULL ; model = model->CCVSnextModel)
|
||||||
{
|
{
|
||||||
/* loop through all the instances of the model */
|
/* loop through all the instances of the model */
|
||||||
for (here = model->CCVSinstances ; here != NULL ; here = here->CCVSnextInstance)
|
for (here = model->CCVSinstances ; here != NULL ; here = here->CCVSnextInstance)
|
||||||
{
|
{
|
||||||
i = 0 ;
|
if ((here-> CCVSposNode != 0) && (here-> CCVSbranch != 0))
|
||||||
if ((here->CCVSposNode != 0) && (here->CCVSbranch != 0))
|
here->CCVSposIbrptr = here->CCVSposIbrptrStructPtr->CSC ;
|
||||||
{
|
|
||||||
while (here->CCVSposIbrptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
|
||||||
here->CCVSposIbrptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> CCVSnegNode != 0) && (here-> CCVSbranch != 0))
|
||||||
if ((here->CCVSnegNode != 0) && (here->CCVSbranch != 0))
|
here->CCVSnegIbrptr = here->CCVSnegIbrptrStructPtr->CSC ;
|
||||||
{
|
|
||||||
while (here->CCVSnegIbrptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
|
||||||
here->CCVSnegIbrptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> CCVSbranch != 0) && (here-> CCVSnegNode != 0))
|
||||||
if ((here->CCVSbranch != 0) && (here->CCVSnegNode != 0))
|
here->CCVSibrNegptr = here->CCVSibrNegptrStructPtr->CSC ;
|
||||||
{
|
|
||||||
while (here->CCVSibrNegptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
|
||||||
here->CCVSibrNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> CCVSbranch != 0) && (here-> CCVSposNode != 0))
|
||||||
if ((here->CCVSbranch != 0) && (here->CCVSposNode != 0))
|
here->CCVSibrPosptr = here->CCVSibrPosptrStructPtr->CSC ;
|
||||||
{
|
|
||||||
while (here->CCVSibrPosptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
if ((here-> CCVSbranch != 0) && (here-> CCVScontBranch != 0))
|
||||||
here->CCVSibrPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
here->CCVSibrContBrptr = here->CCVSibrContBrptrStructPtr->CSC ;
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
|
||||||
if ((here->CCVSbranch != 0) && (here->CCVScontBranch != 0))
|
|
||||||
{
|
|
||||||
while (here->CCVSibrContBrptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
|
||||||
here->CCVSibrContBrptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,14 @@ typedef struct sCCVSinstance {
|
||||||
int CCVSsenParmNo; /* parameter # for sensitivity use;
|
int CCVSsenParmNo; /* parameter # for sensitivity use;
|
||||||
set equal to 0 if not a design parameter*/
|
set equal to 0 if not a design parameter*/
|
||||||
|
|
||||||
|
#ifdef KLU
|
||||||
|
BindElement *CCVSposIbrptrStructPtr ;
|
||||||
|
BindElement *CCVSnegIbrptrStructPtr ;
|
||||||
|
BindElement *CCVSibrNegptrStructPtr ;
|
||||||
|
BindElement *CCVSibrPosptrStructPtr ;
|
||||||
|
BindElement *CCVSibrContBrptrStructPtr ;
|
||||||
|
#endif
|
||||||
|
|
||||||
} CCVSinstance ;
|
} CCVSinstance ;
|
||||||
|
|
||||||
/* per model data */
|
/* per model data */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue