How to build a generic pvsystem using PVLIB

Question:

I am trying to build a generic pvsystem for modelling without the need for specific modules and inverters. I have all the key variables (surface azimuth, tilt, albedo, tracking technology(Fixed, Single, Dual), location, DC size in KW, loss factors, DC/AC ratio)

I understand PVWatts is the best way to do this, but I don’t know how it works. how best would I build such a pvsystem in PVLIB?

Current code attached, It works but looking to change the pvsystem build

# 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()
Asked By: Bobby Heyer

||

Answers:

Replace your sandia_module and cec_inverter with dictionaries that specify the PVWatts parameters. The code in this documentation section demonstrates specifying PVWatts parameters: https://pvlib-python.readthedocs.io/en/stable/user_guide/pvsystem.html#design-philosophy

Answered By: Will Holmgren
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.