SM_ElectricalExcited

model SM_ElectricalExcited "Electrical excited synchronous induction machine with damper cage"
    extends Machines.Interfaces.PartialBasicInductionMachine(Lssigma(start = 0.1 / (2 * pi * fsNominal)), final idq_ss = airGapR.i_ss, final idq_sr = airGapR.i_sr, final idq_rs = airGapR.i_rs, final idq_rr = airGapR.i_rr, redeclare final Machines.Thermal.SynchronousInductionMachines.ThermalAmbientSMEE thermalAmbient(final useDamperCage = useDamperCage, final Te = TeOperational, final Tr = TrOperational), redeclare final Machines.Interfaces.InductionMachines.ThermalPortSMEE thermalPort(final useDamperCage = useDamperCage), redeclare final Machines.Interfaces.InductionMachines.ThermalPortSMEE internalThermalPort(final useDamperCage = useDamperCage), redeclare final Machines.Interfaces.InductionMachines.PowerBalanceSMEE powerBalance(final lossPowerRotorWinding = damperCageLossPower, final powerExcitation = ve * ie, final lossPowerExcitation = re.LossPower, final lossPowerBrush = brush.lossPower, final lossPowerRotorCore = 0), statorCore(final w = statorCoreParameters.wRef));

    Modelica.Blocks.Interfaces.RealOutput ir[2](start = zeros(2), each final quantity = "ElectricCurrent", each final unit = "A") if useDamperCage "Damper cage currents"
        annotation (
            Placement(visible = false),
            Dialog(showStartAttribute = true));
    Modelica.Blocks.Interfaces.RealOutput idq_dr[2](each stateSelect = StateSelect.prefer, each final quantity = "ElectricCurrent", each final unit = "A") if useDamperCage "Damper space phasor current / rotor fixed frame"
        annotation (Placement(visible = false));
    Machines.BasicMachines.Components.AirGapR airGapR(final p = p, final Lmd = Lmd, final Lmq = Lmq, final m = m) annotation (Placement(transformation(
        extent = {
            {-10, -10}, 
            {10, 10}},
        rotation = 270)));
    parameter Modelica.SIunits.Temperature TrOperational(start = 293.15) "Operational temperature of (optional) damper cage"
        annotation (Dialog(
            group = "Operational temperatures",
            enable = not useThermalPort and useDamperCage));
    parameter Modelica.SIunits.Inductance Lmd(start = 1.5 / (2 * pi * fsNominal)) "Stator main field inductance per phase in d-axis"
        annotation (Dialog(tab = "Nominal resistances and inductances"));
    parameter Modelica.SIunits.Inductance Lmq(start = 1.5 / (2 * pi * fsNominal)) "Stator main field inductance per phase in q-axis"
        annotation (Dialog(tab = "Nominal resistances and inductances"));
    parameter Boolean useDamperCage(start = true) "Enable / disable damper cage"
        annotation (
            Evaluate = true,
            Dialog(
                tab = "Nominal resistances and inductances",
                group = "DamperCage"));
    parameter Modelica.SIunits.Inductance Lrsigmad(start = 0.05 / (2 * pi * fsNominal)) "Damper stray inductance in d-axis"
        annotation (Dialog(
            tab = "Nominal resistances and inductances",
            group = "DamperCage",
            enable = useDamperCage));
    parameter Modelica.SIunits.Inductance Lrsigmaq = Lrsigmad "Damper stray inductance in q-axis"
        annotation (Dialog(
            tab = "Nominal resistances and inductances",
            group = "DamperCage",
            enable = useDamperCage));
    parameter Modelica.SIunits.Resistance Rrd(start = 0.04) "Damper resistance in d-axis at TRef"
        annotation (Dialog(
            tab = "Nominal resistances and inductances",
            group = "DamperCage",
            enable = useDamperCage));
    parameter Modelica.SIunits.Resistance Rrq = Rrd "Damper resistance in q-axis at TRef"
        annotation (Dialog(
            tab = "Nominal resistances and inductances",
            group = "DamperCage",
            enable = useDamperCage));
    parameter Modelica.SIunits.Temperature TrRef(start = 293.15) "Reference temperature of damper resistances in d- and q-axis"
        annotation (Dialog(
            tab = "Nominal resistances and inductances",
            group = "DamperCage",
            enable = useDamperCage));
    parameter Machines.Thermal.LinearTemperatureCoefficient20 alpha20r(start = 0) "Temperature coefficient of damper resistances in d- and q-axis"
        annotation (Dialog(
            tab = "Nominal resistances and inductances",
            group = "DamperCage",
            enable = useDamperCage));
    parameter Modelica.SIunits.Voltage VsNominal(start = 100) "Nominal stator RMS voltage per phase"
        annotation (Dialog(tab = "Excitation"));
    parameter Modelica.SIunits.Current IeOpenCircuit(start = 10) "Open circuit excitation current @ nominal voltage and frequency"
        annotation (Dialog(tab = "Excitation"));
    parameter Modelica.SIunits.Resistance Re(start = 2.5) "Excitation resistance at TRef"
        annotation (Dialog(tab = "Excitation"));
    parameter Modelica.SIunits.Temperature TeRef(start = 293.15) "Reference temperature of excitation resistance"
        annotation (Dialog(tab = "Excitation"));
    parameter Machines.Thermal.LinearTemperatureCoefficient20 alpha20e(start = 0) "Temperature coefficient of excitation resistance"
        annotation (Dialog(tab = "Excitation"));
    parameter Real sigmae(min = 0, max = 0.99, start = 0.025) "Stray fraction of total excitation inductance"
        annotation (Dialog(tab = "Excitation"));
    parameter Modelica.SIunits.Temperature TeOperational(start = 293.15) "Operational excitation temperature"
        annotation (Dialog(
            group = "Operational temperatures",
            enable = not useThermalPort));
    parameter Machines.Losses.BrushParameters brushParameters "Brush loss parameter record"
        annotation (Dialog(tab = "Losses"));
    output Modelica.SIunits.Voltage ve = pin_ep.v - pin_en.v "Excitation voltage";
    output Modelica.SIunits.Current ie = pin_ep.i "Excitation current";
    Machines.BasicMachines.Components.DamperCage damperCage(final Lrsigmad = Lrsigmad, final Lrsigmaq = Lrsigmaq, final Rrd = Rrd, final Rrq = Rrq, final T_ref = TrRef, final alpha = Machines.Thermal.convertAlpha(alpha20r, TrRef), final useHeatPort = true) if useDamperCage annotation (Placement(transformation(
        origin = {0, -40},
        extent = {
            {-10, -10}, 
            {10, 10}},
        rotation = 270)));
    Machines.BasicMachines.Components.ElectricalExcitation electricalExcitation(final turnsRatio = turnsRatio) annotation (Placement(transformation(
        origin = {-70, -50},
        extent = {
            {-10, 10}, 
            {10, -10}},
        rotation = 180)));
    Modelica.Electrical.Analog.Basic.Resistor re(final R = Re, final T_ref = TeRef, final alpha = Machines.Thermal.convertAlpha(alpha20e, TeRef), final useHeatPort = true) annotation (Placement(transformation(
        origin = {-80, 10},
        extent = {
            {-10, 10}, 
            {10, -10}},
        rotation = 270)));
    Modelica.Electrical.Analog.Basic.Inductor lesigma(final L = Lesigma) annotation (Placement(transformation(
        extent = {
            {10, -10}, 
            {-10, 10}},
        rotation = 90,
        origin = {-80, -20})));
    Modelica.Electrical.Analog.Interfaces.PositivePin pin_ep "Positive excitation pin"
        annotation (Placement(transformation(extent = {
            {-110, 70}, 
            {-90, 50}})));
    Modelica.Electrical.Analog.Interfaces.NegativePin pin_en "Negative excitation pin"
        annotation (Placement(transformation(extent = {
            {-90, -50}, 
            {-110, -70}})));
    Machines.Losses.DCMachines.Brush brush(final brushParameters = brushParameters, final useHeatPort = true) annotation (Placement(transformation(
        extent = {
            {10, -10}, 
            {-10, 10}},
        rotation = 90,
        origin = {-80, 40})));
