Skip to content

Instantly share code, notes, and snippets.

@johanrhodin
Created February 2, 2016 16:39
Show Gist options
  • Save johanrhodin/d701a67a3dfe6ac6a8c2 to your computer and use it in GitHub Desktop.
Save johanrhodin/d701a67a3dfe6ac6a8c2 to your computer and use it in GitHub Desktop.
Small example for Wolfram Community, demonstrate how to use "Modelica.Electrical.MultiPhase.Basic.Star"
model StarExample
extends Modelica.Icons.Example;
import Modelica.Constants.pi;
Modelica.Electrical.MultiPhase.Basic.Star star(m = m) annotation(Placement(visible = true, transformation(origin = {-60, 40}, extent = {{-10, -10}, {10, 10}}, rotation = -540)));
Modelica.Electrical.Analog.Basic.Ground ground annotation(Placement(visible = true, transformation(origin = {-80, -80}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Sources.SineVoltage sineVoltage(V = 10, freqHz = 1) annotation(Placement(visible = true, transformation(origin = {-80, -0}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
Modelica.Electrical.MultiPhase.Sources.SineVoltage sineVoltage1(final m = m, V = fill(sqrt(2) * VRMS, m), freqHz = fill(f, m)) annotation(Placement(transformation(origin = {0, 0}, extent = {{10, -10}, {-10, 10}}, rotation = 90), visible = true));
Modelica.Electrical.MultiPhase.Basic.Star star1(final m = m) annotation(Placement(transformation(extent = {{10, -10}, {-10, 10}}, rotation = 90, origin = {0, -40}), visible = true));
Modelica.Electrical.Analog.Basic.Ground ground1 annotation(Placement(transformation(origin = {0, -80}, extent = {{-10, -10}, {10, 10}}, rotation = 0), visible = true));
Modelica.Electrical.MultiPhase.Basic.Resistor resistor(m = m, R = fill(R, m)) annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 270, origin = {70, -0}), visible = true));
Modelica.Electrical.MultiPhase.Basic.Inductor inductor(m = m, L = fill(L, m)) annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 270, origin = {70, -30}), visible = true));
Modelica.Electrical.MultiPhase.Basic.Star starLoad(m = m) annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 270, origin = {70, -60}), visible = true));
Modelica.Electrical.MultiPhase.Sensors.CurrentQuasiRMSSensor currentQuasiRMSSensor(m = m) annotation(Placement(transformation(extent = {{-10, 10}, {10, -10}}, rotation = 270, origin = {70, 80}), visible = true));
Modelica.Electrical.MultiPhase.Sensors.PowerSensor powerSensor(m = m) annotation(Placement(transformation(extent = {{10, -10}, {-10, 10}}, rotation = 90, origin = {70, 30}), visible = true));
constant Integer m = 3 "Number of phases";
parameter Modelica.SIunits.Voltage VRMS = 100 "Nominal RMS voltage per phase";
parameter Modelica.SIunits.Frequency f = 50 "Frequency";
parameter Modelica.SIunits.Resistance R = 1 / sqrt(2) "Load resistance";
parameter Modelica.SIunits.Inductance L = 1 / sqrt(2) / (2 * pi * f) "Load inductance";
Modelica.Electrical.MultiPhase.Basic.Resistor resistor1(m = m, R = fill(R, m)) annotation(Placement(transformation(extent = {{-10, -10}, {10, 10}}, rotation = 0, origin = {-30, 40}), visible = true));
equation
connect(star.plug_p, resistor1.plug_p) annotation(Line(visible = true, origin = {-45, 40}, points = {{-5, 0}, {5, 0}}, color = {0, 0, 255}));
connect(powerSensor.nv, starLoad.plug_p) annotation(Line(points = {{30, 20}, {30, -60}, {20, -60}}, color = {0, 0, 255}, visible = true, origin = {50, 10}));
connect(powerSensor.pc, powerSensor.pv) annotation(Line(points = {{20, 30}, {10, 30}, {10, 20}}, color = {0, 0, 255}, visible = true, origin = {50, 10}));
connect(currentQuasiRMSSensor.plug_n, powerSensor.pc) annotation(Line(points = {{20, 60}, {20, 30}}, color = {0, 0, 255}, visible = true, origin = {50, 10}));
connect(powerSensor.nc, resistor.plug_p) annotation(Line(points = {{20, 10}, {20, 0}}, color = {0, 0, 255}, visible = true, origin = {50, 10}));
connect(sineVoltage1.plug_p, currentQuasiRMSSensor.plug_p) annotation(Line(points = {{-35, -61.5}, {-35, 21.5}, {35, 21.5}, {35, 18.5}}, color = {0, 0, 255}, visible = true, origin = {35, 71.5}));
connect(inductor.plug_n, starLoad.plug_p) annotation(Line(points = {{20, -50}, {20, -60}}, color = {0, 0, 255}, visible = true, origin = {50, 10}));
connect(resistor.plug_n, inductor.plug_p) annotation(Line(points = {{20, -20}, {20, -30}}, color = {0, 0, 255}, visible = true, origin = {50, 10}));
connect(sineVoltage1.plug_n, star1.plug_p) annotation(Line(points = {{0, 10}, {-0, -10}}, color = {0, 0, 255}, visible = true, origin = {0, -20}));
connect(star1.pin_n, ground1.p) annotation(Line(points = {{-0, 10}, {0, -10}}, color = {0, 0, 255}, visible = true, origin = {0, -60}));
connect(sineVoltage.p, star.pin_n) annotation(Line(visible = true, origin = {-76.667, 30}, points = {{-3.333, -20}, {-3.333, 10}, {6.667, 10}}, color = {0, 0, 255}));
connect(sineVoltage.n, ground.p) annotation(Line(visible = true, origin = {-80, -40}, points = {{0, 30}, {0, -30}}, color = {0, 0, 255}));
annotation(experiment(StopTime = 1, __Wolfram_SynchronizeWithRealTime = false));
end StarExample;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment