Wind Farm Sizing in PySAM

  • Paul Gilman
  • Topic Author
More
03 Mar 2021 23:30 - 03 Mar 2021 23:32 #9337 by Paul Gilman
Wind Farm Sizing in PySAM was created by Paul Gilman
I had a quick question regarding the wind power PySAM module. I am trying to run the module for different system capacities yet I keep getting the same power output regardless of the system capacity that I specify. In the code snippet below, whenever I change the Farm.system_capacity value, the annual energy generated remains the same. When I change the resource file I can get a different power generated, but changing the system capacity doesn’t affect the annual energy for that new resource. I feel like I am missing something simple, but haven’t been able to find any fixes in the forum or documentation. 
import PySAM.Windpower as wpsystem_model = wp.default('WindPowerLCOECalculator')

system_model = wp.default('WindPowerLCOECalculator')
system_model.Resource.wind_resource_filename = 'lat39.74_lon-104.98__2013_80m.srw'

system_model.Farm.system_capacity = 10e3  # (kW)

system_model.execute(0)

print(system_model.Outputs.annual_energy)
Last edit: 03 Mar 2021 23:32 by Paul Gilman.

Please Log in or Create an account to join the conversation.

  • Paul Gilman
  • Topic Author
More
03 Mar 2021 23:44 - 04 Mar 2021 00:18 #9338 by Paul Gilman
Replied by Paul Gilman on topic Wind Farm Sizing in PySAM
On the SAM user interface's Wind Farm page, there is an option to choose how to size the system.



These sizing options involve calculations that are performed in the SAM user interface rather than in the underlying SSC library that SAM and PySAM share, so the options are not available in PySAM.

I will try to get an example demonstrating how to size a wind farm in PySAM and either post it here or add it to the PySAM documentation at nrel-pysam.readthedocs.io/en/master/index.html.

Best regards,
Paul.
Attachments:
Last edit: 04 Mar 2021 00:18 by Paul Gilman.

Please Log in or Create an account to join the conversation.

  • Paul Gilman
  • Topic Author
More
19 Apr 2021 20:18 - 19 Apr 2021 20:34 #9481 by Paul Gilman
Replied by Paul Gilman on topic Wind Farm Sizing in PySAM
Here is a simple example showing how to model a single turbine and a wind farm from using PySAM. To test it, put the attached wind resource file sample-wind-data.srw in the same folder as the Python script.

import PySAM.Windpower as wp

system_model = wp.default('WindPowerLCOECalculator')
system_model.Resource.wind_resource_filename = 'sample-wind-data.srw'


# Wind turbine power curve data

system_model.Turbine.wind_turbine_powercurve_windspeeds = [ 0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 4, 4.25, 4.5, 4.75, 5, 5.25, 5.5, 5.75, 6, 6.25, 6.5, 6.75, 7, 7.25, 7.5, 7.75, 8, 8.25, 8.5, 8.75, 9, 9.25, 9.5, 9.75, 10, 10.25, 10.5, 10.75, 11, 11.25, 11.5, 11.75, 12, 12.25, 12.5, 12.75, 13, 13.25, 13.5, 13.75, 14, 14.25, 14.5, 14.75, 15, 15.25, 15.5, 15.75, 16, 16.25, 16.5, 16.75, 17, 17.25, 17.5, 17.75, 18, 18.25, 18.5, 18.75, 19, 19.25, 19.5, 19.75, 20, 20.25, 20.5, 20.75, 21, 21.25, 21.5, 21.75, 22, 22.25, 22.5, 22.75, 23, 23.25, 23.5, 23.75, 24, 24.25, 24.5, 24.75, 25, 25.25, 25.5, 25.75, 26, 26.25, 26.5, 26.75, 27, 27.25, 27.5, 27.75, 28, 28.25, 28.5, 28.75, 29, 29.25, 29.5, 29.75, 30, 30.25, 30.5, 30.75, 31, 31.25, 31.5, 31.75, 32, 32.25, 32.5, 32.75, 33, 33.25, 33.5, 33.75, 34, 34.25, 34.5, 34.75, 35, 35.25, 35.5, 35.75, 36, 36.25, 36.5, 36.75, 37, 37.25, 37.5, 37.75, 38, 38.25, 38.5, 38.75, 39, 39.25, 39.5, 39.75, 40 ]
system_model.Turbine.wind_turbine_powercurve_powerout = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21.32, 33.51, 45.69, 65.21, 79.83, 104.25, 128.66, 157.97, 187.27, 216.58, 250.78, 292.32, 333.85, 375.4, 426.72, 475.6, 534.27, 597.81, 656.49, 724.94, 798.29, 871.63, 940.08, 1010, 1060, 1130, 1190, 1240, 1290, 1330, 1370, 1390, 1410, 1430, 1440, 1460, 1470, 1475, 1480, 1485, 1490, 1495, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
system_model.Turbine.wind_turbine_rotor_diameter = 77 # m
system_model.Turbine.wind_turbine_hub_ht = 80 # m

