VariableInductor

model VariableInductor "Ideal linear electrical inductor with variable inductance"
    extends Modelica.Electrical.Analog.Interfaces.OnePort;

    Modelica.Blocks.Interfaces.RealInput L(unit = "H") annotation (Placement(
        transformation(
            origin = {0, 120},
            extent = {
                {-20, -20}, 
                {20, 20}},
            rotation = 270),
        iconTransformation(
            extent = {
                {-20, -20}, 
                {20, 20}},
            rotation = 270,
            origin = {0, 120})));
    SI.MagneticFlux Psi;
    parameter SI.Inductance Lmin = Modelica.Constants.eps "lower bound for variable inductance";
    parameter SI.Current IC = 0 "Initial Value";
    parameter Boolean UIC = false;
initial equation
    if UIC then 
        i = IC;
    end if;
equation
    assert(0 <= L, "Inductance L_ (= " + String(L) + ") has to be >= 0!");
    v = der(Psi);
    Psi = noEvent(max(L, Lmin)) * i;

    annotation (
        defaultComponentName = "inductor",
        Documentation(
            info = "<html>\n<p>The linear inductor connects the branch voltage <em>v</em> with the branch current <em>i</em> by\n<br><em><strong>v = d Psi/dt </strong></em>with <em><strong>Psi = L * i </strong></em>.\n<br>The inductance <em>L</em> is as input signal.\nIt is required that L &ge; 0, otherwise an assertion is raised. To avoid a variable index system, L = Lmin, if 0 &le; L &lt; Lmin, where Lmin is a parameter with default value Modelica.Constants.eps.</p>\n<p>Besides the Lmin parameter the inductor model has got the two parameters IC and UIC that belong together. With the IC parameter the user can specify an initial value of the current that flows through the inductor.</p>\n<p><br/>Hence the inductor has an initial current at the beginning of the simulation. The other parameter UIC is of type Boolean. If UIC is true, the simulation tool uses</p>\n<p><br/>the IC value at the initial calculation by adding the equation i= IC. If UIC is false, the IC value can be used (but it does not need to!) to calculate the initial values in order to simplify the numerical algorithms of initial calculation.</p>\n</html>",
            revisions = "<html>\n<ul>\n<li><em>June 7, 2004   </em>\n       by Christoph Clauss<br>changed, docu added<br>\n       </li>\n<li><em>April 30, 2004</em>\n       by Anton Haumer<br>implemented.\n       </li>\n</ul>\n</html>"),
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    points = {
                        {-90, 0}, 
                        {-60, 0}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {60, 0}, 
                        {90, 0}},
                    color = {0, 0, 255}), 
                Text(
                    extent = {
                        {-150, 90}, 
                        {150, 50}},
                    textString = "%name",
                    lineColor = {0, 0, 255}), 
                Line(
                    points = {
                        {-60, 0}, 
                        {-59, 6}, 
                        {-52, 14}, 
                        {-38, 14}, 
                        {-31, 6}, 
                        {-30, 0}},
                    color = {0, 0, 255},
                    smooth = Smooth.Bezier), 
                Line(
                    points = {
                        {-30, 0}, 
                        {-29, 6}, 
                        {-22, 14}, 
                        {-8, 14}, 
                        {-1, 6}, 
                        {0, 0}},
                    color = {0, 0, 255},
                    smooth = Smooth.Bezier), 
                Line(
                    points = {
                        {0, 0}, 
                        {1, 6}, 
                        {8, 14}, 
                        {22, 14}, 
                        {29, 6}, 
                        {30, 0}},
                    color = {0, 0, 255},
                    smooth = Smooth.Bezier), 
                Line(
                    points = {
                        {30, 0}, 
                        {31, 6}, 
                        {38, 14}, 
                        {52, 14}, 
                        {59, 6}, 
                        {60, 0}},
                    color = {0, 0, 255},
                    smooth = Smooth.Bezier)}));
end VariableInductor;