@@ -89,17 +89,17 @@ def test_006_update_multiple_source(self):
8989
9090 def test_007_export (self ):
9191 circuit = PyGridSim ()
92- circuit .update_source ()
93- circuit .add_load_nodes ()
94- circuit .add_lines ([("source" , "load0" )])
92+ circuit .update_source (params = { "kV" : 10 } )
93+ circuit .add_load_nodes (params = { "kV" : 5 , "kW" : 10 , "kvar" : 2 } )
94+ circuit .add_lines ([("source" , "load0" )], params = { "length" : 2 } )
9595 circuit .solve ()
9696 print (circuit .results (["Voltages" , "Losses" ], export_path = "sim.json" ))
9797
9898 def test_008_PVsystem (self ):
9999 circuit = PyGridSim ()
100100 circuit .update_source ()
101101 circuit .add_load_nodes (num = 2 )
102- circuit .add_PVSystem (load_nodes = ["load0" , "load1" ], num_panels = 5 )
102+ circuit .add_PVSystems (load_nodes = ["load0" , "load1" ], num_panels = 5 )
103103 circuit .add_lines ([("source" , "load0" )])
104104 circuit .solve ()
105105 print (circuit .results (["Voltages" , "Losses" ]))
@@ -108,7 +108,7 @@ def test_009_generator(self):
108108 circuit = PyGridSim ()
109109 circuit .update_source ()
110110 circuit .add_load_nodes ()
111- circuit .add_generator (num = 3 , gen_type = "small" )
111+ circuit .add_generators (num = 3 , gen_type = "small" )
112112 circuit .add_lines ([("source" , "load0" ), ("generator0" , "load0" )])
113113 circuit .solve ()
114114 print (circuit .results (["Voltages" , "Losses" ]))
@@ -117,10 +117,10 @@ def test_010_many_sources(self):
117117 circuit = PyGridSim ()
118118 circuit .update_source (source_type = "powerplant" )
119119 circuit .add_load_nodes (num = 3 )
120- circuit .add_PVSystem (load_nodes = ["load1" , "load2" ], num_panels = 10 )
121- circuit .add_generator (num = 3 , gen_type = "small" )
122- circuit .update_source (source_type = "turbine" )
123- circuit .add_generator (num = 4 , gen_type = "large" )
120+ circuit .add_PVSystems (load_nodes = ["load1" , "load2" ], num_panels = 10 )
121+ circuit .add_generators (num = 3 , gen_type = "small" )
122+ circuit .update_source (source_type = "turbine" ) # change to a turbine source midway
123+ circuit .add_generators (num = 4 , gen_type = "large" )
124124 circuit .add_lines ([("source" , "load0" ), ("generator0" , "load0" ), ("generator5" , "source" )])
125125 circuit .solve ()
126126 print (circuit .results (["Voltages" , "Losses" ]))
@@ -148,10 +148,10 @@ def test_011_configs(self):
148148
149149 # GENERATOR CONFIG
150150 # works, because not case sensitive
151- circuit .add_generator (num = 3 , gen_type = "SMALl" )
151+ circuit .add_generators (num = 3 , gen_type = "SMALl" )
152152 # don't want linetype input, just string
153153 with self .assertRaises (Exception ):
154- circuit .add_generator (num = 3 , gen_type = GeneratorType .SMALL )
154+ circuit .add_generators (num = 3 , gen_type = GeneratorType .SMALL )
155155
156156 # SOURCE CONFIG
157157 # works, because not case sensitive
@@ -162,6 +162,19 @@ def test_011_configs(self):
162162 with self .assertRaises (Exception ):
163163 circuit .update_source (source_type = SourceType .TURBINE )
164164
165+ def test_012_all_results (self ):
166+ circuit = PyGridSim ()
167+ circuit .update_source ()
168+ circuit .add_load_nodes ()
169+ circuit .add_generators (num = 2 , gen_type = "small" )
170+ circuit .add_lines ([("source" , "load0" ), ("generator0" , "load0" )])
171+ circuit .solve ()
172+ # Should be flexible with capitalization, spaces
173+ queries = ["Voltages" , "losses" , "Total Power" ]
174+ # Add "partial" queries to just parts of losses/total power
175+ queries += ["realpowerloss" , "reactive Loss" , "Active Power" , "reactivepower" ]
176+ print (circuit .results (queries ))
177+
165178
166179class TestCustomizedCircuit (unittest .TestCase ):
167180 """
@@ -210,9 +223,9 @@ def test_101_bad_parameter(self):
210223 # add load nodes so we can test pv system erroring
211224 circuit .add_load_nodes (num = 2 , params = {"kV" : 10 , "kW" : 20 , "kvar" : 1 })
212225 with self .assertRaises (KeyError ):
213- circuit .add_generator (num = 4 , params = {"badParam" : 100 })
226+ circuit .add_generators (num = 4 , params = {"badParam" : 100 })
214227 with self .assertRaises (KeyError ):
215- circuit .add_PVSystem (load_nodes = ["load0" ], params = {"badParam" : 100 }, num_panels = 4 )
228+ circuit .add_PVSystems (load_nodes = ["load0" ], params = {"badParam" : 100 }, num_panels = 4 )
216229
217230 def test_102_negative_inputs (self ):
218231 """
@@ -244,6 +257,24 @@ def test_104_non_int_parameters(self):
244257 with self .assertRaises (TypeError ):
245258 circuit .add_load_nodes (params = {"kV" : "stringInput" })
246259
260+ def test_105_alt_source_parameters (self ):
261+ circuit = PyGridSim ()
262+ circuit .add_load_nodes (num = 5 )
263+ circuit .add_generators (params = {"kV" : 50 , "kW" : 100 })
264+ circuit .add_PVSystems (load_nodes = ["load0" , "load1" ], num_panels = 5 , params = {"kV" : 0.1 })
265+ circuit .solve ()
266+ print (circuit .results (["Voltages" , "Losses" ]))
267+ circuit .clear ()
268+
269+ def test_106_transformer_parameters (self ):
270+ circuit = PyGridSim ()
271+ circuit .add_load_nodes (num = 5 )
272+ circuit .update_source ()
273+ circuit .add_lines ([("source" , "load0" )], params = {"length" : 20 , "XHL" : 5 })
274+ circuit .solve ()
275+ print (circuit .results (["Voltages" , "Losses" ]))
276+ circuit .clear ()
277+
247278
248279class TestTypeQueryFunctions (unittest .TestCase ):
249280
0 commit comments