Test example: InductionMachineSquirrelCage transformer starting. At start time tStart1 three-phase voltage is supplied to the induction machine with squirrel cage via the transformer;
the machine starts from standstill, accelerating inertias against load torque quadratic dependent on speed;
at start time tStart2 the machine is fed directly from the voltage source, finally reaching nominal speed.

within Modelica.Electrical.Machines.Examples.InductionMachines;
model IMC_Transformer
  "Test example: InductionMachineSquirrelCage transformer starting"
  extends Modelica.Icons.Example;
  constant Integer m=3 "Number of phases";
  parameter SI.Voltage VNominal=100
    "Nominal RMS voltage per phase";
  parameter SI.Frequency fNominal=50 "Nominal frequency";
  parameter SI.Time tStart1=0.1 "Start time";
  parameter SI.Time tStart2=2.0
    "Start time of bypass transformer";
  parameter SI.Torque TLoad=161.4 "Nominal load torque";
  parameter SI.AngularVelocity wLoad(displayUnit="rev/min")=
       1440.45*2*Modelica.Constants.pi/60 "Nominal load speed";
  parameter SI.Inertia JLoad=0.29
    "Load's moment of inertia";
  Machines.BasicMachines.InductionMachines.IM_SquirrelCage aimc(
    p=aimcData.p,
    fsNominal=aimcData.fsNominal,
    Rs=aimcData.Rs,
    TsRef=aimcData.TsRef,
    alpha20s(displayUnit="1/K") = aimcData.alpha20s,
    Lszero=aimcData.Lszero,
    Lssigma=aimcData.Lssigma,
    Jr=aimcData.Jr,
    Js=aimcData.Js,
    frictionParameters=aimcData.frictionParameters,
    phiMechanical(fixed=true),
    wMechanical(fixed=true),
    statorCoreParameters=aimcData.statorCoreParameters,
    strayLoadParameters=aimcData.strayLoadParameters,
    Lm=aimcData.Lm,
    Lrsigma=aimcData.Lrsigma,
    Rr=aimcData.Rr,
    TrRef=aimcData.TrRef,
    TsOperational=293.15,
    alpha20r=aimcData.alpha20r,
    TrOperational=293.15)
  Machines.Sensors.CurrentQuasiRMSSensor currentQuasiRMSSensor
  Modelica.Electrical.Polyphase.Sources.SineVoltage sineVoltage(
    final m=m,
    f=fill(fNominal, m),
    V=fill(sqrt(2/3)*VNominal, m))
  Modelica.Electrical.Polyphase.Basic.Star star(final m=m)
  Modelica.Electrical.Analog.Basic.Ground ground
  Modelica.Blocks.Sources.BooleanStep booleanStep1[m](each startTime=
        tStart1)
  Modelica.Electrical.Polyphase.Ideal.IdealClosingSwitch idealCloser(
    final m=m,
    Ron=fill(1e-5, m),
    Goff=fill(1e-5, m))
  Machines.BasicMachines.Transformers.Yy.Yy00 transformer(
    n=transformerData.n,
    R1=transformerData.R1,
    L1sigma=transformerData.L1sigma,
    R2=transformerData.R2,
    L2sigma=transformerData.L2sigma,
    T1Ref=293.15,
    alpha20_1(displayUnit="1/K") = Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    T2Ref=293.15,
    alpha20_2(displayUnit="1/K") = Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    T1Operational=293.15,
    T2Operational=293.15)

  Modelica.Electrical.Analog.Basic.Ground ground2
  parameter Machines.Utilities.TransformerData transformerData(
    f=fNominal,
    V1=VNominal,
    C1=Modelica.Utilities.Strings.substring(
        transformer.VectorGroup,
        1,
        1),
    V2=VNominal/sqrt(3),
    C2=Modelica.Utilities.Strings.substring(
        transformer.VectorGroup,
        2,
        2),
    SNominal=50E3,
    v_sc=0.06,
    P_sc=500) "Transformer data"
  Modelica.Blocks.Sources.BooleanStep booleanStep2[m](each startTime=
        tStart2)
  Modelica.Electrical.Polyphase.Ideal.IdealCommutingSwitch
    idealCommutingSwitch(
    final m=m,
    Ron=fill(1e-5, m),
    Goff=fill(50E-5, m))
  Modelica.Mechanics.Rotational.Components.Inertia loadInertia(J=JLoad)
  Modelica.Mechanics.Rotational.Sources.QuadraticSpeedDependentTorque
    quadraticLoadTorque(
    w_nominal=wLoad,
    TorqueDirection=false,
    tau_nominal=-TLoad,
    useSupport=false)
  Machines.Utilities.TerminalBox terminalBox(terminalConnection="D")
  parameter Utilities.ParameterRecords.IM_SquirrelCageData aimcData "Induction machine data"
initial equation
  aimc.is = zeros(3);
  aimc.ir = zeros(2);
  transformer.i1[1:2] = zeros(2);
equation
  connect(star.pin_n, ground.p)
  connect(terminalBox.plug_sn, aimc.plug_sn)
  connect(terminalBox.plug_sp, aimc.plug_sp)
  connect(loadInertia.flange_b, quadraticLoadTorque.flange)
  connect(aimc.flange, loadInertia.flange_a)
  connect(star.plug_p, sineVoltage.plug_n)
  connect(booleanStep2.y, idealCommutingSwitch.control)
  connect(transformer.starpoint2, ground2.p)
  connect(idealCommutingSwitch.plug_p, terminalBox.plugSupply)
  connect(transformer.plug2, idealCommutingSwitch.plug_n1)
  connect(sineVoltage.plug_p, currentQuasiRMSSensor.plug_p)
  connect(booleanStep1.y, idealCloser.control)
  connect(currentQuasiRMSSensor.plug_n, idealCloser.plug_p)
  connect(transformer.plug1, idealCloser.plug_n)
  connect(idealCloser.plug_n, idealCommutingSwitch.plug_n2)
end IMC_Transformer;


Test example: InductionMachineSquirrelCage with losses.

within Modelica.Electrical.Machines.Examples.InductionMachines;
model IMC_withLosses
  "Test example: InductionMachineSquirrelCage with losses"
  extends Modelica.Icons.Example;
  constant Integer m=3 "Number of phases";
  import Modelica.Constants.pi;
  import Modelica.Units.Conversions.from_rpm;
  import Modelica.Units.Conversions.to_rpm;
  import Modelica.Units.Conversions.from_degC;
protected
  parameter SI.Power PNominal=18500 "Nominal output";
  parameter SI.Voltage VNominal=400 "Nominal RMS voltage";
  parameter SI.Current INominal=32.85 "Nominal RMS current";
  parameter Real pfNominal=0.898 "Nominal power factor";
  parameter SI.Power PsNominal=sqrt(3)*VNominal*INominal*pfNominal "Nominal stator power";
  parameter SI.Power lossNominal=PsNominal-PNominal "Nominal losses";
  parameter Real etaNominal=0.9049 "Nominal efficiency";
  parameter SI.Frequency fNominal=50 "Nominal frequency";
  parameter SI.AngularVelocity wNominal=from_rpm(1462.5)
    "Nominal speed";
  parameter SI.Torque TNominal=PNominal/wNominal
    "Nominal torque";
  parameter SI.Temperature TempNominal=from_degC(90)
    "Nominal temperature";
  SI.Power Pel=electricalPowerSensor.P;
  SI.ReactivePower Qel=electricalPowerSensor.Q;
  SI.ApparentPower Sel=sqrt(Pel^2 + Qel^2);
  parameter Real Ptable[:]={1E-6,1845,3549,5325,7521,9372,11010,12930,
      14950,16360,18500,18560,20180,22170};
  parameter Real Itable[:]={11.0,11.20,12.27,13.87,16.41,18.78,21.07,
      23.92,27.05,29.40,32.85,32.95,35.92,39.35};
  parameter Real wtable[:]=from_rpm({1500,1496,1493,1490,1486,1482,1479,1475,1471,
      1467,1462,1462,1458,1453});
  parameter Real ctable[:]={0.085,0.327,0.506,0.636,0.741,0.797,0.831,
      0.857,0.875,0.887,0.896,0.896,0.902,0.906};
  parameter Real etable[:]={0,0.7250,0.8268,0.8698,0.8929,0.9028,0.9064,
      0.9088,0.9089,0.9070,0.9044,0.9043,0.9008,0.8972};
public
  output SI.Power Pmech=powerSensor.power "Mechanical output";
  output SI.Power Ps_sim=sqrt(3)*VNominal*I_sim*pf_sim "Simulated stator power";
  output SI.Power Ps_meas=sqrt(3)*VNominal*I_meas*pf_meas "Simulated stator power";
  output SI.Power loss_sim=Ps_sim-Pmech "Simulated total losses";
  output SI.Power loss_meas=Ps_meas-Pmech "Measured total losses";
  output SI.Current I_sim=currentQuasiRMSSensor.I "Simulated current";
  output SI.Current I_meas=combiTable1Ds.y[1] "Measured current";
  output SI.AngularVelocity w_sim(displayUnit="rev/min")=aimc.wMechanical "Simulated speed";
  output SI.AngularVelocity w_meas(displayUnit="rev/min")=combiTable1Ds.y[2] "Measured speed";
  output Real pf_sim=if noEvent(Sel > Modelica.Constants.small) then Pel/Sel else 0 "Simulated power factor";
  output Real pf_meas=combiTable1Ds.y[3] "Measured power factor";
  output Real eff_sim=if noEvent(abs(Pel) > Modelica.Constants.small) then Pmech/Pel else 0 "Simulated efficiency";
  output Real eff_meas=combiTable1Ds.y[4] "Measured efficiency";
  Machines.BasicMachines.InductionMachines.IM_SquirrelCage aimc(
    p=aimcData.p,
    fsNominal=aimcData.fsNominal,
    Rs=aimcData.Rs,
    TsRef=aimcData.TsRef,
    alpha20s(displayUnit="1/K") = aimcData.alpha20s,
    Lszero=aimcData.Lszero,
    Lssigma=aimcData.Lssigma,
    Jr=aimcData.Jr,
    Js=aimcData.Js,
    frictionParameters=aimcData.frictionParameters,
    phiMechanical(fixed=true),
    statorCoreParameters=aimcData.statorCoreParameters,
    strayLoadParameters=aimcData.strayLoadParameters,
    Lm=aimcData.Lm,
    Lrsigma=aimcData.Lrsigma,
    Rr=aimcData.Rr,
    TrRef=aimcData.TrRef,
    TsOperational=TempNominal,
    TrOperational=TempNominal,
    wMechanical(fixed=true, start=2*pi*aimcData.fsNominal/aimcData.p),
    alpha20r=aimcData.alpha20r)
  Machines.Utilities.TerminalBox terminalBox(terminalConnection="D")
  Machines.Sensors.ElectricalPowerSensor electricalPowerSensor
  Machines.Sensors.CurrentQuasiRMSSensor currentQuasiRMSSensor
  Modelica.Electrical.Polyphase.Sources.SineVoltage sineVoltage(
    final m=m,
    f=fill(fNominal, m),
    V=fill(sqrt(2/3)*VNominal, m))
  Modelica.Electrical.Polyphase.Basic.Star star(final m=m)
  Modelica.Electrical.Analog.Basic.Ground ground
  Modelica.Mechanics.Rotational.Sensors.PowerSensor powerSensor
  Modelica.Mechanics.Rotational.Components.Inertia loadInertia(J=aimcData.Jr)
  Modelica.Mechanics.Rotational.Sources.Torque torque
  Modelica.Blocks.Math.Gain gain(k=-1)
  Modelica.Blocks.Continuous.PI PI(
    k=0.01,
    T=0.01,
    initType=Modelica.Blocks.Types.Init.InitialState)
  Modelica.Blocks.Math.Feedback feedback
  Modelica.Blocks.Sources.Ramp ramp(
    height=1.2*PNominal,
    offset=0,
    startTime=4.5,
    duration=5.5)
  Modelica.Blocks.Tables.CombiTable1Ds combiTable1Ds(table={{Ptable[j],
        Itable[j],wtable[j],ctable[j],etable[j]} for j in 1:size(Ptable,
        1)}, smoothness=Modelica.Blocks.Types.Smoothness.ContinuousDerivative)
  parameter Utilities.ParameterRecords.IM_SquirrelCageData aimcData(
    statorCoreParameters(PRef=410, VRef=387.9),
    Jr=0.12,
    Rs=0.56,
    alpha20s(displayUnit="1/K")=Modelica.Electrical.Machines.Thermal.Constants.alpha20Copper,
    Lssigma=1.52/(2*pi*fNominal),
    frictionParameters(PRef=180, wRef=wNominal),
    strayLoadParameters(
      PRef=0.005*sqrt(3)*VNominal*INominal*pfNominal,
      IRef=INominal/sqrt(3),
      wRef=wNominal),
    Lm=66.4/(2*pi*fNominal),
    Lrsigma=2.31/(2*pi*fNominal),
    Rr=0.42,
    alpha20r(displayUnit="1/K")=Modelica.Electrical.Machines.Thermal.Constants.alpha20Aluminium)   "Induction machine data"

initial equation
  aimc.i_0_s = 0;
  der(aimc.idq_sr) = zeros(2);
  der(aimc.idq_rr) = zeros(2);
equation
  connect(star.pin_n, ground.p)
  connect(sineVoltage.plug_n, star.plug_p)
  connect(terminalBox.plug_sn, aimc.plug_sn)
  connect(terminalBox.plug_sp, aimc.plug_sp)
  connect(currentQuasiRMSSensor.plug_n, electricalPowerSensor.plug_p)

  connect(electricalPowerSensor.plug_nv, star.plug_p)
  connect(electricalPowerSensor.plug_ni, terminalBox.plugSupply)
  connect(aimc.flange, powerSensor.flange_a)
  connect(powerSensor.flange_b, loadInertia.flange_a)
  connect(torque.flange, loadInertia.flange_b)
  connect(gain.y, torque.tau)
  connect(sineVoltage.plug_p, currentQuasiRMSSensor.plug_p)
  connect(powerSensor.power, feedback.u2)
  connect(feedback.y, PI.u)
  connect(PI.y, gain.u)
  connect(ramp.y, feedback.u1)
  connect(powerSensor.power, combiTable1Ds.u)
end IMC_withLosses;


Test example: InductionMachineSquirrelCage Y-D. At start time tStart three-phase voltage is supplied to the induction machine with squirrel cage,
first star-connected, then delta-connected; the machine starts from standstill, accelerating inertias against
load torque quadratic dependent on speed, finally reaching nominal speed.

within Modelica.Electrical.Machines.Examples.InductionMachines;
model IMC_YD
  "Test example: InductionMachineSquirrelCage Y-D"
  extends Modelica.Icons.Example;
  constant Integer m=3 "Number of phases";
  parameter SI.Voltage VNominal=100
    "Nominal RMS voltage per phase";
  parameter SI.Frequency fNominal=50 "Nominal frequency";
  parameter SI.Time tStart1=0.1 "Start time";
  parameter SI.Time tStart2=2.0 "Start time from Y to D";
  parameter SI.Torque TLoad=161.4 "Nominal load torque";
  parameter SI.AngularVelocity wLoad(displayUnit="rev/min")=
       1440.45*2*Modelica.Constants.pi/60 "Nominal load speed";
  parameter SI.Inertia JLoad=0.29
    "Load's moment of inertia";
  Machines.BasicMachines.InductionMachines.IM_SquirrelCage aimc(
    p=aimcData.p,
    fsNominal=aimcData.fsNominal,
    Rs=aimcData.Rs,
    TsRef=aimcData.TsRef,
    alpha20s(displayUnit="1/K") = aimcData.alpha20s,
    Lszero=aimcData.Lszero,
    Lssigma=aimcData.Lssigma,
    Jr=aimcData.Jr,
    Js=aimcData.Js,
    frictionParameters=aimcData.frictionParameters,
    phiMechanical(fixed=true),
    wMechanical(fixed=true),
    statorCoreParameters=aimcData.statorCoreParameters,
    strayLoadParameters=aimcData.strayLoadParameters,
    Lm=aimcData.Lm,
    Lrsigma=aimcData.Lrsigma,
    Rr=aimcData.Rr,
    TrRef=aimcData.TrRef,
    TsOperational=293.15,
    alpha20r=aimcData.alpha20r,
    TrOperational=293.15)
  Machines.Sensors.CurrentQuasiRMSSensor currentQuasiRMSSensor
  Modelica.Electrical.Polyphase.Sources.SineVoltage sineVoltage(
    final m=m,
    f=fill(fNominal, m),
    V=fill(sqrt(2/3)*VNominal, m))
  Modelica.Electrical.Polyphase.Basic.Star star(final m=m)
  Modelica.Electrical.Analog.Basic.Ground ground
  Modelica.Blocks.Sources.BooleanStep booleanStep[m](each startTime=
        tStart1)
  Modelica.Electrical.Polyphase.Ideal.IdealClosingSwitch idealCloser(
    final m=m,
    Ron=fill(1e-5, m),
    Goff=fill(1e-5, m))
  Machines.Utilities.SwitchYD switchYD(m=m)
  Modelica.Blocks.Sources.BooleanStep booleanStepYD[m](each startTime=
        tStart2)
  Modelica.Mechanics.Rotational.Components.Inertia loadInertia(J=JLoad)
  Modelica.Mechanics.Rotational.Sources.QuadraticSpeedDependentTorque
    quadraticLoadTorque(
    w_nominal=wLoad,
    TorqueDirection=false,
    tau_nominal=-TLoad,
    useSupport=false)
  parameter Utilities.ParameterRecords.IM_SquirrelCageData aimcData "Induction machine data"
initial equation
  aimc.is = zeros(3);
  aimc.ir = zeros(2);
equation
  connect(star.pin_n, ground.p)
  connect(sineVoltage.plug_n, star.plug_p)
  connect(sineVoltage.plug_p, idealCloser.plug_p)
  connect(loadInertia.flange_b, quadraticLoadTorque.flange)
  connect(booleanStep.y, idealCloser.control)
  connect(booleanStepYD.y, switchYD.control)
  connect(idealCloser.plug_n, currentQuasiRMSSensor.plug_p)
  connect(switchYD.plug_sn, aimc.plug_sn)
  connect(switchYD.plug_sp, aimc.plug_sp)
  connect(switchYD.plugSupply, currentQuasiRMSSensor.plug_n)
  connect(aimc.flange, loadInertia.flange_a)
end IMC_YD;


Test example: InductionMachineSquirrelCage Y-D. Same example as IMC_YD, but with a time delay between Y off and D on.

within Modelica.Electrical.Machines.Examples.InductionMachines;
model IMC_YDarc "Test example: InductionMachineSquirrelCage Y-D"
  extends Modelica.Icons.Example;
  import Modelica.Constants.pi;
  constant Integer m=3 "Number of phases";
  parameter SI.Voltage VNominal=100
    "Nominal RMS voltage per phase";
  parameter SI.Frequency fNominal=50 "Nominal frequency";
  parameter SI.Resistance RLine=0.0001 "Line resistance";
  parameter SI.Inductance LLine=0.0001/(2*pi*fNominal) "Line inductance";
  parameter SI.Time tStart1=0.1 "Start time";
  parameter SI.Time tStart2=2.0 "Start time from Y to D";
  parameter SI.Torque TLoad=161.4 "Nominal load torque";
  parameter SI.AngularVelocity wLoad(displayUnit="rev/min")=
       1440.45*2*Modelica.Constants.pi/60 "Nominal load speed";
  parameter SI.Inertia JLoad=0.29
    "Load's moment of inertia";
  Machines.BasicMachines.InductionMachines.IM_SquirrelCage aimc(
    p=aimcData.p,
    fsNominal=aimcData.fsNominal,
    Rs=aimcData.Rs,
    TsRef=aimcData.TsRef,
    alpha20s(displayUnit="1/K") = aimcData.alpha20s,
    Lszero=aimcData.Lszero,
    Lssigma=aimcData.Lssigma,
    Jr=aimcData.Jr,
    Js=aimcData.Js,
    frictionParameters=aimcData.frictionParameters,
    phiMechanical(fixed=true),
    wMechanical(fixed=true),
    statorCoreParameters=aimcData.statorCoreParameters,
    strayLoadParameters=aimcData.strayLoadParameters,
    Lm=aimcData.Lm,
    Lrsigma=aimcData.Lrsigma,
    Rr=aimcData.Rr,
    TrRef=aimcData.TrRef,
    TsOperational=293.15,
    alpha20r=aimcData.alpha20r,
    TrOperational=293.15)
  Machines.Sensors.CurrentQuasiRMSSensor currentQuasiRMSSensor
  Modelica.Electrical.Polyphase.Sources.SineVoltage sineVoltage(
    final m=m,
    f=fill(fNominal, m),
    V=fill(sqrt(2/3)*VNominal, m))
  Modelica.Electrical.Polyphase.Basic.Star star(final m=m)
  Modelica.Electrical.Analog.Basic.Ground ground
  Modelica.Blocks.Sources.BooleanStep booleanStep[m](each startTime=
        tStart1)
  Modelica.Electrical.Polyphase.Ideal.IdealClosingSwitch idealCloser(
    final m=m,
    Ron=fill(1e-5, m),
    Goff=fill(1e-5, m))
  Utilities.SwitchYDwithArc   switchYDwithArc(
                                       m=m, delayTime=0.02,
    V0=10,
    dVdt=10E3,
    Vmax=100)
  Modelica.Blocks.Sources.BooleanStep booleanStepYD[m](each startTime=
        tStart2)
  Modelica.Mechanics.Rotational.Components.Inertia loadInertia(J=JLoad)
  Modelica.Mechanics.Rotational.Sources.QuadraticSpeedDependentTorque
    quadraticLoadTorque(
    w_nominal=wLoad,
    TorqueDirection=false,
    tau_nominal=-TLoad,
    useSupport=false)
  parameter Utilities.ParameterRecords.IM_SquirrelCageData aimcData "Induction machine data"
  Polyphase.Basic.Resistor resistor(m=m, R=fill(RLine, m))
  Polyphase.Basic.Inductor inductor(m=m, L=fill(LLine, m))
initial equation
  inductor.i[1:2] = zeros(2);
  aimc.is = zeros(3);
  aimc.ir = zeros(2);
equation
  connect(star.pin_n, ground.p)
  connect(sineVoltage.plug_n, star.plug_p)
  connect(loadInertia.flange_b, quadraticLoadTorque.flange)
  connect(booleanStep.y, idealCloser.control)
  connect(booleanStepYD.y, switchYDwithArc.control)
  connect(idealCloser.plug_n, currentQuasiRMSSensor.plug_p)
  connect(switchYDwithArc.plug_sn, aimc.plug_sn)
  connect(switchYDwithArc.plug_sp, aimc.plug_sp)
  connect(switchYDwithArc.plugSupply, currentQuasiRMSSensor.plug_n)
  connect(aimc.flange, loadInertia.flange_a)
  connect(sineVoltage.plug_p, resistor.plug_p)
  connect(resistor.plug_n, inductor.plug_p)
  connect(inductor.plug_n, idealCloser.plug_p)
end IMC_YDarc;


Test example: InductionMachineSlipRing. At start time tStart1 three-phase voltage is supplied to the induction machine with sliprings;
the machine starts from standstill, accelerating inertias against load torque quadratic dependent on speed,
using a starting resistance. At time tStart2 external rotor resistance is shortened, finally reaching nominal speed.

within Modelica.Electrical.Machines.Examples.InductionMachines;
model IMS_Start "Test example: InductionMachineSlipRing"
  extends Modelica.Icons.Example;
  constant Integer m=3 "Number of phases";
  parameter SI.Voltage VNominal=100
    "Nominal RMS voltage per phase";
  parameter SI.Frequency fNominal=50 "Nominal frequency";
  parameter SI.Time tStart1=0.1 "Start time";
  parameter SI.Resistance Rstart=0.16/aimsData.turnsRatio^2
    "Starting resistance";
  parameter SI.Time tStart2=1.0
    "Start time of shorting starting resistance";
  parameter SI.Torque TLoad=161.4 "Nominal load torque";
  parameter SI.AngularVelocity wLoad(displayUnit="rev/min")=
       1440.45*2*Modelica.Constants.pi/60 "Nominal load speed";
  parameter SI.Inertia JLoad=0.29
    "Load's moment of inertia";
  Machines.BasicMachines.InductionMachines.IM_SlipRing aims(
    p=aimsData.p,
    Jr=aimsData.Jr,
    Js=aimsData.Js,
    phiMechanical(fixed=true),
    wMechanical(fixed=true),
    useTurnsRatio=aimsData.useTurnsRatio,
    turnsRatio=aimsData.turnsRatio,
    VsNominal=aimsData.VsNominal,
    VrLockedRotor=aimsData.VrLockedRotor,
    Rs=aimsData.Rs,
    TsRef=aimsData.TsRef,
    Lszero=aimsData.Lszero,
    Lssigma=aimsData.Lssigma,
    Lm=aimsData.Lm,
    Lrsigma=aimsData.Lrsigma,
    Lrzero=aimsData.Lrzero,
    Rr=aimsData.Rr,
    TrRef=aimsData.TrRef,
    frictionParameters=aimsData.frictionParameters,
    statorCoreParameters=aimsData.statorCoreParameters,
    strayLoadParameters=aimsData.strayLoadParameters,
    rotorCoreParameters=aimsData.rotorCoreParameters,
    fsNominal=aimsData.fsNominal,
    TsOperational=293.15,
    alpha20s=aimsData.alpha20s,
    alpha20r=aimsData.alpha20r,
    TrOperational=293.15)
  Machines.Sensors.CurrentQuasiRMSSensor currentQuasiRMSSensor
  Modelica.Electrical.Polyphase.Sources.SineVoltage sineVoltage(
    final m=m,
    f=fill(fNominal, m),
    V=fill(sqrt(2/3)*VNominal, m))
  Modelica.Electrical.Polyphase.Basic.Star star(final m=m)
  Modelica.Electrical.Analog.Basic.Ground ground
  Modelica.Blocks.Sources.BooleanStep booleanStep[m](each startTime=
        tStart1)
  Modelica.Electrical.Polyphase.Ideal.IdealClosingSwitch idealCloser(
    final m=m,
    Ron=fill(1e-5, m),
    Goff=fill(1e-5, m))
  Modelica.Mechanics.Rotational.Components.Inertia loadInertia(J=JLoad)
  Modelica.Mechanics.Rotational.Sources.QuadraticSpeedDependentTorque
    quadraticLoadTorque(
    w_nominal=wLoad,
    TorqueDirection=false,
    tau_nominal=-TLoad,
    useSupport=false)
  Machines.Utilities.TerminalBox terminalBox(terminalConnection="D")
  Machines.Utilities.SwitchedRheostat switchedRheostat(
    RStart=Rstart,
    tStart=tStart2,
    m=m)
  parameter Utilities.ParameterRecords.IM_SlipRingData aimsData "Induction machine data"
initial equation
  aims.is = zeros(3);
  aims.ir = zeros(3);
equation
  connect(star.pin_n, ground.p)
  connect(sineVoltage.plug_n, star.plug_p)
  connect(sineVoltage.plug_p, idealCloser.plug_p)
  connect(loadInertia.flange_b, quadraticLoadTorque.flange)
  connect(booleanStep.y, idealCloser.control)
  connect(idealCloser.plug_n, currentQuasiRMSSensor.plug_p)
  connect(terminalBox.plugSupply, currentQuasiRMSSensor.plug_n)
  connect(terminalBox.plug_sn, aims.plug_sn)
  connect(terminalBox.plug_sp, aims.plug_sp)
  connect(aims.flange, loadInertia.flange_a)
  connect(switchedRheostat.plug_p, aims.plug_rp)
  connect(switchedRheostat.plug_n, aims.plug_rn)
end IMS_Start;


Test examples of induction machines

within Modelica.Electrical.Machines.Examples;
package InductionMachines "Test examples of induction machines"
  extends Modelica.Icons.ExamplesPackage;
end InductionMachines;


Test examples of synchronous machines

within Modelica.Electrical.Machines.Examples;
package SynchronousMachines "Test examples of synchronous machines"
  extends Modelica.Icons.ExamplesPackage;
end SynchronousMachines;


Test example: ElectricalExcitedSynchronousMachine starting direct on line. An electrically excited synchronous generator is started direct on line utilizing the damper cage
(and the shorted excitation winding) at 0 seconds.

within Modelica.Electrical.Machines.Examples.SynchronousMachines;
model SMEE_DOL
  "Test example: ElectricalExcitedSynchronousMachine starting direct on line"
  extends Modelica.Icons.Example;
  constant Integer m=3 "Number of phases";
  parameter SI.Voltage VNominal=100
    "Nominal RMS voltage per phase";
  parameter SI.Frequency fNominal=50 "Nominal frequency";
  parameter SI.Voltage Ve=smeeData.Re*smeeData.IeOpenCircuit "Excitation current";
  parameter SI.Angle gamma0(displayUnit="deg") = 0
    "Initial rotor displacement angle";
  Machines.BasicMachines.SynchronousMachines.SM_ElectricalExcited smee(
    phiMechanical(start=-(Modelica.Constants.pi + gamma0)/smee.p, fixed=true),
    fsNominal=smeeData.fsNominal,
    Rs=smeeData.Rs,
    TsRef=smeeData.TsRef,
    Lssigma=smeeData.Lssigma,
    Lmd=smeeData.Lmd,
    Lmq=smeeData.Lmq,
    Lrsigmad=smeeData.Lrsigmad,
    Lrsigmaq=smeeData.Lrsigmaq,
    Rrd=smeeData.Rrd,
    Rrq=smeeData.Rrq,
    TrRef=smeeData.TrRef,
    VsNominal=smeeData.VsNominal,
    IeOpenCircuit=smeeData.IeOpenCircuit,
    Re=smeeData.Re,
    TeRef=smeeData.TeRef,
    sigmae=smeeData.sigmae,
    p=2,
    Jr=0.29,
    Js=0.29,
    useDamperCage=true,
    statorCoreParameters(VRef=100),
    strayLoadParameters(IRef=100),
    brushParameters(ILinear=0.01),
    ir(each fixed=true),
    wMechanical(fixed=true),
    TsOperational=293.15,
    alpha20s=smeeData.alpha20s,
    TrOperational=293.15,
    alpha20r=smeeData.alpha20r,
    alpha20e=smeeData.alpha20e,
    TeOperational=293.15)
  Machines.Sensors.RotorDisplacementAngle rotorDisplacementAngle(p=smee.p, m=m)
  Modelica.Electrical.Analog.Basic.Ground groundExcitation
  Mechanics.Rotational.Sensors.MultiSensor
                                         mechanicalMultiSensor
  Machines.Sensors.ElectricalPowerSensor electricalPowerSensor
  Machines.Sensors.CurrentQuasiRMSSensor currentQuasiRMSSensor
  Modelica.Electrical.Polyphase.Sources.SineVoltage sineVoltage(
    final m=m,
    final V=fill(VNominal*sqrt(2), m),
    final f=fill(fNominal, m))
  Modelica.Electrical.Polyphase.Basic.Star star(final m=m)
  Modelica.Electrical.Analog.Basic.Ground ground
  Analog.Sources.RampVoltage                     rampVoltage(
    duration=0.1,
    V=Ve,
    offset=0,
    startTime=0.5)
  Machines.Utilities.TerminalBox terminalBox(terminalConnection="Y")
  parameter Machines.Utilities.SynchronousMachineData smeeData(
    SNominal=30e3,
    VsNominal=100,
    fsNominal=50,
    IeOpenCircuit=10,
    x0=0.1,
    xd=1.6,
    xq=1.6,
    xdTransient=0.1375,
    xdSubtransient=0.121428571,
    xqSubtransient=0.148387097,
    Ta=0.014171268,
    Td0Transient=0.261177343,
    Td0Subtransient=0.006963029,
    Tq0Subtransient=0.123345081,
    alpha20s(displayUnit="1/K") = Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    alpha20r(displayUnit="1/K") = Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    alpha20e(displayUnit="1/K") = Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    TsSpecification=293.15,
    TsRef=293.15,
    TrSpecification=293.15,
    TrRef=293.15,
    TeSpecification=293.15,
    TeRef=293.15) "Synchronous machine data"

  Polyphase.Ideal.IdealClosingSwitch                     idealCloser(
    final m=m,
    Ron=fill(1e-5, m),
    Goff=fill(1e-5, m))
  Blocks.Sources.BooleanStep booleanStep(startTime=0.0)
  Blocks.Routing.BooleanReplicator booleanReplicator(nout=m)
  Mechanics.Rotational.Sources.TorqueStep torqueStep(
    offsetTorque=0,
    stepTorque=50,
    startTime=2)
initial equation
  smee.is[1:2] = zeros(2);
  smee.ie = 0;
  //conditional damper cage currents are defined as fixed start values
equation
  connect(rotorDisplacementAngle.plug_n, smee.plug_sn)
  connect(rotorDisplacementAngle.plug_p, smee.plug_sp)
  connect(star.pin_n, ground.p)
  connect(star.plug_p, sineVoltage.plug_n)
  connect(electricalPowerSensor.plug_ni, currentQuasiRMSSensor.plug_p)
  connect(electricalPowerSensor.plug_nv, smee.plug_sn)
  connect(terminalBox.plugSupply, currentQuasiRMSSensor.plug_n)
  connect(terminalBox.plug_sn, smee.plug_sn)
  connect(terminalBox.plug_sp, smee.plug_sp)
  connect(smee.flange, rotorDisplacementAngle.flange)
  connect(smee.flange,mechanicalMultiSensor. flange_a)
  connect(sineVoltage.plug_p, idealCloser.plug_p)
  connect(idealCloser.plug_n, electricalPowerSensor.plug_p)
  connect(booleanReplicator.y, idealCloser.control)
  connect(booleanStep.y, booleanReplicator.u)
  connect(groundExcitation.p, rampVoltage.n)
  connect(rampVoltage.n, smee.pin_en)
  connect(rampVoltage.p, smee.pin_ep)
  connect(mechanicalMultiSensor.flange_b, torqueStep.flange)
end SMEE_DOL;


Test example: ElectricalExcitedSynchronousMachine as Generator. An electrically excited synchronous generator is connected to the grid and driven with constant speed.
Since speed is slightly smaller than synchronous speed corresponding to mains frequency,
rotor angle is very slowly increased. This allows to see several characteristics dependent on rotor angle.

within Modelica.Electrical.Machines.Examples.SynchronousMachines;
model SMEE_Generator
  "Test example: ElectricalExcitedSynchronousMachine as Generator"
  extends Modelica.Icons.Example;
  constant Integer m=3 "Number of phases";
  parameter SI.Voltage VNominal=100
    "Nominal RMS voltage per phase";
  parameter SI.Frequency fNominal=50 "Nominal frequency";
  parameter SI.AngularVelocity wActual(displayUnit="rev/min")=
       1499*2*Modelica.Constants.pi/60 "Actual speed";
  parameter SI.Current Ie=19 "Excitation current";
  parameter SI.Current Ie0=10 "Initial excitation current";
  parameter SI.Angle gamma0(displayUnit="deg") = 0
    "Initial rotor displacement angle";
  Machines.BasicMachines.SynchronousMachines.SM_ElectricalExcited smee(
    phiMechanical(start=-(Modelica.Constants.pi + gamma0)/smee.p, fixed=true),
    fsNominal=smeeData.fsNominal,
    Rs=smeeData.Rs,
    TsRef=smeeData.TsRef,
    Lssigma=smeeData.Lssigma,
    Lmd=smeeData.Lmd,
    Lmq=smeeData.Lmq,
    Lrsigmad=smeeData.Lrsigmad,
    Lrsigmaq=smeeData.Lrsigmaq,
    Rrd=smeeData.Rrd,
    Rrq=smeeData.Rrq,
    TrRef=smeeData.TrRef,
    VsNominal=smeeData.VsNominal,
    IeOpenCircuit=smeeData.IeOpenCircuit,
    Re=smeeData.Re,
    TeRef=smeeData.TeRef,
    sigmae=smeeData.sigmae,
    p=2,
    Jr=0.29,
    Js=0.29,
    useDamperCage=true,
    statorCoreParameters(VRef=100),
    strayLoadParameters(IRef=100),
    brushParameters(ILinear=0.01),
    TsOperational=293.15,
    alpha20s=smeeData.alpha20s,
    ir(each fixed=true),
    TrOperational=293.15,
    alpha20r=smeeData.alpha20r,
    alpha20e=smeeData.alpha20e,
    TeOperational=293.15)
  Machines.Sensors.RotorDisplacementAngle rotorDisplacementAngle(p=smee.p)
  Modelica.Electrical.Analog.Basic.Ground groundExcitation
  Modelica.Mechanics.Rotational.Sources.ConstantSpeed constantSpeed(
      final w_fixed=wActual)
  Machines.Sensors.MechanicalPowerSensor mechanicalPowerSensor
  Machines.Sensors.ElectricalPowerSensor electricalPowerSensor
  Machines.Sensors.CurrentQuasiRMSSensor currentQuasiRMSSensor
  Modelica.Electrical.Polyphase.Sources.SineVoltage sineVoltage(
    final m=m,
    final V=fill(VNominal*sqrt(2), m),
    final f=fill(fNominal, m))
  Modelica.Electrical.Polyphase.Basic.Star star(final m=m)
  Modelica.Electrical.Analog.Basic.Ground ground
  Modelica.Electrical.Analog.Sources.RampCurrent rampCurrent(
    duration=0.1,
    I=Ie - Ie0,
    offset=Ie0)
  Machines.Utilities.TerminalBox terminalBox(terminalConnection="Y")
  parameter Machines.Utilities.SynchronousMachineData smeeData(
    SNominal=30e3,
    VsNominal=100,
    fsNominal=50,
    IeOpenCircuit=10,
    x0=0.1,
    xd=1.6,
    xq=1.6,
    xdTransient=0.1375,
    xdSubtransient=0.121428571,
    xqSubtransient=0.148387097,
    Ta=0.014171268,
    Td0Transient=0.261177343,
    Td0Subtransient=0.006963029,
    Tq0Subtransient=0.123345081,
    alpha20s(displayUnit="1/K") = Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    alpha20r(displayUnit="1/K") = Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    alpha20e(displayUnit="1/K") = Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    TsSpecification=293.15,
    TsRef=293.15,
    TrSpecification=293.15,
    TrRef=293.15,
    TeSpecification=293.15,
    TeRef=293.15) "Synchronous machine data"

initial equation
  smee.is[1:2] = zeros(2);
  //conditional damper cage currents are defined as fixed start values
equation
  connect(rotorDisplacementAngle.plug_n, smee.plug_sn)
  connect(rotorDisplacementAngle.plug_p, smee.plug_sp)
  connect(star.pin_n, ground.p)
  connect(star.plug_p, sineVoltage.plug_n)
  connect(electricalPowerSensor.plug_ni, currentQuasiRMSSensor.plug_p)
  connect(mechanicalPowerSensor.flange_b, constantSpeed.flange)
  connect(sineVoltage.plug_p, electricalPowerSensor.plug_p)
  connect(rampCurrent.p, groundExcitation.p)
  connect(rampCurrent.p, smee.pin_en)
  connect(rampCurrent.n, smee.pin_ep)
  connect(electricalPowerSensor.plug_nv, smee.plug_sn)
  connect(terminalBox.plugSupply, currentQuasiRMSSensor.plug_n)
  connect(terminalBox.plug_sn, smee.plug_sn)
  connect(terminalBox.plug_sp, smee.plug_sp)
  connect(smee.flange, rotorDisplacementAngle.flange)
  connect(smee.flange, mechanicalPowerSensor.flange_a)
end SMEE_Generator;


Test example: ElectricalExcitedSynchronousMachine with voltage controller. An electrically excited synchronous generator is started with a speed ramp, then driven with constant speed.
Voltage is controlled, the set point depends on speed. After start-up the generator is loaded, the load is rejected.

within Modelica.Electrical.Machines.Examples.SynchronousMachines;
model SMEE_LoadDump
  "Test example: ElectricalExcitedSynchronousMachine with voltage controller"
  extends Modelica.Icons.Example;
  import Modelica.Constants.pi;
  constant Integer m=3 "Number of phases";
  parameter SI.AngularVelocity wNominal=2*pi*smeeData.fsNominal
      /smee.p "Nominal speed";
  parameter SI.Impedance ZNominal=3*smeeData.VsNominal^2/
      smeeData.SNominal "Nominal load impedance";
  parameter Real powerFactor(
    min=0,
    max=1) = 0.8 "Load power factor";
  parameter SI.Resistance RLoad=ZNominal*powerFactor
    "Load resistance";
  parameter SI.Inductance LLoad=ZNominal*sqrt(1 -
      powerFactor^2)/(2*pi*smeeData.fsNominal) "Load inductance";
  parameter SI.Voltage Ve0=smee.IeOpenCircuit*
      Machines.Thermal.convertResistance(
            smee.Re,
            smee.TeRef,
            smee.alpha20e,
            smee.TeOperational) "No load excitation voltage";
  parameter Real k=2*Ve0/smeeData.VsNominal "Voltage controller: gain";
  parameter SI.Time Ti=smeeData.Td0Transient/2
    "Voltage controller: integral time constant";
  output Real controlError=(setPointGain.y - voltageQuasiRMSSensor.V)/
      smeeData.VsNominal;
  Machines.BasicMachines.SynchronousMachines.SM_ElectricalExcited smee(
    fsNominal=smeeData.fsNominal,
    Rs=smeeData.Rs,
    TsRef=smeeData.TsRef,
    Lssigma=smeeData.Lssigma,
    Lmd=smeeData.Lmd,
    Lmq=smeeData.Lmq,
    Lrsigmad=smeeData.Lrsigmad,
    Lrsigmaq=smeeData.Lrsigmaq,
    Rrd=smeeData.Rrd,
    Rrq=smeeData.Rrq,
    TrRef=smeeData.TrRef,
    VsNominal=smeeData.VsNominal,
    IeOpenCircuit=smeeData.IeOpenCircuit,
    Re=smeeData.Re,
    TeRef=smeeData.TeRef,
    sigmae=smeeData.sigmae,
    useDamperCage=true,
    p=2,
    Jr=0.29,
    Js=0.29,
    statorCoreParameters(VRef=100),
    strayLoadParameters(IRef=100),
    brushParameters(ILinear=0.01),
    TsOperational=293.15,
    alpha20s=smeeData.alpha20s,
    TrOperational=293.15,
    alpha20r=smeeData.alpha20r,
    alpha20e=smeeData.alpha20e,
    TeOperational=293.15)
  parameter Machines.Utilities.SynchronousMachineData smeeData(
    SNominal=30e3,
    VsNominal=100,
    fsNominal=50,
    IeOpenCircuit=10,
    x0=0.1,
    xd=1.6,
    xq=1.6,
    xdTransient=0.1375,
    xdSubtransient=0.121428571,
    xqSubtransient=0.148387097,
    Ta=0.014171268,
    Td0Transient=0.261177343,
    Td0Subtransient=0.006963029,
    Tq0Subtransient=0.123345081,
    TsSpecification=293.15,
    TsRef=293.15,
    alpha20s(displayUnit="1/K") = Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    TrSpecification=293.15,
    TrRef=293.15,
    alpha20r(displayUnit="1/K") = Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    TeSpecification=293.15,
    TeRef=293.15,
    alpha20e(displayUnit="1/K") = Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero)
    "Synchronous machine data"

  Machines.Utilities.TerminalBox terminalBox(terminalConnection="Y")
  Modelica.Electrical.Analog.Basic.Ground ground
  Modelica.Mechanics.Rotational.Sources.Speed speed
  Modelica.Blocks.Sources.Ramp speedRamp(height=wNominal, duration=1)
  Modelica.Mechanics.Rotational.Sensors.SpeedSensor speedSensor
  Modelica.Blocks.Math.Gain setPointGain(k=(smeeData.VsNominal/wNominal))
  Machines.Sensors.VoltageQuasiRMSSensor voltageQuasiRMSSensor(ToSpacePhasor1(y(
          each start=1E-3, each fixed=true)))
  Modelica.Blocks.Continuous.LimPID voltageController(
    controllerType=Modelica.Blocks.Types.SimpleController.PI,
    k=k,
    Ti=Ti,
    yMax=2.5*Ve0,
    yMin=0,
    initType=Modelica.Blocks.Types.Init.InitialState,
    Td=0.001)
  Modelica.Electrical.Analog.Sources.SignalVoltage excitationVoltage
  Modelica.Electrical.Analog.Basic.Ground groundExcitation
  Machines.Sensors.CurrentQuasiRMSSensor currentQuasiRMSSensor
  Modelica.Blocks.Sources.BooleanPulse loadControl(period=4, startTime=2)
  Modelica.Electrical.Polyphase.Ideal.CloserWithArc switch(
    m=m,
    Ron=fill(1e-5, m),
    Goff=fill(1e-5, m),
    V0=fill(30, m),
    dVdt=fill(10e3, m),
    Vmax=fill(60, m),
    closerWithArc(off(start=fill(true, m), fixed=fill(true, m))))
  Modelica.Electrical.Polyphase.Basic.Resistor loadResistor(m=m, R=fill(
        RLoad, m))
  Modelica.Electrical.Polyphase.Basic.Inductor loadInductor(m=m, L=fill(
        LLoad, m))
  Modelica.Electrical.Polyphase.Basic.Star star(m=m)
protected
  constant SI.MagneticFlux unitMagneticFlux=1
initial equation
  smee.idq_sr = zeros(2);
  //conditional damper cage currents are defined as fixed start values
  smee.ie = 0;
equation
  connect(terminalBox.plug_sn, smee.plug_sn)
  connect(terminalBox.plug_sp, smee.plug_sp)
  connect(excitationVoltage.p, smee.pin_ep)
  connect(excitationVoltage.n, smee.pin_en)
  connect(excitationVoltage.n, groundExcitation.p)
  connect(voltageQuasiRMSSensor.plug_n, smee.plug_sn)
  connect(voltageQuasiRMSSensor.plug_p, smee.plug_sp)
  connect(terminalBox.plugSupply, currentQuasiRMSSensor.plug_n)
  connect(smee.flange, speed.flange)
  connect(speed.flange, speedSensor.flange)
  connect(speedRamp.y, speed.w_ref)
  connect(setPointGain.y, voltageController.u_s)
  connect(speedSensor.w, setPointGain.u)
  connect(voltageQuasiRMSSensor.V, voltageController.u_m)
  connect(voltageController.y, excitationVoltage.v)
  connect(loadInductor.plug_p, loadResistor.plug_n)
  connect(loadResistor.plug_p, switch.plug_n)
  connect(switch.plug_p, currentQuasiRMSSensor.plug_p)
  connect(star.plug_p, loadInductor.plug_n)
  connect(loadControl.y, switch.control[1])
  connect(loadControl.y, switch.control[2])
  connect(loadControl.y, switch.control[3])
  connect(star.pin_n, ground.p)
end SMEE_LoadDump;


Test example: ElectricalExcitedSynchronousMachine with rectifier. An electrically excited synchronous generator is driven with constant speed. Voltage is controlled,
the set point depends on speed. The generator is loaded with a rectifier.

within Modelica.Electrical.Machines.Examples.SynchronousMachines;
model SMEE_Rectifier
  "Test example: ElectricalExcitedSynchronousMachine with rectifier"
  extends Modelica.Icons.Example;
  import Modelica.Constants.pi;
  constant Integer m=3 "Number of phases";
  parameter SI.AngularVelocity wNominal=2*pi*smeeData.fsNominal
      /smee.p "Nominal speed";
  parameter SI.Voltage VDC0=sqrt(2*3)*smeeData.VsNominal
    "No-load DC voltage";
  parameter SI.Resistance RLoad=VDC0^2/smeeData.SNominal
    "Load resistance";
  parameter SI.Voltage Ve0=smee.IeOpenCircuit*
      Machines.Thermal.convertResistance(
            smee.Re,
            smee.TeRef,
            smee.alpha20e,
            smee.TeOperational) "No load excitation voltage";
  parameter Real k=2*Ve0/smeeData.VsNominal "Voltage controller: gain";
  parameter SI.Time Ti=smeeData.Td0Transient/2
    "Voltage controller: integral time constant";
  Machines.BasicMachines.SynchronousMachines.SM_ElectricalExcited smee(
    fsNominal=smeeData.fsNominal,
    Rs=smeeData.Rs,
    TsRef=smeeData.TsRef,
    Lssigma=smeeData.Lssigma,
    Lmd=smeeData.Lmd,
    Lmq=smeeData.Lmq,
    Lrsigmad=smeeData.Lrsigmad,
    Lrsigmaq=smeeData.Lrsigmaq,
    Rrd=smeeData.Rrd,
    Rrq=smeeData.Rrq,
    TrRef=smeeData.TrRef,
    VsNominal=smeeData.VsNominal,
    IeOpenCircuit=smeeData.IeOpenCircuit,
    Re=smeeData.Re,
    TeRef=smeeData.TeRef,
    sigmae=smeeData.sigmae,
    useDamperCage=true,
    p=2,
    Jr=0.29,
    Js=0.29,
    statorCoreParameters(VRef=100),
    strayLoadParameters(IRef=100),
    brushParameters(ILinear=0.01),
    TsOperational=293.15,
    alpha20s=smeeData.alpha20s,
    ir(each fixed=true),
    TrOperational=293.15,
    alpha20r=smeeData.alpha20r,
    alpha20e=smeeData.alpha20e,
    TeOperational=293.15)
  parameter Machines.Utilities.SynchronousMachineData smeeData(
    SNominal=30e3,
    VsNominal=100,
    fsNominal=50,
    IeOpenCircuit=10,
    x0=0.1,
    xd=1.6,
    xq=1.6,
    xdTransient=0.1375,
    xdSubtransient=0.121428571,
    xqSubtransient=0.148387097,
    Ta=0.014171268,
    Td0Transient=0.261177343,
    Td0Subtransient=0.006963029,
    Tq0Subtransient=0.123345081,
    TsSpecification=293.15,
    TsRef=293.15,
    alpha20s(displayUnit="1/K") = Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    TrSpecification=293.15,
    TrRef=293.15,
    alpha20r(displayUnit="1/K") = Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    TeSpecification=293.15,
    TeRef=293.15,
    alpha20e(displayUnit="1/K") = Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero)

  Machines.Utilities.TerminalBox terminalBox(terminalConnection="Y")
  Modelica.Electrical.Analog.Basic.Ground ground
  Modelica.Mechanics.Rotational.Sources.Speed speed
  Blocks.Sources.Constant constantSpeed(k=wNominal)
  Modelica.Mechanics.Rotational.Sensors.SpeedSensor speedSensor
  Modelica.Blocks.Math.Gain setPointGain(k=(smeeData.VsNominal/wNominal)/
        unitMagneticFlux)
  Modelica.Blocks.Continuous.LimPID voltageController(
    controllerType=Modelica.Blocks.Types.SimpleController.PI,
    k=k,
    Ti=Ti,
    yMax=2.5*Ve0,
    yMin=0,
    initType=Modelica.Blocks.Types.Init.InitialState,
    Td=0.001)
  Modelica.Electrical.Analog.Sources.SignalVoltage excitationVoltage
  Modelica.Electrical.Analog.Basic.Ground groundExcitation
  Modelica.Electrical.Polyphase.Basic.Star star1(m=m)
  Modelica.Electrical.Polyphase.Ideal.IdealDiode idealDiode1(
    m=m,
    Ron=fill(1E-5, m),
    Goff=fill(1E-5, m),
    Vknee=fill(0, m))
  Modelica.Electrical.Polyphase.Ideal.IdealDiode idealDiode2(
    m=m,
    Ron=fill(1E-5, m),
    Goff=fill(1E-5, m),
    Vknee=fill(0, m))
  Modelica.Electrical.Polyphase.Basic.Star star2(m=m)
  Modelica.Electrical.Analog.Basic.Capacitor capacitor1(C=2*10E-6, v(
        fixed=true, start=0))
  Modelica.Electrical.Analog.Basic.Capacitor capacitor2(C=2*10E-6, v(
        fixed=true, start=0))
  Modelica.Electrical.Analog.Basic.Resistor resistor(R=RLoad)
  Modelica.Electrical.Analog.Sensors.VoltageSensor voltageSensor
  Modelica.Blocks.Continuous.Filter filter(
    analogFilter=Modelica.Blocks.Types.AnalogFilter.CriticalDamping,
    filterType=Modelica.Blocks.Types.FilterType.LowPass,
    order=2,
    f_cut=20,
    gain=1/sqrt(2*3),
    normalized=true)
protected
  constant SI.MagneticFlux unitMagneticFlux=1
initial equation
  smee.is[1:2] = zeros(2);
  //conditional damper cage currents are defined as fixed start values
  smee.ie = 0;
equation
  connect(terminalBox.plug_sn, smee.plug_sn)
  connect(terminalBox.plug_sp, smee.plug_sp)
  connect(excitationVoltage.p, smee.pin_ep)
  connect(excitationVoltage.n, smee.pin_en)
  connect(excitationVoltage.n, groundExcitation.p)
  connect(smee.flange, speed.flange)
  connect(speed.flange, speedSensor.flange)
  connect(constantSpeed.y, speed.w_ref)
  connect(setPointGain.y, voltageController.u_s)
  connect(speedSensor.w, setPointGain.u)
  connect(voltageController.y, excitationVoltage.v)
  connect(idealDiode1.plug_p, idealDiode2.plug_n)
  connect(idealDiode2.plug_p, star2.plug_p)
  connect(idealDiode1.plug_n, star1.plug_p)
  connect(capacitor2.n, star2.pin_n)
  connect(capacitor1.p, star1.pin_n)
  connect(capacitor1.n, capacitor2.p)
  connect(capacitor1.n, ground.p)
  connect(filter.y, voltageController.u_m)
  connect(voltageSensor.v, filter.u)
  connect(terminalBox.plugSupply, idealDiode2.plug_n)
  connect(resistor.p, capacitor1.p)
  connect(resistor.n, capacitor2.n)
  connect(voltageSensor.n, capacitor2.n)
  connect(voltageSensor.p, capacitor1.p)
end SMEE_Rectifier;


Test example: PermanentMagnetSynchronousMachine acting as brake. A synchronous machine with permanent magnets starts braking from nominal speed by feeding a diode bridge,
which in turn feeds a braking resistor.
Since induced voltage is reduced proportional to falling speed, the braking resistance is set proportional to speed to
achieve constant current and torque.

within Modelica.Electrical.Machines.Examples.SynchronousMachines;
model SMPM_Braking
  "Test example: PermanentMagnetSynchronousMachine acting as brake"
  extends Modelica.Icons.Example;
  import Modelica.Constants.pi;
  constant Integer m=3 "Number of phases";
  constant Real unitK( unit="rad/(s.Ohm)")=1
  parameter SI.Resistance R=1 "Nominal braking resistance";
  parameter SI.AngularVelocity wNominal=2*pi*smpmData.fsNominal/smpmData.p
    "Nominal speed";
  parameter SI.Inertia JLoad=0.29
    "Load's moment of inertia";
  Machines.BasicMachines.SynchronousMachines.SM_PermanentMagnet smpm(
    phiMechanical(start=0, fixed=true),
    useSupport=false,
    useThermalPort=false,
    p=smpmData.p,
    fsNominal=smpmData.fsNominal,
    Rs=smpmData.Rs,
    TsRef=smpmData.TsRef,
    Lszero=smpmData.Lszero,
    Lssigma=smpmData.Lssigma,
    Jr=smpmData.Jr,
    Js=smpmData.Js,
    frictionParameters=smpmData.frictionParameters,
    statorCoreParameters=smpmData.statorCoreParameters,
    strayLoadParameters=smpmData.strayLoadParameters,
    VsOpenCircuit=smpmData.VsOpenCircuit,
    Lmd=smpmData.Lmd,
    Lmq=smpmData.Lmq,
    useDamperCage=smpmData.useDamperCage,
    Lrsigmad=smpmData.Lrsigmad,
    Lrsigmaq=smpmData.Lrsigmaq,
    Rrd=smpmData.Rrd,
    Rrq=smpmData.Rrq,
    TrRef=smpmData.TrRef,
    permanentMagnetLossParameters=smpmData.permanentMagnetLossParameters,
    TsOperational=293.15,
    alpha20s=smpmData.alpha20s,
    wMechanical(start=wNominal, fixed=true),
    TrOperational=293.15,
    alpha20r=smpmData.alpha20r)

  Modelica.Electrical.Analog.Basic.Ground ground
  Machines.Utilities.TerminalBox terminalBox(terminalConnection="Y")
  Modelica.Mechanics.Rotational.Components.Inertia inertiaLoad(J=JLoad)
  Modelica.Mechanics.Rotational.Sensors.SpeedSensor speedSensor
  parameter Machines.Utilities.ParameterRecords.SM_PermanentMagnetData smpmData(
      useDamperCage=false) "Synchronous machine data"
  Sensors.CurrentQuasiRMSSensor currentQuasiRMSSensor
  PowerConverters.ACDC.DiodeBridge2mPulse diodeBridge2mPulse(m=m)
  Analog.Basic.VariableResistor variableResistor
  Blocks.Math.Gain          gain(k=R/wNominal)
  Blocks.Nonlinear.Limiter          limiter(           uMin=0.1, uMax=10)
  Blocks.Math.Gain          ac2dc(k=pi^2/8)
  Polyphase.Basic.Star                     starM(final m=m)
  Sensors.VoltageQuasiRMSSensor          voltageQuasiRMSSensor
  Analog.Basic.Resistor grounding(R=1e6)
initial equation
  smpm.is[1:2] = zeros(2);
  smpm.i_0_s = 0;

equation
  connect(terminalBox.plug_sn, smpm.plug_sn)
  connect(terminalBox.plug_sp, smpm.plug_sp)
  connect(currentQuasiRMSSensor.plug_n, terminalBox.plugSupply)
  connect(diodeBridge2mPulse.ac, currentQuasiRMSSensor.plug_p)
  connect(variableResistor.p, diodeBridge2mPulse.dc_p)
  connect(variableResistor.n, diodeBridge2mPulse.dc_n)
  connect(smpm.flange, inertiaLoad.flange_a)
  connect(gain.u, speedSensor.w)
  connect(limiter.u, gain.y)
  connect(limiter.y, ac2dc.u)
  connect(ac2dc.y, variableResistor.R)
  connect(starM.plug_p, voltageQuasiRMSSensor.plug_n)
  connect(voltageQuasiRMSSensor.plug_p, currentQuasiRMSSensor.plug_n)
  connect(smpm.flange, speedSensor.flange)
  connect(terminalBox.starpoint, starM.pin_n)
  connect(ground.p, variableResistor.n)
  connect(ground.p, grounding.n)
  connect(starM.pin_n, grounding.p)
end SMPM_Braking;


Test example: PermanentMagnetSynchronousMachine fed by current source. A synchronous machine with permanent magnets accelerates a quadratic speed dependent load from standstill.
The rms values of d- and q-current in rotor fixed coordinate system are converted to three-phase currents,
and fed to the machine. The result shows that the torque is influenced by the q-current,
whereas the stator voltage is influenced by the d-current.

within Modelica.Electrical.Machines.Examples.SynchronousMachines;
model SMPM_CurrentSource
  "Test example: PermanentMagnetSynchronousMachine fed by current source"
  extends Modelica.Icons.Example;
  import Modelica.Constants.pi;
  constant Integer m=3 "Number of phases";
  parameter SI.Current Idq[2]={-53.5, 84.6}
    "Desired d- and q-current";
  parameter SI.AngularVelocity wNominal=2*pi*smpmData.fsNominal/smpmData.p
    "Nominal speed";
  parameter SI.Torque TLoad=181.4 "Nominal load torque";
  parameter SI.Inertia JLoad=0.29
    "Load's moment of inertia";
  Machines.BasicMachines.SynchronousMachines.SM_PermanentMagnet smpm(
    p=smpmData.p,
    fsNominal=smpmData.fsNominal,
    TsOperational=293.15,
    Rs=smpmData.Rs,
    TsRef=smpmData.TsRef,
    alpha20s=smpmData.alpha20s,
    Lszero=smpmData.Lszero,
    Lssigma=smpmData.Lssigma,
    Jr=smpmData.Jr,
    Js=smpmData.Js,
    frictionParameters=smpmData.frictionParameters,
    phiMechanical(fixed=true),
    wMechanical(fixed=true),
    statorCoreParameters=smpmData.statorCoreParameters,
    strayLoadParameters=smpmData.strayLoadParameters,
    TrOperational=293.15,
    VsOpenCircuit=smpmData.VsOpenCircuit,
    Lmd=smpmData.Lmd,
    Lmq=smpmData.Lmq,
    useDamperCage=smpmData.useDamperCage,
    Lrsigmad=smpmData.Lrsigmad,
    Lrsigmaq=smpmData.Lrsigmaq,
    Rrd=smpmData.Rrd,
    Rrq=smpmData.Rrq,
    TrRef=smpmData.TrRef,
    alpha20r=smpmData.alpha20r,
    permanentMagnetLossParameters=smpmData.permanentMagnetLossParameters)
  Modelica.Electrical.Polyphase.Sources.SignalCurrent signalCurrent(
      final m=m)
  Modelica.Electrical.Polyphase.Basic.Star star(final m=m)
  Modelica.Electrical.Analog.Basic.Ground ground
  Utilities.DQToThreePhase dqToThreePhase(p=smpm.p)
  Modelica.Blocks.Sources.Constant iq(k=Idq[2])
  Modelica.Blocks.Sources.Constant id(k=Idq[1])
  Sensors.VoltageQuasiRMSSensor voltageQuasiRMSSensor
  Modelica.Electrical.Polyphase.Basic.Star starM(final m=m)
  Modelica.Electrical.Analog.Basic.Ground groundM
  Machines.Utilities.TerminalBox terminalBox(terminalConnection="Y")
  Machines.Sensors.RotorDisplacementAngle rotorDisplacementAngle(p=smpm.p)
  Mechanics.Rotational.Sensors.AngleSensor angleSensor
  Mechanics.Rotational.Sensors.MultiSensor  multiSensor
  Mechanics.Rotational.Components.Inertia inertiaLoad(J=JLoad)
  Mechanics.Rotational.Sources.QuadraticSpeedDependentTorque
    quadraticSpeedDependentTorque(            tau_nominal=-TLoad,
      w_nominal(displayUnit="rad/s") = wNominal)
  parameter Utilities.ParameterRecords.SM_PermanentMagnetData smpmData(
      useDamperCage=false) "Synchronous machine data"
  Sensors.CurrentQuasiRMSSensor currentQuasiRMSSensor
equation
  connect(star.pin_n, ground.p)
  connect(rotorDisplacementAngle.plug_n, smpm.plug_sn)
  connect(rotorDisplacementAngle.plug_p, smpm.plug_sp)
  connect(terminalBox.plug_sn, smpm.plug_sn)
  connect(terminalBox.plug_sp, smpm.plug_sp)
  connect(smpm.flange, rotorDisplacementAngle.flange)
  connect(signalCurrent.plug_p, star.plug_p)
  connect(id.y, dqToThreePhase.d)
  connect(iq.y, dqToThreePhase.q)
  connect(groundM.p, terminalBox.starpoint)
  connect(smpm.flange, multiSensor.flange_a)
  connect(voltageQuasiRMSSensor.plug_p, terminalBox.plugSupply)
  connect(starM.plug_p, voltageQuasiRMSSensor.plug_n)
  connect(starM.pin_n, groundM.p)
  connect(dqToThreePhase.y, signalCurrent.i)
  connect(quadraticSpeedDependentTorque.flange, inertiaLoad.flange_b)
  connect(multiSensor.flange_b, inertiaLoad.flange_a)
  connect(signalCurrent.plug_n, currentQuasiRMSSensor.plug_p)
  connect(currentQuasiRMSSensor.plug_n, voltageQuasiRMSSensor.plug_p)
  connect(smpm.flange, angleSensor.flange)
  connect(angleSensor.phi, dqToThreePhase.phi)
end SMPM_CurrentSource;


Test example: PermanentMagnetSynchronousMachine with inverter. An ideal frequency inverter is modeled by using a VfController and a three-phase SignalVoltage.
Frequency is raised by a ramp, causing the permanent magnet synchronous machine to start,
and accelerating inertias. At time tStep a load step is applied.

within Modelica.Electrical.Machines.Examples.SynchronousMachines;
model SMPM_Inverter
  "Test example: PermanentMagnetSynchronousMachine with inverter"
  extends Modelica.Icons.Example;
  constant Integer m=3 "Number of phases";
  parameter SI.Voltage VNominal=100
    "Nominal RMS voltage per phase";
  parameter SI.Frequency fNominal=50 "Nominal frequency";
  parameter SI.Frequency f=50 "Actual frequency";
  parameter SI.Time tRamp=1 "Frequency ramp";
  parameter SI.Torque TLoad=181.4 "Nominal load torque";
  parameter SI.Time tStep=1.2 "Time of load torque step";
  parameter SI.Inertia JLoad=0.29
    "Load's moment of inertia";
  Machines.BasicMachines.SynchronousMachines.SM_PermanentMagnet smpm(
    p=smpmData.p,
    fsNominal=smpmData.fsNominal,
    Rs=smpmData.Rs,
    TsRef=smpmData.TsRef,
    Lszero=smpmData.Lszero,
    Lssigma=smpmData.Lssigma,
    Jr=smpmData.Jr,
    Js=smpmData.Js,
    frictionParameters=smpmData.frictionParameters,
    phiMechanical(fixed=true),
    wMechanical(fixed=true),
    statorCoreParameters=smpmData.statorCoreParameters,
    strayLoadParameters=smpmData.strayLoadParameters,
    VsOpenCircuit=smpmData.VsOpenCircuit,
    Lmd=smpmData.Lmd,
    Lmq=smpmData.Lmq,
    useDamperCage=smpmData.useDamperCage,
    Lrsigmad=smpmData.Lrsigmad,
    Lrsigmaq=smpmData.Lrsigmaq,
    Rrd=smpmData.Rrd,
    Rrq=smpmData.Rrq,
    TrRef=smpmData.TrRef,
    permanentMagnetLossParameters=smpmData.permanentMagnetLossParameters,
    TsOperational=293.15,
    alpha20s=smpmData.alpha20s,
    ir(each fixed=true),
    TrOperational=293.15,
    alpha20r=smpmData.alpha20r)

  Machines.Sensors.CurrentQuasiRMSSensor currentQuasiRMSSensor
  Machines.Sensors.RotorDisplacementAngle rotorDisplacementAngle(p=smpm.p)
  Modelica.Blocks.Sources.Ramp ramp(height=f, duration=tRamp)
  Machines.Utilities.VfController vfController(
    final m=m,
    VNominal=VNominal,
    fNominal=fNominal,
    BasePhase=+Modelica.Constants.pi/2)
  Modelica.Electrical.Polyphase.Sources.SignalVoltage signalVoltage(
      final m=m)
  Modelica.Electrical.Polyphase.Basic.Star star(final m=m)
  Modelica.Electrical.Analog.Basic.Ground ground
  Modelica.Mechanics.Rotational.Components.Inertia loadInertia(J=JLoad)
  Modelica.Mechanics.Rotational.Sources.TorqueStep loadTorqueStep(
    startTime=tStep,
    stepTorque=-TLoad,
    useSupport=false,
    offsetTorque=0)
  Machines.Utilities.TerminalBox terminalBox(terminalConnection="Y")
  parameter Utilities.ParameterRecords.SM_PermanentMagnetData smpmData "Synchronous machine data"
initial equation
  smpm.is[1:2] = zeros(2);
  //conditional damper cage currents are defined as fixed start values
equation
  connect(signalVoltage.plug_n, star.plug_p)
  connect(star.pin_n, ground.p)
  connect(ramp.y, vfController.u)
  connect(vfController.y, signalVoltage.v)
  connect(loadInertia.flange_b, loadTorqueStep.flange)
  connect(signalVoltage.plug_p, currentQuasiRMSSensor.plug_p)
  connect(rotorDisplacementAngle.plug_n, smpm.plug_sn)
  connect(rotorDisplacementAngle.plug_p, smpm.plug_sp)
  connect(terminalBox.plugSupply, currentQuasiRMSSensor.plug_n)
  connect(terminalBox.plug_sn, smpm.plug_sn)
  connect(terminalBox.plug_sp, smpm.plug_sp)
  connect(smpm.flange, rotorDisplacementAngle.flange)
  connect(smpm.flange, loadInertia.flange_a)
end SMPM_Inverter;


SMPM at no-load. Synchronous machine with permanent magnets at no-load, driven with linear time dependent speed.

within Modelica.Electrical.Machines.Examples.SynchronousMachines;
model SMPM_NoLoad "SMPM at no-load"
  extends Modelica.Icons.Example;
  import Modelica.Constants.pi;
  constant Integer m=3 "Number of phases";
  parameter
    Modelica.Electrical.Machines.Utilities.ParameterRecords.SM_PermanentMagnetData
    smpmData(useDamperCage=false) "Synchronous machine data"
  Modelica.Electrical.Machines.BasicMachines.SynchronousMachines.SM_PermanentMagnet
    smpm(
    p=smpmData.p,
    fsNominal=smpmData.fsNominal,
    Rs=smpmData.Rs,
    TsRef=smpmData.TsRef,
    Lszero=smpmData.Lszero,
    Lssigma=smpmData.Lssigma,
    Jr=smpmData.Jr,
    VsOpenCircuit=smpmData.VsOpenCircuit,
    Lmd=smpmData.Lmd,
    Lmq=smpmData.Lmq,
    useDamperCage=smpmData.useDamperCage,
    Lrsigmad=smpmData.Lrsigmad,
    Lrsigmaq=smpmData.Lrsigmaq,
    Rrd=smpmData.Rrd,
    Rrq=smpmData.Rrq,
    TrRef=smpmData.TrRef,
    frictionParameters=smpmData.frictionParameters,
    statorCoreParameters=smpmData.statorCoreParameters,
    strayLoadParameters=smpmData.strayLoadParameters,
    permanentMagnetLossParameters=smpmData.permanentMagnetLossParameters,
    TsOperational=293.15,
    alpha20s=smpmData.alpha20s,
    phiMechanical(fixed=true, start=(pi + 0*2*pi/m)/smpmData.p),
    TrOperational=293.15,
    alpha20r=smpmData.alpha20r)
  Modelica.Electrical.Machines.Utilities.TerminalBox terminalBox(
      terminalConnection="Y", m=m)
  Modelica.Electrical.Analog.Basic.Ground ground
  Modelica.Electrical.Polyphase.Sensors.PotentialSensor potentialSensor(m=m)
  Modelica.Electrical.Machines.SpacePhasors.Blocks.ToSpacePhasor toSpacePhasor(m=m)
  SpacePhasors.Blocks.ToPolar toPolar
  Blocks.Math.Gain toDeg(k=180/pi)
  Sensors.HallSensor hallSensor(p=smpmData.p)
  Mechanics.Rotational.Sources.Speed                  speed(exact=true, phi(
        fixed=false))

  Blocks.Sources.Ramp ramp(
    height=4*pi*smpmData.fsNominal/smpmData.p,
    duration=0.16,
    offset=-2*pi*smpmData.fsNominal/smpmData.p,
    startTime=0.08)
equation
  connect(terminalBox.plug_sn, smpm.plug_sn)
  connect(terminalBox.plug_sp, smpm.plug_sp)
  connect(ground.p, terminalBox.starpoint)
  connect(potentialSensor.plug_p, terminalBox.plugSupply)
  connect(potentialSensor.phi, toSpacePhasor.u)
  connect(speed.flange, smpm.flange)
  connect(smpm.flange, hallSensor.flange)
  connect(toSpacePhasor.y, toPolar.u)
  connect(toPolar.y[2], toDeg.u)
  connect(ramp.y, speed.w_ref)
end SMPM_NoLoad;


PermanentMagnetSynchronousMachine braking with a resistor. The voltages induced by the permanent magnets of the synchronous machine is shortened over the inductance and resistance of the stator winding
and the (optional) external braking resistors. The currents driven by these voltages cause a braking torque.

within Modelica.Electrical.Machines.Examples.SynchronousMachines;
model SMPM_ResistiveBraking
  "PermanentMagnetSynchronousMachine braking with a resistor"
  extends Modelica.Icons.Example;
  import Modelica.Constants.pi;
  constant Integer m=3 "Number of phases";
  parameter SI.Inertia JLoad=4*smpmData.Jr "Load's moment of inertia";
  parameter SI.AngularVelocity w0(displayUnit="rev/min")=
    2*pi*smpmData.fsNominal/smpmData.p "Initial speed";
  parameter Real k[3]={1,3,5} "Braking resistance stages w.r.t. Rs";
  parameter SI.Current idq_sr[2](each fixed=false)
    "Initial stator current space phasor";
  SI.Torque tauElectrical=smpm.tauElectrical "Electrical torque";
  SI.Torque tauShaft=smpm.tauShaft "Shaft torque";
  SI.AngularVelocity wMechanical(displayUnit="rev/min")=
    smpm.wMechanical "Shaft speed";
  parameter
    Modelica.Electrical.Machines.Utilities.ParameterRecords.SM_PermanentMagnetData
    smpmData(useDamperCage=false)
  Modelica.Electrical.Machines.BasicMachines.SynchronousMachines.SM_PermanentMagnet
    smpm(
    phiMechanical(start=0, fixed=true),
    useSupport=false,
    useThermalPort=false,
    p=smpmData.p,
    fsNominal=smpmData.fsNominal,
    Rs=smpmData.Rs,
    TsRef=smpmData.TsRef,
    Lssigma=smpmData.Lssigma,
    Jr=smpmData.Jr,
    Js=smpmData.Js,
    frictionParameters=smpmData.frictionParameters,
    statorCoreParameters=smpmData.statorCoreParameters,
    strayLoadParameters=smpmData.strayLoadParameters,
    VsOpenCircuit=smpmData.VsOpenCircuit,
    Lmd=smpmData.Lmd,
    Lmq=smpmData.Lmq,
    useDamperCage=smpmData.useDamperCage,
    Lrsigmad=smpmData.Lrsigmad,
    Lrsigmaq=smpmData.Lrsigmaq,
    Rrd=smpmData.Rrd,
    Rrq=smpmData.Rrq,
    TrRef=smpmData.TrRef,
    permanentMagnetLossParameters=smpmData.permanentMagnetLossParameters,
    TsOperational=293.15,
    alpha20s=smpmData.alpha20s,
    wMechanical(fixed=true, start=w0),
    TrOperational=293.15,
    alpha20r=smpmData.alpha20r)

  Modelica.Mechanics.Rotational.Components.Inertia inertiaLoad(J=JLoad)
  Modelica.Electrical.Machines.Utilities.TerminalBox terminalBox(m=m,
      terminalConnection="Y")
  Modelica.Electrical.Polyphase.Sensors.CurrentQuasiRMSSensor
    currentQuasiRMSSensor(m=m)
  Modelica.Electrical.Polyphase.Basic.Star star(final m=m)
  Modelica.Electrical.Analog.Basic.Ground
    ground
  Modelica.Electrical.Polyphase.Sensors.VoltageQuasiRMSSensor
    voltageRMSSensor(m=m)
  Modelica.Electrical.Polyphase.Basic.Resistor resistor1(m=m, R=k[1]*fill(
        smpmData.Rs, m))
  Modelica.Electrical.Polyphase.Basic.Resistor resistor2(m=m, R=k[2]*fill(
        smpmData.Rs, m))
  Modelica.Electrical.Polyphase.Basic.Resistor resistor3(m=m, R=k[3]*fill(
        smpmData.Rs, m))
  Modelica.Electrical.Polyphase.Ideal.IdealClosingSwitch switch2(
    m=m,
    Ron=fill(1e-9, m),
    Goff=fill(1e-9, m))
  Modelica.Electrical.Polyphase.Ideal.IdealClosingSwitch switch3(
    m=m,
    Ron=fill(1e-9, m),
    Goff=fill(1e-9, m))
  Modelica.Blocks.Routing.BooleanReplicator booleanReplicator2(nout=m)
  Modelica.Blocks.Routing.BooleanReplicator booleanReplicator3(nout=m)
  Modelica.Blocks.Sources.BooleanStep booleanStep2(startTime=0.65)
  Modelica.Blocks.Sources.BooleanStep booleanStep3(startTime=0.5)
initial equation
  0 = (1 + sum(k))*smpmData.Rs*idq_sr[1] - w0*smpmData.p*(smpmData.Lssigma + smpmData.Lmq)*idq_sr[2];
  0 = (1 + sum(k))*smpmData.Rs*idq_sr[2] + w0*smpmData.p*(smpmData.Lssigma + smpmData.Lmd)*idq_sr[1] + sqrt(2)*smpmData.VsOpenCircuit;
  smpm.idq_sr=idq_sr;
equation
  connect(smpm.flange, inertiaLoad.flange_a)
  connect(terminalBox.plug_sn, smpm.plug_sn)
  connect(terminalBox.plug_sp, smpm.plug_sp)
  connect(star.pin_n, ground.p)
  connect(currentQuasiRMSSensor.plug_n, terminalBox.plugSupply)
  connect(resistor1.plug_p, currentQuasiRMSSensor.plug_p)
  connect(currentQuasiRMSSensor.plug_p, voltageRMSSensor.plug_p)
  connect(star.plug_p, voltageRMSSensor.plug_n)
  connect(resistor1.plug_n, resistor2.plug_p)
  connect(resistor2.plug_n, resistor3.plug_p)
  connect(resistor3.plug_n, star.plug_p)
  connect(resistor2.plug_n, switch2.plug_n)
  connect(resistor2.plug_p, switch2.plug_p)
  connect(resistor3.plug_n, switch3.plug_n)
  connect(resistor3.plug_p, switch3.plug_p)
  connect(booleanReplicator2.y, switch2.control)
  connect(booleanReplicator3.y, switch3.control)
  connect(booleanStep3.y, booleanReplicator3.u)
  connect(booleanStep2.y, booleanReplicator2.u)
end SMPM_ResistiveBraking;


Test example: PermanentMagnetSynchronousMachine fed by FOC. A synchronous machine with permanent magnets accelerates a quadratic speed dependent load from standstill.
The rms values of d- and q-current in rotor fixed coordinate system are controlled by the dqCurrentController,
and the output voltages fed to the machine. The result shows that the torque is influenced by the q-current,
whereas the stator voltage is influenced by the d-current.

within Modelica.Electrical.Machines.Examples.SynchronousMachines;
model SMPM_VoltageSource
  "Test example: PermanentMagnetSynchronousMachine fed by FOC"
  extends Modelica.Icons.Example;
  import Modelica.Constants.pi;
  constant Integer m=3 "Number of phases";
  parameter SI.Current Idq[2]={-53.5, 84.6}
    "Desired d- and q-current";
  parameter SI.AngularVelocity wNominal=2*pi*smpmData.fsNominal/smpmData.p
    "Nominal speed";
  parameter SI.Torque TLoad=181.4 "Nominal load torque";
  parameter SI.Inertia JLoad=0.29
    "Load's moment of inertia";
  Machines.BasicMachines.SynchronousMachines.SM_PermanentMagnet smpm(
    phiMechanical(start=0, fixed=true),
    wMechanical(start=0, fixed=true),
    useSupport=false,
    useThermalPort=false,
    p=smpmData.p,
    fsNominal=smpmData.fsNominal,
    Rs=smpmData.Rs,
    TsRef=smpmData.TsRef,
    Lszero=smpmData.Lszero,
    Lssigma=smpmData.Lssigma,
    Jr=smpmData.Jr,
    Js=smpmData.Js,
    frictionParameters=smpmData.frictionParameters,
    statorCoreParameters=smpmData.statorCoreParameters,
    strayLoadParameters=smpmData.strayLoadParameters,
    VsOpenCircuit=smpmData.VsOpenCircuit,
    Lmd=smpmData.Lmd,
    Lmq=smpmData.Lmq,
    useDamperCage=smpmData.useDamperCage,
    Lrsigmad=smpmData.Lrsigmad,
    Lrsigmaq=smpmData.Lrsigmaq,
    Rrd=smpmData.Rrd,
    Rrq=smpmData.Rrq,
    TrRef=smpmData.TrRef,
    permanentMagnetLossParameters=smpmData.permanentMagnetLossParameters,
    TsOperational=293.15,
    alpha20s=smpmData.alpha20s,
    TrOperational=293.15,
    alpha20r=smpmData.alpha20r)

  Modelica.Electrical.Polyphase.Sources.SignalVoltage signalVoltage(
      final m=m)
  Modelica.Electrical.Polyphase.Basic.Star star(final m=m)
  Modelica.Electrical.Analog.Basic.Ground ground
  Modelica.Blocks.Sources.Constant iq(k=Idq[2])
  Modelica.Blocks.Sources.Constant id(k=Idq[1])
  Machines.Utilities.TerminalBox terminalBox(terminalConnection="Y")
  Modelica.Mechanics.Rotational.Components.Inertia inertiaLoad(J=JLoad)
  Modelica.Mechanics.Rotational.Sources.QuadraticSpeedDependentTorque
    quadraticSpeedDependentTorque(            tau_nominal=-TLoad,
      w_nominal(displayUnit="rad/s") = wNominal)
  Modelica.Electrical.Polyphase.Sensors.CurrentSensor currentSensor(m=m)
  Utilities.DQCurrentController dqCurrentController(
    p=smpm.p,
    Ld=smpm.Lssigma + smpm.Lmd,
    Lq=smpm.Lssigma + smpm.Lmq,
    Rs=Machines.Thermal.convertResistance(
              smpm.Rs,
              smpm.TsRef,
              smpm.alpha20s,
              smpm.TsOperational),
    fsNominal=smpm.fsNominal,
    VsOpenCircuit=smpm.VsOpenCircuit)
  Mechanics.Rotational.Sensors.MultiSensor           multiSensor
  Machines.Sensors.RotorDisplacementAngle rotorDisplacementAngle(p=smpm.p)
  Modelica.Electrical.Analog.Basic.Ground groundM
  Modelica.Electrical.Polyphase.Basic.Star starM(final m=m)
  Machines.Sensors.VoltageQuasiRMSSensor voltageQuasiRMSSensor
  parameter Machines.Utilities.ParameterRecords.SM_PermanentMagnetData smpmData(
      useDamperCage=false) "Synchronous machine data"
  Sensors.CurrentQuasiRMSSensor currentQuasiRMSSensor
  Sensors.SinCosResolver sinCosResolver(p=1)
  Utilities.SinCosEvaluation sinCosEvaluation
initial equation
  smpm.is[1:2] = zeros(2);

equation
  connect(star.pin_n, ground.p)
  connect(terminalBox.plug_sn, smpm.plug_sn)
  connect(terminalBox.plug_sp, smpm.plug_sp)
  connect(quadraticSpeedDependentTorque.flange, inertiaLoad.flange_b)
  connect(star.plug_p, signalVoltage.plug_n)
  connect(currentSensor.plug_n, terminalBox.plugSupply)
  connect(id.y, dqCurrentController.id)
  connect(iq.y, dqCurrentController.iq)
  connect(dqCurrentController.y, signalVoltage.v)
  connect(currentSensor.i, dqCurrentController.iActual)
  connect(inertiaLoad.flange_a, multiSensor.flange_b)
  connect(multiSensor.flange_a, smpm.flange)
  connect(rotorDisplacementAngle.flange, smpm.flange)
  connect(rotorDisplacementAngle.plug_p, smpm.plug_sp)
  connect(rotorDisplacementAngle.plug_n, smpm.plug_sn)
  connect(voltageQuasiRMSSensor.plug_p, currentSensor.plug_n)
  connect(starM.plug_p, voltageQuasiRMSSensor.plug_n)
  connect(groundM.p, starM.pin_n)
  connect(currentQuasiRMSSensor.plug_n, currentSensor.plug_p)
  connect(signalVoltage.plug_p, currentQuasiRMSSensor.plug_p)
  connect(smpm.flange, sinCosResolver.flange)
  connect(sinCosResolver.y, sinCosEvaluation.u)
  connect(sinCosEvaluation.phi, dqCurrentController.phi)
end SMPM_VoltageSource;


Test example: SynchronousMachineReluctanceRotor direct-on-line.

within Modelica.Electrical.Machines.Examples.SynchronousMachines;
model SMR_DOL
  "Test example: SynchronousMachineReluctanceRotor direct-on-line"
  extends Modelica.Icons.Example;
  constant Integer m=3 "Number of phases";
  parameter SI.Voltage VNominal=100
    "Nominal RMS voltage per phase";
  parameter SI.Frequency fNominal=50 "Nominal frequency";
  parameter SI.Frequency f=50 "Actual frequency";
  parameter SI.Time tStart1=0.1 "Switch-on time";
  parameter SI.Torque TLoad=20 "Nominal load torque";
  parameter SI.Time tStep=1.5 "Time of load torque step";
  parameter SI.Inertia JLoad=0.29
    "Load's moment of inertia";
  Modelica.Electrical.Machines.BasicMachines.SynchronousMachines.SM_ReluctanceRotor
    smr(
    p=smrData.p,
    fsNominal=smrData.fsNominal,
    Rs=smrData.Rs,
    TsRef=smrData.TsRef,
    Lszero=smrData.Lszero,
    Lssigma=smrData.Lssigma,
    Jr=smrData.Jr,
    Js=smrData.Js,
    frictionParameters=smrData.frictionParameters,
    phiMechanical(fixed=true),
    wMechanical(fixed=true),
    statorCoreParameters=smrData.statorCoreParameters,
    strayLoadParameters=smrData.strayLoadParameters,
    Lmd=smrData.Lmd,
    Lmq=smrData.Lmq,
    useDamperCage=smrData.useDamperCage,
    Lrsigmad=smrData.Lrsigmad,
    Lrsigmaq=smrData.Lrsigmaq,
    Rrd=smrData.Rrd,
    Rrq=smrData.Rrq,
    TrRef=smrData.TrRef,
    TsOperational=293.15,
    alpha20s=smrData.alpha20s,
    ir(each fixed=true),
    TrOperational=293.15,
    alpha20r=smrData.alpha20r)
  Modelica.Electrical.Machines.Sensors.CurrentQuasiRMSSensor currentQuasiRMSSensor
  Modelica.Electrical.Machines.Sensors.RotorDisplacementAngle rotorDisplacementAngle(p=smr.p)
  Modelica.Mechanics.Rotational.Components.Inertia loadInertia(J=JLoad)
  Modelica.Mechanics.Rotational.Sources.TorqueStep loadTorqueStep(
    startTime=tStep,
    stepTorque=-TLoad,
    useSupport=false,
    offsetTorque=0)
  Modelica.Electrical.Machines.Utilities.TerminalBox terminalBox(
      terminalConnection="Y")
  parameter
    Modelica.Electrical.Machines.Utilities.ParameterRecords.SM_ReluctanceRotorData
    smrData "Synchronous machine data"
  Modelica.Electrical.Polyphase.Sources.SineVoltage sineVoltage(
    final m=m,
    f=fill(fNominal, m),
    V=fill(sqrt(2/3)*VNominal, m))
  Modelica.Electrical.Polyphase.Basic.Star star(final m=m)
  Modelica.Electrical.Analog.Basic.Ground ground
  Modelica.Blocks.Sources.BooleanStep booleanStep[m](each startTime=
        tStart1)
  Modelica.Electrical.Polyphase.Ideal.IdealClosingSwitch idealCloser(
    final m=m,
    Ron=fill(1e-5, m),
    Goff=fill(1e-5, m))
initial equation
  smr.is[1:2] = zeros(2);
equation
  connect(loadInertia.flange_b, loadTorqueStep.flange)
  connect(smr.plug_sn, rotorDisplacementAngle.plug_n)
  connect(smr.plug_sp, rotorDisplacementAngle.plug_p)
  connect(terminalBox.plugSupply, currentQuasiRMSSensor.plug_n)
  connect(terminalBox.plug_sp, smr.plug_sp)
  connect(terminalBox.plug_sn, smr.plug_sn)
  connect(smr.flange, rotorDisplacementAngle.flange)
  connect(smr.flange, loadInertia.flange_a)
  connect(star.pin_n,ground. p)
  connect(sineVoltage.plug_n,star. plug_p)
  connect(sineVoltage.plug_p,idealCloser. plug_p)
  connect(booleanStep.y,idealCloser. control)
  connect(idealCloser.plug_n, currentQuasiRMSSensor.plug_p)
end SMR_DOL;


Test example: SynchronousMachineReluctanceRotor with inverter. An ideal frequency inverter is modeled by using a VfController and a three-phase SignalVoltage.
Frequency is raised by a ramp, causing the reluctance machine to start,
and accelerating inertias. At time tStep a load step is applied.

within Modelica.Electrical.Machines.Examples.SynchronousMachines;
model SMR_Inverter
  "Test example: SynchronousMachineReluctanceRotor with inverter"
  extends Modelica.Icons.Example;
  constant Integer m=3 "Number of phases";
  parameter SI.Voltage VNominal=100
    "Nominal RMS voltage per phase";
  parameter SI.Frequency fNominal=50 "Nominal frequency";
  parameter SI.Frequency f=50 "Actual frequency";
  parameter SI.Time tRamp=1 "Frequency ramp";
  parameter SI.Torque TLoad=46 "Nominal load torque";
  parameter SI.Time tStep=1.2 "Time of load torque step";
  parameter SI.Inertia JLoad=0.29
    "Load's moment of inertia";
  Machines.BasicMachines.SynchronousMachines.SM_ReluctanceRotor smr(
    p=smrData.p,
    fsNominal=smrData.fsNominal,
    Rs=smrData.Rs,
    TsRef=smrData.TsRef,
    Lszero=smrData.Lszero,
    Lssigma=smrData.Lssigma,
    Jr=smrData.Jr,
    Js=smrData.Js,
    frictionParameters=smrData.frictionParameters,
    phiMechanical(fixed=true),
    wMechanical(fixed=true),
    statorCoreParameters=smrData.statorCoreParameters,
    strayLoadParameters=smrData.strayLoadParameters,
    Lmd=smrData.Lmd,
    Lmq=smrData.Lmq,
    useDamperCage=smrData.useDamperCage,
    Lrsigmad=smrData.Lrsigmad,
    Lrsigmaq=smrData.Lrsigmaq,
    Rrd=smrData.Rrd,
    Rrq=smrData.Rrq,
    TrRef=smrData.TrRef,
    TsOperational=293.15,
    alpha20s=smrData.alpha20s,
    ir(each fixed=true),
    TrOperational=293.15,
    alpha20r=smrData.alpha20r)
  Machines.Sensors.CurrentQuasiRMSSensor currentQuasiRMSSensor
  Machines.Sensors.RotorDisplacementAngle rotorDisplacementAngle(p=smr.p)
  Modelica.Blocks.Sources.Ramp ramp(height=f, duration=tRamp)
  Machines.Utilities.VfController vfController(
    final m=m,
    VNominal=VNominal,
    fNominal=fNominal)
  Modelica.Electrical.Polyphase.Sources.SignalVoltage signalVoltage(
      final m=m)
  Modelica.Electrical.Polyphase.Basic.Star star(final m=m)
  Modelica.Electrical.Analog.Basic.Ground ground
  Modelica.Mechanics.Rotational.Components.Inertia loadInertia(J=JLoad)
  Modelica.Mechanics.Rotational.Sources.TorqueStep loadTorqueStep(
    startTime=tStep,
    stepTorque=-TLoad,
    useSupport=false,
    offsetTorque=0)
  Machines.Utilities.TerminalBox terminalBox(terminalConnection="Y")
  parameter Utilities.ParameterRecords.SM_ReluctanceRotorData smrData "Synchronous machine data"
