within PowerGrids.Electrical.Test;

model SynchronousMachine4WindingsNoLoadAccurate
  extends Modelica.Icons.Example;
  PowerGrids.Electrical.Buses.InfiniteBus bus(PStart = 0, SNom = 5.5e+08, UNom = 24000, UStart = 24000, X = 0, portVariablesPhases = true, portVariablesPu = true, theta = 0)
  PowerGrids.Electrical.Machines.SynchronousMachine4Windings machine(H = 6, PStart = 0, QStart = 0, SNom = 5.5e+08, Tpd0 = 8, Tppd0 = 0.03, Tppq0 = 0.07, Tpq0 = 1, UNom = 24000, UStart = 24000, excitationPuType = PowerGrids.Types.Choices.ExcitationPuType.nominalStatorVoltageNoLoad, portVariablesPhases = true, raPu = 0.003, timeConstApprox = PowerGrids.Types.Choices.TimeConstantsApproximation.accurateEstimation, xdPu = 1.81, xlPu = 0.15, xpdPu = 0.3, xppdPu = 0.23, xppqPu = 0.25, xpqPu = 0.65, xqPu = 1.76)
  inner PowerGrids.Electrical.System systemPowerGrids(fNom = 50)
  Modelica.Blocks.Sources.Step PmPu(height = 0.0, offset = 0.0, startTime = 50)
  Modelica.Blocks.Sources.Step ufPu(height = 0, offset = 1)
equation
  connect(bus.terminal, machine.terminal)
  connect(ufPu.y, machine.ufPuIn)
  connect(PmPu.y, machine.PmPu)
end SynchronousMachine4WindingsNoLoadAccurate;


within PowerGrids.Electrical.Test;

model SynchronousMachine4WindingsNoLoadExact
  extends Modelica.Icons.Example;
  PowerGrids.Electrical.Buses.InfiniteBus bus(PStart = 0, SNom = 5.5e+08, UNom = 24000, UStart = 24000, X = 0, portVariablesPhases = true, portVariablesPu = true, theta = 0)
  PowerGrids.Electrical.Machines.SynchronousMachine4Windings machine(H = 6, PStart = 0, QStart = 0, SNom = 5.5e+08, Tpd0 = 8, Tppd0 = 0.03, Tppq0 = 0.07, Tpq0 = 1, UNom = 24000, UStart = 24000, excitationPuType = PowerGrids.Types.Choices.ExcitationPuType.nominalStatorVoltageNoLoad, portVariablesPhases = true, raPu = 0.003, timeConstApprox = PowerGrids.Types.Choices.TimeConstantsApproximation.exactComputation, xdPu = 1.81, xlPu = 0.15, xpdPu = 0.3, xppdPu = 0.23, xppqPu = 0.25, xpqPu = 0.65, xqPu = 1.76)
  inner PowerGrids.Electrical.System systemPowerGrids(fNom = 50)
  Modelica.Blocks.Sources.Step PmPu(height = 0.0, offset = 0.0, startTime = 50)
  Modelica.Blocks.Sources.Step ufPu(height = 0, offset = 1)
equation
  connect(bus.terminal, machine.terminal)
  connect(ufPu.y, machine.ufPuIn)
  connect(PmPu.y, machine.PmPu)
end SynchronousMachine4WindingsNoLoadExact;


--daeMode -d=initialization,evaluateAllParameters.

within PowerGrids.Electrical.Test;

model SynchronousMachine4WindingsPowerSwing
  extends Modelica.Icons.Example;
  PowerGrids.Electrical.Buses.InfiniteBus bus(SNom = 5.5e+08, UNom = 24000, UStart = 24000, X = 0, portVariablesPhases = true, portVariablesPu = true, theta = 0)
  PowerGrids.Electrical.Machines.SynchronousMachine4Windings machine(H = 6, PStart = -4.95e+08, QStart = -2.5e+08, SNom = 5.5e+08, Tpd0 = 8, Tppd0 = 0.03, Tppq0 = 0.07, Tpq0 = 1, UNom = 24000, UStart = 24000, excitationPuType = PowerGrids.Types.Choices.ExcitationPuType.nominalStatorVoltageNoLoad, portVariablesPhases = true, raPu = 0, timeConstApprox = PowerGrids.Types.Choices.TimeConstantsApproximation.exactComputation, xdPu = 1.81, xlPu = 0.15, xpdPu = 0.3, xppdPu = 0.23, xppqPu = 0.25, xpqPu = 0.65, xqPu = 1.76)
  inner PowerGrids.Electrical.System systemPowerGrids
  Modelica.Blocks.Sources.Step PmPu(height = 0.0, offset = 0.9, startTime = 0)
  Modelica.Blocks.Sources.Step ufPu(height = 0, offset = machine.ufPuInStart)
  PowerGrids.Electrical.Branches.LineConstantImpedance line(PStartA = 0, PStartB = 0, R = 0, SNom = 1e+08, UNom = 24000, X = 1, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Loads.LoadPQVoltageDependenceInputs load(PStart = 4.95e+08, QStart = 2.5e+08, SNom = 5.5e+08, UNom = 24000, UPhaseStart = 0.680678, portVariablesPhases = true)
  Modelica.Blocks.Sources.Step P(height = -10e6, offset = 495e6, startTime = 1)
  Modelica.Blocks.Sources.Step Q(height = 0, offset = 250e6)
equation
  connect(ufPu.y, machine.ufPuIn)
  connect(machine.terminal, line.terminalA)
  connect(line.terminalB, bus.terminal)
  connect(Q.y, load.QRefIn)
  connect(PmPu.y, machine.PmPu)
  connect(load.terminal, machine.terminal)
  connect(P.y, load.PRefIn)
end SynchronousMachine4WindingsPowerSwing;


Test case EquivalentGrid model.

within PowerGrids.Electrical.Test;

model TestEquivalentGrid "Test case EquivalentGrid model"
  extends Modelica.Icons.Example;
  import Modelica.ComplexMath;
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.Buses.InfiniteBus voltageSource( SNom = 5e+08, UNom = 380000, URef = 380000, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Branches.LineConstantImpedance equivalentLine(R = 6.32207, SNom = 5e+08, UNom = 380000, X = 63.2207, portVariablesPhases = true, portVariablesPu = true)
  Buses.EquivalentGrid equivalentGrid(R_X = 1 / 10, SNom = 5e+08, SSC = 2.5e+09, UNom = 380000, URef = 1.050 * 380e3, c = 1.1, portVariablesPhases = true, portVariablesPu = true)
  Buses.Ground ground
  Loads.LoadPQVoltageDependence load(PRefConst = 1e+07, QRefConst = 2e+07, SNom = 5e+08, UNom = 380000, portVariablesPhases = true)
  Modelica.Blocks.Sources.RealExpression shortCircuitCapacity(y = ComplexMath.'abs'(equivalentLine.portB.S) * equivalentGrid.c)
equation
  connect(load.terminal, equivalentGrid.terminal)
  connect(ground.terminal, equivalentLine.terminalA)
  connect(equivalentLine.terminalB, voltageSource.terminal)
end TestEquivalentGrid;


within PowerGrids.Electrical.Test;
model TestExciterRectifierRegulationCharacteristicIEEE
  extends Modelica.Icons.Example;
  PowerGrids.Electrical.Controls.ExcitationSystems.BaseClasses.ExciterRectifierRegulationCharacteristicEquationsIEEE exciterRectifierRegulationCharacteristicIEEE
  Modelica.Blocks.Sources.RealExpression realExpression(y = time)
equation
  connect(realExpression.y, exciterRectifierRegulationCharacteristicIEEE.u)
end TestExciterRectifierRegulationCharacteristicIEEE;


within PowerGrids.Electrical.Test;

model TestExciterVoltageTransducerIEEE
  extends Modelica.Icons.Example;
  Modelica.ComplexBlocks.Sources.ComplexConstant V(k.re = -1, k.im = 1)
  Modelica.ComplexBlocks.Sources.ComplexConstant I(k.re = 1, k.im = 1)
  PowerGrids.Electrical.VoltageTransducers.ExciterVoltageTransducerIEEE exciterVoltageTransducerIEEE(ki = 1,kp = sqrt(2), thetap = 0.785398, xl = 1)
equation
  connect(I.y, exciterVoltageTransducerIEEE.It)
  connect(V.y, exciterVoltageTransducerIEEE.Vt)
end TestExciterVoltageTransducerIEEE;


Same behaviour as <a href=\.

within PowerGrids.Electrical.Test;
model TestOneBusTransmissionLineWithBreakersOneLoad
  extends Modelica.Icons.Example;
  PowerGrids.Electrical.Buses.InfiniteBus infiniteBus(SNom = 1e+07, UNom = 10000, portVariablesPu = true, theta = 0.523599)
  PowerGrids.Electrical.Loads.LoadPQVoltageDependence loadPQ(PRefConst = 1e+07, QRefConst = 0, SNom = 1e+07, UNom = 10000, alpha = 0, beta = 0, portVariablesPhases = true)
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.Branches.LineConstantImpedanceWithBreakers transmissionLine(B = 0.02, G = 0.01,R = 0.3, SNom = 1e+07, UNom = 10000, X = 1.5, portVariablesPu = true)
equation
  connect(infiniteBus.terminal, transmissionLine.terminalA)
  connect(transmissionLine.terminalB, loadPQ.terminal)

end TestOneBusTransmissionLineWithBreakersOneLoad;


Time lag before changing the first tap.

within PowerGrids.Electrical.Test;

model TestTapChangerLogicInterval
  extends Modelica.Icons.Example;
  extends PowerGrids.Electrical.Branches.BaseClasses.TapChangerPhaseShifterLogicInterval
    (t1st = 3 "Time lag before changing the first tap",
    tNext = 2 "Time lag before changing subsequent taps",
    tapMin = 1 "Minimum tap",
    tapMax = 20 "Maximum tap",
    Ntap = 20 "Number of taps",
    actionSel = ActionType.direct "Tap direct or reverse action selector",
    lockedStart = false "Wether the tap-changer/phase-shifter is initially locked",
    runningStart = true "Wether the tap-changer/phase-shifter is initially running",
    tapStart = 10 "Initial tap",
    stateStart = State.standard "Initial state",
    tToStandardState = 2 "Time lag before transition to standard state, in order to avoid chattering");
    Real U = sin(2*Modelica.Constants.pi*time/40) "Monitored Value";
    Real Umin = -0.5;
    Real Umax = 0.5;
equation
  locked = time < 20;
  running = true;
  valueAboveMax = U > Umax;
  valueUnderMin = U < Umin;
end TestTapChangerLogicInterval;


Time lag before changing the first tap.

within PowerGrids.Electrical.Test;
model TestTapChangerLogicMax
  extends Modelica.Icons.Example;
  extends PowerGrids.Electrical.Branches.BaseClasses.TapChangerPhaseShifterLogicMax(
    t1st = 3 "Time lag before changing the first tap",
    tNext = 1 "Time lag before changing subsequent taps",
    Ntap = 10 "Number of taps",
    actionSel = ActionType.direct "Tap direct or reverse action selector",
    lockedStart = false "Wether the tap-changer/phase-shifter is initially locked",
    runningStart = true "Wether the tap-changer/phase-shifter is initially running",
    tapStart = 10 "Initial tap",
    stateStart = State.standard "Initial state");
equation
  locked = time >= 5 and time < 8;
  running = true;
  valueUnderStop = time >= 15.5;
  valueAboveMax = time >= 1 and time < 10;
end TestTapChangerLogicMax;


within PowerGrids.Electrical.Test;

model TestTerminalVoltageTransducerIEEE
  extends Modelica.Icons.Example;
  PowerGrids.Electrical.VoltageTransducers.TerminalVoltageTransducerIEEE terminalVoltageTransducer(Rc = 1, Xc = 1, Tr = 1, initType = Modelica.Blocks.Types.Init.InitialOutput)
  Modelica.ComplexBlocks.Sources.ComplexConstant V(k.re = -1, k.im = 1)
  Modelica.ComplexBlocks.Sources.ComplexConstant I(k.re = 1, k.im = 1)
equation
  connect(I.y, terminalVoltageTransducer.It)
  connect(V.y, terminalVoltageTransducer.Vt)
end TestTerminalVoltageTransducerIEEE;


Similar to <a href=\.

within PowerGrids.Electrical.Test;

model TestTransformerFixedRatio
  extends Modelica.Icons.Example;
  PowerGrids.Electrical.Buses.InfiniteBus infiniteBus(SNom = 1e+07, UNom = 5000, portVariablesPu = true, theta = 0.523599)
  PowerGrids.Electrical.Loads.LoadPQVoltageDependence loadPQ(PRefConst = 1e+07, QRefConst = 0, SNom = 1e+07, UNom = 10000, alpha = 0, beta = 0, portVariablesPhases = true)
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.Branches.TransformerFixedRatio transformer(R = 0.3, SNom = 1e+07, UNomA = 5000, UNomB = 10000, X = 1.5, portVariablesPu = true, rFixed = 2)
equation
  connect(infiniteBus.terminal, transformer.terminalA)
  connect(transformer.terminalB, loadPQ.terminal)
end TestTransformerFixedRatio;


Similar to <a href=\.

within PowerGrids.Electrical.Test;

model TestTransformerFixedRatioWithBreaker
  extends Modelica.Icons.Example;
  PowerGrids.Electrical.Buses.InfiniteBus infiniteBus1(SNom = 1e+07, UNom = 5000, portVariablesPu = true, theta = 0.523599)
  PowerGrids.Electrical.Loads.LoadPQVoltageDependence loadPQ(PRefConst = 1e+07, QRefConst = 0, SNom = 1e+07, UNom = 10000, alpha = 0, beta = 0, portVariablesPhases = true)
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.Branches.TransformerFixedRatioWithBreaker transformer(B = 1e-6, G = 1e-6,R = 0.3, SNom = 1e+07, UNomA = 5000, UNomB = 10000, X = 1.5, portVariablesPu = true, rFixed = 2, useBreaker = true)
  Modelica.Blocks.Sources.BooleanExpression breakerState(y = time < 2)
  PowerGrids.Electrical.Buses.InfiniteBus infiniteBus2(SNom = 1e+07, UNom = 10000, portVariablesPu = true, theta = 0.523599)
  Branches.LineConstantImpedance line(R = 0.06, SNom = 1e+7, UNom = 10000, X = 1.5)
equation
  connect(infiniteBus1.terminal, transformer.terminalA)
  connect(transformer.terminalB, loadPQ.terminal)
  connect(breakerState.y, transformer.breakerStatusIn)
  connect(loadPQ.terminal, line.terminalA)
  connect(line.terminalB, infiniteBus2.terminal)
end TestTransformerFixedRatioWithBreaker;


within PowerGrids.Electrical.Test;

model TestTransformerWithTapChangerInterval
  extends Modelica.Icons.Example;
  PowerGrids.Electrical.Buses.InfiniteBusVariableVoltage infiniteBus(R = 0, SNom = 1e+06, UNom = 1000, X = 0, useUIn = true)
  PowerGrids.Electrical.Branches.TransformerWithTapChangerInterval trafo(B = 0, G = 0, K = {2, 3, 4, 5, 6}, Ntap = 5, R = 1, SNom = 1e+06, UMax = 4000, UMin = 2000, UNomA = 1000, UNomB = 1000, X = 1, actionSel = PowerGrids.Electrical.Branches.TransformerWithTapChangerInterval.ActionType.direct, portVariablesPu = true, t1st = 1, tNext = 0.1, tapStart = 2)
  PowerGrids.Electrical.Buses.InfiniteBus busLoad(R = 1000, SNom = 1e+06, UNom = 1000, X = 0, theta = 0)
  Modelica.Blocks.Sources.RealExpression Uset(y = 500 * (sin(6.28 * time / 40) + 2))
  inner PowerGrids.Electrical.System systemPowerGrids
equation
  connect(Uset.y, infiniteBus.UIn)
  connect(trafo.terminalB, busLoad.terminal)
  connect(infiniteBus.terminal, trafo.terminalA)
end TestTransformerWithTapChangerInterval;


within PowerGrids.Electrical.Test;

model TestTransformerWithTapChangerMax
  extends Modelica.Icons.Example;
  PowerGrids.Electrical.Buses.InfiniteBusVariableVoltage infiniteBus(R = 0, SNom = 1e+06, UNom = 1000, X = 0, portVariablesPu = true, useUIn = true)
  PowerGrids.Electrical.Branches.TransformerWithTapChangerMax trafo(B = 0, G = 0, K = {1, 2, 3, 4, 5}, Ntap = 5, R = 1, SNom = 1e+06, UMax = 4500, UNomA = 1000, UNomB = 1000, UStop = 2600, X = 1, actionSel = PowerGrids.Electrical.Branches.TransformerWithTapChangerInterval.ActionType.direct, portVariablesPu = true, t1st = 1, tNext = 2, tapStart = 5)
  PowerGrids.Electrical.Buses.InfiniteBus busLoad(R = 1000, SNom = 1e+06, UNom = 1000, X = 0, portVariablesPu = true, theta = 0)
  Modelica.Blocks.Sources.RealExpression Uset(y = 500 * (sin(6.28 * time / 40) + 1))
  inner PowerGrids.Electrical.System systemPowerGrids
equation
  connect(Uset.y, infiniteBus.UIn)
  connect(trafo.terminalB, busLoad.terminal)
  connect(infiniteBus.terminal, trafo.terminalA)
end TestTransformerWithTapChangerMax;


<span style=\.

within PowerGrids.Electrical.Test;
model TestTwoBusesTwoLinesOneLoadOneBreakerOpenClosePortA
  extends TestTwoBusesTwoTransmLinesWithBreakersOneLoad(transmissionLine2.useBreakerA = true);
  Modelica.Blocks.Sources.BooleanExpression BreakerStatus(y = time < 1 or time >= 10)
equation
  connect(BreakerStatus.y, transmissionLine2.breakerStatusA)

end TestTwoBusesTwoLinesOneLoadOneBreakerOpenClosePortA;


<p style=\.

within PowerGrids.Electrical.Test;
model TestTwoBusesTwoLinesOneLoadOneBreakerOpenClosePortB
  extends TestTwoBusesTwoTransmLinesWithBreakersOneLoad(transmissionLine1.useBreakerB = true);
  Modelica.Blocks.Sources.BooleanExpression BreakerStatus(y = time < 1 or time >= 10)
equation
  connect(transmissionLine1.breakerStatusB, BreakerStatus.y)

end TestTwoBusesTwoLinesOneLoadOneBreakerOpenClosePortB;


<p style=\.

within PowerGrids.Electrical.Test;
model TestTwoBusesTwoLinesOneLoadOneBreakerOpenClosePortsAB
  extends TestTwoBusesTwoTransmLinesWithBreakersOneLoad(transmissionLine1.useBreakerB = true, transmissionLine1.portVariablesPu = true, transmissionLine1.useBreakerA = true, transmissionLine2.portVariablesPu = true, transmissionLine2.useBreakerA = true, transmissionLine2.useBreakerB = true);
  Modelica.Blocks.Sources.BooleanExpression BreakerStatusLine1AB(y = time < 1 or time >= 2)
  Modelica.Blocks.Sources.BooleanExpression BreakerStatusLine2A(y = time < 3 or time >= 5)
  Modelica.Blocks.Sources.BooleanExpression BreakerStatusLine2B(y = time < 4 or time >= 5)
equation
  connect(BreakerStatusLine2B.y, transmissionLine2.breakerStatusB)
  connect(BreakerStatusLine2A.y, transmissionLine2.breakerStatusA)
  connect(BreakerStatusLine1AB.y, transmissionLine1.breakerStatusB)
  connect(BreakerStatusLine1AB.y, transmissionLine1.breakerStatusA)

end TestTwoBusesTwoLinesOneLoadOneBreakerOpenClosePortsAB;


<span style=\.

within PowerGrids.Electrical.Test;
model TestTwoBusesTwoTransmLinesWithBreakersOneLoad
  extends Modelica.Icons.Example;
  PowerGrids.Electrical.Buses.InfiniteBus infiniteBus1(SNom = 1e+07, UNom = 10000, portVariablesPu = true, theta = 0.523599)
  PowerGrids.Electrical.Loads.LoadPQVoltageDependence loadPQ(PRefConst = 1e+07, QRefConst = 0, SNom = 1e+07, UNom = 10000, alpha = 0, beta = 0, portVariablesPhases = true)
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.Branches.LineConstantImpedanceWithBreakers transmissionLine1(B = 0.02, G = 0.01,R = 0.3, SNom = 1e+07, UNom = 10000, X = 1.5, portVariablesPu = true)
  PowerGrids.Electrical.Branches.LineConstantImpedanceWithBreakers transmissionLine2(B = 0.02, G = 0.01,R = 0.3, SNom = 1e+07, UNom = 10000, X = 1.5, portVariablesPu = true)
  PowerGrids.Electrical.Buses.InfiniteBus infiniteBus2(SNom = 1e+07, UNom = 10000, portVariablesPu = true, theta = 0.523599)
equation
  connect(transmissionLine2.terminalB, infiniteBus2.terminal)
  connect(loadPQ.terminal, transmissionLine2.terminalA)
  connect(transmissionLine1.terminalB, loadPQ.terminal)
  connect(infiniteBus1.terminal, transmissionLine1.terminalA)

end TestTwoBusesTwoTransmLinesWithBreakersOneLoad;


This model demonstrates the dissipation of reactive power of a purely inductive transmission line, connected to two infinite buses, one with a phase-to-phase voltage U = 10 kV, one with a phase-to-phase voltage U = 9 kV, both with a 30 deg phase. The reactance of each conductor is 1 Ohm.

As a consequence, the current flowing in each conductor is

I = (VA - VB)/X = ((UA-UB)/sqrt3)/X = 577.35 A.

The active power flow in the line is zero. The reactive power entering the line from portA is

3*VA*I' = UA*(UA - UB)*X = 10 MW

while the reactive power dissipated by the transmission line is

portA.P + portB.P = 3*(VA - VB)*I = (UA - UB)^2/R = 1 MW

By choosing a base power of 10 MW and a base voltage of 10 kV, the current flowing through the line is 1 p.u., the active power entering portA of the line is 1 p.u. and the active power leaving portB of the line is 0.9 p.u. All currents and voltages have 30 deg phase.

.

within PowerGrids.Electrical.Test;

model TwoBusesInductiveTransmissionLine
  extends Modelica.Icons.Example;
  PowerGrids.Electrical.Buses.InfiniteBus infiniteBusA(SNom = 1e+07, UNom = 10000, portVariablesPu = true, theta = 0.523599)
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.Branches.LineConstantImpedance transmissionLine(R = 0, SNom = 1e+07, UNom = 10000, X = 1, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Buses.InfiniteBus infiniteBusB(SNom = 1e+07, UNom = 9000, portVariablesPu = true, theta = 0.523599)
equation
  connect(infiniteBusA.terminal, transmissionLine.terminalA)
  connect(transmissionLine.terminalB, infiniteBusB.terminal)
end TwoBusesInductiveTransmissionLine;


This model demonstrates the transmission of active power through a purely inductive transmission line, connected to two infinite buses with a phase-to-phase voltage of 10 kV. The generator at portA of the line has 30 deg phase, the other one has 0 deg phase. The reactance of each conductor is 1 Ohm.

The active power flow from portA to portB is

P = 3(VA*VB)/X*sin(delta)= UA*UB/X*sin(delta) = 50 MW.

By choosing a base power of 100 MW and a base voltage of 10 kV, the active power flow from portA to portB is 0.5 p.u.

.

within PowerGrids.Electrical.Test;

model TwoBusesPowerTransferTransmissionLine
  extends Modelica.Icons.Example;
  PowerGrids.Electrical.Buses.InfiniteBus infiniteBusA(SNom = 1e+08, UNom = 10000, portVariablesPhases = true, portVariablesPu = true, theta = 0.523599)
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.Branches.LineConstantImpedance transmissionLine(R = 0, SNom = 1e+08, UNom = 10000, X = 1, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Buses.InfiniteBus infiniteBusB(SNom = 1e+08, UNom = 10000, portVariablesPhases = true, portVariablesPu = true, theta = 0)
equation
  connect(infiniteBusA.terminal, transmissionLine.terminalA)
  connect(transmissionLine.terminalB, infiniteBusB.terminal)
end TwoBusesPowerTransferTransmissionLine;


This model demonstrates the dissipation of active power of a purely resistive transmission line, connected to two infinite buses, one with a phase-to-phase voltage U = 10 kV, one with a phase-to-phase voltage U = 9 kV, both with a 30 deg phase. The resistance of each conductor is 1 Ohm.

As a consequence, the current flowing in each conductor is

I = (VA - VB)/R = ((UA-UB)/sqrt3)/R = 577.35 A.

The reactive power flow in the line is zero. The active power entering the line from portA is

3*VA*I = UA*(UA - UB)/R = 10 MW

while the active power dissipated by the transmission line is

portA.P + portB.P = 3*(VA - VB)*I = (UA - UB)^2/R = 1 kW

By choosing a base power of 10 MW and a base voltage of 10 kV, the current flowing through the line is 1 p.u., the active power entering portA of the line is 1 p.u. and the active power leaving portB of the line is 0.9 p.u. All currents and voltages have 30 deg phase.

.

within PowerGrids.Electrical.Test;

model TwoBusesResistiveTransmissionLine
  extends Modelica.Icons.Example;
  PowerGrids.Electrical.Buses.InfiniteBus infiniteBusA(SNom = 1e+07, UNom = 10000, portVariablesPu = true, theta = 0.523599)
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.Branches.LineConstantImpedance transmissionLine(R = 1, SNom = 1e+07, UNom = 10000, X = 0, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Buses.InfiniteBus infiniteBusB(SNom = 1e+07, UNom = 9000, portVariablesPu = true, theta = 0.523599)
equation
  connect(infiniteBusA.terminal, transmissionLine.terminalA)
  connect(transmissionLine.terminalB, infiniteBusB.terminal)
end TwoBusesResistiveTransmissionLine;


This model demonstrates the behaviour of a purely resistive transmission line with a purely resistive intermediate fault.

At the beginning of the transient, a current flows from bus A (phase to phase voltage 10 kV) to bus B (phase-to-phase voltage 9 kV) through a resistance of 1 Ohm.

As a consequence, the current flowing in each conductor is

I = (VA - VB)/R = ((UA-UB)/sqrt3)/R = 577.35 A.

When the fault is activated, the analytical computation of the current flowing into the fault yields a current of 10.5215 kA, which corresponds to the simulation result.

At time = 0.6 the fault is cleared and the current through the line returns to the original value.

.

within PowerGrids.Electrical.Test;

model TwoBusesResistiveTransmissionLineFault
  extends Modelica.Icons.Example;
  PowerGrids.Electrical.Buses.InfiniteBus infiniteBusA(SNom = 1e+07, UNom = 10000, portVariablesPu = true, theta = 0.523599)
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.Branches.LineConstantImpedanceFault transmissionLine(R = 1, RFault = 0.3, SNom = 1e+07, UNom = 10000, X = 0, XFault = 0, faultLocationPu = 0.7, portVariablesPhases = true, portVariablesPu = true, startTime = 0.4, stopTime = 0.6)
  PowerGrids.Electrical.Buses.InfiniteBus infiniteBusB(SNom = 1e+07, UNom = 9000, portVariablesPu = true, theta = 0.523599)
equation
  connect(infiniteBusA.terminal, transmissionLine.terminalA)
  connect(transmissionLine.terminalB, infiniteBusB.terminal)
end TwoBusesResistiveTransmissionLineFault;


This model demonstrates the effect of the shunt admittance of the transmission line, connected to two infinite buses, with phase-to-phase voltage U = 10 kV and 30 deg phase. The line resistance is very high, so there is practically no current flowing through. The shunt admittance and susceptance are both 0.01 Ohm.

As a consequence, the two currents flowing into the line from each port are rotated by 45 deg with respect to the 30 deg voltage angle. The active power on each side is 0.5 MW and the reactive power is -0.5 MVA, which correspond to 0.05 and -0.05 pu with the chosen base quantities.

.

within PowerGrids.Electrical.Test;

model TwoBusesShuntTransmissionLine
  extends Modelica.Icons.Example;
  PowerGrids.Electrical.Buses.InfiniteBus infiniteBusA(SNom = 1e+07, UNom = 10000, portVariablesPu = true, theta = 0.523599)
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.Branches.LineConstantImpedance transmissionLine(B = 0.01, G = 0.01, R = 1e8, SNom = 1e+07, UNom = 10000, X = 0, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Buses.InfiniteBus infiniteBusB(SNom = 1e+07, UNom = 10000, portVariablesPu = true, theta = 0.523599)
equation
  connect(infiniteBusA.terminal, transmissionLine.terminalA)
  connect(transmissionLine.terminalB, infiniteBusB.terminal)
end TwoBusesShuntTransmissionLine;


Exciter voltage transducer.

within PowerGrids.Electrical.VoltageTransducers;
model ExciterVoltageTransducerIEEE "Exciter voltage transducer"
  parameter SI.PerUnit kp = 9.3"First potential circuit gain";
  parameter SI.Angle thetap = 0 "Potential circuit phase angle Thetap";
  parameter SI.PerUnit ki = 0 "Second potential circuit gain coefficient";
  parameter SI.PerUnit xl = 0.124 "Reactance associated with potential source";
  Modelica.ComplexBlocks.Interfaces.ComplexInput Vt
  Modelica.ComplexBlocks.Interfaces.ComplexInput It
  Modelica.Blocks.Interfaces.RealOutput Ve
  Modelica.Blocks.Sources.Constant constKp(k = kp)
  Modelica.Blocks.Sources.Constant constThetap(k = thetap)
  Modelica.ComplexBlocks.ComplexMath.Add add1
  Modelica.ComplexBlocks.ComplexMath.ComplexToPolar complexToPolar
  Modelica.ComplexBlocks.ComplexMath.PolarToComplex complexKp
  Modelica.ComplexBlocks.ComplexMath.Gain gainXl(k.re = 0, k.im = xl)
  Modelica.ComplexBlocks.ComplexMath.Gain J(k.re = 0, k.im = 1)
  Modelica.ComplexBlocks.ComplexMath.Product prod1
  Modelica.ComplexBlocks.ComplexMath.Add add2
  Modelica.ComplexBlocks.ComplexMath.Product prod2
  Modelica.ComplexBlocks.Sources.ComplexConstant constKi(k.re = ki, k.im = 0)
equation
  connect(constKi.y, add1.u2)
  connect(Vt, prod2.u1)
  connect(complexToPolar.len, Ve)
  connect(add2.y, complexToPolar.u)
  connect(prod1.y, add2.u2)
  connect(prod2.y, add2.u1)
  connect(complexKp.y, prod2.u2)
  connect(It, prod1.u2)
  connect(J.y, prod1.u1)
  connect(add1.y, J.u)
  connect(gainXl.y, add1.u1)
  connect(complexKp.y, gainXl.u)
  connect(constThetap.y, complexKp.phi)
  connect(constKp.y, complexKp.len)
end ExciterVoltageTransducerIEEE;


Voltage transducer models

within PowerGrids.Electrical;
package VoltageTransducers "Voltage transducer models"
  extends Modelica.Icons.Package;
end VoltageTransducers;


Terminal voltage transducer IEEE.

within PowerGrids.Electrical.VoltageTransducers;
model TerminalVoltageTransducerIEEE "Terminal voltage transducer IEEE"
  parameter Modelica.SIunits.Time Tr = 0 "Transducer time constant";
  parameter Modelica.SIunits.PerUnit Rc = 0 "Load compensation resistance";
  parameter Modelica.SIunits.PerUnit Xc = 0 "Load compensation reactance";
  parameter Modelica.Blocks.Types.Init initType=Modelica.Blocks.Types.Init.NoInit "Type of initialization (1: no init, 2: steady state, 3/4: initial output)"
  parameter Real yStart=0 "Initial or guess value of output (= state)"
  Modelica.ComplexBlocks.Interfaces.ComplexInput Vt
  Modelica.ComplexBlocks.Interfaces.ComplexInput It
  Modelica.Blocks.Interfaces.RealOutput Vc
  Modelica.ComplexBlocks.ComplexMath.RealToComplex constZc
  Modelica.Blocks.Sources.Constant constRc(k = Rc)
  Modelica.Blocks.Sources.Constant constXc(k = Xc)
  Modelica.ComplexBlocks.ComplexMath.Add add1
  Modelica.ComplexBlocks.ComplexMath.Product prod1
  Modelica.ComplexBlocks.ComplexMath.ComplexToPolar complexToPolar
  Modelica.Blocks.Continuous.FirstOrder firstOrder(T = Tr, initType = initType, y_start = yStart)
equation
  connect(firstOrder.y, Vc)
  connect(complexToPolar.len, firstOrder.u)
  connect(add1.y, complexToPolar.u)
  connect(Vt, add1.u1)
  connect(prod1.y, add1.u2)
  connect(It, prod1.u1)
  connect(constZc.y, prod1.u2)
  connect(constXc.y, constZc.im)
  connect(constRc.y, constZc.re)
end TerminalVoltageTransducerIEEE;


info

within PowerGrids.Examples;

package Overview
  extends Modelica.Icons.Information;
end Overview;


Information

within PowerGrids.Examples.ENTSOE;

package Info "Information"
  extends Modelica.Icons.Information;
end Info;


Simple example from ENTSO-E document

within PowerGrids.Examples;

package ENTSOE "Simple example from ENTSO-E document"
  extends Modelica.Icons.ExamplesPackage;
end ENTSOE;


Reproduces the basic static power flow, see fig. 3-1 of the report.

within PowerGrids.Examples.ENTSOE;

model SteadyState "Reproduces the basic static power flow, see fig. 3-1 of the report"
  extends Modelica.Icons.Example;
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.Machines.SynchronousMachine4Windings GEN(H = 4, PStart = -4.75e+08, QStart = -1.56e+08, SNom = 5e+08, Tpd0 = 5.143, Tppd0 = 0.042, Tppq0 = 0.083, Tpq0 = 2.16, UNom = 21000, UPhaseStart = 0.161146, UStart = 21e3 * 0.992, portVariablesPhases = true, raPu = 0, xdPu = 2, xlPu = 0.15, xpdPu = 0.35, xppdPu = 0.25, xppqPu = 0.3, xpqPu = 0.5, xqPu = 1.8)
  PowerGrids.Electrical.Buses.Bus NTLV(SNom = 5e+08, UNom = 21000, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Buses.Bus NTHV(SNom = 5e+08, UNom = 380000, UPhaseStart = 0, UStart = 1.050 * 380e3,portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Branches.TransformerFixedRatio TGEN(PStartA = 4.75e+08, PStartB = -4.75e+08, QStartA = 1.56e+08, QStartB = -7.6e+07, R = 0.15e-2 * 419 ^ 2 / 500, SNom = 5e+08, UNomA = 21000, UNomB = 419000, UPhaseStartA = 0.161146, UPhaseStartB = 0, UStartA = 0.992 * 21e3, UStartB = 1.050 * 380e3, X = 16e-2 * 419 ^ 2 / 500, portVariablesPhases = true, portVariablesPu = true, rFixed = 419 / 21)
  PowerGrids.Electrical.Controls.TurbineGovernors.IEEE_TGOV1 TGOV(R = 0.05, T1 = 0.5, T2 = 3, T3 = 10, VMax = 1)
  PowerGrids.Electrical.Controls.ExcitationSystems.IEEE_AC4A AVR(Ka = 200, Ta = 0.05, Tb = 10, Tc = 3, VrMax = 4)
  PowerGrids.Electrical.Controls.PowerSystemStabilizers.IEEE_PSS2A PSS(Ks1 = 10, Ks2 = 0.1564, M = 0, N = 0, T1 = 0.25, T2 = 0.03, T3 = 0.15, T4 = 0.015, T7 = 2, T8 = 0.5, T9 = 0.1, Tw1 = 2, Tw2 = 2, Tw3 = 2, Tw4 = 0, VstMax = 0.1, VstMin = -0.1)
  Modelica.Blocks.Sources.RealExpression zero
  Modelica.Blocks.Sources.RealExpression VrefPu(y = 1.004552)
  Modelica.Blocks.Sources.RealExpression RefLPu(y = 475 / 500 * 0.05)
  PowerGrids.Electrical.Loads.LoadImpedancePQ GRIDL(PRefConst = 4.75e+08, PStart(displayUnit = "W"), QRefConst = 7.6e+07, SNom = 5e+08, UNom = 380000, URef(displayUnit = "V") = 1.05 * 380e3, UStart(displayUnit = "V"), portVariablesPhases = true, portVariablesPu = true)

  Types.PerUnit       AA_01_NGEN_U = GEN.VPu;
  Types.PerUnit       AA_02_NGRID_U = GRID.port.VPu;
  Types.Angle         AA_03_NGRID_delta = GRID.port.UPhase;
  Types.Angle         AA_04_NGEN_delta = GEN.port.UPhase;
  Types.ActivePower   AA_05_PG = GEN.port.PGen;
  Types.ReactivePower AA_06_QG = GEN.port.QGen;
  Types.ActivePower   AA_07_PGRID = -GRID.port.P;
  Types.ReactivePower AA_08_QGRID = -GRID.port.Q;
  Types.ActivePower   AA_09_PGRIDL = GRIDL.port.P;
  Types.ReactivePower AA_10_QGRIDL = GRIDL.port.Q;
  Electrical.Buses.EquivalentGrid GRID(R_X = 1 / 10, SNom = 5e+08, SSC = 2.5e+09, UNom = 380000, URef = 1.05 * 380e3, c = 1.1, portVariablesPhases = true, portVariablesPu = true)
equation
  connect(VrefPu.y, AVR.VrefPu)
  connect(GRID.terminal, NTHV.terminal)
  connect(TGEN.terminalB, NTHV.terminal)
  connect(NTHV.terminal, GRIDL.terminal)
  connect(GEN.PPu, PSS.Vsi2Pu)
  connect(GEN.VPu, AVR.VcPu)
  connect(RefLPu.y, TGOV.RefLPu)
  connect(zero.y, AVR.VuelPu)
  connect(GEN.omegaPu, PSS.Vsi1Pu)
  connect(PSS.VstPu, AVR.VsPu)
  connect(AVR.efdPu, GEN.ufPuIn)
  connect(GEN.omegaPu, TGOV.omegaPu)
  connect(TGOV.PMechPu, GEN.PmPu)
  connect(NTLV.terminal, TGEN.terminalA)
  connect(GEN.terminal, NTLV.terminal)
end SteadyState;


Test Case 1, Section 5.1, focuses on the dynamic behavior of the model for the synchronous generator machine and its AVR.

within PowerGrids.Examples.ENTSOE;

model TestCase1 "Test Case 1, Section 5.1, focuses on the dynamic behavior of the model for the synchronous generator machine and its AVR"
  extends Modelica.Icons.Example;
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.Machines.SynchronousMachine4Windings GEN(H = 4, PStart = 0, QStart = 0, SNom = 5e+08, Tpd0 = 5.143, Tppd0 = 0.042, Tppq0 = 0.083, Tpq0 = 2.16, UNom = 21000, UPhaseStart = 0, UStart = 21000, portVariablesPhases = true, raPu = 0, xdPu = 2, xlPu = 0.15, xpdPu = 0.35, xppdPu = 0.25, xppqPu = 0.3, xpqPu = 0.5, xqPu = 1.8)
  PowerGrids.Electrical.Buses.ReferenceBus NTLV(SNom = 5e+08, UNom = 21000, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Controls.TurbineGovernors.IEEE_TGOV1 TGOV(R = 0.05, T1 = 0.5, T2 = 3, T3 = 10, VMax = 1)
  PowerGrids.Electrical.Controls.ExcitationSystems.IEEE_AC4A AVR(Ka = 200, Ta = 0.05, Tb = 10, Tc = 3, VrMax = 4)
  PowerGrids.Electrical.Controls.PowerSystemStabilizers.IEEE_PSS2A PSS(Ks1 = 10, Ks2 = 0.1564, M = 0, N = 0, T1 = 0.25, T2 = 0.03, T3 = 0.15, T4 = 0.015, T7 = 2, T8 = 0.5, T9 = 0.1, Tw1 = 2, Tw2 = 2, Tw3 = 2, Tw4 = 0, VstMax = 0.1, VstMin = -0.1)
  Modelica.Blocks.Sources.RealExpression zero
  Modelica.Blocks.Sources.RealExpression VrefPu(y = if time < 0.1 then 1.005 else 1.055)
  Modelica.Blocks.Sources.RealExpression RefLPu(y = 0)

  Types.PerUnit AA_01_GEN_Upu = GEN.port.VPu "Fig. 5.1, terminal voltage";
  Types.PerUnit AA_02_GEN_efd = GEN.ufPuIn "Fig. 5.2, excitation voltage";

equation
  connect(GEN.PPu, PSS.Vsi2Pu)
  connect(GEN.VPu, AVR.VcPu)
  connect(RefLPu.y, TGOV.RefLPu)
  connect(VrefPu.y, AVR.VrefPu)
  connect(zero.y, AVR.VuelPu)
  connect(GEN.omegaPu, PSS.Vsi1Pu)
  connect(PSS.VstPu, AVR.VsPu)
  connect(AVR.efdPu, GEN.ufPuIn)
  connect(GEN.omegaPu, TGOV.omegaPu)
  connect(TGOV.PMechPu, GEN.PmPu)
  connect(GEN.terminal, NTLV.terminal)
end TestCase1;


Test Case 2, Section 5.2, focuses on the dynamic behavior of the model for the synchronous generator and its governor.

within PowerGrids.Examples.ENTSOE;

model TestCase2 "Test Case 2, Section 5.2, focuses on the dynamic behavior of the model for the synchronous generator and its governor"
  extends Modelica.Icons.Example;
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.Machines.SynchronousMachine4Windings GEN(H = 4, PStart = -3.8e+08, QStart = 0, SNom = 4.75e+08, Tpd0 = 5.143, Tppd0 = 0.042, Tppq0 = 0.083, Tpq0 = 2.16, UNom = 21000, UPhaseStart = 0, UStart = 21000, portVariablesPhases = true, raPu = 0, referenceGenerator = true, xdPu = 2, xlPu = 0.15, xpdPu = 0.35, xppdPu = 0.25, xppqPu = 0.3, xpqPu = 0.5, xqPu = 1.8)
  PowerGrids.Electrical.Buses.ReferenceBus NGEN(SNom = 5e+08, UNom = 21000, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Controls.TurbineGovernors.IEEE_TGOV1 TGOV(R = 0.05, T1 = 0.5, T2 = 3, T3 = 10, VMax = 1)
  PowerGrids.Electrical.Controls.ExcitationSystems.IEEE_AC4A AVR(Ka = 200, Ta = 0.05, Tb = 10, Tc = 3, VrMax = 4)
  Modelica.Blocks.Sources.RealExpression zero
  Modelica.Blocks.Sources.RealExpression VrefPu(y = 1.00943)
  Modelica.Blocks.Sources.RealExpression RefLPu(y = 380 / 475 * 0.05)
  PowerGrids.Electrical.Loads.LoadImpedancePQInputs LOAD(PStart = 3.8e+08, SNom = 4.75e+08, UNom = 21000, portVariablesPhases = true, portVariablesPu = true)
  Modelica.Blocks.Sources.Step PLoad(height = 23.75e6, offset = 380e6, startTime = 0.1)
  Modelica.Blocks.Sources.RealExpression zero2

  Types.PerUnit AA_01_GEN_UPu = GEN.port.VPu "Fig. 5-3, terminal voltage";
  Types.PerUnit AA_02_GEN_PPu = GEN.port.PGenPu "Fig. 5-4, active power of the synchronous machine";
  Types.PerUnit AA_03_GEN_PmechPu = GEN.PmPu "Fig. 5-5, mechanical power of the synchronous machine";
  Types.PerUnit AA_04_GEN_omegaPu = GEN.omegaPu "Fig. 5-6, speed";

equation
  connect(GEN.VPu, AVR.VcPu)
  connect(zero2.y, LOAD.QRefIn)
  connect(zero.y, AVR.VuelPu)
  connect(zero.y, AVR.VsPu)
  connect(VrefPu.y, AVR.VrefPu)
  connect(PLoad.y, LOAD.PRefIn)
  connect(NGEN.terminal, LOAD.terminal)
  connect(RefLPu.y, TGOV.RefLPu)
  connect(AVR.efdPu, GEN.ufPuIn)
  connect(GEN.omegaPu, TGOV.omegaPu)
  connect(TGOV.PMechPu, GEN.PmPu)
  connect(GEN.terminal, NGEN.terminal)
end TestCase2;


Test Case 3, Section 5.3, focuses on the dynamic behavior of the model for the synchronous machine with its whole control in response to a short-circuit.

within PowerGrids.Examples.ENTSOE;

model TestCase3 "Test Case 3, Section 5.3, focuses on the dynamic behavior of the model for the synchronous machine with its whole control in response to a short-circuit"
  extends Modelica.Icons.Example;
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.Machines.SynchronousMachine4Windings GEN(H = 4, PStart = -4.75e+08, QStart = -1.56e+08, SNom = 5e+08, Tpd0 = 5.143, Tppd0 = 0.042, Tppq0 = 0.083, Tpq0 = 2.16, UNom = 21000, UPhaseStart = 0.161146, UStart = 21e3 * 0.992, portVariablesPhases = true, raPu = 0, xdPu = 2, xlPu = 0.15, xpdPu = 0.35, xppdPu = 0.25, xppqPu = 0.3, xpqPu = 0.5, xqPu = 1.8)
  PowerGrids.Electrical.Buses.Bus NTLV(SNom = 5e+08, UNom = 21000, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Buses.BusFault NTHV(R = 0.05, SNom = 5e+08, UNom = 380000, UStart = 1.050 * 380e3, X = 0, portVariablesPhases = true, portVariablesPu = true, startTime = 0.1, stopTime = 0.2)
  PowerGrids.Electrical.Branches.TransformerFixedRatio TGEN(PStartA = 4.75e+08, PStartB = -4.75e+08, QStartA = 1.56e+08, QStartB = -7.6e+07, R = 0.15e-2 * 419 ^ 2 / 500, SNom = 5e+08, UNomA = 21000, UNomB = 419000, UPhaseStartA = 0.161146, UPhaseStartB = 0, UStartA = 0.992 * 21e3, UStartB = 1.050 * 380e3, X = 16e-2 * 419 ^ 2 / 500, portVariablesPhases = true, portVariablesPu = true, rFixed = 419 / 21)
  PowerGrids.Electrical.Controls.TurbineGovernors.IEEE_TGOV1 TGOV(R = 0.05, T1 = 0.5, T2 = 3, T3 = 10, VMax = 1)
  PowerGrids.Electrical.Controls.ExcitationSystems.IEEE_AC4A AVR(Ka = 200, Ta = 0.05, Tb = 10, Tc = 3, VrMax = 4)
  PowerGrids.Electrical.Controls.PowerSystemStabilizers.IEEE_PSS2A PSS(Ks1 = 10, Ks2 = 0.1564, M = 0, N = 0, T1 = 0.25, T2 = 0.03, T3 = 0.15, T4 = 0.015, T7 = 2, T8 = 0.5, T9 = 0.1, Tw1 = 2, Tw2 = 2, Tw3 = 2, Tw4 = 0, VstMax = 0.1, VstMin = -0.1)
  Modelica.Blocks.Sources.RealExpression zero
  Modelica.Blocks.Sources.RealExpression VrefPu(y = 1.004552)
  Modelica.Blocks.Sources.RealExpression RefLPu(y = 475 / 500 * 0.05)
  PowerGrids.Electrical.Loads.LoadImpedancePQ GRIDL(PRef = 4.75e+08, QRef = 7.6e+07, SNom = 5e+08, UNom = 380000, URef = 1.05 * 380e3, portVariablesPhases = true, portVariablesPu = true)
  Electrical.Buses.EquivalentGrid GRID(R_X = 1 / 10, SNom = 5e+08, SSC = 2.5e+09, UNom = 380000, URef = 1.050 * 380e3, c = 1.1, portVariablesPhases = true, portVariablesPu = true)

  Types.PerUnit AA_01_GEN_Upu = GEN.port.VPu "Fig. 5.7, terminal voltage";
  Types.PerUnit AA_02_GEN_efd = GEN.ufPuIn "Fig. 5.8, excitation voltage";
  Types.PerUnit AA_03_GEN_Ppu = GEN.port.PGenPu/0.95 "Fig. 5.9, active power of the synchronous machine";
  Types.PerUnit AA_04_GEN_Qpu = GEN.port.QGenPu/0.314583 "Fig. 5.10, reactive power of the synchronous machine";
  Types.PerUnit AA_05_GEN_omegapu = GEN.omegaPu "Fig. 5.11, speed";
  Types.PerUnit AA_06_PSS_out = PSS.VstPu "Fig. 5.12, PSS output signal";
  Types.PerUnit AA_07_GRIDL_Ppu = GRIDL.port.PPu/0.95 "Fig. 5.13, active power of the load";
  Types.PerUnit AA_08_GRIDL_Qpu = GRIDL.port.QPu/0.1519 "Fig. 5.14, reactive power of the load";

equation
  connect(GRID.terminal, NTHV.terminal)
  connect(VrefPu.y, AVR.VrefPu)
  connect(TGEN.terminalB, NTHV.terminal)
  connect(NTHV.terminal, GRIDL.terminal)
  connect(GEN.PPu, PSS.Vsi2Pu)
  connect(GEN.VPu, AVR.VcPu)
  connect(RefLPu.y, TGOV.RefLPu)
  connect(zero.y, AVR.VuelPu)
  connect(GEN.omegaPu, PSS.Vsi1Pu)
  connect(PSS.VstPu, AVR.VsPu)
  connect(AVR.efdPu, GEN.ufPuIn)
  connect(GEN.omegaPu, TGOV.omegaPu)
  connect(TGOV.PMechPu, GEN.PmPu)
  connect(NTLV.terminal, TGEN.terminalA)
  connect(GEN.terminal, NTLV.terminal)
end TestCase3;


Model of controlled generator for the IEEE 14-bus benchmark - synchronous machine with proportional regulations.

within PowerGrids.Examples.IEEE14bus;
model ControlledGeneratorIEEE "Model of controlled generator for the IEEE 14-bus benchmark - synchronous machine with proportional regulations"
  extends Icons.Machine;
  PowerGrids.Electrical.Machines.SynchronousMachine4Windings GEN(portVariablesPhases = true)
  PowerGrids.Interfaces.TerminalAC terminal
  Electrical.Controls.ExcitationSystems.VRProportional AVR(Ka = 20, VcPuStart = GEN.UStart / GEN.UNom, VrMax = 5, VrMin = -5)
  Electrical.Controls.TurbineGovernors.GoverProportional GOV(KGover = 5, PMaxPu = 1, PMinPu = 0, PPuStart = -GEN.PStart / GEN.PNom)
  PowerGrids.Controls.FreeOffset PmRefPu(use_u = true)
  Controls.FreeOffset VrefPu(use_u = true)
  Modelica.Blocks.Sources.RealExpression VrefPuDef(y = 1)
  Modelica.Blocks.Sources.RealExpression PmRefPuDef(y = -GEN.PStart / GEN.PNom)
  Modelica.Blocks.Interfaces.RealOutput omega
equation
  connect(GEN.terminal, terminal)
  connect(GOV.omegaPu, GEN.omegaPu)
  connect(AVR.VcPu, GEN.VPu)
  connect(AVR.efdPu, GEN.ufPuIn)
  connect(GOV.PMechPu, GEN.PmPu)
  connect(PmRefPu.y, GOV.PmRefPu)
  connect(VrefPu.y, AVR.VrefPu)
  connect(VrefPuDef.y, VrefPu.u)
  connect(GEN.PPu, GOV.PPu)
  connect(PmRefPuDef.y, PmRefPu.u)
  connect(GEN.omega, omega)
end ControlledGeneratorIEEE;


Simulation of the disconnection of generator 2 at t = 1 s.

within PowerGrids.Examples.IEEE14bus;
model IEEE14busGen2Disconnection "Simulation of the disconnection of generator 2 at t = 1 s"
  extends IEEE14busStaticNetwork(Tgen2(useBreaker = true));
  Modelica.Blocks.Sources.BooleanExpression Gen2BreakerState(y = time < 1)
equation
  connect(Gen2BreakerState.y, Tgen2.breakerStatusIn)
end IEEE14busGen2Disconnection;


Simulation of the opening of line 1 to 5 at t = 1 s.

within PowerGrids.Examples.IEEE14bus;

model IEEE14busLine1to5Opening "Simulation of the opening of line 1 to 5 at t = 1 s"
  extends IEEE14busStaticNetwork(L1to5(useBreakerB = true));
  Modelica.Blocks.Sources.BooleanExpression L1to5BreakerState(y = time < 1)
equation
  connect(L1to5BreakerState.y, L1to5.breakerStatusB)
end IEEE14busLine1to5Opening;


Simulation of a load increase on load 2 at t = 1 s.

within PowerGrids.Examples.IEEE14bus;

model IEEE14busLoad2Variation "Simulation of a load increase on load 2 at t = 1 s"
  extends IEEE14busStaticNetwork(
    Load2(
      PRef = Load2.PRefConst*(if time < 1 then 1 else 2) "Active power consumption at reference voltage",
      QRef = Load2.QRefConst*(if time < 1 then 1 else 2) "Reactive power consumption at reference voltage"
    ));
equation
end IEEE14busLoad2Variation;


Power flow model of the IEEE 14-bus benchmark.

within PowerGrids.Examples.IEEE14bus;

model IEEE14busPowerFlow "Power flow model of the IEEE 14-bus benchmark"
  extends Modelica.Icons.Example;
  inner PowerGrids.Electrical.System systemPowerGrids

  // Buses
  PowerGrids.Electrical.PowerFlow.SlackBus bus1(
    SNom = 100e6,
    U = 69e3*1.0598,
    UNom = 69000
  )
  PowerGrids.Electrical.Buses.Bus bus2(
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Buses.Bus bus3(
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Buses.Bus bus4(
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Buses.Bus bus5(
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Buses.Bus bus6(
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Buses.Bus bus7(
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Buses.Bus bus8(
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Buses.Bus bus9(
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Buses.Bus bus10(
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Buses.Bus bus11(
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Buses.Bus bus12(
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Buses.Bus bus13(
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Buses.Bus bus14(
    SNom = 100e6,
    UNom = 13.8e3
  )

  // Lines
  PowerGrids.Electrical.Branches.LineConstantImpedance L1to2(
    portVariablesPhases = true,
    R = 0.922682,
    X = 2.81708,
    G = 0,
    B = 0.00110901,
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedanceWithBreakers L1to5(
    portVariablesPhases = true,
    R = 2.57237,
    X = 10.6189,
    B = 0.0010334,
    G = 0,
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L2to3(
    portVariablesPhases = true,
    R = 2.23719,
    X = 9.42535,
    G = 0,
    B = 0.000919975,
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L2to4(
    portVariablesPhases = true,
    R = 2.76662,
    X = 8.3946,
    G = 0,
    B = 0.000714136,
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L2to5(
    portVariablesPhases = true,
    R = 2.71139,
    X = 8.27843,
    G = 0,
    B = 0.000726738,
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L3to4(
    portVariablesPhases = true,
    R = 3.19035,
    X = 8.14274,
    G = 0,
    B = 0.000268851,
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L4to5(
    portVariablesPhases = true,
    R = 0.635593,
    X = 2.00486,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L6to11(
    portVariablesPhases = true,
    R = 0.18088,
    X = 0.378785,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L6to12(
    portVariablesPhases = true,
    R = 0.23407,
    X = 0.487165,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L6to13(
    portVariablesPhases = true,
    R = 0.125976,
    X = 0.248086,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L7to8(
    portVariablesPhases = true,
    R = 0,
    X = 0.33546,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L7to9(
    portVariablesPhases = true,
    R = 0,
    X = 0.209503,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L9to10(
    portVariablesPhases = true,
    R = 0.060579,
    X = 0.160922,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L9to14(
    portVariablesPhases = true,
    R = 0.242068,
    X = 0.514912,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L10to11(
    portVariablesPhases = true,
    R = 0.156256,
    X = 0.365778,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L12to13(
    portVariablesPhases = true,
    R = 0.42072,
    X = 0.380651,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L13to14(
    portVariablesPhases = true,
    R = 0.325519,
    X = 0.662763,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )

  // LOADS
  PowerGrids.Electrical.PowerFlow.PQBus Load2(
    portVariablesPhases = true,
    P = 21.7e6,
    Q = 12.7e6,
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.PowerFlow.PQBus Load3(
    portVariablesPhases = true,
    P = 94.2e6,
    Q = 19.1e6,
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.PowerFlow.PQBus Load4(
    portVariablesPhases = true,
    P = 47.8e6,
    Q = -3.9e6,
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.PowerFlow.PQBus Load5(
    portVariablesPhases = true,
    P = 7.6e6,
    Q = 1.6e6,
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.PowerFlow.PQBus Load6(
    portVariablesPhases = true,
    P = 11.2e6,
    Q = 7.5e6,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.PowerFlow.PQBus Load9(
    portVariablesPhases = true,
    P = 29.5e6,
    Q = 16.6e6,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.PowerFlow.PQBus Load10(
    portVariablesPhases = true,
    P = 9e6,
    Q = 5.8e6,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.PowerFlow.PQBus Load11(
    portVariablesPhases = true,
    P = 3.5e6,
    Q = 1.8e6,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.PowerFlow.PQBus Load12(
    portVariablesPhases = true,
    P = 6.1e6,
    Q = 1.6e6,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.PowerFlow.PQBus Load13(
    portVariablesPhases = true,
    P = 13.8e6,
    Q = 5.8e6,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.PowerFlow.PQBus Load14(
    portVariablesPhases = true,
    P = 14.9e6,
    Q = 5e6,
    SNom = 100e6,
    UNom = 13.8e3
  )

  // Capacitor bank
  PowerGrids.Electrical.Banks.CapacitorBankFixed Cbank9(
    portVariablesPhases = true,
    B = 0.099769,
    SNom = 100e6,
    UNom = 13.8e3
  )

  // Transformers
  PowerGrids.Electrical.Branches.TransformerFixedRatio T4to7(
    portVariablesPhases = true,
    R = 0,
    X = 0.398248,
    B = 0,
    G = 0,
    rFixed = 0.204082,
    SNom = 100e6,
    UNomA = 69e3,
    UNomB = 13.8e3
  )
  PowerGrids.Electrical.Branches.TransformerFixedRatio T4to9(
    portVariablesPhases = true,
    R = 0,
    X = 1.05919,
    B = 0,
    G = 0,
    rFixed = 0.208333,
    SNom = 100e6,
    UNomA = 69.0e3,
    UNomB = 13.8e3
  )
  PowerGrids.Electrical.Branches.TransformerFixedRatio T5to6(
    portVariablesPhases = true,
    R = 0,
    X = 0.479948,
    B = 0,
    G = 0,
    rFixed = 0.212766,
    SNom = 100e6,
    UNomA = 69e3,
    UNomB = 13.8e3
  )
  PowerGrids.Electrical.Branches.TransformerFixedRatio Tgen1(
    portVariablesPhases = true,
    R = 0,
    X = 0.393146,
    B = 0,
    G = 0,
    rFixed = 2.875,
    SNom = 1211e6,
    UNomA = 24e3,
    UNomB = 69e3
  )
  PowerGrids.Electrical.Branches.TransformerFixedRatioWithBreaker Tgen2(
    portVariablesPhases = true,
    R = 0,
    X = 0.425089,
    B = 0,
    G = 0,
    rFixed = 2.875,
    SNom = 1120e6,
    UNomA = 24e3,
    UNomB = 69e3
  )
  PowerGrids.Electrical.Branches.TransformerFixedRatio Tgen3(
    portVariablesPhases = true,
    R = 0,
    X = 0.288545,
    B = 0,
    G = 0,
    rFixed = 3.45,
    SNom = 1650e6,
    UNomA = 20e3,
    UNomB = 69e3
  )
  PowerGrids.Electrical.Branches.TransformerFixedRatio Tgen8(
    portVariablesPhases = true,
    R = 0,
    X = 0.076176,
    B = 0,
    G = 0,
    rFixed = 0.766667,
    SNom = 250e6,
    UNomA = 18e3,
    UNomB = 13.8e3
  )

  // Generators
  PowerGrids.Electrical.PowerFlow.PVBus GEN1(
    portVariablesPhases = true,
    SNom = 1211e6,
    UNom = 24e3,
    P = -232.36955e6,
    U = 25.4068e3
  )
  PowerGrids.Electrical.PowerFlow.PVBus GEN2(
    portVariablesPhases = true,
    SNom = 1120e6,
    UNom = 24e3,
    U = 25.1608e3,
    P = -40e6
  )
  PowerGrids.Electrical.PowerFlow.PVBus GEN3(
    portVariablesPhases = true,
    SNom = 1650e6,
    UNom = 20e3,
    U = 20.229e3,
    P = 0.0
  )
  PowerGrids.Electrical.PowerFlow.PVBus GEN6(
    portVariablesPhases = true,
    SNom = 80.0e6,
    UNom = 13.8e3,
    U = 14.7347e3,
    P = 0
  )
  PowerGrids.Electrical.PowerFlow.PVBus GEN8(
    portVariablesPhases = true,
    SNom = 250e6,
    UNom = 18e3,
    U = 19.6461e3,
    P = 0
  )

equation
  connect(bus12.terminal, L6to12.terminalB)
  connect(L12to13.terminalA, bus12.terminal)
  connect(L12to13.terminalB, bus13.terminal)
  connect(L6to12.terminalA, bus6.terminal)
  connect(L6to13.terminalA, bus6.terminal)
  connect(L6to13.terminalB, bus13.terminal)
  connect(bus13.terminal, L6to13.terminalB)
  connect(L6to11.terminalA, bus6.terminal)
  connect(L6to11.terminalB, bus11.terminal)
  connect(L13to14.terminalA, bus13.terminal)
  connect(L13to14.terminalB, bus14.terminal)
  connect(L9to14.terminalB, bus14.terminal)
  connect(L9to14.terminalA, bus9.terminal)
  connect(L10to11.terminalB, bus11.terminal)
  connect(L10to11.terminalA, bus10.terminal)
  connect(L9to10.terminalB, bus10.terminal)
  connect(L9to10.terminalA, bus9.terminal)
  connect(L7to8.terminalA, bus7.terminal)
  connect(L7to9.terminalA, bus7.terminal)
  connect(L7to9.terminalB, bus9.terminal)
  connect(L7to8.terminalB, bus8.terminal)
  connect(T4to9.terminalA, bus4.terminal)
  connect(T4to9.terminalB, bus9.terminal)
  connect(T5to6.terminalB, bus6.terminal)
  connect(T5to6.terminalA, bus5.terminal)
  connect(L1to2.terminalA, bus1.terminal)
  connect(L1to2.terminalB, bus2.terminal)
  connect(L1to5.terminalA, bus1.terminal)
  connect(L1to5.terminalB, bus5.terminal)
  connect(L2to5.terminalB, bus5.terminal)
  connect(L4to5.terminalB, bus5.terminal)
  connect(L2to5.terminalA, bus2.terminal)
  connect(L2to4.terminalA, bus2.terminal)
  connect(L3to4.terminalB, bus4.terminal)
  connect(L3to4.terminalA, bus3.terminal)
  connect(L2to4.terminalB, bus4.terminal)
  connect(L4to5.terminalA, bus4.terminal)
  connect(L2to3.terminalB, bus3.terminal)
  connect(Tgen8.terminalB, bus8.terminal)
  connect(Tgen3.terminalB, bus3.terminal)
  connect(Tgen2.terminalB, bus2.terminal)
  connect(Tgen1.terminalB, bus1.terminal)
  connect(Load12.terminal, bus12.terminal)
  connect(bus13.terminal, Load13.terminal)
  connect(Load14.terminal, bus14.terminal)
  connect(Load11.terminal, bus11.terminal)
  connect(Load10.terminal, bus10.terminal)
  connect(Cbank9.terminal, bus9.terminal)
  connect(Load9.terminal, bus9.terminal)
  connect(Load6.terminal, bus6.terminal)
  connect(Load5.terminal, bus5.terminal)
  connect(Load3.terminal, bus3.terminal)
  connect(Load2.terminal, bus2.terminal)
  connect(L2to3.terminalA, bus2.terminal)
  connect(Tgen1.terminalA, GEN1.terminal)
  connect(GEN2.terminal, Tgen2.terminalA)
  connect(Tgen3.terminalA, GEN3.terminal)
  connect(GEN8.terminal, Tgen8.terminalA)
  connect(Load4.terminal, bus4.terminal)
  connect(GEN6.terminal, bus6.terminal)
  connect(T4to7.terminalA, bus4.terminal)
  connect(T4to7.terminalB, bus7.terminal)
end IEEE14busPowerFlow;


Dynamic model of the IEEE 14-bus system, operating in steady-state.

within PowerGrids.Examples.IEEE14bus;
model IEEE14busStaticNetwork "Dynamic model of the IEEE 14-bus system, operating in steady-state"
  extends Modelica.Icons.Example;
  inner PowerGrids.Electrical.System systemPowerGrids(initOpt = PowerGrids.Types.Choices.InitializationOption.globalSteadyStateFixedPowerFlow, referenceFrequency = PowerGrids.Types.Choices.ReferenceFrequency.fixedReferenceGenerator)

// Buses
  PowerGrids.Electrical.Buses.ReferenceBus bus1(
    SNom = 100e6,
    UNom = 69e3,
    UStart = 69e3*1.0598
  )
  PowerGrids.Electrical.Buses.Bus bus2(
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Buses.Bus bus3(
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Buses.Bus bus4(
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Buses.Bus bus5(
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Buses.Bus bus6(
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Buses.Bus bus7(
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Buses.Bus bus8(
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Buses.Bus bus9(
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Buses.Bus bus10(
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Buses.Bus bus11(
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Buses.Bus bus12(
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Buses.Bus bus13(
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Buses.Bus bus14(
    SNom = 100e6,
    UNom = 13.8e3
  )

// Lines
  PowerGrids.Electrical.Branches.LineConstantImpedance L1to2(
    portVariablesPhases = true,
    R = 0.922682,
    X = 2.81708,
    G = 0,
    B = 0.00110901,
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedanceWithBreakers L1to5(
    portVariablesPhases = true,
    R = 2.57237,
    X = 10.6189,
    G = 0,
    B = 0.0010334,
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L2to3(
    portVariablesPhases = true,
    R = 2.23719,
    X = 9.42535,
    G = 0,
    B = 0.000919975,
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L2to4(
    portVariablesPhases = true,
    R = 2.76662,
    X = 8.3946,
    G = 0,
    B = 0.000714136,
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L2to5(
    portVariablesPhases = true,
    R = 2.71139,
    X = 8.27843,
    G = 0,
    B = 0.000726738,
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L3to4(
    portVariablesPhases = true,
    R = 3.19035,
    X = 8.14274,
    G = 0,
    B = 0.000268851,
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L4to5(
    portVariablesPhases = true,
    R = 0.635593,
    X = 2.00486,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 69e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L6to11(
    portVariablesPhases = true,
    R = 0.18088,
    X = 0.378785,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L6to12(
    R = 0.23407,
    portVariablesPhases = true,
    X = 0.487165,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L6to13(
    portVariablesPhases = true,
    R = 0.125976,
    X = 0.248086,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L7to8(
    portVariablesPhases = true,
    R = 0,
    X = 0.33546,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L7to9(
    portVariablesPhases = true,
    R = 0,
    X = 0.209503,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L9to10(
    portVariablesPhases = true,
    R = 0.060579,
    X = 0.160922,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L9to14(
    portVariablesPhases = true,
    R = 0.242068,
    X = 0.514912,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L10to11(
    portVariablesPhases = true,
    R = 0.156256,
    X = 0.365778,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L12to13(
    portVariablesPhases = true,
    R = 0.42072,
    X = 0.380651,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )
  PowerGrids.Electrical.Branches.LineConstantImpedance L13to14(
    portVariablesPhases = true,
    R = 0.325519,
    X = 0.662763,
    G = 0,
    B = 0,
    SNom = 100e6,
    UNom = 13.8e3
  )

// Loads
  PowerGrids.Electrical.Loads.LoadPQVoltageDependence Load2(
    alpha = 1.5,
    beta = 2.5,
    PRefConst = 21.7e6,
    QRefConst = 12.7e6,
    SNom = 100e6,
    UNom = 69e3,
    URef = 72.105e3,
    UStart = 72.0866e3,
    UPhaseStart = -0.087
  )
  PowerGrids.Electrical.Loads.LoadPQVoltageDependence Load3(
    alpha = 1.5,
    beta = 2.5,
    PRefConst = 94.2e6,
    QRefConst = 19.1e6,
    SNom = 100e6,
    UNom = 69e3,
    URef = 69.69e3,
    UStart = 69.685e3,
    UPhaseStart = -0.22231
  )
  PowerGrids.Electrical.Loads.LoadPQVoltageDependence Load4(
    alpha = 1.5,
    beta = 2.5,
    PRefConst = 47.8e6,
    QRefConst = -3.9e6,
    SNom = 100e6,
    UNom = 69e3,
    URef = 70.2756e3,
    UStart = 70.2049e3,
    UPhaseStart = -0.180223
  )
  PowerGrids.Electrical.Loads.LoadPQVoltageDependence Load5(
    alpha = 1.5,
    beta = 2.5,
    PRefConst = 7.6e6,
    QRefConst = 1.6e6,
    SNom = 100e6,
    UNom = 69e3,
    URef = 70.4552e3,
    UStart = 70.3898e3,
    UPhaseStart = -0.153511
  )
  PowerGrids.Electrical.Loads.LoadPQVoltageDependence Load6(
    alpha = 1.5,
    beta = 2.5,
    PRefConst = 11.2e6,
    QRefConst = 7.5e6,
    SNom = 100e6,
    UNom = 13.8e3,
    URef = 14.766e3,
    UStart = 14.7347e3,
    UPhaseStart = -0.249364
  )
  PowerGrids.Electrical.Loads.LoadPQVoltageDependence Load9(
    alpha = 1.5,
    beta = 2.5,
    PRefConst = 29.5e6,
    QRefConst = 16.6e6,
    SNom = 100e6,
    UNom = 13.8e3,
    URef = 14.5966e3,
    UStart = 14.5624e3,
    UPhaseStart = -0.261599
  )
  PowerGrids.Electrical.Loads.LoadPQVoltageDependence Load10(
    alpha = 1.5,
    beta = 2.5,
    PRefConst = 9e6,
    QRefConst = 5.8e6,
    SNom = 100e6,
    UNom = 13.8e3,
    URef = 14.5241e3,
    UStart = 14.4903e3,
    UPhaseStart = -0.264445
  )
  PowerGrids.Electrical.Loads.LoadPQVoltageDependence Load11(
    alpha = 1.5,
    beta = 2.5,
    PRefConst = 3.5e6,
    QRefConst = 1.8e6,
    SNom = 100e6,
    UNom = 13.8e3,
    URef = 14.5959e3,
    UStart = 14.5633e3,
    UPhaseStart = -0.259223
  )
  PowerGrids.Electrical.Loads.LoadPQVoltageDependence Load12(
    alpha = 1.5,
    beta = 2.5,
    PRefConst = 6.1e6,
    QRefConst = 1.6e6,
    SNom = 100e6,
    UNom = 13.8e3,
    URef = 14.499e3,
    UStart = 14.5308e3,
    UPhaseStart = -0.264428
  )
  PowerGrids.Electrical.Loads.LoadPQVoltageDependence Load13(
    alpha = 1.5,
    beta = 2.5,
    PRefConst = 13.8e6,
    QRefConst = 5.8e6,
    SNom = 100e6,
    UNom = 13.8e3,
    URef = 14.5634e3,
    UStart = 14.4648e3,
    UPhaseStart = -0.265952
  )
  PowerGrids.Electrical.Loads.LoadPQVoltageDependence Load14(
    alpha = 1.5,
    beta = 2.5,
    PRefConst = 14.9e6,
    QRefConst = 5e6,
    SNom = 100e6,
    UNom = 13.8e3,
    URef = 14.3062e3,
    UStart = 14.2714e3,
    UPhaseStart = -0.281002
  )

// Capacitor Bank
  PowerGrids.Electrical.Banks.CapacitorBankFixed Cbank9(
    B = 0.099769,
    SNom = 100e6,
    UNom = 13.8e3
  )

// Transformers
  PowerGrids.Electrical.Branches.TransformerFixedRatio T4to7(
    R = 0,
    X = 0.398248,
    B = 0,
    G = 0,
    rFixed = 0.204082,
    SNom = 100e6,
    UNomA = 69e3,
    UNomB = 13.8e3
  )
  PowerGrids.Electrical.Branches.TransformerFixedRatio T4to9(
    R = 0,
    X = 1.05919,
    B = 0,
    G = 0,
    rFixed = 0.208333,
    SNom = 100e6,
    UNomA = 69.0e3,
    UNomB = 13.8e3
  )
  PowerGrids.Electrical.Branches.TransformerFixedRatio T5to6(
    R = 0,
    X = 0.479948,
    B = 0,
    G = 0,
    rFixed = 0.212766,
    SNom = 100e6,
    UNomA = 69e3,
    UNomB = 13.8e3
  )
  PowerGrids.Electrical.Branches.TransformerFixedRatio Tgen1(
    portVariablesPhases = true,
    R = 0,
    X = 0.393146,
    B = 0,
    G = 0,
    rFixed = 2.875,
    SNom = 1211e6,
    UNomA = 24e3,
    UNomB = 69e3
  )
  PowerGrids.Electrical.Branches.TransformerFixedRatioWithBreaker Tgen2(
    portVariablesPhases = true,
    R = 0,
    X = 0.425089,
    B = 0,
    G = 0,
    rFixed = 2.875,
    SNom = 1120e6,
    UNomA = 24e3,
    UNomB = 69e3
  )
  PowerGrids.Electrical.Branches.TransformerFixedRatio Tgen3(
    portVariablesPhases = true,
    R = 0,
    X = 0.288545,
    B = 0,
    G = 0,
    rFixed = 3.45,
    SNom = 1650e6,
    UNomA = 20e3,
    UNomB = 69e3
  )
  PowerGrids.Electrical.Branches.TransformerFixedRatio Tgen8(
    portVariablesPhases = true,
    R = 0,
    X = 0.076176,
    B = 0,
    G = 0,
    rFixed = 0.766667,
    SNom = 250e6,
    UNomA = 18e3,
    UNomB = 13.8e3
  )

// Generators
  PowerGrids.Examples.IEEE14bus.ControlledGeneratorIEEE GEN1(
    GEN(
      DPu = 0.0,
      H = 5.4,
      Tppd0 = 0.08,
      xpdPu = 0.384,
      Tpd0 = 8.094,
      raPu = 0.002796,
      xpqPu = 0.393,
      Tppq0 = 0.084,
      Tpq0 = 1.572,
      xppdPu = 0.264,
      xdPu = 2.22,
      xlPu = 0.202,
      xppqPu = 0.262,
      xqPu = 2.22,
      PNom = 1090e6,
      SNom = 1211e6,
      UNom = 24e3,
      PStart = -232.37e6,
      QStart = 15.7473e6,
      UStart = 25.4068e3,
      UPhaseStart = 0.0171006
    )
  )
  PowerGrids.Examples.IEEE14bus.ControlledGeneratorIEEE GEN2(
    GEN(
      DPu = 0.0,
      H = 5.4,
      Tppd0 = 0.058,
      xpdPu = 0.407,
      Tpd0 = 9.651,
      raPu = 0.00357,
      xpqPu = 0.454,
      Tppq0 = 0.06,
      Tpq0 = 1.009,
      xppdPu = 0.3,
      xdPu = 2.57,
      xlPu = 0.219,
      xppqPu = 0.301,
      xqPu = 2.57,
      PNom = 1008e6,
      SNom = 1120e6,
      UNom = 24e3,
      PStart = -40e6,
      QStart = -42.7306e6,
      UStart = 25.1608e3,
      UPhaseStart = -0.0837392
    )
  )
  PowerGrids.Examples.IEEE14bus.SynchronousCondenser GEN3(
    GEN(
      DPu = 0.0,
      H = 5.625,
      Tppd0 = 0.065,
      xpdPu = 0.509,
      Tpd0 = 10.041,
      raPu = 0.00316,
      xpqPu = 0.601,
      Tppq0 = 0.094,
      Tpq0 = 1.22,
      xppdPu = 0.354,
      xdPu = 2.81,
      xlPu = 0.256,
      xppqPu = 0.377,
      xqPu = 2.62,
      PNom = 1485e6,
      SNom = 1650e6,
      UNom = 20e3,
      PStart = 0.0,
      QStart = -25.3998e6,
      UStart = 20.229e3,
      UPhaseStart = -0.22231
    )
  )
  PowerGrids.Examples.IEEE14bus.SynchronousCondenser GEN6(
    GEN(
      xpqPu = 0.225,
      Tpq0 = 3.0,
      DPu = 0.0,
      H = 4.975,
      Tppd0 = 0.04,
      xpdPu = 0.225,
      Tpd0 = 3.0,
      raPu = 0.004,
      Tppq0 = 0.06,
      xppdPu = 0.154,
      xdPu = 0.75,
      xlPu = 0.102,
      xppqPu = 0.154,
      xqPu = 0.45,
      PNom = 71.8e6,
      SNom = 80.0e6,
      UNom = 13.8e3,
      PStart = 0,
      QStart = -15.0186e6,
      UStart = 14.7347e3,
      UPhaseStart = -0.249364
    )
  )
  PowerGrids.Examples.IEEE14bus.SynchronousCondenser GEN8(
    GEN(
      xpqPu = 0.31,
      Tpq0 = 8.4,
      DPu = 0.0,
      H = 2.748,
      Tppd0 = 0.096,
      xpdPu = 0.31,
      Tpd0 = 8.4,
      raPu = 0.004,
      Tppq0 = 0.1,
      xppdPu = 0.275,
      xdPu = 1.53,
      xlPu = 0.11,
      xppqPu = 0.346,
      xqPu = 0.99,
      PNom = 242e6,
      SNom = 250e6,
      UNom = 18e3,
      PStart = 0,
      QStart = -16.2253e6,
      UStart = 19.6461e3,
      UPhaseStart = -0.233851
    )
  )

equation
  connect(bus12.terminal, L6to12.terminalB)
  connect(L12to13.terminalA, bus12.terminal)
  connect(L12to13.terminalB, bus13.terminal)
  connect(L6to12.terminalA, bus6.terminal)
  connect(L6to13.terminalA, bus6.terminal)
  connect(L6to13.terminalB, bus13.terminal)
  connect(bus13.terminal, L6to13.terminalB)
  connect(L6to11.terminalA, bus6.terminal)
  connect(L6to11.terminalB, bus11.terminal)
  connect(L13to14.terminalA, bus13.terminal)
  connect(L13to14.terminalB, bus14.terminal)
  connect(L9to14.terminalB, bus14.terminal)
  connect(L9to14.terminalA, bus9.terminal)
  connect(L10to11.terminalB, bus11.terminal)
  connect(L10to11.terminalA, bus10.terminal)
  connect(L9to10.terminalB, bus10.terminal)
  connect(L9to10.terminalA, bus9.terminal)
  connect(L7to8.terminalA, bus7.terminal)
  connect(L7to9.terminalA, bus7.terminal)
  connect(L7to9.terminalB, bus9.terminal)
  connect(L7to8.terminalB, bus8.terminal)
  connect(T4to9.terminalA, bus4.terminal)
  connect(T4to9.terminalB, bus9.terminal)
  connect(T5to6.terminalB, bus6.terminal)
  connect(T5to6.terminalA, bus5.terminal)
  connect(L1to2.terminalA, bus1.terminal)
  connect(L1to2.terminalB, bus2.terminal)
  connect(L1to5.terminalA, bus1.terminal)
  connect(L1to5.terminalB, bus5.terminal)
  connect(L2to5.terminalB, bus5.terminal)
  connect(L4to5.terminalB, bus5.terminal)
  connect(L2to5.terminalA, bus2.terminal)
  connect(L2to4.terminalA, bus2.terminal)
  connect(L3to4.terminalB, bus4.terminal)
  connect(L3to4.terminalA, bus3.terminal)
  connect(L2to4.terminalB, bus4.terminal)
  connect(L4to5.terminalA, bus4.terminal)
  connect(L2to3.terminalB, bus3.terminal)
  connect(Tgen8.terminalB, bus8.terminal)
  connect(Tgen3.terminalB, bus3.terminal)
  connect(Tgen2.terminalB, bus2.terminal)
  connect(Tgen1.terminalB, bus1.terminal)
  connect(Load12.terminal, bus12.terminal)
  connect(bus13.terminal, Load13.terminal)
  connect(Load14.terminal, bus14.terminal)
  connect(Load11.terminal, bus11.terminal)
  connect(Load10.terminal, bus10.terminal)
  connect(Cbank9.terminal, bus9.terminal)
  connect(Load9.terminal, bus9.terminal)
  connect(Load6.terminal, bus6.terminal)
  connect(Load5.terminal, bus5.terminal)
  connect(Load3.terminal, bus3.terminal)
  connect(Load2.terminal, bus2.terminal)
  connect(L2to3.terminalA, bus2.terminal)
  connect(Tgen1.terminalA, GEN1.terminal)
  connect(GEN2.terminal, Tgen2.terminalA)
  connect(Tgen3.terminalA, GEN3.terminal)
  connect(GEN8.terminal, Tgen8.terminalA)
  connect(Load4.terminal, bus4.terminal)
  connect(GEN6.terminal, bus6.terminal)
  connect(T4to7.terminalA, bus4.terminal)
  connect(T4to7.terminalB, bus7.terminal)
  connect(GEN1.omega, systemPowerGrids.omegaRefIn)
end IEEE14busStaticNetwork;


Information

within PowerGrids.Examples.IEEE14bus;

package Info "Information"
  extends Modelica.Icons.Information;
end Info;


Classical IEEE14 bus network

within PowerGrids.Examples;
package IEEE14bus "Classical IEEE14 bus network"
  extends Modelica.Icons.ExamplesPackage;
end IEEE14bus;


Model of a synchronous condenser for the IEEE-14 bus system.

within PowerGrids.Examples.IEEE14bus;

model SynchronousCondenser "Model of a synchronous condenser for the IEEE-14 bus system"
  extends Icons.Machine;
  PowerGrids.Electrical.Machines.SynchronousMachine4Windings GEN(portVariablesPhases = true)
  PowerGrids.Interfaces.TerminalAC terminal
  Electrical.Controls.ExcitationSystems.VRProportional AVR(Ka = 20, VcPuStart = GEN.UStart / GEN.UNom, VrMax = 5, VrMin = -5)
  Controls.FreeOffset VrefPu(use_u = true)
  Modelica.Blocks.Sources.RealExpression VrefPuDef(y = 1)
  Modelica.Blocks.Sources.RealExpression PmPu(y = 0)
  Modelica.Blocks.Interfaces.RealOutput omega
equation
  connect(GEN.terminal, terminal)
  connect(AVR.VcPu, GEN.VPu)
  connect(AVR.efdPu, GEN.ufPuIn)
  connect(VrefPu.y, AVR.VrefPu)
  connect(VrefPuDef.y, VrefPu.u)
  connect(GEN.omega, omega)
  connect(PmPu.y, GEN.PmPu)
end SynchronousCondenser;


within PowerGrids.Examples;

package Tutorial "Tutorial examples of increasing complexity"
  extends Modelica.Icons.ExamplesPackage;
end Tutorial;


Examples of grid-connected systems

within PowerGrids.Examples.Tutorial;
package GridOperation "Examples of grid-connected systems"
  extends Modelica.Icons.ExamplesPackage;
end GridOperation;


Model of a synchronous generator with governor, AVR, and PSS.

within PowerGrids.Examples.Tutorial.GridOperation.Controlled;
model ControlledGenerator "Model of a synchronous generator with governor, AVR, and PSS"
  extends Icons.Machine;
  PowerGrids.Electrical.Machines.SynchronousMachine4Windings GEN(H = 4, PStart = -4.75e+08, QStart = -1.56e+08,SNom = 5e+08, Tpd0 = 5.143, Tppd0 = 0.042, Tppq0 = 0.083, Tpq0 = 2.16, UNom = 21000, UPhaseStart = 0.161156, UStart = 21e3 * 0.9917, portVariablesPhases = true, raPu = 0, xdPu = 2, xlPu = 0.15, xpdPu = 0.35, xppdPu = 0.25, xppqPu = 0.3, xpqPu = 0.5, xqPu = 1.8)
  PowerGrids.Electrical.Controls.TurbineGovernors.IEEE_TGOV1 TGOV(PMechPuStart = -GEN.PStart / GEN.SNom,R = 0.05, T1 = 0.5, T2 = 3, T3 = 10, VMax = 1)
  PowerGrids.Electrical.Controls.ExcitationSystems.IEEE_AC4A AVR(Ka = 200, Ta = 0.05, Tb = 10, Tc = 3, VcPuStart = GEN.UStart / GEN.UNom, VrMax = 4)
  Modelica.Blocks.Sources.RealExpression zero
  PowerGrids.Electrical.Controls.PowerSystemStabilizers.IEEE_PSS2A PSS(Ks1 = 10, Ks2 = 0.1564, M = 0, N = 0, T1 = 0.25, T2 = 0.03, T3 = 0.15, T4 = 0.015, T7 = 2, T8 = 0.5, T9 = 0.1, Tw1 = 2, Tw2 = 2, Tw3 = 2, Tw4 = 0, VstMax = 0.1, VstMin = -0.1)
  PowerGrids.Interfaces.TerminalAC terminal
  PowerGrids.Controls.FreeOffset RefLPu
  PowerGrids.Controls.FreeOffset VrefPu
  Modelica.Blocks.Interfaces.RealOutput omega "Angular frequency / (rad/s)"
equation
  connect(GEN.ufPuIn, AVR.efdPu)
  connect(TGOV.PMechPu, GEN.PmPu)
  connect(GEN.VPu, AVR.VcPu)
  connect(PSS.VstPu, AVR.VsPu)
  connect(PSS.Vsi2Pu, GEN.PPu)
  connect(GEN.terminal, terminal)
  connect(RefLPu.y, TGOV.RefLPu)
  connect(VrefPu.y, AVR.VrefPu)
  connect(GEN.omegaPu, TGOV.omegaPu)
  connect(AVR.VuelPu, zero.y)
  connect(GEN.omegaPu, PSS.Vsi1Pu)
  connect(GEN.omega, omega)
end ControlledGenerator;


Variant of ControlledGridWithPSS.

within PowerGrids.Examples.Tutorial.GridOperation.Controlled;
model ControlledGridParametersChange "Variant of ControlledGridWithPSS"
  extends Modelica.Icons.Example;
  extends Examples.Tutorial.GridOperation.Controlled.ControlledGridWithPSS(
    TGOV(T1 = 0.4 "Governor new time constant"),
    AVR(Ka = 210 "Overall new equivalent gain")
    );
end ControlledGridParametersChange;


System under automatic control with high-level controlled generator component.

within PowerGrids.Examples.Tutorial.GridOperation.Controlled;
model ControlledGridWithControlledGen "System under automatic control with high-level controlled generator component"
  extends Modelica.Icons.Example;
  inner PowerGrids.Electrical.System systemPowerGrids(initOpt = PowerGrids.Types.Choices.InitializationOption.globalSteadyStateFixedPowerFlow)
  PowerGrids.Electrical.Buses.Bus NTLV(SNom = 5e+08, UNom = 21000, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Branches.TransformerFixedRatio TGEN(PStartA = 4.75e+08, PStartB = -4.75e+08, QStartA = 1.56e+08, QStartB = -7.6e+07, R = 0.15e-2 * 419 ^ 2 / 500, SNom = 5e+08, UNomA = 21000, UNomB = 419000, UPhaseStartA = 0.161156, UPhaseStartB = 0, UStartA = 0.9917 * 21e3, UStartB = 0.95227 * 380e3, X = 16e-2 * 419 ^ 2 / 500, portVariablesPhases = true, portVariablesPu = true, rFixed = 419 / 21)
  PowerGrids.Electrical.Buses.EquivalentGrid GRID(R_X = 1 / 10, SNom = 5e+08, SSC = 2.5e+09, UNom = 380000, URef = 1.05 * 380e3, c = 1.1, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Loads.LoadImpedancePQ GRIDL(PRefConst = 4.75e+08, QRefConst = 7.6e+07, SNom = 5e+08, UNom = 380000, URef = 1.05 * 380e3, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Buses.BusFault NTHV(R = 0.05,SNom = 5e+08, UNom = 380000, UPhaseStart = 0, UStart = 1.050 * 380e3,portVariablesPhases = true, portVariablesPu = true, startTime = 2, stopTime = 2.1)
  PowerGrids.Examples.Tutorial.GridOperation.Controlled.ControlledGenerator ctrlGEN(AVR(Ka = 150))
equation
  connect(NTLV.terminal, TGEN.terminalA)
  connect(TGEN.terminalB, NTHV.terminal)
  connect(NTHV.terminal, GRID.terminal)
  connect(NTHV.terminal, GRIDL.terminal)
  connect(ctrlGEN.terminal, NTLV.terminal)

end ControlledGridWithControlledGen;


System under automatic control without PSS.

within PowerGrids.Examples.Tutorial.GridOperation.Controlled;
model ControlledGridWithoutPSS "System under automatic control without PSS"
  extends Modelica.Icons.Example;
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.Machines.SynchronousMachine4Windings GEN(H = 4, PStart = -4.75e+08, QStart = -1.56e+08,SNom = 5e+08, Tpd0 = 5.143, Tppd0 = 0.042, Tppq0 = 0.083, Tpq0 = 2.16, UNom = 21000, UPhaseStart = 0.161156, UStart = 21e3 * 0.9917, portVariablesPhases = true, raPu = 0, xdPu = 2, xlPu = 0.15, xpdPu = 0.35, xppdPu = 0.25, xppqPu = 0.3, xpqPu = 0.5, xqPu = 1.8)
  PowerGrids.Electrical.Buses.Bus NTLV(SNom = 5e+08, UNom = 21000, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Branches.TransformerFixedRatio TGEN(PStartA = 4.75e+08, PStartB = -4.75e+08, QStartA = 1.56e+08, QStartB = -7.6e+07, R = 0.15e-2 * 419 ^ 2 / 500, SNom = 5e+08, UNomA = 21000, UNomB = 419000, UPhaseStartA = 0.161156, UPhaseStartB = 0, UStartA = 0.9917 * 21e3, UStartB = 0.95227 * 380e3, X = 16e-2 * 419 ^ 2 / 500, portVariablesPhases = true, portVariablesPu = true, rFixed = 419 / 21)
  PowerGrids.Electrical.Buses.EquivalentGrid GRID(R_X = 1 / 10, SNom = 5e+08, SSC = 2.5e+09, UNom = 380000, URef = 1.05 * 380e3, c = 1.1, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Loads.LoadImpedancePQ GRIDL(PRefConst = 4.75e+08, QRefConst = 7.6e+07, SNom = 5e+08, UNom = 380000, URef = 1.05 * 380e3, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Controls.TurbineGovernors.IEEE_TGOV1 TGOV(R = 0.05, T1 = 0.5, T2 = 3, T3 = 10, VMax = 1)
  PowerGrids.Electrical.Controls.ExcitationSystems.IEEE_AC4A AVR(Ka = 200, Ta = 0.05, Tb = 10, Tc = 3, VrMax = 4)
  Modelica.Blocks.Sources.RealExpression zero
  Modelica.Blocks.Sources.RealExpression VrefPu(y = 1.004552)
  Modelica.Blocks.Sources.RealExpression RefLPu(y = 475 / 500 * 0.05)
  PowerGrids.Electrical.Buses.BusFault NTHV(R = 0.05,SNom = 5e+08, UNom = 380000, UPhaseStart = 0, UStart = 1.050 * 380e3,portVariablesPhases = true, portVariablesPu = true, startTime = 2, stopTime = 2.1)
equation
  connect(GEN.terminal, NTLV.terminal)
  connect(NTLV.terminal, TGEN.terminalA)
  connect(TGEN.terminalB, NTHV.terminal)
  connect(NTHV.terminal, GRID.terminal)
  connect(NTHV.terminal, GRIDL.terminal)
  connect(RefLPu.y, TGOV.RefLPu)
  connect(AVR.VrefPu, VrefPu.y)
  connect(AVR.VsPu, zero.y)
  connect(AVR.VuelPu, zero.y)
  connect(GEN.ufPuIn, AVR.efdPu)
  connect(TGOV.PMechPu, GEN.PmPu)
  connect(GEN.VPu, AVR.VcPu)
  connect(GEN.omegaPu, TGOV.omegaPu)
end ControlledGridWithoutPSS;


System under automatic control including PSS.

within PowerGrids.Examples.Tutorial.GridOperation.Controlled;
model ControlledGridWithPSS "System under automatic control including PSS"
  extends Modelica.Icons.Example;
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.Machines.SynchronousMachine4Windings GEN(H = 4, PStart = -4.75e+08, QStart = -1.56e+08,SNom = 5e+08, Tpd0 = 5.143, Tppd0 = 0.042, Tppq0 = 0.083, Tpq0 = 2.16, UNom = 21000, UPhaseStart = 0.161156, UStart = 21e3 * 0.9917, portVariablesPhases = true, raPu = 0, xdPu = 2, xlPu = 0.15, xpdPu = 0.35, xppdPu = 0.25, xppqPu = 0.3, xpqPu = 0.5, xqPu = 1.8)
  PowerGrids.Electrical.Buses.Bus NTLV(SNom = 5e+08, UNom = 21000, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Branches.TransformerFixedRatio TGEN(PStartA = 4.75e+08, PStartB = -4.75e+08, QStartA = 1.56e+08, QStartB = -7.6e+07, R = 0.15e-2 * 419 ^ 2 / 500, SNom = 5e+08, UNomA = 21000, UNomB = 419000, UPhaseStartA = 0.161156, UPhaseStartB = 0, UStartA = 0.9917 * 21e3, UStartB = 0.95227 * 380e3, X = 16e-2 * 419 ^ 2 / 500, portVariablesPhases = true, portVariablesPu = true, rFixed = 419 / 21)
  PowerGrids.Electrical.Buses.EquivalentGrid GRID(R_X = 1 / 10, SNom = 5e+08, SSC = 2.5e+09, UNom = 380000, URef = 1.05 * 380e3, c = 1.1, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Loads.LoadImpedancePQ GRIDL(PRefConst = 4.75e+08, QRefConst = 7.6e+07, SNom = 5e+08, UNom = 380000, URef = 1.05 * 380e3, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Controls.TurbineGovernors.IEEE_TGOV1 TGOV(R = 0.05, T1 = 0.5, T2 = 3, T3 = 10, VMax = 1)
  PowerGrids.Electrical.Controls.ExcitationSystems.IEEE_AC4A AVR(Ka = 200, Ta = 0.05, Tb = 10, Tc = 3, VrMax = 4)
  Modelica.Blocks.Sources.RealExpression zero
  Modelica.Blocks.Sources.RealExpression VrefPu(y = 1.004552)
  Modelica.Blocks.Sources.RealExpression RefLPu(y = 475 / 500 * 0.05)
  PowerGrids.Electrical.Buses.BusFault NTHV(R = 0.05,SNom = 5e+08, UNom = 380000, UPhaseStart = 0, UStart = 1.050 * 380e3,portVariablesPhases = true, portVariablesPu = true, startTime = 2, stopTime = 2.1)
  PowerGrids.Electrical.Controls.PowerSystemStabilizers.IEEE_PSS2A PSS(Ks1 = 10, Ks2 = 0.1564, M = 0, N = 0, T1 = 0.25, T2 = 0.03, T3 = 0.15, T4 = 0.015, T7 = 2, T8 = 0.5, T9 = 0.1, Tw1 = 2, Tw2 = 2, Tw3 = 2, Tw4 = 0, VstMax = 0.1, VstMin = -0.1)
equation
  connect(GEN.terminal, NTLV.terminal)
  connect(NTLV.terminal, TGEN.terminalA)
  connect(TGEN.terminalB, NTHV.terminal)
  connect(NTHV.terminal, GRID.terminal)
  connect(NTHV.terminal, GRIDL.terminal)
  connect(RefLPu.y, TGOV.RefLPu)
  connect(AVR.VrefPu, VrefPu.y)
  connect(AVR.VuelPu, zero.y)
  connect(GEN.ufPuIn, AVR.efdPu)
  connect(TGOV.PMechPu, GEN.PmPu)
  connect(GEN.VPu, AVR.VcPu)
  connect(GEN.omegaPu, TGOV.omegaPu)
  connect(PSS.VstPu, AVR.VsPu)
  connect(PSS.Vsi1Pu, GEN.omegaPu)
  connect(PSS.Vsi2Pu, GEN.PPu)

end ControlledGridWithPSS;


System under automatic control with automatic computation of set point offsets.

within PowerGrids.Examples.Tutorial.GridOperation.Controlled;
model ControlledGridWithReferenceCalculation "System under automatic control with automatic computation of set point offsets"
  extends Modelica.Icons.Example;
  inner PowerGrids.Electrical.System systemPowerGrids(initOpt = PowerGrids.Types.Choices.InitializationOption.globalSteadyStateFixedPowerFlow)
  PowerGrids.Electrical.Machines.SynchronousMachine4Windings GEN(H = 4, PStart = -4.75e+08, QStart = -1.56e+08,SNom = 5e+08, Tpd0 = 5.143, Tppd0 = 0.042, Tppq0 = 0.083, Tpq0 = 2.16, UNom = 21000, UPhaseStart = 0.161156, UStart = 21e3 * 0.9917, portVariablesPhases = true, raPu = 0, xdPu = 2, xlPu = 0.15, xpdPu = 0.35, xppdPu = 0.25, xppqPu = 0.3, xpqPu = 0.5, xqPu = 1.8)
  PowerGrids.Electrical.Buses.Bus NTLV(SNom = 5e+08, UNom = 21000, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Branches.TransformerFixedRatio TGEN(PStartA = 4.75e+08, PStartB = -4.75e+08, QStartA = 1.56e+08, QStartB = -7.6e+07, R = 0.15e-2 * 419 ^ 2 / 500, SNom = 5e+08, UNomA = 21000, UNomB = 419000, UPhaseStartA = 0.161156, UPhaseStartB = 0, UStartA = 0.9917 * 21e3, UStartB = 0.95227 * 380e3, X = 16e-2 * 419 ^ 2 / 500, portVariablesPhases = true, portVariablesPu = true, rFixed = 419 / 21)
  PowerGrids.Electrical.Buses.EquivalentGrid GRID(R_X = 1 / 10, SNom = 5e+08, SSC = 2.5e+09, UNom = 380000, URef = 1.05 * 380e3, c = 1.1, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Loads.LoadImpedancePQ GRIDL(PRefConst = 4.75e+08, QRefConst = 7.6e+07, SNom = 5e+08, UNom = 380000, URef = 1.05 * 380e3, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Controls.TurbineGovernors.IEEE_TGOV1 TGOV(PMechPuStart = -GEN.PStart / GEN.SNom,R = 0.05, T1 = 0.5, T2 = 3, T3 = 10, VMax = 1)
  PowerGrids.Electrical.Controls.ExcitationSystems.IEEE_AC4A AVR(Ka = 200, Ta = 0.05, Tb = 10, Tc = 3, VcPuStart = GEN.UStart/GEN.UNom, VrMax = 4)
  Modelica.Blocks.Sources.RealExpression zero
  PowerGrids.Electrical.Buses.Bus NTHV(SNom = 5e+08, UNom = 380000, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Controls.PowerSystemStabilizers.IEEE_PSS2A PSS(Ks1 = 10, Ks2 = 0.1564, M = 0, N = 0, T1 = 0.25, T2 = 0.03, T3 = 0.15, T4 = 0.015, T7 = 2, T8 = 0.5, T9 = 0.1, Tw1 = 2, Tw2 = 2, Tw3 = 2, Tw4 = 0, VstMax = 0.1, VstMin = -0.1)
  PowerGrids.Controls.FreeOffset RefLPu
  PowerGrids.Controls.FreeOffset VrefPu(use_u = true)
  Modelica.Blocks.Sources.RealExpression deltaVrefPu(y=if time >= 2 then 3e3*sin(2*Modelica.Constants.pi * 0.05 *(time-2))/GEN.UNom else 0)

  Real VrefPuTot = deltaVrefPu.y + GEN.VStartPu;

equation
  connect(GEN.terminal, NTLV.terminal)
  connect(NTLV.terminal, TGEN.terminalA)
  connect(TGEN.terminalB, NTHV.terminal)
  connect(NTHV.terminal, GRID.terminal)
  connect(NTHV.terminal, GRIDL.terminal)
  connect(AVR.VuelPu, zero.y)
  connect(GEN.ufPuIn, AVR.efdPu)
  connect(TGOV.PMechPu, GEN.PmPu)
  connect(GEN.VPu, AVR.VcPu)
  connect(GEN.omegaPu, TGOV.omegaPu)
  connect(PSS.VstPu, AVR.VsPu)
  connect(PSS.Vsi1Pu, GEN.omegaPu)
  connect(PSS.Vsi2Pu, GEN.PPu)
  connect(VrefPu.y, AVR.VrefPu)
  connect(RefLPu.y, TGOV.RefLPu)
  connect(deltaVrefPu.y, VrefPu.u)
end ControlledGridWithReferenceCalculation;


System under automatic control with automatic computation of set point offsets - saturation case.

within PowerGrids.Examples.Tutorial.GridOperation.Controlled;
model ControlledGridWithReferenceCalculationSat "System under automatic control with automatic computation of set point offsets - saturation case"
  extends ControlledGridWithReferenceCalculation(AVR.VrMax = 0.5);
end ControlledGridWithReferenceCalculationSat;


within PowerGrids.Examples.Tutorial.GridOperation;
package Controlled "Models of grid-connected systems with generator controllers"
  extends Modelica.Icons.ExamplesPackage;
end Controlled;


Load step response specified by input signals.

within PowerGrids.Examples.Tutorial.GridOperation.LoadChange;
model LoadChangeByInputSignals "Load step response specified by input signals"
  extends Modelica.Icons.Example;
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.Machines.SynchronousMachine4Windings GEN(H = 4, PStart = -4.75e+08, QStart = -1.56e+08,SNom = 5e+08, Tpd0 = 5.143, Tppd0 = 0.042, Tppq0 = 0.083, Tpq0 = 2.16, UNom = 21000, UPhaseStart = 0.161156, UStart = 21e3 * 0.9917, portVariablesPhases = true, raPu = 0, xdPu = 2, xlPu = 0.15, xpdPu = 0.35, xppdPu = 0.25, xppqPu = 0.3, xpqPu = 0.5, xqPu = 1.8)
  PowerGrids.Electrical.Buses.Bus NTLV(SNom = 5e+08, UNom = 21000, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Buses.BusFault NTHV(R = 0.05,SNom = 5e+08, UNom = 380000, UPhaseStart = 0, UStart = 1.050 * 380e3,portVariablesPhases = true, portVariablesPu = true, startTime = 1e10, stopTime = 1e10)
  PowerGrids.Electrical.Branches.TransformerFixedRatio TGEN(PStartA = 4.75e+08, PStartB = -4.75e+08, QStartA = 1.56e+08, QStartB = -7.6e+07, R = 0.15e-2 * 419 ^ 2 / 500, SNom = 5e+08, UNomA = 21000, UNomB = 419000, UPhaseStartA = 0.161156, UPhaseStartB = 0, UStartA = 0.9917 * 21e3, UStartB = 0.95227 * 380e3, X = 16e-2 * 419 ^ 2 / 500, portVariablesPhases = true, portVariablesPu = true, rFixed = 419 / 21)
  PowerGrids.Electrical.Buses.EquivalentGrid GRID(R_X = 1 / 10, SNom = 5e+08, SSC = 2.5e+09, UNom = 380000, URef = 1.05 * 380e3, c = 1.1, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Loads.LoadImpedancePQInputs GRIDL(SNom = 5e+08, UNom = 380000, URef = 1.05 * 380e3, portVariablesPhases = true, portVariablesPu = true)
  Modelica.Blocks.Sources.RealExpression PmPu(y = -GEN.PStart / GEN.SNom)
  Modelica.Blocks.Sources.RealExpression ufPuIn(y = GEN.ufPuInStart)
  Modelica.Blocks.Sources.Step PRef(height = 475e6 * 0.05, offset = 475e6, startTime = 2)
  Modelica.Blocks.Sources.Step QRef(height = 76e6 * 0.04, offset = 76e6, startTime = 2)
equation
  connect(PmPu.y, GEN.PmPu)
  connect(ufPuIn.y, GEN.ufPuIn)
  connect(GEN.terminal, NTLV.terminal)
  connect(NTLV.terminal, TGEN.terminalA)
  connect(TGEN.terminalB, NTHV.terminal)
  connect(NTHV.terminal, GRID.terminal)
  connect(NTHV.terminal, GRIDL.terminal)
  connect(PRef.y, GRIDL.PRefIn)
  connect(QRef.y, GRIDL.QRefIn)
end LoadChangeByInputSignals;


Load step response specified by modifiers on a copy of the static system.

within PowerGrids.Examples.Tutorial.GridOperation.LoadChange;
model LoadChangeByModifier "Load step response specified by modifiers on a copy of the static system"
  extends Modelica.Icons.Example;
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.Machines.SynchronousMachine4Windings GEN(H = 4, PStart = -4.75e+08, QStart = -1.56e+08,SNom = 5e+08, Tpd0 = 5.143, Tppd0 = 0.042, Tppq0 = 0.083, Tpq0 = 2.16, UNom = 21000, UPhaseStart = 0.161156, UStart = 21e3 * 0.9917, portVariablesPhases = true, raPu = 0, xdPu = 2, xlPu = 0.15, xpdPu = 0.35, xppdPu = 0.25, xppqPu = 0.3, xpqPu = 0.5, xqPu = 1.8)
  PowerGrids.Electrical.Buses.Bus NTLV(SNom = 5e+08, UNom = 21000, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Buses.Bus NTHV(SNom = 5e+08, UNom = 380000, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Branches.TransformerFixedRatio TGEN(PStartA = 4.75e+08, PStartB = -4.75e+08, QStartA = 1.56e+08, QStartB = -7.6e+07, R = 0.15e-2 * 419 ^ 2 / 500, SNom = 5e+08, UNomA = 21000, UNomB = 419000, UPhaseStartA = 0.161156, UPhaseStartB = 0, UStartA = 0.9917 * 21e3, UStartB = 0.95227 * 380e3, X = 16e-2 * 419 ^ 2 / 500, portVariablesPhases = true, portVariablesPu = true, rFixed = 419 / 21)
  PowerGrids.Electrical.Buses.EquivalentGrid GRID(R_X = 1 / 10, SNom = 5e+08, SSC = 2.5e+09, UNom = 380000, URef = 1.05 * 380e3, c = 1.1, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Loads.LoadImpedancePQ GRIDL(
      PRef = 4.75e+08*(if time < 2 then 1 else 1.05) "Active power consumption at reference voltage",
      QRef = 7.6e+07*(if time < 2 then 1 else 1.04) "Reactive power consumption at reference voltage",
      SNom = 5e+08,
      UNom = 380000,
      URef = 1.05 * 380e3,
      portVariablesPhases = true,
      portVariablesPu = true)
  Modelica.Blocks.Sources.RealExpression PmPu(y = -GEN.PStart / GEN.SNom)
  Modelica.Blocks.Sources.RealExpression ufPuIn(y = GEN.ufPuInStart)

equation
  connect(PmPu.y, GEN.PmPu)
  connect(ufPuIn.y, GEN.ufPuIn)
  connect(GRIDL.terminal, NTHV.terminal)
  connect(GEN.terminal, NTLV.terminal)
  connect(NTLV.terminal, TGEN.terminalA)
  connect(TGEN.terminalB, NTHV.terminal)
  connect(NTHV.terminal, GRID.terminal)
end LoadChangeByModifier;


Load step response specified by modifiers by inheritance from the static system.

within PowerGrids.Examples.Tutorial.GridOperation.LoadChange;
model LoadChangeByModifierUsingExtends "Load step response specified by modifiers by inheritance from the static system"
  extends Examples.Tutorial.GridOperation.Static.StaticGridComputedParameters(
    GRIDL(
      PRef = GRIDL.PRefConst*(if time < 2 then 1 else 1.05) "Active power consumption at reference voltage",
      QRef = GRIDL.QRefConst*(if time < 2 then 1 else 1.04) "Reactive power consumption at reference voltage"));
end LoadChangeByModifierUsingExtends;


within PowerGrids.Examples.Tutorial.GridOperation;
package LoadChange "Models of grid-connected systems subject to open-loop load changes"
  extends Modelica.Icons.ExamplesPackage;
end LoadChange;


within PowerGrids.Examples.Tutorial.GridOperation;
package Static "Models of grid-connected systems operating in steady-state"
  extends Modelica.Icons.ExamplesPackage;
end Static;


Power flow for the basic grid used in the tutorial.

within PowerGrids.Examples.Tutorial.GridOperation.Static;
model PowerFlow "Power flow for the basic grid used in the tutorial"
  extends Modelica.Icons.Example;
  PowerGrids.Electrical.PowerFlow.PVBus GEN(P = -4.75e+8, SNom = 5e+8, U = 20825.8, UNom = 21000, generatorConvention = false, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Buses.Bus NTLV(SNom = 5e+8, UNom = 21000, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Branches.TransformerFixedRatio TGEN( R = 0.15e-2 * 419 ^ 2 / 500, SNom = 5e+8, UNomA = 21000, UNomB = 419000, X = 16e-2 * 419 ^ 2 / 500, portVariablesPhases = true, portVariablesPu = true, rFixed = 419 / 21)
  PowerGrids.Electrical.Buses.Bus NTHV(SNom = 5e+8, UNom = 380000, portVariablesPhases = true, portVariablesPu = true)
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.PowerFlow.PQBus GRIDL(P = 4.75e+8, Q = 7.6e+7, SNom = 5e+8, UNom = 380000, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.PowerFlow.SlackBus GRID(SNom = 5e+8, U = 399000, UNom = 380000, portVariablesPhases = true, portVariablesPu = true)
equation
  connect(GEN.terminal, NTLV.terminal)
  connect(NTLV.terminal, TGEN.terminalA)
  connect(TGEN.terminalB, NTHV.terminal)
  connect(NTHV.terminal, GRID.terminal)
  connect(GRIDL.terminal, NTHV.terminal)
end PowerFlow;


System operating in steady-state with given inputs.

within PowerGrids.Examples.Tutorial.GridOperation.Static;
model StaticGrid "System operating in steady-state with given inputs"
  extends Modelica.Icons.Example;
  inner PowerGrids.Electrical.System systemPowerGrids
  PowerGrids.Electrical.Machines.SynchronousMachine4Windings GEN(H = 4, PStart = -4.75e+08, QStart = -1.56e+08,SNom = 5e+08, Tpd0 = 5.143, Tppd0 = 0.042, Tppq0 = 0.083, Tpq0 = 2.16, UNom = 21000, UPhaseStart = 0.161156, UStart = 21e3 * 0.9917, portVariablesPhases = true, raPu = 0, xdPu = 2, xlPu = 0.15, xpdPu = 0.35, xppdPu = 0.25, xppqPu = 0.3, xpqPu = 0.5, xqPu = 1.8)
  PowerGrids.Electrical.Buses.Bus NTLV(SNom = 5e+08, UNom = 21000, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Buses.Bus NTHV(SNom = 5e+08, UNom = 380000, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Branches.TransformerFixedRatio TGEN( R = 0.15e-2 * 419 ^ 2 / 500, SNom = 5e+08, UNomA = 21000, UNomB = 419000, X = 16e-2 * 419 ^ 2 / 500, portVariablesPhases = true, portVariablesPu = true, rFixed = 419 / 21)
  PowerGrids.Electrical.Buses.EquivalentGrid GRID(R_X = 1 / 10, SNom = 5e+08, SSC = 2.5e+09, UNom = 380000, URef = 1.05 * 380e3, c = 1.1, portVariablesPhases = true, portVariablesPu = true)
  PowerGrids.Electrical.Loads.LoadImpedancePQ GRIDL(PRefConst = 4.75e+08, QRefConst = 7.6e+07, SNom = 5e+08, UNom = 380000, UPhaseStart = 0, URef = 1.05 * 380e3, UStart = 399000, portVariablesPhases = true, portVariablesPu = true)
  Modelica.Blocks.Sources.RealExpression PmPu(y = 0.95)
  Modelica.Blocks.Sources.RealExpression ufPuIn(y = 2.50826)
equation
  connect(PmPu.y, GEN.PmPu)
  connect(ufPuIn.y, GEN.ufPuIn)
  connect(GRIDL.terminal, NTHV.terminal)
  connect(GEN.terminal, NTLV.terminal)
  connect(NTLV.terminal, TGEN.terminalA)
  connect(TGEN.terminalB, NTHV.terminal)
  connect(NTHV.terminal, GRID.terminal)
end StaticGrid;


System operating in steady-state with computed inputs.

within PowerGrids.Examples.Tutorial.GridOperation.Static;
model StaticGridComputedParameters "System operating in steady-state with computed inputs"
  extends StaticGrid(
    PmPu(y = -GEN.PStart / GEN.SNom),
    ufPuIn(y = GEN.ufPuInStart));
end StaticGridComputedParameters;