dctrcurv.c, #1/7, whitespace cleanup
This commit is contained in:
parent
5b42d09618
commit
8baf4f435f
|
|
@ -26,22 +26,22 @@ Modified: 1999 Paolo Nenzi
|
||||||
#include "ngspice/devdefs.h"
|
#include "ngspice/devdefs.h"
|
||||||
|
|
||||||
#ifdef HAS_PROGREP
|
#ifdef HAS_PROGREP
|
||||||
static double actval, actdiff;
|
static double actval, actdiff;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void inp_evaluate_temper(void);
|
extern void inp_evaluate_temper(void);
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
DCtrCurv(CKTcircuit *ckt, int restart)
|
DCtrCurv(CKTcircuit *ckt, int restart)
|
||||||
|
/* forced restart flag */
|
||||||
/* forced restart flag */
|
|
||||||
{
|
{
|
||||||
TRCV *job = (TRCV *) ckt->CKTcurJob;
|
TRCV *job = (TRCV *) ckt->CKTcurJob;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
double *temp;
|
double *temp;
|
||||||
int converged;
|
int converged;
|
||||||
int rcode;
|
int rcode;
|
||||||
int vcode;
|
int vcode;
|
||||||
int icode;
|
int icode;
|
||||||
int j;
|
int j;
|
||||||
|
|
@ -49,23 +49,23 @@ DCtrCurv(CKTcircuit *ckt, int restart)
|
||||||
IFuid varUid;
|
IFuid varUid;
|
||||||
IFuid *nameList;
|
IFuid *nameList;
|
||||||
int numNames;
|
int numNames;
|
||||||
int firstTime=1;
|
int firstTime = 1;
|
||||||
static runDesc *plot = NULL;
|
static runDesc *plot = NULL;
|
||||||
|
|
||||||
#ifdef WANT_SENSE2
|
#ifdef WANT_SENSE2
|
||||||
long save;
|
long save;
|
||||||
#ifdef SENSDEBUG
|
#ifdef SENSDEBUG
|
||||||
if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode&DCSEN) ){
|
if (ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & DCSEN)) {
|
||||||
printf("\nDC Sensitivity Results\n\n");
|
printf("\nDC Sensitivity Results\n\n");
|
||||||
CKTsenPrint(ckt);
|
CKTsenPrint(ckt);
|
||||||
}
|
}
|
||||||
#endif /* SENSDEBUG */
|
#endif /* SENSDEBUG */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
rcode = CKTtypelook("Resistor");
|
rcode = CKTtypelook("Resistor");
|
||||||
vcode = CKTtypelook("Vsource");
|
vcode = CKTtypelook("Vsource");
|
||||||
icode = CKTtypelook("Isource");
|
icode = CKTtypelook("Isource");
|
||||||
|
|
||||||
if (!restart && job->TRCVnestState >= 0) {
|
if (!restart && job->TRCVnestState >= 0) {
|
||||||
/* continuing */
|
/* continuing */
|
||||||
i = job->TRCVnestState;
|
i = job->TRCVnestState;
|
||||||
|
|
@ -77,27 +77,28 @@ DCtrCurv(CKTcircuit *ckt, int restart)
|
||||||
&plot);
|
&plot);
|
||||||
goto resume;
|
goto resume;
|
||||||
}
|
}
|
||||||
|
|
||||||
ckt->CKTtime = 0;
|
ckt->CKTtime = 0;
|
||||||
ckt->CKTdelta = job->TRCVvStep[0];
|
ckt->CKTdelta = job->TRCVvStep[0];
|
||||||
ckt->CKTmode = (ckt->CKTmode & MODEUIC) | MODEDCTRANCURVE | MODEINITJCT ;
|
ckt->CKTmode = (ckt->CKTmode & MODEUIC) | MODEDCTRANCURVE | MODEINITJCT;
|
||||||
ckt->CKTorder=1;
|
ckt->CKTorder = 1;
|
||||||
|
|
||||||
|
|
||||||
/* Save the state of the circuit */
|
/* Save the state of the circuit */
|
||||||
for(i=0;i<7;i++) {
|
for (i = 0; i < 7; i++) {
|
||||||
ckt->CKTdeltaOld[i]=ckt->CKTdelta;
|
ckt->CKTdeltaOld[i] = ckt->CKTdelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i <= job->TRCVnestLevel; i++) {
|
for (i = 0; i <= job->TRCVnestLevel; i++) {
|
||||||
if(rcode >= 0) {
|
|
||||||
|
if (rcode >= 0) {
|
||||||
/* resistances are in this version, so use them */
|
/* resistances are in this version, so use them */
|
||||||
RESinstance *here;
|
RESinstance *here;
|
||||||
RESmodel *model;
|
RESmodel *model;
|
||||||
|
|
||||||
for(model = (RESmodel *)ckt->CKThead[rcode];model != NULL;
|
for (model = (RESmodel *)ckt->CKThead[rcode]; model != NULL;
|
||||||
model=model->RESnextModel){
|
model = model->RESnextModel) {
|
||||||
for(here=model->RESinstances;here!=NULL;
|
for (here = model->RESinstances; here != NULL;
|
||||||
here=here->RESnextInstance) {
|
here = here->RESnextInstance) {
|
||||||
if (here->RESname == job->TRCVvName[i]) {
|
if (here->RESname == job->TRCVvName[i]) {
|
||||||
job->TRCVvElt[i] = (GENinstance *)here;
|
job->TRCVvElt[i] = (GENinstance *)here;
|
||||||
job->TRCVvSave[i] = here->RESresist;
|
job->TRCVvSave[i] = here->RESresist;
|
||||||
|
|
@ -111,15 +112,16 @@ DCtrCurv(CKTcircuit *ckt, int restart)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(vcode >= 0) {
|
|
||||||
|
if (vcode >= 0) {
|
||||||
/* voltage sources are in this version, so use them */
|
/* voltage sources are in this version, so use them */
|
||||||
VSRCinstance *here;
|
VSRCinstance *here;
|
||||||
VSRCmodel *model;
|
VSRCmodel *model;
|
||||||
|
|
||||||
for(model = (VSRCmodel *)ckt->CKThead[vcode];model != NULL;
|
for (model = (VSRCmodel *)ckt->CKThead[vcode]; model != NULL;
|
||||||
model=model->VSRCnextModel){
|
model = model->VSRCnextModel) {
|
||||||
for(here=model->VSRCinstances;here!=NULL;
|
for (here = model->VSRCinstances; here != NULL;
|
||||||
here=here->VSRCnextInstance) {
|
here = here->VSRCnextInstance) {
|
||||||
if (here->VSRCname == job->TRCVvName[i]) {
|
if (here->VSRCname == job->TRCVvName[i]) {
|
||||||
job->TRCVvElt[i] = (GENinstance *)here;
|
job->TRCVvElt[i] = (GENinstance *)here;
|
||||||
job->TRCVvSave[i] = here->VSRCdcValue;
|
job->TRCVvSave[i] = here->VSRCdcValue;
|
||||||
|
|
@ -132,16 +134,17 @@ DCtrCurv(CKTcircuit *ckt, int restart)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(icode >= 0 ) {
|
|
||||||
|
if (icode >= 0) {
|
||||||
/* current sources are in this version, so use them */
|
/* current sources are in this version, so use them */
|
||||||
ISRCinstance *here;
|
ISRCinstance *here;
|
||||||
ISRCmodel *model;
|
ISRCmodel *model;
|
||||||
|
|
||||||
for(model= (ISRCmodel *)ckt->CKThead[icode];model != NULL;
|
for (model = (ISRCmodel *)ckt->CKThead[icode]; model != NULL;
|
||||||
model=model->ISRCnextModel){
|
model = model->ISRCnextModel) {
|
||||||
for(here=model->ISRCinstances;here!=NULL;
|
for (here = model->ISRCinstances; here != NULL;
|
||||||
here=here->ISRCnextInstance) {
|
here = here->ISRCnextInstance) {
|
||||||
if(here->ISRCname == job->TRCVvName[i]) {
|
if (here->ISRCname == job->TRCVvName[i]) {
|
||||||
job->TRCVvElt[i] = (GENinstance *)here;
|
job->TRCVvElt[i] = (GENinstance *)here;
|
||||||
job->TRCVvSave[i] = here->ISRCdcValue;
|
job->TRCVvSave[i] = here->ISRCdcValue;
|
||||||
job->TRCVgSave[i] = here->ISRCdcGiven;
|
job->TRCVgSave[i] = here->ISRCdcGiven;
|
||||||
|
|
@ -153,7 +156,7 @@ DCtrCurv(CKTcircuit *ckt, int restart)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(job->TRCVvName[i], "temp"))
|
if (!strcmp(job->TRCVvName[i], "temp"))
|
||||||
{
|
{
|
||||||
job->TRCVvSave[i] = ckt->CKTtemp; /* Saves the old circuit temperature */
|
job->TRCVvSave[i] = ckt->CKTtemp; /* Saves the old circuit temperature */
|
||||||
|
|
@ -166,10 +169,10 @@ DCtrCurv(CKTcircuit *ckt, int restart)
|
||||||
}
|
}
|
||||||
|
|
||||||
SPfrontEnd->IFerrorf (ERR_FATAL,
|
SPfrontEnd->IFerrorf (ERR_FATAL,
|
||||||
"DCtrCurv: source / resistor %s not in circuit", job->TRCVvName[i]);
|
"DCtrCurv: source / resistor %s not in circuit", job->TRCVvName[i]);
|
||||||
return(E_NODEV);
|
return(E_NODEV);
|
||||||
|
|
||||||
found:;
|
found:;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAS_PROGREP
|
#ifdef HAS_PROGREP
|
||||||
|
|
@ -191,178 +194,165 @@ found:;
|
||||||
/* gtri - end - wbk */
|
/* gtri - end - wbk */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
i--; /* PN: This seems to do nothing ??? */
|
i--; /* PN: This seems to do nothing ??? */
|
||||||
|
|
||||||
error = CKTnames(ckt,&numNames,&nameList);
|
error = CKTnames(ckt, &numNames, &nameList);
|
||||||
if(error) return(error);
|
if (error) return(error);
|
||||||
|
|
||||||
|
|
||||||
if (job->TRCVvType[i] == vcode)
|
if (job->TRCVvType[i] == vcode)
|
||||||
SPfrontEnd->IFnewUid (ckt, &varUid, NULL, "v-sweep", UID_OTHER, NULL);
|
SPfrontEnd->IFnewUid (ckt, &varUid, NULL, "v-sweep", UID_OTHER, NULL);
|
||||||
|
|
||||||
else {
|
else {
|
||||||
if (job->TRCVvType[i] == icode)
|
if (job->TRCVvType[i] == icode)
|
||||||
SPfrontEnd->IFnewUid (ckt, &varUid, NULL, "i-sweep", UID_OTHER, NULL);
|
SPfrontEnd->IFnewUid (ckt, &varUid, NULL, "i-sweep", UID_OTHER, NULL);
|
||||||
|
|
||||||
else {
|
else {
|
||||||
if (job->TRCVvType[i] == TEMP_CODE)
|
if (job->TRCVvType[i] == TEMP_CODE)
|
||||||
SPfrontEnd->IFnewUid (ckt, &varUid, NULL, "temp-sweep", UID_OTHER, NULL);
|
SPfrontEnd->IFnewUid (ckt, &varUid, NULL, "temp-sweep", UID_OTHER, NULL);
|
||||||
|
|
||||||
else {
|
else {
|
||||||
if (job->TRCVvType[i] == rcode)
|
if (job->TRCVvType[i] == rcode)
|
||||||
SPfrontEnd->IFnewUid (ckt, &varUid, NULL, "res-sweep", UID_OTHER, NULL);
|
SPfrontEnd->IFnewUid (ckt, &varUid, NULL, "res-sweep", UID_OTHER, NULL);
|
||||||
|
|
||||||
else
|
else
|
||||||
SPfrontEnd->IFnewUid (ckt, &varUid, NULL, "?-sweep", UID_OTHER, NULL);
|
SPfrontEnd->IFnewUid (ckt, &varUid, NULL, "?-sweep", UID_OTHER, NULL);
|
||||||
} /* icode */
|
} /* icode */
|
||||||
} /* TEMP_CODE */
|
} /* TEMP_CODE */
|
||||||
} /* rcode*/
|
} /* rcode*/
|
||||||
|
|
||||||
error = SPfrontEnd->OUTpBeginPlot (ckt, ckt->CKTcurJob,
|
error = SPfrontEnd->OUTpBeginPlot (ckt, ckt->CKTcurJob,
|
||||||
ckt->CKTcurJob->JOBname,
|
ckt->CKTcurJob->JOBname,
|
||||||
varUid, IF_REAL,
|
varUid, IF_REAL,
|
||||||
numNames, nameList, IF_REAL,
|
numNames, nameList, IF_REAL,
|
||||||
&plot);
|
&plot);
|
||||||
tfree(nameList);
|
tfree(nameList);
|
||||||
|
|
||||||
if(error) return(error);
|
if (error) return(error);
|
||||||
|
|
||||||
/* initialize CKTsoaCheck `warn' counters */
|
/* initialize CKTsoaCheck `warn' counters */
|
||||||
if (ckt->CKTsoaCheck)
|
if (ckt->CKTsoaCheck)
|
||||||
error = CKTsoaInit();
|
error = CKTsoaInit();
|
||||||
|
|
||||||
/* now have finished the initialization - can start doing hard part */
|
/* now have finished the initialization - can start doing hard part */
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
resume:
|
resume:
|
||||||
|
|
||||||
for(;;) {
|
for (;;) {
|
||||||
|
|
||||||
if (job->TRCVvType[i] == vcode) { /* voltage source */
|
if (job->TRCVvType[i] == vcode) { /* voltage source */
|
||||||
if((((VSRCinstance*)(job->TRCVvElt[i]))->VSRCdcValue) *
|
if ((((VSRCinstance*)(job->TRCVvElt[i]))->VSRCdcValue) *
|
||||||
SIGN(1.0, job->TRCVvStep[i]) -
|
SIGN(1.0, job->TRCVvStep[i]) -
|
||||||
SIGN(1.0, job->TRCVvStep[i]) * job->TRCVvStop[i] >
|
SIGN(1.0, job->TRCVvStep[i]) * job->TRCVvStop[i] >
|
||||||
DBL_EPSILON*1e+03)
|
DBL_EPSILON * 1e+03)
|
||||||
{
|
{
|
||||||
i++ ;
|
i++;
|
||||||
firstTime=1;
|
firstTime = 1;
|
||||||
ckt->CKTmode = (ckt->CKTmode & MODEUIC) |
|
ckt->CKTmode = (ckt->CKTmode & MODEUIC) |
|
||||||
MODEDCTRANCURVE | MODEINITJCT ;
|
MODEDCTRANCURVE | MODEINITJCT;
|
||||||
if (i > job->TRCVnestLevel) break;
|
if (i > job->TRCVnestLevel) break;
|
||||||
goto nextstep;
|
goto nextstep;
|
||||||
}
|
}
|
||||||
} else if (job->TRCVvType[i] == icode) { /* current source */
|
} else if (job->TRCVvType[i] == icode) { /* current source */
|
||||||
if((((ISRCinstance*)(job->TRCVvElt[i]))->ISRCdcValue) *
|
if ((((ISRCinstance*)(job->TRCVvElt[i]))->ISRCdcValue) *
|
||||||
SIGN(1.0, job->TRCVvStep[i]) -
|
SIGN(1.0, job->TRCVvStep[i]) -
|
||||||
SIGN(1.0, job->TRCVvStep[i]) * job->TRCVvStop[i] >
|
SIGN(1.0, job->TRCVvStep[i]) * job->TRCVvStop[i] >
|
||||||
DBL_EPSILON*1e+03)
|
DBL_EPSILON * 1e+03)
|
||||||
{
|
|
||||||
i++ ;
|
|
||||||
firstTime=1;
|
|
||||||
ckt->CKTmode = (ckt->CKTmode & MODEUIC) |
|
|
||||||
MODEDCTRANCURVE | MODEINITJCT ;
|
|
||||||
if (i > job->TRCVnestLevel) break;
|
|
||||||
goto nextstep;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (job->TRCVvType[i] == rcode) { /* resistance */
|
|
||||||
if((((RESinstance*)(job->TRCVvElt[i]))->RESresist) *
|
|
||||||
SIGN(1.0, job->TRCVvStep[i]) -
|
|
||||||
SIGN(1.0, job->TRCVvStep[i]) * job->TRCVvStop[i]
|
|
||||||
> DBL_EPSILON*1e+03)
|
|
||||||
{
|
|
||||||
i++ ;
|
|
||||||
firstTime=1;
|
|
||||||
ckt->CKTmode = (ckt->CKTmode & MODEUIC) |
|
|
||||||
MODEDCTRANCURVE | MODEINITJCT ;
|
|
||||||
if (i > job->TRCVnestLevel) break;
|
|
||||||
goto nextstep;
|
|
||||||
}
|
|
||||||
} else if (job->TRCVvType[i] == TEMP_CODE) { /* temp sweep */
|
|
||||||
if(((ckt->CKTtemp) - CONSTCtoK) * SIGN(1.0, job->TRCVvStep[i]) -
|
|
||||||
SIGN(1.0, job->TRCVvStep[i]) * job->TRCVvStop[i] >
|
|
||||||
DBL_EPSILON*1e+03)
|
|
||||||
{
|
{
|
||||||
i++ ;
|
i++;
|
||||||
firstTime=1;
|
firstTime = 1;
|
||||||
ckt->CKTmode = (ckt->CKTmode & MODEUIC) |
|
ckt->CKTmode = (ckt->CKTmode & MODEUIC) |
|
||||||
MODEDCTRANCURVE | MODEINITJCT ;
|
MODEDCTRANCURVE | MODEINITJCT;
|
||||||
|
if (i > job->TRCVnestLevel) break;
|
||||||
|
goto nextstep;
|
||||||
|
}
|
||||||
|
} else if (job->TRCVvType[i] == rcode) { /* resistance */
|
||||||
|
if ((((RESinstance*)(job->TRCVvElt[i]))->RESresist) *
|
||||||
|
SIGN(1.0, job->TRCVvStep[i]) -
|
||||||
|
SIGN(1.0, job->TRCVvStep[i]) * job->TRCVvStop[i]
|
||||||
|
> DBL_EPSILON * 1e+03)
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
firstTime = 1;
|
||||||
|
ckt->CKTmode = (ckt->CKTmode & MODEUIC) |
|
||||||
|
MODEDCTRANCURVE | MODEINITJCT;
|
||||||
|
if (i > job->TRCVnestLevel) break;
|
||||||
|
goto nextstep;
|
||||||
|
}
|
||||||
|
} else if (job->TRCVvType[i] == TEMP_CODE) { /* temp sweep */
|
||||||
|
if (((ckt->CKTtemp) - CONSTCtoK) * SIGN(1.0, job->TRCVvStep[i]) -
|
||||||
|
SIGN(1.0, job->TRCVvStep[i]) * job->TRCVvStop[i] >
|
||||||
|
DBL_EPSILON * 1e+03)
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
firstTime = 1;
|
||||||
|
ckt->CKTmode = (ckt->CKTmode & MODEUIC) |
|
||||||
|
MODEDCTRANCURVE | MODEINITJCT;
|
||||||
if (i > job->TRCVnestLevel) break;
|
if (i > job->TRCVnestLevel) break;
|
||||||
goto nextstep;
|
goto nextstep;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* else not possible */
|
} /* else not possible */
|
||||||
while (i > 0) {
|
|
||||||
|
while (i > 0) {
|
||||||
/* init(i); */
|
/* init(i); */
|
||||||
i--;
|
i--;
|
||||||
if (job->TRCVvType[i] == vcode) { /* voltage source */
|
if (job->TRCVvType[i] == vcode) { /* voltage source */
|
||||||
((VSRCinstance *)(job->TRCVvElt[i]))->VSRCdcValue =
|
((VSRCinstance *)(job->TRCVvElt[i]))->VSRCdcValue =
|
||||||
job->TRCVvStart[i];
|
job->TRCVvStart[i];
|
||||||
|
|
||||||
} else if (job->TRCVvType[i] == icode) { /* current source */
|
} else if (job->TRCVvType[i] == icode) { /* current source */
|
||||||
((ISRCinstance *)(job->TRCVvElt[i]))->ISRCdcValue =
|
((ISRCinstance *)(job->TRCVvElt[i]))->ISRCdcValue =
|
||||||
job->TRCVvStart[i];
|
job->TRCVvStart[i];
|
||||||
|
|
||||||
} else if (job->TRCVvType[i] == TEMP_CODE) {
|
} else if (job->TRCVvType[i] == TEMP_CODE) {
|
||||||
ckt->CKTtemp = job->TRCVvStart[i] + CONSTCtoK;
|
ckt->CKTtemp = job->TRCVvStart[i] + CONSTCtoK;
|
||||||
if (expr_w_temper)
|
if (expr_w_temper)
|
||||||
inp_evaluate_temper();
|
inp_evaluate_temper();
|
||||||
CKTtemp(ckt);
|
CKTtemp(ckt);
|
||||||
|
|
||||||
} else if (job->TRCVvType[i] == rcode) {
|
} else if (job->TRCVvType[i] == rcode) {
|
||||||
((RESinstance *)(job->TRCVvElt[i]))->RESresist =
|
((RESinstance *)(job->TRCVvElt[i]))->RESresist =
|
||||||
job->TRCVvStart[i];
|
job->TRCVvStart[i];
|
||||||
((RESinstance *)(job->TRCVvElt[i]))->RESconduct =
|
((RESinstance *)(job->TRCVvElt[i]))->RESconduct =
|
||||||
1/(((RESinstance *)(job->TRCVvElt[i]))->RESresist);
|
1 / (((RESinstance *)(job->TRCVvElt[i]))->RESresist);
|
||||||
/* Note: changing the resistance does nothing */
|
/* Note: changing the resistance does nothing */
|
||||||
/* changing the conductance 1/r instead */
|
/* changing the conductance 1/r instead */
|
||||||
DEVices[rcode]->DEVload(job->TRCVvElt[i]->GENmodPtr, ckt);
|
DEVices[rcode]->DEVload(job->TRCVvElt[i]->GENmodPtr, ckt);
|
||||||
|
/*
|
||||||
/*
|
* RESload(job->TRCVvElt[i]->GENmodPtr, ckt);
|
||||||
* RESload(job->TRCVvElt[i]->GENmodPtr, ckt);
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
} /* else not possible */
|
} /* else not possible */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Rotate state vectors. */
|
/* Rotate state vectors. */
|
||||||
temp = ckt->CKTstates[ckt->CKTmaxOrder+1];
|
temp = ckt->CKTstates[ckt->CKTmaxOrder + 1];
|
||||||
for(j=ckt->CKTmaxOrder;j>=0;j--) {
|
for (j = ckt->CKTmaxOrder; j >= 0; j--) {
|
||||||
ckt->CKTstates[j+1] = ckt->CKTstates[j];
|
ckt->CKTstates[j + 1] = ckt->CKTstates[j];
|
||||||
}
|
}
|
||||||
ckt->CKTstate0 = temp;
|
ckt->CKTstate0 = temp;
|
||||||
|
|
||||||
/* do operation */
|
/* do operation */
|
||||||
#ifdef XSPICE
|
#ifdef XSPICE
|
||||||
/* gtri - begin - wbk - Do EVTop if event instances exist */
|
/* gtri - begin - wbk - Do EVTop if event instances exist */
|
||||||
if(ckt->evt->counts.num_insts == 0) {
|
if (ckt->evt->counts.num_insts == 0) {
|
||||||
/* If no event-driven instances, do what SPICE normally does */
|
/* If no event-driven instances, do what SPICE normally does */
|
||||||
#endif
|
#endif
|
||||||
converged = NIiter(ckt,ckt->CKTdcTrcvMaxIter);
|
converged = NIiter(ckt, ckt->CKTdcTrcvMaxIter);
|
||||||
if(converged != 0) {
|
if (converged != 0) {
|
||||||
converged = CKTop(ckt,
|
converged = CKTop(ckt,
|
||||||
(ckt->CKTmode&MODEUIC)|MODEDCTRANCURVE | MODEINITJCT,
|
(ckt->CKTmode & MODEUIC) | MODEDCTRANCURVE | MODEINITJCT,
|
||||||
(ckt->CKTmode&MODEUIC)|MODEDCTRANCURVE | MODEINITFLOAT,
|
(ckt->CKTmode & MODEUIC) | MODEDCTRANCURVE | MODEINITFLOAT,
|
||||||
ckt->CKTdcMaxIter);
|
ckt->CKTdcMaxIter);
|
||||||
if(converged != 0) {
|
if (converged != 0) {
|
||||||
return(converged);
|
return(converged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef XSPICE
|
#ifdef XSPICE
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* else do new algorithm */
|
/* else do new algorithm */
|
||||||
|
|
||||||
/* first get the current step in the analysis */
|
/* first get the current step in the analysis */
|
||||||
if (job->TRCVvType[0] == vcode) {
|
if (job->TRCVvType[0] == vcode) {
|
||||||
g_mif_info.circuit.evt_step =
|
g_mif_info.circuit.evt_step =
|
||||||
((VSRCinstance *)(job->TRCVvElt[i]))->VSRCdcValue ;
|
((VSRCinstance *)(job->TRCVvElt[i]))->VSRCdcValue;
|
||||||
} else if (job->TRCVvType[0] == icode) {
|
} else if (job->TRCVvType[0] == icode) {
|
||||||
g_mif_info.circuit.evt_step =
|
g_mif_info.circuit.evt_step =
|
||||||
((ISRCinstance *)(job->TRCVvElt[i]))->ISRCdcValue ;
|
((ISRCinstance *)(job->TRCVvElt[i]))->ISRCdcValue;
|
||||||
} else if (job->TRCVvType[0] == rcode) {
|
} else if (job->TRCVvType[0] == rcode) {
|
||||||
g_mif_info.circuit.evt_step =
|
g_mif_info.circuit.evt_step =
|
||||||
((RESinstance*)(job->TRCVvElt[i]->GENmodPtr))->RESresist;
|
((RESinstance*)(job->TRCVvElt[i]->GENmodPtr))->RESresist;
|
||||||
|
|
@ -372,32 +362,32 @@ resume:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if first time through, call EVTop immediately and save event results */
|
/* if first time through, call EVTop immediately and save event results */
|
||||||
if(firstTime) {
|
if (firstTime) {
|
||||||
converged = EVTop(ckt,
|
converged = EVTop(ckt,
|
||||||
(ckt->CKTmode & MODEUIC) | MODEDCTRANCURVE | MODEINITJCT,
|
(ckt->CKTmode & MODEUIC) | MODEDCTRANCURVE | MODEINITJCT,
|
||||||
(ckt->CKTmode & MODEUIC) | MODEDCTRANCURVE | MODEINITFLOAT,
|
(ckt->CKTmode & MODEUIC) | MODEDCTRANCURVE | MODEINITFLOAT,
|
||||||
ckt->CKTdcMaxIter,
|
ckt->CKTdcMaxIter,
|
||||||
MIF_TRUE);
|
MIF_TRUE);
|
||||||
EVTdump(ckt, IPC_ANAL_DCOP, g_mif_info.circuit.evt_step);
|
EVTdump(ckt, IPC_ANAL_DCOP, g_mif_info.circuit.evt_step);
|
||||||
EVTop_save(ckt, MIF_FALSE, g_mif_info.circuit.evt_step);
|
EVTop_save(ckt, MIF_FALSE, g_mif_info.circuit.evt_step);
|
||||||
if(converged != 0)
|
if (converged != 0)
|
||||||
return(converged);
|
return(converged);
|
||||||
}
|
}
|
||||||
/* else, call NIiter first with mode = MODEINITPRED */
|
/* else, call NIiter first with mode = MODEINITPRED */
|
||||||
/* to attempt quick analog solution. Then call all hybrids and call */
|
/* to attempt quick analog solution. Then call all hybrids and call */
|
||||||
/* EVTop only if event outputs have changed, or if non-converged */
|
/* EVTop only if event outputs have changed, or if non-converged */
|
||||||
else {
|
else {
|
||||||
converged = NIiter(ckt,ckt->CKTdcTrcvMaxIter);
|
converged = NIiter(ckt, ckt->CKTdcTrcvMaxIter);
|
||||||
EVTcall_hybrids(ckt);
|
EVTcall_hybrids(ckt);
|
||||||
if((converged != 0) || (ckt->evt->queue.output.num_changed != 0)) {
|
if ((converged != 0) || (ckt->evt->queue.output.num_changed != 0)) {
|
||||||
converged = EVTop(ckt,
|
converged = EVTop(ckt,
|
||||||
(ckt->CKTmode & MODEUIC) | MODEDCTRANCURVE | MODEINITJCT,
|
(ckt->CKTmode & MODEUIC) | MODEDCTRANCURVE | MODEINITJCT,
|
||||||
(ckt->CKTmode & MODEUIC) | MODEDCTRANCURVE | MODEINITFLOAT,
|
(ckt->CKTmode & MODEUIC) | MODEDCTRANCURVE | MODEINITFLOAT,
|
||||||
ckt->CKTdcMaxIter,
|
ckt->CKTdcMaxIter,
|
||||||
MIF_FALSE);
|
MIF_FALSE);
|
||||||
EVTdump(ckt, IPC_ANAL_DCTRCURVE, g_mif_info.circuit.evt_step);
|
EVTdump(ckt, IPC_ANAL_DCTRCURVE, g_mif_info.circuit.evt_step);
|
||||||
EVTop_save(ckt, MIF_FALSE, g_mif_info.circuit.evt_step);
|
EVTop_save(ckt, MIF_FALSE, g_mif_info.circuit.evt_step);
|
||||||
if(converged != 0)
|
if (converged != 0)
|
||||||
return(converged);
|
return(converged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -405,18 +395,18 @@ resume:
|
||||||
/* gtri - end - wbk - Do EVTop if event instances exist */
|
/* gtri - end - wbk - Do EVTop if event instances exist */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ckt->CKTmode = (ckt->CKTmode&MODEUIC) | MODEDCTRANCURVE | MODEINITPRED ;
|
ckt->CKTmode = (ckt->CKTmode & MODEUIC) | MODEDCTRANCURVE | MODEINITPRED;
|
||||||
if (job->TRCVvType[0] == vcode) {
|
if (job->TRCVvType[0] == vcode) {
|
||||||
ckt->CKTtime = ((VSRCinstance *)(job->TRCVvElt[i]))->VSRCdcValue ;
|
ckt->CKTtime = ((VSRCinstance *)(job->TRCVvElt[i]))->VSRCdcValue;
|
||||||
} else if (job->TRCVvType[0] == icode) {
|
} else if (job->TRCVvType[0] == icode) {
|
||||||
ckt->CKTtime = ((ISRCinstance *)(job->TRCVvElt[i]))->ISRCdcValue ;
|
ckt->CKTtime = ((ISRCinstance *)(job->TRCVvElt[i]))->ISRCdcValue;
|
||||||
} else if (job->TRCVvType[0] == rcode) {
|
} else if (job->TRCVvType[0] == rcode) {
|
||||||
ckt->CKTtime = ((RESinstance *)(job->TRCVvElt[i]))->RESresist;
|
ckt->CKTtime = ((RESinstance *)(job->TRCVvElt[i]))->RESresist;
|
||||||
}
|
}
|
||||||
/* PN Temp sweep */
|
/* PN Temp sweep */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ckt->CKTtime = ckt->CKTtemp - CONSTCtoK ;
|
ckt->CKTtime = ckt->CKTtemp - CONSTCtoK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef XSPICE
|
#ifdef XSPICE
|
||||||
|
|
@ -425,7 +415,7 @@ resume:
|
||||||
/* If first time through, call CKTdump to output Operating Point info */
|
/* If first time through, call CKTdump to output Operating Point info */
|
||||||
/* for Mspice compatibility */
|
/* for Mspice compatibility */
|
||||||
|
|
||||||
if(g_ipc.enabled && firstTime) {
|
if (g_ipc.enabled && firstTime) {
|
||||||
ipc_send_dcop_prefix();
|
ipc_send_dcop_prefix();
|
||||||
CKTdump(ckt, 0.0, plot);
|
CKTdump(ckt, 0.0, plot);
|
||||||
ipc_send_dcop_suffix();
|
ipc_send_dcop_suffix();
|
||||||
|
|
@ -436,29 +426,28 @@ resume:
|
||||||
|
|
||||||
#ifdef WANT_SENSE2
|
#ifdef WANT_SENSE2
|
||||||
/*
|
/*
|
||||||
if(!ckt->CKTsenInfo) printf("sensitivity structure does not exist\n");
|
if (!ckt->CKTsenInfo) printf("sensitivity structure does not exist\n");
|
||||||
*/
|
*/
|
||||||
if(ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode&DCSEN) ){
|
if (ckt->CKTsenInfo && (ckt->CKTsenInfo->SENmode & DCSEN)) {
|
||||||
int senmode;
|
int senmode;
|
||||||
|
|
||||||
#ifdef SENSDEBUG
|
#ifdef SENSDEBUG
|
||||||
if (job->TRCVvType[i] == vcode) { /* voltage source */
|
if (job->TRCVvType[i] == vcode) { /* voltage source */
|
||||||
printf("Voltage Source Value : %.5e V\n",
|
printf("Voltage Source Value : %.5e V\n",
|
||||||
((VSRCinstance*) (job->TRCVvElt[i]))->VSRCdcValue);
|
((VSRCinstance*) (job->TRCVvElt[i]))->VSRCdcValue);
|
||||||
}
|
}
|
||||||
if (job->TRCVvType[i] == icode) { /* current source */
|
if (job->TRCVvType[i] == icode) { /* current source */
|
||||||
printf("Current Source Value : %.5e A\n",
|
printf("Current Source Value : %.5e A\n",
|
||||||
((ISRCinstance*)(job->TRCVvElt[i]))->ISRCdcValue);
|
((ISRCinstance*)(job->TRCVvElt[i]))->ISRCdcValue);
|
||||||
}
|
}
|
||||||
if (job->TRCVvType[i] == rcode) { /* resistance */
|
if (job->TRCVvType[i] == rcode) { /* resistance */
|
||||||
printf("Current Resistance Value : %.5e Ohm\n",
|
printf("Current Resistance Value : %.5e Ohm\n",
|
||||||
((RESinstance*)(job->TRCVvElt[i]->GENmodPtr))->RESresist);
|
((RESinstance*)(job->TRCVvElt[i]->GENmodPtr))->RESresist);
|
||||||
}
|
}
|
||||||
if (job->TRCVvType[i] == TEMP_CODE) { /* Temperature */
|
if (job->TRCVvType[i] == TEMP_CODE) { /* Temperature */
|
||||||
printf("Current Circuit Temperature : %.5e C\n",
|
printf("Current Circuit Temperature : %.5e C\n",
|
||||||
ckt->CKTtemp - CONSTCtoK);
|
ckt->CKTtemp - CONSTCtoK);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SENSDEBUG */
|
#endif /* SENSDEBUG */
|
||||||
|
|
||||||
senmode = ckt->CKTsenInfo->SENmode;
|
senmode = ckt->CKTsenInfo->SENmode;
|
||||||
|
|
@ -470,14 +459,13 @@ resume:
|
||||||
|
|
||||||
ckt->CKTmode = save;
|
ckt->CKTmode = save;
|
||||||
ckt->CKTsenInfo->SENmode = senmode;
|
ckt->CKTsenInfo->SENmode = senmode;
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef XSPICE
|
#ifdef XSPICE
|
||||||
/* gtri - modify - wbk - 12/19/90 - Send IPC delimiters */
|
/* gtri - modify - wbk - 12/19/90 - Send IPC delimiters */
|
||||||
|
|
||||||
if(g_ipc.enabled)
|
if (g_ipc.enabled)
|
||||||
ipc_send_data_prefix(ckt->CKTtime);
|
ipc_send_data_prefix(ckt->CKTtime);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -487,36 +475,36 @@ resume:
|
||||||
error = CKTsoaCheck(ckt);
|
error = CKTsoaCheck(ckt);
|
||||||
|
|
||||||
#ifdef XSPICE
|
#ifdef XSPICE
|
||||||
if(g_ipc.enabled)
|
if (g_ipc.enabled)
|
||||||
ipc_send_data_suffix();
|
ipc_send_data_suffix();
|
||||||
|
|
||||||
/* gtri - end - wbk */
|
/* gtri - end - wbk */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(firstTime) {
|
if (firstTime) {
|
||||||
firstTime=0;
|
firstTime = 0;
|
||||||
memcpy(ckt->CKTstate1, ckt->CKTstate0,
|
memcpy(ckt->CKTstate1, ckt->CKTstate0,
|
||||||
(size_t) ckt->CKTnumStates * sizeof(double));
|
(size_t) ckt->CKTnumStates * sizeof(double));
|
||||||
}
|
}
|
||||||
|
|
||||||
nextstep:;
|
nextstep:;
|
||||||
|
|
||||||
if (job->TRCVvType[i] == vcode) { /* voltage source */
|
if (job->TRCVvType[i] == vcode) { /* voltage source */
|
||||||
((VSRCinstance*)(job->TRCVvElt[i]))->VSRCdcValue +=
|
((VSRCinstance*)(job->TRCVvElt[i]))->VSRCdcValue +=
|
||||||
job->TRCVvStep[i];
|
job->TRCVvStep[i];
|
||||||
} else if (job->TRCVvType[i] == icode) { /* current source */
|
} else if (job->TRCVvType[i] == icode) { /* current source */
|
||||||
((ISRCinstance*)(job->TRCVvElt[i]))->ISRCdcValue +=
|
((ISRCinstance*)(job->TRCVvElt[i]))->ISRCdcValue +=
|
||||||
job->TRCVvStep[i];
|
job->TRCVvStep[i];
|
||||||
} else if (job->TRCVvType[i] == rcode) { /* resistance */
|
} else if (job->TRCVvType[i] == rcode) { /* resistance */
|
||||||
((RESinstance*)(job->TRCVvElt[i]))->RESresist +=
|
((RESinstance*)(job->TRCVvElt[i]))->RESresist +=
|
||||||
job->TRCVvStep[i];
|
job->TRCVvStep[i];
|
||||||
/* This code should update resistance and conductance */
|
/* This code should update resistance and conductance */
|
||||||
((RESinstance*)(job->TRCVvElt[i]))->RESconduct =
|
((RESinstance*)(job->TRCVvElt[i]))->RESconduct =
|
||||||
1/(((RESinstance*)(job->TRCVvElt[i]))->RESresist);
|
1 / (((RESinstance*)(job->TRCVvElt[i]))->RESresist);
|
||||||
DEVices[rcode]->DEVload(job->TRCVvElt[i]->GENmodPtr, ckt);
|
DEVices[rcode]->DEVload(job->TRCVvElt[i]->GENmodPtr, ckt);
|
||||||
/*
|
/*
|
||||||
* RESload(job->TRCVvElt[i]->GENmodPtr, ckt);
|
* RESload(job->TRCVvElt[i]->GENmodPtr, ckt);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
/* PN Temp Sweep - serban */
|
/* PN Temp Sweep - serban */
|
||||||
else if (job->TRCVvType[i] == TEMP_CODE)
|
else if (job->TRCVvType[i] == TEMP_CODE)
|
||||||
|
|
@ -526,18 +514,20 @@ nextstep:;
|
||||||
inp_evaluate_temper();
|
inp_evaluate_temper();
|
||||||
CKTtemp(ckt);
|
CKTtemp(ckt);
|
||||||
} /* else not possible */
|
} /* else not possible */
|
||||||
|
|
||||||
if(SPfrontEnd->IFpauseTest()) {
|
if (SPfrontEnd->IFpauseTest()) {
|
||||||
/* user asked us to pause, so save state */
|
/* user asked us to pause, so save state */
|
||||||
job->TRCVnestState = i;
|
job->TRCVnestState = i;
|
||||||
return(E_PAUSE);
|
return(E_PAUSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAS_PROGREP
|
#ifdef HAS_PROGREP
|
||||||
if (i == job->TRCVnestLevel) {
|
if (i == job->TRCVnestLevel) {
|
||||||
actval += job->TRCVvStep[job->TRCVnestLevel];
|
actval += job->TRCVvStep[job->TRCVnestLevel];
|
||||||
SetAnalyse( "dc", abs((int)(actval * 1000. / actdiff)));
|
SetAnalyse("dc", abs((int)(actval * 1000. / actdiff)));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* all done, lets put everything back */
|
/* all done, lets put everything back */
|
||||||
|
|
@ -556,14 +546,12 @@ nextstep:;
|
||||||
job->TRCVvSave[i];
|
job->TRCVvSave[i];
|
||||||
/* We restore both resistance and conductance */
|
/* We restore both resistance and conductance */
|
||||||
((RESinstance*)(job->TRCVvElt[i]))->RESconduct =
|
((RESinstance*)(job->TRCVvElt[i]))->RESconduct =
|
||||||
1/(((RESinstance*)(job->TRCVvElt[i]))->RESresist);
|
1 / (((RESinstance*)(job->TRCVvElt[i]))->RESresist);
|
||||||
|
|
||||||
((RESinstance*)(job->TRCVvElt[i]))->RESresGiven = (job->TRCVgSave[i] != 0);
|
((RESinstance*)(job->TRCVvElt[i]))->RESresGiven = (job->TRCVgSave[i] != 0);
|
||||||
DEVices[rcode]->DEVload(job->TRCVvElt[i]->GENmodPtr, ckt);
|
DEVices[rcode]->DEVload(job->TRCVvElt[i]->GENmodPtr, ckt);
|
||||||
|
/*
|
||||||
/*
|
* RESload(job->TRCVvElt[i]->GENmodPtr, ckt);
|
||||||
* RESload(job->TRCVvElt[i]->GENmodPtr, ckt);
|
*/
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
else if (job->TRCVvType[i] == TEMP_CODE) {
|
else if (job->TRCVvType[i] == TEMP_CODE) {
|
||||||
ckt->CKTtemp = job->TRCVvSave[i];
|
ckt->CKTtemp = job->TRCVvSave[i];
|
||||||
|
|
@ -572,6 +560,7 @@ nextstep:;
|
||||||
CKTtemp(ckt);
|
CKTtemp(ckt);
|
||||||
} /* else not possible */
|
} /* else not possible */
|
||||||
}
|
}
|
||||||
|
|
||||||
SPfrontEnd->OUTendPlot (plot);
|
SPfrontEnd->OUTendPlot (plot);
|
||||||
|
|
||||||
return(OK);
|
return(OK);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue