HeatingPMOS

model HeatingPMOS "Simple PMOS 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 = 1.05e-5 "Transconductance parameter";
    parameter SI.Voltage Vt = -1 "Zero bias threshold voltage";
    parameter Real K2 = 0.41 "Bulk threshold parameter";
    parameter Real K5 = 0.839 "Reduction of pinch-off region";
    parameter SI.Length dW = -2.5e-6 "Narrowing of channel";
    parameter SI.Length dL = -2.1e-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.0029 "Fitting parameter for Vt";
    parameter Real kk2 = 6.2e-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, "HeatingPMOS: Effective length must be positive");
    assert(0 < W + dW, "HeatingPMOS: Effective width  must be positive");
    assert(0 < T_heatPort, "HeatingPMOS: 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 0 <= ugst then uds * gds else if ugst < uds 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 B.v < us then 0 else B.v - us);
    ud = smooth(0, if S.v < D.v then S.v else D.v);
    uds = ud - us;
    ugst = (G.v - us - vt_t + k2_t * ubs) * K5;
    us = smooth(0, if S.v < D.v then D.v else S.v);
    vt_t = Vt * (1 + (T_heatPort - Tnom) * kvt);
    B.i = 0;
    D.i = smooth(0, if S.v < D.v then -id else id);
    G.i = 0;
    S.i = smooth(0, if S.v < D.v then id else -id);

    annotation (
        defaultComponentName = "pMOS",
        Documentation(
            info = "<html>\n<p>The PMOS model is a simple model of a p-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.</p>\n<dl><dt><strong>References:</strong> </dt>\n<dd>Spiro, H.: Simulation integrierter Schaltungen. R. Oldenbourg Verlag Muenchen Wien 1990. </dd>\n</dl><p>Some typical parameter sets are:</p>\n<pre>\n  W       L      Beta        Vt    K2     K5      DW       DL\n  m       m      A/V^2       V     -      -       m        m\n  50.e-6  8.e-6  0.0085e-3  -0.15  0.41   0.839  -3.8e-6  -4.0e-6\n  20.e-6  6.e-6  0.0105e-3  -1.0   0.41   0.839  -2.5e-6  -2.1e-6\n  30.e-6  5.e-6  0.0059e-3  -0.3   0.98   1.01    0       -3.9e-6\n  30.e-6  5.e-6  0.0152e-3  -0.69  0.104  1.1    -0.8e-6  -0.4e-6\n  30.e-6  5.e-6  0.0163e-3  -0.69  0.104  1.1    -0.8e-6  -0.4e-6\n  30.e-6  5.e-6  0.0182e-3  -0.69  0.086  1.06   -0.1e-6  -0.6e-6\n  20.e-6  6.e-6  0.0074e-3  -1.    0.4    0.59    0        0\n</pre>\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 = {
                        {60, 0}, 
                        {40, 5}, 
                        {40, -5}, 
                        {60, 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 HeatingPMOS;