Added the support for .ic statement in KLU mode
This commit is contained in:
parent
98a9845cba
commit
6914b6b3a6
|
|
@ -997,15 +997,36 @@ SMPelement *
|
||||||
SMPfindElt (SMPmatrix *eMatrix, int Row, int Col, int CreateIfMissing)
|
SMPfindElt (SMPmatrix *eMatrix, int Row, int Col, int CreateIfMissing)
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = eMatrix->SPmatrix ;
|
MatrixPtr Matrix = eMatrix->SPmatrix ;
|
||||||
ElementPtr Element ;
|
|
||||||
|
|
||||||
/* Begin `SMPfindElt'. */
|
if (eMatrix->CKTkluMODE)
|
||||||
assert (IS_SPARSE (Matrix)) ;
|
{
|
||||||
Row = Matrix->ExtToIntRowMap [Row] ;
|
int i ;
|
||||||
Col = Matrix->ExtToIntColMap [Col] ;
|
|
||||||
Element = Matrix->FirstInCol [Col] ;
|
Row = Matrix->ExtToIntRowMap [Row] ;
|
||||||
Element = spcFindElementInCol (Matrix, &Element, Row, Col, CreateIfMissing) ;
|
Col = Matrix->ExtToIntColMap [Col] ;
|
||||||
return (SMPelement *)Element ;
|
for (i = eMatrix->CKTkluAp [Col - 1] ; i < eMatrix->CKTkluAp [Col] ; i++) {
|
||||||
|
if (eMatrix->CKTkluAi [i] == Row - 1) {
|
||||||
|
if (eMatrix->CKTkluMatrixIsComplex == CKTkluMatrixReal) {
|
||||||
|
return (SMPelement *) &(eMatrix->CKTkluAx [i]) ;
|
||||||
|
} else if (eMatrix->CKTkluMatrixIsComplex == CKTkluMatrixComplex) {
|
||||||
|
return (SMPelement *) &(eMatrix->CKTkluAx_Complex [2 * i]) ;
|
||||||
|
} else {
|
||||||
|
return NULL ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL ;
|
||||||
|
} else {
|
||||||
|
ElementPtr Element ;
|
||||||
|
|
||||||
|
/* Begin `SMPfindElt'. */
|
||||||
|
assert (IS_SPARSE (Matrix)) ;
|
||||||
|
Row = Matrix->ExtToIntRowMap [Row] ;
|
||||||
|
Col = Matrix->ExtToIntColMap [Col] ;
|
||||||
|
Element = Matrix->FirstInCol [Col] ;
|
||||||
|
Element = spcFindElementInCol (Matrix, &Element, Row, Col, CreateIfMissing) ;
|
||||||
|
return (SMPelement *)Element ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX The following should probably be implemented in spUtils */
|
/* XXX The following should probably be implemented in spUtils */
|
||||||
|
|
|
||||||
|
|
@ -25,15 +25,30 @@ CKTic(CKTcircuit *ckt)
|
||||||
|
|
||||||
for(node = ckt->CKTnodes;node != NULL; node = node->next) {
|
for(node = ckt->CKTnodes;node != NULL; node = node->next) {
|
||||||
if(node->nsGiven) {
|
if(node->nsGiven) {
|
||||||
node->ptr = SMPmakeElt(ckt->CKTmatrix,node->number,node->number);
|
if (ckt->CKTkluMODE) {
|
||||||
|
node->ptr = (double *) SMPfindElt (ckt->CKTmatrix, node->number, node->number, 0) ;
|
||||||
|
if (node->ptr == NULL) {
|
||||||
|
printf ("Warning: The needed element doesn't exist in the matrix, but KLU mode cannot create a new element. ") ;
|
||||||
|
printf ("Please specify an existing element for .nodeset\n") ;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
node->ptr = SMPmakeElt(ckt->CKTmatrix,node->number,node->number);
|
||||||
|
}
|
||||||
if(node->ptr == NULL) return(E_NOMEM);
|
if(node->ptr == NULL) return(E_NOMEM);
|
||||||
ckt->CKThadNodeset = 1;
|
ckt->CKThadNodeset = 1;
|
||||||
ckt->CKTrhsOld[node->number] = ckt->CKTrhs[node->number] = node->nodeset;
|
ckt->CKTrhsOld[node->number] = ckt->CKTrhs[node->number] = node->nodeset;
|
||||||
}
|
}
|
||||||
if(node->icGiven) {
|
if(node->icGiven) {
|
||||||
if(! ( node->ptr)) {
|
if(! ( node->ptr)) {
|
||||||
node->ptr = SMPmakeElt(ckt->CKTmatrix,node->number,
|
if (ckt->CKTkluMODE) {
|
||||||
node->number);
|
node->ptr = (double *) SMPfindElt (ckt->CKTmatrix, node->number, node->number, 0) ;
|
||||||
|
if (node->ptr == NULL) {
|
||||||
|
printf ("Warning: The needed element doesn't exist in the matrix, but KLU mode cannot create a new element. ") ;
|
||||||
|
printf ("Please specify an existing element for .ic\n") ;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
node->ptr = SMPmakeElt(ckt->CKTmatrix,node->number, node->number);
|
||||||
|
}
|
||||||
if(node->ptr == NULL) return(E_NOMEM);
|
if(node->ptr == NULL) return(E_NOMEM);
|
||||||
}
|
}
|
||||||
ckt->CKTrhsOld[node->number] = ckt->CKTrhs[node->number] = node->ic;
|
ckt->CKTrhsOld[node->number] = ckt->CKTrhs[node->number] = node->ic;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue