Skip to content

Instantly share code, notes, and snippets.

@christiankral
Last active May 12, 2022 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christiankral/72645586c2a92ec10a8f914359d3e235 to your computer and use it in GitHub Desktop.
Save christiankral/72645586c2a92ec10a8f914359d3e235 to your computer and use it in GitHub Desktop.
Cases of load flow currently not working under OpenModelica 1.20.0~dev-33-g9ccf941
package LoadFlowCases
model LoadFlow
extends Modelica.Icons.Example;
import Modelica.Constants.pi;
parameter Modelica.Units.SI.Impedance ZLoad = 1 "Load impedance";
parameter Modelica.Units.SI.Impedance ZLine = 0.1 "Load impedance";
parameter Modelica.Units.SI.Angle phiLoad = 1E-2 * pi / 180 "Load phase angle";
parameter Modelica.Units.SI.Angle phiLine = 89.99 * pi / 180 "Line phase angle";
parameter Modelica.Units.SI.Angle phi = 89.99 * pi / 180 "Transformer voltage phase angle";
Modelica.Electrical.QuasiStatic.SinglePhase.Sources.VoltageSource voltageSource(V = 100, f = 50, gamma(displayUnit = "rad", fixed = true, start = 0), phi = 0) annotation (
Placement(visible = true, transformation(origin = {-80, -10}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Electrical.QuasiStatic.SinglePhase.Sources.VariableVoltageSource deltaVoltageSource(gamma(displayUnit = "rad", fixed = true, start = 0)) annotation (
Placement(visible = true, transformation(origin = {-40, 20}, extent = {{10, 10}, {-10, -10}}, rotation = 0)));
Modelica.Electrical.QuasiStatic.SinglePhase.Basic.Ground ground annotation (
Placement(visible = true, transformation(origin = {-80, -50}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.QuasiStatic.SinglePhase.Basic.Impedance impedance1(Z_ref = Complex(ZLine * cos(phiLine), ZLine * sin(phiLine))) annotation (
Placement(visible = true, transformation(origin = {-10, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.QuasiStatic.SinglePhase.Basic.Impedance impedance1p(Z_ref = Complex(ZLine * cos(phiLine), ZLine * sin(phiLine))) annotation (
Placement(visible = true, transformation(origin = {-10, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.QuasiStatic.SinglePhase.Basic.VariableImpedance load annotation (
Placement(visible = true, transformation(origin = {60, -10}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.ComplexBlocks.Sources.ComplexRampPhasor voltageRamp(duration = 1, magnitude1 = 0, magnitude2 = 10, phi = phi, startTime = 0, useLogRamp = false) annotation (
Placement(visible = true, transformation(origin = {-30, -20}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
Modelica.ComplexBlocks.Sources.ComplexRampPhasor loadRamp(duration = 1,magnitude1 = ZLoad, magnitude2 = ZLoad, phi = phiLoad, startTime = 0, useLogRamp = true) annotation (
Placement(visible = true, transformation(origin = {90, -10}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
Modelica.Electrical.QuasiStatic.SinglePhase.Sensors.PowerSensor powerSensor1 annotation (
Placement(visible = true, transformation(origin = {20, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.QuasiStatic.SinglePhase.Sensors.PowerSensor powerSensor1p annotation (
Placement(visible = true, transformation(origin = {40, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Sources.Constant frequency(k = 50) annotation (
Placement(visible = true, transformation(origin = {-50, -70}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
equation
connect(load.pin_n, ground.pin) annotation (
Line(points = {{60, -20}, {60, -40}, {-80, -40}}, color = {85, 170, 255}));
connect(ground.pin, voltageSource.pin_n) annotation (
Line(points = {{-80, -40}, {-80, -20}}, color = {85, 170, 255}));
connect(loadRamp.y, load.Z_ref) annotation (
Line(points = {{79, -10}, {72, -10}}, color = {85, 170, 255}));
connect(powerSensor1p.currentP, powerSensor1p.voltageP) annotation (
Line(points = {{30, 60}, {30, 70}, {40, 70}}, color = {85, 170, 255}));
connect(powerSensor1.currentP, powerSensor1.voltageP) annotation (
Line(points = {{10, 20}, {10, 30}, {20, 30}}, color = {85, 170, 255}));
connect(powerSensor1.voltageN, ground.pin) annotation (
Line(points = {{20, 10}, {20, -40}, {-80, -40}}, color = {85, 170, 255}));
connect(powerSensor1p.voltageN, ground.pin) annotation (
Line(points = {{40, 50}, {40, -40}, {-80, -40}}, color = {85, 170, 255}));
connect(deltaVoltageSource.V, voltageRamp.y) annotation (
Line(points = {{-34, 8}, {-34, 0.5}, {-30, 0.5}, {-30, -9}}, color = {85, 170, 255}));
connect(frequency.y, deltaVoltageSource.f) annotation (
Line(points = {{-50, -59}, {-50, -0.5}, {-46, -0.5}, {-46, 8}}, color = {0, 0, 127}));
connect(voltageSource.pin_p, deltaVoltageSource.pin_n) annotation (
Line(points = {{-80, 0}, {-80, 20}, {-50, 20}}, color = {85, 170, 255}));
connect(deltaVoltageSource.pin_p, impedance1.pin_p) annotation (
Line(points = {{-30, 20}, {-20, 20}}, color = {85, 170, 255}));
connect(impedance1.pin_n, powerSensor1.currentP) annotation (
Line(points = {{0, 20}, {10, 20}}, color = {85, 170, 255}));
connect(powerSensor1.currentN, load.pin_p) annotation (
Line(points = {{30, 20}, {60, 20}, {60, 0}}, color = {85, 170, 255}));
connect(powerSensor1p.currentN, load.pin_p) annotation (
Line(points = {{50, 60}, {60, 60}, {60, 0}}, color = {85, 170, 255}));
connect(impedance1p.pin_n, powerSensor1p.currentP) annotation (
Line(points = {{0, 60}, {30, 60}}, color = {85, 170, 255}));
connect(impedance1p.pin_p, voltageSource.pin_p) annotation (
Line(points = {{-20, 60}, {-80, 60}, {-80, 0}}, color = {85, 170, 255}));
end LoadFlow;
extends Modelica.Icons.Package;
model LoadFlow1
import Modelica.Constants.pi;
extends LoadFlowCases.LoadFlow(phiLine=90*pi/180);
equation
end LoadFlow1;
model LoadFlow2
import Modelica.Constants.pi;
extends LoadFlowCases.LoadFlow(phiLoad=0,phiLine=90*pi/180,phi=0);
equation
end LoadFlow2;
annotation(uses(Modelica(version = "4.0.0")));
end LoadFlowCases;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment