shmem-cigre-mv-pf-profiles-dpsim.py 1.98 KB
Newer Older
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
59
60
61
62
63
64
65
66
import os
import urllib.request
import glob

import dpsimpy

name = 'CIGRE-MV-Profiles'
files = glob.glob('build/_deps/cim-data-src/CIGRE_MV/NEPLAN/CIGRE_MV_no_tapchanger_With_LoadFlow_Results/*.xml')
print(files)

reader = dpsimpy.CIMReader(name)
system = reader.loadCIM(50, files, dpsimpy.Domain.SP, dpsimpy.PhaseType.Single)

csv_files = glob.glob('build/_deps/profile-data-src/CIGRE_MV_NoTap/load_profiles/')[0]
print(csv_files)

assignList = { }
assignList['LOAD-H-1'] = 'Load_H_1'
assignList['LOAD-H-3'] = 'Load_H_3'
assignList['LOAD-H-4'] = 'Load_H_4'
assignList['LOAD-H-5'] = 'Load_H_5'
assignList['LOAD-H-6'] = 'Load_H_6'
assignList['LOAD-H-8'] = 'Load_H_8'
assignList['LOAD-H-10'] = 'Load_H_10'
assignList['LOAD-H-11'] = 'Load_H_11'
assignList['LOAD-H-12'] = 'Load_H_12'
assignList['LOAD-H-14'] = 'Load_H_14'
assignList['LOAD-I-1'] = 'Load_I_1'
assignList['LOAD-I-3'] = 'Load_I_3'
assignList['LOAD-I-7'] = 'Load_I_7'
assignList['LOAD-I-9'] = 'Load_I_9'
assignList['LOAD-I-10'] = 'Load_I_10'
assignList['LOAD-I-12'] = 'Load_I_12'
assignList['LOAD-I-13'] = 'Load_I_13'
assignList['LOAD-I-14'] = 'Load_I_14'

csvreader = dpsimpy.CSVReader(name, csv_files, assignList, dpsimpy.LogLevel.info)
csvreader.assignLoadProfile(system, 0, 1, 300, dpsimpy.CSVReaderMode.MANUAL, dpsimpy.CSVReaderFormat.SECONDS)

sim = dpsimpy.RealTimeSimulation(name)
sim.set_system(system)
sim.set_domain(dpsimpy.Domain.SP)
sim.set_solver(dpsimpy.Solver.NRP)
sim.set_time_step(1)
sim.set_final_time(30)

logger = dpsimpy.Logger(name)
sim.add_logger(logger)

intf = dpsimpy.InterfaceShmem()
sim.add_interface(intf)

obj_list = system.list_idobjects()
node_list = {k: v for k, v in obj_list.items() if v == 'SimNode<std::complex<double> >'}
print(node_list)

for i in range(15):
    objname = 'N'+str(i)
    sim.export_attr(objname, 'v', (i*2), dpsimpy.AttrModifier.mag)
    sim.export_attr(objname, 'v', (i*2)+1, dpsimpy.AttrModifier.phase)
    print(objname)

for node in system.nodes:
    logger.log_attribute(node.name()+'.V', 'v', node)

sim.run(2)