protected
    final parameter Real turnsRatio = sqrt(2) * VsNominal / (2 * pi * fsNominal * Lmd * IeOpenCircuit) "Stator current / excitation current";
    final parameter Modelica.SIunits.Inductance Lesigma = 0.5 * (Lmd * turnsRatio ^ 2 * 3) * sigmae / (1 - sigmae);
    Modelica.Blocks.Interfaces.RealOutput damperCageLossPower(final quantity = "Power", final unit = "W") "Damper losses";
equation
    connect(idq_dr,damperCage.i);
    connect(ir,damperCage.i);
    connect(damperCageLossPower,damperCage.lossPower);
    if not useDamperCage then 
        damperCageLossPower = 0;
    end if;
    connect(pin_ep,brush.p) annotation (Line(
        points = {
            {-100, 60}, 
            {-80, 60}, 
            {-80, 50}},
        color = {0, 0, 255}));
    connect(airGapR.flange,inertiaRotor.flange_a) annotation (Line(points = {
        {10, 0}, 
        {70, 0}}));
    connect(airGapR.support,internalSupport) annotation (Line(points = {
        {-10, 0}, 
        {-26, 0}, 
        {-40, 0}, 
        {-40, -90}, 
        {60, -90}, 
        {60, -100}}));
    connect(airGapR.spacePhasor_r,damperCage.spacePhasor_r) annotation (Line(
        points = {
            {10, -10}, 
            {10, -30}},
        color = {0, 0, 255}));
    connect(airGapR.spacePhasor_r,electricalExcitation.spacePhasor_r) annotation (Line(
        points = {
            {10, -10}, 
            {10, -10}, 
            {10, -20}, 
            {-60, -20}, 
            {-60, -40}},
        color = {0, 0, 255}));
    connect(brush.n,re.p) annotation (Line(
        points = {
            {-80, 30}, 
            {-80, 20}},
        color = {0, 0, 255}));
    connect(brush.heatPort,internalThermalPort.heatPortBrush) annotation (Line(
        points = {
            {-70, 50}, 
            {-60, 50}, 
            {-60, 40}, 
            {50, 40}, 
            {50, -80}, 
            {0, -80}},
        color = {191, 0, 0}));
    connect(lesigma.n,electricalExcitation.pin_ep) annotation (Line(
        points = {
            {-80, -30}, 
            {-80, -40}},
        color = {0, 0, 255}));
    connect(lssigma.spacePhasor_b,airGapR.spacePhasor_s) annotation (Line(
        points = {
            {20, 10}, 
            {10, 10}},
        color = {0, 0, 255}));
    connect(re.n,lesigma.p) annotation (Line(
        points = {
            {-80, 0}, 
            {-80, -10}},
        color = {0, 0, 255}));
    connect(re.heatPort,internalThermalPort.heatPortExcitation) annotation (Line(
        points = {
            {-70, 10}, 
            {-60, 10}, 
            {-60, 40}, 
            {50, 40}, 
            {50, -80}, 
            {0, -80}},
        color = {191, 0, 0}));
    connect(damperCage.heatPort,internalThermalPort.heatPortRotorWinding) annotation (Line(
        points = {
            {-10, -40}, 
            {-10, -80}, 
            {0, -80}, 
            {0, -80}},
        color = {191, 0, 0}));
    connect(electricalExcitation.pin_en,pin_en) annotation (Line(
        points = {
            {-80, -60}, 
            {-100, -60}},
        color = {0, 0, 255}));

    annotation (
        defaultComponentName = "smee",
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Ellipse(
                    extent = {
                        {-134, 34}, 
                        {-66, -34}},
                    lineColor = {0, 0, 255}), 
                Line(
                    points = {
                        {-100, 50}, 
                        {-100, 20}, 
                        {-130, 20}, 
                        {-130, -4}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {-130, -4}, 
                        {-129, 1}, 
                        {-125, 5}, 
                        {-120, 6}, 
                        {-115, 5}, 
                        {-111, 1}, 
                        {-110, -4}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {-110, -4}, 
                        {-109, 1}, 
                        {-105, 5}, 
                        {-100, 6}, 
                        {-95, 5}, 
                        {-91, 1}, 
                        {-90, -4}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {-90, -4}, 
                        {-89, 1}, 
                        {-85, 5}, 
                        {-80, 6}, 
                        {-75, 5}, 
                        {-71, 1}, 
                        {-70, -4}},
                    color = {0, 0, 255}), 
                Line(
                    points = {
                        {-100, -50}, 
                        {-100, -20}, 
                        {-70, -20}, 
                        {-70, -2}},
                    color = {0, 0, 255})}),
        Documentation(info = "<html>\n<p><strong>Model of a three phase electrical excited synchronous induction machine with damper cage.</strong><br>\nResistance and stray inductance of stator is modeled directly in stator phases, then using space phasor transformation and a rotor-fixed <em>AirGap</em> model. Resistance and stray inductance of rotor's squirrel cage is modeled in two axis of the rotor-fixed coordinate system. Electrical excitation is modelled by converting excitation current and voltage to d-axis space phasors. The machine models take the following loss effects into account:\n</p>\n\n<ul>\n<li>heat losses in the temperature dependent stator winding resistances</li>\n<li>heat losses in the temperature dependent excitation winding resistance</li>\n<li>optional, when enabled: heat losses in the temperature dependent damper cage resistances</li>\n<li>brush losses in the excitation circuit</li>\n<li>friction losses</li>\n<li>core losses (only eddy current losses, no hysteresis losses)</li>\n<li>stray load losses</li>\n</ul>\n\n<p>Whether a damper cage is present or not, can be selected with Boolean parameter useDamperCage (default = true).\n<br><strong>Default values for machine's parameters (a realistic example) are:</strong><br></p>\n<table>\n<tr>\n<td>number of pole pairs p</td>\n<td>2</td><td> </td>\n</tr>\n<tr>\n<td>stator's moment of inertia</td>\n<td>0.29</td><td>kg.m2</td>\n</tr>\n<tr>\n<td>rotor's moment of inertia</td>\n<td>0.29</td><td>kg.m2</td>\n</tr>\n<tr>\n<td>nominal frequency fNominal</td>\n<td>50</td><td>Hz</td>\n</tr>\n<tr>\n<td>nominal voltage per phase</td>\n<td>100</td><td>V RMS</td>\n</tr>\n<tr>\n<td>no-load excitation current<br>\n    @ nominal voltage and frequency</td>\n<td>10</td><td>A DC</td>\n</tr>\n<tr>\n<td>warm excitation resistance</td>\n<td>2.5</td><td>Ohm</td>\n</tr>\n<tr>\n<td>nominal current per phase</td>\n<td>100</td><td>A RMS</td>\n</tr>\n<tr>\n<td>nominal apparent power</td>\n<td>-30000</td><td>VA</td>\n</tr>\n<tr>\n<td>power factor</td>\n<td>-1.0</td><td>ind./cap.</td>\n</tr>\n<tr>\n<td>nominal excitation current</td>\n<td>19</td><td>A</td>\n</tr>\n<tr>\n<td>efficiency w/o excitation</td>\n<td>97.1</td><td>%</td>\n</tr>\n<tr>\n<td>nominal torque</td>\n<td>-196.7</td><td>Nm</td>\n</tr>\n<tr>\n<td>nominal speed</td>\n<td>1500</td><td>rpm</td>\n</tr>\n<tr>\n<td>nominal rotor angle</td>\n<td>-57.23</td><td>degree</td>\n</tr>\n<tr>\n<td>stator resistance</td>\n<td>0.03</td><td>Ohm per phase at reference temperature</td>\n</tr>\n<tr>\n<td>reference temperature TsRef</td>\n<td>20</td><td>&deg;C</td>\n</tr>\n<tr>\n<td>temperature coefficient alpha20s </td>\n<td>0</td><td>1/K</td>\n</tr>\n<tr>\n<td>stator reactance Xd</td>\n<td>1.6</td><td>Ohm per phase in d-axis</td>\n</tr>\n<tr>\n<td>giving Kc</td>\n<td>0.625</td><td> </td>\n</tr>\n<tr>\n<td>stator reactance Xq</td>\n<td>1.6</td><td>Ohm per phase in q-axis</td>\n</tr>\n<tr>\n<td>stator stray reactance Xss</td>\n<td>0.1</td><td>Ohm per phase</td>\n</tr>\n<tr>\n<td>damper resistance in d-axis</td>\n<td>0.04</td><td>Ohm at reference temperature</td>\n</tr>\n<tr>\n<td>damper resistance in q-axis</td>\n<td>same as d-axis</td><td> </td>\n</tr>\n<tr>\n<td>reference temperature TrRef</td>\n<td>20</td><td>&deg;C</td>\n</tr>\n<tr>\n<td>temperature coefficient alpha20r </td>\n<td>0</td><td>1/K</td>\n</tr>\n<tr>\n<td>damper stray reactance in d-axis XDds</td>\n<td>0.05</td><td>Ohm</td>\n</tr>\n<tr>\n<td>damper stray reactance in q-axis XDqs</td>\n<td>same as d-axis</td><td> </td>\n</tr>\n<tr>\n<td>excitation resistance</td>\n<td>2.5</td><td>Ohm at reference temperature</td>\n</tr>\n<tr>\n<td>reference temperature TeRef</td>\n<td>20</td><td>&deg;C</td>\n</tr>\n<tr>\n<td>temperature coefficient alpha20e </td>\n<td>0</td><td>1/K</td>\n</tr>\n<tr>\n<td>excitation stray inductance</td>\n<td>2.5</td><td>% of total excitation inductance</td>\n</tr>\n<tr>\n<td>stator operational temperature TsOperational</td>\n<td>20</td><td>&deg;C</td>\n</tr>\n<tr>\n<td>damper operational temperature TrOperational</td>\n<td>20</td><td>&deg;C</td>\n</tr>\n<tr>\n<td>excitation operational temperature TeOperational</td>\n<td>20</td><td>&deg;C</td>\n</tr>\n<tr>\n<td>These values give the following inductances:</td>\n<td> </td><td> </td>\n</tr>\n<tr>\n<td>main field inductance in d-axis</td>\n<td>(Xd - Xss)/(2*pi*fNominal)</td><td> </td>\n</tr>\n<tr>\n<td>main field inductance in q-axis</td>\n<td>(Xq - Xss)/(2*pi*fNominal)</td><td> </td>\n</tr>\n<tr>\n<td>stator stray inductance per phase</td>\n<td>Xss/(2*pi*fNominal)</td><td> </td>\n</tr>\n<tr>\n<td>damper stray inductance in d-axis</td>\n<td>XDds/(2*pi*fNominal)</td><td> </td>\n</tr>\n<tr>\n<td>damper stray inductance in q-axis</td>\n<td>XDqs/(2*pi*fNominal)</td><td> </td>\n</tr>\n</table>\n</html>"));
end SM_ElectricalExcited;