devices/res, introduce RESupdate_conduct()

which will be usefull later
This commit is contained in:
rlar 2017-09-30 22:44:22 +02:00
parent 0af576a7d8
commit 0a48e6f2a7
3 changed files with 33 additions and 26 deletions

View File

@ -281,9 +281,7 @@ DCtrCurv(CKTcircuit *ckt, int restart)
} else if (job->TRCVvType[i] == rcode) {
((RESinstance *)(job->TRCVvElt[i]))->RESresist =
job->TRCVvStart[i];
/* RESload() needs conductance as well */
((RESinstance *)(job->TRCVvElt[i]))->RESconduct =
1 / (((RESinstance *)(job->TRCVvElt[i]))->RESresist);
RESupdate_conduct((RESinstance *)(job->TRCVvElt[i]));
DEVices[rcode]->DEVload(job->TRCVvElt[i]->GENmodPtr, ckt);
}
@ -463,9 +461,7 @@ DCtrCurv(CKTcircuit *ckt, int restart)
} else if (job->TRCVvType[i] == rcode) { /* resistance */
((RESinstance*)(job->TRCVvElt[i]))->RESresist +=
job->TRCVvStep[i];
/* RESload() needs conductance as well */
((RESinstance*)(job->TRCVvElt[i]))->RESconduct =
1 / (((RESinstance*)(job->TRCVvElt[i]))->RESresist);
RESupdate_conduct((RESinstance *)(job->TRCVvElt[i]));
DEVices[rcode]->DEVload(job->TRCVvElt[i]->GENmodPtr, ckt);
} else if (job->TRCVvType[i] == TEMP_CODE) { /* temperature */
ckt->CKTtemp += job->TRCVvStep[i];
@ -499,10 +495,8 @@ DCtrCurv(CKTcircuit *ckt, int restart)
((ISRCinstance*)(job->TRCVvElt[i]))->ISRCdcGiven = (job->TRCVgSave[i] != 0);
} else if (job->TRCVvType[i] == rcode) { /* Resistance */
((RESinstance*)(job->TRCVvElt[i]))->RESresist = job->TRCVvSave[i];
/* RESload() needs conductance as well */
((RESinstance*)(job->TRCVvElt[i]))->RESconduct =
1 / (((RESinstance*)(job->TRCVvElt[i]))->RESresist);
((RESinstance*)(job->TRCVvElt[i]))->RESresGiven = (job->TRCVgSave[i] != 0);
RESupdate_conduct((RESinstance *)(job->TRCVvElt[i]));
DEVices[rcode]->DEVload(job->TRCVvElt[i]->GENmodPtr, ckt);
} else if (job->TRCVvType[i] == TEMP_CODE) {
ckt->CKTtemp = job->TRCVvSave[i];

View File

@ -187,4 +187,6 @@ typedef struct sRESmodel { /* model structure for a resistor */
#include "resext.h"
extern void RESupdate_conduct(RESinstance *);
#endif /*RES*/

View File

@ -21,9 +21,6 @@ REStemp(GENmodel *inModel, CKTcircuit *ckt)
{
RESmodel *model = (RESmodel *)inModel;
RESinstance *here;
double factor;
double difference;
double tc1, tc2, tce;
/* loop through all the resistor models */
@ -33,6 +30,34 @@ REStemp(GENmodel *inModel, CKTcircuit *ckt)
for (here = model->RESinstances; here != NULL ;
here=here->RESnextInstance) {
/* Default Value Processing for Resistor Instance */
if (!here->REStempGiven) {
here->REStemp = ckt->CKTtemp;
if (!here->RESdtempGiven)
here->RESdtemp = 0.0;
} else {
here->RESdtemp = 0.0;
if (here->RESdtempGiven)
printf("%s: Instance temperature specified, dtemp ignored\n", here->RESname);
}
RESupdate_conduct(here);
}
}
return OK;
}
void
RESupdate_conduct(RESinstance *here)
{
RESmodel *model = here->RESmodPtr;
double factor;
double difference;
double tc1, tc2, tce;
if (!here->RESresGiven) {
if (here->RESlength * here->RESwidth * model->RESsheetRes > 0.0) {
here->RESresist =
@ -48,17 +73,6 @@ REStemp(GENmodel *inModel, CKTcircuit *ckt)
}
}
/* Default Value Processing for Resistor Instance */
if(!here->REStempGiven) {
here->REStemp = ckt->CKTtemp;
if(!here->RESdtempGiven) here->RESdtemp = 0.0;
} else { /* REStempGiven */
here->RESdtemp = 0.0;
if (here->RESdtempGiven)
printf("%s: Instance temperature specified, dtemp ignored\n", here->RESname);
}
difference = (here->REStemp + here->RESdtemp) - model->REStnom;
/* instance parameters tc1,tc2 and tce will override
@ -92,7 +106,4 @@ REStemp(GENmodel *inModel, CKTcircuit *ckt)
here -> RESacConduct = here -> RESconduct;
here -> RESacResist = here -> RESresist;
}
}
}
return(OK);
}