Tools¶
These helper functions provide additional functionality for working with specific models.
Resource Tools¶
These can be accessed via import PySAM.ResourceTools
These functions help with solar resource, wind resource and utility rate data, downloads and formatting. See how to download solar resource data from the National Solar Radiation Database or wind resource data from the WindToolKit. Use resource files directly in your PySAM models or input them as dictionaries.
Please see an example of FetchResource here
-
class
files.ResourceTools.
FetchResourceFiles
(tech, nrel_api_key, nrel_api_email, workers=1, resource_year='tmy', resource_interval_min=60, resource_dir=None)¶ Download U.S. solar and wind resource data for SAM from NRELs developer network https://developer.nrel.gov/
Param: tech (str): one of ‘wind’ or ‘pv’ Param: workers (int): number of threads to use when parellelizing downloads Param: resource_year (int): year to grab resources from. can be ‘tmy’ for solar Param: resource_interval_min (int): time interval of resource data Param: nrel_api_key (str): NREL developer API key, available here https://developer.nrel.gov/signup/ nrel_api_email (str): email associated with nrel_api_key
-
fetch
(points)¶ Creates dict with {region:path_to_SAM_resource_file}.
points(iterable): iterable of lon/lat tuples, i.e. Shapely Points
-
-
files.ResourceTools.
SRW_to_wind_data
(filename)¶ Format as ‘wind_resource_data’ dictionary for use in PySAM. For more information about SRW file format, see https://sam.nrel.gov/weather-data/weather-data-publications.html
Parameters: filename – A .srw wind resource file Returns: Dictionary for PySAM.Windpower.Windpower.Resource
-
files.ResourceTools.
TMY_CSV_to_solar_data
(filename)¶ Format a TMY csv file as ‘solar_resource_data’ dictionary for use in PySAM. For more information about TMY CSV file format, see https://sam.nrel.gov/weather-data/weather-data-publications.html
Parameters: filename – Any csv resource file formatted according to NSRDB Returns: Dictionary for PySAM.Pvwattsv7.Pvwattsv7.SolarResource, and other models
-
files.ResourceTools.
URDBv7_to_ElectricityRates
(urdb_response)¶ - Formats response from Utility Rate Database API version 7 for use in PySAM
- i.e.
- model = PySAM.UtilityRate5.new() rates = PySAM.ResourceTools.URDBv7_to_ElectricityRates(urdb_response) model.ElectricityRates.assign(rates)
Param: urdb_response: dictionary with response fields following https://openei.org/services/doc/rest/util_rates/?version=7 Returns: dictionary for PySAM.UtilityRate5.UtilityRate5.ElectricityRates
Battery Tools¶
These can be accessed via import PySAM.BatteryTools
-
files.BatteryTools.
battery_model_sizing
(model, desired_power, desired_capacity, desired_voltage, leadacid_q10=None, leadacid_q20=None, leadacid_qn=None, leadacid_tn=None)¶ Modifies model with new sizing
Parameters: - model – PySAM.StandAloneBattery model
- desired_power – float kWAC if AC-connected, kWDC otherwise
- desired_capacity – float kWhAC if AC-connected, kWhDC otherwise
- desired_voltage – float volts
- leadacid_q10 – optional float new Capacity at 10-hour discharge rate
- leadacid_q20 – optional float new Capacity at 20-hour discharge rate
- leadacid_qn – optional float new Capacity at n-hour discharge rate
- leadacid_tn – optional float Hour for leadacid_qn
Returns: output_dictionary of sizing parameters
-
files.BatteryTools.
size_li_ion_battery
(input_dict)¶ All efficiencies and rates in percentages, 0-100.
Inverter efficiency depends on which inverter model is being used, inverter_model.
Parameters: input_dict – - batt_chem: int
- Lithium-ion (1) or Lead-Acid (0)
- batt_Qfull: float, Ah
- capacity of single cell
- batt_Vnom_default: float, V
- voltage of single cell
- Required only if batt_chem is False:
- LeadAcid_q10: float 0-100, Ah
- 10 hour discharge rate
- LeadAcid_q20: float 0-100, Ah
- 20 hour discharge rate
- LeadAcid_tn: int, hour
- hour for custom hour discharge rate
- LeadAcid_qn: float 0-100, Ah
- n-hour discharge rate
- batt_ac_or_dc: bool
- True if ac-connected
- desired_power: float, kW
- power of the battery
- desired_capacity: float, kWh
- capacity
- desired_voltage: float, V
- voltage
- size_by_ac_not_dc: bool, default False
- True for sizing battery as kWAC and kWhAC
- batt_dc_ac_efficiency: float 0-100, required only if size_by_ac_not_dc is True
- AC to DC power in conversion
- inverter_eff: float 0-100, required only if batt_ac_or_dc is False
- AC to DC power from inverter
- batt_dc_dc_efficiency: float 0-100, optional
- DC to DC power conversion in battery management system
Returns: output_dict: voltage: float, V computed- power: float
- computed
- batt_computed_bank_capacity: float
- computed
- batt_computed_series: int
- number of cells connected in series
- batt_computed_strings: int
- number of strings connected in parallel
time_capacity: float 0-1
batt_current_charge_max: float, A
batt_current_discharge_max: float, A
batt_power_charge_max_kwac: float, kWAC
batt_power_discharge_max_kwac: float, kWAC
batt_power_charge_max_kwdc: float, kWDC
batt_power_discharge_max_kwdc: float, kWDC
- only if batt_chem is False:
- LeadAcid_q10_computed: float 0-100, Ah
LeadAcid_q20_computed: float 0-100, Ah
LeadAcid_qn_computed: float 0-100, Ah