HeatingPNP

model HeatingPNP "Simple PNP BJT according to Ebers-Moll with heating port"
    parameter Real Bf = 50 "Forward beta";
    parameter Real Br = 0.1 "Reverse beta";
    parameter SI.Current Is = 1e-16 "Transport saturation current";
    parameter SI.InversePotential Vak = 0.02 "Early voltage (inverse), 1/Volt";
    parameter SI.Time Tauf = 1.2e-10 "Ideal forward transit time";
    parameter SI.Time Taur = 5e-9 "Ideal reverse transit time";
    parameter SI.Capacitance Ccs = 1e-12 "Collector-substrate(ground) cap.";
    parameter SI.Capacitance Cje = 4e-13 "Base-emitter zero bias depletion cap.";
    parameter SI.Capacitance Cjc = 5e-13 "Base-coll. zero bias depletion cap.";
    parameter SI.Voltage Phie = 0.8 "Base-emitter diffusion voltage";
    parameter Real Me = 0.4 "Base-emitter gradation exponent";
    parameter SI.Voltage Phic = 0.8 "Base-collector diffusion voltage";
    parameter Real Mc = 0.333 "Base-collector gradation exponent";
    parameter SI.Conductance Gbc = 1e-15 "Base-collector conductance";
    parameter SI.Conductance Gbe = 1e-15 "Base-emitter conductance";
    parameter Real EMin = -100 "if x < EMin, the exp(x) function is linearized";
    parameter Real EMax = 40 "if x > EMax, the exp(x) function is linearized";
    parameter SI.Temperature Tnom = 300.15 "Parameter measurement temperature";
    parameter Real XTI = 3 "Temperature exponent for effect on Is";
    parameter Real XTB = 0 "Forward and reverse beta temperature exponent";
    parameter SI.Voltage EG = 1.11 "Energy gap for temperature effect on Is";
    parameter Real NF = 1 "Forward current emission coefficient";
    parameter Real NR = 1 "Reverse current emission coefficient";

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

    SI.Voltage vcb "Collector-base voltage";
    SI.Voltage veb "Emitter-base voltage";
    Real qbk "Relative majority carrier charge, inverse";
    SI.Current icb "Collector-base diode current";
    SI.Current ieb "Emitter-base diode current";
    SI.Capacitance ccb "Total collector-base capacitance";
    SI.Capacitance ceb "Total emitter-base capacitance";
    SI.Capacitance Capcje "Effective emitter-base depletion capacitance";
    SI.Capacitance Capcjc "Effective collector-base depletion capacitance";
    SI.Current is_t "Temperature dependent transport saturation current";
    Real br_t "Temperature dependent forward beta";
    Real bf_t "Temperature dependent reverse beta";
    SI.Voltage vt_t "Voltage equivalent of effective temperature";
    Real hexp "Auxiliary quantity temperature dependent exponent";
    Real htempexp "Auxiliary quantity exp(hexp)";
    Modelica.Electrical.Analog.Interfaces.Pin C "Collector"
        annotation (Placement(
            transformation(extent = {
                {90, 50}, 
                {110, 70}}),
            iconTransformation(extent = {
                {90, 50}, 
                {110, 70}})));
    Modelica.Electrical.Analog.Interfaces.Pin B "Base"
        annotation (Placement(transformation(extent = {
            {-90, -10}, 
            {-110, 10}})));
    Modelica.Electrical.Analog.Interfaces.Pin E "Emitter"
        annotation (Placement(
            transformation(extent = {
                {90, -50}, 
                {110, -70}}),
            iconTransformation(extent = {
                {90, -50}, 
                {110, -70}})));
equation
    assert(0 < T_heatPort, "Temperature must be positive");
    Capcjc = smooth(1, Cjc * powlin(vcb / Phic, Mc));
    Capcje = smooth(1, Cje * powlin(veb / Phie, Me));
    LossPower = vcb * icb / br_t + veb * ieb / bf_t + (icb - ieb) * qbk * (C.v - E.v);
    bf_t = Bf * pow(T_heatPort / Tnom, XTB);
    br_t = Br * pow(T_heatPort / Tnom, XTB);
    ccb = smooth(1, Taur * is_t / (NR * vt_t) * exlin2(vcb / (NR * vt_t), EMin, EMax) + Capcjc);
    ceb = smooth(1, Tauf * is_t / (NF * vt_t) * exlin2(veb / (NF * vt_t), EMin, EMax) + Capcje);
    hexp = (T_heatPort / Tnom - 1) * EG / vt_t;
    htempexp = smooth(1, exlin2(hexp, EMin, EMax));
    icb = smooth(1, is_t * (exlin2(vcb / (NR * vt_t), EMin, EMax) - 1) + vcb * Gbc);
    ieb = smooth(1, is_t * (exlin2(veb / (NF * vt_t), EMin, EMax) - 1) + veb * Gbe);
    is_t = Is * pow(T_heatPort / Tnom, XTI) * htempexp;
    qbk = 1 - vcb * Vak;
    vcb = C.v - B.v;
    veb = E.v - B.v;
    vt_t = k / q * T_heatPort;
    B.i = -ieb / bf_t - icb / br_t - ceb * der(veb) - ccb * der(vcb);
    C.i = icb / br_t + ccb * der(vcb) + Ccs * der(C.v) + (icb - ieb) * qbk;
    E.i = -B.i - C.i + Ccs * der(C.v);

    annotation (
        defaultComponentName = "pnp",
        Documentation(
            info = "<html>\n<p>This model is a simple model of a bipolar PNP junction transistor according to Ebers-Moll.\n<br>A heating port is added for thermal electric simulation. The heating port is defined in the Modelica.Thermal library.\n<br>A typical parameter set is (the parameter Vt is no longer used):</p>\n<pre>  Bf  Br  Is     Vak  Tauf    Taur  Ccs   Cje     Cjc     Phie  Me   PHic   Mc     Gbc    Gbe\n  -   -   A      V    s       s     F     F       F       V     -    V      -      mS     mS\n  50  0.1 1e-16  0.02 0.12e-9 5e-9  1e-12 0.4e-12 0.5e-12 0.8   0.4  0.8    0.333  1e-15  1e-15</pre>\n<p><strong>References:</strong></p>\n<p>Vlach, J.; Singal, K.: Computer methods for circuit analysis and design. Van Nostrand Reinhold, New York 1983 on page 317 ff.</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>March 20, 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 = {
                        {-20, 40}, 
                        {-20, -40}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {-20, 0}, 
                        {-100, 0}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {91, 60}, 
                        {30, 60}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {30, 60}, 
                        {-20, 10}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {-20, -10}, 
                        {30, -60}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {30, -60}, 
                        {91, -60}},
                    color = {0, 0, 255}), 
                Polygon(
                    points = {
                        {-20, -10}, 
                        {-5, -17}, 
                        {-13, -25}, 
                        {-20, -10}},
                    fillColor = {0, 0, 255},
                    fillPattern = FillPattern.Solid,
                    lineColor = {0, 0, 255}), 
                Text(
                    extent = {
                        {-150, 130}, 
                        {150, 90}},
                    textString = "%name",
                    lineColor = {0, 0, 255})}));
end HeatingPNP;