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 *
The validationtools are used to validate the simulate results from the model.
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
- Mapping the results with the reference results
- Asserting the module
- Mapping the results to the reference results
- Asserting the model results
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
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.
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
- Current: remove unnecessary current variables
:param neplan_timeseries: result of neplan in timeseries
......@@ -48,25 +58,25 @@ def convert_neplan_to_modelica_timeseries(neplan_timeseries):
for num_to_del in range(len(line_del)):
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)):
if 'ANGLE' in neplan_timeseries[i].name:
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:
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)):
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('.U', '.Vpp')
neplan_timeseries[i].name = neplan_timeseries[i].name.replace('.ANGLEI', '.Iangle')
neplan_timeseries[i].name = neplan_timeseries[i].name.replace('.ANGLEU', v_angle_std_suffix)
neplan_timeseries[i].name = neplan_timeseries[i].name.replace('.U', v_abs_std_suffix)
neplan_timeseries[i].name = neplan_timeseries[i].name.replace('.ANGLEI', i_angle_std_suffix)
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
:return: a result timeseries
......@@ -74,8 +84,8 @@ def convert_simulink_to_modelica_timeseries(simseri):
for check in range(len(simseri)):
if 'U AB:' in simseri[check].name:
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('VDegree', 'Vangle')
simseri[check].name = simseri[check].name.replace('Vrms', v_abs_std_suffix)
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('_', '')
if 'Vangle' in simseri[check].name:
......@@ -83,7 +93,8 @@ def convert_simulink_to_modelica_timeseries(simseri):
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
: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):
for ts,values in dpsim_timeseries.items():
ts_abs = values.abs(ts + '.Vpp')
ts_phase = values.phase(ts + '.Vangle')
ts_abs = values.abs() = re.sub("_abs", v_abs_std_suffix,
ts_phase = values.phase() = re.sub("_phase", v_angle_std_suffix,
......@@ -182,9 +195,9 @@ def validate_modelica_res(net_name, modelica_res_path, reference_res_path, thres
print('\n************************ Reference Results ****************')
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':
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:
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