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

5 6
# Path to NEPLAN result file (power flow result in *.rlf format)
neplan_result_file=r"D:\git\data\reference-results\Neplan\ReferenceGrids\CIGRE_MV_NoTap.rlf"
7

8 9
# Path to DPsim result file (power flow result in *.csv format)
dpsim_result_file = "D:\\git\\code\\dpsim-powerflow-integration\\dpsim\\build\\Dependencies\\fpotencia\\src\\test\\Logs\\CIGRE-MV-NoTap-Neplan.csv"
10

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

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

28 29
# Converting both timeseries objects to a common format (here the Modelica format) and afterwards compare and assert the results
net_name='CIGRE_MV_NoTap'
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
threshold=0.5
print('************************ convert neplan to modelica start ****************')
res_ref=validationtools.convert_neplan_to_modelica_timeseries(ts_NEPLAN)
for i in range(len(res_ref)):
    print(res_ref[i].name)
    print(res_ref[i].values)
print('************************  convert neplan to modelica end  ****************')

print('************************ convert dpsim to modelica start  ****************')
ts_dpsimList=validationtools.convert_dpsim_to_modelica_timeseries(ts_dpsim)
for i in range(len(ts_dpsimList)):
    print(ts_dpsimList[i].name)
    print(ts_dpsimList[i].values)
print('************************ convert dpsim to modelica end  ****************')

res_err=validationtools.compare_timeseries(res_ref,ts_dpsimList)
46
validationtools.assert_modelica_results(net_name,res_err,threshold)