turbine_capacity = 1500 # kW

# Single turbine example

turbine_x_positions = [ 0 ] # m
turbine_y_positions = [ 0 ] # m

number_of_turbines = len( turbine_x_positions )

system_model.Farm.wind_farm_xCoordinates = turbine_x_positions
system_model.Farm.wind_farm_yCoordinates = turbine_y_positions

system_model.Farm.system_capacity = turbine_capacity * number_of_turbines  # (kW)

system_model.execute(0)

calculate_capacity_factor = system_model.Outputs.annual_energy / system_model.Farm.system_capacity / 8760 * 100

print("One turbine:")
print(system_model.Outputs.annual_energy,  "kWh")
print(system_model.Farm.system_capacity, "kW")
print(system_model.Outputs.capacity_factor, "%")
print(calculate_capacity_factor, "%")

# Four turbine example

# X-Y grid of turbine positions
turbine_x_positions = [ 0, 616, 308, 924 ] # m
turbine_y_positions = [ 0, 0, 616, 616 ] # m, must have same length as turbine x positions

number_of_turbines = len( turbine_x_positions )

system_model.Farm.wind_farm_xCoordinates = turbine_x_positions
system_model.Farm.wind_farm_yCoordinates = turbine_y_positions

system_model.Farm.system_capacity = turbine_capacity * number_of_turbines  # (kW)

system_model.execute(0)

calculate_capacity_factor = system_model.Outputs.annual_energy / system_model.Farm.system_capacity / 8760 * 100

print()

print("Multiple turbines:")
print(system_model.Outputs.annual_energy, "kWh")
print(system_model.Farm.system_capacity, "kW")
print(system_model.Outputs.capacity_factor, "%")
print(calculate_capacity_factor, "%")

Best regards,
Paul.
Last edit: 19 Apr 2021 20:34 by Paul Gilman.

Please Log in or Create an account to join the conversation.

  • Jubeyer Rahman
More
21 Apr 2021 20:56 #9488 by Jubeyer Rahman
Replied by Jubeyer Rahman on topic Wind Farm Sizing in PySAM
Hi Paul,

Your post seems very helpful. However, I am trying to develop something similar to the NSRDB data download and processing for wind from WindToolkit but my model doesn't seem to work. As a new user of PySAM, I seek for your help. Below is my code. Can you please help me to find out what really the issue is?


