Skip to main content
 首页 » 编程设计

python之如何使用 PVLIB 构建通用光伏系统

2024年11月24日10shanyou

我正在尝试构建一个通用的光伏系统来建模,而不需要特定的模块和逆变器。我有所有关键变量(表面方位角、倾斜、反照率、跟踪技术(固定、单、双)、位置、DC 大小(KW)、损耗因子、DC/AC 比)

我知道 PVWatts 是执行此操作的最佳方法,但我不知道它是如何工作的。我如何最好地在 PVLIB 中构建这样的 pvsystem?

附加的当前代码,它可以工作,但希望更改 pvsystem 构建

# import packages 
import os 
import itertools 
import matplotlib.pyplot as plt 
import pandas as pd 
from pandas.plotting import register_matplotlib_converters 
import numpy as np 
 
# pvlib imports 
import pvlib 
from pvlib import clearsky, atmosphere, solarposition 
from pvlib.iotools import read_tmy3 
from pvlib.pvsystem import PVSystem 
from pvlib.location import Location 
from pvlib.modelchain import ModelChain 
 
# Set Location 
latitude, longitude, tz, altitude, name = -17.0, 145.4, 'Etc/GMT+10', 400, 'Mareeba/QLD' 
location = Location(latitude, longitude, tz, altitude, name) 
 
# load some module and inverter specifications 
sandia_modules = pvlib.pvsystem.retrieve_sam('SandiaMod') 
cec_inverters = pvlib.pvsystem.retrieve_sam('cecinverter') 
sandia_module = sandia_modules['Canadian_Solar_CS5P_220M___2009_'] 
cec_inverter = cec_inverters['ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_'] 
system = PVSystem( 
                    surface_tilt=20, 
                    surface_azimuth=0, 
                    module_parameters=sandia_module, 
                    inverter_parameters=cec_inverter, 
                    albedo=0.2, 
                    # modules_per_string=5, 
                    # strings_per_inverter=5 
                  )    
 
# Get Irradiance and weather 
times = pd.date_range(start='2018-01-01', end='2018-12-31', freq='5min', tz=location.tz) 
solpos = pvlib.solarposition.get_solarposition(times, latitude, longitude) 
apparent_zenith = solpos['apparent_zenith'] 
airmass = pvlib.atmosphere.get_relative_airmass(apparent_zenith) 
pressure = pvlib.atmosphere.alt2pres(altitude) 
airmass = pvlib.atmosphere.get_absolute_airmass(airmass, pressure) 
linke_turbidity = pvlib.clearsky.lookup_linke_turbidity(times, latitude, longitude) 
dni_extra = pvlib.irradiance.get_extra_radiation(times) 
ineichen = clearsky.ineichen(apparent_zenith, airmass, linke_turbidity, altitude, dni_extra) 
print(ineichen.head(3)) 
 
# Graph Irriadiance 
# plt.figure(); 
# ax = ineichen.plot() 
# ax.set_ylabel('Irradiance $W/m^2$'); 
# ax.set_title('Ineichen Clear Sky Model'); 
# ax.legend(loc=2); 
# plt.show() 
 
# build weather data 
weather = pd.concat( 
    [ 
        ineichen, 
        pd.DataFrame( 
            [[20.0, 5.0] for _ in range(ineichen.shape[0])], 
            ineichen.index, ['temp_air', 'wind_speed'] 
        ) 
    ], axis=1) 
print(weather.head(3)) 
 
# build model chain 
mc = ModelChain(system, location) 
 
# run model chain 
mc.run_model(times=weather.index, weather=weather) 
 
register_matplotlib_converters() 
plt.plot(mc.ac) 
plt.show() 

请您参考如下方法:

用指定 PVWatts 参数的字典替换您的 sandia_module 和 cec_inverter。本文档部分中的代码演示了如何指定 PVWatts 参数:https://pvlib-python.readthedocs.io/en/stable/user_guide/pvsystem.html#design-philosophy