compare_neplan_dpsim.py 2.35 KB
Newer Older
1
2
3
from villas.dataprocessing.readtools import *
from villas.dataprocessing.timeseries import *
import villas.dataprocessing.validationtools as validationtools
4
import os
5

6
# Path to NEPLAN result file (power flow result in *.rlf format)
7
neplan_result_file= os.path.abspath(r"..\sampledata\CIGRE_MV_NoTap.rlf")
8

9
# Path to DPsim result file (power flow result in *.csv format)
10
dpsim_result_file = os.path.abspath(r"..\sampledata\CIGRE-MV-NoTap.csv")
11

12
13
14
# Read in NEPLAN results
print('************************ reading neplan power flow data start ****************')
ts_NEPLAN = read_timeseries_NEPLAN_loadflow(neplan_result_file)
15
16
for i in range(len(ts_NEPLAN)):
    print('%s is %s' % (ts_NEPLAN[i].name, ts_NEPLAN[i].values)) # result as list of TimeSeries
17
print('************************ reading neplan power flow data end ****************')
18
19
print('\n')

20
# Read in DPsim powerflow results
21
print('************************ reading dpsim power flow data start ****************')
22
ts_dpsim = read_timeseries_csv(dpsim_result_file)
23
for ts,values in ts_dpsim.items():
24
25
    ts_abs = values.abs()
    ts_phase = values.phase()
26
    print(ts_abs.name + ': ' + str(ts_abs.values) + '\n' +ts_phase.name+' :'+ str(ts_phase.values))
27
print('************************ reading dpsim power flow data end ****************')
28

29
# Converting both timeseries objects to a common format and afterwards compare and assert the results
30
net_name='CIGRE_MV_NoTap'
31
threshold=0.5
32
33
print('************************ convert neplan to standard start ****************')
res_ref=validationtools.convert_neplan_to_standard_timeseries(ts_NEPLAN)
34
35
36
for i in range(len(res_ref)):
    print(res_ref[i].name)
    print(res_ref[i].values)
37
print('************************  convert neplan to standard end  ****************')
38

39
40
print('************************ convert dpsim to standard start  ****************')
ts_dpsimList=validationtools.convert_dpsim_to_standard_timeseries(ts_dpsim)
41
42
43
for i in range(len(ts_dpsimList)):
    print(ts_dpsimList[i].name)
    print(ts_dpsimList[i].values)
44
print('************************ convert dpsim to standard end  ****************')
45

46
print('************************ comparison and assertion start  ****************')
47
res_err=validationtools.compare_timeseries(res_ref,ts_dpsimList)
48
49
validationtools.assert_modelica_results(net_name,res_err,threshold)
print('************************ comparison and assertion end  ****************')