Polyphase DC to AC converter with R load. Plot current currentSensor.i[:], harmonic current magnitude fundamentalWaveCurrent[:].y_RMS, harmonic voltage magnitude fundamentalWaveVoltage[:].y_RMS. The instantaneous voltages voltageSensor.i[:] and currents currentSensor.i[:] directly show the switching pattern of the inverter. There is not smoothing effect due to an inductance in this example; see PolyphaseTwoLevel_RL.

within Modelica.Electrical.PowerConverters.Examples.DCAC.PolyphaseTwoLevel;
model PolyphaseTwoLevel_R "Polyphase DC to AC converter with R load"
  extends Modelica.Icons.Example;
  parameter Integer m=3 "Number of phases"
  parameter SI.Frequency f=1000 "Switching frequency";
  parameter SI.Frequency f1=50
    "Fundamental wave AC frequency";
  parameter SI.Resistance R=100 "Resistance";
  Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage_n(
      V=50)
  PowerConverters.DCAC.Polyphase2Level inverter(useHeatPort=false, m=m)
  Modelica.Electrical.Polyphase.Sensors.CurrentSensor currentSensor(m=
        m)
  Modelica.Electrical.Polyphase.Sensors.VoltageSensor voltageSensor(m=
        m)
  Modelica.Electrical.Analog.Basic.Ground ground
  PowerConverters.DCDC.Control.SignalPWM signalPWM[m](each useConstantDutyCycle
      =false, each f=f)
  Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage_p(
      V=50)
  Modelica.Blocks.Sources.Sine sine[m](
    phase=-
        Modelica.Electrical.Polyphase.Functions.symmetricOrientation(m),
    startTime=zeros(m),
    amplitude=fill(0.5, m),
    offset=fill(0.5, m),
    f=fill(f1, m))
  Modelica.Blocks.Math.Harmonic fundamentalWaveCurrent[m](
    each k=1,
    each x0Cos=0,
    each x0Sin=0,
    each f=f1)
  Modelica.Blocks.Math.Harmonic fundamentalWaveVoltage[m](
    each k=1,
    each x0Cos=0,
    each x0Sin=0,
    each f=f1)
  Modelica.Electrical.Polyphase.Basic.Resistor resistor(m=m, R=fill(R,
        m))
  Modelica.Electrical.Polyphase.Basic.Star star(m=m)
equation
  connect(constantVoltage_p.n, constantVoltage_n.p)
  connect(constantVoltage_p.p, inverter.dc_p)
  connect(constantVoltage_n.n, inverter.dc_n)
  connect(ground.p, constantVoltage_p.n)
  connect(sine.y, signalPWM.dutyCycle)
  connect(voltageSensor.v, fundamentalWaveVoltage.u)
  connect(fundamentalWaveCurrent.u, currentSensor.i)
  connect(signalPWM.fire, inverter.fire_p)
  connect(signalPWM.notFire, inverter.fire_n)
  connect(inverter.ac, resistor.plug_p)
  connect(voltageSensor.plug_p, inverter.ac)
  connect(voltageSensor.plug_n, currentSensor.plug_n)
  connect(currentSensor.plug_n, star.plug_p)
  connect(resistor.plug_n, currentSensor.plug_p)
end PolyphaseTwoLevel_R;


Polyphase DC to AC converter with R-L load. Plot current currentSensor.i[:], harmonic current magnitude fundamentalWaveCurrent[:].y_RMS, harmonic voltage magnitude fundamentalWaveVoltage[:].y_RMS. The instantaneous voltages voltageSensor.i[:] directly show the switching pattern of the inverter.

within Modelica.Electrical.PowerConverters.Examples.DCAC.PolyphaseTwoLevel;
model PolyphaseTwoLevel_RL
  "Polyphase DC to AC converter with R-L load"
  extends Modelica.Icons.Example;
  parameter Integer m=6 "Number of phases"
  parameter SI.Frequency f=1000 "Switching frequency";
  parameter SI.Frequency f1=50
    "Fundamental wave AC frequency";
  parameter SI.Resistance R=100 "Resistance";
  parameter SI.Inductance L=1 "Inductance";
  Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage_n(
      V=50)
  PowerConverters.DCAC.Polyphase2Level inverter(useHeatPort=false, m=m)
  Modelica.Electrical.Polyphase.Sensors.CurrentSensor currentSensor(m=
        m)
  Modelica.Electrical.Polyphase.Sensors.VoltageSensor voltageSensor(m=
        m)
  Modelica.Electrical.Analog.Basic.Ground ground
  PowerConverters.DCDC.Control.SignalPWM signalPWM[m](each useConstantDutyCycle
      =false, each f=f)
  Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage_p(
      V=50)
  Modelica.Blocks.Sources.Sine sine[m](
    phase=-
        Modelica.Electrical.Polyphase.Functions.symmetricOrientation(m),
    startTime=zeros(m),
    amplitude=fill(0.5, m),
    offset=fill(0.5, m),
    f=fill(f1, m))
  Modelica.Blocks.Math.Harmonic fundamentalWaveCurrent[m](
    each k=1,
    each x0Cos=0,
    each x0Sin=0,
    each f=f1)
  Modelica.Blocks.Math.Harmonic fundamentalWaveVoltage[m](
    each k=1,
    each x0Cos=0,
    each x0Sin=0,
    each f=f1)
  Modelica.Electrical.Polyphase.Basic.Resistor resistor(m=m, R=fill(R,
        m))
  Modelica.Electrical.Polyphase.Basic.Inductor inductor(m=m, L=fill(L,
        m))
  Modelica.Electrical.Polyphase.Basic.Star star(m=m)
initial equation
  inductor.i[1:m - 1] = zeros(m - 1);

equation
  connect(constantVoltage_p.n, constantVoltage_n.p)
  connect(constantVoltage_p.p, inverter.dc_p)
  connect(constantVoltage_n.n, inverter.dc_n)
  connect(ground.p, constantVoltage_p.n)
  connect(sine.y, signalPWM.dutyCycle)
  connect(voltageSensor.v, fundamentalWaveVoltage.u)
  connect(fundamentalWaveCurrent.u, currentSensor.i)
  connect(signalPWM.fire, inverter.fire_p)
  connect(signalPWM.notFire, inverter.fire_n)
  connect(inverter.ac, resistor.plug_p)
  connect(resistor.plug_n, inductor.plug_p)
  connect(voltageSensor.plug_p, inverter.ac)
  connect(voltageSensor.plug_n, currentSensor.plug_n)
  connect(currentSensor.plug_p, inductor.plug_n)
  connect(currentSensor.plug_n, star.plug_p)
end PolyphaseTwoLevel_RL;


Test of pulse width modulation methods. A reference space vector (formed by real part = cosine and imaginary part = sine) of length √2*RMS and frequency 2 Hz is applied.
The resulting switching patterns are applied to a three-phase twolevel bridge with switching frequency 100 Hz, fed by DC voltage = √2*√3*1
where 1 is the theoretical maximum voltage from terminal to neutral.
The resulting voltages with reference to midpoint of the DC voltage are measured.

within Modelica.Electrical.PowerConverters.Examples.DCAC.PolyphaseTwoLevel;
model ThreePhaseTwoLevel_PWM "Test of pulse width modulation methods"
  extends Modelica.Icons.Example;
  import Modelica.Electrical.Polyphase.Functions.factorY2DC;
  import Modelica.Constants.pi;
  parameter Real RMS=1 "Reference RMS Y";
  Modelica.Blocks.Sources.Cosine cosine(f=2,
    phase=0,
    amplitude=RMS*sqrt(2))
  Modelica.Blocks.Sources.Sine sine(
    amplitude=cosine.amplitude,
    f=cosine.f,
    phase=cosine.phase)
  PowerConverters.DCAC.Control.PWM pwm(uMax=sqrt(2*3), f=100)
  PowerConverters.DCAC.Polyphase2Level multiPhase2Level
  Modelica.Electrical.Analog.Sources.ConstantVoltage dcPos(V=pwm.uMax/2)
  Modelica.Electrical.Analog.Sources.ConstantVoltage dcNeg(V=pwm.uMax/2)
  Modelica.Electrical.Analog.Basic.Ground ground
  Modelica.Electrical.Polyphase.Sensors.PotentialSensor potentialSensor
  Modelica.Blocks.Math.Harmonic harmonic(f=cosine.f, k=1)
  Modelica.Electrical.Machines.SpacePhasors.Blocks.ToSpacePhasor toSpacePhasor
  Modelica.Electrical.Machines.SpacePhasors.Blocks.Rotator rotator
  Modelica.Blocks.Sources.Constant const(k=cosine.f)
  Modelica.Blocks.Continuous.Integrator integrator(k=2*pi)
  Modelica.Blocks.Continuous.Filter filter[2](
    each init=Modelica.Blocks.Types.Init.InitialOutput,
    each analogFilter=Modelica.Blocks.Types.AnalogFilter.CriticalDamping,
    y_start={cosine.amplitude,cosine.phase},
    each order=2,
    each f_cut=0.5*cosine.f)
  Modelica.Electrical.Machines.SpacePhasors.Blocks.ToPolar toPolar
equation
  connect(pwm.fire_p, multiPhase2Level.fire_p)
  connect(pwm.fire_n, multiPhase2Level.fire_n)
  connect(dcNeg.n, multiPhase2Level.dc_n)
  connect(dcPos.p, multiPhase2Level.dc_p)
  connect(dcPos.n, ground.p)
  connect(ground.p, dcNeg.p)
  connect(cosine.y, pwm.u[1])
  connect(sine.y, pwm.u[2])
  connect(multiPhase2Level.ac, potentialSensor.plug_p)
  connect(toSpacePhasor.y, rotator.u)
  connect(potentialSensor.phi, toSpacePhasor.u)
  connect(const.y, integrator.u)
  connect(integrator.y, rotator.angle)
  connect(potentialSensor.phi[1], harmonic.u)
  connect(rotator.y, filter.u)
  connect(filter.y, toPolar.u)
end ThreePhaseTwoLevel_PWM;


within Modelica.Electrical.PowerConverters.Examples.DCAC;
package SinglePhaseTwoLevel "Single-phase two level inverter examples"
  extends Modelica.Icons.ExamplesPackage;

end SinglePhaseTwoLevel;


Single-phase DC to AC converter with resistive load. Plot current currentSensor.i, average current meanCurrent.y, voltage voltageSensor.v and average voltage meanVoltage.v. The instantaneous voltage and current directly show the switch pattern of the inverter. The average voltage and average current reveal the fundamental wave of the voltage and current, each of them being basically in phase with the command sine.y.

within Modelica.Electrical.PowerConverters.Examples.DCAC.SinglePhaseTwoLevel;
model SinglePhaseTwoLevel_R
  "Single-phase DC to AC converter with resistive load"
  extends ExampleTemplates.SinglePhaseTwoLevel(sine(
      amplitude=0.5,
      offset=0.5,
      f=f1));
  extends Modelica.Icons.Example;
  parameter SI.Resistance R=100 "Resistance";
  parameter SI.Frequency f1=50 "AC frequency";
  Modelica.Electrical.Analog.Basic.Resistor resistor(R=R)
equation
  connect(resistor.p, inverter.ac)
  connect(resistor.n, currentSensor.p)
end SinglePhaseTwoLevel_R;


Single-phase DC to AC converter with R-L load. Plot current currentSensor.i, average current meanCurrent.y, voltage voltageSensor.v and average voltage meanVoltage.v. The instantaneous voltage directly show the switch pattern of the inverter. The current shows a particular ripple determined by the input voltage and the switching frequency. The average voltage is basically in phase with the command sine.y. The average current has a phase shift due to the R-L load.

within Modelica.Electrical.PowerConverters.Examples.DCAC.SinglePhaseTwoLevel;
model SinglePhaseTwoLevel_RL
  "Single-phase DC to AC converter with R-L load"
  extends ExampleTemplates.SinglePhaseTwoLevel(sine(
      amplitude=0.5,
      offset=0.5,
      f=f1));
  extends Modelica.Icons.Example;
  parameter SI.Resistance R=100 "Resistance";
  parameter SI.Inductance L=1 "Inductance";
  parameter SI.Frequency f1=50 "AC frequency";
  Modelica.Electrical.Analog.Basic.Resistor resistor(R=R)
  Modelica.Electrical.Analog.Basic.Inductor inductor(L=L, i(fixed=true))
equation
  connect(resistor.p, inverter.ac)
  connect(resistor.n, inductor.p)
  connect(inductor.n, currentSensor.p)
end SinglePhaseTwoLevel_RL;


DC to DC converter examples

within Modelica.Electrical.PowerConverters.Examples;
package DCDC "DC to DC converter examples"
  extends Modelica.Icons.ExamplesPackage;
end DCDC;


This examples demonstrates bidirectional coupling of two batteries with different voltages as used in automotive.
For idleDutyCycle = 1 - (VLV/VHV), no current is exchanged.

Starting with dutyCycle < idleDutyCycle, the high voltage battery feeds the low voltage battery.
Changing the dutyCycle > idleDutyCycle, the low voltage battery feeds the high voltage battery.

The capacitors are precharged to the battery voltages, but the inductor leads zero current.
The current sensor may be used to implement current control.

Control

For hints implementing control, see:
Stefan Norbert Matlok,
<a href=\. This examples demonstrates bidirectional coupling of two batteries with different voltages as used in automotive.
For idleDutyCycle = 1 - (VLV/VHV), no current is exchanged.

within Modelica.Electrical.PowerConverters.Examples.DCDC.ChopperBuckBoost;
model ChopperBuckBoost_DutyCycle
  extends DCDC.ExampleTemplates.ChopperBuckBoost(pwm(useConstantDutyCycle=false));
  extends Modelica.Icons.Example;
  Modelica.Blocks.Sources.Step dutyCycle(
    height=0.2,
    offset=idleDutyCycle - 0.1,
    startTime=0.05)
equation
  connect(dutyCycle.y, pwm.dutyCycle)
end ChopperBuckBoost_DutyCycle;


Chopper buck/boost

within Modelica.Electrical.PowerConverters.Examples.DCDC;
package ChopperBuckBoost "Chopper buck/boost"
  extends Modelica.Icons.ExamplesPackage;

end ChopperBuckBoost;


Step down chopper with resistive load. This example demonstrates the switching on of a resistive load operated by a step down chopper.
DC output voltage is equal to dutyCycle times the input voltage.
Plot current currentSensor.i, averaged current meanCurrent.y, total voltage voltageSensor.v and voltage meanVoltage.v.

within Modelica.Electrical.PowerConverters.Examples.DCDC.ChopperStepDown;
model ChopperStepDown_R "Step down chopper with resistive load"
  extends ExampleTemplates.ChopperStepDown(signalPWM(useConstantDutyCycle=false));
  extends Modelica.Icons.Example;
  Modelica.Electrical.Analog.Basic.Resistor loadResistor(R=RLoad)
  PowerConverters.DCDC.Control.Voltage2DutyCycle adaptor(
    reciprocal=false,
    useBipolarVoltage=false,
    VLim=Vsource)
  Modelica.Blocks.Sources.Ramp vRef(
    height=V0,
    duration=0.05,
    offset=0,
    startTime=0.025)
equation
  connect(loadResistor.n, currentSensor.p)
  connect(loadResistor.p, capacitor.p)
  connect(adaptor.dutyCycle, signalPWM.dutyCycle)
  connect(vRef.y, adaptor.v)
end ChopperStepDown_R;


Step down chopper with R-L load. This example demonstrates the switching on of an R-L load operated by a step down chopper.
DC output voltage is equal to dutyCycle times the input voltage.
Plot current currentSensor.i, averaged current meanCurrent.y, total voltage voltageSensor.v and voltage meanVoltage.v. The waveform the average current is determined by the time constant L/R of the load.

within Modelica.Electrical.PowerConverters.Examples.DCDC.ChopperStepDown;
model ChopperStepDown_RL "Step down chopper with R-L load"
  extends ExampleTemplates.ChopperStepDown(signalPWM(useConstantDutyCycle=false));
  extends Modelica.Icons.Example;
  parameter SI.Inductance LLoad=0.025 "Load inductance";
  Modelica.Electrical.Analog.Basic.Resistor loadResistor(R=RLoad)
  Modelica.Electrical.Analog.Basic.Inductor loadInductor(i(fixed=true, start=0),
    L=LLoad)
  PowerConverters.DCDC.Control.Voltage2DutyCycle adaptor(
    reciprocal=false,
    useBipolarVoltage=false,
    VLim=Vsource)
  Modelica.Blocks.Sources.Ramp vRef(
    height=V0,
    duration=0.05,
    offset=0,
    startTime=0.025)
equation
  connect(loadResistor.p, capacitor.p)
  connect(loadInductor.n, currentSensor.p)
  connect(loadResistor.n, loadInductor.p)
  connect(adaptor.dutyCycle, signalPWM.dutyCycle)
  connect(adaptor.v, vRef.y)
end ChopperStepDown_RL;


Step down chopper

within Modelica.Electrical.PowerConverters.Examples.DCDC;
package ChopperStepDown "Step down chopper"
  extends Modelica.Icons.ExamplesPackage;

end ChopperStepDown;


Step up chopper with resistive load. This example demonstrates the switching on of a resistive load operated by a step up chopper.
DC output voltage is equal to 1/(1 - dutyCycle) times the input voltage.
Plot current currentSensor.i, averaged current meanCurrent.y, total voltage voltageSensor.v and voltage meanVoltage.v.

within Modelica.Electrical.PowerConverters.Examples.DCDC.ChopperStepUp;
model ChopperStepUp_R "Step up chopper with resistive load"
  extends ExampleTemplates.ChopperStepUp(signalPWM(useConstantDutyCycle=false));
  extends Modelica.Icons.Example;
  Modelica.Electrical.Analog.Basic.Resistor loadResistor(R=RLoad)
  PowerConverters.DCDC.Control.Voltage2DutyCycle adaptor(
    reciprocal=true,
    useBipolarVoltage=false,
    VLim=Vsource)
  Modelica.Blocks.Sources.Ramp vRef(
    height=V0 - Vsource,
    duration=0.05,
    offset=Vsource,
    startTime=0.025)
equation
  connect(loadResistor.n, currentSensor.p)
  connect(loadResistor.p, capacitor.p)
  connect(adaptor.dutyCycle, signalPWM.dutyCycle)
  connect(vRef.y, adaptor.v)
end ChopperStepUp_R;


Step up chopper

within Modelica.Electrical.PowerConverters.Examples.DCDC;
package ChopperStepUp "Step up chopper"
  extends Modelica.Icons.ExamplesPackage;

end ChopperStepUp;


Buck/boost converter example template. Buck/boost chopper example template including both voltage sources; control not included.

within Modelica.Electrical.PowerConverters.Examples.DCDC.ExampleTemplates;
partial model ChopperBuckBoost "Buck/boost converter example template"
  extends Modelica.Electrical.PowerConverters.Icons.ExampleTemplate;
  parameter Modelica.Units.SI.Voltage VLV=12 "LV voltage";
  parameter Modelica.Units.SI.Resistance RiLV=0.01 "LV inner resistance";
  parameter Modelica.Units.SI.Voltage VHV=24 "HV voltage";
  parameter Modelica.Units.SI.Resistance RiHV=0.01 "HV inner resistance";
  parameter Modelica.Units.SI.Capacitance CLV=500e-6 "Low voltage capacitance";
  parameter Modelica.Units.SI.Capacitance CHV=250e-6 "High voltage capacitance";
  parameter Modelica.Units.SI.Inductance L=10e-6 "Inductance";
  parameter Modelica.Units.SI.Resistance R=1e-3 "Resistance of inductor";
  parameter Modelica.Units.SI.Frequency fS=40e3 "Switching frequency";
  parameter Real idleDutyCycle=1 - VLV/VHV "Duty cycle for idle operation";
  Modelica.Electrical.PowerConverters.DCDC.ChopperBuckBost dcdc
  Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltageLV(V=VLV)
  Modelica.Electrical.Analog.Basic.Resistor resistorLV(R=RiLV)
  Modelica.Electrical.Analog.Basic.Ground ground
  Modelica.Electrical.Analog.Basic.Capacitor capacitorLV(v(fixed=true, start=VLV), C=CLV)
  Modelica.Electrical.Analog.Basic.Resistor resistor(R=R, useHeatPort=false)
  Modelica.Electrical.Analog.Basic.Inductor inductor(i(fixed=true),  L=L)
  Modelica.Electrical.Analog.Basic.Capacitor capacitorHV(v(fixed=true, start=VHV), C=CHV)
  Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltageHV(V=VHV)
  Modelica.Electrical.Analog.Basic.Resistor resistorHV(R=RiHV)
  Modelica.Blocks.Sources.RealExpression vLV(y=capacitorLV.v)
  Modelica.Blocks.Sources.RealExpression iLV(y=resistorLV.i)
  Modelica.Blocks.Sources.RealExpression vHV(y=capacitorHV.v)
  Modelica.Blocks.Sources.RealExpression iHV(y=resistorHV.i)
  Modelica.Blocks.Math.Mean mean_vLV(f=fS)
  Modelica.Blocks.Math.Mean mean_iLV(f=fS)
  Modelica.Blocks.Math.Mean mean_vHV(f=fS)
  Modelica.Blocks.Math.Mean mean_iHV(f=fS)
  Modelica.Electrical.PowerConverters.DCDC.Control.SignalPWM pwm(f=fS)
  Modelica.Electrical.Analog.Sensors.CurrentSensor currentSensor
equation
  connect(constantVoltageLV.p, resistorLV.p)
  connect(constantVoltageLV.n, ground.p)
  connect(resistorHV.p, constantVoltageHV.p)
  connect(vLV.y, mean_vLV.u)
  connect(iLV.y,mean_iLV. u)
  connect(mean_iHV.u, iHV.y)
  connect(vHV.y, mean_vHV.u)
  connect(capacitorHV.n, dcdc.dc_n2)
  connect(dcdc.dc_p2, resistorHV.n)
  connect(capacitorHV.p, resistorHV.n)
  connect(capacitorHV.n, constantVoltageHV.n)
  connect(resistorLV.n, resistor.p)
  connect(resistor.n, inductor.p)
  connect(dcdc.dc_p1, inductor.n)
  connect(dcdc.fire_p, pwm.fire)
  connect(dcdc.fire_n, pwm.notFire)
  connect(resistor.p, capacitorLV.p)
  connect(ground.p, currentSensor.n)
  connect(currentSensor.p, capacitorLV.n)
  connect(capacitorLV.n, dcdc.dc_n1)
end ChopperBuckBoost;


Step down chopper including control. Step down chopper example template including supply and sensors; load is not yet included

within Modelica.Electrical.PowerConverters.Examples.DCDC.ExampleTemplates;
partial model ChopperStepDown "Step down chopper including control"
  extends Icons.ExampleTemplate;
  parameter SI.Frequency f=1000 "Switching frequency";
  parameter SI.Voltage Vsource=60 "Source voltage";
  parameter SI.Inductance L=25e-3 "Source inductance";
  parameter SI.Capacitance C=20e-6 "Smoothing capacitance";
  parameter Real dutyCycle=0.20 "Duty cycle";
  parameter SI.Current ILoad=1.2 "Load current";
  parameter SI.Resistance RLoad=V0/ILoad "Load resistance";
  parameter SI.Voltage V0=Vsource*dutyCycle "No-load output voltage";
  Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage(final V=Vsource)
  PowerConverters.DCDC.ChopperStepDown chopperStepDown
  Modelica.Electrical.Analog.Sensors.CurrentSensor currentSensor
  Modelica.Electrical.Analog.Sensors.VoltageSensor voltageSensor
  Modelica.Electrical.Analog.Basic.Ground ground
  PowerConverters.DCDC.Control.SignalPWM signalPWM(constantDutyCycle=dutyCycle,
      f=f)
  Modelica.Blocks.Math.Mean meanCurrent(f=f, x0=0)
  Modelica.Blocks.Math.Mean meanVoltage(f=f, x0=0)
  Modelica.Electrical.Analog.Basic.Inductor inductor(i(fixed=true, start=0), L=L)
  Modelica.Electrical.Analog.Basic.Capacitor capacitor(C=C, v(fixed=true, start=V0))
equation
  connect(constantVoltage.p, chopperStepDown.dc_p1)
  connect(constantVoltage.n, chopperStepDown.dc_n1)
  connect(voltageSensor.n, currentSensor.p)
  connect(constantVoltage.n, ground.p)
  connect(voltageSensor.v, meanVoltage.u)
  connect(currentSensor.i, meanCurrent.u)
  connect(signalPWM.fire, chopperStepDown.fire_p)
  connect(chopperStepDown.dc_p2, inductor.p)
  connect(inductor.n, capacitor.p)
  connect(voltageSensor.p, capacitor.p)
  connect(chopperStepDown.dc_n2, capacitor.n)
  connect(capacitor.n, currentSensor.n)
end ChopperStepDown;


Step up chopper including control. Step up chopper example template including supply and sensors; load is not yet included

within Modelica.Electrical.PowerConverters.Examples.DCDC.ExampleTemplates;
partial model ChopperStepUp "Step up chopper including control"
  extends Icons.ExampleTemplate;
  parameter SI.Frequency f=1000 "Switching frequency";
  parameter SI.Voltage Vsource=60 "Source voltage";
  parameter SI.Inductance L=25e-3 "Source inductance";
  parameter SI.Capacitance C=20e-6 "Smoothing capacitance";
  parameter Real dutyCycle=0.20 "Duty cycle";
  parameter SI.Current ILoad=1.2 "Load current";
  parameter SI.Resistance RLoad=V0/ILoad "Load resistance";
  parameter SI.Voltage V0=Vsource/(1 - dutyCycle) "No-load output voltage";
  Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage(V=Vsource)
  PowerConverters.DCDC.ChopperStepUp chopperStepUp
  Modelica.Electrical.Analog.Sensors.CurrentSensor currentSensor
  Modelica.Electrical.Analog.Sensors.VoltageSensor voltageSensor
  Modelica.Electrical.Analog.Basic.Ground ground
  PowerConverters.DCDC.Control.SignalPWM signalPWM(constantDutyCycle=dutyCycle,
      f=f)
  Modelica.Blocks.Math.Mean meanCurrent(f=f, x0=0)
  Modelica.Blocks.Math.Mean meanVoltage(f=f, x0=0)
  Modelica.Electrical.Analog.Basic.Inductor inductor(i(fixed=true, start=0),
      final L=L)
  Modelica.Electrical.Analog.Basic.Capacitor capacitor(C=C, v(fixed=true, start=V0))
equation
  connect(constantVoltage.n, chopperStepUp.dc_n1)
  connect(voltageSensor.n, currentSensor.p)
  connect(constantVoltage.n, ground.p)
  connect(voltageSensor.v, meanVoltage.u)
  connect(currentSensor.i, meanCurrent.u)
  connect(signalPWM.fire, chopperStepUp.fire_p)
  connect(constantVoltage.p, inductor.p)
  connect(inductor.n, chopperStepUp.dc_p1)
  connect(voltageSensor.p, capacitor.p)
  connect(capacitor.p, chopperStepUp.dc_p2)
  connect(chopperStepUp.dc_n2, capacitor.n)
  connect(capacitor.n, currentSensor.n)
end ChopperStepUp;


H bridge DC/DC converter. H bridge example template including supply and sensors; load is not yet included

within Modelica.Electrical.PowerConverters.Examples.DCDC.ExampleTemplates;
partial model HBridge "H bridge DC/DC converter"
  extends Icons.ExampleTemplate;
  parameter SI.Frequency f=1000 "Switching frequency";
  PowerConverters.DCDC.HBridge hbridge(useHeatPort=false)
  Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage(V=
        100)
  PowerConverters.DCDC.Control.SignalPWM signalPWM(constantDutyCycle=0.6, f=f)
  Modelica.Electrical.Analog.Basic.Ground ground
  Modelica.Electrical.Analog.Sensors.CurrentSensor currentSensor
  Modelica.Electrical.Analog.Sensors.VoltageSensor voltageSensor
  Modelica.Blocks.Math.Mean meanCurrent(f=f, x0=0)
  Modelica.Blocks.Math.Mean meanVoltage(f=f, x0=0)
equation
  connect(hbridge.fire_p, signalPWM.fire)
  connect(ground.p, constantVoltage.n)
  connect(constantVoltage.p, hbridge.dc_p1)
  connect(constantVoltage.n, hbridge.dc_n1)
  connect(voltageSensor.n, currentSensor.p)
  connect(voltageSensor.v, meanVoltage.u)
  connect(currentSensor.i, meanCurrent.u)
  connect(hbridge.dc_p2, voltageSensor.p)
  connect(currentSensor.n, hbridge.dc_n2)
  connect(signalPWM.notFire, hbridge.fire_n)
end HBridge;


Templates of examples

within Modelica.Electrical.PowerConverters.Examples.DCDC;
package ExampleTemplates "Templates of examples"
  extends Modelica.Icons.Package;
end ExampleTemplates;


H bridge DC/DC converter with DC drive. This example of an H bridge with DC drive demonstrates the operation of the DC machine in four quadrants.
The DC output voltage is equal to 2 * (dutyCycle - 0.5) times the input voltage.

within Modelica.Electrical.PowerConverters.Examples.DCDC.HBridge;
model HBridge_DC_Drive "H bridge DC/DC converter with DC drive"
  extends ExampleTemplates.HBridge(signalPWM(useConstantDutyCycle=false,
      refType=Modelica.Electrical.PowerConverters.Types.SingleReferenceType.Triangle,
      commonComparison=false),
      constantVoltage(V=120));

  extends Modelica.Icons.Example;
  parameter SI.Inductance Ld=3*dcpmData.La
    "Smoothing inductance";
  final parameter SI.Torque tauNominal=dcpmData.ViNominal
      *dcpmData.IaNominal/dcpmData.wNominal "Nominal torque";
  parameter Real dMin=0.2 "Minimum duty cycle";
  parameter Real dMax=1 - dMin "Maximum duty cycle";
  Modelica.Electrical.Machines.BasicMachines.DCMachines.DC_PermanentMagnet
    dcpm(
    VaNominal=dcpmData.VaNominal,
    IaNominal=dcpmData.IaNominal,
    wNominal=dcpmData.wNominal,
    TaNominal=dcpmData.TaNominal,
    Ra=dcpmData.Ra,
    TaRef=dcpmData.TaRef,
    La=dcpmData.La,
    Jr=dcpmData.Jr,
    useSupport=false,
    Js=dcpmData.Js,
    frictionParameters=dcpmData.frictionParameters,
    coreParameters=dcpmData.coreParameters,
    strayLoadParameters=dcpmData.strayLoadParameters,
    brushParameters=dcpmData.brushParameters,
    ia(start=0, fixed=true),
    TaOperational=293.15,
    alpha20a=dcpmData.alpha20a,
    phiMechanical(fixed=true, start=0),
    wMechanical(fixed=true, start=0))
  parameter
    Modelica.Electrical.Machines.Utilities.ParameterRecords.DcPermanentMagnetData
    dcpmData "Data record of PM excited DC machine"
  Modelica.Mechanics.Rotational.Sources.Torque torque
  Modelica.Blocks.Sources.TimeTable torqueTable(table=[0, 0; 6, 0; 7, -
        tauNominal; 9, -tauNominal; 10, +tauNominal; 15, tauNominal; 16,
        -tauNominal; 18, -tauNominal; 19, 0; 24, 0])
  Modelica.Blocks.Sources.TimeTable dutyCycleTable(table=[0, 0.5; 3,
        0.5; 4, dMax; 12, dMax; 13, dMin; 21, dMin; 22, 0.5; 24, 0.5])
  Modelica.Electrical.Analog.Basic.Inductor inductor(L=Ld)
equation
  connect(inductor.n, dcpm.pin_ap)
  connect(dcpm.pin_an, currentSensor.p)
  connect(dcpm.flange, torque.flange)
  connect(torque.tau, torqueTable.y)
  connect(inductor.p, hbridge.dc_p2)
  connect(dutyCycleTable.y, signalPWM.dutyCycle)
end HBridge_DC_Drive;


H bridge DC/DC converter with resistive load. This example demonstrates the switching on of a resistive load operated by an H bridge.
DC output voltage is equal to 2 * (dutyCycle - 0.5) times the input voltage.
Plot current currentSensor.i, averaged current meanCurrent.y, total voltage voltageSensor.v and voltage meanVoltage.v.

within Modelica.Electrical.PowerConverters.Examples.DCDC.HBridge;
model HBridge_R "H bridge DC/DC converter with resistive load"
  extends ExampleTemplates.HBridge;
  extends Modelica.Icons.Example;
  parameter SI.Resistance R=100 "Resistance";
  Modelica.Electrical.Analog.Basic.Resistor resistor(R=R)
equation
  connect(resistor.p, hbridge.dc_p2)
  connect(resistor.n, currentSensor.p)
end HBridge_R;


H bridge DC/DC converter with R-L load. This example demonstrates the switching on of an R-L load operated by an H bridge.
DC output voltage is equal to 2 * (dutyCycle - 0.5) times the input voltage.
Plot current currentSensor.i, averaged current meanCurrent.y, total voltage voltageSensor.v and voltage meanVoltage.v. The waveform the average current is determined by the time constant L/R of the load.

within Modelica.Electrical.PowerConverters.Examples.DCDC.HBridge;
model HBridge_RL "H bridge DC/DC converter with R-L load"
  extends ExampleTemplates.HBridge;
  extends Modelica.Icons.Example;
  parameter SI.Resistance R=100 "Resistance";
  parameter SI.Inductance L=1 "Inductance";
  Modelica.Electrical.Analog.Basic.Resistor resistor(R=R)
  Modelica.Electrical.Analog.Basic.Inductor inductor(i(fixed=true,
        start=0), L=L)
equation
  connect(resistor.n, inductor.p)
  connect(inductor.n, currentSensor.p)
  connect(resistor.p, hbridge.dc_p2)
end HBridge_RL;


H bridge DC/DC converter with R-L load. This is the same example as HBridge_RL
but using a triangle (instead of a sawtooth) as pwm reference signal.
This enables an easy sampling of the current in the middle of the pwm period, which delivers with good approximation the mean current:
Compare meanCurrent.y and zeroOrderHold.y.
For discrete or quasi-continuous control it is essential to sample the correct mean current with low effort once during the pwm period.

within Modelica.Electrical.PowerConverters.Examples.DCDC.HBridge;
model HBridge_TrianglePWM_RL "H bridge DC/DC converter with R-L load"
  extends ExampleTemplates.HBridge(signalPWM(refType=Modelica.Electrical.PowerConverters.Types.SingleReferenceType.Triangle));
  extends Modelica.Icons.Example;
  parameter SI.Resistance R=100 "Resistance";
  parameter SI.Inductance L=1 "Inductance";
  Modelica.Electrical.Analog.Basic.Resistor resistor(R=R)
  Modelica.Electrical.Analog.Basic.Inductor inductor(i(fixed=true,
        start=0), L=L)
  Blocks.Discrete.ZeroOrderHold zeroOrderHold(samplePeriod=1/f, startTime=0.5/f)
equation
  connect(resistor.n, inductor.p)
  connect(inductor.n, currentSensor.p)
  connect(resistor.p, hbridge.dc_p2)
  connect(currentSensor.i, zeroOrderHold.u)
end HBridge_TrianglePWM_RL;


H bridge converter

within Modelica.Electrical.PowerConverters.Examples.DCDC;
package HBridge "H bridge converter"
  extends Modelica.Icons.ExamplesPackage;
end HBridge;


Control icon.

within Modelica.Electrical.PowerConverters.Icons;
partial block Control "Control icon"
end Control;


Converter icon.

within Modelica.Electrical.PowerConverters.Icons;
partial model Converter "Converter icon"
end Converter;


Example template.

within Modelica.Electrical.PowerConverters.Icons;
partial model ExampleTemplate "Example template"
end ExampleTemplate;


Icons

within Modelica.Electrical.PowerConverters;
package Icons "Icons"
  extends Modelica.Icons.Package;
end Icons;


Interfaces

within Modelica.Electrical.PowerConverters;
package Interfaces "Interfaces"
  extends Modelica.Icons.InterfacesPackage;
end Interfaces;


AC polyphase plug.

within Modelica.Electrical.PowerConverters.Interfaces.ACDC;
partial model ACplug "AC polyphase plug"
  parameter Integer m(final min=3) = 3 "Number of phases"
  Modelica.Electrical.Polyphase.Interfaces.PositivePlug ac(final m=m)
    "AC input"
  SI.Voltage vAC[m]=ac.pin[:].v "AC potentials";
  SI.Current iAC[m]=ac.pin[:].i "AC currents";
  SI.Power powerAC[m]=vAC.*iAC "AC power";
  SI.Power powerTotalAC=sum(powerAC) "AC total power";
end ACplug;


Positive and negative AC pin.

within Modelica.Electrical.PowerConverters.Interfaces.ACDC;
partial model ACtwoPin "Positive and negative AC pin"

  Modelica.Electrical.Analog.Interfaces.PositivePin ac_p
    "Positive AC input"
  Modelica.Electrical.Analog.Interfaces.NegativePin ac_n
    "Negative AC input"
  SI.Voltage vAC=ac_p.v - ac_n.v "AC voltages";
  SI.Current iAC=ac_p.i "AC currents";
  SI.Power powerAC=vAC*iAC "AC power";
end ACtwoPin;


Two AC polyphase plugs.

within Modelica.Electrical.PowerConverters.Interfaces.ACDC;
partial model ACtwoPlug "Two AC polyphase plugs"
  parameter Integer m(final min=3) = 3 "Number of phases"
  Modelica.Electrical.Polyphase.Interfaces.PositivePlug ac_p(final m=m)
    "Positive potential AC input"
  Modelica.Electrical.Polyphase.Interfaces.NegativePlug ac_n(final m=m)
    "Negative potential AC input"
  SI.Voltage vAC[m]=ac_p.pin[:].v - ac_n.pin[:].v "AC voltages";
  SI.Current iAC[m]=ac_p.pin[:].i "AC currents";
  SI.Power powerAC[m]=vAC.*iAC "AC power";
  SI.Power powerTotalAC=sum(powerAC) "AC total power";
end ACtwoPlug;


Single DC pin.

