Skip to content

Commit c5654d3

Browse files
committed
pv system
1 parent 61e9232 commit c5654d3

File tree

9 files changed

+61
-11
lines changed

9 files changed

+61
-11
lines changed
1014 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
934 Bytes
Binary file not shown.

pygridsim/core.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from altdss import altdss
33
from altdss import AltDSS, Transformer, Vsource, Load, LoadModel, LoadShape
44
from dss.enums import LineUnits, SolveModes
5-
from pygridsim.parameters import make_load_node, make_source_node
5+
from pygridsim.parameters import make_load_node, make_source_node, make_pv
66
from pygridsim.results import query_solution, export_results
77
from pygridsim.lines import make_line
88
from pygridsim.transformers import make_transformer
@@ -18,6 +18,7 @@ def __init__(self):
1818
self.num_loads = 0
1919
self.num_lines = 0
2020
self.num_transformers = 0
21+
self.num_pv = 0
2122
altdss.ClearAll()
2223
altdss('new circuit.MyCircuit')
2324

@@ -53,10 +54,34 @@ def update_source(self, params = {}, source_type: SourceType = SourceType.TURBIN
5354
"""
5455
return make_source_node(params, source_type)
5556

56-
def add_power_source(self, source_type: SourceType):
57+
def add_PVSystem(self, load_nodes = [], params = {}, num_panels = 1):
5758
"""
58-
Source type is one of Generator, PvSystem
59+
Specify a list of load nodes to add a PVsystem ("solar panel") to.
60+
61+
Args:
62+
load_nodes: which load nodes to add PVsystem to
63+
params: specify anything else about the PVsystem. otherwise defaults to typical solar panel
64+
num_panels: representing how many solar panels (to represent scale)
65+
Return:
66+
list of PVSystem objects
67+
"""
68+
PV_nodes = []
69+
for load in load_nodes:
70+
PV_nodes.append(make_pv(load, params, num_panels, self.num_pv))
71+
self.num_pv += 1
72+
return PV_nodes
73+
74+
def add_generator(self, params = {}):
5975
"""
76+
Specify parameters for a generator to add to the circuit
77+
78+
Args:
79+
params: specify anything else about the PVsystem. otherwise defaults to typical solar panel
80+
num: representing how many solar panels (to represent scale)
81+
Return:
82+
list of PVSystem objects
83+
"""
84+
6085

6186
def add_lines(self, connections, line_type: LineType = LineType.LV_LINE, params = {}, transformer = True):
6287
"""

pygridsim/defaults.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@
4646
INDUSTRIAL_KVAR = [20, 25]
4747

4848
"""
49-
Source Nodes
50-
TODO also fuel cells, other less common forms of energy later
49+
Source Nodes (including other form of sources, like PVSystem)
5150
"""
5251

5352
TURBINE_BASE_KV = [3000,4000]
5453
SOLAR_PANEL_BASE_KV = [0.2, 0.4] # per solar panel
5554
IMPEDANCE = 0.0001
5655

56+
5757
"""
5858
Units: KM
5959
LV = Low Voltage, MV = Medium Voltage

pygridsim/parameters.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Helper functions to parse the parameters used for loads and sources
33
"""
44
from altdss import altdss
5-
from altdss import AltDSS, Transformer, Vsource, Load, LoadModel, LoadShape
5+
from altdss import AltDSS, Transformer, Vsource, Load, LoadModel, LoadShape, PVSystem
66
import pygridsim.defaults as defaults
77
import random
88

@@ -88,4 +88,20 @@ def make_source_node(source_params, source_type):
8888
if (source.BasekV) < 0:
8989
raise ValueError("Cannot have negative voltage in source")
9090

91-
return source
91+
return source
92+
93+
def make_pv(load_node, params, num_panels, count):
94+
"""
95+
Make a PV at the load node given, scaling kV by the number of solar panels
96+
97+
Args:
98+
load_node: which load to add PVsystem to
99+
params: any customized parameters
100+
num_panels: representation of how many solar panels this PVsystem includes
101+
count: how many pv already made, to not run into duplicates
102+
"""
103+
pv : PVSystem = altdss.PVSystem.new('pv' + str(count))
104+
pv.Bus1 = load_node
105+
pv.Phases = get_param(params, "phases", defaults.PHASES)
106+
pv.kV = get_param(params, "kV", random_param(defaults.SOLAR_PANEL_BASE_KV) * num_panels)
107+
# todo: inverter capacity?

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": 3661799.375697402,
4-
"load0": 274.3263413306505
3+
"source": 3939392.445246486,
4+
"load0": 801.6009509982497
55
},
66
"Losses": {
7-
"Active Power Loss": 769141628339.1614,
8-
"Reactive Power Loss": 1598841291844.7805
7+
"Active Power Loss": 1549277840399.3896,
8+
"Reactive Power Loss": 3221430546551.8247
99
}
1010
}
626 Bytes
Binary file not shown.

tests/test_circuit.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ def test_007_export(self):
107107
circuit.add_lines([("source", "load0")])
108108
circuit.solve()
109109
print(circuit.results(["Voltages", "Losses"], export_path="sim.json"))
110+
111+
def test_008_PVsystem(self):
112+
circuit = PyGridSim()
113+
circuit.update_source()
114+
circuit.add_load_nodes(num=2)
115+
circuit.add_PVSystem(load_nodes=["load0", "load1"], num_panels=5)
116+
circuit.add_lines([("source", "load0")])
117+
circuit.solve()
118+
print(circuit.results(["Voltages", "Losses"]))
110119

111120

112121
class TestCustomizedCircuit(unittest.TestCase):

0 commit comments

Comments
 (0)