|
1 | 1 | within OpenIPSL.Electrical.Solar.PowerFactory.General; |
2 | | -model StaVmea |
3 | | - parameter Types.Time Tfe = 3 / 50 annotation ( |
4 | | - Dialog(enable = use_ref_machine_frequency)); |
5 | | - parameter Types.Frequency fn = 50; |
6 | | - parameter Types.Angle angle_0; |
7 | | - parameter Boolean use_ref_machine_frequency = false; |
8 | | - OpenIPSL.Interfaces.PwPin p annotation ( |
9 | | - Placement(transformation(origin = {-110, 0}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {-110, 0}, extent = {{-10, -10}, {10, 10}}))); |
10 | | - Modelica.Blocks.Interfaces.RealOutput u annotation ( |
11 | | - Placement(transformation(origin = {118, 58}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {110, 50}, extent = {{-10, -10}, {10, 10}}))); |
12 | | - Modelica.Blocks.Interfaces.RealOutput fe annotation ( |
13 | | - Placement(transformation(origin = {108, -30}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {110, -50}, extent = {{-10, -10}, {10, 10}}))); |
| 2 | +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)); |
| 9 | + OpenIPSL.Interfaces.PwPin p annotation (Placement(transformation(extent={{-120,-10},{-100,10}}))); |
14 | 10 | Real cosphi(start = cos(angle_0)); |
15 | 11 | Real sinphi(start = sin(angle_0)); |
16 | | - Real df(start = 0); |
17 | | - Real phi if use_ref_machine_frequency; |
18 | | - Real vx; |
19 | | - Real vy; |
20 | | - Real local_df if not use_ref_machine_frequency; |
21 | | - Modelica.Blocks.Interfaces.RealInput omega if use_ref_machine_frequency annotation ( |
22 | | - Placement(transformation(origin = {-100, 70}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {-94, 70}, extent = {{-20, -20}, {20, 20}}))); |
| 12 | + Types.Frequency df(start = 0) "Frequency difference"; |
| 13 | + Types.PerUnit vx "Voltage component"; |
| 14 | + Types.PerUnit vy "Voltage component"; |
| 15 | + Modelica.Blocks.Interfaces.RealOutput u "Voltage magnitude [pu]" annotation (Placement(transformation(extent={{100,50},{120,70}}))); |
| 16 | + 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}}))); |
| 20 | + |
| 21 | +protected |
| 22 | + Modelica.Blocks.Interfaces.RealInput omega_internal "Helping variable/connector"; |
| 23 | + Modelica.Blocks.Interfaces.RealInput phi if use_ref_machine_frequency "Conditional angle"; |
| 24 | + Modelica.Blocks.Interfaces.RealInput phi_internal "Helping variable/connector"; |
| 25 | + Modelica.Blocks.Interfaces.RealInput local_df if not use_ref_machine_frequency "Conditional frequency difference"; |
| 26 | + Modelica.Blocks.Interfaces.RealInput local_df_internal "Helping variable/connector"; |
23 | 27 | equation |
24 | 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); |
25 | 32 | if use_ref_machine_frequency then |
26 | | -// 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 |
27 | | - der(phi) = 2 * Modelica.Constants.pi * 50 * (omega - 1); |
28 | | - vx = p.vr * cos(phi) + p.vi * sin(phi); |
29 | | - vy = (-p.vr * sin(phi)) + p.vi * cos(phi); |
| 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 |
| 35 | +"; |
| 36 | + vx = p.vr * cos(phi_internal) + p.vi * sin(phi_internal); |
| 37 | + vy = (-p.vr * sin(phi_internal)) + p.vi * cos(phi_internal); |
30 | 38 | der(cosphi) = (vx / u - cosphi) / Tfe; |
31 | 39 | der(sinphi) = (vy / u - sinphi) / Tfe; |
32 | | - fe = omega + df; |
| 40 | + fe = omega_internal + df; |
33 | 41 | else |
34 | 42 | cosphi = vx/u; |
35 | 43 | sinphi = vy/u; |
36 | | - der(local_df) = (df - local_df) /Tfe; |
| 44 | + der(local_df_internal) = (df - local_df_internal) /Tfe; |
37 | 45 | vx = p.vr; |
38 | 46 | vy = p.vi; |
39 | | - fe = 1 + local_df; |
| 47 | + fe = 1 + local_df_internal; |
| 48 | + omega_internal = 0 "Balance equation"; |
| 49 | + phi_internal = 0 "Balance equation"; |
40 | 50 | end if; |
41 | 51 | if abs(cosphi) > abs(sinphi) then |
42 | | - df = der(sinphi) / cosphi / (2 * Modelica.Constants.pi * fn); |
| 52 | + df = der(sinphi) / cosphi / (2 * C.pi * fn); |
43 | 53 | else |
44 | | - df = -der(cosphi) / sinphi / (2 * Modelica.Constants.pi * fn); |
| 54 | + df = -der(cosphi) / sinphi / (2 * C.pi * fn); |
45 | 55 | end if; |
46 | 56 | p.ii = 0; |
47 | 57 | p.ir = 0; |
48 | 58 | annotation ( |
49 | | - Icon(graphics = {Rectangle(fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, extent = {{-100, 100}, {100, -100}}), Text(origin = {0, 90}, extent = {{-100, 10}, {100, -10}}, textString = "StaVmeas"), Text(origin = {0, 50}, extent = {{62, 8}, {100, -10}}, textString = "u"), Text(origin = {0, -50}, extent = {{62, 8}, {100, -10}}, textString = "fe")}, coordinateSystem()), |
| 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( |
| 61 | + extent={{-100,20},{100,-20}}, |
| 62 | + lineColor={0,0,0}, |
| 63 | + textString="%name")}, coordinateSystem), |
50 | 64 | Documentation(info="<html> |
51 | 65 | <p> |
52 | | -StaVmea model in PowerFactory measures voltage and frequency. Frequency in PowerFactory is computed with respect to the frame rorating with frequency equal to the synchronous machine. This is supported via the input omega here. Most of the OpenIPSL examples do not provide omega of the reference machine and thus, if the input is not connected the frequency is computed with respect to the 50Hz reference frame and filtered to simulate the measurement delay. |
| 66 | +StaVmea model in PowerFactory measures voltage and frequency. |
| 67 | +The frequency in PowerFactory is computed with respect to the frame rotating with frequency |
| 68 | +equal to the synchronous machine. |
| 69 | +This is supported via the input <code>omega</code> here. |
| 70 | +Most of the OpenIPSL examples do not provide <code>omega</code> of the reference machine and thus, |
| 71 | +if the input is not connected the frequency is computed with respect to the 50 Hz reference frame |
| 72 | +and filtered to simulate the measurement delay. |
53 | 73 | </p> |
54 | 74 | </html>", revisions="<html> |
55 | 75 | <table cellspacing=\"1\" cellpadding=\"1\" border=\"1\"><tr> |
|
0 commit comments