NMOS

model NMOS "Simple MOS Transistor"
    Interfaces.Pin D "Drain"
        annotation (Placement(
            transformation(extent = {
                {90, 50}, 
                {110, 70}}),
            iconTransformation(extent = {
                {90, 50}, 
                {110, 70}})));
    Interfaces.Pin G "Gate"
        annotation (Placement(
            transformation(extent = {
                {-90, -50}, 
                {-110, -70}}),
            iconTransformation(extent = {
                {-90, -50}, 
                {-110, -70}})));
    Interfaces.Pin S "Source"
        annotation (Placement(
            transformation(extent = {
                {90, -50}, 
                {110, -70}}),
            iconTransformation(extent = {
                {90, -50}, 
                {110, -70}})));
    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";

    extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(T = 293.15);

protected
    Real v;
    Real uds;
    Real ubs;
    Real ugst;
    Real ud;
    Real us;
    Real id;
    Real gds;
equation
    assert(0 < L + dL, "NMOS: Effective length must be positive");
    assert(0 < W + dW, "NMOS: Effective width  must be positive");
    v = Beta * (W + dW) / (L + dL);
    LossPower = D.i * (D.v - S.v);
    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);
    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 + K2 * ubs) * K5;
    us = if D.v < S.v then D.v else S.v;
    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 (
        Documentation(
            info = "<html>\n<p>\nThe NMOS model is a simple model of a n-channel metal-oxide semiconductor\nFET. It differs slightly from the device used in the SPICE simulator.\nFor more details please care for H. Spiro.\n</p>\n<p>\nThe model does not consider capacitances. A high drain-source resistance RDS\nis included to avoid numerical difficulties.\n<br><br>\n<strong>Please note:</strong>\nIn case of useHeatPort=true the temperature dependence of the electrical\nbehavior is <strong>not</strong> modelled yet. The parameters are not temperature dependent.\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\n<dl>\n<dt><strong>References:</strong></dt>\n<dd>Spiro, H.: Simulation integrierter Schaltungen. R. Oldenbourg Verlag\nMuenchen Wien 1990.</dd>\n</dl>\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> 1998   </em>\n       by Christoph Clauss<br> initially 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}), 
                Line(
                    visible = useHeatPort,
                    points = {
                        {0, -100}, 
                        {0, 0}},
                    color = {127, 0, 0},
                    pattern = LinePattern.Dot), 
                Text(
                    extent = {
                        {-150, 130}, 
                        {150, 90}},
                    textString = "%name",
                    lineColor = {0, 0, 255})}));
end NMOS;