New Binding Method extended to VCVS device
This commit is contained in:
parent
3872fe0171
commit
bc6efce79c
|
|
@ -1,5 +1,5 @@
|
||||||
/**********
|
/**********
|
||||||
Author: 2012 Francesco Lannutti
|
Author: 2013 Francesco Lannutti
|
||||||
**********/
|
**********/
|
||||||
|
|
||||||
#include "ngspice/ngspice.h"
|
#include "ngspice/ngspice.h"
|
||||||
|
|
@ -7,102 +7,127 @@ Author: 2012 Francesco Lannutti
|
||||||
#include "vcvsdefs.h"
|
#include "vcvsdefs.h"
|
||||||
#include "ngspice/sperror.h"
|
#include "ngspice/sperror.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static
|
||||||
int
|
int
|
||||||
VCVSbindCSC(GENmodel *inModel, CKTcircuit *ckt)
|
BindCompare (const void *a, const void *b)
|
||||||
{
|
{
|
||||||
VCVSmodel *model = (VCVSmodel *)inModel;
|
BindElement *A, *B ;
|
||||||
int i ;
|
A = (BindElement *)a ;
|
||||||
|
B = (BindElement *)b ;
|
||||||
|
|
||||||
/* loop through all the vcvs models */
|
return ((int)(A->Sparse - B->Sparse)) ;
|
||||||
for( ; model != NULL; model = model->VCVSnextModel ) {
|
|
||||||
VCVSinstance *here;
|
|
||||||
|
|
||||||
/* loop through all the instances of the model */
|
|
||||||
for (here = model->VCVSinstances; here != NULL ;
|
|
||||||
here = here->VCVSnextInstance) {
|
|
||||||
|
|
||||||
i = 0 ;
|
|
||||||
if ((here-> VCVSposNode != 0) && (here-> VCVSbranch != 0)) {
|
|
||||||
while (here->VCVSposIbrptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
|
||||||
here->VCVSposIbrptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
i = 0 ;
|
|
||||||
if ((here-> VCVSnegNode != 0) && (here-> VCVSbranch != 0)) {
|
|
||||||
while (here->VCVSnegIbrptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
|
||||||
here->VCVSnegIbrptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
i = 0 ;
|
|
||||||
if ((here-> VCVSbranch != 0) && (here-> VCVSnegNode != 0)) {
|
|
||||||
while (here->VCVSibrNegptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
|
||||||
here->VCVSibrNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
i = 0 ;
|
|
||||||
if ((here-> VCVSbranch != 0) && (here-> VCVSposNode != 0)) {
|
|
||||||
while (here->VCVSibrPosptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
|
||||||
here->VCVSibrPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
i = 0 ;
|
|
||||||
if ((here-> VCVSbranch != 0) && (here-> VCVScontPosNode != 0)) {
|
|
||||||
while (here->VCVSibrContPosptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
|
||||||
here->VCVSibrContPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
i = 0 ;
|
|
||||||
if ((here-> VCVSbranch != 0) && (here-> VCVScontNegNode != 0)) {
|
|
||||||
while (here->VCVSibrContNegptr != ckt->CKTmatrix->CKTbind_Sparse [i]) i ++ ;
|
|
||||||
here->VCVSibrContNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(OK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
VCVSbindCSCComplex(GENmodel *inModel, CKTcircuit *ckt)
|
VCVSbindCSC (GENmodel *inModel, CKTcircuit *ckt)
|
||||||
{
|
{
|
||||||
VCVSmodel *model = (VCVSmodel *)inModel;
|
VCVSmodel *model = (VCVSmodel *)inModel ;
|
||||||
int i ;
|
VCVSinstance *here ;
|
||||||
|
double *i ;
|
||||||
|
BindElement *matched, *BindStruct ;
|
||||||
|
size_t nz ;
|
||||||
|
|
||||||
/* loop through all the vcvs models */
|
BindStruct = ckt->CKTmatrix->CKTbindStruct ;
|
||||||
for( ; model != NULL; model = model->VCVSnextModel ) {
|
nz = (size_t)ckt->CKTmatrix->CKTklunz ;
|
||||||
VCVSinstance *here;
|
|
||||||
|
|
||||||
|
/* loop through all the VCVS models */
|
||||||
|
for ( ; model != NULL ; model = model->VCVSnextModel)
|
||||||
|
{
|
||||||
/* loop through all the instances of the model */
|
/* loop through all the instances of the model */
|
||||||
for (here = model->VCVSinstances; here != NULL ;
|
for (here = model->VCVSinstances ; here != NULL ; here = here->VCVSnextInstance)
|
||||||
here = here->VCVSnextInstance) {
|
{
|
||||||
|
if ((here-> VCVSposNode != 0) && (here-> VCVSbranch != 0))
|
||||||
|
{
|
||||||
|
i = here->VCVSposIbrptr ;
|
||||||
|
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||||
|
here->VCVSposIbrptrStructPtr = matched ;
|
||||||
|
here->VCVSposIbrptr = matched->CSC ;
|
||||||
|
}
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> VCVSnegNode != 0) && (here-> VCVSbranch != 0))
|
||||||
if ((here-> VCVSposNode != 0) && (here-> VCVSbranch != 0)) {
|
{
|
||||||
while (here->VCVSposIbrptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
i = here->VCVSnegIbrptr ;
|
||||||
here->VCVSposIbrptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||||
}
|
here->VCVSnegIbrptrStructPtr = matched ;
|
||||||
i = 0 ;
|
here->VCVSnegIbrptr = matched->CSC ;
|
||||||
if ((here-> VCVSnegNode != 0) && (here-> VCVSbranch != 0)) {
|
}
|
||||||
while (here->VCVSnegIbrptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
|
||||||
here->VCVSnegIbrptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
if ((here-> VCVSbranch != 0) && (here-> VCVSnegNode != 0))
|
||||||
}
|
{
|
||||||
i = 0 ;
|
i = here->VCVSibrNegptr ;
|
||||||
if ((here-> VCVSbranch != 0) && (here-> VCVSnegNode != 0)) {
|
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||||
while (here->VCVSibrNegptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
here->VCVSibrNegptrStructPtr = matched ;
|
||||||
here->VCVSibrNegptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
here->VCVSibrNegptr = matched->CSC ;
|
||||||
}
|
}
|
||||||
i = 0 ;
|
|
||||||
if ((here-> VCVSbranch != 0) && (here-> VCVSposNode != 0)) {
|
if ((here-> VCVSbranch != 0) && (here-> VCVSposNode != 0))
|
||||||
while (here->VCVSibrPosptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
{
|
||||||
here->VCVSibrPosptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
i = here->VCVSibrPosptr ;
|
||||||
}
|
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||||
i = 0 ;
|
here->VCVSibrPosptrStructPtr = matched ;
|
||||||
if ((here-> VCVSbranch != 0) && (here-> VCVScontPosNode != 0)) {
|
here->VCVSibrPosptr = matched->CSC ;
|
||||||
while (here->VCVSibrContPosptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
}
|
||||||
here->VCVSibrContPosptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
|
||||||
}
|
if ((here-> VCVSbranch != 0) && (here-> VCVScontPosNode != 0))
|
||||||
i = 0 ;
|
{
|
||||||
if ((here-> VCVSbranch != 0) && (here-> VCVScontNegNode != 0)) {
|
i = here->VCVSibrContPosptr ;
|
||||||
while (here->VCVSibrContNegptr != ckt->CKTmatrix->CKTbind_CSC [i]) i ++ ;
|
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||||
here->VCVSibrContNegptr = ckt->CKTmatrix->CKTbind_CSC_Complex [i] ;
|
here->VCVSibrContPosptrStructPtr = matched ;
|
||||||
}
|
here->VCVSibrContPosptr = matched->CSC ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((here-> VCVSbranch != 0) && (here-> VCVScontNegNode != 0))
|
||||||
|
{
|
||||||
|
i = here->VCVSibrContNegptr ;
|
||||||
|
matched = (BindElement *) bsearch (&i, BindStruct, nz, sizeof(BindElement), BindCompare) ;
|
||||||
|
here->VCVSibrContNegptrStructPtr = matched ;
|
||||||
|
here->VCVSibrContNegptr = matched->CSC ;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return(OK);
|
|
||||||
|
return (OK) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
VCVSbindCSCComplex (GENmodel *inModel, CKTcircuit *ckt)
|
||||||
|
{
|
||||||
|
VCVSmodel *model = (VCVSmodel *)inModel ;
|
||||||
|
VCVSinstance *here ;
|
||||||
|
|
||||||
|
NG_IGNORE (ckt) ;
|
||||||
|
|
||||||
|
/* loop through all the VCVS models */
|
||||||
|
for ( ; model != NULL ; model = model->VCVSnextModel)
|
||||||
|
{
|
||||||
|
/* loop through all the instances of the model */
|
||||||
|
for (here = model->VCVSinstances ; here != NULL ; here = here->VCVSnextInstance)
|
||||||
|
{
|
||||||
|
if ((here-> VCVSposNode != 0) && (here-> VCVSbranch != 0))
|
||||||
|
here->VCVSposIbrptr = here->VCVSposIbrptrStructPtr->CSC_Complex ;
|
||||||
|
|
||||||
|
if ((here-> VCVSnegNode != 0) && (here-> VCVSbranch != 0))
|
||||||
|
here->VCVSnegIbrptr = here->VCVSnegIbrptrStructPtr->CSC_Complex ;
|
||||||
|
|
||||||
|
if ((here-> VCVSbranch != 0) && (here-> VCVSnegNode != 0))
|
||||||
|
here->VCVSibrNegptr = here->VCVSibrNegptrStructPtr->CSC_Complex ;
|
||||||
|
|
||||||
|
if ((here-> VCVSbranch != 0) && (here-> VCVSposNode != 0))
|
||||||
|
here->VCVSibrPosptr = here->VCVSibrPosptrStructPtr->CSC_Complex ;
|
||||||
|
|
||||||
|
if ((here-> VCVSbranch != 0) && (here-> VCVScontPosNode != 0))
|
||||||
|
here->VCVSibrContPosptr = here->VCVSibrContPosptrStructPtr->CSC_Complex ;
|
||||||
|
|
||||||
|
if ((here-> VCVSbranch != 0) && (here-> VCVScontNegNode != 0))
|
||||||
|
here->VCVSibrContNegptr = here->VCVSibrContNegptrStructPtr->CSC_Complex ;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (OK) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
@ -110,57 +135,35 @@ VCVSbindCSCComplexToReal (GENmodel *inModel, CKTcircuit *ckt)
|
||||||
{
|
{
|
||||||
VCVSmodel *model = (VCVSmodel *)inModel ;
|
VCVSmodel *model = (VCVSmodel *)inModel ;
|
||||||
VCVSinstance *here ;
|
VCVSinstance *here ;
|
||||||
int i ;
|
|
||||||
|
|
||||||
/* loop through all the VoltageControlledVoltageSource models */
|
NG_IGNORE (ckt) ;
|
||||||
|
|
||||||
|
/* loop through all the VCVS models */
|
||||||
for ( ; model != NULL ; model = model->VCVSnextModel)
|
for ( ; model != NULL ; model = model->VCVSnextModel)
|
||||||
{
|
{
|
||||||
/* loop through all the instances of the model */
|
/* loop through all the instances of the model */
|
||||||
for (here = model->VCVSinstances ; here != NULL ; here = here->VCVSnextInstance)
|
for (here = model->VCVSinstances ; here != NULL ; here = here->VCVSnextInstance)
|
||||||
{
|
{
|
||||||
i = 0 ;
|
if ((here-> VCVSposNode != 0) && (here-> VCVSbranch != 0))
|
||||||
if ((here->VCVSposNode != 0) && (here->VCVSbranch != 0))
|
here->VCVSposIbrptr = here->VCVSposIbrptrStructPtr->CSC ;
|
||||||
{
|
|
||||||
while (here->VCVSposIbrptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
|
||||||
here->VCVSposIbrptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> VCVSnegNode != 0) && (here-> VCVSbranch != 0))
|
||||||
if ((here->VCVSnegNode != 0) && (here->VCVSbranch != 0))
|
here->VCVSnegIbrptr = here->VCVSnegIbrptrStructPtr->CSC ;
|
||||||
{
|
|
||||||
while (here->VCVSnegIbrptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
|
||||||
here->VCVSnegIbrptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> VCVSbranch != 0) && (here-> VCVSnegNode != 0))
|
||||||
if ((here->VCVSbranch != 0) && (here->VCVSnegNode != 0))
|
here->VCVSibrNegptr = here->VCVSibrNegptrStructPtr->CSC ;
|
||||||
{
|
|
||||||
while (here->VCVSibrNegptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
|
||||||
here->VCVSibrNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> VCVSbranch != 0) && (here-> VCVSposNode != 0))
|
||||||
if ((here->VCVSbranch != 0) && (here->VCVSposNode != 0))
|
here->VCVSibrPosptr = here->VCVSibrPosptrStructPtr->CSC ;
|
||||||
{
|
|
||||||
while (here->VCVSibrPosptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
|
||||||
here->VCVSibrPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
if ((here-> VCVSbranch != 0) && (here-> VCVScontPosNode != 0))
|
||||||
if ((here->VCVSbranch != 0) && (here->VCVScontPosNode != 0))
|
here->VCVSibrContPosptr = here->VCVSibrContPosptrStructPtr->CSC ;
|
||||||
{
|
|
||||||
while (here->VCVSibrContPosptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
if ((here-> VCVSbranch != 0) && (here-> VCVScontNegNode != 0))
|
||||||
here->VCVSibrContPosptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
here->VCVSibrContNegptr = here->VCVSibrContNegptrStructPtr->CSC ;
|
||||||
}
|
|
||||||
|
|
||||||
i = 0 ;
|
|
||||||
if ((here->VCVSbranch != 0) && (here->VCVScontNegNode != 0))
|
|
||||||
{
|
|
||||||
while (here->VCVSibrContNegptr != ckt->CKTmatrix->CKTbind_CSC_Complex [i]) i ++ ;
|
|
||||||
here->VCVSibrContNegptr = ckt->CKTmatrix->CKTbind_CSC [i] ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (OK) ;
|
return (OK) ;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,15 @@ typedef struct sVCVSinstance {
|
||||||
int VCVSsenParmNo; /* parameter # for sensitivity use;
|
int VCVSsenParmNo; /* 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 *VCVSposIbrptrStructPtr ;
|
||||||
|
BindElement *VCVSnegIbrptrStructPtr ;
|
||||||
|
BindElement *VCVSibrNegptrStructPtr ;
|
||||||
|
BindElement *VCVSibrPosptrStructPtr ;
|
||||||
|
BindElement *VCVSibrContPosptrStructPtr ;
|
||||||
|
BindElement *VCVSibrContNegptrStructPtr ;
|
||||||
|
#endif
|
||||||
|
|
||||||
} VCVSinstance ;
|
} VCVSinstance ;
|
||||||
|
|
||||||
#define VCVSvOld VCVSstates
|
#define VCVSvOld VCVSstates
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue