Test example with polyphase components. Test example with polyphase components:

Star-connected voltage source feeds via a line reactor a diode bridge rectifier with a DC burden.

Using f=50 Hz, simulate for 0.1 second and compare voltages and currents of source and DC burden, neglecting initial transient.

We may also compare: Active power measured by powerSensor, powerSensorSpacePhasor and aronSensor,
as well as reactive power measured by powerSensorSpacePhasor and reactivePowerSensor.

within Modelica.Electrical.Polyphase.Examples;
model Rectifier "Test example with polyphase components"
  extends Modelica.Icons.Example;
  import Modelica.Electrical.Polyphase.Functions.factorY2DC;
  final parameter Integer m=3 "Number of phases"
  parameter SI.Voltage V=100 "RMS of Star-Voltage";
  parameter SI.Frequency f=50 "Frequency";
  parameter SI.Inductance L=0.0001 "Line Inductance";
  parameter SI.Resistance RL=2 "Load Resistance";
  parameter SI.Capacitance C=0.005 "Total DC-Capacitance";
  parameter SI.Resistance RE=1E6 "Earthing Resistance";
  parameter SI.Resistance Ron=1e-5 "Closed diode resistance";
  parameter SI.Conductance Goff=1e-5
    "Opened diode conductance";
  parameter SI.Voltage Vknee=0 "Threshold diode voltage";
  final parameter SI.Voltage VDC=factorY2DC(m)*V "Estimated average DC voltage";
  final parameter SI.Current IDC=VDC/RL "Estimated average DC current";
  Sources.SineVoltage sineVoltage(
    m=m,
    f=fill(f, m),
    V=sqrt(2)*fill(V, m))
  Basic.Star starS(m=m)
  Basic.Inductor supplyL(m=m, L=fill(L, m))
  Ideal.IdealDiode idealDiode1(
    m=m,
    Ron=fill(Ron, m),
    Goff=fill(Goff, m),
    Vknee=fill(Vknee, m))
  Basic.Star star1(m=m)
  Ideal.IdealDiode idealDiode2(
    m=m,
    Ron=fill(Ron, m),
    Goff=fill(Goff, m),
    Vknee=fill(Vknee, m))
  Basic.Star star2(m=m)
  Modelica.Electrical.Analog.Basic.Resistor loadR(R=RL)
  Modelica.Electrical.Analog.Basic.Capacitor cDC1(C=2*C)
  Modelica.Electrical.Analog.Basic.Capacitor cDC2(C=2*C)
  Modelica.Electrical.Analog.Basic.Ground groundDC
  Modelica.Electrical.Machines.Sensors.ElectricalPowerSensor powerSensorSpacePhasor
  Sensors.AronSensor aronSensor
  Sensors.PowerSensor powerSensor(m=m)
  Sensors.ReactivePowerSensor reactivePowerSensor
initial equation
  cDC1.v = VDC/2;
  cDC2.v = VDC/2;
//supplyL.i[1:m - 1] = zeros(m - 1) "Y-connection";
  supplyL.i[2]=-IDC;
  supplyL.i[3]= IDC;
equation
  connect(cDC1.n, cDC2.p)
  connect(cDC1.n, groundDC.p)
  connect(starS.plug_p, sineVoltage.plug_n)
  connect(sineVoltage.plug_p, supplyL.plug_p)
  connect(idealDiode1.plug_n, star1.plug_p)
  connect(idealDiode2.plug_p, star2.plug_p)
  connect(star2.pin_n, loadR.n)
  connect(star2.pin_n, cDC2.n)
  connect(star1.pin_n, loadR.p)
  connect(star1.pin_n, cDC1.p)
  connect(idealDiode1.plug_p, idealDiode2.plug_n)
  connect(supplyL.plug_n, powerSensor.pc)
  connect(powerSensor.nc, powerSensorSpacePhasor.plug_p)
  connect(powerSensorSpacePhasor.plug_ni, aronSensor.plug_p)
  connect(aronSensor.plug_n, reactivePowerSensor.plug_p)
  connect(idealDiode1.plug_p, reactivePowerSensor.plug_n)
  connect(powerSensor.pc, powerSensor.pv)
  connect(starS.plug_p, powerSensor.nv)
  connect(starS.plug_p, powerSensorSpacePhasor.plug_nv)
end Rectifier;


Number of phases. Test polyphase quasiRMS and power sensors: A sinusoidal source feeds a load consisting of resistor and inductor.

within Modelica.Electrical.Polyphase.Examples;
model TestSensors
  extends Modelica.Icons.Example;
  constant Integer m=3 "Number of phases";
  import Modelica.Constants.pi;
  parameter SI.Voltage VRMS=100
    "Nominal RMS voltage per phase";
  parameter SI.Frequency f=50 "Frequency";
  parameter SI.Resistance R=1/sqrt(2) "Load resistance";
  parameter SI.Inductance L=1/sqrt(2)/(2*pi*f) "Load inductance";
  final parameter SI.Impedance Z=sqrt(R^2 + (2*pi*f*L)^2) "Load impedance";
  final parameter SI.Current IRMS=VRMS/Z "Steady state RMS current";
  final parameter SI.ActivePower P=3*R*IRMS^2 "Total active power";
  final parameter SI.ReactivePower Q=3*(2*pi*f*L)*IRMS^2 "Total reactive power";
  final parameter SI.ApparentPower S=3*Z*IRMS^2 "Total apparent power";
  Modelica.Electrical.Polyphase.Sources.SineVoltage sineVoltage(
    final m=m,
    V=fill(sqrt(2)*VRMS, m),
    f=fill(f, m))
  Modelica.Electrical.Polyphase.Basic.Star star(final m=m)
  Modelica.Electrical.Analog.Basic.Ground ground
  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 starLoad(m=m)
  Modelica.Electrical.Polyphase.Sensors.CurrentQuasiRMSSensor
    currentQuasiRMSSensor(m=m)
  Modelica.Blocks.Math.Feedback feedbackI
  Modelica.Blocks.Sources.Constant constI(k=IRMS)

  Sensors.VoltageQuasiRMSSensor voltageQuasiRMSSensor(m=m)
  Modelica.Blocks.Math.Feedback feedbackV
  Modelica.Blocks.Sources.Constant constV(k=VRMS)
  Sensors.PowerSensor powerSensor(m=m)
  Modelica.Blocks.Math.Feedback feedbackP
  Modelica.Blocks.Sources.RealExpression realExpression(y=
        Modelica.Electrical.Polyphase.Functions.activePower(
        voltageQuasiRMSSensor.v, currentQuasiRMSSensor.i))
  Modelica.Electrical.Machines.Sensors.ElectricalPowerSensor powerSensorSpacePhasor
  Modelica.Blocks.Math.Feedback feedbackSpacePhasor
  Sensors.AronSensor aronSensor
  Modelica.Blocks.Math.Feedback feedbackAron
  Sensors.ReactivePowerSensor reactivePowerSensor
  Modelica.Blocks.Math.Feedback feedbackQ
initial equation
  for k in 1:m - 1 loop
    inductor.i[k] = 0;
  end for;

equation
  connect(star.pin_n, ground.p)

  connect(resistor.plug_n, inductor.plug_p)
  connect(inductor.plug_n, starLoad.plug_p)
  connect(voltageQuasiRMSSensor.plug_n, sineVoltage.plug_n)
  connect(voltageQuasiRMSSensor.plug_p, sineVoltage.plug_p)
  connect(feedbackV.u1, voltageQuasiRMSSensor.V)
  connect(constV.y, feedbackV.u2)
  connect(powerSensor.nc, resistor.plug_p)
  connect(powerSensor.pc, powerSensor.pv)
  connect(powerSensor.nv, starLoad.plug_p)
  connect(powerSensor.power, feedbackP.u1)
  connect(aronSensor.plug_n, powerSensor.pc)
  connect(sineVoltage.plug_n, star.plug_p)
  connect(feedbackI.u2, constI.y)
  connect(feedbackI.u1, currentQuasiRMSSensor.I)
  connect(currentQuasiRMSSensor.plug_p, sineVoltage.plug_p)
  connect(feedbackP.u2, realExpression.y)
  connect(powerSensorSpacePhasor.plug_p, currentQuasiRMSSensor.plug_n)
  connect(powerSensorSpacePhasor.plug_nv, starLoad.plug_p)
  connect(powerSensorSpacePhasor.plug_ni, reactivePowerSensor.plug_p)
  connect(reactivePowerSensor.plug_n, aronSensor.plug_p)
  connect(reactivePowerSensor.reactivePower, feedbackQ.u1)
  connect(powerSensorSpacePhasor.Q, feedbackQ.u2)
  connect(aronSensor.power, feedbackAron.u1)
  connect(feedbackSpacePhasor.u1, powerSensorSpacePhasor.P)
  connect(realExpression.y, feedbackAron.u2)
  connect(realExpression.y, feedbackSpacePhasor.u2)
end TestSensors;


Test example with polyphase components. Test example with polyphase components:

Star-connected voltage source feeds via a Y-D-transformer with internal impedance (RT, LT) a load resistor RT.

Using f=5 Hz LT=3mH defines nominal voltage drop of approximately 10 %.

Simulate for 1 second (2 periods) and compare voltages and currents of source, transformer and load.

within Modelica.Electrical.Polyphase.Examples;
model TransformerYD "Test example with polyphase components"
  extends Modelica.Icons.Example;
  parameter Integer m=3 "Number of phases"
  parameter SI.Voltage V=1 "Amplitude of Star-Voltage";
  parameter SI.Frequency f=5 "Frequency";
  parameter SI.Inductance Lm=1 "Transformer main inductance";
  parameter SI.Inductance LT=0.003
    "Transformer stray inductance";
  parameter SI.Resistance RT=0.05 "Transformer resistance";
  parameter SI.Resistance RL=1 "Load Resistance";
  parameter Real nT=1/sqrt((1 - Modelica.Math.cos(2*Modelica.Constants.pi/m))
      ^2 + (Modelica.Math.sin(2*Modelica.Constants.pi/m))^2)
    "Transformer ratio";
  Sources.SineVoltage sineVoltage(
    V=fill(V, m),
    f=fill(f, m),
    m=m)
  Basic.Star starS(m=m)
  Modelica.Electrical.Analog.Basic.Ground groundS
  Ideal.IdealTransformer idealTransformer(
    m=m,
    n=fill(nT, m),
    Lm1=fill(Lm, m))
  Basic.Star starT(m=m)
  Basic.Delta deltaT2(m=m)
  Modelica.Electrical.Analog.Basic.Ground groundT
  Basic.Resistor transformerR(m=m, R=fill(RT/nT^2, m))
  Basic.Inductor transformerL(m=m, L=fill(LT/nT^2, m))
  Basic.Resistor loadR(m=m, R=fill(RL, m))
  Basic.Star starL(m=m)
  Modelica.Electrical.Analog.Basic.Ground groundL
initial equation
  transformerL.i[1:m] = zeros(m) "D-connection";

equation
  connect(groundS.p, starS.pin_n)
  connect(groundT.p, starT.pin_n)
  connect(starS.plug_p, sineVoltage.plug_n)
  connect(sineVoltage.plug_p, idealTransformer.plug_p1)
  connect(idealTransformer.plug_n1, starT.plug_p)
  connect(idealTransformer.plug_p2, transformerR.plug_p)
  connect(transformerR.plug_n, transformerL.plug_p)
  connect(transformerL.plug_n, deltaT2.plug_p)
  connect(deltaT2.plug_n, idealTransformer.plug_n2)
  connect(deltaT2.plug_p, loadR.plug_p)
  connect(loadR.plug_n, starL.plug_p)
  connect(starL.pin_n, groundL.p)
end TransformerYD;


Test example with polyphase components. Test example with polyphase components:

Star-connected voltage source feeds via a Y-Y-transformer with internal impedance (RT, LT) a load resistor RT.

Using f=5 Hz LT=3mH defines nominal voltage drop of approximately 10 %.

Simulate for 1 second (2 periods) and compare voltages and currents of source, transformer and load.

within Modelica.Electrical.Polyphase.Examples;
model TransformerYY "Test example with polyphase components"
  extends Modelica.Icons.Example;
  parameter Integer m=3 "Number of phases"
  parameter SI.Voltage V=1 "Amplitude of Star-Voltage";
  parameter SI.Frequency f=5 "Frequency";
  parameter SI.Inductance Lm=1 "Transformer main inductance";
  parameter SI.Inductance LT=0.003
    "Transformer stray inductance";
  parameter SI.Resistance RT=0.05 "Transformer resistance";
  parameter SI.Resistance RL=1 "Load Resistance";
  parameter Real nT=1 "Transformer ratio";
  Sources.SineVoltage sineVoltage(
    V=fill(V, m),
    f=fill(f, m),
    m=m)
  Basic.Star starS(m=m)
  Modelica.Electrical.Analog.Basic.Ground groundS
  Ideal.IdealTransformer idealTransformer(
    m=m,
    Lm1=fill(Lm, m),
    n=fill(nT, m))
  Basic.Star starT1(m=m)
  Basic.Star starT2(m=m)
  Modelica.Electrical.Analog.Basic.Ground groundT2
  Basic.Resistor transformerR(m=m, R=fill(RT, m))
  Basic.Inductor transformerL(m=m, L=fill(LT, m))
  Basic.Resistor loadR(m=m, R=fill(RL, m))
  Basic.Star starL(m=m)
  Modelica.Electrical.Analog.Basic.Ground groundT1
initial equation
  transformerL.i[1:m - 1] = zeros(m - 1) "Y-connection";

equation
  connect(starS.pin_n, groundS.p)
  connect(starT1.pin_n, groundT1.p)
  connect(starT2.pin_n, groundT2.p)
  connect(starS.plug_p, sineVoltage.plug_n)
  connect(sineVoltage.plug_p, idealTransformer.plug_p1)
  connect(idealTransformer.plug_n1, starT1.plug_p)
  connect(starT2.plug_p, idealTransformer.plug_n2)
  connect(idealTransformer.plug_p2, transformerR.plug_p)
  connect(transformerR.plug_n, transformerL.plug_p)
  connect(transformerL.plug_n, loadR.plug_p)
  connect(loadR.plug_n, starL.plug_p)
end TransformerYY;


Analyze AC voltage, current and power. Provides mean of total power over one period as well as the following values for each phase:

within Modelica.Electrical.Polyphase.Examples.Utilities;
model AnalysatorAC "Analyze AC voltage, current and power"
  extends Icons.RoundSensor;
  extends Modelica.Electrical.Polyphase.Interfaces.TwoPlug;
  import Modelica.Electrical.Polyphase.Functions.numberOfSymmetricBaseSystems;
  parameter SI.Frequency f=50 "Mains frequency";
  final parameter Integer mSystems=numberOfSymmetricBaseSystems(m)
    "Number of base systems";
  final parameter Integer mBasic=integer(m/mSystems)
    "Phase number of base systems";
  final parameter Integer kPolygon=if m==2 then 1 else integer((mBasic - 1)/2)
    "Alternative of largest polygon voltage";
  Interfaces.NegativePlug plug_nv(final m=m)
    "Negative polyphase electrical plug with m pins"
  Modelica.Blocks.Interfaces.RealOutput pTotal(unit="W") "Total power, mean"
  Modelica.Blocks.Interfaces.RealOutput iFeed[m](each unit="A")
    "RMS feed currents, first harmonic"
  Modelica.Blocks.Interfaces.RealOutput vLL1[m](each unit="V")
    "RMS voltages line-to-line, first harmonic"
  Modelica.Blocks.Interfaces.RealOutput vLN[m](each unit="V")
    "RMS voltages line-to-neutral, first harmonic"
  Sensors.MultiSensor multiSensorAC(m=m)
  Basic.MultiDelta multiDelta(m=m, kPolygon=kPolygon)
  Sensors.VoltageSensor voltageSensor(m=m)
  Modelica.Blocks.Math.Harmonic iH1[m](each f=f, each k=1)
  Modelica.Blocks.Math.Harmonic vH1[m](each f=f, each k=1)
  Modelica.Blocks.Math.Mean powerTotal(f=f)
  Modelica.Blocks.Math.Harmonic voltageLine2Line[m](each f=f, each k=1)
    "Line-to-line voltage"
equation
  connect(plug_p, multiSensorAC.pc)
  connect(multiSensorAC.pc, multiSensorAC.pv)
  connect(multiSensorAC.nc, plug_n)
  connect(multiSensorAC.nv, plug_nv)
  connect(multiDelta.plug_p, voltageSensor.plug_p)
  connect(multiDelta.plug_n, voltageSensor.plug_n)
  connect(plug_p, multiDelta.plug_p)
  connect(voltageLine2Line.y_rms, vLL1)
  connect(voltageSensor.v, voltageLine2Line.u)
  connect(multiSensorAC.powerTotal,powerTotal.u)
  connect(powerTotal.y, pTotal)
  connect(multiSensorAC.i, iH1.u)
  connect(iH1.y_rms, iFeed)
  connect(vH1.y_rms, vLN)
  connect(multiSensorAC.v, vH1.u)
end AnalysatorAC;


Analyze DC voltage, current and power. Provides mean values over one period:

within Modelica.Electrical.Polyphase.Examples.Utilities;
model AnalysatorDC "Analyze DC voltage, current and power"
  extends Icons.RoundSensor;
  extends Modelica.Electrical.Analog.Interfaces.TwoPin;
  import Modelica.Electrical.Polyphase.Functions.numberOfSymmetricBaseSystems;
  parameter SI.Frequency f=50 "Mains frequency";
  Analog.Interfaces.NegativePin nv "Negative electrical pin"
  Modelica.Blocks.Interfaces.RealOutput pDC(unit="W") "Mean power"
  Modelica.Blocks.Interfaces.RealOutput iMean(unit="A") "Mean current"
  Modelica.Blocks.Interfaces.RealOutput vMean(unit="V") "Mean voltage"
  Analog.Sensors.MultiSensor multiSensorDC
  Modelica.Blocks.Math.Mean powerTotal(f=f)
  Modelica.Blocks.Math.Mean meanCurrent(f=f)
  Modelica.Blocks.Math.Mean meanVoltage(f=f)
equation
  connect(multiSensorDC.pc,multiSensorDC. pv)
  connect(multiSensorDC.nv, nv)
  connect(powerTotal.y, pDC)
  connect(multiSensorDC.power, powerTotal.u)
  connect(meanCurrent.y, iMean)
  connect(multiSensorDC.i, meanCurrent.u)
  connect(multiSensorDC.v, meanVoltage.u)
  connect(meanVoltage.y, vMean)
  connect(multiSensorDC.pc, p)
  connect(multiSensorDC.nc, n)
end AnalysatorDC;


Utilities for Examples

within Modelica.Electrical.Polyphase.Examples;
package Utilities "Utilities for Examples"
  extends Icons.UtilitiesPackage;

end Utilities;


Functions for polyphase systems

within Modelica.Electrical.Polyphase;
package Functions "Functions for polyphase systems"
  extends Modelica.Icons.FunctionsPackage;
end Functions;


Polyphase closer with arc. Contains m closing switches with arc (Modelica.Electrical.Analog.Ideal.CloserWithArc).

within Modelica.Electrical.Polyphase.Ideal;
model CloserWithArc "Polyphase closer with arc"
  extends Interfaces.TwoPlug;
  parameter SI.Resistance Ron[m](final min=zeros(m), start=
        fill(1e-5, m)) "Closed switch resistance";
  parameter SI.Conductance Goff[m](final min=zeros(m), start=
        fill(1e-5, m)) "Opened switch conductance";
  parameter SI.Voltage V0[m](start=fill(30, m))
    "Initial arc voltage";
  parameter SI.VoltageSlope dVdt[m](start=fill(10E3, m))
    "Arc voltage slope";
  parameter SI.Voltage Vmax[m](start=fill(60, m))
    "Max. arc voltage";
  extends Polyphase.Interfaces.ConditionalHeatPort(final mh=m, final T=fill(
        293.15, m));
  Modelica.Blocks.Interfaces.BooleanInput control[m]
    "true => switch open, false => p--n connected"
  Modelica.Electrical.Analog.Ideal.CloserWithArc closerWithArc[m](
    final Ron=Ron,
    final Goff=Goff,
    final V0=V0,
    final dVdt=dVdt,
    final Vmax=Vmax,
    each final useHeatPort=useHeatPort)
equation
  connect(plug_p.pin, closerWithArc.p)
  connect(closerWithArc.n, plug_n.pin)
  connect(control, closerWithArc.control)
  connect(closerWithArc.heatPort, heatPort)
end CloserWithArc;


Polyphase ideal closer. Contains m ideal closing switches (Modelica.Electrical.Analog.Ideal.IdealClosingSwitch).

within Modelica.Electrical.Polyphase.Ideal;
model IdealClosingSwitch "Polyphase ideal closer"
  extends Interfaces.TwoPlug;
  parameter SI.Resistance Ron[m](final min=zeros(m), start=
        fill(1e-5, m)) "Closed switch resistance";
  parameter SI.Conductance Goff[m](final min=zeros(m), start=
        fill(1e-5, m)) "Opened switch conductance";
  extends Polyphase.Interfaces.ConditionalHeatPort(final mh=m, final T=fill(
        293.15, m));
  Modelica.Blocks.Interfaces.BooleanInput control[m]
    "true => p--n connected, false => switch open"
  Modelica.Electrical.Analog.Ideal.IdealClosingSwitch idealClosingSwitch[m](
    final Ron=Ron,
    final Goff=Goff,
    each final useHeatPort=useHeatPort)
equation
  connect(plug_p.pin, idealClosingSwitch.p)
  connect(idealClosingSwitch.n, plug_n.pin)
  connect(control, idealClosingSwitch.control)
  connect(idealClosingSwitch.heatPort, heatPort)
end IdealClosingSwitch;


Polyphase ideal commuting switch.

within Modelica.Electrical.Polyphase.Ideal;
model IdealCommutingSwitch "Polyphase ideal commuting switch"
  parameter Integer m(final min=1) = 3 "Number of phases"
  parameter SI.Resistance Ron[m](final min=zeros(m), start=
        fill(1e-5, m)) "Closed switch resistance";
  parameter SI.Conductance Goff[m](final min=zeros(m), start=
        fill(1e-5, m)) "Opened switch conductance";
  extends Polyphase.Interfaces.ConditionalHeatPort(final mh=m, final T=fill(
        293.15, m));
  Modelica.Blocks.Interfaces.BooleanInput control[m]
    "true => p--n2 connected, false => p--n1 connected"
  Interfaces.PositivePlug plug_p(final m=m)
  Interfaces.NegativePlug plug_n2(final m=m)
  Interfaces.NegativePlug plug_n1(final m=m)
  Modelica.Electrical.Analog.Ideal.IdealTwoWaySwitch idealCommutingSwitch[m](
    final Ron=Ron,
    final Goff=Goff,
    each final useHeatPort=useHeatPort)
equation
  connect(plug_p.pin, idealCommutingSwitch.p)
  connect(idealCommutingSwitch.n2, plug_n2.pin)
  connect(idealCommutingSwitch.n1, plug_n1.pin)
  connect(control, idealCommutingSwitch.control)
  connect(idealCommutingSwitch.heatPort, heatPort)
end IdealCommutingSwitch;


Polyphase ideal diode. Contains m ideal diodes (Modelica.Electrical.Analog.Ideal.IdealDiode).

within Modelica.Electrical.Polyphase.Ideal;
model IdealDiode "Polyphase ideal diode"
  extends Interfaces.TwoPlug;
  parameter SI.Resistance Ron[m](final min=zeros(m), start=
        fill(1e-5, m)) "Closed diode resistance";
  parameter SI.Conductance Goff[m](final min=zeros(m), start=
        fill(1e-5, m)) "Opened diode conductance";
  parameter SI.Voltage Vknee[m](final min=zeros(m), start=
        zeros(m)) "Threshold voltage";
  extends Polyphase.Interfaces.ConditionalHeatPort(final mh=m, final T=fill(
        293.15, m));
  Modelica.Electrical.Analog.Ideal.IdealDiode idealDiode[m](
    final Ron=Ron,
    final Goff=Goff,
    final Vknee=Vknee,
    each final useHeatPort=useHeatPort)
equation
  connect(plug_p.pin, idealDiode.p)
  connect(idealDiode.n, plug_n.pin)
  connect(idealDiode.heatPort, heatPort)
end IdealDiode;


Polyphase ideal GTO thyristor. Contains m ideal GTO thyristors (Modelica.Electrical.Analog.Ideal.IdealGTOThyristor).

within Modelica.Electrical.Polyphase.Ideal;
model IdealGTOThyristor "Polyphase ideal GTO thyristor"
  extends Interfaces.TwoPlug;
  parameter SI.Resistance Ron[m](final min=zeros(m), start=
        fill(1e-5, m)) "Closed thyristor resistance";
  parameter SI.Conductance Goff[m](final min=zeros(m), start=
        fill(1e-5, m)) "Opened thyristor conductance";
  parameter SI.Voltage Vknee[m](final min=zeros(m), start=
        zeros(m)) "Threshold voltage";
  extends Polyphase.Interfaces.ConditionalHeatPort(final mh=m, final T=fill(
        293.15, m));
  Modelica.Blocks.Interfaces.BooleanInput fire[m]
  Modelica.Electrical.Analog.Ideal.IdealGTOThyristor idealGTOThyristor[m](
    final Ron=Ron,
    final Goff=Goff,
    final Vknee=Vknee,
    each final useHeatPort=useHeatPort)
equation
  connect(idealGTOThyristor.p, plug_p.pin)
  connect(idealGTOThyristor.n, plug_n.pin)
  connect(fire, idealGTOThyristor.fire)
  connect(idealGTOThyristor.heatPort, heatPort)
end IdealGTOThyristor;


Polyphase ideal intermediate switch.

within Modelica.Electrical.Polyphase.Ideal;
model IdealIntermediateSwitch "Polyphase ideal intermediate switch"
  parameter Integer m(final min=1) = 3 "Number of phases"
  parameter SI.Resistance Ron[m](final min=zeros(m), start=
        fill(1e-5, m)) "Closed switch resistance";
  parameter SI.Conductance Goff[m](final min=zeros(m), start=
        fill(1e-5, m)) "Opened switch conductance";
  extends Polyphase.Interfaces.ConditionalHeatPort(final mh=m, final T=fill(
        293.15, m));
  Modelica.Blocks.Interfaces.BooleanInput control[m]
    "true => p1--n2, p2--n1 connected, otherwise p1--n1, p2--n2 connected"
  Interfaces.PositivePlug plug_p1(final m=m)
  Interfaces.PositivePlug plug_p2(final m=m)
  Interfaces.NegativePlug plug_n2(final m=m)
  Interfaces.NegativePlug plug_n1(final m=m)
  Modelica.Electrical.Analog.Ideal.IdealIntermediateSwitch idealIntermediateSwitch[m](
    final Ron=Ron,
    final Goff=Goff,
    each final useHeatPort=useHeatPort)
equation
  connect(plug_p2.pin, idealIntermediateSwitch.p2)
  connect(idealIntermediateSwitch.n2, plug_n2.pin)
  connect(idealIntermediateSwitch.p1, plug_p1.pin)
  connect(idealIntermediateSwitch.n1, plug_n1.pin)
  connect(control, idealIntermediateSwitch.control)
  connect(idealIntermediateSwitch.heatPort, heatPort)
end IdealIntermediateSwitch;


Polyphase ideal opener. Contains m ideal opening switches (Modelica.Electrical.Analog.Ideal.IdealOpeningSwitch).

within Modelica.Electrical.Polyphase.Ideal;
model IdealOpeningSwitch "Polyphase ideal opener"
  extends Interfaces.TwoPlug;
  parameter SI.Resistance Ron[m](final min=zeros(m), start=
        fill(1e-5, m)) "Closed switch resistance";
  parameter SI.Conductance Goff[m](final min=zeros(m), start=
        fill(1e-5, m)) "Opened switch conductance";
  extends Polyphase.Interfaces.ConditionalHeatPort(final mh=m, final T=fill(
        293.15, m));
  Modelica.Blocks.Interfaces.BooleanInput control[m]
    "true => switch open, false => p--n connected"
  Modelica.Electrical.Analog.Ideal.IdealOpeningSwitch idealOpeningSwitch[m](
    final Ron=Ron,
    final Goff=Goff,
    each final useHeatPort=useHeatPort)
equation
  connect(plug_p.pin, idealOpeningSwitch.p)
  connect(idealOpeningSwitch.n, plug_n.pin)
  connect(control, idealOpeningSwitch.control)
  connect(idealOpeningSwitch.heatPort, heatPort)
