Skip to content

Commit 38f901b

Browse files
committed
transformer basic sketch
1 parent 07081c7 commit 38f901b

14 files changed

+125
-65
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ NOTE: will be moved to Dai lab repository
2323

2424
# Overview
2525

26-
TODO: Provide a short overview of the project here.
26+
PyGridSim aims to provide accessible access to tools like OpenDSS, AltDSS using Python. The goal is to create large-scale electrical circuits representing residential neighborhoods (and other scenarios) using an intuitive interface, without any background in OpenDSS software.
2727

2828
# Install
2929

@@ -88,7 +88,7 @@ for more details about this process.
8888
In this short tutorial we will guide you through a series of steps that will help you
8989
getting started with **PyGridSim**.
9090

91-
TODO: Create a step by step guide here.
91+
TODO: Create a step by step guide here. Also figure out how to ensure prerequisites properly.
9292

9393
# What's next?
9494

1.28 KB
Binary file not shown.
-74 Bytes
Binary file not shown.
209 Bytes
Binary file not shown.
-15 Bytes
Binary file not shown.
350 Bytes
Binary file not shown.
1.45 KB
Binary file not shown.

pygridsim/basic_test.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
from core import PyGridSim
2-
from enums import LineType, SourceType
2+
from enums import LineType, SourceType, LoadType
3+
from altdss import altdss
34

45
"""
56
Goal: to be able to very easily make a scalable circuit that represents a residential district
67
"""
78

89
circuit = PyGridSim()
9-
circuit.add_source_nodes(num=1)
10-
circuit.add_load_nodes(num=4)
11-
circuit.add_lines([("source0", "load0"), ("source0", "load2")], LineType.INDUSTRIAL_LV_LINE)
10+
circuit.add_source_nodes(num_in_batch=10, source_type=SourceType.SOLAR_PANEL)
11+
circuit.add_load_nodes(num=4, load_type=LoadType.HOUSE)
12+
circuit.add_lines([("source", "load0"), ("source", "load3")], LineType.MV_LINE)
13+
circuit.add_transformers([("source", "load0")])
1214
circuit.solve()
1315
print(circuit.results(["BusVMag"]))
1416

15-
# using solar panel leads to a lot lower kv obviously
17+
"""
18+
print(circuit.view_load_nodes())
19+
print(circuit.view_source_node())
20+
"""

pygridsim/core.py

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from parameters import make_load_node, make_source_node
66
from queries import query_solution
77
from lines import make_line
8-
from enums import LineType, SourceType
8+
from transformers import make_transformer
9+
from enums import LineType, SourceType, LoadType
910

1011
"""Main module."""
1112

@@ -14,14 +15,12 @@ def __init__(self):
1415
"""
1516
Initialize OpenDSS/AltDSS engine. Creates an Empty Circuit
1617
"""
17-
self.load_nodes = []
1818
self.num_loads = 0
19-
self.source_nodes = []
20-
self.num_sources = 0
2119
self.num_lines = 0
20+
self.num_transformers = 0
2221
altdss('new circuit.IEEE13Nodeckt')
2322

24-
def add_load_nodes(self, load_params = {}, num = 1):
23+
def add_load_nodes(self, load_params = {}, load_type: LoadType = LoadType.HOUSE, num = 1):
2524
"""
2625
When the user wants to manually add nodes, or make nodes with varying parameters.
2726
@@ -34,30 +33,26 @@ def add_load_nodes(self, load_params = {}, num = 1):
3433
"""
3534
load_nodes = []
3635
for i in range(num):
37-
load_nodes.append(make_load_node(load_params, self.num_loads))
36+
make_load_node(load_params, load_type, self.num_loads)
3837
self.num_loads += 1
39-
self.load_nodes += load_nodes
4038
return load_nodes
4139

