How to predict energy output using CECMods

692 views Asked by At

I'm trying to reproduce the code here using a 'CECMod' module instead of a 'SandiaMod' module

So, instead of instantiating sandia_modules = pvlib.pvsystem.retrieve_sam('SandiaMod'), I do sandia_modules = pvlib.pvsystem.retrieve_sam('CECMod').

However, the CECMod DataFrame has fewer rows than the SandiaMod DataFrame. As such, there are some rows in SandiaMod (like A[0], A1, A[2], A[3], A[4], B[0], etc.) that don't occur in CECMod. Unfortunately, those rows are utilized to calculate the effective irradiance, and thus the ultimate energy output of our system. Since CECMod has incomplete information, the energy output cannot be calculated. That means none of the modules in CECMod can be used to calculate the energy output of the system using this method.

Can someone direct me toward a way to calculate energy output that is compatible with modules in the CECMod DataFrame?

1

There are 1 answers

0
Luis Vargas On

I had the same issue and I solved in the following way:

Import dependencies:

import pandas as pd
import pvlib
from pvlib.pvsystem import PVSystem
from pvlib.location import Location
from pvlib.modelchain import ModelChain
from pvlib.temperature import TEMPERATURE_MODEL_PARAMETERS

Use Temperature_Model_parameters in order to set model at the top level.

temperature_model_parameters = TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_glass']

Here I set up module and inverter regarding to my system you should be able to change this according to your cec_module and inversor

cec_modules = pvlib.pvsystem.retrieve_sam('CECMod')
cec_inverters = pvlib.pvsystem.retrieve_sam('cecinverter')

cec_module = cec_modules['Canadian_Solar_Inc__CS6X_320P']
cec_inverter = cec_inverters['INGETEAM_POWER_TECHNOLOGY_S_A___Ingecon_Sun_40TL_U_M__480V_']

then declare your location variables

latitude= 20.56
longitude= -103.22
altitude=1544
tz='America/Mexico_City'

instance a Location class:

location = Location(latitude=latitude, longitude=longitude, altitude=altitude, tz=tz)

declare variables for the configuration of your system

surface_tilt = 25
surface_azimuth = 180 # pvlib uses 0=North, 90=East, 180=South, 270=West convention
albedo = 0.2

Instance a PVSystem class with your variables declared:

system = PVSystem(surface_tilt=surface_tilt, surface_azimuth=surface_azimuth,
                 module_parameters=cec_module,
                 inverter_parameters=cec_inverter,
                 temperature_model_parameters=temperature_model_parameters,
                 albedo=albedo, surface_type=None, module=None, 
                 module_type='glass_polymer',
                 modules_per_string=19.5, 
                 strings_per_inverter=8, inverter=None, 
                 racking_model='open_rack', 
                 losses_parameters=None, 
                 name='Name of PV system: Huerto de Cutonalá')

then instance a ModelChain class:

mc = ModelChain(system, location, name='Huerto de Cutonalá', 
                clearsky_model='ineichen', transposition_model='haydavies', 
                solar_position_method='nrel_numpy', airmass_model='kastenyoung1989',
                dc_model=None, #from module specifications
                ac_model='sandia', #from inverter specifications
                aoi_model='no_loss', 
                spectral_model='no_loss', #spectral model 'no loss' otherwise error
                temperature_model='sapm', losses_model='no_loss')

At this point you already have simulated your system but now you have to declare your weather forecast model and your time variables in order to get the power otput.

import datetime
#Variables de tiempo

start = pd.Timestamp(datetime.date.today(), tz=tz) # today's date
end = start + pd.Timedelta(days=7) # 7 days from today

import dependencies related to forecast models:

from pvlib import solarposition, irradiance, atmosphere, pvsystem, inverter, temperature, iam
from pvlib.forecast import GFS, NAM, NDFD, RAP, HRRR

# define your forecast model
fm = GFS()
#fm = NAM()
#fm = NDFD()
#fm = RAP()
#fm = HRRR()

get and process data from the forecast model:

forecast_data = fm.get_processed_data(latitude, longitude, start, end)

Now this is the tricky part, in order to use the .run_model method, you need a pandas.DataFrame with weather data:

ghi = forecast_data['ghi']
dni = forecast_data['dni']
dhi = forecast_data['dhi']
temp_air = forecast_data['temp_air']
wind_speed = forecast_data['wind_speed']
indexDF = forecast_data.index

weather = pd.DataFrame([dni, ghi, dhi, temp_air, wind_speed]).T

You should use .T method in order to transpose the data according to the weather parameter required in .run_model method

Now use .run_model method with weather dataframe as parameter:

mc.run_model(weather)

then you can now use .ac, .dc and some other methods for your modelChain instance:

mc.ac
mc.effective_irradiance
mc.airmass
mc.cell_temperature