initial equation
  smr.is[1:2] = zeros(2);
  //conditional damper cage currents are defined as fixed start values
equation
  connect(signalVoltage.plug_n, star.plug_p)
  connect(star.pin_n, ground.p)
  connect(ramp.y, vfController.u)
  connect(vfController.y, signalVoltage.v)
  connect(loadInertia.flange_b, loadTorqueStep.flange)
  connect(currentQuasiRMSSensor.plug_p, signalVoltage.plug_p)
  connect(smr.plug_sn, rotorDisplacementAngle.plug_n)
  connect(smr.plug_sp, rotorDisplacementAngle.plug_p)
  connect(terminalBox.plugSupply, currentQuasiRMSSensor.plug_n)
  connect(terminalBox.plug_sp, smr.plug_sp)
  connect(terminalBox.plug_sn, smr.plug_sn)
  connect(smr.flange, rotorDisplacementAngle.flange)
  connect(smr.flange, loadInertia.flange_a)
end SMR_Inverter;


Asymmetrical load.

within Modelica.Electrical.Machines.Examples.Transformers;
model AsymmetricalLoad "Asymmetrical load"
  extends Modelica.Icons.Example;
  parameter SI.Resistance RL=1 "Load resistance";
  Modelica.Electrical.Polyphase.Sources.SineVoltage source(f=fill(
        50, 3), V=fill(sqrt(2/3)*100, 3))
  Modelica.Electrical.Polyphase.Basic.Star starS
  Modelica.Electrical.Analog.Basic.Ground groundS
  Modelica.Electrical.Polyphase.Sensors.CurrentSensor currentSensorS
  Modelica.Electrical.Analog.Basic.Ground groundL
  parameter Machines.Utilities.TransformerData transformerData(
    C1=Modelica.Utilities.Strings.substring(
        transformer.VectorGroup,
        1,
        1),
    C2=Modelica.Utilities.Strings.substring(
        transformer.VectorGroup,
        2,
        2),
    f=50,
    V1=100,
    V2=100,
    SNominal=30E3,
    v_sc=0.05,
    P_sc=300) "Transformer data"
  BasicMachines.Transformers.Dy.Dy01 transformer(
    n=transformerData.n,
    R1=transformerData.R1,
    L1sigma=transformerData.L1sigma,
    R2=transformerData.R2,
    L2sigma=transformerData.L2sigma,
    T1Ref=293.15,
    alpha20_1(displayUnit="1/K")=Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    T2Ref=293.15,
    alpha20_2(displayUnit="1/K")=Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    T1Operational=293.15,
    T2Operational=293.15)

  Modelica.Electrical.Polyphase.Basic.PlugToPin_n plugToPin_n(k=1)
  Analog.Basic.Resistor load(R=RL)
  Analog.Basic.Resistor earth(R=1e6)
  Analog.Basic.Ground groundT
initial equation
  transformer.i2[1] = 0;
equation
  connect(starS.pin_n, groundS.p)
  connect(source.plug_n, starS.plug_p)
  connect(currentSensorS.plug_n, transformer.plug1)
  connect(transformer.plug2, plugToPin_n.plug_n)
  connect(transformer.starpoint2, groundL.p)
  connect(load.p, plugToPin_n.pin_n)
  connect(transformer.starpoint2, load.n)
  connect(source.plug_p, currentSensorS.plug_p)
  connect(earth.n, groundT.p)
end AsymmetricalLoad;


Test example: InductionMachineSquirrelCage transformer starting.

within Modelica.Electrical.Machines.Examples.Transformers;
model IMC_Transformer
  "Test example: InductionMachineSquirrelCage transformer starting"
  extends Machines.Examples.InductionMachines.IMC_Transformer;
end IMC_Transformer;


Test examples of transformers

within Modelica.Electrical.Machines.Examples;
package Transformers "Test examples of transformers"
  extends Modelica.Icons.ExamplesPackage;
end Transformers;


12-pulse rectifier with 2 transformers.

within Modelica.Electrical.Machines.Examples.Transformers;
model Rectifier12pulse "12-pulse rectifier with 2 transformers"
  extends Machines.Examples.Transformers.Rectifier6pulse(RL=0.2);
  Modelica.Electrical.Polyphase.Ideal.IdealDiode diode3(
    m=m,
    Ron=fill(1e-5, m),
    Goff=fill(1e-5, m),
    Vknee=fill(0, m))
  Modelica.Electrical.Polyphase.Basic.Star star3(m=m)
  Modelica.Electrical.Polyphase.Ideal.IdealDiode diode4(
    m=m,
    Ron=fill(1e-5, m),
    Goff=fill(1e-5, m),
    Vknee=fill(0, m))
  Modelica.Electrical.Polyphase.Basic.Star star4(m=m)
  Machines.BasicMachines.Transformers.Dd.Dd00 transformer2(
    n=transformerData2.n,
    R1=transformerData2.R1,
    L1sigma=transformerData2.L1sigma,
    R2=transformerData2.R2,
    L2sigma=transformerData2.L2sigma,
    T1Ref=293.15,
    alpha20_1(displayUnit="1/K") = Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    T2Ref=293.15,
    alpha20_2(displayUnit="1/K") = Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    T1Operational=293.15,
    T2Operational=293.15)

  parameter Machines.Utilities.TransformerData transformerData2(
    C1=Modelica.Utilities.Strings.substring(
        transformer2.VectorGroup,
        1,
        1),
    C2=Modelica.Utilities.Strings.substring(
        transformer2.VectorGroup,
        2,
        2),
    f=50,
    V1=100,
    V2=100,
    SNominal=30E3,
    v_sc=0.05,
    P_sc=300) "Data of transformer 2"
initial equation
  transformer2.core.plug_p1.pin[1:3].i = zeros(3);
equation
  connect(diode3.plug_n, star3.plug_p)
  connect(diode4.plug_p, star4.plug_p)
  connect(diode4.plug_n, diode3.plug_p)
  connect(star4.pin_n, cDC2.n)
  connect(star3.pin_n, cDC1.p)
  connect(transformer2.plug2, diode4.plug_n)
  connect(transformer2.plug1, currentSensor.plug_n)
end Rectifier12pulse;


6-pulse rectifier with 1 transformer.

within Modelica.Electrical.Machines.Examples.Transformers;
model Rectifier6pulse "6-pulse rectifier with 1 transformer"
  extends Modelica.Icons.Example;
  constant Integer m=3 "Number of phases";
  parameter SI.Voltage V=100*sqrt(2/3)
    "Amplitude of star-voltage";
  parameter SI.Frequency f=50 "Frequency";
  parameter SI.Resistance RL=0.4 "Load resistance";
  parameter SI.Capacitance C=0.005 "Total DC-capacitance";
  parameter SI.Voltage VC0=sqrt(3)*V
    "Initial voltage of capacitance";
  Modelica.Electrical.Polyphase.Sources.SineVoltage source(
    m=m,
    V=fill(V, m),
    f=fill(f, m))
  Modelica.Electrical.Polyphase.Basic.Star starAC(m=m)
  Modelica.Electrical.Analog.Basic.Ground groundAC
  Modelica.Electrical.Polyphase.Sensors.CurrentSensor currentSensor(m=m)
  Modelica.Electrical.Polyphase.Ideal.IdealDiode diode1(
    m=m,
    Ron=fill(1e-5, m),
    Goff=fill(1e-5, m),
    Vknee=fill(0, m))
  Modelica.Electrical.Polyphase.Basic.Star star1(m=m)
  Modelica.Electrical.Polyphase.Ideal.IdealDiode diode2(
    m=m,
    Ron=fill(1e-5, m),
    Goff=fill(1e-5, m),
    Vknee=fill(0, m))
  Modelica.Electrical.Polyphase.Basic.Star star2(m=m)
  Modelica.Electrical.Analog.Basic.Resistor load(R=RL)
  Modelica.Electrical.Analog.Basic.Capacitor cDC1(C=2*C, v(start=VC0/2))
  Modelica.Electrical.Analog.Basic.Capacitor cDC2(C=2*C, v(start=VC0/2))
  Modelica.Electrical.Analog.Basic.Ground groundDC
  parameter Machines.Utilities.TransformerData transformerData1(
    C1=Modelica.Utilities.Strings.substring(
        transformer1.VectorGroup,
        1,
        1),
    C2=Modelica.Utilities.Strings.substring(
        transformer1.VectorGroup,
        2,
        2),
    f=50,
    V1=100,
    V2=100,
    SNominal=30E3,
    v_sc=0.05,
    P_sc=300) "Data of transformer 1"
  Machines.BasicMachines.Transformers.Dy.Dy01 transformer1(
    n=transformerData1.n,
    R1=transformerData1.R1,
    L1sigma=transformerData1.L1sigma,
    R2=transformerData1.R2,
    L2sigma=transformerData1.L2sigma,
    T1Ref=293.15,
    alpha20_1(displayUnit="1/K") = Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    T2Ref=293.15,
    alpha20_2(displayUnit="1/K") = Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    T1Operational=293.15,
    T2Operational=293.15)

initial equation
  cDC1.v = VC0/2;
  cDC2.v = VC0/2;
  transformer1.i2[1:2] = zeros(2);
equation
  connect(cDC1.n, cDC2.p)
  connect(cDC1.n, groundDC.p)
  connect(starAC.plug_p, source.plug_n)
  connect(diode1.plug_n, star1.plug_p)
  connect(diode2.plug_p, star2.plug_p)
  connect(diode2.plug_n, diode1.plug_p)
  connect(starAC.pin_n, groundAC.p)
  connect(source.plug_p, currentSensor.plug_p)
  connect(load.p, cDC1.p)
  connect(load.n, cDC2.n)
  connect(star1.pin_n, cDC1.p)
  connect(star2.pin_n, cDC2.n)
  connect(transformer1.plug1, currentSensor.plug_n)
  connect(transformer1.plug2, diode1.plug_p)
end Rectifier6pulse;


Transformer test bench.

within Modelica.Electrical.Machines.Examples.Transformers;
model TransformerTestbench "Transformer test bench"
  extends Modelica.Icons.Example;
  parameter SI.Resistance RL[3]=fill(1/3, 3)
    "Load resistance";
  Modelica.Electrical.Polyphase.Sources.SineVoltage source(f=fill(
        50, 3), V=fill(sqrt(2/3)*100, 3))
  Modelica.Electrical.Polyphase.Basic.Star starS
  Modelica.Electrical.Analog.Basic.Ground groundS
  Machines.Sensors.ElectricalPowerSensor electricalPowerSensorS
  Machines.Sensors.CurrentQuasiRMSSensor currentQuasiRMSSensorS
  Machines.Sensors.VoltageQuasiRMSSensor voltageQuasiRMSSensorS
  Modelica.Electrical.Polyphase.Basic.Delta deltaS
  Modelica.Electrical.Analog.Basic.Resistor earth(R=1e6)
  Modelica.Electrical.Analog.Basic.Ground groundT
  Machines.Sensors.VoltageQuasiRMSSensor voltageRMSSensorL
  Modelica.Electrical.Polyphase.Basic.Delta deltaL
  Machines.Sensors.CurrentQuasiRMSSensor currentQuasiRMSSensorL
  Machines.Sensors.ElectricalPowerSensor electricalPowerSensorL
  Modelica.Electrical.Polyphase.Basic.Resistor load(R=RL)
  Modelica.Electrical.Polyphase.Basic.Star starL
  Modelica.Electrical.Analog.Basic.Ground groundL
  parameter Machines.Utilities.TransformerData transformerData(
    C1=Modelica.Utilities.Strings.substring(
        transformer.VectorGroup,
        1,
        1),
    C2=Modelica.Utilities.Strings.substring(
        transformer.VectorGroup,
        2,
        2),
    f=50,
    V1=100,
    V2=100,
    SNominal=30E3,
    v_sc=0.05,
    P_sc=300) "Transformer data"
  BasicMachines.Transformers.Dy.Dy01 transformer(
    n=transformerData.n,
    R1=transformerData.R1,
    L1sigma=transformerData.L1sigma,
    R2=transformerData.R2,
    L2sigma=transformerData.L2sigma,
    T1Ref=293.15,
    alpha20_1(displayUnit="1/K")=Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    T2Ref=293.15,
    alpha20_2(displayUnit="1/K")=Modelica.Electrical.Machines.Thermal.Constants.alpha20Zero,
    T1Operational=293.15,
    T2Operational=293.15)

initial equation
  transformer.i2[1:2] = zeros(2);
equation
  connect(starS.pin_n, groundS.p)
  connect(source.plug_n, starS.plug_p)
  connect(starL.pin_n, groundL.p)
  connect(load.plug_n, starL.plug_p)
  connect(earth.n, groundT.p)
  connect(electricalPowerSensorS.plug_nv, starS.plug_p)
  connect(source.plug_p, electricalPowerSensorS.plug_p)
  connect(electricalPowerSensorS.plug_ni, currentQuasiRMSSensorS.plug_p)
  connect(currentQuasiRMSSensorL.plug_n, electricalPowerSensorL.plug_p)
  connect(electricalPowerSensorL.plug_ni, load.plug_p)
  connect(electricalPowerSensorL.plug_nv, starL.plug_p)
  connect(currentQuasiRMSSensorS.plug_n, transformer.plug1)
  connect(transformer.plug2, currentQuasiRMSSensorL.plug_p)
  connect(deltaS.plug_p, voltageQuasiRMSSensorS.plug_n)
  connect(deltaS.plug_n, voltageQuasiRMSSensorS.plug_p)
  connect(currentQuasiRMSSensorS.plug_n, deltaS.plug_n)
  connect(currentQuasiRMSSensorL.plug_p, deltaL.plug_n)
  connect(deltaL.plug_n, voltageRMSSensorL.plug_p)
  connect(deltaL.plug_p, voltageRMSSensorL.plug_n)
end TransformerTestbench;


Generic icon of an electric drive. This icon represents a generic electric drive model.

within Modelica.Electrical.Machines.Icons;
partial model Drive "Generic icon of an electric drive"
end Drive;


This icon is designed for a FundamentalWave machine model.

. This icon is designed for a FundamentalWave machine model.

within Modelica.Electrical.Machines.Icons;
partial model FundamentalWaveMachine
end FundamentalWaveMachine;


Generic icon of an electric machine. This icon represents a generic electric machine model.

within Modelica.Electrical.Machines.Icons;
partial model Machine "Generic icon of an electric machine"
end Machine;


Icons for electrical machines

within Modelica.Electrical.Machines;
package Icons "Icons for electrical machines"
  extends Modelica.Icons.IconsPackage;
end Icons;


Icon of quasi-static fundamental wave machine. This icon is designed for a quasi-static fundamental wave machine model.