42-
def add_source_nodes(self, source_params = {}, num = 1, source_type: SourceType = SourceType.TURBINE):
40+
def add_source_nodes(self, source_params = {}, source_type: SourceType = SourceType.TURBINE, num_in_batch = 1):
4341
"""
4442
When the user wants to manually add nodes, or make nodes with varying parameters.
4543
4644
Args:
4745
source_params: load parameters for these manual additions
4846
lines: which nodes these new sources are connected to
49-
num (optional): number of sources to create with these parameters
47+
num (optional): number of sources to create with these parameters (removed for now)
48+
num_in_batch: how many to batch together directly (so they can't be connected to lines separately, etc.
49+
most common use case is if a house has 20 solar panels it's more useful to group them together)
5050
Return:
5151
List of source_nodes
5252
"""
53-
source_nodes = []
54-
for i in range(num):
55-
source_nodes.append(make_source_node(source_params, self.num_sources, source_type))
56-
self.num_sources += 1
57-
self.source_nodes += source_nodes
58-
return source_nodes
59-
60-
def add_lines(self, connections, line_type: LineType = LineType.RESIDENTIAL_LV_LINE, params = {}):
53+
return make_source_node(source_params, source_type, num_in_batch=num_in_batch)
54+
55+
def add_lines(self, connections, line_type: LineType = LineType.LV_LINE, params = {}):
6156
"""
6257
Specify all lines that the user wants to add. If redundant lines, doesn't add anything
6358
@@ -69,6 +64,17 @@ def add_lines(self, connections, line_type: LineType = LineType.RESIDENTIAL_LV_L
6964
make_line(src, dst, line_type, self.num_lines, params)
7065
self.num_lines += 1
7166

67+
def add_transformers(self, connections, params = {}):
68+
"""
69+
Specify all transformers that the user wants to add, same input style as lines.
70+
71+
Args:
72+
connections: a list of new transformers to add (where to add them), with these params
73+
"""
74+
for src, dst in connections:
75+
make_transformer(src, dst, self.num_transformers, params)
76+
self.num_transformers += 1
77+
7278

7379
def view_load_nodes(self, indices = []):
7480
"""
@@ -78,17 +84,36 @@ def view_load_nodes(self, indices = []):
7884
indices (optional): Which indices to view the nodes at.
7985
If none given, display all
8086
"""
87+
load_nodes = []
88+
if not indices:
89+
indices = [i for i in range(self.num_loads)]
90+
91+
for idx in indices:
92+
load_obj = altdss.Load["load" + str(idx)]
93+
load_info = {}
94+
load_info["name"] = "load" + str(idx)
95+
load_info["kV"] = load_obj.kV
96+
load_info["kW"] = load_obj.kW
97+
load_info["kVar"] = load_obj.kvar
98+
load_nodes.append(load_info)
99+
return load_nodes
81100

82101

83-
def view_source_nodes(self, indices = []):
102+
def view_source_node(self):
84103
"""
85104
View source nodes (what their parameters are) at the given indices.
86105
87106
Args:
88107
indices (optional): Which indices to view the nodes at.
89108
If none given, display all
90-
"""
91-
109+
110+
TODO once capability for more source nodes is initialized
111+
"""
112+
source_obj = altdss.Vsource["source"]
113+
source_info = {}
114+
source_info["name"] = "source"
115+
source_info["kV"] = source_obj.BasekV
116+
return source_info
92117

93118
def solve(self):
94119
"""

pygridsim/defaults.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,33 @@
2929

3030
"""
3131
Load Nodes
32+
kW: around 30 kWH a day, divide by 24 hours
33+
kVar is like around 0.2 or 0.1 of what kVar is
3234
"""
33-
HOUSE_KV = [120, 240]
34-
HOUSE_KW = [1, 1.4]
35-
HOUSE_KVAR = 0.6 # unclear
35+
HOUSE_KV = [.12, .24]
36+
HOUSE_KW = [1, 1.5]
37+
HOUSE_KVAR = [0.5, 1] # unclear
38+
39+
COMMERCIAL_KV = [.24, .48]
40+
COMMERCIAL_KW = [10, 50]
41+
COMMERCIAL_KVAR = [5, 10]
42+
43+
INDUSTRIAL_KV = [.24, .48]
44+
INDUSTRIAL_KW = [30, 100]
45+
INDUSTRIAL_KVAR = [20, 25]
3646

3747
"""
3848
Source Nodes
3949
TODO also fuel cells, other less common forms of energy later
4050
"""
4151

42-
TURBINE_BASE_KV = [0.55,0.7]
43-
SOLAR_PANEL_BASE_KV = [0.0005, 0.0006] # per solar panel
52+
TURBINE_BASE_KV = [3000,4000]
53+
SOLAR_PANEL_BASE_KV = [0.2, 0.4] # per solar panel
4454

4555
"""
4656
Units: KM
4757
LV = Low Voltage, MV = Medium Voltage
48-
Based on IEEE standards
49-
"""
50-
RESIDENTIAL_LV_LINE_LENGTH = [0.05, 0.3]
51-
RESIDENTIAL_MV_LINE_LENGTH = [1, 10]
52-
RURAL_LV_LINE_LENGTH = [0.1 ,0.5]
53-
RURAL_MV_LINE_LENGTH = [10, 50]
54-
INDUSTRIAL_LV_LINE_LENGTH = [0.01, 0.2]
55-
INDUSTRIAL_MV_LINE_LENGTH = [1,5]
56-
URBAN_LV_LINE_LENGTH = [0.02, 0.2]
57-
URBAN_MV_LINE_LENGTH = [1,10]
58+
"""
59+
LV_LINE_LENGTH = [30, 60]
60+
MV_LINE_LENGTH = [60, 160]
61+
HV_LINE_LENGTH = [160,300]

0 commit comments

Comments
 (0)