-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path13bus_set_new_load.py
47 lines (37 loc) · 1.33 KB
/
13bus_set_new_load.py
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
# Kevin Moy, 8/6/2020
# Uses IEEE 13-bus system
# Test to see if we can set loads using generate_state_space.py
import win32com.client
import pandas as pd
import numpy as np
from generate_state_space import load_states
# Instantiate the OpenDSS Object
try:
DSSObj = win32com.client.Dispatch("OpenDSSEngine.DSS")
except:
print("Unable to start the OpenDSS Engine")
raise SystemExit
print("OpenDSS Engine started\n")
# Set up the Text, Circuit, and Solution Interfaces
DSSText = DSSObj.Text
DSSCircuit = DSSObj.ActiveCircuit
DSSSolution = DSSCircuit.Solution
# Load in an example circuit
DSSText.Command = r"Compile 'C:\Program Files\OpenDSS\IEEETestCases\13Bus\IEEE13Nodeckt.dss'"
# Disable voltage regulators
DSSText.Command = "Disable regcontrol.Reg1"
DSSText.Command = "Disable regcontrol.Reg2"
DSSText.Command = "Disable regcontrol.Reg3"
# Solve initial circuit
DSSSolution.solve()
print(DSSCircuit.AllBusVmagPu)
loadNames = np.array(DSSCircuit.Loads.AllNames)
loadKwdf = pd.DataFrame(loadNames)
loadKws = load_states(loadNames, DSSCircuit, DSSSolution)
for loadnum in range(np.size(loadNames)):
DSSCircuit.SetActiveElement("Load." + loadNames[loadnum])
# Set load with new loadKws
DSSCircuit.ActiveDSSElement.Properties("kW").Val = loadKws[loadnum]
# Solve new circuit
DSSSolution.solve()
print(DSSCircuit.AllBusVmagPu)