Skip to content

Commit

Permalink
improvement on temperature windspeedfactor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shirubana committed Jan 18, 2024
1 parent 59e501b commit 828b945
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 23 deletions.
4 changes: 3 additions & 1 deletion pvdeg/fatigue.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def solder_fatigue(
b=0.33,
C1=405.6,
Q=0.12,
wind_speed_factor=None,
):
"""
Get the Thermomechanical Fatigue of flat plate photovoltaic module solder joints.
Expand Down Expand Up @@ -169,7 +170,8 @@ def solder_fatigue(
time_range = weather_df.index

if temp_cell is None:
temp_cell = temperature.cell(weather_df, meta)
temp_cell = temperature.cell(weather_df=weather_df, meta=meta,
wind_speed_factor=wind_speed_factor)

temp_amplitude, temp_max_avg = _avg_daily_temp_change(time_range, temp_cell)

Expand Down
57 changes: 36 additions & 21 deletions pvdeg/temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ def module(
Contains keys/columns 'poa_global', 'poa_direct', 'poa_diffuse',
'poa_sky_diffuse', 'poa_ground_diffuse'.
temp_model : str, optional
The temperature model to use, Sandia Array Performance Model 'sapm' from pvlib by default.
The temperature model to use, Sandia Array Performance Model 'sapm'
from pvlib by default.
conf : str, optional
The configuration of the PV module architecture and mounting configuration.
The configuration of the PV module architecture and mounting
configuration.
Options:
'sapm': 'open_rack_glass_polymer' (default), 'open_rack_glass_glass',
'close_mount_glass_glass', 'insulated_back_glass_polymer'
'sapm': 'open_rack_glass_polymer' (default),
'open_rack_glass_glass', 'close_mount_glass_glass',
'insulated_back_glass_polymer'
Returns
-------
Expand All @@ -53,14 +56,8 @@ def module(
return module_temperature


def cell(
weather_df,
meta,
poa=None,
temp_model="sapm",
conf="open_rack_glass_polymer",
wind_speed_factor=1.7,
):
def cell(weather_df, meta, poa=None, temp_model="sapm",
conf="open_rack_glass_polymer", wind_speed_factor=None):
"""
Calculate the PV cell temperature using PVLIB
Currently this only supports the SAPM temperature model.
Expand All @@ -74,27 +71,45 @@ def cell(
poa : (dataframe or series, optional)
Dataframe or series with minimum requirement of 'poa_global'
temp_model : (str, optional)
DO NOT CHANGE UNTIL UPDATED
Specify which temperature model from pvlib to use. Current options:
'sapm'
conf : (str)
The configuration of the PV module architecture and mounting configuration.
The configuration of the PV module architecture and mounting
configuration.
Options: 'open_rack_glass_polymer' (default), 'open_rack_glass_glass',
'close_mount_glass_glass', 'insulated_back_glass_polymer'
wind_speed_factor : (str)
Wind speed factor is a #KEMPE EXPLAIN HERE. Common values are 1.7 for
sapm. If None is passed, the function checks which algorithm for
temperature calculation is used and assigns it automatically.
Return:
-------
temp_cell : pandas.DataFrame
This is the temperature of the cell in a module at every time step. [°C]
This is the temperature of the cell in a module at every time step.[°C]
"""

# TODO: if weather object passed is NSRDB data, use wind_seped_factor 1.7
# (and update description)
if wind_speed_factor is None:
if temp_model == "sapm":
wind_speed_factor = 1.7
else:
wind_speed_factor = 1.0

parameters = pvlib.temperature.TEMPERATURE_MODEL_PARAMETERS[temp_model][conf]

if poa is None:
poa = pvdeg.spectral.poa_irradiance(weather_df, meta)

temp_cell = pvlib.temperature.sapm_cell(
poa_global=poa["poa_global"],
temp_air=weather_df["temp_air"],
wind_speed=weather_df["wind_speed"]* wind_speed_factor,
**parameters
)
if temp_model == 'sapm':
temp_cell = pvlib.temperature.sapm_cell(
poa_global=poa["poa_global"],
temp_air=weather_df["temp_air"],
wind_speed=weather_df["wind_speed"]*wind_speed_factor,
**parameters)
else:
# TODO: add options for temperature model
print("There are other models but they haven't been implemented yet!")

return temp_cell
3 changes: 2 additions & 1 deletion tests/test_fatigue.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ def test_solder_fatigue():
# test solder fatique with default parameters
# requires PSM3 weather file

damage = fatigue.solder_fatigue(weather_df=WEATHER, meta=META)
damage = fatigue.solder_fatigue(weather_df=WEATHER, meta=META,
wind_speed_factor=1.0)
assert damage == pytest.approx(15.646, abs=0.005)

0 comments on commit 828b945

Please sign in to comment.