Fixed the case in which the KCL is not enabled

This commit is contained in:
Francesco Lannutti 2013-06-02 12:30:00 +02:00
parent 0e59399e2a
commit d75fe9e10c
1 changed files with 14 additions and 3 deletions

View File

@ -28,9 +28,10 @@ NIconvTest(CKTcircuit *ckt)
double tol;
#endif
size = SMPmatSize (ckt->CKTmatrix) ;
size = SMPmatSize(ckt->CKTmatrix);
#ifndef KIRCHHOFF
node = ckt->CKTnodes;
#ifdef STEPDEBUG
for (i=1;i<=size;i++) {
new = ckt->CKTrhs [i] ;
@ -38,8 +39,6 @@ NIconvTest(CKTcircuit *ckt)
printf("chk for convergence: %s new: %g old: %g\n",CKTnodName(ckt,i),new,old);
}
#endif /* STEPDEBUG */
node = ckt->CKTnodes ;
for (i=1;i<=size;i++) {
node = node->next;
new = ckt->CKTrhs [i] ;
@ -51,6 +50,18 @@ NIconvTest(CKTcircuit *ckt)
#ifdef STEPDEBUG
printf(" non-convergence at node (type=3) %s (fabs(new-old)>tol --> fabs(%g-%g)>%g)\n",CKTnodName(ckt,i),new,old,tol);
printf(" reltol: %g voltTol: %g (tol=reltol*(MAX(fabs(old),fabs(new))) + voltTol)\n",ckt->CKTreltol,ckt->CKTvoltTol);
#endif /* STEPDEBUG */
ckt->CKTtroubleNode = i;
ckt->CKTtroubleElt = NULL;
return(1);
}
} else {
tol = ckt->CKTreltol * (MAX(fabs(old),fabs(new))) +
ckt->CKTabstol;
if (fabs(new-old) >tol ) {
#ifdef STEPDEBUG
printf(" non-convergence at node (type=%d) %s (fabs(new-old)>tol --> fabs(%g-%g)>%g)\n",node->type,CKTnodName(ckt,i),new,old,tol);
printf(" reltol: %g abstol: %g (tol=reltol*(MAX(fabs(old),fabs(new))) + abstol)\n",ckt->CKTreltol,ckt->CKTabstol);
#endif /* STEPDEBUG */
ckt->CKTtroubleNode = i;
ckt->CKTtroubleElt = NULL;