end IdealOpeningSwitch;


Polyphase ideal thyristor. Contains m ideal thyristors (Modelica.Electrical.Analog.Ideal.IdealThyristor).

within Modelica.Electrical.Polyphase.Ideal;
model IdealThyristor "Polyphase ideal thyristor"
  extends Interfaces.TwoPlug;
  parameter SI.Resistance Ron[m](final min=zeros(m), start=
        fill(1e-5, m)) "Closed thyristor resistance";
  parameter SI.Conductance Goff[m](final min=zeros(m), start=
        fill(1e-5, m)) "Opened thyristor conductance";
  parameter SI.Voltage Vknee[m](final min=zeros(m), start=
        zeros(m)) "Threshold voltage";
  Boolean off[m] = idealThyristor.off "Alias of boolean thyristor off";
  extends Polyphase.Interfaces.ConditionalHeatPort(final mh=m, final T=fill(
        293.15, m));
  Modelica.Blocks.Interfaces.BooleanInput fire[m]
  Modelica.Electrical.Analog.Ideal.IdealThyristor idealThyristor[m](
    final Ron=Ron,
    final Goff=Goff,
    final Vknee=Vknee,
    each final useHeatPort=useHeatPort)
equation
  connect(plug_p.pin, idealThyristor.p)
  connect(idealThyristor.n, plug_n.pin)
  connect(fire, idealThyristor.fire)
  connect(idealThyristor.heatPort, heatPort)
end IdealThyristor;


Polyphase ideal transformer. Contains m ideal transformers (Modelica.Electrical.Analog.Ideal.IdealTransformer).

within Modelica.Electrical.Polyphase.Ideal;
model IdealTransformer "Polyphase ideal transformer"
  extends Interfaces.FourPlug;
  parameter Real n[m](start=fill(1, m)) "Turns ratio primary:secondary voltage";
  parameter Boolean considerMagnetization=false
    "Choice of considering magnetization";
  parameter SI.Inductance Lm1[m](start=fill(1, m))
    "Magnetization inductances w.r.t. primary side";
  Modelica.Electrical.Analog.Ideal.IdealTransformer idealTransformer[m](
    final n=n,
    each final considerMagnetization=considerMagnetization,
    final Lm1=Lm1)
equation
  connect(plug_p1.pin, idealTransformer.p1)
  connect(plug_p2.pin, idealTransformer.p2)
  connect(plug_n1.pin, idealTransformer.n1)
  connect(plug_n2.pin, idealTransformer.n2)
end IdealTransformer;


Polyphase idle branch.

within Modelica.Electrical.Polyphase.Ideal;
model Idle "Polyphase idle branch"
  extends Interfaces.TwoPlug;
  Modelica.Electrical.Analog.Ideal.Idle idle[m]
equation

  connect(plug_p.pin, idle.p)
  connect(idle.n, plug_n.pin)
end Idle;


Polyphase opener with arc. Contains m opening switches with arc (Modelica.Electrical.Analog.Ideal.OpenerWithArc).

within Modelica.Electrical.Polyphase.Ideal;
model OpenerWithArc "Polyphase opener with arc"
  extends Interfaces.TwoPlug;
  parameter SI.Resistance Ron[m](final min=zeros(m), start=
        fill(1e-5, m)) "Closed switch resistance";
  parameter SI.Conductance Goff[m](final min=zeros(m), start=
        fill(1e-5, m)) "Opened switch conductance";
  parameter SI.Voltage V0[m](start=fill(30, m))
    "Initial arc voltage";
  parameter SI.VoltageSlope dVdt[m](start=fill(10E3, m))
    "Arc voltage slope";
  parameter SI.Voltage Vmax[m](start=fill(60, m))
    "Max. arc voltage";
  extends Polyphase.Interfaces.ConditionalHeatPort(final mh=m, final T=fill(
        293.15, m));
  Modelica.Blocks.Interfaces.BooleanInput control[m]
    "true => switch open, false => p--n connected"
  Modelica.Electrical.Analog.Ideal.OpenerWithArc openerWithArc[m](
    final Ron=Ron,
    final Goff=Goff,
    final V0=V0,
    final dVdt=dVdt,
    final Vmax=Vmax,
    each final useHeatPort=useHeatPort)
equation
  connect(plug_p.pin, openerWithArc.p)
  connect(openerWithArc.n, plug_n.pin)
  connect(control, openerWithArc.control)
  connect(openerWithArc.heatPort, heatPort)
end OpenerWithArc;


within Modelica.Electrical.Polyphase;
package Ideal "Polyphase components with idealized behaviour"
  extends Modelica.Icons.Package;
end Ideal;


Polyphase short cut branch. Contains m short cuts (Modelica.Electrical.Analog.Ideal.Short)

within Modelica.Electrical.Polyphase.Ideal;
model Short "Polyphase short cut branch"
  extends Interfaces.TwoPlug;
  Modelica.Electrical.Analog.Ideal.Short short[m]
equation

  connect(plug_p.pin, short.p)
  connect(short.n, plug_n.pin)
end Short;


Partial model to include conditional HeatPorts in order to describe the power loss via a thermal network. This partial model provides conditional heat ports for the connection to a thermal network.

within Modelica.Electrical.Polyphase.Interfaces;
partial model ConditionalHeatPort
  "Partial model to include conditional HeatPorts in order to describe the power loss via a thermal network"
  parameter Integer mh(min=1) = 3 "Number of heatPorts=number of phases";
  parameter Boolean useHeatPort=false
    "= true, if all heat ports are enabled"
  parameter SI.Temperature T[mh]=fill(293.15, mh)
    "Fixed device temperatures if useHeatPort = false"
  Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort[mh] if
    useHeatPort "Conditional heat ports"
end ConditionalHeatPort;


Component with two polyphase electrical ports. Superclass of elements which have four electrical plugs.

within Modelica.Electrical.Polyphase.Interfaces;
partial model FourPlug "Component with two polyphase electrical ports"
  parameter Integer m(final min=1) = 3 "Number of phases"
  SI.Voltage v1[m] "Voltage drops of port 1";
  SI.Voltage v2[m] "Voltage drops of port 2";
  SI.Current i1[m]
    "Currents flowing into positive polyphase plug of port 1";
  SI.Current i2[m]
    "Currents flowing into positive polyphase plug of port 2";
  PositivePlug plug_p1(final m=m) "Positive electrical polyphase plug of port 1 with m pins"
  PositivePlug plug_p2(final m=m) "Positive electrical polyphase plug of port 2 with m pins"
  NegativePlug plug_n1(final m=m) "Negative electrical polyphase plug of port 1 with m pins"
  NegativePlug plug_n2(final m=m) "Negative electrical polyphase plug of port 2 with m pins"
equation
  v1 = plug_p1.pin.v - plug_n1.pin.v;
  v2 = plug_p2.pin.v - plug_n2.pin.v;
  i1 = plug_p1.pin.i;
  i2 = plug_p2.pin.i;
end FourPlug;


Component with two electrical plugs and currents from plug_p to plug_n. Superclass of elements which have two electrical plugs:
the positive plug connector plug_p, and the negative plug connector plug_n.
The currents flowing into plug_p are provided explicitly as currents i[m].
It is assumed that the currents flowing into plug_p are identical to the currents flowing out of plug_n.

within Modelica.Electrical.Polyphase.Interfaces;
partial model OnePort
  "Component with two electrical plugs and currents from plug_p to plug_n"

  extends TwoPlug;
equation
  plug_p.pin.i + plug_n.pin.i = zeros(m);
end OnePort;


within Modelica.Electrical.Polyphase;
package Interfaces "Interfaces for electrical polyphase models"
  extends Modelica.Icons.InterfacesPackage;
end Interfaces;


Component with one polyphase electrical port. Superclass of elements which have two electrical plugs:
the positive plug connector plug_p, and the negative plug connector plug_n.
The currents flowing into plug_p are provided explicitly as currents i[m].

within Modelica.Electrical.Polyphase.Interfaces;
partial model TwoPlug "Component with one polyphase electrical port"
  parameter Integer m(min=1) = 3 "Number of phases"
  SI.Voltage v[m] "Voltage drops of the two polyphase plugs";
  SI.Current i[m] "Currents flowing into positive polyphase plugs";
  PositivePlug plug_p(final m=m) "Positive polyphase electrical plug with m pins"
  NegativePlug plug_n(final m=m) "Negative polyphase electrical plug with m pins"
equation
  v = plug_p.pin.v - plug_n.pin.v;
  i = plug_p.pin.i;
end TwoPlug;


Component with two polyphase electrical ports, including currents. Superclass of elements which have four electrical plugs.
It is assumed that the currents flowing into plug_p1 are identical to the currents flowing out of plug_n1,
and that the currents flowing into plug_p2 are identical to the currents flowing out of plug_n2.

within Modelica.Electrical.Polyphase.Interfaces;
partial model TwoPort
  "Component with two polyphase electrical ports, including currents"
  extends FourPlug;
equation
  plug_p1.pin.i + plug_n1.pin.i = zeros(m);
  plug_p2.pin.i + plug_n2.pin.i = zeros(m);
end TwoPort;


Three-phase Aron sensor for active power. Contains two power meters to measure total active power in a three-phase system.

within Modelica.Electrical.Polyphase.Sensors;
model AronSensor "Three-phase Aron sensor for active power"
  extends Modelica.Icons.RoundSensor;
  final parameter Integer m(final min=1) = 3 "Number of phases"
  Interfaces.PositivePlug plug_p(final m=m)
  Interfaces.NegativePlug plug_n(final m=m)
  Modelica.Blocks.Interfaces.RealOutput power(unit="W") "Active power"
  Basic.PlugToPins_p plugToPins_p(final m=m)
  Basic.PlugToPins_n plugToPins_n(final m=m)
  Modelica.Electrical.Analog.Sensors.PowerSensor powerSensor1
  Modelica.Electrical.Analog.Sensors.PowerSensor powerSensor3
  Modelica.Blocks.Math.Add add
equation
  connect(plug_p, plugToPins_p.plug_p)
  connect(plugToPins_n.plug_n, plug_n)
  connect(plugToPins_p.pin_p[1], powerSensor1.pc)
  connect(powerSensor1.pc, powerSensor1.pv)
  connect(powerSensor1.nc, plugToPins_n.pin_n[1])
  connect(plugToPins_p.pin_p[2], plugToPins_n.pin_n[2])
  connect(plugToPins_p.pin_p[3], powerSensor3.pc)
  connect(powerSensor3.pc, powerSensor3.pv)
  connect(powerSensor3.nc, plugToPins_n.pin_n[3])
  connect(powerSensor1.nv, plugToPins_p.pin_p[2])
  connect(powerSensor3.nv, plugToPins_p.pin_p[2])
  connect(add.y, power)
  connect(powerSensor1.power, add.u2)
  connect(powerSensor3.power, add.u1)
end AronSensor;


Continuous quasi current RMS sensor for polyphase system. This sensor determines the continuous quasi RMS value of a polyphase current system, representing an equivalent RMS current vector I or phasor. If the current waveform deviates from a sine curve, the output of the sensor will not be exactly the average RMS value.

within Modelica.Electrical.Polyphase.Sensors;
model CurrentQuasiRMSSensor
  "Continuous quasi current RMS sensor for polyphase system"
  extends Modelica.Icons.RoundSensor;
  extends Polyphase.Interfaces.TwoPlug;
  parameter Integer m(min=1) = 3 "Number of phases"
  Modelica.Blocks.Interfaces.RealOutput I(unit="A")
    "Continuous quasi average RMS of current"
  Polyphase.Sensors.CurrentSensor currentSensor(final m=m)
  Polyphase.Blocks.QuasiRMS quasiRMS(final m=m)
equation
  connect(plug_p, currentSensor.plug_p)
  connect(currentSensor.plug_n, plug_n)
  connect(currentSensor.i, quasiRMS.u)
  connect(quasiRMS.y, I)
end CurrentQuasiRMSSensor;


Polyphase current sensor. Contains m current sensors (Modelica.Electrical.Analog.Sensors.CurrentSensor),
thus measuring the m currents i[m] flowing from the m pins of plug_p to the m pins of plug_n.

within Modelica.Electrical.Polyphase.Sensors;
model CurrentSensor "Polyphase current sensor"
  extends Modelica.Icons.RoundSensor;
  parameter Integer m(final min=1) = 3 "Number of phases"
  Interfaces.PositivePlug plug_p(final m=m)
  Interfaces.NegativePlug plug_n(final m=m)
  Modelica.Blocks.Interfaces.RealOutput i[m](each unit="A")
    "Current in the branch from p to n as output signal"
  Modelica.Electrical.Analog.Sensors.CurrentSensor currentSensor[m]
equation
  connect(plug_p.pin, currentSensor.p)
  connect(currentSensor.n, plug_n.pin)
  connect(currentSensor.i, i)
end CurrentSensor;


Polyphase sensor to measure current, voltage and power. This multi sensor measures currents, voltages and instantaneous electrical power of a polyphase system and has separated voltage and current paths.
The plugs of the voltage paths are pv and nv, the plugs of the current paths are pc and nc.
The internal resistance of each current path is zero, the internal resistance of each voltage path is infinite.

within Modelica.Electrical.Polyphase.Sensors;
model MultiSensor "Polyphase sensor to measure current, voltage and power"
  extends Modelica.Icons.RoundSensor;
  parameter Integer m(min=1) = 3 "Number of phases"
  Polyphase.Interfaces.PositivePlug pc(final m=m) "Positive plug, current path"
  Polyphase.Interfaces.NegativePlug nc(final m=m) "Negative plug, current path"
  Polyphase.Interfaces.PositivePlug pv(final m=m) "Positive plug, voltage path"
  Polyphase.Interfaces.NegativePlug nv(final m=m) "Negative plug, voltage path"
  Modelica.Blocks.Interfaces.RealOutput i[m](each final quantity="ElectricCurrent", each final unit="A")
    "Current as output signal"
  Modelica.Blocks.Interfaces.RealOutput v[m](each final quantity="ElectricPotential", each final unit="V")
    "Voltage as output signal"
  Modelica.Blocks.Interfaces.RealOutput power[m](each final quantity="Power", each final unit="W")
    "Instantaneous power as output signal"
  Modelica.Blocks.Interfaces.RealOutput powerTotal(final quantity="Power", final unit="W")
    "Sum of instantaneous power as output signal"
equation
  pc.pin.i + nc.pin.i = zeros(m);
  pc.pin.v - nc.pin.v = zeros(m);
  pv.pin.i = zeros(m);
  nv.pin.i = zeros(m);
  i = pc.pin.i;
  v = pv.pin.v - nv.pin.v;
  power = v.*i;
  powerTotal = sum(power);
end MultiSensor;


within Modelica.Electrical.Polyphase;
package Sensors "Polyphase potential, voltage and current sensors"
  extends Modelica.Icons.SensorsPackage;
end Sensors;


Polyphase potential sensor. Contains m potential sensors (Modelica.Electrical.Analog.Sensors.PotentialSensor),
thus measuring the m potentials phi[m] of the m pins of plug_p.

within Modelica.Electrical.Polyphase.Sensors;
model PotentialSensor "Polyphase potential sensor"
  extends Modelica.Icons.RoundSensor;
  parameter Integer m(final min=1) = 3 "Number of phases"
  Interfaces.PositivePlug plug_p(final m=m)
  Modelica.Blocks.Interfaces.RealOutput phi[m](each unit="V")
    "Absolute voltage potential as output signal"
  Modelica.Electrical.Analog.Sensors.PotentialSensor potentialSensor[m]
equation
  connect(potentialSensor.p, plug_p.pin)
  connect(potentialSensor.phi, phi)
end PotentialSensor;


Polyphase instantaneous power sensor. This power sensor measures instantaneous electrical power of a polyphase system and has a separated voltage and current path. The plugs of the voltage path are pv and nv, the plugs of the current path are pc and nc. The internal resistance of each current path is zero, the internal resistance of each voltage path is infinite.

within Modelica.Electrical.Polyphase.Sensors;
model PowerSensor "Polyphase instantaneous power sensor"
  extends Modelica.Icons.RoundSensor;
  parameter Integer m(min=1) = 3 "Number of phases"
  Polyphase.Interfaces.PositivePlug pc(final m=m) "Positive plug, current path"
  Polyphase.Interfaces.NegativePlug nc(final m=m) "Negative plug, current path"
  Polyphase.Interfaces.PositivePlug pv(final m=m) "Positive plug, voltage path"
  Polyphase.Interfaces.NegativePlug nv(final m=m) "Negative plug, voltage path"
  Modelica.Blocks.Interfaces.RealOutput power(unit="W")
  Polyphase.Sensors.VoltageSensor voltageSensor(final m=m)
  Polyphase.Sensors.CurrentSensor currentSensor(final m=m)
  Modelica.Blocks.Math.Product product[m]
  Modelica.Blocks.Math.Sum sum(final nin=m, final k=ones(m))
equation
  connect(pc, currentSensor.plug_p)
  connect(currentSensor.plug_n, nc)
  connect(voltageSensor.plug_p, pv)
  connect(voltageSensor.plug_n, nv)
  connect(voltageSensor.v, product.u1)
  connect(currentSensor.i, product.u2)
  connect(product.y, sum.u)
  connect(sum.y, power)
end PowerSensor;


Three-phase sensor for reactive power. Contains 3 power meters (Modelica.Electrical.Analog.Sensors.PowerSensor) to measure total reactive power in a three-phase system.

within Modelica.Electrical.Polyphase.Sensors;
model ReactivePowerSensor "Three-phase sensor for reactive power"
  extends Modelica.Icons.RoundSensor;
  final parameter Integer m(final min=1) = 3 "Number of phases"
  Interfaces.PositivePlug plug_p(final m=m)
  Interfaces.NegativePlug plug_n(final m=m)
  Modelica.Blocks.Interfaces.RealOutput reactivePower(unit="var") "Reactive power"
  Basic.PlugToPins_p plugToPins_p(final m=m)
  Basic.PlugToPins_n plugToPins_n(final m=m)
  Modelica.Electrical.Analog.Sensors.PowerSensor powerSensor1
  Modelica.Electrical.Analog.Sensors.PowerSensor powerSensor2
  Modelica.Blocks.Math.Add3 add(
    final k1=1/sqrt(3),
    final k2=1/sqrt(3),
    final k3=1/sqrt(3))
  Modelica.Electrical.Analog.Sensors.PowerSensor powerSensor3
equation
  connect(plug_p, plugToPins_p.plug_p)
  connect(plugToPins_n.plug_n, plug_n)
  connect(add.y, reactivePower)
  connect(plugToPins_p.pin_p[1], powerSensor1.pc)
  connect(powerSensor1.pv, plugToPins_p.pin_p[2])
  connect(plugToPins_p.pin_p[3], powerSensor1.nv)
  connect(plugToPins_p.pin_p[3], powerSensor2.pv)
  connect(plugToPins_p.pin_p[2], powerSensor2.pc)
  connect(powerSensor1.nc, plugToPins_n.pin_n[1])
  connect(powerSensor2.nc, plugToPins_n.pin_n[2])
  connect(powerSensor1.nc, powerSensor2.nv)
  connect(plugToPins_p.pin_p[3], powerSensor3.pc)
  connect(powerSensor3.nc, plugToPins_n.pin_n[3])
  connect(powerSensor1.nc, powerSensor3.pv)
  connect(powerSensor3.nv, plugToPins_n.pin_n[2])
  connect(powerSensor2.power, add.u2)
  connect(powerSensor1.power, add.u1)
  connect(powerSensor3.power, add.u3)
end ReactivePowerSensor;


Continuous quasi voltage RMS sensor for polyphase system. This sensor determines the continuous quasi RMS value of a polyphase voltage system, representing an equivalent RMS voltage V vector or phasor. If the voltage waveform deviates from a sine curve, the output of the sensor will not be exactly the average RMS value.

within Modelica.Electrical.Polyphase.Sensors;
model VoltageQuasiRMSSensor
  "Continuous quasi voltage RMS sensor for polyphase system"
  extends Modelica.Icons.RoundSensor;
  extends Polyphase.Interfaces.TwoPlug;
  parameter Integer m(min=1) = 3 "Number of phases"

  Modelica.Blocks.Interfaces.RealOutput V(unit="V") "Continuous quasi RMS of voltage"
  Polyphase.Sensors.VoltageSensor voltageSensor(final m=m)
  Polyphase.Blocks.QuasiRMS quasiRMS(final m=m)
equation
  connect(plug_p, voltageSensor.plug_p)
  connect(voltageSensor.plug_n, plug_n)
  connect(voltageSensor.v, quasiRMS.u)
  connect(quasiRMS.y, V)
end VoltageQuasiRMSSensor;


Polyphase voltage sensor. Contains m voltage sensors (Modelica.Electrical.Analog.Sensors.VoltageSensor),
thus measuring the m potential differences v[m] between the m pins of plug_p and plug_n.

within Modelica.Electrical.Polyphase.Sensors;
model VoltageSensor "Polyphase voltage sensor"
  extends Modelica.Icons.RoundSensor;
  parameter Integer m(final min=1) = 3 "Number of phases"
  Interfaces.PositivePlug plug_p(final m=m)
  Interfaces.NegativePlug plug_n(final m=m)
  Modelica.Blocks.Interfaces.RealOutput v[m](each unit="V")
    "Voltage between pin p and n (= p.v - n.v) as output signal"
  Modelica.Electrical.Analog.Sensors.VoltageSensor voltageSensor[m]
equation
  connect(voltageSensor.n, plug_n.pin)
  connect(voltageSensor.p, plug_p.pin)
  connect(voltageSensor.v, v)
end VoltageSensor;


Polyphase constant current source. Contains m constant current sources (Modelica.Electrical.Analog.Sources.ConstantCurrent)

within Modelica.Electrical.Polyphase.Sources;
model ConstantCurrent "Polyphase constant current source"
  extends Interfaces.TwoPlug;
  parameter SI.Current I[m](start=fill(1, m))
    "Values of constant currents";
  Modelica.Electrical.Analog.Sources.ConstantCurrent constantCurrent[m](
      final I=I)
equation
  connect(constantCurrent.p, plug_p.pin)
  connect(constantCurrent.n, plug_n.pin)
end ConstantCurrent;


Polyphase constant voltage source. Contains m constant voltage sources (Modelica.Electrical.Analog.Sources.ConstantVoltage)

within Modelica.Electrical.Polyphase.Sources;
model ConstantVoltage "Polyphase constant voltage source"
  extends Interfaces.TwoPlug;
  parameter SI.Voltage V[m](start=fill(1, m))
    "Values of constant voltages";
  Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage[m](
      final V=V)
equation
  connect(constantVoltage.p, plug_p.pin)
  connect(constantVoltage.n, plug_n.pin)
end ConstantVoltage;


Polyphase cosine current source. Contains m cosine current sources (Modelica.Electrical.Analog.Sources.CosineCurrent)
with a default phase shift determined by
symmetricOrientation.

within Modelica.Electrical.Polyphase.Sources;
model CosineCurrent "Polyphase cosine current source"
  extends Interfaces.TwoPlug;
  parameter SI.Current I[m](start=fill(1, m))
    "Amplitudes of cosine waves";
  parameter SI.Angle phase[m]=-
      Polyphase.Functions.symmetricOrientation(                    m)
    "Phases of cosine waves";
  parameter SI.Frequency f[m](start=fill(1, m))
    "Frequencies of cosine waves";
  parameter SI.Current offset[m]=zeros(m) "Current offsets";
  parameter SI.Time startTime[m]=zeros(m) "Time offsets";
  Modelica.Electrical.Analog.Sources.CosineCurrent cosineCurrent[m](
    final I=I,
    final phase=phase,
    final f=f,
    final offset=offset,
    final startTime=startTime)
equation
  connect(cosineCurrent.p, plug_p.pin)
  connect(cosineCurrent.n, plug_n.pin)
end CosineCurrent;


Polyphase cosine voltage source. Contains m cosine voltage sources (Modelica.Electrical.Analog.Sources.CosineVoltage)
with a default phase shift determined by
symmetricOrientation.

within Modelica.Electrical.Polyphase.Sources;
model CosineVoltage "Polyphase cosine voltage source"
  extends Interfaces.TwoPlug;
  parameter SI.Voltage V[m](start=fill(1, m))
    "Amplitudes of cosine waves";
  parameter SI.Angle phase[m]=-
      Polyphase.Functions.symmetricOrientation(                    m)
    "Phases of cosine waves";
  parameter SI.Frequency f[m](start=fill(1, m))
    "Frequencies of cosine waves";
  parameter SI.Voltage offset[m]=zeros(m) "Voltage offsets";
  parameter SI.Time startTime[m]=zeros(m) "Time offsets";
  Modelica.Electrical.Analog.Sources.CosineVoltage cosineVoltage[m](
    final V=V,
    final phase=phase,
    final f=f,
    final offset=offset,
    final startTime=startTime)
equation
  connect(cosineVoltage.p, plug_p.pin)
  connect(cosineVoltage.n, plug_n.pin)
end CosineVoltage;


Polyphase voltage and current sources

within Modelica.Electrical.Polyphase;
package Sources "Polyphase voltage and current sources"
  extends Modelica.Icons.SourcesPackage;
end Sources;


Polyphase signal current source. Contains m signal controlled current sources (Modelica.Electrical.Analog.Sources.SignalCurrent)

within Modelica.Electrical.Polyphase.Sources;
model SignalCurrent "Polyphase signal current source"
  parameter Integer m(min=1) = 3 "Number of phases"
  SI.Voltage v[m]=plug_p.pin.v - plug_n.pin.v
    "Voltage drops between the two plugs";
  Interfaces.PositivePlug plug_p(final m=m)
  Interfaces.NegativePlug plug_n(final m=m)
  Modelica.Blocks.Interfaces.RealInput i[m](each unit="A")
    "Current flowing from pin p to pin n as input signal"
  Modelica.Electrical.Analog.Sources.SignalCurrent signalCurrent[m]
equation
  connect(signalCurrent.p, plug_p.pin)
  connect(signalCurrent.n, plug_n.pin)
  connect(i, signalCurrent.i)
end SignalCurrent;


Polyphase signal voltage source. Contains m signal controlled voltage sources (Modelica.Electrical.Analog.Sources.SignalVoltage)

within Modelica.Electrical.Polyphase.Sources;
model SignalVoltage "Polyphase signal voltage source"
  parameter Integer m(min=1) = 3 "Number of phases"
  SI.Current i[m]=plug_p.pin.i
    "Currents flowing into positive plugs";
  Interfaces.PositivePlug plug_p(final m=m)
  Interfaces.NegativePlug plug_n(final m=m)
  Modelica.Blocks.Interfaces.RealInput v[m](each unit="V")
    "Voltage between pin p and n (= p.v - n.v) as input signal"
  Modelica.Electrical.Analog.Sources.SignalVoltage signalVoltage[m]
equation
  connect(signalVoltage.p, plug_p.pin)
  connect(signalVoltage.n, plug_n.pin)
  connect(v, signalVoltage.v)
end SignalVoltage;


Polyphase sine current source. Contains m sine current sources (Modelica.Electrical.Analog.Sources.SineCurrent)
with a default phase shift determined by
symmetricOrientation.

within Modelica.Electrical.Polyphase.Sources;
model SineCurrent "Polyphase sine current source"
  extends Interfaces.TwoPlug;
  parameter SI.Current I[m](start=fill(1, m))
    "Amplitudes of sine waves";
  parameter SI.Angle phase[m]=-
      Polyphase.Functions.symmetricOrientation(                    m)
    "Phases of sine waves";
  parameter SI.Frequency f[m](start=fill(1, m))
    "Frequencies of sine waves";
  parameter SI.Current offset[m]=zeros(m) "Current offsets";
  parameter SI.Time startTime[m]=zeros(m) "Time offsets";
  Modelica.Electrical.Analog.Sources.SineCurrent sineCurrent[m](
    final I=I,
    final phase=phase,
    final f=f,
    final offset=offset,
    final startTime=startTime)
equation
  connect(sineCurrent.p, plug_p.pin)
  connect(sineCurrent.n, plug_n.pin)
end SineCurrent;


Polyphase sine voltage source. Contains m sine voltage sources (Modelica.Electrical.Analog.Sources.SineVoltage)
with a default phase shift determined by
symmetricOrientation.

within Modelica.Electrical.Polyphase.Sources;
model SineVoltage "Polyphase sine voltage source"
  extends Interfaces.TwoPlug;
  parameter SI.Voltage V[m](start=fill(1, m))
    "Amplitudes of sine waves";
  parameter SI.Angle phase[m]=-
      Polyphase.Functions.symmetricOrientation(                    m)
    "Phases of sine waves";
  parameter SI.Frequency f[m](start=fill(1, m))
    "Frequencies of sine waves";
  parameter SI.Voltage offset[m]=zeros(m) "Voltage offsets";
  parameter SI.Time startTime[m]=zeros(m) "Time offsets";
  Modelica.Electrical.Analog.Sources.SineVoltage sineVoltage[m](
    final V=V,
    final phase=phase,
    final f=f,
    final offset=offset,
    final startTime=startTime)
equation
  connect(sineVoltage.p, plug_p.pin)
  connect(sineVoltage.n, plug_n.pin)
end SineVoltage;


within Modelica.Electrical;
package PowerConverters "Rectifiers, Inverters, DC/DC and AC/AC converters"
  extends Modelica.Icons.Package;
end PowerConverters;


AC to AC converters

within Modelica.Electrical.PowerConverters;
package ACAC "AC to AC converters"
  extends Modelica.Icons.Package;
end ACAC;


Triodes for alternating current. Simplified model of m
triodes for alternating current, each built from two antiparallel thyristors.
thyristor1 has to be fired during the positive halfwave of the voltage.
thyristor2 has to be fired during the negative halfwave of the voltage.

within Modelica.Electrical.PowerConverters.ACAC;
model PolyphaseTriac "Triodes for alternating current"
  extends Modelica.Electrical.Polyphase.Interfaces.TwoPlug;
  parameter SI.Resistance Ron(final min=0)=1e-5
    "Forward state-on differential resistance (closed resistance)";
  parameter SI.Conductance Goff(final min=0)=1e-5
    "Backward state-off conductance (opened conductance)";
  parameter SI.Voltage Vknee(final min=0)=0 "Forward threshold voltage";
  extends Modelica.Electrical.Polyphase.Interfaces.ConditionalHeatPort(final mh=m);
  Modelica.Blocks.Interfaces.BooleanInput fire1[m]
  Modelica.Blocks.Interfaces.BooleanInput fire2[m]
  Modelica.Electrical.Polyphase.Basic.PlugToPins_p plugToPins_p(final m=m)
  Modelica.Electrical.Polyphase.Basic.PlugToPins_n plugToPins_n(final m=m)
  SinglePhaseTriac triac[m](each useHeatPort=useHeatPort)
equation
  connect(plug_p, plugToPins_p.plug_p)
  connect(plugToPins_n.plug_n, plug_n)
  connect(triac.heatPort, heatPort)
  connect(fire1, triac.fire1)
  connect(fire2, triac.fire2)
  connect(plugToPins_p.pin_p, triac.p)
  connect(triac.n, plugToPins_n.pin_n)
end PolyphaseTriac;


Triode for alternating current. Simplified model of a triode for alternating current, built from two antiparallel thyristors.
thyristor1 has to be fired during the positive halfwave of the voltage.
thyristor2 has to be fired during the negative halfwave of the voltage.

within Modelica.Electrical.PowerConverters.ACAC;
model SinglePhaseTriac "Triode for alternating current"
  extends Modelica.Electrical.Analog.Interfaces.TwoPin;
  SI.Current i=p.i "Current flowing from pin p to pin n";
  parameter SI.Resistance Ron(final min=0)=1e-5
    "Forward state-on differential resistance (closed resistance)";
  parameter SI.Conductance Goff(final min=0)=1e-5
    "Backward state-off conductance (opened conductance)";
  parameter SI.Voltage Vknee(final min=0)=0 "Forward threshold voltage";
  parameter Boolean useHeatPort = false "= true, if heatPort is enabled"
  parameter SI.Temperature T=293.15
    "Fixed device temperature if useHeatPort = false"
  Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort if useHeatPort
    "Conditional heat port"
  Modelica.Blocks.Interfaces.BooleanInput fire1
  Modelica.Blocks.Interfaces.BooleanInput fire2
  Modelica.Electrical.Analog.Ideal.IdealThyristor thyristor1(
    final Ron=Ron,
    final Goff=Goff,
    final Vknee=Vknee,
    final useHeatPort=useHeatPort,
    final T=T,
    off(fixed=true))
  Modelica.Electrical.Analog.Ideal.IdealThyristor thyristor2(
    final Ron=Ron,
    final Goff=Goff,
    final Vknee=Vknee,
    final useHeatPort=useHeatPort,
    final T=T,
    off(fixed=true))
equation
  connect(fire1, thyristor1.fire)
  connect(fire2, thyristor2.fire)
  connect(thyristor1.heatPort, heatPort)
  connect(heatPort, thyristor2.heatPort)
  connect(p, thyristor1.p)
  connect(p, thyristor2.n)
  connect(n, thyristor1.n)
  connect(n, thyristor2.p)
end SinglePhaseTriac;


within Modelica.Electrical.PowerConverters.ACAC;
package Control "Control components for AC to AC converters"
  extends Modelica.Icons.Package;

end Control;


Soft start control. This block models the functionality of a soft starter controller, controlling the output vRef in the range [0,1] with respect to nominal voltage.

within Modelica.Electrical.PowerConverters.ACAC.Control;
block SoftStartControl "Soft start control"
  extends Modelica.Blocks.Icons.Block;
  import ModeOfOperation =
    Modelica.Electrical.PowerConverters.Types.SoftStarterModeOfOperation;
  parameter SI.Time tRampUp "Start ramp duration";
  parameter Real vStart=0 "Start voltage / nominal voltage";
  parameter Real iMax "Maximum current / nominal current";
  parameter Real iMin=0.9*iMax "Lower threshold of current control";
  parameter SI.Current INominal "Nominal current";
parameter SI.Time tRampDown "Stop ramp duration";
  Modelica.Blocks.Interfaces.RealInput iRMS(unit="A") "Measured RMS current"
  Modelica.Blocks.Interfaces.RealOutput vRef(min=0, max=1, start=0) "Reference voltage"
  Modelica.Blocks.Interfaces.BooleanInput start
protected
  PowerConverters.Types.SoftStarterModeOfOperation modeOfOperation;
  Real i=iRMS/INominal "Measured current";
  Boolean limit "Indicates current limitation";
initial equation
  if start then
    if vRef<1 then
      modeOfOperation=ModeOfOperation.Up;
    else
      modeOfOperation=ModeOfOperation.On;
    end if;
  else
    if vRef>0 then
      modeOfOperation=ModeOfOperation.Down;
    else
      modeOfOperation=ModeOfOperation.Off;
    end if;
  end if;
  limit = i>=iMax;
equation
  assert(iMax>iMin, "iMax has to be greater than iMin");
  when start then
    modeOfOperation = ModeOfOperation.Up;
  elsewhen vRef>=1 then
    modeOfOperation = ModeOfOperation.On;
  elsewhen not start then
    modeOfOperation = ModeOfOperation.Down;
  elsewhen vRef<=0 then
    modeOfOperation = ModeOfOperation.Off;
  end when;
  when start and vRef<vStart then
    reinit(vRef, vStart);
  end when;
  when i>=iMax then
    limit=true;
  elsewhen i<=iMin then
    limit=false;
  end when;
  if modeOfOperation==ModeOfOperation.Up and not limit then
    der(vRef) = (1 - vStart)/tRampUp;
  elseif modeOfOperation==ModeOfOperation.Down  and not limit then
    der(vRef) = -1/tRampDown;
  else
    der(vRef) = 0;
  end if;
end SoftStartControl;


Reference voltage to firing angle converter. This block calculates firing angle from desired voltage,
choosing either a linear (Lin) relationship or prescribing the first harmonic (H01)  or the root mean square (RMS) .
Since calculating the firing angle from both the H01 and the RMS involves a nonlinear equation,
both relationships have been precalculated and are interpolated from a table.


2*m pulse diode rectifier bridge. General information about AC/DC converters can be found at the
AC/DC converter concept

within Modelica.Electrical.PowerConverters.ACDC;
model DiodeBridge2mPulse "2*m pulse diode rectifier bridge"
  extends Icons.Converter;
  import Modelica.Constants.pi;
  parameter Integer m(final min=3) = 3 "Number of phases"
  parameter SI.Resistance RonDiode(final min=0) = 1e-05
    "Closed diode resistance";
  parameter SI.Conductance GoffDiode(final min=0) = 1e-05
    "Opened diode conductance";
  parameter SI.Voltage VkneeDiode(final min=0) = 0
    "Diode forward threshold voltage";
  extends PowerConverters.Interfaces.ACDC.ACplug;
  extends PowerConverters.Interfaces.ACDC.DCtwoPin;
  extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(final T=
       293.15);
  Modelica.Electrical.Polyphase.Ideal.IdealDiode diode_p(
    final m=m,
    final Ron=fill(RonDiode, m),
    final Goff=fill(GoffDiode, m),
    final Vknee=fill(VkneeDiode, m),
    final useHeatPort=useHeatPort)
    "Diodes connected to positive DC potential"
  Modelica.Electrical.Polyphase.Ideal.IdealDiode diode_n(
    final m=m,
    final Ron=fill(RonDiode, m),
    final Goff=fill(GoffDiode, m),
    final Vknee=fill(VkneeDiode, m),
    final useHeatPort=useHeatPort)
    "Diodes connected to negative DC potential"
  Modelica.Electrical.Polyphase.Basic.Star star_p(final m=m)
  Modelica.Electrical.Polyphase.Basic.Star star_n(final m=m)
  Modelica.Thermal.HeatTransfer.Components.ThermalCollector
    thermalCollector(final m=m) if useHeatPort
equation
  if not useHeatPort then
    LossPower = sum(diode_p.idealDiode.LossPower) + sum(diode_n.idealDiode.LossPower);
  end if;
  connect(ac, diode_p.plug_p)
  connect(diode_p.plug_p, diode_n.plug_n)
  connect(diode_p.plug_n, star_p.plug_p)
  connect(star_p.pin_n, dc_p)
  connect(diode_n.plug_p, star_n.plug_p)
  connect(star_n.pin_n, dc_n)
  connect(thermalCollector.port_a, diode_n.heatPort)
  connect(thermalCollector.port_b, heatPort)
  connect(diode_p.heatPort, thermalCollector.port_a)
end DiodeBridge2mPulse;


Two pulse Graetz diode rectifier bridge. General information about AC/DC converters can be found at the
AC/DC converter concept

within Modelica.Electrical.PowerConverters.ACDC;
model DiodeBridge2Pulse "Two pulse Graetz diode rectifier bridge"
  extends Icons.Converter;
  import Modelica.Constants.pi;
  parameter SI.Resistance RonDiode(final min=0) = 1e-05
    "Closed diode resistance";
  parameter SI.Conductance GoffDiode(final min=0) = 1e-05
    "Opened diode conductance";
  parameter SI.Voltage VkneeDiode(final min=0) = 0
    "Diode forward threshold voltage";
  extends PowerConverters.Interfaces.ACDC.ACtwoPin;
  extends PowerConverters.Interfaces.ACDC.DCtwoPin;
  extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(final T=
       293.15);
  Modelica.Electrical.Analog.Ideal.IdealDiode diode_p1(
    final Goff=GoffDiode,
    final Vknee=VkneeDiode,
    final useHeatPort=useHeatPort,
    final Ron=RonDiode)
    "Diode connecting the positive AC input pin with positive DC output"
  Modelica.Electrical.Analog.Ideal.IdealDiode diode_p2(
    final Ron=RonDiode,
    final Goff=GoffDiode,
    final Vknee=VkneeDiode,
    final useHeatPort=useHeatPort)
    "Diode connecting the negative AC input pin with positive DC output"
  Modelica.Electrical.Analog.Ideal.IdealDiode diode_n1(
    final Ron=RonDiode,
    final Goff=GoffDiode,
    final Vknee=VkneeDiode,
    final useHeatPort=useHeatPort)
    "Diode connecting the positive AC input pin with negative DC output"
  Modelica.Electrical.Analog.Ideal.IdealDiode diode_n2(
    final Ron=RonDiode,
    final Goff=GoffDiode,
    final Vknee=VkneeDiode,
    final useHeatPort=useHeatPort)
    "Diode connecting the negative AC input pin with negative DC output"
equation
  if not useHeatPort then
    LossPower = diode_p1.LossPower + diode_p2.LossPower + diode_n1.LossPower
       + diode_n2.LossPower;
  end if;
  connect(diode_p2.n, diode_p1.n)
  connect(diode_n1.p, diode_n2.p)
  connect(diode_n2.n, diode_p2.p)
  connect(diode_p1.p, diode_n1.n)
  connect(diode_p1.n, dc_p)
  connect(diode_n1.p, dc_n)
  connect(diode_n1.heatPort, heatPort)
  connect(diode_n2.heatPort, heatPort)
  connect(diode_p1.heatPort, heatPort)
  connect(diode_p2.heatPort, heatPort)
  connect(ac_p, diode_p1.p)
  connect(ac_n, diode_p2.p)
end DiodeBridge2Pulse;


2*m pulse diode rectifier with center tap. General information about AC/DC converters can be found at the
AC/DC converter concept

within Modelica.Electrical.PowerConverters.ACDC;
model DiodeCenterTap2mPulse "2*m pulse diode rectifier with center tap"
  extends Icons.Converter;
  import Modelica.Constants.pi;
  parameter Integer m(final min=3) = 3 "Number of phases"
  parameter SI.Resistance RonDiode(final min=0) = 1e-05
    "Closed diode resistance";
  parameter SI.Conductance GoffDiode(final min=0) = 1e-05
    "Opened diode conductance";
  parameter SI.Voltage VkneeDiode(final min=0) = 0
    "Diode forward threshold voltage";
  extends PowerConverters.Interfaces.ACDC.ACtwoPlug;
  extends PowerConverters.Interfaces.ACDC.DCpin;
  extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(final T=
       293.15);
  Modelica.Electrical.Polyphase.Ideal.IdealDiode diode_p(
    final m=m,
    final Ron=fill(RonDiode, m),
    final Goff=fill(GoffDiode, m),
    final Vknee=fill(VkneeDiode, m),
    final useHeatPort=useHeatPort)
    "Diodes connected to positive DC potential"
  Modelica.Electrical.Polyphase.Ideal.IdealDiode diode_n(
    final m=m,
    final Ron=fill(RonDiode, m),
    final Goff=fill(GoffDiode, m),
    final Vknee=fill(VkneeDiode, m),
    final useHeatPort=useHeatPort)
    "Diodes connected to negative DC potential"
  Modelica.Electrical.Polyphase.Basic.Star star_p(final m=m)
  Modelica.Electrical.Polyphase.Basic.Star star_n(final m=m)
  Modelica.Thermal.HeatTransfer.Components.ThermalCollector
    thermalCollector(final m=m) if useHeatPort
