Browse Source

Fixed CKTsetup for KLU when XSPICE is used

pre-master-46
Francesco Lannutti 6 years ago
committed by Holger Vogt
parent
commit
1ee798ec9d
  1. 91
      src/spicelib/analysis/cktsetup.c

91
src/spicelib/analysis/cktsetup.c

@ -36,12 +36,19 @@ CKTsetup(CKTcircuit *ckt)
{
int i;
int error;
#ifdef XSPICE
/* gtri - begin - Setup for adding rshunt option resistors */
CKTnode *node;
int num_nodes;
/* gtri - end - Setup for adding rshunt option resistors */
#ifdef KLU
BindElement BindNode, *matched, *BindStruct ;
size_t nz ;
#endif
#endif
SMPmatrix *matrix;
if (!ckt->CKThead) {
@ -108,6 +115,38 @@ CKTsetup(CKTcircuit *ckt)
}
}
#ifdef XSPICE
/* gtri - begin - Setup for adding rshunt option resistors */
if(ckt->enh->rshunt_data.enabled) {
/* Count number of voltage nodes in circuit */
for(num_nodes = 0, node = ckt->CKTnodes; node; node = node->next)
if((node->type == SP_VOLTAGE) && (node->number != 0))
num_nodes++;
/* Allocate space for the matrix diagonal data */
if(num_nodes > 0) {
ckt->enh->rshunt_data.diag =
TMALLOC(double *, num_nodes);
}
/* Set the number of nodes in the rshunt data */
ckt->enh->rshunt_data.num_nodes = num_nodes;
/* Get/create matrix diagonal entry following what RESsetup does */
for(i = 0, node = ckt->CKTnodes; node; node = node->next) {
if((node->type == SP_VOLTAGE) && (node->number != 0)) {
ckt->enh->rshunt_data.diag[i] =
SMPmakeElt(matrix,node->number,node->number);
i++;
}
}
}
/* gtri - end - Setup for adding rshunt option resistors */
#endif
#ifdef KLU
if (ckt->CKTmatrix->CKTkluMODE)
{
@ -120,6 +159,27 @@ CKTsetup(CKTcircuit *ckt)
for (i = 0 ; i < DEVmaxnum ; i++)
if (DEVices [i] && DEVices [i]->DEVbindCSC && ckt->CKThead [i])
DEVices [i]->DEVbindCSC (ckt->CKThead [i], ckt) ;
#ifdef XSPICE
if (ckt->enh->rshunt_data.num_nodes > 0) {
BindStruct = ckt->CKTmatrix->SMPkluMatrix->KLUmatrixBindStructCOO ;
nz = (size_t)ckt->CKTmatrix->SMPkluMatrix->KLUmatrixLinkedListNZ ;
for(i = 0, node = ckt->CKTnodes; node; node = node->next) {
if((node->type == SP_VOLTAGE) && (node->number != 0)) {
BindNode.COO = ckt->enh->rshunt_data.diag [i] ;
BindNode.CSC = NULL ;
BindNode.CSC_Complex = NULL ;
matched = (BindElement *) bsearch (&BindNode, BindStruct, nz, sizeof (BindElement), BindCompare) ;
if (matched == NULL) {
printf ("Ptr %p not found in BindStruct Table\n", ckt->enh->rshunt_data.diag [i]) ;
}
ckt->enh->rshunt_data.diag [i] = matched->CSC ;
i++;
}
}
}
#endif
} else {
fprintf (stderr, "Using SPARSE 1.3 as Direct Linear Solver\n") ;
}
@ -141,37 +201,6 @@ CKTsetup(CKTcircuit *ckt)
error = NIreinit(ckt);
if(error) return(error);
}
#ifdef XSPICE
/* gtri - begin - Setup for adding rshunt option resistors */
if(ckt->enh->rshunt_data.enabled) {
/* Count number of voltage nodes in circuit */
for(num_nodes = 0, node = ckt->CKTnodes; node; node = node->next)
if((node->type == SP_VOLTAGE) && (node->number != 0))
num_nodes++;
/* Allocate space for the matrix diagonal data */
if(num_nodes > 0) {
ckt->enh->rshunt_data.diag =
TMALLOC(double *, num_nodes);
}
/* Set the number of nodes in the rshunt data */
ckt->enh->rshunt_data.num_nodes = num_nodes;
/* Get/create matrix diagonal entry following what RESsetup does */
for(i = 0, node = ckt->CKTnodes; node; node = node->next) {
if((node->type == SP_VOLTAGE) && (node->number != 0)) {
ckt->enh->rshunt_data.diag[i] =
SMPmakeElt(matrix,node->number,node->number);
i++;
}
}
}
/* gtri - end - Setup for adding rshunt option resistors */
#endif
return(OK);
}

Loading…
Cancel
Save