JFETtemp

original_code:
int
JFETtemp(GENmodel *inModel, CKTcircuit *ckt)
{
    JFETmodel *model = (JFETmodel*)inModel;
    JFETinstance *here;
    double xfc;
    double vt;
    double vtnom;
    double kt,kt1;
    double arg,arg1;
    double fact1,fact2;
    double egfet,egfet1;
    double pbfact,pbfact1;
    double gmanew,gmaold;
    double ratio1;
    double pbo;
    double cjfact,cjfact1;
    for( ; model != ((void *)0); model = model->JFETnextModel ) {
        if(!(model->JFETtnomGiven)) {
            model->JFETtnom = ckt->CKTnomTemp;
        }
        vtnom = CONSTKoverQ * model->JFETtnom;
        fact1 = model->JFETtnom/300.15;
        kt1 = (1.3806226e-23) * model->JFETtnom;
        egfet1 = 1.16-(7.02e-4*model->JFETtnom*model->JFETtnom)/
                (model->JFETtnom+1108);
        arg1 = -egfet1/(kt1+kt1)+1.1150877/((1.3806226e-23)*(300.15 +300.15));
        pbfact1 = -2*vtnom * (1.5*log(fact1)+(1.6021918e-19)*arg1);
        pbo = (model->JFETgatePotential-pbfact1)/fact1;
        gmaold = (model->JFETgatePotential-pbo)/pbo;
        cjfact = 1/(1+.5*(4e-4*(model->JFETtnom-300.15)-gmaold));
        if(model->JFETdrainResist != 0) {
            model->JFETdrainConduct = 1/model->JFETdrainResist;
        } else {
            model->JFETdrainConduct = 0;
        }
        if(model->JFETsourceResist != 0) {
            model->JFETsourceConduct = 1/model->JFETsourceResist;
        } else {
            model->JFETsourceConduct = 0;
        }
        if(model->JFETdepletionCapCoeff >.95) {
            (*(SPfrontEnd->IFerror))(0x1,
                    "%s: Depletion cap. coefficient too large, limited to .95",
                    &(model->JFETmodName));
            model->JFETdepletionCapCoeff = .95;
        }
        xfc = log(1 - model->JFETdepletionCapCoeff);
        model->JFETf2 = exp((1+.5)*xfc);
        model->JFETf3 = 1 - model->JFETdepletionCapCoeff * (1 + .5);
 model->JFETbFac = (1 - model->JFETb)
  / (model->JFETgatePotential - model->JFETthreshold);
        for (here = model->JFETinstances; here != ((void *)0) ;
                here=here->JFETnextInstance) {
     if (here->JFETowner != ARCHme) continue;
            if(!(here->JFETdtempGiven)) {
                here->JFETdtemp = 0.0;
            }
            if(!(here->JFETtempGiven)) {
                here->JFETtemp = ckt->CKTtemp + here->JFETdtemp;
            }
            vt = here->JFETtemp * CONSTKoverQ;
            fact2 = here->JFETtemp/300.15;
            ratio1 = here->JFETtemp/model->JFETtnom -1;
            here->JFETtSatCur = model->JFETgateSatCurrent * exp(ratio1*1.11/vt);
            here->JFETtCGS = model->JFETcapGS * cjfact;
            here->JFETtCGD = model->JFETcapGD * cjfact;
            kt = (1.3806226e-23)*here->JFETtemp;
            egfet = 1.16-(7.02e-4*here->JFETtemp*here->JFETtemp)/
                    (here->JFETtemp+1108);
            arg = -egfet/(kt+kt) + 1.1150877/((1.3806226e-23)*(300.15 +300.15));
            pbfact = -2 * vt * (1.5*log(fact2)+(1.6021918e-19)*arg);
            here->JFETtGatePot = fact2 * pbo + pbfact;
            gmanew = (here->JFETtGatePot-pbo)/pbo;
            cjfact1 = 1+.5*(4e-4*(here->JFETtemp-300.15)-gmanew);
            here->JFETtCGS *= cjfact1;
            here->JFETtCGD *= cjfact1;
            here->JFETcorDepCap = model->JFETdepletionCapCoeff *
                    here->JFETtGatePot;
            here->JFETf1 = here->JFETtGatePot * (1 - exp((1-.5)*xfc))/(1-.5);
            here->JFETvcrit = vt * log(vt/(CONSTroot2 * here->JFETtSatCur));
        }
    }
    return(0);
}

