IdealDiode

model IdealDiode "Multiphase ideal diode"
    extends Interfaces.TwoPlug;

    parameter Modelica.SIunits.Resistance Ron[m](final min = zeros(m), start = fill(1e-5, m)) "Closed diode resistance";
    parameter Modelica.SIunits.Conductance Goff[m](final min = zeros(m), start = fill(1e-5, m)) "Opened diode conductance";
    parameter Modelica.SIunits.Voltage Vknee[m](final min = zeros(m), start = zeros(m)) "Threshold voltage";

    extends Modelica.Electrical.MultiPhase.Interfaces.ConditionalHeatPort(final mh = m, final T = fill(293.15, m));

    Modelica.Electrical.Analog.Ideal.IdealDiode idealDiode[m](final Ron = Ron, final Goff = Goff, final Vknee = Vknee, each final useHeatPort = useHeatPort) annotation (Placement(transformation(extent = {
        {-10, -10}, 
        {10, 10}})));
equation
    connect(plug_p.pin,idealDiode.p) annotation (Line(
        points = {
            {-100, 0}, 
            {-10, 0}},
        color = {0, 0, 255}));
    connect(idealDiode.n,plug_n.pin) annotation (Line(
        points = {
            {10, 0}, 
            {100, 0}},
        color = {0, 0, 255}));
    connect(idealDiode.heatPort,heatPort) annotation (Line(
        points = {
            {0, -10}, 
            {0, -100}},
        color = {191, 0, 0}));

    annotation (
        defaultComponentName = "diode",
        Icon(
            coordinateSystem(
                preserveAspectRatio = false,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    points = {
                        {-90, 0}, 
                        {40, 0}},
                    color = {0, 0, 255}), 
                Polygon(
                    points = {
                        {30, 0}, 
                        {-30, 40}, 
                        {-30, -40}, 
                        {30, 0}},
                    lineColor = {0, 0, 255},
                    fillColor = {255, 255, 255}), 
                Line(
                    points = {
                        {30, 40}, 
                        {30, -40}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {40, 0}, 
                        {90, 0}},
                    color = {0, 0, 255}), 
                Text(
                    extent = {
                        {-150, -80}, 
                        {150, -40}},
                    textString = "m=%m"), 
                Text(
                    extent = {
                        {-150, 90}, 
                        {150, 50}},
                    textString = "%name",
                    lineColor = {0, 0, 255})}),
        Documentation(info = "<html>\n<p>\nContains m ideal diodes (Modelica.Electrical.Analog.Ideal.IdealDiode).\n</p>\n</html>"));
end IdealDiode;