import pandas as pdimport numpy as npimport sys, osfrom IPython.display import displaylat, lon, year = 33.2164, -97.1292, 2010  # You must request an NSRDB api key from the link aboveapi_key = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'# Set the attributes to extract (e.g.,windspeed, winddirection, etc.), separated by commas.attributes = 'pressure_100m,windspeed_100m,winddirection_100m,temperature_100m'# Choose year of datayear = '2010'# Set leap year to true or false. True will return leap day data if present, false will not.leap_year = 'false'# Set time interval in minutes, i.e., '30' is half hour intervals. Valid intervals are 5, 15, 30, 45 & 60.interval = '5'# Specify Coordinated Universal Time (UTC), 'true' will use UTC, 'false' will use the local time zone of the data.# NOTE: In order to use the WindToolkit data in SAM, you must specify UTC as 'false'. SAM requires the data to be in the# local time zone.utc = 'false'# Your full name, use '+' instead of spaces.your_name = 'X+X'# Your reason for using the NSRDB.reason_for_use = 'example'# Your affiliationyour_affiliation = 'NREL'# Your email addressyour_email = 'X@X.com'# Please join our mailing list so we can keep you up-to-date on new developments.mailing_list = 'true'# Declare url stringurl = 'developer.nrel.gov/api/wind-toolkit/v2/wind/wtk-download.csv?wkt=POINT({lon}%20{lat})&names={year}&leap_day={leap}&interval={interval}&utc={utc}&full_name={name}&email={email}&affiliation={affiliation}&mailing_list={mailing_list}&reason={reason}&api_key={api}&attributes={attr}'.format(        year=year, lat=lat, lon=lon, leap=leap_year, interval=interval, utc=utc, name=your_name, email=your_email,        mailing_list=mailing_list, affiliation=your_affiliation, reason=reason_for_use, api=api_key, attr=attributes)# Return just the first 1 line to get metadata:info = pd.read_csv(url, nrows=1)# See metadata for specified properties, e.g., timezone timezone= info# Return all but first 1 line of csv to get data:df = pd.read_csv(        'developer.nrel.gov/api/wind-toolkit/v2/wind/wtk-download.csv?wkt=POINT({lon}%20{lat})&names={year}&leap_day={leap}&interval={interval}&utc={utc}&full_name={name}&email={email}&affiliation={affiliation}&mailing_list={mailing_list}&reason={reason}&api_key={api}&attributes={attr}'.format(            year=year, lat=lat, lon=lon, leap=leap_year, interval=interval, utc=utc, name=your_name, email=your_email,            mailing_list=mailing_list, affiliation=your_affiliation, reason=reason_for_use, api=api_key,            attr=attributes), skiprows=1)# Set the time index in the pandas dataframe:df = df.set_index(pd.date_range('1/1/{yr}'.format(yr=year), freq=interval+'Min', periods=525600/int(interval)))# take a lookprint ('shape:',df.shape)df.head()print (df.columns.values)################################################################################################################## My Doubt is in this section mostly ####import site# Use site.addsitedir() to set the path to the SAM SDK API. Set path to the python directory.site.addsitedir('/Applications/sam-sdk-2015-6-30-r3/languages/python/')import sscapissc = sscapi.PySSC()# Resource inputs for SAM model:wfd = ssc.data_create()ssc.data_set_number(wfd, 'lat', lat)ssc.data_set_number(wfd, 'lon', lon)#ssc.data_set_number(wfd, 'tz', timezone)#ssc.data_set_number(wfd, 'elev', elevation)ssc.data_set_array(wfd, 'year', df.index.year)ssc.data_set_array(wfd, 'month', df.index.month)ssc.data_set_array(wfd, 'day', df.index.day)ssc.data_set_array(wfd, 'hour', df.index.hour)ssc.data_set_array(wfd, 'minute', df.index.minute)wind_turbine_powercurve_windspeeds = [ 0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 4, 4.25, 4.5, 4.75, 5, 5.25, 5.5, 5.75, 6, 6.25, 6.5, 6.75, 7, 7.25, 7.5, 7.75, 8, 8.25, 8.5, 8.75, 9, 9.25, 9.5, 9.75, 10, 10.25, 10.5, 10.75, 11, 11.25, 11.5, 11.75, 12, 12.25, 12.5, 12.75, 13, 13.25, 13.5, 13.75, 14, 14.25, 14.5, 14.75, 15, 15.25, 15.5, 15.75, 16, 16.25, 16.5, 16.75, 17, 17.25, 17.5, 17.75, 18, 18.25, 18.5, 18.75, 19, 19.25, 19.5, 19.75, 20, 20.25, 20.5, 20.75, 21, 21.25, 21.5, 21.75, 22, 22.25, 22.5, 22.75, 23, 23.25, 23.5, 23.75, 24, 24.25, 24.5, 24.75, 25, 25.25, 25.5, 25.75, 26, 26.25, 26.5, 26.75, 27, 27.25, 27.5, 27.75, 28, 28.25, 28.5, 28.75, 29, 29.25, 29.5, 29.75, 30, 30.25, 30.5, 30.75, 31, 31.25, 31.5, 31.75, 32, 32.25, 32.5, 32.75, 33, 33.25, 33.5, 33.75, 34, 34.25, 34.5, 34.75, 35, 35.25, 35.5, 35.75, 36, 36.25, 36.5, 36.75, 37, 37.25, 37.5, 37.75, 38, 38.25, 38.5, 38.75, 39, 39.25, 39.5, 39.75, 40 ]wind_turbine_powercurve_powerout = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21.32, 33.51, 45.69, 65.21, 79.83, 104.25, 128.66, 157.97, 187.27, 216.58, 250.78, 292.32, 333.85, 375.4, 426.72, 475.6, 534.27, 597.81, 656.49, 724.94, 798.29, 871.63, 940.08, 1010, 1060, 1130, 1190, 1240, 1290, 1330, 1370, 1390, 1410, 1430, 1440, 1460, 1470, 1475, 1480, 1485, 1490, 1495, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 1500, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]ssc.data_set_array(wfd,'wind_turbine_powercurve_windspeeds',wind_turbine_powercurve_windspeeds)ssc.data_set_array(wfd,'wind_turbine_powercurve_powerout',wind_turbine_powercurve_powerout)#####ssc.data_set_array(wfd, 'wind_speed', df)ssc.data_set_array(wfd, 'wind_direction', df)# Create SAM compliant object  dat = ssc.data_create()ssc.data_set_table(dat, 'wind_resource_data', wfd)ssc.data_free(wfd)# Specify the system Configurationwind_resource_model_choice=0ssc.data_set_number(dat, 'wind_resource_model_choice', wind_resource_model_choice)# Set system capacity in MWsystem_capacity = 2 # will change for different sitesssc.data_set_number(dat, 'system_capacity', system_capacity)# Setting the hub height in meter of wind turbinewind_turbine_hub_ht=100ssc.data_set_number(dat, 'wind_turbine_hub_ht', wind_turbine_hub_ht)# Set rotor diameter in meterwind_turbine_rotor_diameter=95ssc.data_set_number(dat, 'wind_turbine_rotor_diameter',wind_turbine_rotor_diameter)# Set the shearwind_resource_shear=0.14ssc.data_set_number(dat, 'wind_resource_shear', wind_resource_shear)# execute and put generation results back into dataframemod = ssc.module_create('WindPowerSingleOwner')ssc.module_exec(mod, dat)df = np.array(ssc.data_get_array(dat, 'gen'))# free the memoryssc.data_free(dat)ssc.module_free(mod)############################################## Divide sum of generation by the number of periods times the system sizedf.sum() / (525600/int(interval) * system_capacity)# Total Energy:df.sum()

  

Please Log in or Create an account to join the conversation.

  • Paul Gilman
  • Topic Author
More
22 Apr 2021 18:06 #9493 by Paul Gilman
Replied by Paul Gilman on topic Wind Farm Sizing in PySAM
Hi Jubeyer,

Could you attach your code sample as a text file instead of posting it in the message body?

Best regards,
Paul.

Please Log in or Create an account to join the conversation.

  • Jubeyer Rahman
More
22 Apr 2021 18:38 #9496 by Jubeyer Rahman
Replied by Jubeyer Rahman on topic Wind Farm Sizing in PySAM
OK. Sorry about  that. Please check the attached file.

I have a few additional question:

a. Is there any way to load the turbine specification just by putting its name as we do in the SAM GUI.
Regards,
Jubeyer

Please Log in or Create an account to join the conversation.

Moderators: Paul Gilman
Powered by Kunena Forum