canonical_original_code:
int JFETtemp(struct sGENmodel *inModel, struct CKTcircuit *ckt)
{
    struct sJFETmodel *model = (JFETmodel*)inModel;
    struct sJFETinstance *here;
    double xfc;
    double vt;
    double vtnom;
    double kt; double kt1;
    double arg; double arg1;
    double fact1; double fact2;
    double egfet; double egfet1;
    double pbfact; double pbfact1;
    double gmanew; double gmaold;
    double ratio1;
    double pbo;
    double cjfact; double cjfact1;
    for( ; model != ((void *)0); model = model->JFETnextModel ) {
        if(!(model->JFETtnomGiven)) {
            model->JFETtnom = ckt->CKTnomTemp;
        }
        vtnom = CONSTKoverQ * model->JFETtnom;
        fact1 = model->JFETtnom/300.15;
        kt1 = (1.3806226e-23) * model->JFETtnom;
        egfet1 = 1.16-(7.02e-4*model->JFETtnom*model->JFETtnom)/
                (model->JFETtnom+1108);
        arg1 = -egfet1/(kt1+kt1)+1.1150877/((1.3806226e-23)*(300.15 +300.15));
        pbfact1 = -2*vtnom * (1.5*log(fact1)+(1.6021918e-19)*arg1);
        pbo = (model->JFETgatePotential-pbfact1)/fact1;
        gmaold = (model->JFETgatePotential-pbo)/pbo;
        cjfact = 1/(1+.5*(4e-4*(model->JFETtnom-300.15)-gmaold));
        if(model->JFETdrainResist != 0) {
            model->JFETdrainConduct = 1/model->JFETdrainResist;
        } else {
            model->JFETdrainConduct = 0;
        }
        if(model->JFETsourceResist != 0) {
            model->JFETsourceConduct = 1/model->JFETsourceResist;
        } else {
            model->JFETsourceConduct = 0;
        }
        if(model->JFETdepletionCapCoeff >.95) {
            (*(SPfrontEnd->IFerror))(0x1,
                    "%s: Depletion cap. coefficient too large, limited to .95",
                    &(model->JFETmodName));
            model->JFETdepletionCapCoeff = .95;
        }
        xfc = log(1 - model->JFETdepletionCapCoeff);
        model->JFETf2 = exp((1+.5)*xfc);
        model->JFETf3 = 1 - model->JFETdepletionCapCoeff * (1 + .5);
 model->JFETbFac = (1 - model->JFETb)
  / (model->JFETgatePotential - model->JFETthreshold);
        for (here = model->JFETinstances; here != ((void *)0) ;
                here=here->JFETnextInstance) {
     if (here->JFETowner != ARCHme) continue;
            if(!(here->JFETdtempGiven)) {
                here->JFETdtemp = 0.0;
            }
            if(!(here->JFETtempGiven)) {
                here->JFETtemp = ckt->CKTtemp + here->JFETdtemp;
            }
            vt = here->JFETtemp * CONSTKoverQ;
            fact2 = here->JFETtemp/300.15;
            ratio1 = here->JFETtemp/model->JFETtnom -1;
            here->JFETtSatCur = model->JFETgateSatCurrent * exp(ratio1*1.11/vt);
            here->JFETtCGS = model->JFETcapGS * cjfact;
            here->JFETtCGD = model->JFETcapGD * cjfact;
            kt = (1.3806226e-23)*here->JFETtemp;
            egfet = 1.16-(7.02e-4*here->JFETtemp*here->JFETtemp)/
                    (here->JFETtemp+1108);
            arg = -egfet/(kt+kt) + 1.1150877/((1.3806226e-23)*(300.15 +300.15));
            pbfact = -2 * vt * (1.5*log(fact2)+(1.6021918e-19)*arg);
            here->JFETtGatePot = fact2 * pbo + pbfact;
            gmanew = (here->JFETtGatePot-pbo)/pbo;
            cjfact1 = 1+.5*(4e-4*(here->JFETtemp-300.15)-gmanew);
            here->JFETtCGS *= cjfact1;
            here->JFETtCGD *= cjfact1;
            here->JFETcorDepCap = model->JFETdepletionCapCoeff *
                    here->JFETtGatePot;
            here->JFETf1 = here->JFETtGatePot * (1 - exp((1-.5)*xfc))/(1-.5);
            here->JFETvcrit = vt * log(vt/(CONSTroot2 * here->JFETtSatCur));
        }
    }
    return(0);
}

variable_types: struct sJFETmodel { int JFETmodType; struct sJFETmodel *JFETnextModel; struct sJFETinstance { struct sJFETmodel *JFETmodPtr; struct sJFETinstance *JFETnextInstance; char *JFETname; int JFETowner; int JFETstate; int JFETdrainNode; int JFETgateNode; int JFETsourceNode; int JFETdrainPrimeNode; int JFETsourcePrimeNode; double *JFETdrainDrainPrimePtr; double *JFETgateDrainPrimePtr; double *JFETgateSourcePrimePtr; double *JFETsourceSourcePrimePtr; double *JFETdrainPrimeDrainPtr; double *JFETdrainPrimeGatePtr; double *JFETdrainPrimeSourcePrimePtr; double *JFETsourcePrimeGatePtr; double *JFETsourcePrimeSourcePtr; double *JFETsourcePrimeDrainPrimePtr; double *JFETdrainDrainPtr; double *JFETgateGatePtr; double *JFETsourceSourcePtr; double *JFETdrainPrimeDrainPrimePtr; double *JFETsourcePrimeSourcePrimePtr; int JFETmode; double JFETdCoeffs[21]; double JFETnVar[3][5]; unsigned int JFEToff; unsigned int JFETareaGiven; unsigned int JFETmGiven; unsigned int JFETicVDSGiven; unsigned int JFETicVGSGiven; unsigned int JFETtempGiven; unsigned int JFETdtempGiven; double JFETarea; double JFETm; double JFETicVDS; double JFETicVGS; double JFETtemp; double JFETdtemp; double JFETtSatCur; double JFETtGatePot; double JFETtCGS; double JFETtCGD; double JFETcorDepCap; double JFETvcrit; double JFETf1; } *JFETinstances; char *JFETmodName; int JFETtype; double JFETthreshold; double JFETbeta; double JFETlModulation; double JFETdrainResist; double JFETsourceResist; double JFETcapGS; double JFETcapGD; double JFETgatePotential; double JFETgateSatCurrent; double JFETdepletionCapCoeff; double JFETfNcoef; double JFETfNexp; double JFETdrainConduct; double JFETsourceConduct; double JFETf2; double JFETf3; double JFETb; double JFETbFac; double JFETtnom; unsigned int JFETthresholdGiven; unsigned int JFETbetaGiven; unsigned int JFETlModulationGiven; unsigned int JFETdrainResistGiven; unsigned int JFETsourceResistGiven; unsigned int JFETcapGSGiven; unsigned int JFETcapGDGiven; unsigned int JFETgatePotentialGiven; unsigned int JFETgateSatCurrentGiven; unsigned int JFETdepletionCapCoeffGiven; unsigned int JFETbGiven; unsigned int JFETtnomGiven; unsigned int JFETfNcoefGiven; unsigned int JFETfNexpGiven; } *

