@@ -208,7 +208,7 @@ def get_orientation(strategy, **kwargs):
208
208
209
209
class ModelChain (object ):
210
210
"""
211
- An experimental class that represents all of the modeling steps
211
+ An experimental base class that represents all of the modeling steps
212
212
necessary for calculating power or energy for a PV system at a given
213
213
location.
214
214
@@ -278,7 +278,7 @@ def orientation_strategy(self, strategy):
278
278
279
279
self ._orientation_strategy = strategy
280
280
281
- def run_model (self , times , irradiance = None , weather = None ):
281
+ def prepare_inputs (self , times , irradiance = None , weather = None ):
282
282
"""
283
283
Run the model.
284
284
@@ -301,15 +301,19 @@ def run_model(self, times, irradiance=None, weather=None):
301
301
self
302
302
303
303
Assigns attributes: times, solar_position, airmass, irradiance,
304
- total_irrad, weather, temps, aoi, dc, ac
304
+ total_irrad, weather, aoi
305
305
"""
306
+
306
307
self .times = times
307
308
308
309
self .solar_position = self .location .get_solarposition (self .times )
309
310
310
311
self .airmass = self .location .get_airmass (
311
312
solar_position = self .solar_position , model = self .airmass_model )
312
313
314
+ self .aoi = self .system .get_aoi (self .solar_position ['apparent_zenith' ],
315
+ self .solar_position ['azimuth' ])
316
+
313
317
if irradiance is None :
314
318
irradiance = self .location .get_clearsky (
315
319
self .solar_position .index , self .clearsky_model ,
@@ -329,13 +333,39 @@ def run_model(self, times, irradiance=None, weather=None):
329
333
weather = {'wind_speed' : 0 , 'temp_air' : 20 }
330
334
self .weather = weather
331
335
336
+ return self
337
+
338
+ def run_model (self ):
339
+ """
340
+ A stub function meant to be subclassed.
341
+ """
342
+ raise NotImplementedError (
343
+ 'you must subclass ModelChain and implement this method' )
344
+
345
+
346
+ class SAPM (ModelChain ):
347
+ """
348
+ Uses the SAPM to calculate cell temperature, DC power and AC power.
349
+ """
350
+ def run_model (self ):
351
+ """
352
+ Run the model.
353
+
354
+ Parameters
355
+ ----------
356
+
357
+ Returns
358
+ -------
359
+ self
360
+
361
+ Assigns attributes: temps, dc, ac
362
+ """
363
+
364
+
332
365
self .temps = self .system .sapm_celltemp (self .total_irrad ['poa_global' ],
333
366
self .weather ['wind_speed' ],
334
367
self .weather ['temp_air' ])
335
368
336
- self .aoi = self .system .get_aoi (self .solar_position ['apparent_zenith' ],
337
- self .solar_position ['azimuth' ])
338
-
339
369
self .dc = self .system .sapm (self .total_irrad ['poa_direct' ],
340
370
self .total_irrad ['poa_diffuse' ],
341
371
self .temps ['temp_cell' ],
@@ -345,3 +375,45 @@ def run_model(self, times, irradiance=None, weather=None):
345
375
self .ac = self .system .snlinverter (self .dc ['v_mp' ], self .dc ['p_mp' ])
346
376
347
377
return self
378
+
379
+
380
+ class SingleDiode (ModelChain ):
381
+ """
382
+ Uses the DeSoto and single diode models to calculate the DC power,
383
+ and the SAPM models to calculate cell temperature and AC power.
384
+ """
385
+
386
+ def run_model (self ):
387
+ """
388
+ Run the model.
389
+
390
+ Parameters
391
+ ----------
392
+
393
+ Returns
394
+ -------
395
+ self
396
+
397
+ Assigns attributes: temps, dc, ac
398
+ """
399
+
400
+
401
+ self .temps = self .system .sapm_celltemp (self .total_irrad ['poa_global' ],
402
+ self .weather ['wind_speed' ],
403
+ self .weather ['temp_air' ])
404
+
405
+ (photocurrent , saturation_current , resistance_series ,
406
+ resistance_shunt , nNsVth ) = (
407
+ self .system .calcparams_desoto (self .total_irrad ['poa_global' ],
408
+ self .temps ['temp_cell' ]))
409
+
410
+ self .desoto = (photocurrent , saturation_current , resistance_series ,
411
+ resistance_shunt , nNsVth )
412
+
413
+ self .dc = self .system .singlediode (
414
+ photocurrent , saturation_current , resistance_series ,
415
+ resistance_shunt , nNsVth )
416
+
417
+ self .ac = self .system .snlinverter (self .dc ['v_mp' ], self .dc ['p_mp' ])
418
+
419
+ return self
0 commit comments