Skip to content

Commit 8de850d

Browse files
committed
multiple sources tests, strip spaces on string input
1 parent 3511973 commit 8de850d

File tree

12 files changed

+39
-15
lines changed

12 files changed

+39
-15
lines changed
341 Bytes
Binary file not shown.
1.4 KB
Binary file not shown.
2 Bytes
Binary file not shown.
301 Bytes
Binary file not shown.
59 Bytes
Binary file not shown.

pygridsim/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self):
2222
altdss.ClearAll()
2323
altdss('new circuit.MyCircuit')
2424

25-
def add_load_nodes(self, params = {}, load_type: str = "house", num = 1):
25+
def add_load_nodes(self, load_type: str = "house", params = {}, num = 1):
2626
"""
2727
When the user wants to manually add nodes, or make nodes with varying parameters.
2828
@@ -40,7 +40,7 @@ def add_load_nodes(self, params = {}, load_type: str = "house", num = 1):
4040
self.num_loads += 1
4141
return load_nodes
4242

43-
def update_source(self, params = {}, source_type: str = "turbine"):
43+
def update_source(self, source_type: str = "turbine", params = {}):
4444
"""
4545
Adds a main voltage source if it doesn't exist, otherwise edits it
4646
@@ -74,7 +74,7 @@ def add_PVSystem(self, load_nodes, params = {}, num_panels = 1):
7474
self.num_pv += 1
7575
return PV_nodes
7676

77-
def add_generator(self, num, params = {}, gen_type: GeneratorType = GeneratorType.SMALL):
77+
def add_generator(self, num, gen_type: GeneratorType = GeneratorType.SMALL, params = {}):
7878
"""
7979
Specify parameters for a generator to add to the circuit
8080

pygridsim/lines.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@
66
from pygridsim.parameters import get_param, random_param, check_valid_params, get_enum_obj
77
from dss.enums import LineUnits
88

9+
def get_kv(node_name):
10+
"""
11+
Given a string of a node that exists, fetch its kV or raise error if doesn't exist
12+
"""
13+
if node_name == "source":
14+
return altdss.Vsource[node_name].BasekV
15+
elif "load" in node_name:
16+
return altdss.Load[node_name].kV
17+
elif "generator" in node_name:
18+
return altdss.Generator[node_name].kV
19+
else:
20+
raise KeyError("Invalid src or dst name")
21+
922
def make_line(src, dst, line_type, count, params = {}, transformer = True):
1023
"""
1124
Add a line between src and dst
@@ -39,9 +52,7 @@ def make_line(src, dst, line_type, count, params = {}, transformer = True):
3952
transformer.XHL = get_param(params, "XHL", defaults.XHL)
4053
transformer.Buses = [src, dst]
4154
transformer.Conns = get_param(params, "Conns", [defaults.PRIMARY_CONN, defaults.SECONDARY_CONN])
42-
# TOOD: edit this for clarity
43-
if src == "source":
44-
transformer.kVs = [altdss.Vsource[src].BasekV, altdss.Load[dst].kV]
45-
else:
46-
transformer.kVs = [altdss.Generator[src].kV, altdss.Load[dst].kV]
55+
56+
transformer.kVs = [get_kv(src), get_kv(dst)]
57+
4758
transformer.end_edit()

pygridsim/parameters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
def get_enum_obj(enum_class, enum_val):
1212
enum_obj = None
1313
for enum_type in enum_class:
14-
if (enum_type.value == enum_val.lower()):
14+
if (enum_type.value == enum_val.lower().replace(" ", "")):
1515
enum_obj = enum_type
1616
if not enum_obj:
1717
raise KeyError("invalid enum input")

sim.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"Voltages": {
3-
"source": 1689.9694678157916,
4-
"load0": 213.88830907538258
3+
"source": 2922.164017017074,
4+
"load0": 130.76382218128552
55
},
66
"Losses": {
7-
"Active Power Loss": 138083.11472325015,
8-
"Reactive Power Loss": 287047.4734936169
7+
"Active Power Loss": 742550.0603061075,
8+
"Reactive Power Loss": 1543879.3995447825
99
}
1010
}
8.54 KB
Binary file not shown.

0 commit comments

Comments
 (0)