From 6231368e02af620641dd5b7657000264d837435b Mon Sep 17 00:00:00 2001 From: PVPro-SPA <63314623+PVPro-SPA@users.noreply.github.com> Date: Tue, 11 Aug 2020 10:24:27 -0400 Subject: [PATCH 1/3] Create performance.py Preliminary testing version of PR function. --- pvlib/performance.py | 91 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 pvlib/performance.py diff --git a/pvlib/performance.py b/pvlib/performance.py new file mode 100644 index 0000000000..0a9e808396 --- /dev/null +++ b/pvlib/performance.py @@ -0,0 +1,91 @@ +# -*- coding: utf-8 -*- +""" +Created on Wed Aug 5 14:51:04 2020 + +@author: Saurabh + +The following functions are from or based on NREL paper and existing equations +already in PVLib + +(poa_global, temp_air, wind_speed, a, b, deltaT, + irrad_ref=1000) +""" + +import pandas as pd +import numpy as np +from pvlib.temperature import sapm_module, sapm_cell +from pvlib.pvsystem import pvwatts_dc + + +#get dataframe prepared for testing with Portage data +df = pd.read_csv('Portage Solar_model.csv', index_col=0, parse_dates=True) + +#inputs assumed will be in System object +a_coeff = -3.56 #only needed to create Tmod_syn +b_coeff = -0.075 #only needed to create Tmod_syn +deltaT = 3 +dc_cap = 1983.96 +gamma_pdc = -0.00433 +################################################################################################## +################################################################################################## + + + +#Get weighted Tcell average using NREL paper, equation 5 +def get_Tref(poa_global, cell_temperature): + + r''' + Calculate weighted PV cell temperature . + + See equation [5] in Weather-Corrected Performance Ratio for details on + the weighted method. + + Parameters + ---------- + poa_global : numeric + Total incident irradiance [W/m^2]. + + cell_temperature : numeric + Temperature of back of module surface [C]. + + + Returns + ------- + numeric, values in degrees C. + + + References + ---------- + .. [1] Dierauf..... (2013). "Weather-Corrected Performance Ratio" + ''' + + Tcell_poa_global = poa_global * cell_temperature + Tref = Tcell_poa_global.sum() / poa_global.sum() + + return Tref + + + +#GET TMOD AND TCELL FROM EXISTING PVLIB TEMPERATURE FUNCTION +cell_temperature = sapm_cell(df['poa_global'], + df['temp_air'], + df['wind'], + a_coeff, + b_coeff, + deltaT + ) + +#GET TMOD AND TCELL FROM EXISTING PVLIB TEMPERATURE FUNCTION +Tref = get_Tref(df['poa_global'], + cell_temperature + ) + +#GET TEMPERATURE-CORRECTED DC ENERGY USING WEIGHTED TREF WITH PVLIB PVWATTS FUNCTION +pdc = pvwatts_dc(df['poa_global'], + cell_temperature, + dc_cap, + gamma_pdc, + temp_ref=Tref + ) + + From c9eb2043a78ebee4efd3f448da2b986732c1402c Mon Sep 17 00:00:00 2001 From: PVPro-SPA <63314623+PVPro-SPA@users.noreply.github.com> Date: Tue, 11 Aug 2020 12:24:58 -0400 Subject: [PATCH 2/3] Update performance.py Updated performance ratio function. Updated by placing all work into single function, that has default values for arguments. --- pvlib/performance.py | 111 +++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 56 deletions(-) diff --git a/pvlib/performance.py b/pvlib/performance.py index 0a9e808396..0e59d62dda 100644 --- a/pvlib/performance.py +++ b/pvlib/performance.py @@ -4,38 +4,18 @@ @author: Saurabh -The following functions are from or based on NREL paper and existing equations -already in PVLib - -(poa_global, temp_air, wind_speed, a, b, deltaT, - irrad_ref=1000) """ -import pandas as pd -import numpy as np -from pvlib.temperature import sapm_module, sapm_cell +from pvlib.temperature import sapm_cell from pvlib.pvsystem import pvwatts_dc -#get dataframe prepared for testing with Portage data -df = pd.read_csv('Portage Solar_model.csv', index_col=0, parse_dates=True) - -#inputs assumed will be in System object -a_coeff = -3.56 #only needed to create Tmod_syn -b_coeff = -0.075 #only needed to create Tmod_syn -deltaT = 3 -dc_cap = 1983.96 -gamma_pdc = -0.00433 -################################################################################################## -################################################################################################## - - -#Get weighted Tcell average using NREL paper, equation 5 -def get_Tref(poa_global, cell_temperature): +def get_performance_ratio(poa_global, temp_air, wind_speed, pac, pdc0, a=-3.56, + b=-0.075, deltaT=3, gamma_pdc=-0.00433): r''' - Calculate weighted PV cell temperature . + Calculate NREL Performance Ratio. See equation [5] in Weather-Corrected Performance Ratio for details on the weighted method. @@ -45,47 +25,66 @@ def get_Tref(poa_global, cell_temperature): poa_global : numeric Total incident irradiance [W/m^2]. - cell_temperature : numeric - Temperature of back of module surface [C]. + temp_air : numeric + Ambient dry bulb temperature [C]. + + wind_speed : numeric + Wind speed at a height of 10 meters [m/s]. + + pac : numeric + AC power [kW]. + + pdc0 : numeric + Power of the modules at 1000 W/m2 and cell reference temperature. + + a : float + Parameter :math:`a` in :eq:`sapm1mod`. + + b : float + Parameter :math:`b` in :eq:`sapm1mod`. + + deltaT : float + Parameter :math:`\Delta T` in :eq:`sapm2` [C]. + + gamma_pdc : numeric + The temperature coefficient in units of 1/C. Typically -0.002 + to -0.005 per degree C. + Returns ------- - numeric, values in degrees C. + performance_ratio: numeric + Performance Ratio of data. References ---------- - .. [1] Dierauf..... (2013). "Weather-Corrected Performance Ratio" + .. [1] "Weather-Corrected Performance Ratio". NREL, 2013. ''' + #GET TMOD/TCELL FROM EXISTING PVLIB TEMPERATURE FUNCTION + cell_temperature = sapm_cell(poa_global, + temp_air, + wind_speed, + a, + b, + deltaT + ) + + #Get weighted Tcell average Tcell_poa_global = poa_global * cell_temperature Tref = Tcell_poa_global.sum() / poa_global.sum() - - return Tref - - - -#GET TMOD AND TCELL FROM EXISTING PVLIB TEMPERATURE FUNCTION -cell_temperature = sapm_cell(df['poa_global'], - df['temp_air'], - df['wind'], - a_coeff, - b_coeff, - deltaT - ) - -#GET TMOD AND TCELL FROM EXISTING PVLIB TEMPERATURE FUNCTION -Tref = get_Tref(df['poa_global'], - cell_temperature - ) - -#GET TEMPERATURE-CORRECTED DC ENERGY USING WEIGHTED TREF WITH PVLIB PVWATTS FUNCTION -pdc = pvwatts_dc(df['poa_global'], - cell_temperature, - dc_cap, - gamma_pdc, - temp_ref=Tref - ) - - + + + #GET TEMPERATURE-CORRECTED DC ENERGY USING WEIGHTED TREF WITH PVLIB PVWATTS FUNCTION + pdc = pvwatts_dc(poa_global, + cell_temperature, + pdc0, + gamma_pdc, + temp_ref=Tref + ) + + performance_ratio = pac.sum() / pdc.sum() + + return performance_ratio \ No newline at end of file From 7870ee3f16c18a7b109013b366c37ab070b68cdf Mon Sep 17 00:00:00 2001 From: PVPro-SPA <63314623+PVPro-SPA@users.noreply.github.com> Date: Tue, 11 Aug 2020 12:28:51 -0400 Subject: [PATCH 3/3] Update performance.py Additonal detailing in comments --- pvlib/performance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pvlib/performance.py b/pvlib/performance.py index 0e59d62dda..cfa7dcb4d4 100644 --- a/pvlib/performance.py +++ b/pvlib/performance.py @@ -18,7 +18,7 @@ def get_performance_ratio(poa_global, temp_air, wind_speed, pac, pdc0, a=-3.56, Calculate NREL Performance Ratio. See equation [5] in Weather-Corrected Performance Ratio for details on - the weighted method. + the weighted method for Tref. Parameters ----------