equation
  if not useHeatPort then
    LossPower = sum(diode_p.idealDiode.LossPower) + sum(diode_n.idealDiode.LossPower);
  end if;
  connect(diode_p.plug_n, star_p.plug_p)
  connect(star_p.pin_n, dc_p)
  connect(heatPort, thermalCollector.port_b)
  connect(thermalCollector.port_a, diode_n.heatPort)
  connect(diode_p.heatPort, thermalCollector.port_a)
  connect(ac_p, diode_p.plug_p)
  connect(star_n.pin_n, dc_p)
  connect(diode_n.plug_p, ac_n)
  connect(diode_n.plug_n, star_n.plug_p)
end DiodeCenterTap2mPulse;


Two pulse diode rectifier with center tap. General information about AC/DC converters can be found at the
AC/DC converter concept

within Modelica.Electrical.PowerConverters.ACDC;
model DiodeCenterTap2Pulse "Two pulse diode rectifier with center tap"
  extends Icons.Converter;
  import Modelica.Constants.pi;
  parameter SI.Resistance RonDiode(final min=0) = 1e-05
    "Closed diode resistance";
  parameter SI.Conductance GoffDiode(final min=0) = 1e-05
    "Opened diode conductance";
  parameter SI.Voltage VkneeDiode(final min=0) = 0
    "Diode forward threshold voltage";
  extends PowerConverters.Interfaces.ACDC.ACtwoPin;
  extends PowerConverters.Interfaces.ACDC.DCpin;
  extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(final T=
       293.15);
  Modelica.Electrical.Analog.Ideal.IdealDiode diode_p(
    final Ron=RonDiode,
    final Goff=GoffDiode,
    final Vknee=VkneeDiode,
    final useHeatPort=useHeatPort)
    "Diodes conducting positive pin AC potentials"
  Modelica.Electrical.Analog.Ideal.IdealDiode diode_n(
    final Ron=RonDiode,
    final Goff=GoffDiode,
    final Vknee=VkneeDiode,
    final useHeatPort=useHeatPort)
    "Diodes conducting negative pin AC potentials"
equation
  if not useHeatPort then
    LossPower = diode_p.LossPower + diode_n.LossPower;
  end if;
  connect(ac_p, diode_p.p)
  connect(ac_n, diode_n.p)
  connect(diode_p.n, dc_p)
  connect(diode_n.n, dc_p)
  connect(diode_n.heatPort, heatPort)
  connect(diode_p.heatPort, heatPort)
end DiodeCenterTap2Pulse;


m pulse diode rectifier with center tap. General information about AC/DC converters can be found at the
AC/DC converter concept.

within Modelica.Electrical.PowerConverters.ACDC;
model DiodeCenterTapmPulse "m pulse diode rectifier with center tap"
  import Modelica.Constants.pi;
  extends Icons.Converter;
  parameter Integer m(final min=3) = 3 "Number of phases"
  parameter SI.Resistance RonDiode(final min=0) = 1e-05
    "Closed diode resistance";
  parameter SI.Conductance GoffDiode(final min=0) = 1e-05
    "Opened diode conductance";
  parameter SI.Voltage VkneeDiode(final min=0) = 0
    "Diode forward threshold voltage";
  extends PowerConverters.Interfaces.ACDC.ACplug;
  extends PowerConverters.Interfaces.ACDC.DCpin;
  extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(final T=
       293.15);
  Modelica.Electrical.Polyphase.Ideal.IdealDiode diode(
    final m=m,
    final Ron=fill(RonDiode, m),
    final Goff=fill(GoffDiode, m),
    final Vknee=fill(VkneeDiode, m),
    final useHeatPort=useHeatPort)
    "Diodes connected to positive DC potential"
  Modelica.Electrical.Polyphase.Basic.Star star(final m=m)
  Modelica.Thermal.HeatTransfer.Components.ThermalCollector
    thermalCollector(final m=m) if useHeatPort
equation
  assert(mod(m, 2) == 1,
    "DiodeCenterTapmPulse: only odd phase numbers are allowed");
  if not useHeatPort then
    LossPower = sum(diode.idealDiode.LossPower);
  end if;
  connect(diode.plug_n, star.plug_p)
  connect(star.pin_n, dc_p)
  connect(heatPort, thermalCollector.port_b)
  connect(diode.heatPort, thermalCollector.port_a)
  connect(ac, diode.plug_p)
end DiodeCenterTapmPulse;


2*m pulse half controlled rectifier bridge. General information about AC/DC converters can be found at the
AC/DC converter concept

within Modelica.Electrical.PowerConverters.ACDC;
model HalfControlledBridge2mPulse
  "2*m pulse half controlled rectifier bridge"
  extends Icons.Converter;
  import Modelica.Constants.pi;
  // parameter Integer m(final min=3) = 3 "Number of phases"
  parameter SI.Resistance RonDiode(final min=0) = 1e-05
    "Closed diode resistance";
  parameter SI.Conductance GoffDiode(final min=0) = 1e-05
    "Opened diode conductance";
  parameter SI.Voltage VkneeDiode(final min=0) = 0
    "Diode forward threshold voltage";
  parameter SI.Resistance RonThyristor(final min=0) = 1e-05
    "Closed thyristor resistance";
  parameter SI.Conductance GoffThyristor(final min=0) = 1e-05
    "Opened thyristor conductance";
  parameter SI.Voltage VkneeThyristor(final min=0) = 0
    "Thyristor forward threshold voltage";
  parameter Boolean offStart_p[m]=fill(true, m)
    "Boolean start value of variable thyristor_p[:].off"
  extends PowerConverters.Interfaces.ACDC.ACplug;
  extends PowerConverters.Interfaces.ACDC.DCtwoPin;
  extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(final T=
       293.15);
  extends Interfaces.Enable.Enable1m;
  Modelica.Electrical.Polyphase.Basic.Star star_p(final m=m)
  Modelica.Electrical.Polyphase.Basic.Star star_n(final m=m)
  Modelica.Electrical.Polyphase.Ideal.IdealThyristor thyristor_p(
    final m=m,
    final Ron=fill(RonThyristor, m),
    final Goff=fill(GoffThyristor, m),
    final Vknee=fill(VkneeThyristor, m),
    final useHeatPort=useHeatPort,
    final idealThyristor(off(start=offStart_p, fixed=fill(true, m))))
    "Thyristors connected to positive DC potential"
  Modelica.Electrical.Polyphase.Ideal.IdealDiode diode_n(
    final m=m,
    final Ron=fill(RonDiode, m),
    final Goff=fill(GoffDiode, m),
    final Vknee=fill(VkneeDiode, m),
    final useHeatPort=useHeatPort)
    "Diodes connected to negative DC potential"
  Modelica.Thermal.HeatTransfer.Components.ThermalCollector
    thermalCollector(final m=m) if useHeatPort
  Modelica.Blocks.Logical.Pre pre[m]
equation
  if not useHeatPort then
    LossPower = sum(thyristor_p.idealThyristor.LossPower) + sum(diode_n.idealDiode.LossPower);
  end if;
  connect(ac, thyristor_p.plug_p)
  connect(thyristor_p.plug_p, diode_n.plug_n)
  connect(thyristor_p.plug_n, star_p.plug_p)
  connect(star_p.pin_n, dc_p)
  connect(diode_n.plug_p, star_n.plug_p)
  connect(star_n.pin_n, dc_n)
  connect(heatPort, thermalCollector.port_b)
  connect(thermalCollector.port_a, diode_n.heatPort)
  connect(thyristor_p.heatPort, thermalCollector.port_a)
  connect(andCondition_p.y, pre.u)
  connect(pre.y, thyristor_p.fire)
end HalfControlledBridge2mPulse;


Two pulse Graetz half controlled rectifier bridge. General information about AC/DC converters can be found at the
AC/DC converter concept

within Modelica.Electrical.PowerConverters.ACDC;
model HalfControlledBridge2Pulse
  "Two pulse Graetz half controlled rectifier bridge"
  import Modelica.Constants.pi;
  extends Icons.Converter;
  parameter SI.Resistance RonDiode(final min=0) = 1e-05
    "Closed diode resistance";
  parameter SI.Conductance GoffDiode(final min=0) = 1e-05
    "Opened diode conductance";
  parameter SI.Voltage VkneeDiode(final min=0) = 0
    "Diode forward threshold voltage";
  parameter SI.Resistance RonThyristor(final min=0) = 1e-05
    "Closed thyristor resistance";
  parameter SI.Conductance GoffThyristor(final min=0) = 1e-05
    "Opened thyristor conductance";
  parameter SI.Voltage VkneeThyristor(final min=0) = 0
    "Thyristor forward threshold voltage";
  parameter Boolean offStart_p1=true
    "Boolean start value of variable thyristor_p1.off"
  parameter Boolean offStart_p2=true
    "Boolean start value of variable thyristor_p2.off"
  extends PowerConverters.Interfaces.ACDC.ACtwoPin;
  extends PowerConverters.Interfaces.ACDC.DCtwoPin;
  extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(final T=
       293.15);
  extends Interfaces.Enable.Enable2;
  Modelica.Electrical.Analog.Ideal.IdealThyristor thyristor_p1(
    final Ron=RonThyristor,
    final Goff=GoffThyristor,
    final Vknee=VkneeThyristor,
    final useHeatPort=useHeatPort,
    final off(start=offStart_p1, fixed=true))
  Modelica.Electrical.Analog.Ideal.IdealThyristor thyristor_p2(
    final Ron=RonThyristor,
    final Goff=GoffThyristor,
    final Vknee=VkneeThyristor,
    final useHeatPort=useHeatPort,
    final off(start=offStart_p2, fixed=true))
  Modelica.Electrical.Analog.Ideal.IdealDiode diode_n1(
    final Ron=RonDiode,
    final Goff=GoffDiode,
    final Vknee=VkneeDiode,
    final useHeatPort=useHeatPort)
    "Diode connected to negative DC potential"
  Modelica.Electrical.Analog.Ideal.IdealDiode diode_n2(
    final Ron=RonDiode,
    final Goff=GoffDiode,
    final Vknee=VkneeDiode,
    final useHeatPort=useHeatPort)
    "Diode connected to negative DC potential"
equation
  if not useHeatPort then
    LossPower = thyristor_p1.LossPower + thyristor_p2.LossPower + diode_n1.LossPower
       + diode_n2.LossPower;
  end if;
  connect(thyristor_p2.n, thyristor_p1.n)
  connect(diode_n1.p, diode_n2.p)
  connect(diode_n2.n, thyristor_p2.p)
  connect(thyristor_p1.p, diode_n1.n)
  connect(thyristor_p1.n, dc_p)
  connect(diode_n1.p, dc_n)
  connect(diode_n1.heatPort, heatPort)
  connect(diode_n2.heatPort, heatPort)
  connect(thyristor_p1.heatPort, heatPort)
  connect(thyristor_p2.heatPort, heatPort)
  connect(ac_p, thyristor_p1.p)
  connect(ac_n, diode_n2.n)
  connect(andCondition_p.y, thyristor_p1.fire)
  connect(andCondition_n.y, thyristor_p2.fire)
end HalfControlledBridge2Pulse;


AC to DC converters

within Modelica.Electrical.PowerConverters;
package ACDC "AC to DC converters"
  extends Modelica.Icons.Package;
end ACDC;


2*m pulse thyristor rectifier bridge. General information about AC/DC converters can be found at the
AC/DC converter concept

within Modelica.Electrical.PowerConverters.ACDC;
model ThyristorBridge2mPulse "2*m pulse thyristor rectifier bridge"
  extends Icons.Converter;
  import Modelica.Constants.pi;
  // parameter Integer m(final min=3) = 3 "Number of phases"
  parameter SI.Resistance RonThyristor(final min=0) = 1e-05
    "Closed thyristor resistance";
  parameter SI.Conductance GoffThyristor(final min=0) = 1e-05
    "Opened thyristor conductance";
  parameter SI.Voltage VkneeThyristor(final min=0) = 0
    "Thyristor forward threshold voltage";
  parameter Boolean offStart_p[m]=fill(true, m)
    "Boolean start value of variable thyristor_p[:].off"
  parameter Boolean offStart_n[m]=fill(true, m)
    "Boolean start value of variable thyristor_n[:].off"
  extends PowerConverters.Interfaces.ACDC.ACplug;
  extends PowerConverters.Interfaces.ACDC.DCtwoPin;
  extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(final T=293.15);
  extends Interfaces.Enable.Enable2m;
  Modelica.Electrical.Polyphase.Ideal.IdealThyristor thyristor_p(
    final m=m,
    final Ron=fill(RonThyristor, m),
    final Goff=fill(GoffThyristor, m),
    final Vknee=fill(VkneeThyristor, m),
    final useHeatPort=useHeatPort,
    final idealThyristor(off(start=offStart_p, fixed=fill(true, m))))
    "Thyristors connected to positive DC potential"
  Modelica.Electrical.Polyphase.Ideal.IdealThyristor thyristor_n(
    final m=m,
    final Ron=fill(RonThyristor, m),
    final Goff=fill(GoffThyristor, m),
    final Vknee=fill(VkneeThyristor, m),
    final useHeatPort=useHeatPort,
    final idealThyristor(off(start=offStart_n, fixed=fill(true, m))))
    "Thyristors connected to negative DC potential"
  Modelica.Electrical.Polyphase.Basic.Star star_p(final m=m)
  Modelica.Electrical.Polyphase.Basic.Star star_n(final m=m)
  Modelica.Thermal.HeatTransfer.Components.ThermalCollector
    thermalConnector(final m=m) if useHeatPort
  Modelica.Blocks.Logical.Pre pre_p[m]
  Modelica.Blocks.Logical.Pre pre_n[m]
equation
  if not useHeatPort then
    LossPower = sum(thyristor_p.idealThyristor.LossPower) + sum(thyristor_n.idealThyristor.LossPower);
  end if;
  connect(ac, thyristor_p.plug_p)
  connect(thyristor_p.plug_p, thyristor_n.plug_n)
  connect(thyristor_p.plug_n, star_p.plug_p)
  connect(star_p.pin_n, dc_p)
  connect(thyristor_n.plug_p, star_n.plug_p)
  connect(star_n.pin_n, dc_n)
  connect(heatPort, thermalConnector.port_b)
  connect(thermalConnector.port_a, thyristor_n.heatPort)
  connect(thyristor_p.heatPort, thermalConnector.port_a)
  connect(andCondition_p.y, pre_p.u)
  connect(pre_p.y, thyristor_p.fire)
  connect(pre_n.y, thyristor_n.fire)
  connect(andCondition_n.y, pre_n.u)
end ThyristorBridge2mPulse;


Two pulse Graetz thyristor rectifier bridge. General information about AC/DC converters can be found at the
AC/DC converter concept

within Modelica.Electrical.PowerConverters.ACDC;
model ThyristorBridge2Pulse "Two pulse Graetz thyristor rectifier bridge"
  extends Icons.Converter;
  import Modelica.Constants.pi;
  parameter SI.Resistance RonThyristor(final min=0) = 1e-05
    "Closed thyristor resistance";
  parameter SI.Conductance GoffThyristor(final min=0) = 1e-05
    "Opened thyristor conductance";
  parameter SI.Voltage VkneeThyristor(final min=0) = 0
    "Thyristor forward threshold voltage";
  parameter Boolean offStart_p1=true
    "Boolean start value of variable thyristor_p1.off"
  parameter Boolean offStart_p2=true
    "Boolean start value of variable thyristor_p2.off"
  parameter Boolean offStart_n1=true
    "Boolean start value of variable thyristor_n1.off"
  parameter Boolean offStart_n2=true
    "Boolean start value of variable thyristor_n2.off"
  extends PowerConverters.Interfaces.ACDC.ACtwoPin;
  extends PowerConverters.Interfaces.ACDC.DCtwoPin;
  extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(final T=
       293.15);
  extends Interfaces.Enable.Enable2;
  Modelica.Electrical.Analog.Ideal.IdealThyristor thyristor_p1(
    final Ron=RonThyristor,
    final Goff=GoffThyristor,
    final Vknee=VkneeThyristor,
    final useHeatPort=useHeatPort,
    final off(start=offStart_p1, fixed=true))
    "Thyristor connecting the positive AC input pin with positive DC output"
  Modelica.Electrical.Analog.Ideal.IdealThyristor thyristor_p2(
    final Ron=RonThyristor,
    final Goff=GoffThyristor,
    final Vknee=VkneeThyristor,
    final useHeatPort=useHeatPort,
    final off(start=offStart_p2, fixed=true))
    "Thyristor connecting the negative AC input pin with positive DC output"
  Modelica.Electrical.Analog.Ideal.IdealThyristor thyristor_n1(
    final Ron=RonThyristor,
    final Goff=GoffThyristor,
    final Vknee=VkneeThyristor,
    final useHeatPort=useHeatPort,
    final off(start=offStart_n1, fixed=true))
    "Thyristor connecting the positive AC input with negative DC output"
  Modelica.Electrical.Analog.Ideal.IdealThyristor thyristor_n2(
    final Ron=RonThyristor,
    final Goff=GoffThyristor,
    final Vknee=VkneeThyristor,
    final useHeatPort=useHeatPort,
    final off(start=offStart_n2, fixed=true))
    "Thyristor connecting the negative AC input with negative DC output"
equation
  if not useHeatPort then
    LossPower = thyristor_p1.LossPower + thyristor_p2.LossPower +
      thyristor_n1.LossPower + thyristor_n2.LossPower;
  end if;
  connect(thyristor_p2.n, thyristor_p1.n)
  connect(thyristor_n1.p, thyristor_n2.p)
  connect(thyristor_n2.n, thyristor_p2.p)
  connect(thyristor_p1.p, thyristor_n1.n)
  connect(thyristor_p1.n, dc_p)
  connect(thyristor_n1.p, dc_n)
  connect(thyristor_n1.heatPort, heatPort)
  connect(thyristor_n2.heatPort, heatPort)
  connect(thyristor_p1.heatPort, heatPort)
  connect(thyristor_p2.heatPort, heatPort)
  connect(ac_p, thyristor_p1.p)
  connect(ac_n, thyristor_n2.n)
  connect(andCondition_p.y, thyristor_p1.fire)
  connect(andCondition_p.y, thyristor_n2.fire)
  connect(andCondition_n.y, thyristor_p2.fire)
  connect(andCondition_n.y, thyristor_n1.fire)
end ThyristorBridge2Pulse;


2*m pulse thyristor rectifier with center tap. General information about AC/DC converters can be found at the
AC/DC converter concept

within Modelica.Electrical.PowerConverters.ACDC;
model ThyristorCenterTap2mPulse
  "2*m pulse thyristor rectifier with center tap"
  extends Icons.Converter;
  import Modelica.Constants.pi;
  // parameter Integer m(final min=3) = 3 "Number of phases"
  parameter SI.Resistance RonThyristor(final min=0) = 1e-05
    "Closed thyristor resistance";
  parameter SI.Conductance GoffThyristor(final min=0) = 1e-05
    "Opened thyristor conductance";
  parameter SI.Voltage VkneeThyristor(final min=0) = 0
    "Thyristor forward threshold voltage";
  parameter Boolean offStart_p[m]=fill(true, m)
    "Boolean start value of variable thyristor_p[:].off"
  parameter Boolean offStart_n[m]=fill(true, m)
    "Boolean start value of variable thyristor_n[:].off"
  extends PowerConverters.Interfaces.ACDC.ACtwoPlug;
  extends PowerConverters.Interfaces.ACDC.DCpin;
  extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(final T=
       293.15);
  extends Interfaces.Enable.Enable2m;
  Modelica.Electrical.Polyphase.Ideal.IdealThyristor thyristor_p(
    final m=m,
    final Ron=fill(RonThyristor, m),
    final Goff=fill(GoffThyristor, m),
    final Vknee=fill(VkneeThyristor, m),
    final useHeatPort=useHeatPort,
    final idealThyristor(off(start=offStart_p, fixed=fill(true, m))))
    "Thyristors conducting positive plug AC potentials"
  Modelica.Electrical.Polyphase.Ideal.IdealThyristor thyristor_n(
    final m=m,
    final Ron=fill(RonThyristor, m),
    final Goff=fill(GoffThyristor, m),
    final Vknee=fill(VkneeThyristor, m),
    final useHeatPort=useHeatPort,
    final idealThyristor(off(start=offStart_n, fixed=fill(true, m))))
    "Thyristors conducting negative plug AC potentials"
  Modelica.Electrical.Polyphase.Basic.Star star_p(final m=m)
  Modelica.Electrical.Polyphase.Basic.Star star_n(final m=m)
  Modelica.Thermal.HeatTransfer.Components.ThermalCollector
    thermalCollector(final m=m) if useHeatPort
equation
  if not useHeatPort then
    LossPower = sum(thyristor_p.idealThyristor.LossPower) + sum(thyristor_n.idealThyristor.LossPower);
  end if;
  connect(thyristor_p.plug_n, star_p.plug_p)
  connect(star_p.pin_n, dc_p)
  connect(heatPort, thermalCollector.port_b)
  connect(thermalCollector.port_a, thyristor_n.heatPort)
  connect(thyristor_p.heatPort, thermalCollector.port_a)
  connect(ac_p, thyristor_p.plug_p)
  connect(star_n.pin_n, dc_p)
  connect(thyristor_n.plug_p, ac_n)
  connect(thyristor_n.plug_n, star_n.plug_p)
  connect(andCondition_p.y, thyristor_p.fire)
  connect(andCondition_n.y, thyristor_n.fire)
end ThyristorCenterTap2mPulse;


Two pulse thyristor rectifier with center tap. General information about AC/DC converters can be found at the
AC/DC converter concept

within Modelica.Electrical.PowerConverters.ACDC;
model ThyristorCenterTap2Pulse
  "Two pulse thyristor rectifier with center tap"
  extends Icons.Converter;
  import Modelica.Constants.pi;
  parameter SI.Resistance RonThyristor(final min=0) = 1e-05
    "Closed thyristor resistance";
  parameter SI.Conductance GoffThyristor(final min=0) = 1e-05
    "Opened thyristor conductance";
  parameter SI.Voltage VkneeThyristor(final min=0) = 0
    "Thyristor forward threshold voltage";
  parameter Boolean offStart_p=true
    "Boolean start value of variable thyristor_p.off"
  parameter Boolean offStart_n=true
    "Boolean start value of variable thyristor_n.off"
  extends PowerConverters.Interfaces.ACDC.ACtwoPin;
  extends PowerConverters.Interfaces.ACDC.DCpin;
  extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(final T=
       293.15);
  extends Interfaces.Enable.Enable2;
  Modelica.Electrical.Analog.Ideal.IdealThyristor thyristor_p(
    final Ron=RonThyristor,
    final Goff=GoffThyristor,
    final Vknee=VkneeThyristor,
    final useHeatPort=useHeatPort,
    final off(start=offStart_p, fixed=true))
    "Thyristors conducting positive pin AC potentials"
  Modelica.Electrical.Analog.Ideal.IdealThyristor thyristor_n(
    final Ron=RonThyristor,
    final Goff=GoffThyristor,
    final Vknee=VkneeThyristor,
    final useHeatPort=useHeatPort,
    final off(start=offStart_n, fixed=true))
    "Thyristors conducting negative pin AC potentials"
equation
  if not useHeatPort then
    LossPower = thyristor_p.LossPower + thyristor_n.LossPower;
  end if;
  connect(ac_p, thyristor_p.p)
  connect(ac_n, thyristor_n.p)
  connect(thyristor_p.n, dc_p)
  connect(thyristor_n.n, dc_p)
  connect(thyristor_n.heatPort, heatPort)
  connect(thyristor_p.heatPort, heatPort)
  connect(andCondition_p.y, thyristor_p.fire)
  connect(andCondition_n.y, thyristor_n.fire)
end ThyristorCenterTap2Pulse;


m pulse thyristor rectifier with center tap. General information about AC/DC converters can be found at the
AC/DC converter concept

within Modelica.Electrical.PowerConverters.ACDC;
model ThyristorCenterTapmPulse
  "m pulse thyristor rectifier with center tap"
  extends Icons.Converter;
  import Modelica.Constants.pi;
  // parameter Integer m(final min=3) = 3 "Number of phases"
  parameter SI.Resistance RonThyristor(final min=0) = 1e-05
    "Closed thyristor resistance";
  parameter SI.Conductance GoffThyristor(final min=0) = 1e-05
    "Opened thyristor conductance";
  parameter SI.Voltage VkneeThyristor(final min=0) = 0
    "Thyristor forward threshold voltage";
  parameter Boolean offStart[m]=fill(true, m)
    "Boolean start value of variable thyristor_p[:].off"
  extends PowerConverters.Interfaces.ACDC.ACplug;
  extends PowerConverters.Interfaces.ACDC.DCpin;
  extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(final T=
       293.15);
  extends Interfaces.Enable.Enable1m;
  Modelica.Electrical.Polyphase.Ideal.IdealThyristor thyristor(
    final m=m,
    final Ron=fill(RonThyristor, m),
    final Goff=fill(GoffThyristor, m),
    final Vknee=fill(VkneeThyristor, m),
    final useHeatPort=useHeatPort,
    final idealThyristor(off(start=offStart, fixed=fill(true, m))))
    "Thyristors conducting AC potentials"
  Modelica.Electrical.Polyphase.Basic.Star star(final m=m)
  Modelica.Thermal.HeatTransfer.Components.ThermalCollector
    thermalCollector(final m=m) if useHeatPort
equation
  assert(mod(m, 2) == 1,
    "ThyristorCenterTapmPulse: only odd phase numbers are allowed");
  if not useHeatPort then
    LossPower = sum(thyristor.idealThyristor.LossPower);
  end if;
  connect(thyristor.plug_n, star.plug_p)
  connect(star.pin_n, dc_p)
  connect(heatPort, thermalCollector.port_b)
  connect(thyristor.heatPort, thermalCollector.port_a)
  connect(ac, thyristor.plug_p)
  connect(andCondition_p.y, thyristor.fire)
end ThyristorCenterTapmPulse;


PT1 + all-pass filter. First order filter with cut-off frequency fCut. The phase shift of the filter is compensated by a series of two first order all-pass filters tuned on supply frequency f.

within Modelica.Electrical.PowerConverters.ACDC.Control;
block Filter "PT1 + all-pass filter"
  extends Modelica.Blocks.Interfaces.SISO;
  import Modelica.Constants.pi;
  parameter SI.Frequency f=50 "Mains Frequency";
  parameter SI.Frequency fCut=2*f "Cut off frequency";
  final parameter Integer na(final min=2) = 2
    "Count of 1st order all-pass";
  final parameter SI.Frequency fa=f/tan(pi/na - atan(f/fCut)
      /(2*na)) "Characteristic frequency of all-pass filter";
  parameter Real yStart=0 "Start value of output";
  Modelica.Blocks.Continuous.FirstOrder firstOrder(
    final k=1,
    final T=1/(2*pi*fCut),
    initType=Modelica.Blocks.Types.Init.InitialOutput,
    y_start=yStart)
  Modelica.Blocks.Continuous.TransferFunction transferFunction[na](
    each final b={-1/(2*pi*fa),1},
    each final a={+1/(2*pi*fa),1},
    each initType=Modelica.Blocks.Types.Init.InitialOutput,
    each y_start=yStart)
equation
  for j in 1:na - 1 loop
    connect(transferFunction[j].y, transferFunction[j + 1].u);
  end for;
  connect(u, firstOrder.u)
  connect(firstOrder.y, transferFunction[1].u)
  connect(transferFunction[na].y, y)
end Filter;


Control components for rectifiers

within Modelica.Electrical.PowerConverters.ACDC;
package Control "Control components for rectifiers"
  extends Modelica.Icons.Package;
end Control;


Generic control of 2*m pulse rectifiers. General information about controllers is summarized in
Control.

