//======================================================================================
//======================================================================================
// Filename: JUNCAP200_InitModel.include
//======================================================================================
//======================================================================================
//
//  (c) Copyright 2007, All Rights Reserved, NXP Semiconductors
//
//
//  Version: 102.1 (PSP), 200.2 (JUNCAP), April 2007 (Simkit 2.5)
//
//======================================================================================
//======================================================================================
//
// Further information can be found in the file readme.txt
//

         //////////////////////////////////////////////////////////////
         //
         // Calculation of internal paramters which are independent
         // on instance parameters
         //
         //////////////////////////////////////////////////////////////

         TRJ_i        = `CLIP_LOW( TRJ       , `TRJ_cliplow);
         IMAX_i       = `CLIP_LOW( IMAX      , `IMAX_cliplow);
         CJORBOT_i    = `CLIP_LOW( CJORBOT   , `CJORBOT_cliplow);
         CJORSTI_i    = `CLIP_LOW( CJORSTI   , `CJORSTI_cliplow);
         CJORGAT_i    = `CLIP_LOW( CJORGAT   , `CJORGAT_cliplow);
         VBIRBOT_i    = `CLIP_LOW( VBIRBOT   , `VBIR_cliplow);
         VBIRSTI_i    = `CLIP_LOW( VBIRSTI   , `VBIR_cliplow);
         VBIRGAT_i    = `CLIP_LOW( VBIRGAT   , `VBIR_cliplow);
         PBOT_i       = `CLIP_BOTH(PBOT      , `P_cliplow,`P_cliphigh);
         PSTI_i       = `CLIP_BOTH(PSTI      , `P_cliplow,`P_cliphigh);
         PGAT_i       = `CLIP_BOTH(PGAT      , `P_cliplow,`P_cliphigh);
         IDSATRBOT_i  = `CLIP_LOW( IDSATRBOT , `IDSATR_cliplow);  
         IDSATRSTI_i  = `CLIP_LOW( IDSATRSTI , `IDSATR_cliplow);
         IDSATRGAT_i  = `CLIP_LOW( IDSATRGAT , `IDSATR_cliplow);
         CSRHBOT_i    = `CLIP_LOW( CSRHBOT   , `CSRH_cliplow);
         CSRHSTI_i    = `CLIP_LOW( CSRHSTI   , `CSRH_cliplow);
         CSRHGAT_i    = `CLIP_LOW( CSRHGAT   , `CSRH_cliplow);
         XJUNSTI_i    = `CLIP_LOW( XJUNSTI   , `XJUN_cliplow);
         XJUNGAT_i    = `CLIP_LOW( XJUNGAT   , `XJUN_cliplow);
         CTATBOT_i    = `CLIP_LOW( CTATBOT   , `CTAT_cliplow);
         CTATSTI_i    = `CLIP_LOW( CTATSTI   , `CTAT_cliplow);
         CTATGAT_i    = `CLIP_LOW( CTATGAT   , `CTAT_cliplow);
         MEFFTATBOT_i = `CLIP_LOW( MEFFTATBOT, `MEFFTAT_cliplow);
         MEFFTATSTI_i = `CLIP_LOW( MEFFTATSTI, `MEFFTAT_cliplow);
         MEFFTATGAT_i = `CLIP_LOW( MEFFTATGAT, `MEFFTAT_cliplow);
         CBBTBOT_i    = `CLIP_LOW( CBBTBOT   , `CBBT_cliplow);
         CBBTSTI_i    = `CLIP_LOW( CBBTSTI   , `CBBT_cliplow);
         CBBTGAT_i    = `CLIP_LOW( CBBTGAT   , `CBBT_cliplow);
         VBRBOT_i     = `CLIP_LOW( VBRBOT    , `VBR_cliplow);
         VBRSTI_i     = `CLIP_LOW( VBRSTI    , `VBR_cliplow);
         VBRGAT_i     = `CLIP_LOW( VBRGAT    , `VBR_cliplow);
         PBRBOT_i     = `CLIP_LOW( PBRBOT    , `PBR_cliplow);
         PBRSTI_i     = `CLIP_LOW( PBRSTI    , `PBR_cliplow);
         PBRGAT_i     = `CLIP_LOW( PBRGAT    , `PBR_cliplow);

         tkr            = `KELVINCONVERSION + TRJ_i;
         tkd            = max($temperature + DTA, `KELVINCONVERSION + `MINTEMP);
         auxt           = tkd / tkr;
         KBOL_over_QELE = `KBOL / `QELE;
         phitr          = KBOL_over_QELE * tkr;
         phitrinv       = 1.0 / phitr;
         phitd          = KBOL_over_QELE * tkd;
         phitdinv       = 1.0 / phitd;

         // bandgap voltages at reference temperature
         deltaphigr     = -(7.02e-4 * tkr * tkr) / (1108.0 + tkr);
         phigrbot       = PHIGBOT + deltaphigr;
         phigrsti       = PHIGSTI + deltaphigr;
         phigrgat       = PHIGGAT + deltaphigr;

         // bandgap voltages at device temperature
         deltaphigd     = -(7.02e-4 * tkd * tkd) / (1108.0 + tkd);
         phigdbot       = PHIGBOT + deltaphigd;
         phigdsti       = PHIGSTI + deltaphigd;
         phigdgat       = PHIGGAT + deltaphigd;

         // factors ftd for ideal-current model
         ftdbot         = (pow(auxt, 1.5)) * exp(0.5 * ((phigrbot * phitrinv) - (phigdbot * phitdinv)));
         ftdsti         = (pow(auxt, 1.5)) * exp(0.5 * ((phigrsti * phitrinv) - (phigdsti * phitdinv)));
         ftdgat         = (pow(auxt, 1.5)) * exp(0.5 * ((phigrgat * phitrinv) - (phigdgat * phitdinv)));

         // temperature-scaled saturation current for ideal-current model
         idsatbot       = IDSATRBOT_i * ftdbot * ftdbot;  
         idsatsti       = IDSATRSTI_i * ftdsti * ftdsti;  
         idsatgat       = IDSATRGAT_i * ftdgat * ftdgat;  

         // built-in voltages before limiting
         ubibot        = VBIRBOT_i * auxt - 2 * phitd * ln(ftdbot);
         ubisti        = VBIRSTI_i * auxt - 2 * phitd * ln(ftdsti);
         ubigat        = VBIRGAT_i * auxt - 2 * phitd * ln(ftdgat);

         // built-in voltages limited to phitd
         vbibot        = ubibot + phitd * ln(1 + exp((`vbilow - ubibot) * phitdinv));
         vbisti        = ubisti + phitd * ln(1 + exp((`vbilow - ubisti) * phitdinv));
         vbigat        = ubigat + phitd * ln(1 + exp((`vbilow - ubigat) * phitdinv));

         // inverse values of built-in voltages
         vbiinvbot     = 1.0 / vbibot;
         vbiinvsti     = 1.0 / vbisti;
         vbiinvgat     = 1.0 / vbigat;

         // one minus the grading coefficient
         one_minus_PBOT = 1 - PBOT_i;
         one_minus_PSTI = 1 - PSTI_i;
         one_minus_PGAT = 1 - PGAT_i;

         // one over "one minus the grading coefficient"
         one_over_one_minus_PBOT = 1 / one_minus_PBOT;
         one_over_one_minus_PSTI = 1 / one_minus_PSTI;
         one_over_one_minus_PGAT = 1 / one_minus_PGAT;

         // temperature-scaled zero-bias capacitance
         cjobot        = CJORBOT_i * pow((VBIRBOT_i * vbiinvbot), PBOT_i);
         cjosti        = CJORSTI_i * pow((VBIRSTI_i * vbiinvsti), PSTI_i);
         cjogat        = CJORGAT_i * pow((VBIRGAT_i * vbiinvgat), PGAT_i);

         // prefactor in physical part of charge model
         qprefbot      = cjobot * vbibot * one_over_one_minus_PBOT;
         qprefsti      = cjosti * vbisti * one_over_one_minus_PSTI;
         qprefgat      = cjogat * vbigat * one_over_one_minus_PGAT;

         // prefactor in mathematical extension of charge model
         qpref2bot     = `a * cjobot;
         qpref2sti     = `a * cjosti;
         qpref2gat     = `a * cjogat;

         // zero-bias depletion widths at reference temperature, needed in SRH and TAT model
         wdepnulrbot   = `EPSSI / CJORBOT_i;
         wdepnulrsti   =  XJUNSTI_i * `EPSSI / CJORSTI_i;
         wdepnulrgat   = XJUNGAT_i * `EPSSI / CJORGAT_i;

         // inverse values of "wdepnulr", used in BBT model
         wdepnulrinvbot = 1 / wdepnulrbot;
         wdepnulrinvsti = 1 / wdepnulrsti;
         wdepnulrinvgat = 1 / wdepnulrgat;
                  
         // inverse values of built-in voltages at reference temperature, needed in SRH and BBT model
         VBIRBOTinv    = 1 / VBIRBOT_i; 
         VBIRSTIinv    = 1 / VBIRSTI_i; 
         VBIRGATinv    = 1 / VBIRGAT_i; 

         // some constants needed in erfc-approximation, needed in TAT model
         perfc         = (`SQRTPI * `aerfc);
         berfc         = ((-5 * (`aerfc) + 6 - pow((perfc), -2)) / 3);
         cerfc         = (1.0 - (`aerfc) - (berfc));

         // half the bandgap energy, limited to values > phitd, needed in TAT model
         deltaEbot     = max(0.5 * phigdbot, phitd);
         deltaEsti     = max(0.5 * phigdsti, phitd);
         deltaEgat     = max(0.5 * phigdgat, phitd);

         // values of atat, needed in TAT model
         atatbot       = deltaEbot * phitdinv; 
         atatsti       = deltaEsti * phitdinv; 
         atatgat       = deltaEgat * phitdinv; 

         // values of btatpart, needed in TAT model
         btatpartbot   = sqrt(32 * MEFFTATBOT_i * `MELE * `QELE * (deltaEbot * deltaEbot * deltaEbot)) / (3 * `HBAR);
         btatpartsti   = sqrt(32 * MEFFTATSTI_i * `MELE * `QELE * (deltaEsti * deltaEsti * deltaEsti)) / (3 * `HBAR);
         btatpartgat   = sqrt(32 * MEFFTATGAT_i * `MELE * `QELE * (deltaEgat * deltaEgat * deltaEgat)) / (3 * `HBAR);

         // temperature-scaled values of FBBT, needed in BBT model
         fbbtbot       = FBBTRBOT * (1 + STFBBTBOT * (tkd - tkr));
         fbbtsti       = FBBTRSTI * (1 + STFBBTSTI * (tkd - tkr));
         fbbtgat       = FBBTRGAT * (1 + STFBBTGAT * (tkd - tkr));

         // values of fstop, needed in avalanche/breakdown model
         fstopbot      = 1 / (1 - pow(`alphaav, PBRBOT_i));
         fstopsti      = 1 / (1 - pow(`alphaav, PBRSTI_i));
         fstopgat      = 1 / (1 - pow(`alphaav, PBRGAT_i));

         // inverse values of breakdown voltages, needed in avalanche/breakdown model
         VBRinvbot     = 1 / VBRBOT_i;
         VBRinvsti     = 1 / VBRSTI_i;
         VBRinvgat     = 1 / VBRGAT_i;
         
         // slopes for linear extraploation close to and beyond breakdown, needed in avalanche/breakdown model
         slopebot      = -(fstopbot * fstopbot * pow(`alphaav, (PBRBOT_i - 1))) * PBRBOT_i * VBRinvbot;
         slopesti      = -(fstopsti * fstopsti * pow(`alphaav, (PBRSTI_i - 1))) * PBRSTI_i * VBRinvsti;
         slopegat      = -(fstopgat * fstopgat * pow(`alphaav, (PBRGAT_i - 1))) * PBRGAT_i * VBRinvgat;
