PermanentMagnetLosses

model PermanentMagnetLosses "Model of permanent magnet losses dependent on current and speed"
    import Modelica.Electrical.QuasiStationary.MultiPhase.Functions.quasiRMS;

    extends Modelica.Electrical.Machines.Interfaces.FlangeSupport;

    parameter Integer m(min = 1) = 3 "Number of phases";
    parameter Modelica.Electrical.Machines.Losses.PermanentMagnetLossParameters permanentMagnetLossParameters "Permanent magnet loss parameters";

    extends Modelica.Thermal.HeatTransfer.Interfaces.PartialElementaryConditionalHeatPortWithoutT(useHeatPort = false);

    input Modelica.SIunits.ComplexCurrent is[m] "Instantaneous stator currents";
    Modelica.SIunits.Current iRMS = quasiRMS(is);
equation
    if permanentMagnetLossParameters.PRef <= 0 then 
        tau = 0;
    else 
        tau = -permanentMagnetLossParameters.tauRef * (permanentMagnetLossParameters.c + (1 - permanentMagnetLossParameters.c) * (iRMS / permanentMagnetLossParameters.IRef) ^ permanentMagnetLossParameters.power_I) * sign(w) * (abs(w) / permanentMagnetLossParameters.wRef) ^ permanentMagnetLossParameters.power_w;
    end if;
    lossPower = -tau * w;

    annotation (
        defaultComponentName = "magnetLoss",
        Icon(graphics = {
            Ellipse(
                extent = {
                    {-40, -40}, 
                    {40, 40}},
                lineColor = {200, 0, 0})}),
        Documentation(info = "<html>\n<p>\nPermanent magnet losses are modeled dependent on current and speed.\n</p>\n<p>\nThe permanent magnet losses are modeled such way that they do not cause a voltage drop in the electric circuit.\nInstead, the dissipated losses are considered through an equivalent braking torque at the shaft.\n</p>\n<p>\nThe permanent magnet loss torque is\n</p>\n<pre>\n  tau = PRef/wRef * (c + (1 - c) * (i/IRef)^power_I) * (w/wRef)^power_w\n</pre>\n<p>\nwhere <code>i</code> is the current of the machine and <code>w</code> is the actual angular velocity.\nThe parameter <code>c</code> designates the part of the permanent magnet losses that are present even at current = 0, i.e. independent of current.\nThe dependency of the permanent magnet loss torque on the stator current is modeled by the exponent <code>power_I</code>.\nThe dependency of the permanent magnet loss torque on the angular velocity is modeled by the exponent <code>power_w</code>.\n</p>\n<h4>See also</h4>\n<p>\n<a href=\"modelica://Modelica.Electrical.Machines.Losses.PermanentMagnetLossParameters\">Permanent magnet loss parameters</a>\n</p>\n<p>\nIf it is desired to neglect permanent magnet losses, set <code>strayLoadParameters.PRef = 0</code> (this is the default).\n</p>\n</html>"));
end PermanentMagnetLosses;