within Modelica.Electrical.PowerConverters.ACDC.Control;
block Signal2mPulse "Generic control of 2*m pulse rectifiers"
  import Modelica.Constants.pi;
  extends PowerConverters.Icons.Control;
  parameter Integer m(final min=1) = 3 "Number of phases"
  parameter Boolean useConstantFiringAngle=true
    "Use constant firing angle instead of signal input";
  parameter SI.Angle constantFiringAngle=0 "Firing angle"
  parameter Boolean useFilter=true "Enable use of filter"
  parameter SI.Frequency f=50 "Frequency";
  parameter SI.Frequency fCut=2*f
    "Cut off frequency of filter"
  parameter SI.Voltage vStart[m]=zeros(m)
    "Start voltage of filter output"
  Modelica.Blocks.Interfaces.RealInput firingAngle(unit="rad") if not
    useConstantFiringAngle "Firing angle"
  parameter SI.Angle firingAngleMax(
    final min=0, final max=pi) = Modelica.Constants.pi
    "Maximum firing angle";
  parameter SI.Angle firingAngleMin(
    final min=0, final max=pi) = 0
    "Minimum firing angle";
  Modelica.Blocks.Sources.Constant constantconstantFiringAngle(final k=
        constantFiringAngle) if useConstantFiringAngle
  Modelica.Blocks.Logical.GreaterThreshold positiveThreshold[m](threshold=
       zeros(m))
  Modelica.Blocks.Logical.LessThreshold negativeThreshold[m](threshold=
        zeros(m))
  Modelica.Blocks.Logical.Timer timerPositive[m]
  Modelica.Blocks.Logical.Timer timerNegative[m]
  Modelica.Blocks.Logical.Greater greaterPositive[m]
  Modelica.Blocks.Logical.Greater greaterNegative[m]
  Modelica.Blocks.Interfaces.BooleanOutput fire_p[m]
  Modelica.Blocks.Interfaces.BooleanOutput fire_n[m]
  Modelica.Blocks.Math.Gain gain(final k=1/pi)
  Modelica.Blocks.Routing.Replicator replicator(final nout=m)
  Modelica.Blocks.Nonlinear.Limiter limiter(final uMax=min(firingAngleMax, pi),
      final uMin=max(firingAngleMin, 0))
  Modelica.Blocks.Interfaces.RealInput v[m](each unit="V") "Voltages"
  Filter filter[m](
    each final f=f,
    each final fCut=fCut,
    yStart=vStart) if useFilter
  Modelica.Blocks.Routing.RealPassThrough realPassThrough[m] if not
    useFilter "Pass through in case filter is off"
  Modelica.Blocks.Math.Gain gainPositive[m](each final k=2*f)
  Modelica.Blocks.Math.Gain gainNegative[m](each final k=2*f)
equation
  assert(firingAngleMax>firingAngleMin,
    "Signal2mPulse: firingAngleMax has to be greater than firingAngleMin");
  connect(positiveThreshold.y, timerPositive.u)
  connect(negativeThreshold.y, timerNegative.u)
  connect(greaterPositive.y, fire_p)
  connect(greaterNegative.y, fire_n)
  connect(gain.y, replicator.u)
  connect(replicator.y, greaterPositive.u2)
  connect(replicator.y, greaterNegative.u2)
  connect(limiter.y, gain.u)
  connect(firingAngle, limiter.u)
  connect(constantconstantFiringAngle.y, limiter.u)
  connect(v, filter.u)
  connect(filter.y, positiveThreshold.u)
  connect(filter.y, negativeThreshold.u)
  connect(realPassThrough.u, v)
  connect(realPassThrough.y, positiveThreshold.u)
  connect(realPassThrough.y, negativeThreshold.u)
  connect(timerPositive.y, gainPositive.u)
  connect(gainPositive.y, greaterPositive.u1)
  connect(gainNegative.y, greaterNegative.u1)
  connect(timerNegative.y, gainNegative.u)
end Signal2mPulse;


Control of 2*m pulse bridge rectifier. General information about controllers is summarized in
Control.

within Modelica.Electrical.PowerConverters.ACDC.Control;
model VoltageBridge2mPulse "Control of 2*m pulse bridge rectifier"
  import Modelica.Constants.pi;
  extends Icons.Control;
  parameter Integer m(final min=3) = 3 "Number of phases"
  parameter SI.Frequency f=50 "Frequency";
  parameter Boolean useConstantFiringAngle=true
    "Use constant firing angle instead of signal input";
  parameter SI.Angle constantFiringAngle=0 "Firing angle"
  parameter SI.Angle firingAngleMax(
    final min=0,
    final max=Modelica.Constants.pi) = Modelica.Constants.pi
    "Maximum firing angle";
  parameter Boolean useFilter=true "Enable use of filter"
  parameter SI.Frequency fCut=2*f
    "Cut off frequency of filter"
  parameter SI.Voltage vStart[m]=zeros(m)
    "Start voltage of filter output"
  Modelica.Blocks.Interfaces.RealInput firingAngle(unit="rad") if not
    useConstantFiringAngle "Firing angle"
  Signal2mPulse twomPulse(
    final useConstantFiringAngle=useConstantFiringAngle,
    final f=f,
    final constantFiringAngle=constantFiringAngle,
    final firingAngleMax=firingAngleMax,
    final m=m,
    useFilter=useFilter,
    final fCut=fCut,
    final vStart=vStart)
  Modelica.Electrical.Polyphase.Interfaces.PositivePlug ac(final m=m)
  Modelica.Electrical.Polyphase.Basic.MultiDelta delta(final m=m)
    "Delta connection"
  Modelica.Electrical.Polyphase.Sensors.VoltageSensor voltageSensor(
      final m=m) "Voltage sensor"
  Modelica.Blocks.Interfaces.BooleanOutput fire_p[m]
  Modelica.Blocks.Interfaces.BooleanOutput fire_n[m]
equation
  connect(ac, voltageSensor.plug_p)
  connect(voltageSensor.plug_p, delta.plug_n)
  connect(delta.plug_p, voltageSensor.plug_n)
  connect(voltageSensor.v, twomPulse.v)
  connect(firingAngle, twomPulse.firingAngle)
  connect(twomPulse.fire_n, fire_n)
  connect(twomPulse.fire_p, fire_p)
end VoltageBridge2mPulse;


Control of 2 pulse bridge rectifier. General information about controllers is summarized in
Control.

within Modelica.Electrical.PowerConverters.ACDC.Control;
model VoltageBridge2Pulse "Control of 2 pulse bridge rectifier"
  import Modelica.Constants.pi;
  extends Icons.Control;
  parameter SI.Frequency f=50 "Frequency";
  parameter Boolean useConstantFiringAngle=true
    "Use constant firing angle instead of signal input";
  parameter SI.Angle constantFiringAngle=0 "Firing angle"
  parameter SI.Angle firingAngleMax(
    final min=0,
    final max=Modelica.Constants.pi) = Modelica.Constants.pi
    "Maximum firing angle";
  parameter Boolean useFilter=true "Enable use of filter"
  parameter SI.Frequency fCut=2*f
    "Cut off frequency of filter"
  parameter SI.Voltage vStart=0
    "Start voltage of filter output"
  Modelica.Blocks.Interfaces.RealInput firingAngle(unit="rad") if not
    useConstantFiringAngle "Firing angle"
  Signal2mPulse twoPulse(
    final useConstantFiringAngle=useConstantFiringAngle,
    final f=f,
    final constantFiringAngle=constantFiringAngle,
    final firingAngleMax=firingAngleMax,
    final m=1,
    final useFilter=useFilter,
    final fCut=fCut,
    final vStart=fill(vStart, 1))
  Modelica.Electrical.Analog.Interfaces.PositivePin ac_p
  Modelica.Electrical.Analog.Interfaces.NegativePin ac_n
  Modelica.Electrical.Analog.Sensors.VoltageSensor voltageSensor
  Modelica.Blocks.Interfaces.BooleanOutput fire_p
  Modelica.Blocks.Interfaces.BooleanOutput fire_n
equation
  connect(voltageSensor.v, twoPulse.v[1])
  connect(voltageSensor.p, ac_p)
  connect(voltageSensor.n, ac_n)
  connect(firingAngle, twoPulse.firingAngle)
  connect(twoPulse.fire_n[1], fire_n)
  connect(twoPulse.fire_p[1], fire_p)
end VoltageBridge2Pulse;


Control of 2*m pulse center tap rectifier. General information about controllers is summarized in
Control.

within Modelica.Electrical.PowerConverters.ACDC.Control;
model VoltageCenterTap2mPulse "Control of 2*m pulse center tap rectifier"
  extends Icons.Control;
  import Modelica.Constants.pi;
  parameter Integer m(final min=3) = 3 "Number of phases"
  parameter SI.Frequency f=50 "Frequency";
  parameter Boolean useConstantFiringAngle=true
    "Use constant firing angle instead of signal input";
  parameter SI.Angle constantFiringAngle=0 "Firing angle"
  parameter SI.Angle firingAngleMax(
    final min=0,
    final max=Modelica.Constants.pi) = Modelica.Constants.pi
    "Maximum firing angle";
  parameter Boolean useFilter=true "Enable use of filter"
  parameter SI.Frequency fCut=2*f
    "Cut off frequency of filter"
  parameter SI.Voltage vStart[m]=zeros(m)
    "Start voltage of filter output"
  Modelica.Blocks.Interfaces.RealInput firingAngle(unit="rad") if not
    useConstantFiringAngle "Firing angle"
  Signal2mPulse twomPulse(
    final useConstantFiringAngle=useConstantFiringAngle,
    final f=f,
    final constantFiringAngle=constantFiringAngle,
    final firingAngleMax=firingAngleMax,
    final m=m,
    final useFilter=useFilter,
    final fCut=2*f,
    final vStart=vStart)
  Modelica.Electrical.Polyphase.Interfaces.PositivePlug ac(final m=m)
  Modelica.Blocks.Interfaces.BooleanOutput fire_p[m]
  Modelica.Blocks.Interfaces.BooleanOutput fire_n[m]
  Modelica.Electrical.Polyphase.Basic.MultiDelta delta(final m=m)
    "Delta connection"
  Modelica.Electrical.Polyphase.Sensors.PotentialSensor voltageSensor(
      final m=m) "Voltage sensor"
  Modelica.Blocks.Math.Gain gain[m](final k=fill(-1, m))
equation
  connect(firingAngle, twomPulse.firingAngle)
  connect(voltageSensor.plug_p, delta.plug_p)
  connect(ac, delta.plug_n)
  connect(gain.y, twomPulse.v)
  connect(voltageSensor.phi, gain.u)
  connect(twomPulse.fire_n, fire_n)
  connect(twomPulse.fire_p, fire_p)
end VoltageCenterTap2mPulse;


DC to AC converters

within Modelica.Electrical.PowerConverters;
package DCAC "DC to AC converters"
  extends Modelica.Icons.Package;
end DCAC;


Polyphase DC to AC converter. This is a polyphase two level inverter. The boolean signals fire_p[k] and fire_n[k] for any phase k shall not be true at the same time to avoid DC bus short circuits. The inverter consists of 2*m transistors and two anti parallel free wheeling diodes, respectively, where m is the number of phases.

within Modelica.Electrical.PowerConverters.DCAC;
model Polyphase2Level "Polyphase DC to AC converter"
  extends Modelica.Blocks.Icons.Block;
  extends Interfaces.Enable.Enable2m;
  parameter SI.Resistance RonTransistor=1e-05
    "Transistor closed resistance";
  parameter SI.Conductance GoffTransistor=1e-05
    "Transistor opened conductance";
  parameter SI.Voltage VkneeTransistor=0
    "Transistor threshold voltage";
  parameter SI.Resistance RonDiode=1e-05
    "Diode closed resistance";
  parameter SI.Conductance GoffDiode=1e-05
    "Diode opened conductance";
  parameter SI.Voltage VkneeDiode=0 "Diode threshold voltage";
  // parameter Boolean useEnable "Enables enable signal connector";
  extends PowerConverters.Interfaces.DCAC.DCtwoPin;
  extends PowerConverters.Interfaces.DCAC.ACplug;
  extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(final T=
       293.15);
  Modelica.Electrical.Polyphase.Ideal.IdealGTOThyristor transistor_p(
    final m=m,
    final Ron=fill(RonTransistor, m),
    final Goff=fill(GoffTransistor, m),
    final Vknee=fill(VkneeTransistor, m),
    final useHeatPort=useHeatPort)
  Modelica.Electrical.Polyphase.Ideal.IdealDiode diode_p(
    final m=m,
    final Ron=fill(RonDiode, m),
    final Goff=fill(GoffDiode, m),
    final Vknee=fill(VkneeDiode, m),
    final useHeatPort=useHeatPort)
  Modelica.Electrical.Polyphase.Basic.Star star_p(final m=m)
  Modelica.Electrical.Polyphase.Ideal.IdealGTOThyristor transistor_n(
    final m=m,
    final Ron=fill(RonTransistor, m),
    final Goff=fill(GoffTransistor, m),
    final Vknee=fill(VkneeTransistor, m),
    final useHeatPort=useHeatPort)
  Modelica.Electrical.Polyphase.Ideal.IdealDiode diode_n(
    final m=m,
    final Ron=fill(RonDiode, m),
    final Goff=fill(GoffDiode, m),
    final Vknee=fill(VkneeDiode, m),
    final useHeatPort=useHeatPort)
  Modelica.Electrical.Polyphase.Basic.Star star_n(final m=m)
  Modelica.Thermal.HeatTransfer.Components.ThermalCollector
    thermalCollector(final m=m) if useHeatPort
equation
  if not useHeatPort then
    LossPower = sum(transistor_p.idealGTOThyristor.LossPower) + sum(diode_n.idealDiode.LossPower)
       + sum(transistor_n.idealGTOThyristor.LossPower) + sum(diode_n.idealDiode.LossPower);
  end if;
  connect(transistor_p.plug_p, star_p.plug_p)
  connect(star_p.plug_p, diode_p.plug_n)
  connect(transistor_n.plug_n, star_n.plug_p)
  connect(star_n.plug_p, diode_n.plug_p)
  connect(transistor_p.plug_n, diode_p.plug_p)
  connect(transistor_n.plug_p, diode_n.plug_n)
  connect(star_n.pin_n, dc_n)
  connect(dc_p, star_p.pin_n)
  connect(transistor_p.plug_n, ac)
  connect(transistor_n.plug_p, ac)
  connect(heatPort, thermalCollector.port_b)
  connect(thermalCollector.port_a, transistor_n.heatPort)
  connect(diode_n.heatPort, thermalCollector.port_a)
  connect(transistor_p.heatPort, thermalCollector.port_a)
  connect(diode_p.heatPort, thermalCollector.port_a)
  connect(andCondition_p.y, transistor_p.fire)
  connect(andCondition_n.y, transistor_n.fire)
end Polyphase2Level;