within Modelica.Electrical.PowerConverters.Interfaces.ACDC;
partial model DCpin "Single DC pin"

  Modelica.Electrical.Analog.Interfaces.PositivePin dc_p
    "Positive DC output"
  SI.Voltage vDC=dc_p.v "DC potential";
  SI.Current iDC=dc_p.i "DC current";
  SI.Power powerDC=vDC*iDC "DC power";
end DCpin;


Positive and negative DC pins.

within Modelica.Electrical.PowerConverters.Interfaces.ACDC;
partial model DCtwoPin "Positive and negative DC pins"

  Modelica.Electrical.Analog.Interfaces.PositivePin dc_p
    "Positive DC output"
  Modelica.Electrical.Analog.Interfaces.NegativePin dc_n
    "Negative DC output"
  SI.Voltage vDC=dc_p.v-dc_n.v "DC voltage";
  SI.Current iDC=dc_p.i "DC current";
  SI.Power powerDC=vDC*iDC "DC power";
end DCtwoPin;


AC to DC converter interfaces

within Modelica.Electrical.PowerConverters.Interfaces;
package ACDC "AC to DC converter interfaces"
  extends Modelica.Icons.InterfacesPackage;
end ACDC;


Single AC pin.

within Modelica.Electrical.PowerConverters.Interfaces.DCAC;
partial model ACpin "Single AC pin"

  Modelica.Electrical.Analog.Interfaces.PositivePin ac "AC output"
  SI.Voltage vAC=ac.v "AC potential";
  SI.Current iAC=ac.i "AC current";
  SI.Power powerAC=vAC*iAC "AC power";
end ACpin;


AC polyphase plug.

within Modelica.Electrical.PowerConverters.Interfaces.DCAC;
partial model ACplug "AC polyphase plug"
  parameter Integer m(final min=3) = 3 "Number of phases"
  Modelica.Electrical.Polyphase.Interfaces.PositivePlug ac(final m=m)
    "AC output"
  SI.Voltage vAC[m]=ac.pin[:].v "AC potential";
  SI.Current iAC[m]=ac.pin[:].i "AC current";
  SI.Power powerAC[m]=vAC.*iAC "AC power";
  SI.Power powerTotalAC=sum(powerAC) "AC total power";
end ACplug;


Positive and negative DC pins.

within Modelica.Electrical.PowerConverters.Interfaces.DCAC;
partial model DCtwoPin "Positive and negative DC pins"

  Modelica.Electrical.Analog.Interfaces.PositivePin dc_p
    "Positive DC input"
  Modelica.Electrical.Analog.Interfaces.NegativePin dc_n
    "Negative DC input"
  SI.Voltage vDC=dc_p.v - dc_n.v "DC voltage";
  SI.Current iDC=dc_p.i "DC current";
  SI.Power powerDC=vDC*iDC "DC power";
end DCtwoPin;


DC to AC converter interfaces

within Modelica.Electrical.PowerConverters.Interfaces;
package DCAC "DC to AC converter interfaces"
  extends Modelica.Icons.InterfacesPackage;

end DCAC;


Positive and negative pins of side 1.

within Modelica.Electrical.PowerConverters.Interfaces.DCDC;
partial model DCtwoPin1 "Positive and negative pins of side 1"

  Modelica.Electrical.Analog.Interfaces.PositivePin dc_p1
    "Positive DC input"
  Modelica.Electrical.Analog.Interfaces.NegativePin dc_n1
    "Negative DC input"
  SI.Voltage vDC1=dc_p1.v - dc_n1.v "DC voltage side 1";
  SI.Current iDC1=dc_p1.i "DC current side 1";
  SI.Power powerDC1=vDC1*iDC1 "DC power side 1";
end DCtwoPin1;


Positive and negative pins of side 2.

within Modelica.Electrical.PowerConverters.Interfaces.DCDC;
partial model DCtwoPin2 "Positive and negative pins of side 2"

  Modelica.Electrical.Analog.Interfaces.PositivePin dc_p2
    "Positive DC output"
  Modelica.Electrical.Analog.Interfaces.NegativePin dc_n2
    "Negative DC output"
  SI.Voltage vDC2=dc_p2.v - dc_n2.v "DC voltages side 2";
  SI.Current iDC2=dc_p2.i "DC current side 2";
  SI.Power powerDC2=vDC2*iDC2 "DC power side 2";
end DCtwoPin2;


DC to DC converter interfaces

within Modelica.Electrical.PowerConverters.Interfaces;
package DCDC "DC to DC converter interfaces"
  extends Modelica.Icons.InterfacesPackage;
end DCDC;


Partial model providing enable parameter and optional enable input. This partial model provides parameters and the conditional input signal for the enabling models:

within Modelica.Electrical.PowerConverters.Interfaces.Enable;
partial model Enable
  "Partial model providing enable parameter and optional enable input"
  parameter Boolean useConstantEnable=true
    "Disable boolean input and use constantEnable, if true"
  parameter Boolean constantEnable=true
    "Constant enabling of firing signals"
  parameter Integer m(final min=1) = 3 "Number of phases"
  PowerConverters.Enable.EnableLogic enableLogic(
    final useConstantEnable=useConstantEnable,
    final constantEnable=constantEnable,
    final m=m) "Enabling logic"
  Modelica.Blocks.Interfaces.BooleanInput enable if not useConstantEnable
    "Enables fire and notFire"
equation
  connect(enableLogic.enable, enable)
end Enable;


Partial model providing enable parameter and optional enable input for one firing signal. This partial model provides the enabling logic for one firing signal.

within Modelica.Electrical.PowerConverters.Interfaces.Enable;
partial model Enable1
  "Partial model providing enable parameter and optional enable input for one firing signal"
  extends PowerConverters.Interfaces.Enable.Enable(final m=1);
  Modelica.Blocks.Logical.And andCondition_p
    "And condition for positive firing signal"
  Modelica.Blocks.Interfaces.BooleanInput fire_p
    "Firing signal of positive potential transistor"
equation
  connect(andCondition_p.u1, fire_p)
  connect(enableLogic.enable, enable)
  connect(enableLogic.internalEnable[1], andCondition_p.u2)
end Enable1;


Partial model providing enable parameter and optional enable input for m firing signals. This partial model provides the enabling logic for m firing signal.

within Modelica.Electrical.PowerConverters.Interfaces.Enable;
partial model Enable1m
  "Partial model providing enable parameter and optional enable input for m firing signals"
  parameter Boolean useConstantEnable=true
    "Disable boolean input and use constantEnable, if true"
  parameter Boolean constantEnable=true
    "Constant enabling of firing signals"
  parameter Integer m(final min=3) = 3 "Number of phases"
  Modelica.Blocks.Logical.And andCondition_p[m]
    "And condition for m positive firing signals"
  Modelica.Blocks.Interfaces.BooleanInput fire_p[m]
    "Firing signals of positive potential transistors"
  PowerConverters.Enable.EnableLogic enableLogic(
    final useConstantEnable=useConstantEnable,
    final constantEnable=constantEnable,
    final m=m) "Enabling logic"
  Modelica.Blocks.Interfaces.BooleanInput enable if not useConstantEnable
    "Enables fire and notFire"
equation
  connect(andCondition_p.u1, fire_p)
  connect(enableLogic.enable, enable)
  connect(enableLogic.internalEnable, andCondition_p.u2)
end Enable1m;


Partial model providing enable parameter and optional enable input for two firing signals. This partial model provides the enabling logic for two firing signal.

within Modelica.Electrical.PowerConverters.Interfaces.Enable;
partial model Enable2
  "Partial model providing enable parameter and optional enable input for two firing signals"
  extends PowerConverters.Interfaces.Enable.Enable1;
  Modelica.Blocks.Logical.And andCondition_n
    "And condition for negative firing signal"
  Modelica.Blocks.Interfaces.BooleanInput fire_n
    "Firing signal of negative potential transistor"
equation
  connect(fire_n, andCondition_n.u1)
  connect(enableLogic.internalEnable[1], andCondition_n.u2)
end Enable2;


Partial model providing enable parameter and optional enable input for 2*m firing signals. This partial model provides the enabling logic for 2*m firing signal.

within Modelica.Electrical.PowerConverters.Interfaces.Enable;
partial model Enable2m
  "Partial model providing enable parameter and optional enable input for 2*m firing signals"
  extends Interfaces.Enable.Enable1m;
  Modelica.Blocks.Logical.And andCondition_n[m]
    "And condition for m negative firing signals"
  Modelica.Blocks.Interfaces.BooleanInput fire_n[m]
    "Firing signals of negative potential transistors"
equation
  connect(fire_n, andCondition_n.u1)
  connect(enableLogic.internalEnable, andCondition_n.u2)
end Enable2m;


Enabling interfaces

within Modelica.Electrical.PowerConverters.Interfaces;
package Enable "Enabling interfaces"
  extends Modelica.Icons.InterfacesPackage;
end Enable;


Type definitions for PowerConverters

within Modelica.Electrical.PowerConverters;
package Types "Type definitions for PowerConverters"
  extends Modelica.Icons.TypesPackage;
end Types;


within Modelica.Electrical;
package QuasiStatic "Library for quasi-static electrical single-phase and polyphase AC simulation"
  extends Modelica.Icons.Package;
end QuasiStatic;


Quasi-static machine models

within Modelica.Electrical.QuasiStatic;
package Machines "Quasi-static machine models"
  extends Modelica.Icons.Package;
end Machines;


Basic machine models

within Modelica.Electrical.QuasiStatic.Machines;
package BasicMachines "Basic machine models"
  extends Modelica.Icons.Package;
end BasicMachines;


Ideal transformer with 3 windings.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Components;
model IdealCore "Ideal transformer with 3 windings"
  extends PartialCore;
equation
  im = fill(Complex(0), m);
  v1 = n12*v2;
  v1 = n13*v3;
end IdealCore;


Machine components

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines;
package Components "Machine components"
  extends Modelica.Icons.Package;
end Components;


Partial model of transformer core with 3 windings.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Components;
partial model PartialCore
  "Partial model of transformer core with 3 windings"
  parameter Integer m(final min=1) = 3 "Number of phases"
  parameter Real n12(start=1) "Turns ratio 1:2";
  parameter Real n13(start=1) "Turns ratio 1:3";
  SI.ComplexVoltage v1[m];
  SI.ComplexCurrent i1[m];
  SI.ComplexVoltage v2[m];
  SI.ComplexCurrent i2[m];
  SI.ComplexVoltage v3[m];
  SI.ComplexCurrent i3[m];
  SI.ComplexCurrent im[m] "Magnetizing current";
  QuasiStatic.Polyphase.Interfaces.PositivePlug plug_p1(final m=m)
  QuasiStatic.Polyphase.Interfaces.NegativePlug plug_n1(final m=m)
  QuasiStatic.Polyphase.Interfaces.PositivePlug plug_p2(final m=m)
  QuasiStatic.Polyphase.Interfaces.NegativePlug plug_n2(final m=m)
  QuasiStatic.Polyphase.Interfaces.PositivePlug plug_p3(final m=m)
  QuasiStatic.Polyphase.Interfaces.NegativePlug plug_n3(final m=m)
equation
  v1 = plug_p1.pin.v - plug_n1.pin.v;
  i1 = plug_p1.pin.i;
  v2 = plug_p2.pin.v - plug_n2.pin.v;
  i2 = plug_p2.pin.i;
  v3 = plug_p3.pin.v - plug_n3.pin.v;
  i3 = plug_p3.pin.i;
  im = i1 + i2/n12 + i3/n13;
  //branches p1-n1, p2-n2, p3-n3
  Connections.branch(plug_p1.reference, plug_n1.reference);
  plug_p1.reference.gamma = plug_n1.reference.gamma;
  Connections.branch(plug_p2.reference, plug_n2.reference);
  plug_p2.reference.gamma = plug_n2.reference.gamma;
  Connections.branch(plug_p3.reference, plug_n3.reference);
  plug_p3.reference.gamma = plug_n3.reference.gamma;
  //Define p1.reference.gamme = p2.reference.gamma = p3.reference.gamma
  Connections.branch(plug_p1.reference, plug_p2.reference);
  plug_p1.reference.gamma = plug_p2.reference.gamma;
  Connections.branch(plug_p1.reference, plug_p3.reference);
  plug_p1.reference.gamma = plug_p3.reference.gamma;
  //Note: transformer could be fed from primary or secondary side
  //Define p1, p2 and p3 as potential roots
  //Not necessary since there exist non-breakable branches between primary and secondary side
  //Connections.potentialRoot(plug_p1.reference);
  //Connections.potentialRoot(plug_p2.reference);
  //Connections.potentialRoot(plug_p3.reference);
  //Current balances
  plug_p1.pin.i + plug_n1.pin.i = fill(Complex(0), m);
  plug_p2.pin.i + plug_n2.pin.i = fill(Complex(0), m);
  plug_p3.pin.i + plug_n3.pin.i = fill(Complex(0), m);
end PartialCore;


within Modelica.Electrical.QuasiStatic.Machines.BasicMachines;
package Transformers "Library for technical 3phase transformers"
  extends Modelica.Icons.Package;
end Transformers;


Transformer Dd0.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Dd;
model Dd00 "Transformer Dd0"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Dd00");
  QuasiStatic.Polyphase.Basic.Delta Delta1(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Delta2(final m=m)
equation
  connect(r1.plug_p, Delta1.plug_p)
  connect(Delta2.plug_p, r2.plug_n)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(Delta1.plug_n, core.plug_n1)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_p2, l2sigma.plug_p)
  connect(core.plug_n3, Delta2.plug_n)
end Dd00;


Transformer Dd2.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Dd;
model Dd02 "Transformer Dd2"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Dd02");
  QuasiStatic.Polyphase.Basic.Delta Delta1(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Delta2(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Rot2(final m=m)
equation
  connect(r1.plug_p, Delta1.plug_p)
  connect(Delta2.plug_n, r2.plug_n)
  connect(l2sigma.plug_p, Rot2.plug_p)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(Delta1.plug_n, core.plug_n1)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_p2, Delta2.plug_p)
  connect(core.plug_n3, Rot2.plug_n)
end Dd02;


Transformer Dd4.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Dd;
model Dd04 "Transformer Dd4"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Dd04");
  QuasiStatic.Polyphase.Basic.Delta Delta1(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Delta2(final m=m)
equation
  connect(r1.plug_p, Delta1.plug_p)
  connect(Delta2.plug_n, r2.plug_n)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(Delta1.plug_n, core.plug_n1)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_p2, Delta2.plug_p)
  connect(core.plug_n3, l2sigma.plug_p)
end Dd04;


Transformer Dd6.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Dd;
model Dd06 "Transformer Dd6"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Dd06");
  QuasiStatic.Polyphase.Basic.Delta Delta1(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Delta2(final m=m)
equation
  connect(Delta2.plug_p, r2.plug_n)
  connect(Delta1.plug_p, r1.plug_p)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(Delta1.plug_n, core.plug_n1)
  connect(core.plug_n2, core.plug_p3)
  connect(Delta2.plug_n, core.plug_p2)
  connect(core.plug_n3, l2sigma.plug_p)
end Dd06;


Transformer Dd8.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Dd;
model Dd08 "Transformer Dd8"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Dd08");
  QuasiStatic.Polyphase.Basic.Delta Delta1(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Rot2(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Delta2(final m=m)
equation
  connect(r1.plug_p, Delta1.plug_p)
  connect(Delta2.plug_n, r2.plug_n)
  connect(Rot2.plug_p, l2sigma.plug_p)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n1, Delta1.plug_n)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_p2, Rot2.plug_n)
  connect(core.plug_n3, Delta2.plug_p)
end Dd08;


Transformer Dd10.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Dd;
model Dd10 "Transformer Dd10"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Dd10");
  QuasiStatic.Polyphase.Basic.Delta Delta1(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Delta2(final m=m)
equation
  connect(r1.plug_p, Delta1.plug_p)
  connect(Delta2.plug_n, r2.plug_n)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(Delta1.plug_n, core.plug_n1)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_p2, l2sigma.plug_p)
  connect(core.plug_n3, Delta2.plug_p)
end Dd10;


Transformers: primary D / secondary d

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers;
package Dd "Transformers: primary D / secondary d"
  extends Modelica.Icons.VariantsPackage;
end Dd;


Transformer Dy1.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Dy;
model Dy01 "Transformer Dy1"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Dy01");
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Delta1(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Rot2(final m=m)
equation
  connect(star2.pin_n, starpoint2)
  connect(l2sigma.plug_p, Rot2.plug_p)
  connect(Delta1.plug_p, r1.plug_p)
  connect(Delta1.plug_n, core.plug_n1)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_n3, Rot2.plug_n)
  connect(core.plug_p2, star2.plug_p)
end Dy01;


Transformer Dy3.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Dy;
model Dy03 "Transformer Dy3"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Dy03");
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Delta1(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Rot2(final m=m)
equation
  connect(star2.pin_n, starpoint2)
  connect(Rot2.plug_n, l2sigma.plug_p)
  connect(Delta1.plug_p, r1.plug_p)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(Delta1.plug_n, core.plug_n1)
  connect(core.plug_p2, Rot2.plug_p)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_n3, star2.plug_p)
end Dy03;


Transformer Dy5.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Dy;
model Dy05 "Transformer Dy5"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Dy05");
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Delta1(final m=m)
equation
  connect(star2.pin_n, starpoint2)
  connect(Delta1.plug_p, r1.plug_p)
  connect(Delta1.plug_n, core.plug_n1)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n2, core.plug_p3)
  connect(l2sigma.plug_p, core.plug_n3)
  connect(core.plug_p2, star2.plug_p)
end Dy05;


Transformer Dy7.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Dy;
model Dy07 "Transformer Dy7"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Dy07");
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Delta1(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Rot2(final m=m)
equation
  connect(star2.pin_n, starpoint2)
  connect(r1.plug_p, Delta1.plug_p)
  connect(Rot2.plug_p, l2sigma.plug_p)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(Delta1.plug_n, core.plug_n1)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_n3, star2.plug_p)
  connect(core.plug_p2, Rot2.plug_n)
end Dy07;


Transformer Dy9.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Dy;
model Dy09 "Transformer Dy9"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Dy09");
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Delta1(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Rot2(final m=m)
equation
  connect(star2.pin_n, starpoint2)
  connect(r1.plug_p, Delta1.plug_p)
  connect(l2sigma.plug_p, Rot2.plug_n)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(Delta1.plug_n, core.plug_n1)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_n3, Rot2.plug_p)
  connect(core.plug_p2, star2.plug_p)
end Dy09;


Transformer Dy11.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Dy;
model Dy11 "Transformer Dy11"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Dy11");
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Delta1(final m=m)
equation
  connect(star2.pin_n, starpoint2)
  connect(r1.plug_p, Delta1.plug_p)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(Delta1.plug_n, core.plug_n1)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_n3, star2.plug_p)
  connect(core.plug_p2, l2sigma.plug_p)
end Dy11;


Transformers: primary D / secondary y

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers;
package Dy "Transformers: primary D / secondary y"
  extends Modelica.Icons.VariantsPackage;
end Dy;


Transformer Dz0.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Dz;
model Dz00 "Transformer Dz0"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Dz00");
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Rot21(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Rot22(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Delta1(final m=m)
equation
  connect(star2.pin_n, starpoint2)
  connect(r1.plug_p, Delta1.plug_p)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(Delta1.plug_n, core.plug_n1)
  connect(core.plug_p2, Rot21.plug_n)
  connect(core.plug_p3, Rot21.plug_p)
  connect(l2sigma.plug_p, Rot22.plug_p)
  connect(Rot22.plug_n, core.plug_n2)
  connect(core.plug_n3, star2.plug_p)
end Dz00;


Transformer Dz2.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Dz;
model Dz02 "Transformer Dz2"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Dz02");
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Rot21(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Rot22(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Delta1(final m=m)
equation
  connect(star2.pin_n, starpoint2)
  connect(r1.plug_p, Delta1.plug_p)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(Delta1.plug_n, core.plug_n1)
  connect(core.plug_p2, Rot21.plug_p)
  connect(core.plug_p3, Rot21.plug_n)
  connect(l2sigma.plug_p, Rot22.plug_p)
  connect(Rot22.plug_n, core.plug_n2)
  connect(core.plug_n3, star2.plug_p)
end Dz02;


Transformer Dz4.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Dz;
model Dz04 "Transformer Dz4"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Dz04");
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Rot21(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Delta1(final m=m)
equation
  connect(star2.pin_n, starpoint2)
  connect(r1.plug_p, Delta1.plug_p)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(Delta1.plug_n, core.plug_n1)
  connect(core.plug_p2, Rot21.plug_n)
  connect(core.plug_p3, Rot21.plug_p)
  connect(l2sigma.plug_p, core.plug_n2)
  connect(core.plug_n3, star2.plug_p)
end Dz04;


Transformer Dz6.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Dz;
model Dz06 "Transformer Dz6"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Dz06");
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Rot21(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Delta1(final m=m)
equation
  connect(star2.pin_n, starpoint2)
  connect(r1.plug_p, Delta1.plug_p)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(Delta1.plug_n, core.plug_n1)
  connect(core.plug_p2, Rot21.plug_p)
  connect(core.plug_p3, Rot21.plug_n)
  connect(core.plug_n3, star2.plug_p)
  connect(l2sigma.plug_p, core.plug_n2)
end Dz06;


Transformer Dz8.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Dz;
model Dz08 "Transformer Dz8"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Dz08");
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Rot21(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Rot22(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Delta1(final m=m)
equation
  connect(star2.pin_n, starpoint2)
  connect(r1.plug_p, Delta1.plug_p)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(Delta1.plug_n, core.plug_n1)
  connect(core.plug_p2, Rot21.plug_n)
  connect(core.plug_p3, Rot21.plug_p)
  connect(core.plug_n3, star2.plug_p)
  connect(l2sigma.plug_p, Rot22.plug_n)
  connect(Rot22.plug_p, core.plug_n2)
end Dz08;


Transformer Dz10.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Dz;
model Dz10 "Transformer Dz10"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Dz10");
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Rot21(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Rot22(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Delta1(final m=m)
equation
  connect(star2.pin_n, starpoint2)
  connect(r1.plug_p, Delta1.plug_p)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(Delta1.plug_n, core.plug_n1)
  connect(core.plug_p2, Rot21.plug_p)
  connect(core.plug_p3, Rot21.plug_n)
  connect(core.plug_n3, star2.plug_p)
  connect(l2sigma.plug_p, Rot22.plug_n)
  connect(Rot22.plug_p, core.plug_n2)
end Dz10;


within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers;
package Dz "Transformers: primary D / secondary zig-zag"
  extends Modelica.Icons.VariantsPackage;
end Dz;


Transformers: primary Y / secondary d

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers;
package Yd "Transformers: primary Y / secondary d"
  extends Modelica.Icons.VariantsPackage;
end Yd;


Transformer Yd1.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Yd;
model Yd01 "Transformer Yd1"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Yd01");
  QuasiStatic.Polyphase.Basic.Star star1(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint1
  QuasiStatic.Polyphase.Basic.Delta Delta2(final m=m)
equation
  connect(star1.pin_n, starpoint1)
  connect(Delta2.plug_p, r2.plug_n)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n1, star1.plug_p)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_n3, Delta2.plug_n)
  connect(core.plug_p2, l2sigma.plug_p)
end Yd01;


Transformer Yd3.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Yd;
model Yd03 "Transformer Yd3"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Yd03");
  QuasiStatic.Polyphase.Basic.Star star1(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint1
  QuasiStatic.Polyphase.Basic.Delta Delta2(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Rot2(final m=m)
equation
  connect(star1.pin_n, starpoint1)
  connect(Delta2.plug_n, r2.plug_n)
  connect(l2sigma.plug_p, Rot2.plug_p)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n1, star1.plug_p)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_p2, Delta2.plug_p)
  connect(core.plug_n3, Rot2.plug_n)
end Yd03;


Transformer Yd5.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Yd;
model Yd05 "Transformer Yd5"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Yd05");
  QuasiStatic.Polyphase.Basic.Star star1(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint1
  QuasiStatic.Polyphase.Basic.Delta Delta2(final m=m)
equation
  connect(star1.pin_n, starpoint1)
  connect(Delta2.plug_n, r2.plug_n)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n1, star1.plug_p)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_n3, l2sigma.plug_p)
  connect(core.plug_p2, Delta2.plug_p)
end Yd05;


Transformer Yd7.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Yd;
model Yd07 "Transformer Yd7"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Yd07");
  QuasiStatic.Polyphase.Basic.Star star1(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint1
  QuasiStatic.Polyphase.Basic.Delta Delta2(final m=m)
equation
  connect(star1.pin_n, starpoint1)
  connect(Delta2.plug_p, r2.plug_n)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n1, star1.plug_p)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_p2, Delta2.plug_n)
  connect(l2sigma.plug_p, core.plug_n3)
end Yd07;


Transformer Yd9.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Yd;
model Yd09 "Transformer Yd9"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Yd09");
  QuasiStatic.Polyphase.Basic.Star star1(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint1
  QuasiStatic.Polyphase.Basic.Delta Delta2(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Rot2(final m=m)
equation
  connect(star1.pin_n, starpoint1)
  connect(Rot2.plug_p, l2sigma.plug_p)
  connect(Delta2.plug_n, r2.plug_n)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n1, star1.plug_p)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_p2, Rot2.plug_n)
  connect(core.plug_n3, Delta2.plug_p)
end Yd09;


Transformer Yd11.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Yd;
model Yd11 "Transformer Yd11"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Yd11");
  QuasiStatic.Polyphase.Basic.Star star1(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint1
  QuasiStatic.Polyphase.Basic.Delta Delta2(final m=m)
equation
  connect(star1.pin_n, starpoint1)
  connect(Delta2.plug_n, r2.plug_n)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n1, star1.plug_p)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_n3, Delta2.plug_p)
  connect(core.plug_p2, l2sigma.plug_p)
end Yd11;


Transformers: primary Y / secondary y

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers;
package Yy "Transformers: primary Y / secondary y"
  extends Modelica.Icons.VariantsPackage;
end Yy;


Transformer Yy0.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Yy;
model Yy00 "Transformer Yy0"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Yy00");
  QuasiStatic.Polyphase.Basic.Star star1(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint1
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
equation
  connect(star1.pin_n, starpoint1)
  connect(star2.pin_n, starpoint2)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n1, star1.plug_p)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_p2, l2sigma.plug_p)
  connect(core.plug_n3, star2.plug_p)
end Yy00;


Transformer Yy2.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Yy;
model Yy02 "Transformer Yy2"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Yy02");
  QuasiStatic.Polyphase.Basic.Star star1(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint1
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Rot2(final m=m)
equation
  connect(star1.pin_n, starpoint1)
  connect(star2.pin_n, starpoint2)
  connect(l2sigma.plug_p, Rot2.plug_p)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_n1, star1.plug_p)
  connect(core.plug_n3, Rot2.plug_n)
  connect(core.plug_p2, star2.plug_p)
end Yy02;


Transformer Yy4.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Yy;
model Yy04 "Transformer Yy4"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Yy04");
  QuasiStatic.Polyphase.Basic.Star star1(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint1
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Rot2(final m=m)
equation
  connect(star1.pin_n, starpoint1)
  connect(star2.pin_n, starpoint2)
  connect(Rot2.plug_n, l2sigma.plug_p)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n1, star1.plug_p)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_p2, Rot2.plug_p)
  connect(core.plug_n3, star2.plug_p)
end Yy04;


Transformer Yy6.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Yy;
model Yy06 "Transformer Yy6"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Yy06");
  QuasiStatic.Polyphase.Basic.Star star1(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint1
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
equation
  connect(star1.pin_n, starpoint1)
  connect(star2.pin_n, starpoint2)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n1, star1.plug_p)
  connect(core.plug_n2, core.plug_p3)
  connect(l2sigma.plug_p, core.plug_n3)
  connect(core.plug_p2, star2.plug_p)
end Yy06;


Transformer Yy8.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Yy;
model Yy08 "Transformer Yy8"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Yy08");
  QuasiStatic.Polyphase.Basic.Star star1(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint1
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Rot2(final m=m)
equation
  connect(star1.pin_n, starpoint1)
  connect(star2.pin_n, starpoint2)
  connect(Rot2.plug_p, l2sigma.plug_p)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n1, star1.plug_p)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_p2, Rot2.plug_n)
  connect(core.plug_n3, star2.plug_p)
end Yy08;


Transformer Yy10.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Yy;
model Yy10 "Transformer Yy10"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Yy10");
  QuasiStatic.Polyphase.Basic.Star star1(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint1
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Rot2(final m=m)
equation
  connect(star1.pin_n, starpoint1)
  connect(star2.pin_n, starpoint2)
  connect(l2sigma.plug_p, Rot2.plug_n)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n1, star1.plug_p)
  connect(core.plug_n2, core.plug_p3)
  connect(core.plug_n3, Rot2.plug_p)
  connect(core.plug_p2, star2.plug_p)
end Yy10;


within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers;
package Yz "Transformers: primary Y / secondary zig-zag"
  extends Modelica.Icons.VariantsPackage;
end Yz;


Transformer Yz1.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Yz;
model Yz01 "Transformer Yz1"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Yz01");
  QuasiStatic.Polyphase.Basic.Star star1(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint1
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Rot21(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Rot22(final m=m)
equation
  connect(star1.pin_n, starpoint1)
  connect(star2.pin_n, starpoint2)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n1, star1.plug_p)
  connect(core.plug_p2, Rot21.plug_n)
  connect(core.plug_p3, Rot21.plug_p)
  connect(l2sigma.plug_p, Rot22.plug_p)
  connect(Rot22.plug_n, core.plug_n2)
  connect(core.plug_n3, star2.plug_p)
end Yz01;


Transformer Yz3.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Yz;
model Yz03 "Transformer Yz3"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Yz03");
  QuasiStatic.Polyphase.Basic.Star star1(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint1
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Rot21(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Rot22(final m=m)
equation
  connect(star1.pin_n, starpoint1)
  connect(star2.pin_n, starpoint2)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n1, star1.plug_p)
  connect(core.plug_p2, Rot21.plug_p)
  connect(core.plug_p3, Rot21.plug_n)
  connect(l2sigma.plug_p, Rot22.plug_p)
  connect(Rot22.plug_n, core.plug_n2)
  connect(core.plug_n3, star2.plug_p)
end Yz03;


Transformer Yz5.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Yz;
model Yz05 "Transformer Yz5"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Yz05");
  QuasiStatic.Polyphase.Basic.Star star1(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint1
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Rot21(final m=m)
equation
  connect(star1.pin_n, starpoint1)
  connect(star2.pin_n, starpoint2)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n1, star1.plug_p)
  connect(core.plug_p2, Rot21.plug_n)
  connect(core.plug_p3, Rot21.plug_p)
  connect(core.plug_n3, star2.plug_p)
  connect(l2sigma.plug_p, core.plug_n2)
end Yz05;


Transformer Yz7.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Yz;
model Yz07 "Transformer Yz7"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Yz07");
  QuasiStatic.Polyphase.Basic.Star star1(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint1
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Rot21(final m=m)
equation
  connect(star1.pin_n, starpoint1)
  connect(star2.pin_n, starpoint2)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n1, star1.plug_p)
  connect(core.plug_p2, Rot21.plug_p)
  connect(core.plug_p3, Rot21.plug_n)
  connect(l2sigma.plug_p, core.plug_n2)
  connect(core.plug_n3, star2.plug_p)
end Yz07;


Transformer Yz9.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Yz;
model Yz09 "Transformer Yz9"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Yz09");
  QuasiStatic.Polyphase.Basic.Star star1(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint1
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Rot21(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Rot22(final m=m)
equation
  connect(star1.pin_n, starpoint1)
  connect(star2.pin_n, starpoint2)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n1, star1.plug_p)
  connect(core.plug_p2, Rot21.plug_n)
  connect(core.plug_p3, Rot21.plug_p)
  connect(core.plug_n3, star2.plug_p)
  connect(l2sigma.plug_p, Rot22.plug_n)
  connect(Rot22.plug_p, core.plug_n2)
end Yz09;


Transformer Yz11.

within Modelica.Electrical.QuasiStatic.Machines.BasicMachines.Transformers.Yz;
model Yz11 "Transformer Yz11"

  extends QuasiStatic.Machines.Interfaces.PartialBasicTransformer(final
      VectorGroup="Yz11");
  QuasiStatic.Polyphase.Basic.Star star1(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint1
  QuasiStatic.Polyphase.Basic.Star star2(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin starpoint2
  QuasiStatic.Polyphase.Basic.Delta Rot21(final m=m)
  QuasiStatic.Polyphase.Basic.Delta Rot22(final m=m)
equation
  connect(star1.pin_n, starpoint1)
  connect(star2.pin_n, starpoint2)
  connect(l1sigma.plug_n, core.plug_p1)
  connect(core.plug_n1, star1.plug_p)
  connect(core.plug_p2, Rot21.plug_p)
  connect(core.plug_p3, Rot21.plug_n)
  connect(l2sigma.plug_p, Rot22.plug_n)
  connect(Rot22.plug_p, core.plug_n2)
  connect(core.plug_n3, star2.plug_p)
end Yz11;


Test examples

within Modelica.Electrical.QuasiStatic.Machines;
package Examples "Test examples"
  extends Modelica.Icons.ExamplesPackage;
end Examples;


Transformer test bench.

within Modelica.Electrical.QuasiStatic.Machines.Examples;
model TransformerTestbench "Transformer test bench"
  extends Modelica.Icons.Example;
  parameter Integer m=3 "Number of phases"
  parameter SI.Resistance RL[m]=fill(1/3, m)
    "Load resistance";
  output SI.Voltage VS=polarVS.len "Grid voltage";
  output SI.Angle phiS=polarVS.phi "Grid phase";
  output SI.Voltage VL=polarVL.len "Load voltage";
  output SI.Angle phiL=polarVL.phi "Load phase";
  QuasiStatic.Polyphase.Sources.VoltageSource source(
    f=50,
    V=fill(100/sqrt(3), 3),
    m=m,
    gamma(fixed=true, start=0))
  QuasiStatic.Polyphase.Basic.Star starS(m=m)
  QuasiStatic.SinglePhase.Basic.Ground groundS
  QuasiStatic.Polyphase.Sensors.PowerSensor electricalPowerSensorS(m=m)
  QuasiStatic.Polyphase.Sensors.CurrentSensor currentSensorS(m=m)
  Modelica.ComplexBlocks.ComplexMath.ComplexToPolar polarIS
  QuasiStatic.Polyphase.Sensors.VoltageSensor voltageSensorS(m=m)
  Modelica.ComplexBlocks.ComplexMath.ComplexToPolar polarVS
  QuasiStatic.Polyphase.Basic.Delta deltaS(m=m)
  QuasiStatic.SinglePhase.Basic.Resistor earth(R_ref=1e6)
  QuasiStatic.SinglePhase.Basic.Ground groundT
  QuasiStatic.Polyphase.Sensors.VoltageSensor voltageSensorL(m=m)
  Modelica.ComplexBlocks.ComplexMath.ComplexToPolar polarVL
  QuasiStatic.Polyphase.Basic.Delta deltaL(m=m)
  QuasiStatic.Polyphase.Sensors.CurrentSensor currentSensorL(m=m)
  Modelica.ComplexBlocks.ComplexMath.ComplexToPolar polarIL
  QuasiStatic.Polyphase.Sensors.PowerSensor electricalPowerSensorL(m=m)
  QuasiStatic.Polyphase.Basic.Resistor load(R_ref=RL, m=m)
  QuasiStatic.Polyphase.Basic.Star starL(m=m)
  QuasiStatic.SinglePhase.Basic.Ground groundL
  Modelica.Electrical.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)
  QuasiStatic.Machines.BasicMachines.Transformers.Yd.Yd01 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)

  Polyphase.Blocks.SymmetricalComponents symmetricalComponentsIS(final m=m)
  Polyphase.Blocks.SymmetricalComponents symmetricalComponentsIL(final m=m)
  Polyphase.Blocks.SymmetricalComponents symmetricalComponentsVS(final m=m)
  Polyphase.Blocks.SymmetricalComponents symmetricalComponentsVL(final m=m)
equation
  connect(starS.pin_n, groundS.pin)
  connect(source.plug_n, starS.plug_p)
  connect(starL.pin_n, groundL.pin)
  connect(load.plug_n, starL.plug_p)
  connect(electricalPowerSensorS.currentP, electricalPowerSensorS.voltageP)
  connect(electricalPowerSensorS.currentN, currentSensorS.plug_p)
  connect(currentSensorS.plug_n, transformer.plug1)
  connect(transformer.plug2, currentSensorL.plug_p)
  connect(currentSensorL.plug_n, electricalPowerSensorL.currentP)
  connect(electricalPowerSensorL.currentP, electricalPowerSensorL.voltageP)
  connect(electricalPowerSensorL.currentN, load.plug_p)
  connect(electricalPowerSensorL.voltageN, starL.plug_p)
  connect(electricalPowerSensorS.voltageN, starS.plug_p)
  connect(earth.pin_n, groundT.pin)
  connect(deltaS.plug_p, voltageSensorS.plug_n)
  connect(deltaS.plug_n, voltageSensorS.plug_p)
  connect(currentSensorS.plug_n, deltaS.plug_n)
  connect(deltaL.plug_p, voltageSensorL.plug_n)
  connect(deltaL.plug_n, voltageSensorL.plug_p)
  connect(currentSensorL.plug_p, deltaL.plug_n)
  connect(symmetricalComponentsIS.u,currentSensorS.i)
  connect(symmetricalComponentsIL.u,currentSensorL.i)
  connect(symmetricalComponentsIS.y[1], polarIS.u)
  connect(symmetricalComponentsIL.y[1], polarIL.u)
  connect(voltageSensorS.v, symmetricalComponentsVS.u)
  connect(symmetricalComponentsVS.y[1], polarVS.u)
  connect(voltageSensorL.v, symmetricalComponentsVL.u)
  connect(symmetricalComponentsVL.y[1], polarVL.u)
  connect(electricalPowerSensorS.currentP, source.plug_p)
end TransformerTestbench;


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


Partial model of three-phase transformer.

within Modelica.Electrical.QuasiStatic.Machines.Interfaces;
partial model PartialBasicTransformer
  "Partial model of three-phase transformer"
  extends Modelica.Electrical.Machines.Icons.QuasiStaticTransformer;
  constant Integer m(min=1) = 3 "Number of phases";
  constant String VectorGroup="Yy00";
  parameter Real n(start=1)
    "Ratio primary voltage (line-to-line) / secondary voltage (line-to-line)";
  parameter SI.Resistance R1(start=5E-3/(if C1 == "D" then 1
         else 3)) "Primary resistance per phase at TRef"
  parameter SI.Temperature T1Ref(start=293.15)
    "Reference temperature of primary resistance"
  parameter
    Modelica.Electrical.Machines.Thermal.LinearTemperatureCoefficient20
    alpha20_1(start=0)
    "Temperature coefficient of primary resistance at 20 degC"
  parameter SI.Inductance L1sigma(start=78E-6/(if C1 == "D"
         then 1 else 3)) "Primary stray inductance per phase"
  parameter SI.Resistance R2(start=5E-3/(if C2 == "d" then 1
         else 3)) "Secondary resistance per phase at TRef"
  parameter SI.Temperature T2Ref(start=293.15)
    "Reference temperature of secondary resistance"
  parameter
    Modelica.Electrical.Machines.Thermal.LinearTemperatureCoefficient20
    alpha20_2(start=0)
    "Temperature coefficient of secondary resistance at 20 degC"
  parameter SI.Inductance L2sigma(start=78E-6/(if C2 == "d"
         then 1 else 3)) "Secondary stray inductance per phase"
  parameter Boolean useThermalPort=false
    "Enable / disable (=fixed temperatures) thermal port"
  parameter SI.Temperature T1Operational(start=293.15)
    "Operational temperature of primary resistance"
  parameter SI.Temperature T2Operational(start=293.15)
    "Operational temperature of secondary resistance"
  output Modelica.Electrical.Machines.Interfaces.PowerBalanceTransformer
    powerBalance(
    final power1=sum({Modelica.ComplexMath.real(v1[j]*
        Modelica.ComplexMath.conj(i1[j])) for j in 1:m}),
    final power2=sum({Modelica.ComplexMath.real(v2[j]*
        Modelica.ComplexMath.conj(-i2[j])) for j in 1:m}),
    final lossPower1=-sum(r1.resistor.LossPower),
    final lossPower2=-sum(r2.resistor.LossPower),
    final lossPowerCore=0) "Power balance";
  output SI.ComplexVoltage v1[m]=plug1.pin.v
    "Primary voltage";
  output SI.ComplexCurrent i1[m]=plug1.pin.i
    "Primary current";
  output SI.ComplexVoltage v2[m]=plug2.pin.v
    "Secondary voltage";
  output SI.ComplexCurrent i2[m]=plug2.pin.i
    "Secondary current";
protected
  constant String C1=Modelica.Utilities.Strings.substring(
          VectorGroup,
          1,
          1);
  constant String C2=Modelica.Utilities.Strings.substring(
          VectorGroup,
          2,
          2);
  parameter Real ni=n*(if C2 == "z" then sqrt(3) else 2)*(if C2 == "d"
       then 1 else sqrt(3))/(if C1 == "D" then 1 else sqrt(3));
public
  QuasiStatic.Polyphase.Interfaces.PositivePlug plug1(final m=m) "Primary plug"
  QuasiStatic.Polyphase.Interfaces.NegativePlug plug2(final m=m)
    "Secondary plug"
  QuasiStatic.Polyphase.Basic.Resistor r1(
    final m=m,
    final R_ref=fill(R1, m),
    final T_ref=fill(T1Ref, m),
    final alpha_ref=fill(Modelica.Electrical.Machines.Thermal.convertAlpha(
        alpha20_1, T1Ref), m),
    final useHeatPort=true,
    final T=fill(T1Ref, m))
  QuasiStatic.Polyphase.Basic.Inductor l1sigma(final m=m, final L=fill(L1sigma,
        m))
  QuasiStatic.Polyphase.Basic.Resistor r2(
    final m=m,
    final R_ref=fill(R2, m),
    final T_ref=fill(T2Ref, m),
    final alpha_ref=fill(Modelica.Electrical.Machines.Thermal.convertAlpha(
        alpha20_2, T2Ref), m),
    final useHeatPort=true,
    final T=fill(T2Ref, m))
  QuasiStatic.Polyphase.Basic.Inductor l2sigma(final m=m, final L=fill(L2sigma,
        m))
  QuasiStatic.Machines.BasicMachines.Components.IdealCore core(
    final m=m,
    final n12=ni,
    final n13=ni)
  Modelica.Electrical.Machines.Interfaces.ThermalPortTransformer
    thermalPort if useThermalPort
  Modelica.Electrical.Machines.Thermal.ThermalAmbientTransformer
    thermalAmbient(
    final useTemperatureInputs=false,
    final T1=T1Operational,
    final T2=T2Operational) if not useThermalPort
protected
  Modelica.Electrical.Machines.Interfaces.ThermalPortTransformer
    internalThermalPort
equation
  connect(r1.plug_n, l1sigma.plug_p)
  connect(l2sigma.plug_n, r2.plug_p)
  connect(plug1, r1.plug_p)
  connect(r2.plug_n, plug2)
  connect(thermalPort, internalThermalPort)
  connect(thermalAmbient.thermalPort, internalThermalPort)
  connect(r1.heatPort, internalThermalPort.heatPort1)
  connect(r2.heatPort, internalThermalPort.heatPort2)
end PartialBasicTransformer;


within Modelica.Electrical.QuasiStatic.Machines;
package SpacePhasors "Space phasor components for quasi-static electric machines"
  extends Modelica.Icons.Package;
end SpacePhasors;


Conversion: space phasor -> three-phase.

within Modelica.Electrical.QuasiStatic.Machines.SpacePhasors.Blocks;
block FromSpacePhasor "Conversion: space phasor -> three-phase"
  extends Modelica.Blocks.Icons.Block;
  import Modelica.ComplexMath.j;
  import Modelica.ComplexMath.exp;
  parameter Integer m(min=1) = 3 "Number of phases"
  Modelica.Blocks.Interfaces.RealInput u[2]
  Modelica.ComplexBlocks.Interfaces.ComplexOutput y[m]
protected
  parameter SI.Angle phi[m]=
      Modelica.Electrical.Polyphase.Functions.symmetricOrientation(m);
equation
  y = {Complex(u[1], u[2])*exp(-j*phi[k])/sqrt(2) for k in 1:m};
end FromSpacePhasor;


Conversion: three-phase -> space phasor.

within Modelica.Electrical.QuasiStatic.Machines.SpacePhasors.Blocks;
block ToSpacePhasor "Conversion: three-phase -> space phasor"
  extends Modelica.Blocks.Icons.Block;
  import Modelica.ComplexMath.j;
  import Modelica.ComplexMath.exp;
  import Modelica.ComplexMath.sum;
  parameter Integer m(min=1) = 3 "Number of phases"
  Modelica.ComplexBlocks.Interfaces.ComplexInput u[m]
  Modelica.Blocks.Interfaces.RealOutput y[2]
protected
  parameter SI.Angle phi[m]=
      Modelica.Electrical.Polyphase.Functions.symmetricOrientation(m);
  Complex c;
equation
  c = sqrt(2)/m*sum({u[k]*exp(j*phi[k]) for k in 1:m});
  y = {c.re,c.im};
end ToSpacePhasor;


Polyphase AC components

within Modelica.Electrical.QuasiStatic;
package Polyphase "Polyphase AC components"
  extends Modelica.Icons.Package;
end Polyphase;


Polyphase linear admittance. The admittance model represents a parallel connection of a resistor and either a capacitor or inductor
in each phase.

within Modelica.Electrical.QuasiStatic.Polyphase.Basic;
model Admittance "Polyphase linear admittance"
  extends Interfaces.TwoPlug;
  parameter SI.ComplexAdmittance Y_ref[m](re(start=fill(1,m)),im(start=fill(0,m)))
    "Complex admittances G_ref + j*B_ref";
  parameter SI.Temperature T_ref[m]=fill(293.15, m)
    "Reference temperatures";
  parameter SI.LinearTemperatureCoefficient alpha_ref[m]=zeros(m)
    "Temperature coefficient of resistance (R_actual = R_ref*(1 + alpha_ref*(heatPort.T - T_ref))";
  extends Modelica.Electrical.Polyphase.Interfaces.ConditionalHeatPort(final mh=m, T=T_ref);
  parameter Boolean frequencyDependent = false "Consider frequency dependency, if true"
  parameter SI.Frequency f_ref = 1 "Reference frequency, if frequency dependency is considered"
  QuasiStatic.SinglePhase.Basic.Admittance admittance[m](
    final Y_ref=Y_ref,
    final T_ref=T_ref,
    final alpha_ref=alpha_ref,
    final useHeatPort=fill(useHeatPort, m),
    final T=T,
    final frequencyDependent=fill(frequencyDependent, m),
    final f_ref=fill(f_ref, m))

equation
  connect(plugToPins_p.pin_p, admittance.pin_p)
  connect(admittance.pin_n, plugToPins_n.pin_n)
  connect(admittance.heatPort, heatPort)
end Admittance;


Polyphase linear capacitor. The linear capacitor connects the complex currents i with the complex
voltages v by v*j*ω*C = i,
using m single-phase Capacitors.

within Modelica.Electrical.QuasiStatic.Polyphase.Basic;
model Capacitor "Polyphase linear capacitor"
  extends Interfaces.TwoPlug;
  parameter SI.Capacitance C[m](start=fill(1, m))
    "Capacitances";
  QuasiStatic.SinglePhase.Basic.Capacitor capacitor[m](final C=C)
equation
  connect(plugToPins_p.pin_p, capacitor.pin_p)
  connect(capacitor.pin_n, plugToPins_n.pin_n)
end Capacitor;


Polyphase linear conductor. The linear resistor connects the complex currents i with the complex
voltages v by v*G = i,
using m single-phase Conductors.

within Modelica.Electrical.QuasiStatic.Polyphase.Basic;
model Conductor "Polyphase linear conductor"
  extends Interfaces.TwoPlug;
  parameter SI.Conductance G_ref[m](start=fill(1, m))
    "Reference conductances at T_ref";
  parameter SI.Temperature T_ref[m]=fill(293.15, m)
    "Reference temperatures";
  parameter SI.LinearTemperatureCoefficient alpha_ref[m]=
      zeros(m)
    "Temperature coefficient of conductance (G_actual = G_ref/(1 + alpha_ref*(heatPort.T - T_ref))";
  extends Modelica.Electrical.Polyphase.Interfaces.ConditionalHeatPort(
      final mh=m, T=T_ref);
  QuasiStatic.SinglePhase.Basic.Conductor conductor[m](
    final G_ref=G_ref,
    final T_ref=T_ref,
    final alpha_ref=alpha_ref,
    each final useHeatPort=useHeatPort,
    final T=T)
equation
  connect(plugToPins_p.pin_p, conductor.pin_p)
  connect(conductor.pin_n, plugToPins_n.pin_n)
  connect(conductor.heatPort, heatPort)
end Conductor;


Delta (polygon) connection. Delta (polygon) connection of a polyphase circuit.

within Modelica.Electrical.QuasiStatic.Polyphase.Basic;
model Delta "Delta (polygon) connection"
  parameter Integer m(final min=2) = 3 "Number of phases"
  Interfaces.PositivePlug plug_p(final m=m)
  Interfaces.NegativePlug plug_n(final m=m)

  PlugToPins_p plugToPins_p(final m=m)
  PlugToPins_n plugToPins_n(final m=m)
equation
  for j in 1:m-1 loop
    connect(plugToPins_n.pin_n[j], plugToPins_p.pin_p[j + 1]);
  end for;
  connect(plugToPins_n.pin_n[m], plugToPins_p.pin_p[1]);
  connect(plug_p, plugToPins_p.plug_p)
  connect(plugToPins_n.plug_n, plug_n)
end Delta;


Polyphase linear impedance. The impedance model represents a series connection of a resistor and either an inductor or capacitor
in each phase.

within Modelica.Electrical.QuasiStatic.Polyphase.Basic;
model Impedance "Polyphase linear impedance"
  extends Interfaces.TwoPlug;
  parameter SI.ComplexImpedance Z_ref[m](re(start=fill(1,m)),im(start=fill(0,m)))
    "Complex impedances R_ref + j*X_ref";
  parameter SI.Temperature T_ref[m]=fill(293.15, m)
    "Reference temperatures";
  parameter SI.LinearTemperatureCoefficient alpha_ref[m]=zeros(m)
    "Temperature coefficient of resistance (R_actual = R_ref*(1 + alpha_ref*(heatPort.T - T_ref))";
  extends Modelica.Electrical.Polyphase.Interfaces.ConditionalHeatPort(final mh=m, T=T_ref);
  parameter Boolean frequencyDependent = false "Consider frequency dependency, if true"
  parameter SI.Frequency f_ref = 1 "Reference frequency, if frequency dependency is considered"
  QuasiStatic.SinglePhase.Basic.Impedance impedance[m](
    final Z_ref=Z_ref,
    final T_ref=T_ref,
    final alpha_ref=alpha_ref,
    final useHeatPort=fill(useHeatPort, m),
    final frequencyDependent=fill(frequencyDependent, m),
    final f_ref=fill(f_ref, m),
    final T=T_ref)
equation

  connect(plugToPins_p.pin_p, impedance.pin_p)
  connect(impedance.pin_n, plugToPins_n.pin_n)
  connect(impedance.heatPort, heatPort)
end Impedance;


Polyphase linear inductor. The linear inductor connects the complex voltages v with the complex
currents i by i*j*ω*L = v,
using m single-phase Inductors.

within Modelica.Electrical.QuasiStatic.Polyphase.Basic;
model Inductor "Polyphase linear inductor"
  extends Interfaces.TwoPlug;
  parameter SI.Inductance L[m](start=fill(1, m))
    "Inductances";
  QuasiStatic.SinglePhase.Basic.Inductor inductor[m](final L=L)
equation

  connect(plugToPins_p.pin_p, inductor.pin_p)
  connect(inductor.pin_n, plugToPins_n.pin_n)
end Inductor;


Delta (polygon) connection of polyphase systems consisting of multiple base systems. Delta (polygon) connection of a polyphase circuit consisting of multiple base systems (see
polyphase guidelines).

within Modelica.Electrical.QuasiStatic.Polyphase.Basic;
model MultiDelta
  "Delta (polygon) connection of polyphase systems consisting of multiple base systems"
  import Modelica.Electrical.Polyphase.Functions.numberOfSymmetricBaseSystems;
  import Modelica.Utilities.Streams.print;
  parameter Integer m(final min=2) = 3 "Number of phases"
  parameter Integer kPolygon=1 "Alternative of polygon";
  final parameter Integer mSystems=numberOfSymmetricBaseSystems(m) "Number of base systems";
  final parameter Integer mBasic=integer(m/mSystems) "Phase number of base systems";
  QuasiStatic.Polyphase.Interfaces.PositivePlug plug_p(final m=m)
  QuasiStatic.Polyphase.Interfaces.NegativePlug plug_n(final m=m)
  QuasiStatic.Polyphase.Basic.PlugToPins_p plugToPins_p(final m=m)
  QuasiStatic.Polyphase.Basic.PlugToPins_n plugToPins_n(final m=m)
protected
  parameter Integer kP=if (mBasic<=2 or kPolygon<1 or kPolygon>integer(mBasic - 1)/2) then 1 else kPolygon;
equation
  when initial() then
    if (mBasic<=2 or kPolygon<1 or kPolygon>integer(mBasic - 1)/2) then
      print("MultiDelta: replaced erroneous kPolygon = "+String(kPolygon)+" by kPolygon = 1");
    end if;
  end when;
  for k in 1:mSystems loop
    for j in 1:(mBasic - kP) loop
      connect(plugToPins_n.pin_n[(k - 1)*mBasic + j], plugToPins_p.pin_p[(k - 1)*mBasic + j + kP]);
    end for;
    for j in (mBasic - kP + 1):mBasic loop
      connect(plugToPins_n.pin_n[(k - 1)*mBasic + j], plugToPins_p.pin_p[(k - 2)*mBasic + j + kP]);
    end for;
  end for;
  connect(plug_p, plugToPins_p.plug_p)
  connect(plugToPins_n.plug_n, plug_n)
end MultiDelta;


Star connection of polyphase systems consisting of multiple base systems. Star (wye) connection of a polyphase circuit consisting of multiple base systems (see
polyphase guidelines). The potentials at the star points are all equal.

within Modelica.Electrical.QuasiStatic.Polyphase.Basic;
model MultiStar
  "Star connection of polyphase systems consisting of multiple base systems"
  import Modelica.Electrical.Polyphase.Functions.numberOfSymmetricBaseSystems;
  parameter Integer m(final min=1) = 3 "Number of phases"
  final parameter Integer mSystems=numberOfSymmetricBaseSystems(m) "Number of base systems";
  final parameter Integer mBasic=integer(m/mSystems) "Phase number of base systems";
  QuasiStatic.Polyphase.Interfaces.PositivePlug plug_p(final m=m)
  QuasiStatic.Polyphase.Interfaces.NegativePlug starpoints(final m=mSystems)
  QuasiStatic.Polyphase.Basic.PlugToPins_p plugToPins_p(final m=m)
  QuasiStatic.Polyphase.Basic.PlugToPins_n plugToPins_n(final m=mSystems)
equation
  for k in 1:mSystems loop
    for j in 1:mBasic loop
      connect(plugToPins_p.pin_p[(k - 1)*mBasic + j], plugToPins_n.pin_n[k]);
    end for;
  end for;
  connect(plug_p, plugToPins_p.plug_p)
  connect(plugToPins_n.plug_n, starpoints)
end MultiStar;


Resistance connection of star points. Multi star points are connected by resistors. This model is required to operate polyphase systems with even phase numbers to avoid ideal connections of start points of base systems; see
polyphase guidelines.

within Modelica.Electrical.QuasiStatic.Polyphase.Basic;
model MultiStarResistance "Resistance connection of star points"
  parameter Integer m(final min=3) = 3 "Number of phases"
  final parameter Integer mBasic=
      Modelica.Electrical.Polyphase.Functions.numberOfSymmetricBaseSystems(
      m) "Number of symmetric base systems";
  parameter SI.Resistance R=1e6
    "Insulation resistance between base systems";
  Interfaces.PositivePlug plug(m=m)
  MultiStar multiStar(m=m)
  Resistor resistor(m=mBasic, final R_ref=fill(R, mBasic))
  Star star(m=mBasic)
  SinglePhase.Interfaces.NegativePin pin
equation
  connect(plug, multiStar.plug_p)
  connect(multiStar.starpoints, resistor.plug_p)
  connect(resistor.plug_n, star.plug_p)
  connect(star.pin_n, pin)
end MultiStarResistance;


Linear mutual inductor. Model of a polyphase inductor providing a mutual inductance matrix model.

within Modelica.Electrical.QuasiStatic.Polyphase.Basic;
model MutualInductor "Linear mutual inductor"
  extends QuasiStatic.Polyphase.Interfaces.OnePort;
  import Modelica.ComplexMath.j;
  parameter Real epsilon=1e-9 "Relative accuracy tolerance of matrix symmetry";
  parameter SI.Inductance L[m, m] "Mutual inductance matrix";
initial equation
  if abs(Modelica.Math.Matrices.det(L)) < epsilon then
    Modelica.Utilities.Streams.print("Warning: mutual inductance matrix singular!");
  end if;
equation
  assert(sum(abs(L - transpose(L))) < epsilon*sum(abs(L)),"Mutual inductance matrix is not symmetric");
  for l in 1:m loop
    v[l] = sum(j*omega*L[l, k]*i[k] for k in 1:m);
  end for;
end MutualInductor;


within Modelica.Electrical.QuasiStatic.Polyphase;
package Basic "Basic components for AC polyphase models"
  extends Modelica.Icons.Package;
end Basic;


Connect all (negative) pins. Connects all m single-phase (negative) pins of the polyphase (negative) plug to an array of m single-phase (negative) pins.

within Modelica.Electrical.QuasiStatic.Polyphase.Basic;
model PlugToPins_n "Connect all (negative) pins"
  parameter Integer m(final min=1) = 3 "Number of phases"
  Interfaces.NegativePlug plug_n(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin pin_n[m]
  PlugToPin_n plugToPin_n[m](each final m=m, final k={j for j in 1:m})
equation
  for j in 1:m loop
    /*
    Connections.branch(plug_n.reference, pin_n[j].reference);
    plug_n.reference.gamma = pin_n[j].reference.gamma;
    plug_n.pin[j].v = pin_n[j].v;
    plug_n.pin[j].i = -pin_n[j].i;
*/
    connect(plug_n, plugToPin_n[j].plug_n);
    connect(plugToPin_n[j].pin_n, pin_n[j]);
  end for;
end PlugToPins_n;


Connect all (positive) pins. Connects all m single-phase (positive) pins of the polyphase (positive) plug to an array of m single-phase (positive) pins.

within Modelica.Electrical.QuasiStatic.Polyphase.Basic;
model PlugToPins_p "Connect all (positive) pins"
  parameter Integer m(final min=1) = 3 "Number of phases"
  Interfaces.PositivePlug plug_p(final m=m)
  QuasiStatic.SinglePhase.Interfaces.PositivePin pin_p[m]
  PlugToPin_p plugToPin_p[m](each final m=m, final k={j for j in 1:m})
equation
  for j in 1:m loop
    /*
    Connections.branch(plug_p.reference, pin_p[j].reference);
    plug_p.reference.gamma = pin_p[j].reference.gamma;
    plug_p.pin[j].v = pin_p[j].v;
    plug_p.pin[j].i = -pin_p[j].i;
*/
    connect(plug_p, plugToPin_p[j].plug_p);
    connect(plugToPin_p[j].pin_p, pin_p[j]);
  end for;
end PlugToPins_p;


Connect one (negative) pin. Connects the single-phase (negative) pin k of the polyphase (negative) plug to a single-phase (negative) pin.

within Modelica.Electrical.QuasiStatic.Polyphase.Basic;
model PlugToPin_n "Connect one (negative) pin"
  parameter Integer m(final min=1) = 3 "Number of phases"
  parameter Integer k(
    final min=1,
    final max=m) = 1 "Phase index"
  Interfaces.NegativePlug plug_n(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin pin_n
equation
  Connections.branch(plug_n.reference, pin_n.reference);
  //Connections.potentialRoot(plug_n.reference);
  //Connections.potentialRoot(pin_n.reference);
  plug_n.reference.gamma = pin_n.reference.gamma;
  pin_n.v = plug_n.pin[k].v;
  for j in 1:m loop
    plug_n.pin[j].i = if j == k then -pin_n.i else Complex(0);
  end for;
end PlugToPin_n;


Connect one (positive) pin. Connects the single-phase (positive) pin k of the polyphase (positive) plug to a single-phase (positive) pin.

within Modelica.Electrical.QuasiStatic.Polyphase.Basic;
model PlugToPin_p "Connect one (positive) pin"
  parameter Integer m(final min=1) = 3 "Number of phases"
  parameter Integer k(
    final min=1,
    final max=m) = 1 "Phase index"
  Interfaces.PositivePlug plug_p(final m=m)
  QuasiStatic.SinglePhase.Interfaces.PositivePin pin_p
equation
  Connections.branch(plug_p.reference, pin_p.reference);
  //Connections.potentialRoot(plug_p.reference);
  //Connections.potentialRoot(pin_p.reference);
  plug_p.reference.gamma = pin_p.reference.gamma;
  pin_p.v = plug_p.pin[k].v;
  for j in 1:m loop
    plug_p.pin[j].i = if j == k then -pin_p.i else Complex(0);
  end for;
end PlugToPin_p;


Polyphase linear resistor. The linear resistor connects the complex voltages v with the complex
currents i by i*R = v,
using m single-phase Resistors.

within Modelica.Electrical.QuasiStatic.Polyphase.Basic;
model Resistor "Polyphase linear resistor"
  extends Interfaces.TwoPlug;
  parameter SI.Resistance R_ref[m](start=fill(1, m))
    "Reference resistances at T_ref";
  parameter SI.Temperature T_ref[m]=fill(293.15, m)
    "Reference temperatures";
  parameter SI.LinearTemperatureCoefficient alpha_ref[m]=
      zeros(m)
    "Temperature coefficient of resistance (R_actual = R_ref*(1 + alpha_ref*(heatPort.T - T_ref))";
  extends Modelica.Electrical.Polyphase.Interfaces.ConditionalHeatPort(
      final mh=m, T=T_ref);
  QuasiStatic.SinglePhase.Basic.Resistor resistor[m](
    final R_ref=R_ref,
    final T_ref=T_ref,
    final alpha_ref=alpha_ref,
    each final useHeatPort=useHeatPort,
    final T=T)
equation
  connect(plugToPins_p.pin_p, resistor.pin_p)
  connect(resistor.pin_n, plugToPins_n.pin_n)
  connect(resistor.heatPort, heatPort)
end Resistor;


Star connection. Star (wye) connection of a polyphase circuit. The potentials at the star points are the same.

within Modelica.Electrical.QuasiStatic.Polyphase.Basic;
model Star "Star connection"
  parameter Integer m(final min=1) = 3 "Number of phases"
  Interfaces.PositivePlug plug_p(final m=m)
  QuasiStatic.SinglePhase.Interfaces.NegativePin pin_n
  PlugToPins_p plugToPins_p(final m=m)
equation
  for j in 1:m loop
    connect(plugToPins_p.pin_p[j], pin_n);
  end for;
  connect(plug_p, plugToPins_p.plug_p)
end Star;