-
Notifications
You must be signed in to change notification settings - Fork 1.1k
initial implementation of pvsyst_celltemp function (#552) #628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
800a42f
e5bd8ad
e52c9cb
63f79b1
3b43a09
116a7ba
e9a9463
6d902e7
a360026
f8c9c52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1887,6 +1887,82 @@ def sapm_celltemp(poa_global, wind_speed, temp_air, | |
return pd.DataFrame({'temp_cell': temp_cell, 'temp_module': temp_module}) | ||
|
||
|
||
def pvsyst_celltemp( | ||
poa_global, | ||
wind_speed, | ||
temp_air, | ||
eta_m=0.1, | ||
alpha_absorption=0.9, | ||
temp_model="freestanding", | ||
): | ||
CameronTStark marked this conversation as resolved.
Show resolved
Hide resolved
CameronTStark marked this conversation as resolved.
Show resolved
Hide resolved
CameronTStark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
Calculate PVSyst cell temperature. | ||
CameronTStark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Parameters | ||
------------ | ||
CameronTStark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
poa_global : float or Series | ||
CameronTStark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Total incident irradiance in W/m^2. | ||
|
||
wind_speed : float or Series | ||
Wind speed in m/s at a height of 10 meters. | ||
|
||
temp_air : float or Series | ||
Ambient dry bulb temperature in degrees C. | ||
|
||
eta_m : numeric | ||
PV module efficiency as a fraction | ||
CameronTStark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
alpha_absorption : float | ||
Absorption coefficient, default is 0.9 | ||
|
||
temp_model : string, list, or dict, default 'freestanding' | ||
CameronTStark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Model to be used. | ||
|
||
If string, can be: | ||
|
||
* 'freestanding' (default) | ||
* 'insulated' | ||
wholmgren marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
If tuple/list, supply parameters in the following order: | ||
|
||
* natural_convenction_coeff : float | ||
Natural convection coefficient. Freestanding default is 29, | ||
fully insulated arrays is 15. Recommended values are between | ||
23.5 and 26.5. | ||
|
||
* forced_convection_coeff : float | ||
Forced convection coefficient, default is 0. Recommended values | ||
are between 6.25 and 7.68. | ||
CameronTStark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Returns | ||
wholmgren marked this conversation as resolved.
Show resolved
Hide resolved
|
||
-------- | ||
temp_cell : numeric or Series | ||
Cell temperature in degrees Celsius | ||
""" | ||
CameronTStark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
temp_models = {"freestanding": (29.0, 0), "insulated": (15.0, 0)} | ||
|
||
if isinstance(temp_model, str): | ||
natural_convenction_coeff, forced_convection_coeff = temp_models[ | ||
temp_model.lower() | ||
] | ||
elif isinstance(temp_model, (tuple, list)): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @CameronTStark in the future maybe consider duck typing instead of type checking. Even though duck typing is the Pythonic preference, it may not always work best. I think your solution here is fine, but in general I think duck typing usually results in more robust code. Eg: else:
natural_convenction_coeff, forced_convection_coeff = temp_model
# already raises ValueError or TypeError
# or use try: except to raise a more descriptive exception There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mikofski Yes, thanks for the suggestion! I've been trying to pay attention more to duck typing in my code and thought about it for this instance but since this was my first contribution and sapm_celltemp() had the Look Before You Leap type check in it already I figured I'd just follow convention. |
||
natural_convenction_coeff, forced_convection_coeff = temp_model | ||
else: | ||
raise TypeError( | ||
"Please format temp_model as a str, or tuple/list." | ||
) | ||
|
||
combined_convection_coeff = ( | ||
forced_convection_coeff * wind_speed | ||
) + natural_convenction_coeff | ||
|
||
absorption_coeff = alpha_absorption * poa_global * (1 - eta_m) | ||
temp_difference = absorption_coeff / combined_convection_coeff | ||
temp_cell = temp_air + temp_difference | ||
|
||
return temp_cell | ||
|
||
|
||
def sapm_spectral_loss(airmass_absolute, module): | ||
""" | ||
Calculates the SAPM spectral loss coefficient, F1. | ||
|
Uh oh!
There was an error while loading. Please reload this page.