Skip to content

Commit a6cbfb6

Browse files
committed
More annotation clean up
1 parent 6a3298c commit a6cbfb6

6 files changed

Lines changed: 342 additions & 328 deletions

File tree

OpenIPSL/Electrical/Solar/PowerFactory/General/StaVmea.mo

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
within OpenIPSL.Electrical.Solar.PowerFactory.General;
22
model StaVmea "Voltage Measurement Device"
3-
parameter Types.Time Tfe = 3 / 50 "Measurement delay"
4-
annotation (Dialog(enable = use_ref_machine_frequency));
5-
parameter Types.Frequency fn = 50 "Nominal frequency";
6-
parameter Types.Angle angle_0 = 0 "Initial angle";
7-
parameter Boolean use_ref_machine_frequency = false "Use reference machine frequency"
8-
annotation(choices(checkBox=true));
3+
parameter Types.Time Tfe=3/50 "Measurement delay" annotation (Dialog(enable=use_ref_machine_frequency));
4+
parameter Types.Frequency fn=50 "Nominal frequency";
5+
parameter Types.Angle angle_0=0 "Initial angle";
6+
parameter Boolean use_ref_machine_frequency=false "Use reference machine frequency" annotation (choices(checkBox=true));
97
OpenIPSL.Interfaces.PwPin p annotation (Placement(transformation(extent={{-120,-10},{-100,10}})));
10-
Real cosphi(start = cos(angle_0));
11-
Real sinphi(start = sin(angle_0));
12-
Types.Frequency df(start = 0) "Frequency difference";
8+
Real cosphi(start=cos(angle_0));
9+
Real sinphi(start=sin(angle_0));
10+
Types.Frequency df(start=0) "Frequency difference";
1311
Types.PerUnit vx "Voltage component";
1412
Types.PerUnit vy "Voltage component";
1513
Modelica.Blocks.Interfaces.RealOutput u "Voltage magnitude [pu]" annotation (Placement(transformation(extent={{100,50},{120,70}})));
1614
Modelica.Blocks.Interfaces.RealOutput fe "Electrical frequency [Hz]" annotation (Placement(transformation(extent={{100,-70},{120,-50}})));
17-
Modelica.Blocks.Interfaces.RealInput omega if use_ref_machine_frequency
18-
"Reference machine frequency [Hz]"
19-
annotation (Placement(transformation(extent={{-140,40},{-100,80}})));
15+
Modelica.Blocks.Interfaces.RealInput omega if use_ref_machine_frequency "Reference machine frequency [Hz]" annotation (Placement(transformation(extent={{-140,40},{-100,80}})));
2016

2117
protected
2218
Modelica.Blocks.Interfaces.RealInput omega_internal "Helping variable/connector";
@@ -25,43 +21,46 @@ protected
2521
Modelica.Blocks.Interfaces.RealInput local_df if not use_ref_machine_frequency "Conditional frequency difference";
2622
Modelica.Blocks.Interfaces.RealInput local_df_internal "Helping variable/connector";
2723
equation
28-
u = sqrt(p.vr ^ 2 + p.vi ^ 2);
29-
connect(omega,omega_internal);
30-
connect(phi,phi_internal);
31-
connect(local_df,local_df_internal);
24+
u = sqrt(p.vr^2 + p.vi^2);
25+
connect(omega, omega_internal);
26+
connect(phi, phi_internal);
27+
connect(local_df, local_df_internal);
3228
if use_ref_machine_frequency then
33-
der(phi_internal) = 2 * C.pi * 50 * (omega_internal - 1)
34-
"First this has to be transformed to the rotating reference frame (w.r.t. the frequency of the reference machine) to correspond to PowerFactory implementation
29+
der(phi_internal) = 2*C.pi*50*(omega_internal - 1) "First this has to be transformed to the rotating reference frame (w.r.t. the frequency of the reference machine) to correspond to PowerFactory implementation
3530
";
36-
vx = p.vr * cos(phi_internal) + p.vi * sin(phi_internal);
37-
vy = (-p.vr * sin(phi_internal)) + p.vi * cos(phi_internal);
38-
der(cosphi) = (vx / u - cosphi) / Tfe;
39-
der(sinphi) = (vy / u - sinphi) / Tfe;
31+
vx = p.vr*cos(phi_internal) + p.vi*sin(phi_internal);
32+
vy = (-p.vr*sin(phi_internal)) + p.vi*cos(phi_internal);
33+
der(cosphi) = (vx/u - cosphi)/Tfe;
34+
der(sinphi) = (vy/u - sinphi)/Tfe;
4035
fe = omega_internal + df;
4136
else
4237
cosphi = vx/u;
4338
sinphi = vy/u;
44-
der(local_df_internal) = (df - local_df_internal) /Tfe;
39+
der(local_df_internal) = (df - local_df_internal)/Tfe;
4540
vx = p.vr;
4641
vy = p.vi;
4742
fe = 1 + local_df_internal;
4843
omega_internal = 0 "Balance equation";
4944
phi_internal = 0 "Balance equation";
5045
end if;
5146
if abs(cosphi) > abs(sinphi) then
52-
df = der(sinphi) / cosphi / (2 * C.pi * fn);
47+
df = der(sinphi)/cosphi/(2*C.pi*fn);
5348
else
54-
df = -der(cosphi) / sinphi / (2 * C.pi * fn);
49+
df = -der(cosphi)/sinphi/(2*C.pi*fn);
5550
end if;
5651
p.ii = 0;
5752
p.ir = 0;
58-
annotation (
59-
Icon(graphics={ Rectangle(fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-100, 100}, {100, -100}}), Text(extent={{-80,90},{80,70}}, textString="StaVmeas"), Text(extent={{70,70},{90,50}}, textString="u"), Text(extent={{70,-50},{90,-70}}, textString="fe"),
60-
Text(
53+
annotation (Icon(graphics={
54+
Rectangle(
55+
fillColor={255,255,255},
56+
fillPattern=FillPattern.Solid,
57+
extent={{-100,100},{100,-100}}),
58+
Text(extent={{70,70},{90,50}}, textString="u"),
59+
Text(extent={{70,-50},{90,-70}}, textString="fe"),
60+
Text(
6161
extent={{-100,20},{100,-20}},
6262
lineColor={0,0,0},
63-
textString="%name")}, coordinateSystem),
64-
Documentation(info="<html>
63+
textString="%name")}, coordinateSystem), Documentation(info="<html>
6564
<p>
6665
StaVmea model in PowerFactory measures voltage and frequency.
6766
The frequency in PowerFactory is computed with respect to the frame rotating with frequency

0 commit comments

Comments
 (0)