variable_types: struct sJFETinstance { struct sJFETmodel { int JFETmodType; struct sJFETmodel *JFETnextModel; struct sJFETinstance *JFETinstances; char *JFETmodName; int JFETtype; double JFETthreshold; double JFETbeta; double JFETlModulation; double JFETdrainResist; double JFETsourceResist; double JFETcapGS; double JFETcapGD; double JFETgatePotential; double JFETgateSatCurrent; double JFETdepletionCapCoeff; double JFETfNcoef; double JFETfNexp; double JFETdrainConduct; double JFETsourceConduct; double JFETf2; double JFETf3; double JFETb; double JFETbFac; double JFETtnom; unsigned int JFETthresholdGiven; unsigned int JFETbetaGiven; unsigned int JFETlModulationGiven; unsigned int JFETdrainResistGiven; unsigned int JFETsourceResistGiven; unsigned int JFETcapGSGiven; unsigned int JFETcapGDGiven; unsigned int JFETgatePotentialGiven; unsigned int JFETgateSatCurrentGiven; unsigned int JFETdepletionCapCoeffGiven; unsigned int JFETbGiven; unsigned int JFETtnomGiven; unsigned int JFETfNcoefGiven; unsigned int JFETfNexpGiven; } *JFETmodPtr; struct sJFETinstance *JFETnextInstance; char *JFETname; int JFETowner; int JFETstate; int JFETdrainNode; int JFETgateNode; int JFETsourceNode; int JFETdrainPrimeNode; int JFETsourcePrimeNode; double *JFETdrainDrainPrimePtr; double *JFETgateDrainPrimePtr; double *JFETgateSourcePrimePtr; double *JFETsourceSourcePrimePtr; double *JFETdrainPrimeDrainPtr; double *JFETdrainPrimeGatePtr; double *JFETdrainPrimeSourcePrimePtr; double *JFETsourcePrimeGatePtr; double *JFETsourcePrimeSourcePtr; double *JFETsourcePrimeDrainPrimePtr; double *JFETdrainDrainPtr; double *JFETgateGatePtr; double *JFETsourceSourcePtr; double *JFETdrainPrimeDrainPrimePtr; double *JFETsourcePrimeSourcePrimePtr; int JFETmode; double JFETdCoeffs[21]; double JFETnVar[3][5]; unsigned int JFEToff; unsigned int JFETareaGiven; unsigned int JFETmGiven; unsigned int JFETicVDSGiven; unsigned int JFETicVGSGiven; unsigned int JFETtempGiven; unsigned int JFETdtempGiven; double JFETarea; double JFETm; double JFETicVDS; double JFETicVGS; double JFETtemp; double JFETdtemp; double JFETtSatCur; double JFETtGatePot; double JFETtCGS; double JFETtCGD; double JFETcorDepCap; double JFETvcrit; double JFETf1; } *

variable_types: xfc double

variable_types: vt double

variable_types: vtnom double

variable_types: kt double

variable_types: arg double

variable_types: egfet double

variable_types: pbfact double

variable_types: gmanew double

variable_types: gmaold double

variable_types: pbo double

variable_types: cjfact double


CAPacLoad

repo: gserdyuk/gnucap-a

original_code:
int
CAPacLoad(GENmodel *inModel, CKTcircuit *ckt)
{
    CAPmodel *model = (CAPmodel*)inModel;
    double val;
    double m;
    CAPinstance *here;
    for( ; model != ((void *)0); model = model->CAPnextModel) {
        for( here = model->CAPinstances;here != ((void *)0);
                here = here->CAPnextInstance) {
     if (here->CAPowner != ARCHme) continue;
     m = here -> CAPm;
            val = ckt->CKTomega * here->CAPcapac;
            *(here->CAPposPosptr +1) += m * val;
            *(here->CAPnegNegptr +1) += m * val;
            *(here->CAPposNegptr +1) -= m * val;
            *(here->CAPnegPosptr +1) -= m * val;
        }
    }
    return(0);
}

canonical_original_code:
int CAPacLoad(struct sGENmodel *inModel, struct CKTcircuit *ckt)
{
    struct sCAPmodel *model = (CAPmodel*)inModel;
    double val;
    double m;
    struct sCAPinstance *here;
    for( ; model != ((void *)0); model = model->CAPnextModel) {
        for( here = model->CAPinstances;here != ((void *)0);
                here = here->CAPnextInstance) {
     if (here->CAPowner != ARCHme) continue;
     m = here -> CAPm;
            val = ckt->CKTomega * here->CAPcapac;
            *(here->CAPposPosptr +1) += m * val;
            *(here->CAPnegNegptr +1) += m * val;
            *(here->CAPposNegptr +1) -= m * val;
            *(here->CAPnegPosptr +1) -= m * val;
        }
    }
    return(0);
}

variable_types: struct sGENmodel { int GENmodType; struct sGENmodel *GENnextModel; struct sGENinstance { struct sGENmodel *GENmodPtr; struct sGENinstance *GENnextInstance; char *GENname; int GENowner; int GENstate; int GENnode1; int GENnode2; int GENnode3; int GENnode4; int GENnode5; int GENnode6; int GENnode7; } *GENinstances; char *GENmodName; } *

variable_types: struct CKTcircuit { struct sGENmodel **CKThead; struct STATistics { int STATnumIter; int STATtranIter; int STAToldIter; int STATtimePts; int STATaccepted; int STATrejected; double STATtotAnalTime; double STATloadTime; double STATdecompTime; double STATsolveTime; double STATreorderTime; double STATcombineTime; double STATsyncTime; double STATtranTime; double STATtranDecompTime; double STATtranSolveTime; double STATtranLoadTime; double STATtranTruncTime; double STATtranCombTime; double STATtranSyncTime; double STATacTime; double STATacDecompTime; double STATacSolveTime; double STATacLoadTime; double STATacCombTime; double STATacSyncTime; } *CKTstat; double *CKTstates[8]; double CKTtime; double CKTdelta; double CKTdeltaOld[7]; double CKTtemp; double CKTnomTemp; double CKTvt; double CKTag[7]; double CKTagp[7]; int CKTorder; int CKTmaxOrder; int CKTintegrateMethod; void *CKTmatrix; int CKTniState; double *CKTrhs; double *CKTrhsOld; double *CKTrhsSpare; double *CKTirhs; double *CKTirhsOld; double *CKTirhsSpare; double *CKTpred; double *CKTsols[8]; double *CKTrhsOp; double *CKTsenRhs; double *CKTseniRhs; int CKTmaxEqNum; int CKTcurrentAnalysis; struct sCKTnode { char *name; int type; int number; double ic; double nodeset; double *ptr; struct sCKTnode *next; unsigned int icGiven; unsigned int nsGiven; } *CKTnodes; struct sCKTnode *CKTlastNode; int CKTnumStates; long CKTmode; int CKTbypass; int CKTdcMaxIter; int CKTdcTrcvMaxIter; int CKTtranMaxIter; int CKTbreakSize; int CKTbreak; double CKTsaveDelta; double CKTminBreak; double *CKTbreaks; double CKTabstol; double CKTpivotAbsTol; double CKTpivotRelTol; double CKTreltol; double CKTchgtol; double CKTvoltTol; double CKTgmin; double CKTgshunt; double CKTdelmin; double CKTtrtol; double CKTfinalTime; double CKTstep; double CKTmaxStep; double CKTinitTime; double CKTomega; double CKTsrcFact; double CKTdiagGmin; int CKTnumSrcSteps; int CKTnumGminSteps; double CKTgminFactor; int CKTnoncon; double CKTdefaultMosM; double CKTdefaultMosL; double CKTdefaultMosW; double CKTdefaultMosAD; double CKTdefaultMosAS; unsigned int CKThadNodeset; unsigned int CKTfixLimit; unsigned int CKTnoOpIter; unsigned int CKTisSetup; struct sJOB { int JOBtype; struct sJOB *JOBnextJob; char *JOBname; } *CKTcurJob; struct SENstruct { int JOBtype; struct sJOB *JOBnextJob; char *JOBname; int SENnumVal; char **SENdevices; char **SENparmNames; unsigned int SENinitflag; unsigned int SENicflag; unsigned int SENstatus; unsigned int SENacpertflag; int SENmode; int SENparms; double SENpertfac; double **SEN_Sap; double **SEN_RHS; double **SEN_iRHS; int SENsize; void *SEN_Jacmat; double *SEN_parmVal; char **SEN_parmName; } *CKTsenInfo; double *CKTtimePoints; double *CKTdeltaList; int CKTtimeListSize; int CKTtimeIndex; int CKTsizeIncr; unsigned int CKTtryToCompact; unsigned int CKTbadMos3; unsigned int CKTkeepOpInfo; unsigned int CKTcopyNodesets; unsigned int CKTnodeDamping; double CKTabsDv; double CKTrelDv; int CKTtroubleNode; struct sGENinstance *CKTtroubleElt; } *

variable_types: struct sCAPmodel { int CAPmodType; struct sCAPmodel *CAPnextModel; struct sCAPinstance { struct sCAPmodel *CAPmodPtr; struct sCAPinstance *CAPnextInstance; char *CAPname; int CAPowner; int CAPstate; int CAPposNode; int CAPnegNode; double CAPtemp; double CAPdtemp; double CAPcapac; double CAPinitCond; double CAPwidth; double CAPlength; double CAPscale; double CAPm; double *CAPposPosptr; double *CAPnegNegptr; double *CAPposNegptr; double *CAPnegPosptr; unsigned int CAPcapGiven; unsigned int CAPicGiven; unsigned int CAPwidthGiven; unsigned int CAPlengthGiven; unsigned int CAPtempGiven; unsigned int CAPdtempGiven; unsigned int CAPscaleGiven; unsigned int CAPmGiven; int CAPsenParmNo; } *CAPinstances; char *CAPmodName; double CAPtnom; double CAPtempCoeff1; double CAPtempCoeff2; double CAPmCap; double CAPcj; double CAPcjsw; double CAPdefWidth; double CAPdefLength; double CAPnarrow; double CAPshort; double CAPdi; double CAPthick; unsigned int CAPmCapGiven; unsigned int CAPcjGiven; unsigned int CAPcjswGiven; unsigned int CAPdefWidthGiven; unsigned int CAPdefLengthGiven; unsigned int CAPnarrowGiven; unsigned int CAPshortGiven; unsigned int CAPtnomGiven; unsigned int CAPtc1Given; unsigned int CAPtc2Given; unsigned int CAPdiGiven; unsigned int CAPthickGiven; } *

variable_types: val double

variable_types: m double

variable_types: struct sCAPinstance { struct sCAPmodel { int CAPmodType; struct sCAPmodel *CAPnextModel; struct sCAPinstance *CAPinstances; char *CAPmodName; double CAPtnom; double CAPtempCoeff1; double CAPtempCoeff2; double CAPmCap; double CAPcj; double CAPcjsw; double CAPdefWidth; double CAPdefLength; double CAPnarrow; double CAPshort; double CAPdi; double CAPthick; unsigned int CAPmCapGiven; unsigned int CAPcjGiven; unsigned int CAPcjswGiven; unsigned int CAPdefWidthGiven; unsigned int CAPdefLengthGiven; unsigned int CAPnarrowGiven; unsigned int CAPshortGiven; unsigned int CAPtnomGiven; unsigned int CAPtc1Given; unsigned int CAPtc2Given; unsigned int CAPdiGiven; unsigned int CAPthickGiven; } *CAPmodPtr; struct sCAPinstance *CAPnextInstance; char *CAPname; int CAPowner; int CAPstate; int CAPposNode; int CAPnegNode; double CAPtemp; double CAPdtemp; double CAPcapac; double CAPinitCond; double CAPwidth; double CAPlength; double CAPscale; double CAPm; double *CAPposPosptr; double *CAPnegNegptr; double *CAPposNegptr; double *CAPnegPosptr; unsigned int CAPcapGiven; unsigned int CAPicGiven; unsigned int CAPwidthGiven; unsigned int CAPlengthGiven; unsigned int CAPtempGiven; unsigned int CAPdtempGiven; unsigned int CAPscaleGiven; unsigned int CAPmGiven; int CAPsenParmNo; } *

return_type: int

user_defined_types: struct sGENmodel { int GENmodType; struct sGENmodel *GENnextModel; struct sGENinstance *GENinstances; char *GENmodName; }

user_defined_types: struct CKTcircuit { struct sGENmodel **CKThead; struct STATistics *CKTstat; double *CKTstates[8]; double CKTtime; double CKTdelta; double CKTdeltaOld[7]; double CKTtemp; double CKTnomTemp; double CKTvt; double CKTag[7]; double CKTagp[7]; int CKTorder; int CKTmaxOrder; int CKTintegrateMethod; void *CKTmatrix; int CKTniState; double *CKTrhs; double *CKTrhsOld; double *CKTrhsSpare; double *CKTirhs; double *CKTirhsOld; double *CKTirhsSpare; double *CKTpred; double *CKTsols[8]; double *CKTrhsOp; double *CKTsenRhs; double *CKTseniRhs; int CKTmaxEqNum; int CKTcurrentAnalysis; struct sCKTnode *CKTnodes; struct sCKTnode *CKTlastNode; int CKTnumStates; long CKTmode; int CKTbypass; int CKTdcMaxIter; int CKTdcTrcvMaxIter; int CKTtranMaxIter; int CKTbreakSize; int CKTbreak; double CKTsaveDelta; double CKTminBreak; double *CKTbreaks; double CKTabstol; double CKTpivotAbsTol; double CKTpivotRelTol; double CKTreltol; double CKTchgtol; double CKTvoltTol; double CKTgmin; double CKTgshunt; double CKTdelmin; double CKTtrtol; double CKTfinalTime; double CKTstep; double CKTmaxStep; double CKTinitTime; double CKTomega; double CKTsrcFact; double CKTdiagGmin; int CKTnumSrcSteps; int CKTnumGminSteps; double CKTgminFactor; int CKTnoncon; double CKTdefaultMosM; double CKTdefaultMosL; double CKTdefaultMosW; double CKTdefaultMosAD; double CKTdefaultMosAS; unsigned int CKThadNodeset; unsigned int CKTfixLimit; unsigned int CKTnoOpIter; unsigned int CKTisSetup; struct sJOB *CKTcurJob; struct SENstruct *CKTsenInfo; double *CKTtimePoints; double *CKTdeltaList; int CKTtimeListSize; int CKTtimeIndex; int CKTsizeIncr; unsigned int CKTtryToCompact; unsigned int CKTbadMos3; unsigned int CKTkeepOpInfo; unsigned int CKTcopyNodesets; unsigned int CKTnodeDamping; double CKTabsDv; double CKTrelDv; int CKTtroubleNode; struct sGENinstance *CKTtroubleElt; }


SWacLoad

original_code:
int
SWacLoad(GENmodel *inModel, CKTcircuit *ckt)
{
    SWmodel *model = (SWmodel *)inModel;
    SWinstance *here;
    double g_now;
    int current_state;
    for( ; model != ((void *)0); model = model->SWnextModel ) {
        for (here = model->SWinstances; here != ((void *)0) ;
                here=here->SWnextInstance) {
     if (here->SWowner != ARCHme) continue;
            current_state = (int)*(ckt->CKTstates[0] + here->SWstate);
            g_now = current_state?(model->SWonConduct):(model->SWoffConduct);
            *(here->SWposPosptr) += g_now;
            *(here->SWposNegptr) -= g_now;
            *(here->SWnegPosptr) -= g_now;
            *(here->SWnegNegptr) += g_now;
        }
    }
    return(0);
}

canonical_original_code:
int SWacLoad(struct sGENmodel *inModel, struct CKTcircuit *ckt)
{
    struct sSWmodel *model = (SWmodel *)inModel;
    struct sSWinstance *here;
    double g_now;
    int current_state;
    for( ; model != ((void *)0); model = model->SWnextModel ) {
        for (here = model->SWinstances; here != ((void *)0) ;
                here=here->SWnextInstance) {
     if (here->SWowner != ARCHme) continue;
            current_state = (int)*(ckt->CKTstates[0] + here->SWstate);
            g_now = current_state?(model->SWonConduct):(model->SWoffConduct);
            *(here->SWposPosptr) += g_now;
            *(here->SWposNegptr) -= g_now;
            *(here->SWnegPosptr) -= g_now;
            *(here->SWnegNegptr) += g_now;
        }
    }
    return(0);
}

variable_types: struct sSWmodel { int SWmodType; struct sSWmodel *SWnextModel; struct sSWinstance { struct sSWmodel *SWmodPtr; struct sSWinstance *SWnextInstance; char *SWname; int SWowner; int SWstate; int SWposNode; int SWnegNode; int SWposCntrlNode; int SWnegCntrlNode; double *SWposPosptr; double *SWnegPosptr; double *SWposNegptr; double *SWnegNegptr; double SWcond; unsigned int SWzero_stateGiven; double SWnVar[3]; } *SWinstances; char *SWmodName; double SWonResistance; double SWoffResistance; double SWvThreshold; double SWvHysteresis; double SWonConduct; double SWoffConduct; unsigned int SWonGiven; unsigned int SWoffGiven; unsigned int SWthreshGiven; unsigned int SWhystGiven; } *

variable_types: struct sSWinstance { struct sSWmodel { int SWmodType; struct sSWmodel *SWnextModel; struct sSWinstance *SWinstances; char *SWmodName; double SWonResistance; double SWoffResistance; double SWvThreshold; double SWvHysteresis; double SWonConduct; double SWoffConduct; unsigned int SWonGiven; unsigned int SWoffGiven; unsigned int SWthreshGiven; unsigned int SWhystGiven; } *SWmodPtr; struct sSWinstance *SWnextInstance; char *SWname; int SWowner; int SWstate; int SWposNode; int SWnegNode; int SWposCntrlNode; int SWnegCntrlNode; double *SWposPosptr; double *SWnegPosptr; double *SWposNegptr; double *SWnegNegptr; double SWcond; unsigned int SWzero_stateGiven; double SWnVar[3]; } *

user_defined_types: struct sGENinstance { struct sGENmodel *GENmodPtr; struct sGENinstance *GENnextInstance; char *GENname; int GENowner; int GENstate; int GENnode1; int GENnode2; int GENnode3; int GENnode4; int GENnode5; int GENnode6; int GENnode7; }

user_defined_types: struct STATistics { int STATnumIter; int STATtranIter; int STAToldIter; int STATtimePts; int STATaccepted; int STATrejected; double STATtotAnalTime; double STATloadTime; double STATdecompTime; double STATsolveTime; double STATreorderTime; double STATcombineTime; double STATsyncTime; double STATtranTime; double STATtranDecompTime; double STATtranSolveTime; double STATtranLoadTime; double STATtranTruncTime; double STATtranCombTime; double STATtranSyncTime; double STATacTime; double STATacDecompTime; double STATacSolveTime; double STATacLoadTime; double STATacCombTime; double STATacSyncTime; }

user_defined_types: struct sCKTnode { char *name; int type; int number; double ic; double nodeset; double *ptr; struct sCKTnode *next; unsigned int icGiven; unsigned int nsGiven; }

user_defined_types: struct sJOB { int JOBtype; struct sJOB *JOBnextJob; char *JOBname; }

user_defined_types: struct SENstruct { int JOBtype; struct sJOB *JOBnextJob; char *JOBname; int SENnumVal; char **SENdevices; char **SENparmNames; unsigned int SENinitflag; unsigned int SENicflag; unsigned int SENstatus; unsigned int SENacpertflag; int SENmode; int SENparms; double SENpertfac; double **SEN_Sap; double **SEN_RHS; double **SEN_iRHS; int SENsize; void *SEN_Jacmat; double *SEN_parmVal; char **SEN_parmName; }


LTRAtrunc

original_code:
int
LTRAtrunc(GENmodel *inModel, CKTcircuit *ckt, double *timeStep)
{
  LTRAmodel *model = (LTRAmodel *) inModel;
  LTRAinstance *here;
  double i1, i2, i3, i4;
  double i5, i6, d1, d2, d3, d4;
  double tmp;
  double tolerance;
  double current_lte;
  int maxiter = 2, iterations = 0;
  double x, y, change, deriv, deriv_delta;
  for (; model != ((void *)0); model = model->LTRAnextModel) {
    for (here = model->LTRAinstances; here != ((void *)0);
 here = here->LTRAnextInstance) {
      if (here->LTRAowner != ARCHme) continue;
      switch (model->LTRAspecialCase) {
      case 40:
      case 37:
 if (model->LTRAstepLimit == 32) {
   tmp = model->LTRAtd;
   *timeStep = ((*timeStep) < (tmp) ? (*timeStep) : (tmp));
 } else {
   i1 = ((*(ckt->CKTrhsOld + here->LTRAposNode2)
    - *(ckt->CKTrhsOld + here->LTRAnegNode2))
       * model->LTRAadmit + *(ckt->CKTrhsOld + here->LTRAbrEq2))
       * model->LTRAattenuation;
   i2 = (*(here->LTRAv2 + ckt->CKTtimeIndex) *
       model->LTRAadmit + *(here->LTRAi2 + ckt->CKTtimeIndex))
       * model->LTRAattenuation;
   i3 = (*(here->LTRAv2 + ckt->CKTtimeIndex - 1) * model->LTRAadmit +
       *(here->LTRAi2 + ckt->CKTtimeIndex - 1))
       * model->LTRAattenuation;
   i4 = ((*(ckt->CKTrhsOld + here->LTRAposNode1) -
    *(ckt->CKTrhsOld + here->LTRAnegNode1))
       * model->LTRAadmit + *(ckt->CKTrhsOld + here->LTRAbrEq1))
       * model->LTRAattenuation;
   i5 = (*(here->LTRAv1 + ckt->CKTtimeIndex) * model->LTRAadmit +
       *(here->LTRAi1 + ckt->CKTtimeIndex))
       * model->LTRAattenuation;
   i6 = (*(here->LTRAv1 + ckt->CKTtimeIndex - 1) * model->LTRAadmit +
       *(here->LTRAi1 + ckt->CKTtimeIndex - 1))
       * model->LTRAattenuation;
   d1 = (i1 - i2) / (ckt->CKTtime - *(ckt->CKTtimePoints +
    ckt->CKTtimeIndex));
   d2 = (i2 - i3) / (*(ckt->CKTtimePoints + ckt->CKTtimeIndex)
       - *(ckt->CKTtimePoints + ckt->CKTtimeIndex - 1));
   d3 = (i4 - i5) / (ckt->CKTtime - *(ckt->CKTtimePoints +
    ckt->CKTtimeIndex));
   d4 = (i5 - i6) / (*(ckt->CKTtimePoints + ckt->CKTtimeIndex)
       - *(ckt->CKTtimePoints + ckt->CKTtimeIndex - 1));
   if ((fabs(d1 - d2) >= model->LTRAreltol * ((fabs(d1)) > (fabs(d2)) ? (fabs(d1)) : (fabs(d2))) +
    model->LTRAabstol) ||
       (fabs(d3 - d4) >= model->LTRAreltol * ((fabs(d3)) > (fabs(d4)) ? (fabs(d3)) : (fabs(d4))) +
    model->LTRAabstol)) {
     tmp = model->LTRAtd;
     *timeStep = ((*timeStep) < (tmp) ? (*timeStep) : (tmp));
   }
 }
 break;
      case 38:
      case 39:
 break;
      default:
 return (7);
      }
      if ((model->LTRAspecialCase == 37) &&
   (!model->LTRAtruncDontCut)) {
 *timeStep = ((*timeStep) < (model->LTRAmaxSafeStep) ? (*timeStep) : (model->LTRAmaxSafeStep));
      }
      if (model->LTRAlteConType != 28) {
 switch (model->LTRAspecialCase) {
 case 37:
 case 38:
   tolerance = ckt->CKTtrtol * (ckt->CKTreltol * (
    fabs(here->LTRAinput1) + fabs(here->LTRAinput2))
       + ckt->CKTabstol);
   current_lte = LTRAlteCalculate(ckt, (GENmodel *) model,
       (GENinstance *) here, ckt->CKTtime);
   if (current_lte >= tolerance) {
     if (model->LTRAtruncNR) {
       x = ckt->CKTtime;
       y = current_lte;
       while (1) {
  deriv_delta = 0.01 * (x - *(ckt->CKTtimePoints +
   ckt->CKTtimeIndex));
  deriv = LTRAlteCalculate(ckt, (GENmodel *) model,
      (GENinstance *) here,
      x + deriv_delta) - y;
  deriv /= deriv_delta;
  change = (tolerance - y) / deriv;
  x += change;
  if (maxiter == 0) {
    if (fabs(change) <= fabs(deriv_delta))
      break;
  } else {
    iterations++;
    if (iterations >= maxiter)
      break;
  }
  y = LTRAlteCalculate(ckt, (GENmodel *) model,
      (GENinstance *) here, x);
       }
       tmp = x - *(ckt->CKTtimePoints + ckt->CKTtimeIndex);
       *timeStep = ((*timeStep) < (tmp) ? (*timeStep) : (tmp));
     } else
       *timeStep *= 0.5;
   }
   break;
 case 39:
 case 40:
   break;
 default:
   return (7);
 }
      }
    }
  }
  return (0);
}

canonical_original_code:
int LTRAtrunc(struct sGENmodel *inModel, struct CKTcircuit *ckt, double *timeStep)
{
  struct sLTRAmodel *model = (LTRAmodel *) inModel;
  struct sLTRAinstance *here;
  double i1; double i2; double i3; double i4;
  double i5; double i6; double d1; double d2; double d3; double d4;
  double tmp;
  double tolerance;
  double current_lte;
  int maxiter = 2; int iterations = 0;
  double x; double y; double change; double deriv; double deriv_delta;
  for (; model != ((void *)0); model = model->LTRAnextModel) {
    for (here = model->LTRAinstances; here != ((void *)0);
 here = here->LTRAnextInstance) {
      if (here->LTRAowner != ARCHme) continue;
      switch (model->LTRAspecialCase) {
      case 40:
      case 37:
 if (model->LTRAstepLimit == 32) {
   tmp = model->LTRAtd;
   *timeStep = ((*timeStep) < (tmp) ? (*timeStep) : (tmp));
 } else {
   i1 = ((*(ckt->CKTrhsOld + here->LTRAposNode2)
    - *(ckt->CKTrhsOld + here->LTRAnegNode2))
       * model->LTRAadmit + *(ckt->CKTrhsOld + here->LTRAbrEq2))
       * model->LTRAattenuation;
   i2 = (*(here->LTRAv2 + ckt->CKTtimeIndex) *
       model->LTRAadmit + *(here->LTRAi2 + ckt->CKTtimeIndex))
       * model->LTRAattenuation;
   i3 = (*(here->LTRAv2 + ckt->CKTtimeIndex - 1) * model->LTRAadmit +
       *(here->LTRAi2 + ckt->CKTtimeIndex - 1))
       * model->LTRAattenuation;
   i4 = ((*(ckt->CKTrhsOld + here->LTRAposNode1) -
    *(ckt->CKTrhsOld + here->LTRAnegNode1))
       * model->LTRAadmit + *(ckt->CKTrhsOld + here->LTRAbrEq1))
       * model->LTRAattenuation;
   i5 = (*(here->LTRAv1 + ckt->CKTtimeIndex) * model->LTRAadmit +
       *(here->LTRAi1 + ckt->CKTtimeIndex))
       * model->LTRAattenuation;
   i6 = (*(here->LTRAv1 + ckt->CKTtimeIndex - 1) * model->LTRAadmit +
       *(here->LTRAi1 + ckt->CKTtimeIndex - 1))
       * model->LTRAattenuation;
   d1 = (i1 - i2) / (ckt->CKTtime - *(ckt->CKTtimePoints +
    ckt->CKTtimeIndex));
   d2 = (i2 - i3) / (*(ckt->CKTtimePoints + ckt->CKTtimeIndex)
       - *(ckt->CKTtimePoints + ckt->CKTtimeIndex - 1));
   d3 = (i4 - i5) / (ckt->CKTtime - *(ckt->CKTtimePoints +
    ckt->CKTtimeIndex));
   d4 = (i5 - i6) / (*(ckt->CKTtimePoints + ckt->CKTtimeIndex)
       - *(ckt->CKTtimePoints + ckt->CKTtimeIndex - 1));
   if ((fabs(d1 - d2) >= model->LTRAreltol * ((fabs(d1)) > (fabs(d2)) ? (fabs(d1)) : (fabs(d2))) +
    model->LTRAabstol) ||
       (fabs(d3 - d4) >= model->LTRAreltol * ((fabs(d3)) > (fabs(d4)) ? (fabs(d3)) : (fabs(d4))) +
    model->LTRAabstol)) {
     tmp = model->LTRAtd;
     *timeStep = ((*timeStep) < (tmp) ? (*timeStep) : (tmp));
   }
 }
 break;
      case 38:
      case 39:
 break;
      default:
 return (7);
      }
      if ((model->LTRAspecialCase == 37) &&
   (!model->LTRAtruncDontCut)) {
 *timeStep = ((*timeStep) < (model->LTRAmaxSafeStep) ? (*timeStep) : (model->LTRAmaxSafeStep));
      }
      if (model->LTRAlteConType != 28) {
 switch (model->LTRAspecialCase) {
 case 37:
 case 38:
   tolerance = ckt->CKTtrtol * (ckt->CKTreltol * (
    fabs(here->LTRAinput1) + fabs(here->LTRAinput2))
       + ckt->CKTabstol);
   current_lte = LTRAlteCalculate(ckt, (struct sGENmodel *) model,
       (struct sGENinstance *) here, ckt->CKTtime);
   if (current_lte >= tolerance) {
     if (model->LTRAtruncNR) {
       x = ckt->CKTtime;
       y = current_lte;
       while (1) {
  deriv_delta = 0.01 * (x - *(ckt->CKTtimePoints +
   ckt->CKTtimeIndex));
  deriv = LTRAlteCalculate(ckt, (struct sGENmodel *) model,
      (struct sGENinstance *) here,
      x + deriv_delta) - y;
  deriv /= deriv_delta;
  change = (tolerance - y) / deriv;
  x += change;
  if (maxiter == 0) {
    if (fabs(change) <= fabs(deriv_delta))
      break;
  } else {
    iterations++;
    if (iterations >= maxiter)
      break;
  }
  y = LTRAlteCalculate(ckt, (struct sGENmodel *) model,
      (struct sGENinstance *) here, x);
       }
       tmp = x - *(ckt->CKTtimePoints + ckt->CKTtimeIndex);
       *timeStep = ((*timeStep) < (tmp) ? (*timeStep) : (tmp));
     } else
       *timeStep *= 0.5;
   }
   break;
 case 39:
 case 40:
   break;
 default:
   return (7);
 }
      }
    }
  }
  return (0);
}

variable_types:
timeStep
double *

variable_types: struct sLTRAmodel { int LTRAmodType; struct sLTRAmodel *LTRAnextModel; struct sLTRAinstance { struct sLTRAmodel *LTRAmodPtr; struct sLTRAinstance *LTRAnextInstance; char *LTRAname; int LTRAowner; int LTRAstate; int LTRAposNode1; int LTRAnegNode1; int LTRAposNode2; int LTRAnegNode2; int LTRAbrEq1; int LTRAbrEq2; double LTRAinput1; double LTRAinput2; double LTRAinitVolt1; double LTRAinitCur1; double LTRAinitVolt2; double LTRAinitCur2; double *LTRAv1; double *LTRAi1; double *LTRAv2; double *LTRAi2; int LTRAinstListSize; double *LTRAibr1Ibr1Ptr; double *LTRAibr1Ibr2Ptr; double *LTRAibr1Pos1Ptr; double *LTRAibr1Neg1Ptr; double *LTRAibr1Pos2Ptr; double *LTRAibr1Neg2Ptr; double *LTRAibr2Ibr1Ptr; double *LTRAibr2Ibr2Ptr; double *LTRAibr2Pos1Ptr; double *LTRAibr2Neg1Ptr; double *LTRAibr2Pos2Ptr; double *LTRAibr2Neg2Ptr; double *LTRAneg1Ibr1Ptr; double *LTRAneg2Ibr2Ptr; double *LTRApos1Ibr1Ptr; double *LTRApos2Ibr2Ptr; double *LTRApos1Pos1Ptr; double *LTRAneg1Neg1Ptr; double *LTRApos2Pos2Ptr; double *LTRAneg2Neg2Ptr; unsigned int LTRAicV1Given; unsigned int LTRAicC1Given; unsigned int LTRAicV2Given; unsigned int LTRAicC2Given; } *LTRAinstances; char *LTRAmodName; double LTRAh1dashFirstVal; double LTRAh2FirstVal; double LTRAh3dashFirstVal; double LTRAh1dashFirstCoeff; double LTRAh2FirstCoeff; double LTRAh3dashFirstCoeff; double *LTRAh1dashCoeffs; double *LTRAh2Coeffs; double *LTRAh3dashCoeffs; int LTRAmodelListSize; double LTRAconduct; double LTRAresist; double LTRAinduct; double LTRAcapac; double LTRAlength; double LTRAtd; double LTRAimped; double LTRAadmit; double LTRAalpha; double LTRAbeta; double LTRAattenuation; double LTRAcByR; double LTRArclsqr; double LTRAintH1dash; double LTRAintH2; double LTRAintH3dash; double LTRAnl; double LTRAf; double LTRAcoshlrootGR; double LTRArRsLrGRorG; double LTRArGsLrGRorR; int LTRAauxIndex; double LTRAstLineReltol; double LTRAchopReltol; double LTRAstLineAbstol; double LTRAchopAbstol; unsigned int LTRAreltolGiven; unsigned int LTRAabstolGiven; unsigned int LTRAtruncNR; unsigned int LTRAtruncDontCut; double LTRAmaxSafeStep; unsigned int LTRAresistGiven; unsigned int LTRAconductGiven; unsigned int LTRAinductGiven; unsigned int LTRAcapacGiven; unsigned int LTRAlengthGiven; unsigned int LTRAnlGiven; int LTRAlteConType; int LTRAhowToInterp; unsigned int LTRAprintFlag; int LTRAstepLimit; unsigned int LTRAfGiven; double LTRAabstol; double LTRAreltol; int LTRAspecialCase; } *

variable_types: struct sLTRAinstance { struct sLTRAmodel { int LTRAmodType; struct sLTRAmodel *LTRAnextModel; struct sLTRAinstance *LTRAinstances; char *LTRAmodName; double LTRAh1dashFirstVal; double LTRAh2FirstVal; double LTRAh3dashFirstVal; double LTRAh1dashFirstCoeff; double LTRAh2FirstCoeff; double LTRAh3dashFirstCoeff; double *LTRAh1dashCoeffs; double *LTRAh2Coeffs; double *LTRAh3dashCoeffs; int LTRAmodelListSize; double LTRAconduct; double LTRAresist; double LTRAinduct; double LTRAcapac; double LTRAlength; double LTRAtd; double LTRAimped; double LTRAadmit; double LTRAalpha; double LTRAbeta; double LTRAattenuation; double LTRAcByR; double LTRArclsqr; double LTRAintH1dash; double LTRAintH2; double LTRAintH3dash; double LTRAnl; double LTRAf; double LTRAcoshlrootGR; double LTRArRsLrGRorG; double LTRArGsLrGRorR; int LTRAauxIndex; double LTRAstLineReltol; double LTRAchopReltol; double LTRAstLineAbstol; double LTRAchopAbstol; unsigned int LTRAreltolGiven; unsigned int LTRAabstolGiven; unsigned int LTRAtruncNR; unsigned int LTRAtruncDontCut; double LTRAmaxSafeStep; unsigned int LTRAresistGiven; unsigned int LTRAconductGiven; unsigned int LTRAinductGiven; unsigned int LTRAcapacGiven; unsigned int LTRAlengthGiven; unsigned int LTRAnlGiven; int LTRAlteConType; int LTRAhowToInterp; unsigned int LTRAprintFlag; int LTRAstepLimit; unsigned int LTRAfGiven; double LTRAabstol; double LTRAreltol; int LTRAspecialCase; } *LTRAmodPtr; struct sLTRAinstance *LTRAnextInstance; char *LTRAname; int LTRAowner; int LTRAstate; int LTRAposNode1; int LTRAnegNode1; int LTRAposNode2; int LTRAnegNode2; int LTRAbrEq1; int LTRAbrEq2; double LTRAinput1; double LTRAinput2; double LTRAinitVolt1; double LTRAinitCur1; double LTRAinitVolt2; double LTRAinitCur2; double *LTRAv1; double *LTRAi1; double *LTRAv2; double *LTRAi2; int LTRAinstListSize; double *LTRAibr1Ibr1Ptr; double *LTRAibr1Ibr2Ptr; double *LTRAibr1Pos1Ptr; double *LTRAibr1Neg1Ptr; double *LTRAibr1Pos2Ptr; double *LTRAibr1Neg2Ptr; double *LTRAibr2Ibr1Ptr; double *LTRAibr2Ibr2Ptr; double *LTRAibr2Pos1Ptr; double *LTRAibr2Neg1Ptr; double *LTRAibr2Pos2Ptr; double *LTRAibr2Neg2Ptr; double *LTRAneg1Ibr1Ptr; double *LTRAneg2Ibr2Ptr; double *LTRApos1Ibr1Ptr; double *LTRApos2Ibr2Ptr; double *LTRApos1Pos1Ptr; double *LTRAneg1Neg1Ptr; double *LTRApos2Pos2Ptr; double *LTRAneg2Neg2Ptr; unsigned int LTRAicV1Given; unsigned int LTRAicC1Given; unsigned int LTRAicV2Given; unsigned int LTRAicC2Given; } *

variable_types: tmp double

variable_types: tolerance double

variable_types: maxiter int

variable_types: iterations int

variable_types: x double

variable_types: y double

variable_types: change double

variable_types: deriv double