Skip to content

Commit 49d97fc

Browse files
committed
revert the self.counts change (deleting transformers because unused, alphabetized on init
1 parent 748b9e6 commit 49d97fc

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

pygridsim/core.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ def __init__(self):
1717
Stores numbers of circuit components to ensure unique naming of repeat circuit components.
1818
1919
Attributes:
20-
counts (dict[str, int]): Map of each type to the number seen of that type so far
20+
num_generators (int): Number of generators created so far.
21+
num_lines (int): Number of lines created so far.
22+
num_loads (int): Number of load nodes created so far.
23+
num_pv (int): Number of PVSystems create so far.
2124
"""
22-
self.counts = {}
23-
for count_type in ["loads", "lines", "transformers", "pv", "generators"]:
24-
self.counts[count_type] = 0
25+
self.num_generators = 0
26+
self.num_lines = 0
27+
self.num_loads = 0
28+
self.num_pv = 0
2529

2630
altdss.ClearAll()
2731
altdss('new circuit.MyCircuit')
@@ -52,8 +56,8 @@ def add_load_nodes(self,
5256
params = params or dict()
5357
load_nodes = []
5458
for _ in range(num):
55-
_make_load_node(params, load_type, self.counts["loads"])
56-
self.counts["loads"] += 1
59+
_make_load_node(params, load_type, self.num_loads)
60+
self.num_loads += 1
5761

5862
return load_nodes
5963

@@ -105,8 +109,8 @@ def add_PVSystem(self,
105109

106110
PV_nodes = []
107111
for load in load_nodes:
108-
PV_nodes.append(_make_pv(load, params, num_panels, self.counts["pv"]))
109-
self.counts["pv"] += 1
112+
PV_nodes.append(_make_pv(load, params, num_panels, self.num_pv))
113+
self.num_pv += 1
110114

111115
return PV_nodes
112116

@@ -128,8 +132,8 @@ def add_generator(self, num: int = 1, gen_type: str = "small", params: dict[str,
128132
params = params or dict()
129133
generators = []
130134
for _ in range(num):
131-
generators.append(_make_generator(params, gen_type, count=self.counts["generators"]))
132-
self.counts["generators"] += 1
135+
generators.append(_make_generator(params, gen_type, count=self.num_generators))
136+
self.num_generators += 1
133137

134138
return generators
135139

@@ -158,8 +162,8 @@ def add_lines(self,
158162
"""
159163
params = params or dict()
160164
for src, dst in connections:
161-
_make_line(src, dst, line_type, self.counts["lines"], params, transformer)
162-
self.counts["lines"] += 1
165+
_make_line(src, dst, line_type, self.num_lines, params, transformer)
166+
self.num_lines += 1
163167

164168
def solve(self):
165169
"""Solves the OpenDSS circuit.
@@ -203,8 +207,6 @@ def clear(self):
203207
None
204208
"""
205209
altdss.ClearAll()
206-
for key in self.counts:
207-
self.counts[key] = 0
208210

209211
def get_types(self, component: str, show_ranges: bool = False):
210212
"""Provides list of all supported Load Types

sim.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"Voltages": {
3+
"source": 9999.598243195385,
4+
"load0": 8294.334838925915
5+
},
6+
"Losses": {
7+
"Active Power Loss": 9059444.425434513,
8+
"Reactive Power Loss": 31084427.834760502
9+
}
10+
}

0 commit comments

Comments
 (0)