within Modelica.Electrical.Machines.Icons;
partial model QuasiStaticFundamentalWaveMachine
  "Icon of quasi-static fundamental wave machine"
end QuasiStaticFundamentalWaveMachine;


This icon is designed for a quasi-static machine model.

. This icon is designed for a quasi-static machine model.

within Modelica.Electrical.Machines.Icons;
partial model QuasiStaticMachine
end QuasiStaticMachine;


This icon is designed for a quasi-static transformer model.

. This icon is designed for a quasi-static transformer model.

within Modelica.Electrical.Machines.Icons;
partial model QuasiStaticTransformer
end QuasiStaticTransformer;


This icon is designed for a transient machine model.

. This icon is designed for a transient machine model.

within Modelica.Electrical.Machines.Icons;
partial model TransientMachine
end TransientMachine;


This icon is designed for a transient transformer model.

. This icon is designed for a transient transformer model.

within Modelica.Electrical.Machines.Icons;
model TransientTransformer

end TransientTransformer;


Shaft and support. This partial model defines shaft and housing connector for loss models.
Positive torque tau acts as braking torque.

within Modelica.Electrical.Machines.Interfaces;
partial model FlangeSupport "Shaft and support"
  Modelica.Mechanics.Rotational.Interfaces.Flange_a flange "Shaft end"
  Modelica.Mechanics.Rotational.Interfaces.Flange_a support
    "Housing and support"
  SI.Angle phi "Angle between shaft and support";
  SI.Torque tau "Torque";
  SI.AngularVelocity w
    "Relative angular velocity of flange and support";
equation
  phi = flange.phi - support.phi;
  w = der(phi);
  tau = -flange.tau;
  tau = support.tau;
end FlangeSupport;


within Modelica.Electrical.Machines;
package Interfaces "SpacePhasor connector and PartialMachines"
  extends Modelica.Icons.InterfacesPackage;
end Interfaces;


Partial model for DC machine.

within Modelica.Electrical.Machines.Interfaces;
partial model PartialBasicDCMachine "Partial model for DC machine"
  parameter SI.Temperature TaOperational(start=293.15)
    "Operational armature temperature"
  parameter SI.Voltage VaNominal(start=100)
    "Nominal armature voltage"
  parameter SI.Current IaNominal(start=100)
    "Nominal armature current (>0..Motor, <0..Generator)"
  parameter SI.AngularVelocity wNominal(displayUnit="rev/min",
      start=1425*2*pi/60) "Nominal speed"
  parameter SI.Temperature TaNominal(start=293.15)
    "Nominal armature temperature"
  parameter SI.Resistance Ra(start=0.05)
    "Armature resistance at TaRef"
  parameter SI.Temperature TaRef(start=293.15)
    "Reference temperature of armature resistance"
  parameter Machines.Thermal.LinearTemperatureCoefficient20 alpha20a(start=0)
    "Temperature coefficient of armature resistance"
  parameter SI.Inductance La(start=0.0015)
    "Armature inductance"
  extends PartialBasicMachine(
    Jr(start=0.15),
    frictionParameters(wRef=wNominal),
    friction(final useHeatPort=true));
  parameter Machines.Losses.CoreParameters coreParameters(
    final m=1,
    VRef=ViNominal,
    wRef=wNominal) "Armature core loss parameter record"
  parameter Machines.Losses.StrayLoadParameters strayLoadParameters(IRef=
        IaNominal, wRef=wNominal) "Stray load loss parameter record"
  parameter Machines.Losses.BrushParameters brushParameters(ILinear=0.01*
        IaNominal) "Brush loss parameter record"
  replaceable output
    Machines.Interfaces.DCMachines.PartialPowerBalanceDCMachines powerBalance(
    final powerArmature=va*ia,
    final powerMechanical=wMechanical*tauShaft,
    final powerInertiaStator=inertiaStator.J*inertiaStator.a*inertiaStator.w,
    final powerInertiaRotor=inertiaRotor.J*inertiaRotor.a*inertiaRotor.w,
    final lossPowerArmature=ra.LossPower,
    final lossPowerCore=core.lossPower,
    final lossPowerStrayLoad=strayLoad.lossPower,
    final lossPowerFriction=friction.lossPower,
    final lossPowerBrush=brush.lossPower) "Power balance";

  output SI.Voltage va=pin_ap.v - pin_an.v "Armature voltage";
  output SI.Current ia(start=0) = pin_ap.i "Armature current";
  Modelica.Electrical.Analog.Interfaces.PositivePin pin_ap
    "Positive armature pin"
  Modelica.Electrical.Analog.Interfaces.NegativePin pin_an
    "Negative armature pin"
  Modelica.Electrical.Analog.Basic.Resistor ra(
    final R=Ra,
    final T_ref=TaRef,
    final alpha=Machines.Thermal.convertAlpha(alpha20a, TaRef),
    final useHeatPort=true)
  Machines.BasicMachines.Components.InductorDC la(final L=La, final quasiStatic=
       quasiStatic)
  Machines.Losses.DCMachines.Brush brush(final brushParameters=brushParameters,
      final useHeatPort=true)
  Machines.Losses.DCMachines.Core core(final coreParameters=coreParameters,
      final useHeatPort=true)
  Machines.Losses.DCMachines.StrayLoad strayLoad(final strayLoadParameters=
        strayLoadParameters, final useHeatPort=true)
  replaceable Machines.Interfaces.DCMachines.PartialThermalPortDCMachines thermalPort if
    useThermalPort
  replaceable Machines.Interfaces.DCMachines.PartialThermalAmbientDCMachines thermalAmbient(final
      useTemperatureInputs=false, final Ta=TaOperational) if not useThermalPort
protected
  constant Real pi = Modelica.Constants.pi;
  constant Boolean quasiStatic=false "No electrical transients if true"
  parameter SI.Voltage ViNominal "Nominal induced Voltage";
  parameter SI.MagneticFlux psi_eNominal
    "Nominal magnetic flux";
  parameter Real turnsRatio=ViNominal/(wNominal*psi_eNominal)
    "Ratio of armature turns over number of turns of the excitation winding";
  replaceable Machines.Interfaces.DCMachines.PartialThermalPortDCMachines internalThermalPort
equation
  assert(ViNominal > Modelica.Constants.eps,
    "VaNominal has to be > (Ra[+Rse])*IaNominal");
  connect(la.p, ra.n)
  connect(brush.n, pin_an)
  connect(pin_ap, strayLoad.p)
  connect(strayLoad.n, ra.p)
  connect(strayLoad.support, internalSupport)
  connect(la.p, core.p)
  connect(core.n, brush.p)
  connect(core.heatPort, internalThermalPort.heatPortCore)
  connect(brush.heatPort, internalThermalPort.heatPortBrush)
  connect(strayLoad.heatPort, internalThermalPort.heatPortStrayLoad)
  connect(friction.heatPort, internalThermalPort.heatPortFriction)
  connect(ra.heatPort, internalThermalPort.heatPortArmature)
  connect(inertiaRotor.flange_b, strayLoad.flange)
  connect(thermalAmbient.thermalPort, internalThermalPort)
  connect(internalThermalPort, thermalPort)
end PartialBasicDCMachine;


Partial model for induction machine.

within Modelica.Electrical.Machines.Interfaces;
partial model PartialBasicInductionMachine
  "Partial model for induction machine"
  final parameter Integer m=3 "Number of phases"
  parameter Integer p(min=1, start=2) "Number of pole pairs (Integer)";
  parameter SI.Frequency fsNominal(start=50)
    "Nominal frequency";
  parameter SI.Temperature TsOperational(start=293.15)
    "Operational temperature of stator resistance"
  parameter SI.Resistance Rs(start=0.03*ZsRef)
    "Stator resistance per phase at TRef"
  parameter SI.Temperature TsRef(start=293.15)
    "Reference temperature of stator resistance"
  parameter Machines.Thermal.LinearTemperatureCoefficient20 alpha20s(start=0)
    "Temperature coefficient of stator resistance at 20 degC"
  parameter SI.Inductance Lszero=Lssigma
    "Stator zero sequence inductance"
  parameter SI.Inductance Lssigma(start=3*ZsRef*(1 - sqrt(1 -
        0.0667))/(2*pi*fsNominal)) "Stator stray inductance per phase"
  extends PartialBasicMachine(
    Jr(start=0.29),
    frictionParameters(wRef=2*pi*fsNominal/p),
    friction(final useHeatPort=true));
  parameter Machines.Losses.CoreParameters statorCoreParameters(
    final m=3,
    VRef(start=100),
    wRef=2*pi*fsNominal)
    "Stator core loss parameter record; all parameters refer to stator side"
  parameter Machines.Losses.StrayLoadParameters strayLoadParameters(IRef(start=
          100), wRef=2*pi*fsNominal/p) "Stray load loss parameter record"
  replaceable output
    Machines.Interfaces.InductionMachines.PartialPowerBalanceInductionMachines powerBalance(
    final powerStator=Machines.SpacePhasors.Functions.activePower(vs, is),
    final powerMechanical=wMechanical*tauShaft,
    final powerInertiaStator=inertiaStator.J*inertiaStator.a*inertiaStator.w,
    final powerInertiaRotor=inertiaRotor.J*inertiaRotor.a*inertiaRotor.w,
    final lossPowerStatorWinding=sum(rs.resistor.LossPower),
    final lossPowerStatorCore=statorCore.lossPower,
    final lossPowerStrayLoad=strayLoad.lossPower,
    final lossPowerFriction=friction.lossPower) "Power balance";

  output SI.Voltage vs[m]=plug_sp.pin.v - plug_sn.pin.v
    "Stator instantaneous voltages";
  output SI.Current is[m]=plug_sp.pin.i
    "Stator instantaneous currents";
  output SI.Current i_0_s(stateSelect=StateSelect.prefer)=
    spacePhasorS.zero.i "Stator zero-sequence current";
  // to be defined in model that extends from this partial (since airgap isn't included here)
  input SI.Current idq_ss[2]
    "Stator space phasor current / stator fixed frame";
  input SI.Current idq_sr[2](each stateSelect=StateSelect.prefer)
    "Stator space phasor current / rotor fixed frame";
  input SI.Current idq_rs[2]
    "Rotor space phasor current / stator fixed frame";
  input SI.Current idq_rr[2](each stateSelect=StateSelect.prefer)
    "Rotor space phasor current / rotor fixed frame";
  Modelica.Electrical.Polyphase.Interfaces.PositivePlug plug_sp(final m=m)
    "Positive stator plug"
  Modelica.Electrical.Polyphase.Interfaces.NegativePlug plug_sn(final m=m)
    "Negative stator plug"
  Modelica.Electrical.Polyphase.Basic.Resistor rs(
    final m=m,
    final R=fill(Rs, m),
    final T_ref=fill(TsRef, m),
    final alpha=fill(Machines.Thermal.convertAlpha(alpha20s, TsRef), m),
    final useHeatPort=true,
    final T=fill(TsRef, m))
  Machines.BasicMachines.Components.Inductor lssigma(final L=fill(Lssigma, 2))
  Modelica.Electrical.Analog.Basic.Inductor lszero(final L=Lszero)
  Machines.Losses.InductionMachines.Core statorCore(
    final coreParameters=statorCoreParameters,
    final useHeatPort=true,
    final turnsRatio=1)
  Machines.SpacePhasors.Components.SpacePhasor spacePhasorS(final turnsRatio=1)
  Machines.Losses.InductionMachines.StrayLoad strayLoad(
    final strayLoadParameters=strayLoadParameters,
    final useHeatPort=true,
    final m=m)
  replaceable
    Machines.Interfaces.InductionMachines.PartialThermalPortInductionMachines thermalPort(final m=m)
    if useThermalPort
  replaceable
    Machines.Interfaces.InductionMachines.PartialThermalAmbientInductionMachines
    thermalAmbient(
    final useTemperatureInputs=false,
    final Ts=TsOperational,
    final m=m) if not useThermalPort
protected
  final parameter SI.Impedance ZsRef = 1 "Reference phase impedance based on nominal voltage 100 V and nominal current 100 A; per phase";
  constant Real pi = Modelica.Constants.pi;
  replaceable
    Machines.Interfaces.InductionMachines.PartialThermalPortInductionMachines internalThermalPort(final m=m)
equation
  connect(spacePhasorS.plug_n, plug_sn)
  connect(strayLoad.plug_n, rs.plug_p)
  connect(strayLoad.plug_p, plug_sp)
  connect(strayLoad.support, internalSupport)
  connect(spacePhasorS.plug_p, rs.plug_n)
  connect(spacePhasorS.zero, lszero.p)
  connect(lszero.n, spacePhasorS.ground)
  connect(spacePhasorS.spacePhasor, lssigma.spacePhasor_a)
  connect(statorCore.spacePhasor, lssigma.spacePhasor_a)
  connect(statorCore.heatPort, internalThermalPort.heatPortStatorCore)
  connect(strayLoad.heatPort, internalThermalPort.heatPortStrayLoad)
  connect(rs.heatPort, internalThermalPort.heatPortStatorWinding)
  connect(friction.heatPort, internalThermalPort.heatPortFriction)
  connect(strayLoad.flange, inertiaRotor.flange_b)
  connect(internalThermalPort, thermalPort)
  connect(thermalAmbient.thermalPort, internalThermalPort)
end PartialBasicInductionMachine;


Partial model for all machines.

within Modelica.Electrical.Machines.Interfaces;
partial model PartialBasicMachine "Partial model for all machines"
  import Modelica.Constants.pi;
  extends Machines.Icons.TransientMachine;
  parameter SI.Inertia Jr "Rotor's moment of inertia";
  parameter Boolean useSupport=false
    "Enable / disable (=fixed stator) support"
  parameter SI.Inertia Js=Jr "Stator's moment of inertia"
  parameter Boolean useThermalPort=false
    "Enable / disable (=fixed temperatures) thermal port"
  parameter Machines.Losses.FrictionParameters frictionParameters
    "Friction loss parameter record"
  output SI.Angle phiMechanical(start=0) = flange.phi -
    internalSupport.phi "Mechanical angle of rotor against stator";
  output SI.AngularVelocity wMechanical(
    displayUnit="rev/min",
    start=0) = der(phiMechanical)
    "Mechanical angular velocity of rotor against stator";
  output SI.Torque tauElectrical=inertiaRotor.flange_a.tau
    "Electromagnetic torque";
  output SI.Torque tauShaft=-flange.tau "Shaft torque";
  Modelica.Mechanics.Rotational.Interfaces.Flange_a flange "Shaft"
  Modelica.Mechanics.Rotational.Components.Inertia inertiaRotor(final J=Jr)
  Modelica.Mechanics.Rotational.Interfaces.Flange_a support if useSupport
    "Support at which the reaction torque is acting"
  Modelica.Mechanics.Rotational.Components.Inertia inertiaStator(final J=Js)
  Modelica.Mechanics.Rotational.Components.Fixed fixed if (not useSupport)
  Machines.Losses.Friction friction(final frictionParameters=frictionParameters)
protected
  Modelica.Mechanics.Rotational.Interfaces.Support internalSupport
equation
  connect(inertiaRotor.flange_b, flange)
  connect(inertiaStator.flange_b, support)
  connect(internalSupport, fixed.flange)
  connect(internalSupport, inertiaStator.flange_a)
  connect(inertiaRotor.flange_b, friction.flange)
  connect(friction.support, internalSupport)
end PartialBasicMachine;