HeatingNMOS

model HeatingNMOS "Simple MOS Transistor with heating port"
    Modelica.Electrical.Analog.Interfaces.Pin D "Drain"
        annotation (Placement(
            transformation(extent = {
                {90, 50}, 
                {110, 70}}),
            iconTransformation(extent = {
                {90, 50}, 
                {110, 70}})));
    Modelica.Electrical.Analog.Interfaces.Pin G "Gate"
        annotation (Placement(
            transformation(extent = {
                {-90, -50}, 
                {-110, -70}}),
            iconTransformation(extent = {
                {-90, -50}, 
                {-110, -70}})));
    Modelica.Electrical.Analog.Interfaces.Pin S "Source"
        annotation (Placement(
            transformation(extent = {
                {90, -50}, 
                {110, -70}}),
            iconTransformation(extent = {
                {90, -50}, 
                {110, -70}})));
    Modelica.Electrical.Analog.Interfaces.Pin B "Bulk"
        annotation (Placement(transformation(extent = {
            {90, -10}, 
            {110, 10}})));
    parameter SI.Length W = 2e-5 "Width";
    parameter SI.Length L = 6e-6 "Length";
    parameter SI.Transconductance Beta = 4.1e-5 "Transconductance parameter";
    parameter SI.Voltage Vt = 0.8 "Zero bias threshold voltage";
    parameter Real K2 = 1.144 "Bulk threshold parameter";
    parameter Real K5 = 0.7311 "Reduction of pinch-off region";
    parameter SI.Length dW = -2.5e-6 "Narrowing of channel";
    parameter SI.Length dL = -1.5e-6 "Shortening of channel";
    parameter SI.Resistance RDS = 1e+7 "Drain-Source-Resistance";
    parameter SI.Temperature Tnom = 300.15 "Parameter measurement temperature";
    parameter Real kvt = -0.00696 "Fitting parameter for Vt";
    parameter Real kk2 = 6e-4 "Fitting parameter for K2";

    extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(useHeatPort = true);

protected
    Real v;
    Real uds;
    Real ubs;
    Real ugst;
    Real ud;
    Real us;
    Real id;
    Real gds;
    Real beta_t;
    Real vt_t;
    Real k2_t;
