Space phasors are defined as vectors of length = 2, the first element representing the real part and the second element representing the imaginary part of the space phasor.
Extends from Modelica.Icons.Package (Icon for standard packages).
| Name | Description |
|---|---|
| Conversion: three phase -> space phasor | |
| Conversion: space phasor -> three phase | |
| Rotates space phasor | |
| Converts a space phasor to polar coordinates | |
| Converts a space phasor from polar coordinates | |
| Calculate quasi-RMS value of input | |
| Calculate active power of voltage and current input |
Modelica.Electrical.Machines.SpacePhasors.Functions.ToSpacePhasor
Extends from Modelica.Icons.Function (Icon for functions).
| Type | Name | Default | Description |
|---|---|---|---|
| Real | x[3] |
| Type | Name | Description |
|---|---|---|
| Real | y[2] | |
| Real | y0 |
function ToSpacePhasor "Conversion: three phase -> space phasor"
extends Modelica.Icons.Function;
constant Integer m=3 "Number of phases";
constant Real pi=Modelica.Constants.pi;
input Real x[3];
output Real y[2];
output Real y0;
algorithm
y := zeros(2);
for k in 1:m loop
y := y + 2/m*{+cos((k - 1)/m*2*pi), +sin(+(k - 1)/m*2*pi)}*x[k];
end for;
y0 := 1/m*sum(x);
end ToSpacePhasor;
Modelica.Electrical.Machines.SpacePhasors.Functions.FromSpacePhasor
Extends from Modelica.Icons.Function (Icon for functions).
| Type | Name | Default | Description |
|---|---|---|---|
| Real | x[2] | ||
| Real | x0 |
| Type | Name | Description |
|---|---|---|
| Real | y[3] |
function FromSpacePhasor "Conversion: space phasor -> three phase"
extends Modelica.Icons.Function;
constant Integer m=3 "Number of phases";
constant Real pi=Modelica.Constants.pi;
input Real x[2];
input Real x0;
output Real y[3];
algorithm
for k in 1:m loop
y[k] := x0 + {cos(-(k - 1)/m*2*pi),-sin(-(k - 1)/m*2*pi)}*x;
end for;
end FromSpacePhasor;
Modelica.Electrical.Machines.SpacePhasors.Functions.Rotator
Extends from Modelica.Icons.Function (Icon for functions).
| Type | Name | Default | Description |
|---|---|---|---|
| Real | x[2] | ||
| Angle | angle | [rad] |
| Type | Name | Description |
|---|---|---|
| Real | y[2] |
function Rotator "Rotates space phasor"
extends Modelica.Icons.Function;
input Real x[2];
input Modelica.SIunits.Angle angle;
output Real y[2];
protected
Real RotationMatrix[2,2] = {{+cos(-angle),-sin(-angle)},{+sin(-angle),+cos(-angle)}};
algorithm
y := RotationMatrix*x;
end Rotator;
Modelica.Electrical.Machines.SpacePhasors.Functions.ToPolar
Extends from Modelica.Icons.Function (Icon for functions).
| Type | Name | Default | Description |
|---|---|---|---|
| Real | x[2] |
| Type | Name | Description |
|---|---|---|
| Real | absolute | |
| Angle | angle | [rad] |
function ToPolar "Converts a space phasor to polar coordinates"
extends Modelica.Icons.Function;
constant Real small=Modelica.Constants.small;
input Real x[2];
output Real absolute;
output Modelica.SIunits.Angle angle;
algorithm
absolute := sqrt(x[1]^2 + x[2]^2);
angle := if absolute <= small then 0 else Modelica.Math.atan2(x[2], x[1]);
/*
if absolute <= small then
angle := 0;
else
if x[2] >= 0 then
angle := Modelica.Math.acos(x[1]/absolute);
else
angle := -Modelica.Math.acos(x[1]/absolute);
end if;
end if;
*/
end ToPolar;
Modelica.Electrical.Machines.SpacePhasors.Functions.FromPolar
Extends from Modelica.Icons.Function (Icon for functions).
| Type | Name | Default | Description |
|---|---|---|---|
| Real | absolute | ||
| Angle | angle | [rad] |
| Type | Name | Description |
|---|---|---|
| Real | x[2] |
function FromPolar "Converts a space phasor from polar coordinates"
extends Modelica.Icons.Function;
constant Real pi=Modelica.Constants.pi;
constant Real small=Modelica.Constants.small;
input Real absolute;
input Modelica.SIunits.Angle angle;
output Real x[2];
algorithm
x := absolute*{cos(angle),sin(angle)};
end FromPolar;
Modelica.Electrical.Machines.SpacePhasors.Functions.quasiRMS
Extends from Modelica.Icons.Function (Icon for functions).
| Type | Name | Default | Description |
|---|---|---|---|
| Real | x[3] |
| Type | Name | Description |
|---|---|---|
| Real | y |
function quasiRMS "Calculate quasi-RMS value of input"
extends Modelica.Icons.Function;
constant Integer m=3 "Number of phases";
constant Real pi=Modelica.Constants.pi;
input Real x[3];
output Real y;
protected
Real h[2];
algorithm
h := zeros(2);
for k in 1:m loop
h := h + 2/m*{+cos((k - 1)/m*2*pi), +sin(+(k - 1)/m*2*pi)}*x[k];
end for;
y := sqrt(h[1]^2 + h[2]^2)/sqrt(2);
end quasiRMS;
Modelica.Electrical.Machines.SpacePhasors.Functions.activePower
Extends from Modelica.Icons.Function (Icon for functions).
| Type | Name | Default | Description |
|---|---|---|---|
| Voltage | v[m] | phase voltages [V] | |
| Current | i[m] | phase currents [A] |
| Type | Name | Description |
|---|---|---|
| Power | p | Active power [W] |
function activePower
"Calculate active power of voltage and current input"
extends Modelica.Icons.Function;
constant Integer m=3 "Number of phases";
import Modelica.Constants.pi;
input Modelica.SIunits.Voltage v[m] "phase voltages";
input Modelica.SIunits.Current i[m] "phase currents";
output Modelica.SIunits.Power p "Active power";
protected
Modelica.SIunits.Voltage v_[2] "Voltage space phasor";
Modelica.SIunits.Current i_[2] "Current space phasor";
algorithm
v_ := zeros(2);
i_ := zeros(2);
for k in 1:m loop
v_ := v_ + 2/m*{+cos((k - 1)/m*2*pi), +sin(+(k - 1)/m*2*pi)}*v[k];
i_ := i_ + 2/m*{+cos((k - 1)/m*2*pi), +sin(+(k - 1)/m*2*pi)}*i[k];
end for;
p :=m/2*(+v_[1]*i_[1] + v_[2]*i_[2]);
end activePower;