为什么 pvlib 中能量产生的最佳表面方位角不是在北半球 180° 或附近?

问题描述

我正在使用开源 pvlib 软件(和 CEC 模块)构建模型来估算每年的光伏发电量。我在模型中遇到了一些不一致的问题,如果社区可以提供任何故障排除,我将不胜感激。

我的主要问题是:该模型告诉我,理想的北半球表面_方位角(即能量输出最高的表面_方位角)约为 76°(正东以北),而能量最差的表面_方位角产量约为 270°(正西)。但是,我知道北半球的理想表面方位角应该是大约 180°(由于南方),最差的表面方位角在 0°(由于北方)。

I've included this graph to help visualize the variation in energy production based on surface_azimuth 这也是在所附代码的末尾生成的。

谁能帮我纠正这个问题或纠正我的理解?

复制以下代码以供参考

import os
import pandas as pd
import numpy as np
import os
import os.path
import matplotlib.pyplot as plt
import pvlib
from geopy.exc import GeocoderTimedOut 
from geopy.geocoders import Nominatim 
from IPython.display import Image


## GET THE LATITUDE & LONGITUDE OF A GIVEN CITY
geolocator = Nominatim(user_agent="____'s app") 
geo = geolocator.geocode("Berkeley") 
## CHECK THAT CITY IS CORRECT (by Country,State,etc.)
print(geo.address)
# CHECK THE LAT,LON order
print(geo.latitude,geo.longitude)


## SELECT THE YEAR & TIMES YOU'D LIKE TO MODEL OFF
YEAR = 2019
STARTDATE = '%d-01-01T00:00:00' % YEAR
ENDDATE = '%d-12-31T23:59:59' % YEAR
TIMES = pd.date_range(start=STARTDATE,end=ENDDATE,freq='H')

## ACCESS THE NREL API TO EXTRACT WEATHER DATA
NREL_API_KEY = os.getenv('NREL_API_KEY','DEMO_KEY')
## FILL IN THE BLANK WITH YOUR EMAIL ADRRESS
EMAIL = os.getenv('EMAIL','_______.com')

##NEED TO COMMENT OUT THIS LINE BELOW -- if you call it too many times within an hour,it will break your code
header,data = pvlib.iotools.get_psm3(LATITUDE,LONGITUDE,NREL_API_KEY,EMAIL)


## SELECT THE PVLIB PANEL & INTERVTER YOU'D LIKE TO USE
## CAN ALSO CHOOSE FROM SANDIA LABS' DATASET OF PANELS & INVERTERS (check out the function)
## WE CHOSE THE CECMods because they highlighted the ones that were BIPV
INVERTERS = pvlib.pvsystem.retrieve_sam('CECInverter')
INVERTER_10K = INVERTERS['SMA_America__SB10000TL_US__240V_']
CECMODS = pvlib.pvsystem.retrieve_sam('CECMod')

## SELECT THE PANEL YOU'D LIKE TO USE (NOTE: THE PEVAFERSA MODEL IS A BIPV PANEL)
CECMOD_MONO = CECMODS['Pevafersa_America_IP_235_GG']


## CREATING AN ARRAY TO IteraTE THROUGH IN ORDER TO TEST DIFFERENT SURFACE_AZIMUTHS
heading_array = np.arange(0,361,2)
heading_array

heading_DF = pd.DataFrame(heading_array).rename(columns = {0: "heading"})
heading_DF.head()


# geo IS AN OBJECT (the given city) CREATED ABOVE
LATITUDE,LONGITUDE = geo.latitude,geo.longitude

# data IS AN OBJECT (the weather patterns) CREATED ABOVE
# TIMES IS ALSO CREATED ABOVE,AND REPRESENTS TIME
data.index = TIMES
dni = data.DNI.values
ghi = data.GHI.values
dhi = data.DHI.values
surface_albedo = data['Surface Albedo'].values
temp_air = data.Temperature.values
dni_extra = pvlib.irradiance.get_extra_radiation(TIMES).values

# GET SOLAR POSITION
sp = pvlib.solarposition.get_solarposition(TIMES,LATITUDE,LONGITUDE)
solar_zenith = sp.apparent_zenith.values
solar_azimuth = sp.azimuth.values


# CREATING THE ARRY TO STORE THE DAILY ENERGY OUTPUT BY SOLAR AZIMUTH
e_by_az = []


# IDEAL surface_tilt ANGLE IN norTHERN HEMISPHERE IS ~25
surface_tilt = 25

# ITErating THROUGH DIFFERENT SURFACE_AZIMUTH VALUES
for heading in heading_DF["heading"]:
    
 
    surface_azimuth = heading

    poa_sky_diffuse = pvlib.irradiance.get_sky_diffuse(
        surface_tilt,surface_azimuth,solar_zenith,solar_azimuth,dni,ghi,dhi,dni_extra=dni_extra,model='haydavies')

    # calculate the angle of incidence using the surface_azimuth and (hardcoded) surface_tilt
    aoi = pvlib.irradiance.aoi(
        surface_tilt,solar_azimuth)
    # https://pvlib-python.readthedocs.io/en/stable/generated/pvlib.irradiance.aoi.html
    # https://pvlib-python.readthedocs.io/en/stable/generated/pvlib.pvsystem.PVSystem.html

    poa_ground_diffuse = pvlib.irradiance.get_ground_diffuse(
        surface_tilt,albedo=surface_albedo)
    poa = pvlib.irradiance.poa_components(
        aoi,poa_sky_diffuse,poa_ground_diffuse)
    poa_direct = poa['poa_direct']
    poa_diffuse = poa['poa_diffuse']
    poa_global = poa['poa_global']
    iam = pvlib.iam.ashrae(aoi)
    effective_irradiance = poa_direct*iam + poa_diffuse
    temp_cell = pvlib.temperature.pvsyst_cell(poa_global,temp_air)

    # THIS IS THE MAGIC
    cecparams = pvlib.pvsystem.calcparams_cec(
        effective_irradiance,temp_cell,CECMOD_MONO.alpha_sc,CECMOD_MONO.a_ref,CECMOD_MONO.I_L_ref,CECMOD_MONO.I_o_ref,CECMOD_MONO.R_sh_ref,CECMOD_MONO.R_s,CECMOD_MONO.Adjust)
    # mpp is the list of energy output by hour for the whole year using a single panel
    mpp = pvlib.pvsystem.max_power_point(*cecparams,method='newton')
    mpp = pd.DataFrame(mpp,index=TIMES)
    first48 = mpp[:48]
    Edaily = mpp.p_mp.resample('D').sum()
    # Edaily is the list of energy output by day for the whole year using a single panel

    Eyearly = sum(Edaily)
    
    e_by_az.append(Eyearly)


## LINKING THE heading (ie. surface_azimuth) AND THE Eyearly (ie. yearly energy output) IN A DF
heading_DF["Eyearly"] = e_by_az
heading_DF.head()


## VISUALIZE ENERGY OUTPUT BY SURFACE_AZIMUTH
plt.plot(heading_DF["heading"],heading_DF["Eyearly"])
plt.xlabel("Surface_Azimuth Angle")
plt.ylabel("Yearly Energy Output with tilt @ " + str(surface_tilt))
plt.title("Yearly Energy Output by Solar_Azimuth Angle using surface_tilt = " + str(surface_tilt) + " in Berkeley,CA");

# FIND SURFACE_AZIMUTH THAT YIELDS THE MAX ENERGY OUTPUT
heading_DF[heading_DF["Eyearly"] == max(heading_DF["Eyearly"])]

# FIND SURFACE_AZIMUTH THAT YIELDS THE MIN ENERGY OUTPUT
heading_DF[heading_DF["Eyearly"] == min(heading_DF["Eyearly"])]

解决方法

感谢 kevinanderso@gmail.com 在 pvlib-python Google Group 中帮助我。他指出我的“TIMES 变量不是时区感知的,因此太阳位置计算假定为 UTC”

为了解决这个问题,他建议我使用 tz='Etc/GMT+8' 初始化 TIMES(即美国的 PST)。

用他的话来说,“[I] 最初发布的代码是对一个假设系统进行建模,其中太阳位置和辐照度相互时移。这与现实大相径庭,因此现实生活中的期望并不适用到您的模型”。

感谢 Kevin,希望这能帮助其他遇到类似问题的人。