Diode

model Diode "Simple diode"
    extends Modelica.Electrical.Analog.Interfaces.OnePort;

    parameter SI.Current Ids = 1e-6 "Saturation current";
    parameter SI.Voltage Vt = 0.04 "Voltage equivalent of temperature (kT/qn)";
    parameter Real Maxexp(final min = Modelica.Constants.small) = 15 "Max. exponent for linear continuation";
    parameter SI.Resistance R = 1e+8 "Parallel ohmic resistance";

    extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(T = 293.15);
equation
    i = smooth(1, Ids * (exlin(v / Vt, Maxexp) - 1) + v / R);
    LossPower = v * i;

    annotation (
        defaultComponentName = "diode",
        Documentation(
            info = "<html>\n<p>The simple diode is a one port. It consists of the diode itself and an parallel ohmic resistance <em>R</em>. The diode formula is:</p>\n<pre>                v/vt\n  i  =  ids ( e      - 1).</pre>\n<p>If the exponent <em>v/vt</em> reaches the limit <em>maxex</em>, the diode characteristic is linearly continued to avoid overflow.</p><p><strong>Please note:</strong> In case of useHeatPort=true the temperature dependence of the electrical behavior is <strong>not</strong> modelled yet. The parameters are not temperature dependent.</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> November 15, 2005   </em>\n       by Christoph Clauss<br> smooth function added<br>\n       </li>\n<li><em> 1998   </em>\n       by Christoph Clauss<br> implemented<br>\n       </li>\n</ul>\n</html>"),
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Polygon(
                    points = {
                        {30, 0}, 
                        {-30, 40}, 
                        {-30, -40}, 
                        {30, 0}},
                    lineColor = {0, 0, 255},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid), 
                Line(
                    points = {
                        {-90, 0}, 
                        {40, 0}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {40, 0}, 
                        {90, 0}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {30, 40}, 
                        {30, -40}},
                    color = {0, 0, 255}), 
                Text(
                    extent = {
                        {-150, -40}, 
                        {150, -80}},
                    textString = "Vt=%Vt"), 
                Text(
                    extent = {
                        {-150, 90}, 
                        {150, 50}},
                    textString = "%name",
                    lineColor = {0, 0, 255}), 
                Line(
                    visible = useHeatPort,
                    points = {
                        {0, -100}, 
                        {0, -20}},
                    color = {127, 0, 0},
                    pattern = LinePattern.Dot)}));
end Diode;