IdealTransformer

model IdealTransformer "Ideal transformer core with or without magnetization"
    extends Modelica.Electrical.Analog.Interfaces.TwoPort;

    parameter Real n(start = 1) "Turns ratio primary:secondary voltage";
    parameter Boolean considerMagnetization = false "Choice of considering magnetization";
    parameter SI.Inductance Lm1(start = 1) "Magnetization inductance w.r.t. primary side"
        annotation (Dialog(enable = considerMagnetization));
protected
    SI.Current im1 "Magnetization current w.r.t. primary side";
    SI.MagneticFlux psim1 "Magnetic flux w.r.t. primary side";
equation
    if considerMagnetization then 
        psim1 = Lm1 * im1;
        v1 = der(psim1);
    else 
        psim1 = 0;
        im1 = 0;
    end if;
    im1 = i1 + i2 / n;
    v1 = n * v2;

    annotation (
        defaultComponentName = "transformer",
        Documentation(
            info = "<html>\n<p>\nThe ideal transformer is a two-port circuit element;\nin case of Boolean parameter <code>considerMagnetization = false</code> it is characterized by the following equations:\n</p>\n<pre> i2 = -i1*n;\n v2 =  v1/n;\n</pre>\n<p>\nwhere <code>n</code> is a real number called the turns ratio.\nDue to this equations, also DC voltages and currents are transformed - which is not the case for technical transformers.\n</p>\n<p>\nIn case of Boolean parameter <code>considerMagnetization = true</code> it is characterized by the following equations:\n</p>\n<pre>\n im1  = i1 + i2/n \"Magnetizing current w.r.t. primary side\";\n psim1= Lm1*im1   \"Magnetic flux w.r.t. primary side\";\n v1 = der(psim1)  \"Primary voltage\";\n v2 = v1/n        \"Secondary voltage\";\n</pre>\n<p>\nwhere <code>Lm</code> denotes the magnetizing inductance.\nDue to this equations, the DC offset of secondary voltages and currents decrement according to the time constant defined by the connected circuit.\n</p>\n<p>\nTaking primary <code>L1sigma</code> and secondary <code>L2ssigma</code> leakage inductances into account,\ncompared with the <a href=\"modelica://Modelica.Electrical.Analog.Basic.Transformer\">basic transformer</a>\nthe following parameter conversion can be applied (which leads to identical results):\n</p>\n<pre>\n L1 = L1sigma + M*n \"Primary inductance at secondary no-load\";\n L2 = L2sigma + M/n \"Secondary inductance at primary no-load\";\n  M  = Lm1/n         \"Mutual inductance\";\n</pre>\n<p>\nFor the backward conversion, one has to decide about the partitioning of the leakage to primary and secondary side.\n</p>\n</html>",
            revisions = "<html>\n<ul>\n<li><em>June 3, 2009   </em>\n       magnetisation current added by Anton Haumer<br>\n       </li>\n<li><em>1998   </em>\n       initially implemented by Christoph Clauss<br>\n       </li>\n</ul>\n</html>"),
        Icon(
            coordinateSystem(
                preserveAspectRatio = false,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Text(
                    extent = {
                        {-150, -110}, 
                        {150, -150}},
                    textString = "n=%n"), 
                Text(
                    extent = {
                        {-100, 20}, 
                        {-60, -20}},
                    lineColor = {0, 0, 255},
                    textString = "1"), 
                Text(
                    extent = {
                        {60, 20}, 
                        {100, -20}},
                    lineColor = {0, 0, 255},
                    textString = "2"), 
                Text(
                    extent = {
                        {-150, 150}, 
                        {150, 110}},
                    textString = "%name",
                    lineColor = {0, 0, 255}), 
                Line(
                    points = {
                        {-40, 60}, 
                        {-40, 100}, 
                        {-90, 100}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {40, 60}, 
                        {40, 100}, 
                        {90, 100}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {-40, -60}, 
                        {-40, -100}, 
                        {-90, -100}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {40, -60}, 
                        {40, -100}, 
                        {90, -100}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {-15, -7}, 
                        {-14, -1}, 
                        {-7, 7}, 
                        {7, 7}, 
                        {14, -1}, 
                        {15, -7}},
                    color = {0, 0, 255},
                    smooth = Smooth.Bezier,
                    origin = {-33, 45},
                    rotation = 270), 
                Line(
                    points = {
                        {-15, -7}, 
                        {-14, -1}, 
                        {-7, 7}, 
                        {7, 7}, 
                        {14, -1}, 
                        {15, -7}},
                    color = {0, 0, 255},
                    smooth = Smooth.Bezier,
                    origin = {-33, 15},
                    rotation = 270), 
                Line(
                    points = {
                        {-15, -7}, 
                        {-14, -1}, 
                        {-7, 7}, 
                        {7, 7}, 
                        {14, -1}, 
                        {15, -7}},
                    color = {0, 0, 255},
                    smooth = Smooth.Bezier,
                    origin = {-33, -15},
                    rotation = 270), 
                Line(
                    points = {
                        {-15, -7}, 
                        {-14, -1}, 
                        {-7, 7}, 
                        {7, 7}, 
                        {14, -1}, 
                        {15, -7}},
                    color = {0, 0, 255},
                    smooth = Smooth.Bezier,
                    origin = {-33, -45},
                    rotation = 270), 
                Line(
                    points = {
                        {-15, -7}, 
                        {-14, -1}, 
                        {-7, 7}, 
                        {7, 7}, 
                        {14, -1}, 
                        {15, -7}},
                    color = {0, 0, 255},
                    smooth = Smooth.Bezier,
                    origin = {33, 45},
                    rotation = 90), 
                Line(
                    points = {
                        {-15, -7}, 
                        {-14, -1}, 
                        {-7, 7}, 
                        {7, 7}, 
                        {14, -1}, 
                        {15, -7}},
                    color = {0, 0, 255},
                    smooth = Smooth.Bezier,
                    origin = {33, 15},
                    rotation = 90), 
                Line(
                    points = {
                        {-15, -7}, 
                        {-14, -1}, 
                        {-7, 7}, 
                        {7, 7}, 
                        {14, -1}, 
                        {15, -7}},
                    color = {0, 0, 255},
                    smooth = Smooth.Bezier,
                    origin = {33, -15},
                    rotation = 90), 
                Line(
                    points = {
                        {-15, -7}, 
                        {-14, -1}, 
                        {-7, 7}, 
                        {7, 7}, 
                        {14, -1}, 
                        {15, -7}},
                    color = {0, 0, 255},
                    smooth = Smooth.Bezier,
                    origin = {33, -45},
                    rotation = 90)}));
end IdealTransformer;