Show
Ignore:
Timestamp:
02/01/08 12:53:12 (10 months ago)
Author:
clauss
Message:

Modelica.Electrical.Analog smooth, noEvent added

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/Modelica/Electrical/Analog/Semiconductors.mo

    r887 r1024  
    11within Modelica.Electrical.Analog; 
    2 package Semiconductors 
    3   "Semiconductor devices such as diode, MOS and bipolar transistor" 
     2package Semiconductors  
     3  "Semiconductor devices such as diode, MOS and bipolar transistor"  
    44  extends Modelica.Icons.Library; 
    55  import Modelica.SIunits; 
    6  
     6   
    77  annotation ( 
    88    Window( 
     
    4444</dl> 
    4545</html>")); 
    46  
    47   model Diode "Simple diode" 
     46   
     47  model Diode "Simple diode"  
    4848    extends Modelica.Electrical.Analog.Interfaces.OnePort; 
    4949    parameter SIunits.Current Ids=1.e-6 "Saturation current"; 
    50     parameter SIunits.Voltage Vt=0.04 
     50    parameter SIunits.Voltage Vt=0.04  
    5151      "Voltage equivalent of temperature (kT/qn)"; 
    52     parameter Real Maxexp(final min=Modelica.Constants.small) = 15 
     52    parameter Real Maxexp(final min=Modelica.Constants.small) = 15  
    5353      "Max. exponent for linear continuation"; 
    5454    parameter SIunits.Resistance R=1.e8 "Parallel ohmic resistance"; 
     
    115115        width=0.75, 
    116116        height=0.63)); 
    117   equation 
    118     i = smooth(1,(if (v/Vt > Maxexp) then Ids*(exp(Maxexp)*(1 + v/Vt - Maxexp) - 1) + 
    119       v/R else Ids*(exp(v/Vt) - 1) + v/R)); 
     117  equation  
     118    i = noEvent(smooth(1,(if (v/Vt > Maxexp) then Ids*(exp(Maxexp)*(1 + v/Vt - Maxexp) - 1) + 
     119      v/R else Ids*(exp(v/Vt) - 1) + v/R))); 
    120120  end Diode; 
    121  
    122   model PMOS "Simple MOS Transistor" 
     121   
     122  model PMOS "Simple MOS Transistor"  
    123123    Interfaces.Pin D "Drain" annotation (Placement(transformation(extent={{90, 
    124124              40},{110,60}}, rotation=0))); 
     
    131131    parameter SIunits.Length W=20.0e-6 "Width"; 
    132132    parameter SIunits.Length L=6.0e-6 "Length"; 
    133     parameter SIunits.Transconductance Beta=0.0105e-3 
     133    parameter SIunits.Transconductance Beta=0.0105e-3  
    134134      "Transconductance parameter"; 
    135135    parameter SIunits.Voltage Vt=-1.0 "Zero bias threshold voltage"; 
     
    139139    parameter SIunits.Length dL=-2.1e-6 "Shortening of channel"; 
    140140    parameter SIunits.Resistance RDS=1.e+7 "Drain-Source-Resistance"; 
    141   protected 
     141  protected  
    142142    Real v; 
    143143    Real uds; 
     
    233233            fillPattern=FillPattern.Solid, 
    234234            lineColor={0,0,255})})); 
    235   equation 
     235  equation  
    236236    //assert (L + dL > 0, "Effective length must be positive"); 
    237237    //assert (W + dW > 0, "Effective width  must be positive"); 
    238238    gds = if (RDS < 1.e-20 and RDS > -1.e-20) then 1.e20 else 1/RDS; 
    239239    v = Beta*(W + dW)/(L + dL); 
    240     ud = if (D.v > S.v) then S.v else D.v; 
    241     us = if (D.v > S.v) then D.v else S.v; 
     240    ud = noEvent(smooth(0,if (D.v > S.v) then S.v else D.v)); 
     241    us = noEvent(smooth(0,if (D.v > S.v) then D.v else S.v)); 
    242242    uds = ud - us; 
    243     ubs = if (B.v < us) then 0 else B.v - us; 
     243    ubs = noEvent(smooth(0,if (B.v < us) then 0 else B.v - us)); 
    244244    ugst = (G.v - us - Vt + K2*ubs)*K5; 
    245     id = if (ugst >= 0) then uds*gds else if (ugst < uds) then -v*uds*( 
    246       ugst - uds/2) + uds*gds else -v*ugst*ugst/2 + uds*gds; 
     245    id = noEvent(smooth(0,if (ugst >= 0) then uds*gds else if (ugst < uds) then -v*uds*( 
     246      ugst - uds/2) + uds*gds else -v*ugst*ugst/2 + uds*gds)); 
    247247    G.i = 0; 
    248     D.i = if (D.v > S.v) then -id else id; 
    249     S.i = if (D.v > S.v) then id else -id; 
     248    D.i = noEvent(smooth(0,if (D.v > S.v) then -id else id)); 
     249    S.i = noEvent(smooth(0,if (D.v > S.v) then id else -id)); 
    250250    B.i = 0; 
    251251  end PMOS; 
    252  
    253   model NMOS "Simple MOS Transistor" 
     252   
     253  model NMOS "Simple MOS Transistor"  
    254254    Interfaces.Pin D "Drain" annotation (Placement(transformation(extent={{90, 
    255255              40},{110,60}}, rotation=0))); 
     
    262262    parameter SIunits.Length W=20.e-6 "Width"; 
    263263    parameter SIunits.Length L=6.e-6 "Length"; 
    264     parameter SIunits.Transconductance Beta=0.041e-3 
     264    parameter SIunits.Transconductance Beta=0.041e-3  
    265265      "Transconductance parameter"; 
    266266    parameter SIunits.Voltage Vt=0.8 "Zero bias threshold voltage"; 
     
    270270    parameter SIunits.Length dL=-1.5e-6 "shortening of channel"; 
    271271    parameter SIunits.Resistance RDS=1.e+7 "Drain-Source-Resistance"; 
    272   protected 
     272  protected  
    273273    Real v; 
    274274    Real uds; 
     
    369369            fillPattern=FillPattern.Solid, 
    370370            lineColor={0,0,255})})); 
    371   equation 
     371  equation  
    372372    //assert (L + dL > 0, "Effective length must be positive"); 
    373373    //assert (W + dW > 0, "Effective width  must be positive"); 
    374374    gds = if (RDS < 1.e-20 and RDS > -1.e-20) then 1.e20 else 1/RDS; 
    375375    v = Beta*(W + dW)/(L + dL); 
    376     ud = if (D.v < S.v) then S.v else D.v; 
     376    ud = noEvent(smooth(0,if (D.v < S.v) then S.v else D.v)); 
    377377    us = if (D.v < S.v) then D.v else S.v; 
    378378    uds = ud - us; 
    379     ubs = if (B.v > us) then 0 else B.v - us; 
     379    ubs = noEvent(smooth(0,if (B.v > us) then 0 else B.v - us)); 
    380380    ugst = (G.v - us - Vt + K2*ubs)*K5; 
    381     id = if (ugst <= 0) then uds*gds else if (ugst > uds) then v*uds*(ugst 
    382        - uds/2) + uds*gds else v*ugst*ugst/2 + uds*gds; 
     381    id = noEvent(smooth(0,if (ugst <= 0) then uds*gds else if (ugst > uds) then v*uds*(ugst 
     382       - uds/2) + uds*gds else v*ugst*ugst/2 + uds*gds)); 
    383383    G.i = 0; 
    384     D.i = if (D.v < S.v) then -id else id; 
    385     S.i = if (D.v < S.v) then id else -id; 
     384    D.i = noEvent(smooth(0,if (D.v < S.v) then -id else id)); 
     385    S.i = noEvent(smooth(0,if (D.v < S.v) then id else -id)); 
    386386    B.i = 0; 
    387387  end NMOS; 
    388  
    389   model NPN "Simple BJT according to Ebers-Moll" 
     388   
     389  model NPN "Simple BJT according to Ebers-Moll"  
    390390    parameter Real Bf=50 "Forward beta"; 
    391391    parameter Real Br=0.1 "Reverse beta"; 
    392392    parameter SIunits.Current Is=1.e-16 "Transport saturation current"; 
    393     parameter SIunits.InversePotential Vak=0.02 
     393    parameter SIunits.InversePotential Vak=0.02  
    394394      "Early voltage (inverse), 1/Volt"; 
    395395    parameter SIunits.Time Tauf=0.12e-9 "Ideal forward transit time"; 
    396396    parameter SIunits.Time Taur=5e-9 "Ideal reverse transit time"; 
    397397    parameter SIunits.Capacitance Ccs=1e-12 "Collector-substrat(ground) cap."; 
    398     parameter SIunits.Capacitance Cje=0.4e-12 
     398    parameter SIunits.Capacitance Cje=0.4e-12  
    399399      "Base-emitter zero bias depletion cap."; 
    400     parameter SIunits.Capacitance Cjc=0.5e-12 
     400    parameter SIunits.Capacitance Cjc=0.5e-12  
    401401      "Base-coll. zero bias depletion cap."; 
    402402    parameter SIunits.Voltage Phie=0.8 "Base-emitter diffusion voltage"; 
     
    409409    parameter Real EMin=-100 "if x < EMin, the exp(x) function is linearized"; 
    410410    parameter Real EMax=40 "if x > EMax, the exp(x) function is linearized"; 
    411   protected 
     411  protected  
    412412    Real vbc; 
    413413    Real vbe; 
     
    421421    Real Capcje; 
    422422    Real Capcjc; 
    423     function pow "Just a helper function for x^y" 
     423    function pow "Just a helper function for x^y"  
    424424      input Real x; 
    425425      input Real y; 
    426426      output Real z; 
    427     algorithm 
     427    algorithm  
    428428      z:=x^y; 
    429429    end pow; 
    430   public 
     430  public  
    431431    Modelica.Electrical.Analog.Interfaces.Pin C "Collector" annotation (Placement( 
    432432          transformation(extent={{90,40},{110,60}}, rotation=0))); 
     
    507507            fillPattern=FillPattern.Solid, 
    508508            lineColor={0,0,255})})); 
    509   equation 
     509  equation  
    510510    ExMin = exp(EMin); 
    511511    ExMax = exp(EMax); 
     
    513513    vbe = B.v - E.v; 
    514514    qbk = 1 - vbc*Vak; 
    515  
    516     ibc = noEvent(if (vbc/Vt < EMin) then Is*(ExMin*(vbc/Vt - EMin + 1) - 1) + vbc*Gbc else  
     515     
     516    ibc = noEvent(smooth(1,if (vbc/Vt < EMin) then Is*(ExMin*(vbc/Vt - EMin + 1) - 1) + vbc*Gbc else  
    517517            if (vbc/Vt > EMax) then Is*(ExMax*(vbc/Vt - EMax + 1) - 1) + vbc* 
    518       Gbc else Is*(exp(vbc/Vt) - 1) + vbc*Gbc); 
    519     ibe = noEvent(if (vbe/Vt < EMin) then Is*(ExMin*(vbe/Vt - EMin + 1) - 1) + vbe*Gbe else  
     518      Gbc else Is*(exp(vbc/Vt) - 1) + vbc*Gbc)); 
     519    ibe = noEvent(smooth(1,if (vbe/Vt < EMin) then Is*(ExMin*(vbe/Vt - EMin + 1) - 1) + vbe*Gbe else  
    520520            if (vbe/Vt > EMax) then Is*(ExMax*(vbe/Vt - EMax + 1) - 1) + vbe* 
    521       Gbe else Is*(exp(vbe/Vt) - 1) + vbe*Gbe); 
    522     Capcjc = noEvent(if (vbc/Phic > 0) then Cjc*(1 + Mc*vbc/Phic) else Cjc*pow(1 - vbc 
    523       /Phic, -Mc)); 
    524     Capcje = noEvent(if (vbe/Phie > 0) then Cje*(1 + Me*vbe/Phie) else Cje*pow(1 - vbe 
    525       /Phie, -Me)); 
    526     cbc = noEvent(if (vbc/Vt < EMin) then Taur*Is/Vt*ExMin*(vbc/Vt - EMin + 1) + 
     521      Gbe else Is*(exp(vbe/Vt) - 1) + vbe*Gbe)); 
     522    Capcjc = noEvent(smooth(1,(if (vbc/Phic > 0) then Cjc*(1 + Mc*vbc/Phic) else Cjc*pow(1 - vbc 
     523      /Phic, -Mc)))); 
     524    Capcje = noEvent(smooth(1,(if (vbe/Phie > 0) then Cje*(1 + Me*vbe/Phie) else Cje*pow(1 - vbe 
     525      /Phie, -Me)))); 
     526    cbc = noEvent(smooth(1,(if (vbc/Vt < EMin) then Taur*Is/Vt*ExMin*(vbc/Vt - EMin + 1) + 
    527527      Capcjc else if (vbc/Vt > EMax) then Taur*Is/Vt*ExMax*(vbc/Vt - EMax + 1) 
    528        + Capcjc else Taur*Is/Vt*exp(vbc/Vt) + Capcjc); 
    529     cbe = noEvent(if (vbe/Vt < EMin) then Tauf*Is/Vt*ExMin*(vbe/Vt - EMin + 1) + 
     528       + Capcjc else Taur*Is/Vt*exp(vbc/Vt) + Capcjc))); 
     529    cbe = noEvent(smooth(1,(if (vbe/Vt < EMin) then Tauf*Is/Vt*ExMin*(vbe/Vt - EMin + 1) + 
    530530      Capcje else if (vbe/Vt > EMax) then Tauf*Is/Vt*ExMax*(vbe/Vt - EMax + 1) 
    531        + Capcje else Tauf*Is/Vt*exp(vbe/Vt) + Capcje); 
     531       + Capcje else Tauf*Is/Vt*exp(vbe/Vt) + Capcje))); 
    532532    C.i = (ibe - ibc)*qbk - ibc/Br - cbc*der(vbc) + Ccs*der(C.v); 
    533533    B.i = ibe/Bf + ibc/Br + cbc*der(vbc) + cbe*der(vbe); 
    534534    E.i = -B.i - C.i + Ccs*der(C.v); 
    535535  end NPN; 
    536  
    537   model PNP "Simple BJT according to Ebers-Moll" 
     536   
     537  model PNP "Simple BJT according to Ebers-Moll"  
    538538    parameter Real Bf=50 "Forward beta"; 
    539539    parameter Real Br=0.1 "Reverse beta"; 
    540540    parameter SIunits.Current Is=1.e-16 "Transport saturation current"; 
    541     parameter SIunits.InversePotential Vak=0.02 
     541    parameter SIunits.InversePotential Vak=0.02  
    542542      "Early voltage (inverse), 1/Volt"; 
    543543    parameter SIunits.Time Tauf=0.12e-9 "Ideal forward transit time"; 
    544544    parameter SIunits.Time Taur=5e-9 "Ideal reverse transit time"; 
    545545    parameter SIunits.Capacitance Ccs=1e-12 "Collector-substrat(ground) cap."; 
    546     parameter SIunits.Capacitance Cje=0.4e-12 
     546    parameter SIunits.Capacitance Cje=0.4e-12  
    547547      "Base-emitter zero bias depletion cap."; 
    548     parameter SIunits.Capacitance Cjc=0.5e-12 
     548    parameter SIunits.Capacitance Cjc=0.5e-12  
    549549      "Base-coll. zero bias depletion cap."; 
    550550    parameter SIunits.Voltage Phie=0.8 "Base-emitter diffusion voltage"; 
     
    557557    parameter Real EMin=-100 "if x < EMin, the exp(x) function is linearized"; 
    558558    parameter Real EMax=40 "if x > EMax, the exp(x) function is linearized"; 
    559   protected 
     559  protected  
    560560    Real vbc; 
    561561    Real vbe; 
     
    569569    Real Capcje; 
    570570    Real Capcjc; 
    571     function pow "Just a helper function for x^y" 
     571    function pow "Just a helper function for x^y"  
    572572      input Real x; 
    573573      input Real y; 
    574574      output Real z; 
    575     algorithm 
     575    algorithm  
    576576      z:=x^y; 
    577577    end pow; 
    578   public 
     578  public  
    579579    Modelica.Electrical.Analog.Interfaces.Pin C "Collector" annotation (Placement( 
    580580          transformation(extent={{90,40},{110,60}}, rotation=0))); 
     
    649649            fillPattern=FillPattern.Solid, 
    650650            lineColor={0,0,255})})); 
    651   equation 
     651  equation  
    652652    ExMin = exp(EMin); 
    653653    ExMax = exp(EMax); 
     
    655655    vbe = E.v - B.v; 
    656656    qbk = 1 - vbc*Vak; 
    657  
    658     ibc = noEvent(if (vbc/Vt < EMin) then Is*(ExMin*(vbc/Vt - EMin + 1) - 1) + vbc*Gbc else  
     657     
     658    ibc = noEvent(smooth(1,(if (vbc/Vt < EMin) then Is*(ExMin*(vbc/Vt - EMin + 1) - 1) + vbc*Gbc else  
    659659            if (vbc/Vt > EMax) then Is*(ExMax*(vbc/Vt - EMax + 1) - 1) + vbc* 
    660       Gbc else Is*(exp(vbc/Vt) - 1) + vbc*Gbc); 
    661  
    662     ibe = noEvent(if (vbe/Vt < EMin) then Is*(ExMin*(vbe/Vt - EMin + 1) - 1) + vbe*Gbe else  
     660      Gbc else Is*(exp(vbc/Vt) - 1) + vbc*Gbc))); 
     661     
     662    ibe = noEvent(smooth(1,(if (vbe/Vt < EMin) then Is*(ExMin*(vbe/Vt - EMin + 1) - 1) + vbe*Gbe else  
    663663            if (vbe/Vt > EMax) then Is*(ExMax*(vbe/Vt - EMax + 1) - 1) + vbe* 
    664       Gbe else Is*(exp(vbe/Vt) - 1) + vbe*Gbe); 
    665  
    666     Capcjc = noEvent(if (vbc/Phic > 0) then Cjc*(1 + Mc*vbc/Phic) else Cjc*pow(1 - vbc 
    667       /Phic, -Mc)); 
    668     Capcje = noEvent(if (vbe/Phie > 0) then Cje*(1 + Me*vbe/Phie) else Cje*pow(1 - vbe 
    669       /Phie, -Me)); 
    670     cbc = noEvent(if (vbc/Vt < EMin) then Taur*Is/Vt*ExMin*(vbc/Vt - EMin + 1) + 
     664      Gbe else Is*(exp(vbe/Vt) - 1) + vbe*Gbe))); 
     665     
     666    Capcjc = noEvent(smooth(1,(if (vbc/Phic > 0) then Cjc*(1 + Mc*vbc/Phic) else Cjc*pow(1 - vbc 
     667      /Phic, -Mc)))); 
     668    Capcje = noEvent(smooth(1,if (vbe/Phie > 0) then Cje*(1 + Me*vbe/Phie) else Cje*pow(1 - vbe 
     669      /Phie, -Me))); 
     670    cbc = noEvent(smooth(1,(if (vbc/Vt < EMin) then Taur*Is/Vt*ExMin*(vbc/Vt - EMin + 1) + 
    671671      Capcjc else if (vbc/Vt > EMax) then Taur*Is/Vt*ExMax*(vbc/Vt - EMax + 1) 
    672        + Capcjc else Taur*Is/Vt*exp(vbc/Vt) + Capcjc); 
    673     cbe = noEvent(if (vbe/Vt < EMin) then Tauf*Is/Vt*ExMin*(vbe/Vt - EMin + 1) + 
     672       + Capcjc else Taur*Is/Vt*exp(vbc/Vt) + Capcjc))); 
     673    cbe = noEvent(smooth(1,(if (vbe/Vt < EMin) then Tauf*Is/Vt*ExMin*(vbe/Vt - EMin + 1) + 
    674674      Capcje else if (vbe/Vt > EMax) then Tauf*Is/Vt*ExMax*(vbe/Vt - EMax + 1) 
    675        + Capcje else Tauf*Is/Vt*exp(vbe/Vt) + Capcje); 
     675       + Capcje else Tauf*Is/Vt*exp(vbe/Vt) + Capcje))); 
    676676    C.i = -((ibe - ibc)*qbk - ibc/Br - cbc*der(vbc) - Ccs*der(C.v)); 
    677677    B.i = -(ibe/Bf + ibc/Br + cbe*der(vbe) + cbc*der(vbc)); 
    678678    E.i = -B.i - C.i + Ccs*der(C.v); 
    679679  end PNP; 
    680  
    681         model HeatingDiode "Simple diode with heating port" 
     680   
     681        model HeatingDiode "Simple diode with heating port"  
    682682          extends Modelica.Electrical.Analog.Interfaces.OnePort; 
    683683          Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort(T(start= 
     
    688688          rotation=270))); 
    689689          parameter Modelica.SIunits.Current Ids=1.e-6 "Saturation current"; 
    690  
     690     
    691691            /* parameter Modelica.SIunits.Voltage Vt=0.04 "Voltage equivalent of temperature (kT/qn)"; */ 
    692           parameter Real Maxexp(final min=Modelica.Constants.small) = 15 
     692          parameter Real Maxexp(final min=Modelica.Constants.small) = 15  
    693693      "Max. exponent for linear continuation"; 
    694           parameter Modelica.SIunits.Resistance R=1.e8 
     694          parameter Modelica.SIunits.Resistance R=1.e8  
    695695      "Parallel ohmic resistance"; 
    696696          parameter Real EG=1.11 "activation energy"; 
    697697          parameter Real N=1 "Emission coefficient"; 
    698           parameter Modelica.SIunits.Temperature TNOM=300.15 
     698          parameter Modelica.SIunits.Temperature TNOM=300.15  
    699699      "Parameter measurement temperature"; 
    700700          parameter Real XTI=3 "Temperature exponent of saturation current"; 
    701701          Modelica.SIunits.Temperature vt_t "Temperature voltage"; 
    702702          Modelica.SIunits.Current id "diode current"; 
    703   protected 
     703  protected  
    704704          Real k=1.380662e-23 "Boltzmann's constant, J/K"; 
    705705          Real q=1.6021892e-19 "Electron charge, As"; 
     
    770770              width=0.75, 
    771771              height=0.63)); 
    772         equation 
     772        equation  
    773773          assert( heatPort.T > 0,"temperature must be positive"); 
    774774          htemp = heatPort.T; 
    775775          vt_t = k*htemp/q; 
    776  
     776     
    777777          id = exlin((v/(N*vt_t)), Maxexp) - 1; 
    778  
     778     
    779779          aux = (htemp/TNOM - 1)*EG/(N*vt_t); 
    780780          auxp = exp(aux); 
    781  
     781     
    782782          i = Ids*id*pow(htemp/TNOM, XTI/N)*auxp + v/R; 
    783  
     783     
    784784          heatPort.Q_flow = -i*v; 
    785785        end HeatingDiode; 
    786  
    787         model HeatingNMOS "Simple MOS Transistor with heating port" 
     786   
     787        model HeatingNMOS "Simple MOS Transistor with heating port"  
    788788          Modelica.Electrical.Analog.Interfaces.Pin D "Drain"  
    789789            annotation (Placement(transformation(extent={{90,40},{110,60}}, 
     
    806806          parameter Modelica.SIunits.Length W=20.e-6 "Width"; 
    807807          parameter Modelica.SIunits.Length L=6.e-6 "Length"; 
    808           parameter Modelica.SIunits.Transconductance Beta=0.041e-3 
     808          parameter Modelica.SIunits.Transconductance Beta=0.041e-3  
    809809      "Transconductance parameter"; 
    810           parameter Modelica.SIunits.Voltage Vt=0.8 
     810          parameter Modelica.SIunits.Voltage Vt=0.8  
    811811      "Zero bias threshold voltage"; 
    812812          parameter Real K2=1.144 "Bulk threshold parameter"; 
     
    814814          parameter Modelica.SIunits.Length dW=-2.5e-6 "narrowing of channel"; 
    815815          parameter Modelica.SIunits.Length dL=-1.5e-6 "shortening of channel"; 
    816           parameter Modelica.SIunits.Resistance RDS=1.e+7 
     816          parameter Modelica.SIunits.Resistance RDS=1.e+7  
    817817      "Drain-Source-Resistance"; 
    818           parameter Modelica.SIunits.Temperature Tnom=300.15 
     818          parameter Modelica.SIunits.Temperature Tnom=300.15  
    819819      "Parameter measurement temperature"; 
    820820          parameter Real kvt=-6.96e-3 "fitting parameter for Vt"; 
    821821          parameter Real kk2=6.0e-4 "fitting parameter for K22"; 
    822   protected 
     822  protected  
    823823          Real v; 
    824824          Real uds; 
     
    929929            lineColor={0,0,255}), 
    930930          Line(points={{0,-90},{0,-49}}, color={191,0,0})})); 
    931         equation 
     931        equation  
    932932          assert(L + dL > 0, "Effective length must be positive"); 
    933933          assert(W + dW > 0, "Effective width  must be positive"); 
     
    935935          gds = if (RDS < 1.e-20 and RDS > -1.e-20) then 1.e20 else 1/RDS; 
    936936          v = beta_t*(W + dW)/(L + dL); 
    937           ud = if (D.v < S.v) then S.v else D.v; 
    938           us = if (D.v < S.v) then D.v else S.v; 
     937          ud = noEvent(smooth(0,if (D.v < S.v) then S.v else D.v)); 
     938          us = noEvent(smooth(0,if (D.v < S.v) then D.v else S.v)); 
    939939          uds = ud - us; 
    940           ubs = if (B.v > us) then 0 else B.v - us; 
     940          ubs = noEvent(smooth(0,if (B.v > us) then 0 else B.v - us)); 
    941941          ugst = (G.v - us - vt_t + k2_t*ubs)*K5; 
    942           id = if (ugst <= 0) then uds*gds else if (ugst > uds) then v*uds*( 
    943             ugst - uds/2) + uds*gds else v*ugst*ugst/2 + uds*gds; 
    944  
     942          id = noEvent(smooth(0,if (ugst <= 0) then uds*gds else if (ugst > uds) then v*uds*( 
     943            ugst - uds/2) + uds*gds else v*ugst*ugst/2 + uds*gds)); 
     944     
    945945          beta_t = Beta*pow((heatPort.T/Tnom), -1.5); 
    946946          vt_t = Vt*(1 + (heatPort.T - Tnom)*kvt); 
    947947          k2_t = K2*(1 + (heatPort.T - Tnom)*kk2); 
    948  
     948     
    949949          G.i = 0; 
    950           D.i = if (D.v < S.v) then -id else id; 
    951           S.i = if (D.v < S.v) then id else -id; 
     950          D.i = noEvent(smooth(0,if (D.v < S.v) then -id else id)); 
     951          S.i = noEvent(smooth(0,if (D.v < S.v) then id else -id)); 
    952952          B.i = 0; 
    953953          heatPort.Q_flow = -D.i*(D.v - S.v); 
    954954        end HeatingNMOS; 
    955  
    956         model HeatingPMOS "Simple PMOS Transistor with heating port" 
     955   
     956        model HeatingPMOS "Simple PMOS Transistor with heating port"  
    957957         Modelica.Electrical.Analog.Interfaces.Pin D "Drain"  
    958958            annotation (Placement(transformation(extent={{90,40},{110,60}}, 
     
    975975          parameter Modelica.SIunits.Length W=20.0e-6 "Width"; 
    976976          parameter Modelica.SIunits.Length L=6.0e-6 "Length"; 
    977           parameter Modelica.SIunits.Transconductance Beta=0.0105e-3 
     977          parameter Modelica.SIunits.Transconductance Beta=0.0105e-3  
    978978      "Transconductance parameter"; 
    979           parameter Modelica.SIunits.Voltage Vt=-1.0 
     979          parameter Modelica.SIunits.Voltage Vt=-1.0  
    980980      "Zero bias threshold voltage"; 
    981981          parameter Real K2=0.41 "Bulk threshold parameter"; 
     
    983983          parameter Modelica.SIunits.Length dW=-2.5e-6 "Narrowing of channel"; 
    984984          parameter Modelica.SIunits.Length dL=-2.1e-6 "Shortening of channel"; 
    985           parameter Modelica.SIunits.Resistance RDS=1.e+7 
     985          parameter Modelica.SIunits.Resistance RDS=1.e+7  
    986986      "Drain-Source-Resistance"; 
    987           parameter Modelica.SIunits.Temperature Tnom=300.15 
     987          parameter Modelica.SIunits.Temperature Tnom=300.15  
    988988      "Parameter measurement temperature"; 
    989989          parameter Real kvt=-2.9e-3 "fitting parameter for Vt"; 
    990990          parameter Real kk2=6.2e-4 "fitting parameter for Kk2"; 
    991   protected 
     991  protected  
    992992          Real v; 
    993993          Real uds; 
     
    10931093            lineColor={0,0,255}), 
    10941094          Line(points={{0,-95},{0,-50}}, color={191,0,0})})); 
    1095         equation 
     1095        equation  
    10961096          assert(L + dL > 0, "Effective length must be positive"); 
    10971097          assert(W + dW > 0, "Effective width  must be positive"); 
     
    10991099          gds = if (RDS < 1.e-20 and RDS > -1.e-20) then 1.e20 else 1/RDS; 
    11001100          v = beta_t*(W + dW)/(L + dL); 
    1101           ud = if (D.v > S.v) then S.v else D.v; 
    1102           us = if (D.v > S.v) then D.v else S.v; 
     1101          ud = noEvent(smooth(0,if (D.v > S.v) then S.v else D.v)); 
     1102          us = noEvent(smooth(0,if (D.v > S.v) then D.v else S.v)); 
    11031103          uds = ud - us; 
    1104           ubs = if (B.v < us) then 0 else B.v - us; 
     1104          ubs = noEvent(smooth(0,if (B.v < us) then 0 else B.v - us)); 
    11051105          ugst = (G.v - us - vt_t + k2_t*ubs)*K5; 
    1106           id = if (ugst >= 0) then uds*gds else if (ugst < uds) then -v*uds*( 
    1107             ugst - uds/2) + uds*gds else -v*ugst*ugst/2 + uds*gds; 
    1108  
     1106          id = noEvent(smooth(0,if (ugst >= 0) then uds*gds else if (ugst < uds) then -v*uds*( 
     1107            ugst - uds/2) + uds*gds else -v*ugst*ugst/2 + uds*gds)); 
     1108     
    11091109          beta_t = Beta*pow((heatPort.T/Tnom), -1.5); 
    11101110          vt_t = Vt*(1 + (heatPort.T - Tnom)*kvt); 
    11111111          k2_t = K2*(1 + (heatPort.T - Tnom)*kk2); 
    1112  
     1112     
    11131113          G.i = 0; 
    1114           D.i = if (D.v > S.v) then -id else id; 
    1115           S.i = if (D.v > S.v) then id else -id; 
     1114          D.i = noEvent(smooth(0,if (D.v > S.v) then -id else id)); 
     1115          S.i = noEvent(smooth(0,if (D.v > S.v) then id else -id)); 
    11161116          B.i = 0; 
    11171117          heatPort.Q_flow = -D.i*(D.v - S.v); 
    11181118        end HeatingPMOS; 
    1119  
    1120         model HeatingNPN 
    1121     "Simple NPN BJT according to Ebers-Moll with heating port" 
     1119   
     1120        model HeatingNPN  
     1121    "Simple NPN BJT according to Ebers-Moll with heating port"  
    11221122          parameter Real Bf=50 "Forward beta"; 
    11231123          parameter Real Br=0.1 "Reverse beta"; 
    1124           parameter Modelica.SIunits.Current Is=1.e-16 
     1124          parameter Modelica.SIunits.Current Is=1.e-16  
    11251125      "Transport saturation current"; 
    1126           parameter Modelica.SIunits.InversePotential Vak=0.02 
     1126          parameter Modelica.SIunits.InversePotential Vak=0.02  
    11271127      "Early voltage (inverse), 1/Volt"; 
    1128           parameter Modelica.SIunits.Time Tauf=0.12e-9 
     1128          parameter Modelica.SIunits.Time Tauf=0.12e-9  
    11291129      "Ideal forward transit time"; 
    1130           parameter Modelica.SIunits.Time Taur=5e-9 
     1130          parameter Modelica.SIunits.Time Taur=5e-9  
    11311131      "Ideal reverse transit time"; 
    1132           parameter Modelica.SIunits.Capacitance Ccs=1e-12 
     1132          parameter Modelica.SIunits.Capacitance Ccs=1e-12  
    11331133      "Collector-substrat(ground) cap."; 
    1134           parameter Modelica.SIunits.Capacitance Cje=0.4e-12 
     1134          parameter Modelica.SIunits.Capacitance Cje=0.4e-12  
    11351135      "Base-emitter zero bias depletion cap."; 
    1136           parameter Modelica.SIunits.Capacitance Cjc=0.5e-12 
     1136          parameter Modelica.SIunits.Capacitance Cjc=0.5e-12  
    11371137      "Base-coll. zero bias depletion cap."; 
    1138           parameter Modelica.SIunits.Voltage Phie=0.8 
     1138          parameter Modelica.SIunits.Voltage Phie=0.8  
    11391139      "Base-emitter diffusion voltage"; 
    11401140          parameter Real Me=0.4 "Base-emitter gradation exponent"; 
    1141           parameter Modelica.SIunits.Voltage Phic=0.8 
     1141          parameter Modelica.SIunits.Voltage Phic=0.8  
    11421142      "Base-collector diffusion voltage"; 
    11431143          parameter Real Mc=0.333 "Base-collector gradation exponent"; 
    1144           parameter Modelica.SIunits.Conductance Gbc=1e-15 
     1144          parameter Modelica.SIunits.Conductance Gbc=1e-15  
    11451145      "Base-collector conductance"; 
    1146           parameter Modelica.SIunits.Conductance Gbe=1e-15 
     1146          parameter Modelica.SIunits.Conductance Gbe=1e-15  
    11471147      "Base-emitter conductance"