equation
    assert(0 < L + dL, "Heating NMOS: Effective length must be positive");
    assert(0 < W + dW, "Heating NMOS: Effective width  must be positive");
    assert(0 < T_heatPort, "Heating NMOS: Temperature must be positive");
    v = beta_t * (W + dW) / (L + dL);
    LossPower = D.i * (D.v - S.v);
    beta_t = Beta * pow(T_heatPort / Tnom, -1.5);
    gds = if RDS < 1e-20 and -1e-20 < RDS then 1e+20 else RDS ^ (-1);
    id = smooth(0, if ugst <= 0 then uds * gds else if uds < ugst then v * uds * (ugst - 0.5 * uds) + uds * gds else 0.5 * (v * ugst * ugst) + uds * gds);
    k2_t = K2 * (1 + (T_heatPort - Tnom) * kk2);
    ubs = smooth(0, if us < B.v then 0 else B.v - us);
    ud = smooth(0, if D.v < S.v then S.v else D.v);
    uds = ud - us;
    ugst = (G.v - us - vt_t + k2_t * ubs) * K5;
    us = smooth(0, if D.v < S.v then D.v else S.v);
    vt_t = Vt * (1 + (T_heatPort - Tnom) * kvt);
    B.i = 0;
    D.i = smooth(0, if D.v < S.v then -id else id);
    G.i = 0;
    S.i = smooth(0, if D.v < S.v then id else -id);

    annotation (
        defaultComponentName = "nMOS",
        Documentation(
            info = "<html>\n<p>The NMOS model is a simple model of a n-channel metal-oxide semiconductor FET. It differs slightly from the device used in the SPICE simulator. For more details please care for H. Spiro.\n<br> A heating port is added for thermal electric simulation. The heating port is defined in the Modelica.Thermal library.\n<br>The model does not consider capacitances. A high drain-source resistance RDS is included to avoid numerical difficulties.\n</p>\n<pre>\n  W       L      Beta         Vt      K2     K5       DW       DL\n  m       m      A/V^2        V       -      -        m        m\n  12.e-6  4.e-6  0.062e-3    -4.5     0.24   0.61    -1.2e-6  -0.9e-6      depletion\n  60.e-6  3.e-6  0.048e-3     0.1     0.08   0.68    -1.2e-6  -0.9e-6      enhancement\n  12.e-6  4.e-6  0.0625e-3   -0.8     0.21   0.78    -1.2e-6  -0.9e-6      zero\n  50.e-6  8.e-6  0.0299e-3    0.24    1.144  0.7311  -5.4e-6  -4.e-6\n  20.e-6  6.e-6  0.041e-3     0.8     1.144  0.7311  -2.5e-6  -1.5e-6\n  30.e-6  9.e-6  0.025e-3    -4.0     0.861  0.878   -3.4e-6  -1.74e-6\n  30.e-6  5.e-6  0.031e-3     0.6     1.5    0.72     0       -3.9e-6\n  50.e-6  6.e-6  0.0414e-3   -3.8     0.34   0.8     -1.6e-6  -2.e-6       depletion\n  50.e-6  5.e-6  0.03e-3      0.37    0.23   0.86    -1.6e-6  -2.e-6       enhancement\n  50.e-6  6.e-6  0.038e-3    -0.9     0.23   0.707   -1.6e-6  -2.e-6       zero\n  20.e-6  4.e-6  0.06776e-3   0.5409  0.065  0.71    -0.8e-6  -0.2e-6\n  20.e-6  4.e-6  0.06505e-3   0.6209  0.065  0.71    -0.8e-6  -0.2e-6\n  20.e-6  4.e-6  0.05365e-3   0.6909  0.03   0.8     -0.3e-6  -0.2e-6\n  20.e-6  4.e-6  0.05365e-3   0.4909  0.03   0.8     -0.3e-6  -0.2e-6\n  12.e-6  4.e-6  0.023e-3    -4.5     0.29   0.6      0        0           depletion\n  60.e-6  3.e-6  0.022e-3     0.1     0.11   0.65     0        0           enhancement\n  12.e-6  4.e-6  0.038e-3    -0.8     0.33   0.6      0        0           zero\n  20.e-6  6.e-6  0.022e-3     0.8     1      0.66     0        0\n</pre>\n<p><strong>References:</strong></p>\n<p>Spiro, H.: Simulation integrierter Schaltungen. R. Oldenbourg Verlag Muenchen Wien 1990.</p>\n</html>",
            revisions = "<html>\n<ul>\n<li><em> March 11, 2009   </em>\n       by Christoph Clauss<br> conditional heat port added<br>\n       </li>\n<li><em>December 7, 2005   </em>\n       by Christoph Clauss<br>\n       error in RDS calculation deleted</li>\n<li><em>March 31, 2004   </em>\n       by Christoph Clauss<br> implemented<br>\n       </li>\n</ul>\n</html>"),
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    points = {
                        {-90, -60}, 
                        {-10, -60}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {-10, -60}, 
                        {-10, 60}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {10, 80}, 
                        {10, 39}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {10, 20}, 
                        {10, -21}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {10, -40}, 
                        {10, -81}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {10, 60}, 
                        {91, 60}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {10, 0}, 
                        {90, 0}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {10, -60}, 
                        {90, -60}},
                    color = {0, 0, 255}), 
                Polygon(
                    points = {
                        {40, 0}, 
                        {60, 5}, 
                        {60, -5}, 
                        {40, 0}},
                    fillColor = {0, 0, 255},
                    fillPattern = FillPattern.Solid,
                    lineColor = {0, 0, 255}), 
                Text(
                    extent = {
                        {-150, 130}, 
                        {150, 90}},
                    textString = "%name",
                    lineColor = {0, 0, 255})}));
end HeatingNMOS;