@@ -113,6 +113,31 @@ def pvwatts_dc_pvwatts_ac_system(sapm_temperature_cs5p_220m):
113113 return system
114114
115115
116+ @pytest .fixture (scope = "function" )
117+ def pvwatts_dc_pvwatts_ac_faiman_temp_system ():
118+ module_parameters = {'pdc0' : 220 , 'gamma_pdc' : - 0.003 }
119+ temp_model_params = {'u0' : 25.0 , 'u1' : 6.84 }
120+ inverter_parameters = {'pdc0' : 220 , 'eta_inv_nom' : 0.95 }
121+ system = PVSystem (surface_tilt = 32.2 , surface_azimuth = 180 ,
122+ module_parameters = module_parameters ,
123+ temperature_model_parameters = temp_model_params ,
124+ inverter_parameters = inverter_parameters )
125+ return system
126+
127+
128+ @pytest .fixture (scope = "function" )
129+ def pvwatts_dc_pvwatts_ac_pvsyst_temp_system ():
130+ module_parameters = {'pdc0' : 220 , 'gamma_pdc' : - 0.003 }
131+ temp_model_params = {'u_c' : 29.0 , 'u_v' : 0.0 , 'eta_m' : 0.1 ,
132+ 'alpha_absorption' : 0.9 }
133+ inverter_parameters = {'pdc0' : 220 , 'eta_inv_nom' : 0.95 }
134+ system = PVSystem (surface_tilt = 32.2 , surface_azimuth = 180 ,
135+ module_parameters = module_parameters ,
136+ temperature_model_parameters = temp_model_params ,
137+ inverter_parameters = inverter_parameters )
138+ return system
139+
140+
116141@pytest .fixture (scope = "function" )
117142def system_no_aoi (cec_module_cs5p_220m , sapm_temperature_cs5p_220m ,
118143 cec_inverter_parameters ):
@@ -230,10 +255,10 @@ def test_run_model_gueymard_perez(system, location):
230255 assert_series_equal (ac , expected )
231256
232257
233- def test_run_model_with_weather (system , location , weather , mocker ):
258+ def test_run_model_with_weather_sapm_temp (system , location , weather , mocker ):
259+ # test with sapm cell temperature model
234260 weather ['wind_speed' ] = 5
235261 weather ['temp_air' ] = 10
236- # test with sapm cell temperature model
237262 system .racking_model = 'open_rack'
238263 system .module_type = 'glass_glass'
239264 mc = ModelChain (system , location )
@@ -246,7 +271,12 @@ def test_run_model_with_weather(system, location, weather, mocker):
246271 assert_series_equal (m_sapm .call_args [0 ][1 ], weather ['temp_air' ]) # temp
247272 assert_series_equal (m_sapm .call_args [0 ][2 ], weather ['wind_speed' ]) # wind
248273 assert not mc .ac .empty
274+
275+
276+ def test_run_model_with_weather_pvsyst_temp (system , location , weather , mocker ):
249277 # test with pvsyst cell temperature model
278+ weather ['wind_speed' ] = 5
279+ weather ['temp_air' ] = 10
250280 system .racking_model = 'freestanding'
251281 system .temperature_model_parameters = \
252282 temperature ._temperature_model_params ('pvsyst' , 'freestanding' )
@@ -260,6 +290,21 @@ def test_run_model_with_weather(system, location, weather, mocker):
260290 assert not mc .ac .empty
261291
262292
293+ def test_run_model_with_weather_faiman_temp (system , location , weather , mocker ):
294+ # test with faiman cell temperature model
295+ weather ['wind_speed' ] = 5
296+ weather ['temp_air' ] = 10
297+ system .temperature_model_parameters = {'u0' : 25.0 , 'u1' : 6.84 }
298+ mc = ModelChain (system , location )
299+ mc .temperature_model = 'faiman'
300+ m_faiman = mocker .spy (system , 'faiman_celltemp' )
301+ mc .run_model (weather )
302+ assert m_faiman .call_count == 1
303+ assert_series_equal (m_faiman .call_args [0 ][1 ], weather ['temp_air' ])
304+ assert_series_equal (m_faiman .call_args [0 ][2 ], weather ['wind_speed' ])
305+ assert not mc .ac .empty
306+
307+
263308def test_run_model_tracker (system , location , weather , mocker ):
264309 system = SingleAxisTracker (
265310 module_parameters = system .module_parameters ,
@@ -341,15 +386,20 @@ def test_infer_spectral_model(location, system, cec_dc_snl_ac_system,
341386
342387
343388@pytest .mark .parametrize ('temp_model' , [
344- 'sapm' , pytest .param ('pvsyst' , marks = requires_scipy )])
345- def test_infer_temp_model (location , system , pvsyst_dc_snl_ac_system ,
389+ 'sapm_temp' , 'faiman_temp' ,
390+ pytest .param ('pvsyst_temp' , marks = requires_scipy )])
391+ def test_infer_temp_model (location , system ,
392+ pvwatts_dc_pvwatts_ac_pvsyst_temp_system ,
393+ pvwatts_dc_pvwatts_ac_faiman_temp_system ,
346394 temp_model ):
347- dc_systems = {'sapm' : system ,
348- 'pvsyst' : pvsyst_dc_snl_ac_system }
395+ dc_systems = {'sapm_temp' : system ,
396+ 'pvsyst_temp' : pvwatts_dc_pvwatts_ac_pvsyst_temp_system ,
397+ 'faiman_temp' : pvwatts_dc_pvwatts_ac_faiman_temp_system }
349398 system = dc_systems [temp_model ]
350399 mc = ModelChain (system , location ,
351400 orientation_strategy = 'None' , aoi_model = 'physical' ,
352401 spectral_model = 'no_loss' )
402+ assert temp_model == mc .temperature_model .__name__
353403 assert isinstance (mc , ModelChain )
354404
355405
0 commit comments