forked from sogno-platform/pyvolt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_switch_nv_state_estimator.py
58 lines (48 loc) · 2.07 KB
/
test_switch_nv_state_estimator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import logging
import numpy as np
from pyvolt import network
from pyvolt import nv_powerflow
from pyvolt import nv_state_estimator
from pyvolt import measurement
import cimpy
import os
logging.basicConfig(filename='test_switch_nv_state_estimator.log', level=logging.INFO, filemode='w')
this_file_folder = os.path.dirname(os.path.realpath(__file__))
xml_path = os.path.realpath(os.path.join(this_file_folder, "..", "sample_data", "CIGRE-MV-NoTap-WithBreaker"))
xml_files = [os.path.join(xml_path, "20191126T1535Z_YYY_EQ_.xml"),
os.path.join(xml_path, "20191126T1535Z_XX_YYY_SV_.xml"),
os.path.join(xml_path, "20191126T1535Z_XX_YYY_TP_.xml")]
# Read cim files and create new network.System object
res = cimpy.cim_import(xml_files, "cgmes_v2_4_15")
system = network.System()
base_apparent_power = 25 # MW
system.load_cim_data(res['topology'], base_apparent_power)
# Open breaker
system.breakers[-1].open_breaker()
system.Ymatrix_calc()
# Execute power flow analysis
results_pf, num_iter = nv_powerflow.solve(system)
# --- State Estimation ---
""" Write here the percent uncertainties of the measurements"""
V_unc = 0
I_unc = 0
Sinj_unc = 0
S_unc = 0
Pmu_mag_unc = 1
Pmu_phase_unc = 0
# Create measurements data structures
"""use all node voltages as measures"""
measurements_set = measurement.MeasurementSet()
for node in results_pf.nodes:
measurements_set.create_measurement(node.topology_node, measurement.ElemType.Node, measurement.MeasType.Vpmu_mag,
np.absolute(node.voltage_pu), Pmu_mag_unc)
for node in results_pf.nodes:
measurements_set.create_measurement(node.topology_node, measurement.ElemType.Node, measurement.MeasType.Vpmu_phase,
np.angle(node.voltage_pu), Pmu_phase_unc)
measurements_set.meas_creation()
# Perform state estimation
state_estimation_results = nv_state_estimator.DsseCall(system, measurements_set)
# Print node voltages
print("state_estimation_results.voltages: ")
for node in state_estimation_results.nodes:
print('{}={}'.format(node.topology_node.name, node.voltage))