Aufgrund einer Konfigurationsänderung wird die GitLab Registry ab 10 Uhr nur Read Only zur Verfügung stehen. / Due to a configuration change, the GitLab Registry will be available for read-only access from 10am.

Commit ab644338 authored by Jan Dinkelbach's avatar Jan Dinkelbach

conversion to standard timeseries for validation

parent 959526a3
...@@ -8,22 +8,32 @@ from .readtools import * ...@@ -8,22 +8,32 @@ from .readtools import *
""" """
The validationtools are used to validate the simulate results from the model. The validationtools are used to validate the simulate results from the model.
A typical process to validate a model contains four parts A typical process to validate a model contains four parts
- Building & Running the module to get results - Building and running the model to get results
- Reading in the results - Reading in the results
- Mapping the results with the reference results - Mapping the results to the reference results
- Asserting the module - Asserting the model results
The first step is done by Py4Mod package, the second by readtool. The first step is done by Py4Mod package, the second by readtool.
The validationtool focuses on the last two steps: the conversion function converts the reference-results The validationtool focuses on the last two steps: the conversion function converts the reference-results
timeseries into the modelica timeseries (mapping the names and units), the comparision function compares two timeseries into the standard timeseries (mapping the names and units), the comparision function compares two
timeseries, and the assert function gives an assertion to the result comparison. timeseries, and the assert function gives an assertion to the result comparison.
At last, a top level validation function is introduced to organize the whole job. At last, a top level validation function is introduced to organize the whole job.
The standard timeseries format is specified by a set of names (see below) and the specification that all angles are
given in radiant.
""" """
def convert_neplan_to_modelica_timeseries(neplan_timeseries): # Standard Timeseries Format Naming
v_abs_std_suffix = ".V"
v_angle_std_suffix = ".Vangle"
i_abs_std_suffix = ".I"
i_angle_std_suffix = ".Iangle"
def convert_neplan_to_standard_timeseries(neplan_timeseries):
""" """
Mapping the variable names between modelica and neplan Mapping the variable names from neplan to the standard timeseries format
- Voltage: change *.U and *.ANGLEU to *.V and *.Vangle - Voltage: change *.U and *.ANGLEU to *.V and *.Vangle
- Current: remove unnecessary current variables - Current: remove unnecessary current variables
:param neplan_timeseries: result of neplan in timeseries :param neplan_timeseries: result of neplan in timeseries
...@@ -48,25 +58,25 @@ def convert_neplan_to_modelica_timeseries(neplan_timeseries): ...@@ -48,25 +58,25 @@ def convert_neplan_to_modelica_timeseries(neplan_timeseries):
for num_to_del in range(len(line_del)): for num_to_del in range(len(line_del)):
del neplan_timeseries[line_del[len(line_del) - num_to_del - 1]] del neplan_timeseries[line_del[len(line_del) - num_to_del - 1]]
# Change the unit of variables to keep consistent with those in modelica # Change the unit of variables to keep consistent with those in standard timeseries format
for i in range(len(neplan_timeseries)): for i in range(len(neplan_timeseries)):
if 'ANGLE' in neplan_timeseries[i].name: if 'ANGLE' in neplan_timeseries[i].name:
neplan_timeseries[i].values = neplan_timeseries[i].values / 180 * cmath.pi # unification of the unit neplan_timeseries[i].values = neplan_timeseries[i].values / 180 * cmath.pi # unification of the unit
elif '.U' in neplan_timeseries[i].name or '.I' in neplan_timeseries[i].name: elif '.U' in neplan_timeseries[i].name or '.I' in neplan_timeseries[i].name:
neplan_timeseries[i].values = neplan_timeseries[i].values * 1000 neplan_timeseries[i].values = neplan_timeseries[i].values * 1000
# Change the name of variables to keep consistent with those in modelica # Change the name of variables to keep consistent with those in standard timeseries format
for i in range(len(neplan_timeseries)): for i in range(len(neplan_timeseries)):
neplan_timeseries[i].name = neplan_timeseries[i].name.replace(' ', '') neplan_timeseries[i].name = neplan_timeseries[i].name.replace(' ', '')
neplan_timeseries[i].name = neplan_timeseries[i].name.replace('.ANGLEU', '.Vangle') neplan_timeseries[i].name = neplan_timeseries[i].name.replace('.ANGLEU', v_angle_std_suffix)
neplan_timeseries[i].name = neplan_timeseries[i].name.replace('.U', '.Vpp') neplan_timeseries[i].name = neplan_timeseries[i].name.replace('.U', v_abs_std_suffix)
neplan_timeseries[i].name = neplan_timeseries[i].name.replace('.ANGLEI', '.Iangle') neplan_timeseries[i].name = neplan_timeseries[i].name.replace('.ANGLEI', i_angle_std_suffix)
return neplan_timeseries return neplan_timeseries
def convert_simulink_to_modelica_timeseries(simseri):
def convert_simulink_to_standard_timeseries(simseri):
""" """
Convert the steady-state results timeseries from simulink to modelica timeseries Convert the steady-state results timeseries from simulink to standard timeseries format
:param simseri: simulate timeseries, generated by the result file from simulink :param simseri: simulate timeseries, generated by the result file from simulink
:return: a result timeseries :return: a result timeseries
""" """
...@@ -74,8 +84,8 @@ def convert_simulink_to_modelica_timeseries(simseri): ...@@ -74,8 +84,8 @@ def convert_simulink_to_modelica_timeseries(simseri):
for check in range(len(simseri)): for check in range(len(simseri)):
if 'U AB:' in simseri[check].name: if 'U AB:' in simseri[check].name:
simseri[check].name = simseri[check].name.replace('U AB:', '') simseri[check].name = simseri[check].name.replace('U AB:', '')
simseri[check].name = simseri[check].name.replace('Vrms', 'Vpp') simseri[check].name = simseri[check].name.replace('Vrms', v_abs_std_suffix)
simseri[check].name = simseri[check].name.replace('VDegree', 'Vangle') simseri[check].name = simseri[check].name.replace('VDegree', v_angle_std_suffix)
simseri[check].name = simseri[check].name.replace(' ', '') simseri[check].name = simseri[check].name.replace(' ', '')
simseri[check].name = simseri[check].name.replace('_', '') simseri[check].name = simseri[check].name.replace('_', '')
if 'Vangle' in simseri[check].name: if 'Vangle' in simseri[check].name:
...@@ -83,7 +93,8 @@ def convert_simulink_to_modelica_timeseries(simseri): ...@@ -83,7 +93,8 @@ def convert_simulink_to_modelica_timeseries(simseri):
res.append(simseri[check]) res.append(simseri[check])
return res return res
def convert_dpsim_to_modelica_timeseries(dpsim_timeseries):
def convert_dpsim_to_standard_timeseries(dpsim_timeseries):
""" """
Convert the steady-state results timeseries from dpsim to modelica timeseries Convert the steady-state results timeseries from dpsim to modelica timeseries
:param dpsim_timeseries: dict of dpsim timeseries, generated by the csv result file from dpsim :param dpsim_timeseries: dict of dpsim timeseries, generated by the csv result file from dpsim
...@@ -91,8 +102,10 @@ def convert_dpsim_to_modelica_timeseries(dpsim_timeseries): ...@@ -91,8 +102,10 @@ def convert_dpsim_to_modelica_timeseries(dpsim_timeseries):
""" """
ts_dpsimList=[] ts_dpsimList=[]
for ts,values in dpsim_timeseries.items(): for ts,values in dpsim_timeseries.items():
ts_abs = values.abs(ts + '.Vpp') ts_abs = values.abs()
ts_phase = values.phase(ts + '.Vangle') ts_abs.name = re.sub("_abs", v_abs_std_suffix, ts_abs.name)
ts_phase = values.phase()
ts_phase.name = re.sub("_phase", v_angle_std_suffix, ts_phase.name)
ts_phase.values*=np.pi/180 ts_phase.values*=np.pi/180
ts_dpsimList.append(ts_abs) ts_dpsimList.append(ts_abs)
ts_dpsimList.append(ts_phase) ts_dpsimList.append(ts_phase)
...@@ -182,9 +195,9 @@ def validate_modelica_res(net_name, modelica_res_path, reference_res_path, thres ...@@ -182,9 +195,9 @@ def validate_modelica_res(net_name, modelica_res_path, reference_res_path, thres
print('\n************************ Reference Results ****************') print('\n************************ Reference Results ****************')
if os.path.splitext(reference_res_path)[1] == '.rep': if os.path.splitext(reference_res_path)[1] == '.rep':
res_ref = convert_simulink_to_modelica_timeseries(read_timeseries_simulink_loadflow(reference_res_path)) res_ref = convert_simulink_to_standard_timeseries(read_timeseries_simulink_loadflow(reference_res_path))
elif os.path.splitext(reference_res_path)[1] == '.rlf': elif os.path.splitext(reference_res_path)[1] == '.rlf':
res_ref = convert_neplan_to_modelica_timeseries(read_timeseries_NEPLAN_loadflow(reference_res_path)) res_ref = convert_neplan_to_standard_timeseries(read_timeseries_NEPLAN_loadflow(reference_res_path))
for res in res_ref: for res in res_ref:
print(res.name) print(res.name)
print(res.values) print(res.values)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment