NPN

model NPN "Simple BJT according to Ebers-Moll"
    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 SI.Voltage Vt = 0.02585 "Voltage equivalent of temperature";
    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.Voltage IC = 0 "Initial value"
        annotation (Dialog(enable = UIC));
    parameter Boolean UIC = false "Decision if initial value should be used";

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

    SI.Voltage vbc "Base-collector voltage";
    SI.Voltage vbe "Base-emitter voltage";
    Real qbk "Relative majority carrier charge, inverse";
    SI.Current ibc "Base-collector diode current";
    SI.Current ibe "Base-emitter diode current";
    SI.Capacitance cbc "Total base-collector capacitance";
    SI.Capacitance cbe "Total base-emitter capacitance";
    SI.Capacitance Capcje "Effective base-emitter depletion capacitance";
    SI.Capacitance Capcjc "Effective base-collector depletion capacitance";
    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}})));
initial equation
    if UIC then 
        C.v = IC;
    end if;
equation
    Capcjc = smooth(1, Cjc * powlin(vbc / Phic, Mc));
    Capcje = smooth(1, Cje * powlin(vbe / Phie, Me));
    LossPower = (C.v - E.v) * (ibe - ibc) * qbk + vbc * ibc / Br + vbe * ibe / Bf;
    cbc = smooth(1, Taur * Is / Vt * exlin2(vbc / Vt, EMin, EMax) + Capcjc);
    cbe = smooth(1, Tauf * Is / Vt * exlin2(vbe / Vt, EMin, EMax) + Capcje);
    ibc = smooth(1, Is * (exlin2(vbc / Vt, EMin, EMax) - 1) + vbc * Gbc);
    ibe = smooth(1, Is * (exlin2(vbe / Vt, EMin, EMax) - 1) + vbe * Gbe);
    qbk = 1 - vbc * Vak;
    vbc = B.v - C.v;
    vbe = B.v - E.v;
    B.i = ibe / Bf + ibc / Br + cbc * der(vbc) + cbe * der(vbe);
    C.i = (ibe - ibc) * qbk - ibc / Br - cbc * der(vbc) + Ccs * der(C.v);
    E.i = -B.i - C.i + Ccs * der(C.v);

    annotation (
        Documentation(
            info = "<html>\n<p>\nThis model is a simple model of a bipolar NPN junction transistor according\nto Ebers-Moll.\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<p>\nA typical parameter set is:\n</p>\n<pre>\n  Bf  Br  Is     Vak  Tauf    Taur  Ccs   Cje     Cjc     Phie  Me   PHic   Mc     Gbc    Gbe    Vt\n  -   -   A      V    s       s     F     F       F       V     -    V      -      mS     mS     V\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  0.02585\n</pre>\n<dl>\n<dt><strong>References:</strong></dt>\n<dd>Vlach, J.; Singal, K.: Computer methods for circuit analysis and design.\nVan Nostrand Reinhold, New York 1983\non page 317 ff.</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\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 = {
                        {-20, 40}, 
                        {-20, -40}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {-20, 0}, 
                        {-100, 0}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {90, 60}, 
                        {30, 60}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {30, 60}, 
                        {-20, 10}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {-20, -10}, 
                        {20, -50}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {30, -60}, 
                        {91, -60}},
                    color = {0, 0, 255}), 
                Polygon(
                    points = {
                        {30, -60}, 
                        {24, -46}, 
                        {16, -54}, 
                        {30, -60}},
                    fillColor = {0, 0, 255},
                    fillPattern = FillPattern.Solid,
                    lineColor = {0, 0, 255}), 
                Line(
                    visible = useHeatPort,
                    points = {
                        {0, -100}, 
                        {0, -20}},
                    color = {127, 0, 0},
                    pattern = LinePattern.Dot), 
                Text(
                    extent = {
                        {-150, 130}, 
                        {150, 90}},
                    textString = "%name",
                    lineColor = {0, 0, 255})}));
end NPN;