Skip to content

Instantly share code, notes, and snippets.

@christiankral
Created March 5, 2017 08:26
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/ca370b3dd910d5ad0fff46dab12a84e0 to your computer and use it in GitHub Desktop.
Save christiankral/ca370b3dd910d5ad0fff46dab12a84e0 to your computer and use it in GitHub Desktop.
model TestMultiPhaseConverter
import Modelica.Constants.pi;
extends Modelica.Icons.Example;
Modelica.Electrical.Analog.Basic.Ground groundDC annotation (
Placement(visible = true, transformation(origin={-60,0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.MultiPhase.Basic.Star star annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={80,-60})));
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{70,-96},{90,-76}})));
Modelica.Electrical.MultiPhase.Sources.CosineVoltage cosineVoltage(
freqHz=fill(50, 3),
V=fill(400*sqrt(2/3), 3),
phase=-Modelica.Electrical.MultiPhase.Functions.symmetricOrientation(3))
annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={80,-30})));
Modelica.Blocks.Sources.Ramp rampCurrent(
height=100,
offset=0,
startTime=0,
duration=5) annotation (Placement(transformation(extent={{-100,20},{-80,40}})));
Modelica.Blocks.Sources.Constant powerfactor(k=-acos(0.9))
annotation (Placement(transformation(extent={{-30,-52},{-10,-32}})));
PhotoVoltaics.Components.Converters.MultiPhaseConverter converter(VmpRef=
moduleData.VmpRef, ImpRef=moduleData.ImpRef,
Smax=5000) annotation (Placement(transformation(extent={{-10,20},{10,40}})));
parameter PhotoVoltaics.Records.SHARP_NU_S5_E3E moduleData annotation (Placement(transformation(extent={{60,60},{80,80}})));
Modelica.Electrical.MultiPhase.Sensors.PowerSensor powerSensorGrid annotation (Placement(transformation(extent={{20,20},{40,40}})));
Modelica.Electrical.MultiPhase.Sensors.VoltageQuasiRMSSensor voltageQuasiRMSSensor(m=3) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={50,-30})));
Modelica.Electrical.MultiPhase.Sensors.CurrentQuasiRMSSensor currentQuasiRMSSensor(final m=3) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={80,10})));
Modelica.Blocks.Math.Division powerFactorActual annotation (Placement(transformation(extent={{-70,-90},{-90,-70}})));
Modelica.Blocks.Math.Product product annotation (Placement(transformation(extent={{30,-90},{10,-70}})));
Modelica.Blocks.Math.Gain gain(final k=3)
annotation (Placement(transformation(extent={{0,-90},{-20,-70}})));
Modelica.SIunits.Power powerDC = powerSensor.power "DC power";
Modelica.SIunits.Power powerAC = powerSensorGrid.power "AC real power";
Modelica.SIunits.ApparentPower aparrentPowerAC = powerFactorActual.u2
"AC apparent power";
Real powerFactorAC = powerFactorActual.y "Actual power factor";
Modelica.Blocks.Nonlinear.Limiter limiter(uMax=Modelica.Constants.inf, uMin=Modelica.Constants.small) annotation (Placement(transformation(extent={{-28,-90},{-48,-70}})));
Modelica.Blocks.Sources.Constant constVdc(k=100) annotation (Placement(transformation(extent={{-100,-30},{-80,-10}})));
Modelica.Electrical.Analog.Sources.SignalCurrent signalCurrent annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=90,
origin={-60,30})));
Modelica.Electrical.Analog.Sensors.PowerSensor powerSensor annotation (
Placement(transformation(extent={{-40,40},{-20,60}})));
equation
connect(ground.p,star. pin_n)
annotation (Line(points={{80,-76},{80,-76},{80,-74},{80,-74},{80,-70},{80,-70}},
color={0,0,255}));
connect(cosineVoltage.plug_n,star. plug_p)
annotation (Line(points={{80,-40},{80,-46},{80,-50}}, color={0,0,255}));
connect(converter.dc_n, groundDC.p)
annotation (Line(points={{-10,20},{-10,10},{-60,10}},color={0,0,255}));
connect(powerfactor.y, converter.phi) annotation (Line(points={{-9,-42},{6,-42},{6,18}}, color={0,0,127}));
connect(converter.ac, powerSensorGrid.pc) annotation (Line(points={{10,30},{16,30},{20,30}},
color={0,0,255}));
connect(powerSensorGrid.pv, powerSensorGrid.pc) annotation (Line(points={{30,40},{20,40},{20,30}},color={0,0,255}));
connect(powerSensorGrid.nv, star.plug_p) annotation (Line(points={{30,20},{30,20},{30,-2},{30,-50},{80,-50}}, color={0,0,255}));
connect(powerSensorGrid.nc, currentQuasiRMSSensor.plug_p) annotation (Line(points={{40,30},{54,30},{80,30},{80,20}}, color={0,0,255}));
connect(currentQuasiRMSSensor.plug_n, cosineVoltage.plug_p) annotation (Line(points={{80,0},{80,-6},{80,-20}},
color={0,0,255}));
connect(voltageQuasiRMSSensor.plug_n, star.plug_p) annotation (Line(points={{50,-40},{50,-50},{80,-50}}, color={0,0,255}));
connect(voltageQuasiRMSSensor.plug_p, currentQuasiRMSSensor.plug_n) annotation (Line(points={{50,-20},{50,-10},{80,-10},{80,0}}, color={0,0,255}));
connect(powerFactorActual.u1, powerSensorGrid.power) annotation (Line(points={{-68,-74},{-60,-74},{-60,-60},{22,-60},{22,19}}, color={0,0,127}));
connect(gain.u, product.y) annotation (Line(points={{2,-80},{9,-80}}, color={0,0,127}));
connect(product.u1, currentQuasiRMSSensor.I) annotation (Line(points={{32,-74},{32,-74},{34,-74},{34,-32},{34,10},{70,10}}, color={0,0,127}));
connect(product.u2, voltageQuasiRMSSensor.V) annotation (Line(points={{32,-86},{38,-86},{38,-30},{40,-30}}, color={0,0,127}));
connect(limiter.y, powerFactorActual.u2) annotation (Line(points={{-49,-80},{-60,-80},{-60,-84},{-60,-86},{-68,-86}}, color={0,0,127}));
connect(limiter.u, gain.y) annotation (Line(points={{-26,-80},{-21,-80}}, color={0,0,127}));
connect(constVdc.y, converter.vDCRef) annotation (Line(points={{-79,-20},{-42,-20},{-6,-20},{-6,18}}, color={0,0,127}));
connect(signalCurrent.p, groundDC.p) annotation (Line(points={{-60,20},{-60,15},{-60,10}}, color={0,0,255}));
connect(rampCurrent.y, signalCurrent.i) annotation (Line(points={{-79,30},{-74,30},{-67,30}}, color={0,0,127}));
connect(powerSensor.pc,powerSensor. pv) annotation (
Line(points={{-40,50},{-40,60},{-30,60}}, color = {0, 0, 255}));
connect(converter.dc_p,powerSensor. nc)
annotation (Line(points={{-10,40},{-10,50},{-20,50}},
color={0,0,255}));
connect(powerSensor.nv,groundDC. p) annotation (
Line(points={{-30,40},{-30,40},{-30,12},{-30,10},{-60,10}}, color = {0, 0, 255}));
connect(powerSensor.pc, signalCurrent.n) annotation (Line(points={{-40,50},{-60,50},{-60,40}}, color={0,0,255}));
annotation (
Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,
-100},{100,100}})), experiment(StopTime=5, Interval=0.0001),
uses(Modelica(version="3.2.2"), PhotoVoltaics(version="1.0.0")));
end TestMultiPhaseConverter;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment