From 0a48e6f2a7a0e62cc19432be4a39cf9f689529e5 Mon Sep 17 00:00:00 2001 From: rlar Date: Sat, 30 Sep 2017 22:44:22 +0200 Subject: [PATCH] devices/res, introduce RESupdate_conduct() which will be usefull later --- src/spicelib/analysis/dctrcurv.c | 12 ++------ src/spicelib/devices/res/resdefs.h | 2 ++ src/spicelib/devices/res/restemp.c | 45 +++++++++++++++++++----------- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/spicelib/analysis/dctrcurv.c b/src/spicelib/analysis/dctrcurv.c index a292360f5..66311b8a2 100644 --- a/src/spicelib/analysis/dctrcurv.c +++ b/src/spicelib/analysis/dctrcurv.c @@ -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]; diff --git a/src/spicelib/devices/res/resdefs.h b/src/spicelib/devices/res/resdefs.h index b024f6a61..b9b0c7d3f 100644 --- a/src/spicelib/devices/res/resdefs.h +++ b/src/spicelib/devices/res/resdefs.h @@ -187,4 +187,6 @@ typedef struct sRESmodel { /* model structure for a resistor */ #include "resext.h" +extern void RESupdate_conduct(RESinstance *); + #endif /*RES*/ diff --git a/src/spicelib/devices/res/restemp.c b/src/spicelib/devices/res/restemp.c index fc46a0a28..5c74fec36 100644 --- a/src/spicelib/devices/res/restemp.c +++ b/src/spicelib/devices/res/restemp.c @@ -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); }