from dotenv import load_dotenv from hybrid.keys import set_developer_nrel_gov_key # California Site # lat = 33.907295 # lon = -116.555588 # year = 2012 # hubheight = 80 # Texas Site # lat = 34.212257 # lon = -101.361160 # year = 2012 # hubheight = 91.5 # Maine Site lat = 44.766171 lon = -68.157669 year = 2012 hubheight = 116.5 load_dotenv() NREL_API_KEY = os.getenv("NREL_API_KEY") set_developer_nrel_gov_key( NREL_API_KEY ) # Set this key manually here if you are not setting it using the .env WindResource(lat=lat, lon=lon, year=year, wind_turbine_hub_ht=hubheight) SolarResource(lat=lat, lon=lon, year=year)
def setup_power_calcs(scenario, solar_size_mw, storage_size_mwh, storage_size_mw, interconnection_size_mw): """ A function to facilitate plant setup for POWER calculations, assuming one wind turbine. INPUT VARIABLES scenario: dict, the H2 scenario of interest solar_size_mw: float, the amount of solar capacity in MW storage_size_mwh: float, the amount of battery storate capacity in MWh storage_size_mw: float, the amount of battery storate capacity in MW interconnection_size_mw: float, the interconnection size in MW OUTPUTS hybrid_plant: the hybrid plant object from HOPP for power calculations """ # Set API key load_dotenv() NREL_API_KEY = os.getenv("NREL_API_KEY") set_developer_nrel_gov_key( NREL_API_KEY ) # Set this key manually here if you are not setting it using the .env # Step 1: Establish output structure and special inputs year = 2013 sample_site['year'] = year useful_life = 30 custom_powercurve = True electrolyzer_size = 50000 sample_site['lat'] = scenario['Lat'] sample_site['lon'] = scenario['Long'] tower_height = scenario['Tower Height'] scenario['Useful Life'] = useful_life site = SiteInfo(sample_site, hub_height=tower_height) technologies = { 'pv': { 'system_capacity_kw': solar_size_mw * 1000 }, 'wind': { 'num_turbines': 1, 'turbine_rating_kw': scenario['Turbine Rating'] * 1000, 'hub_height': scenario['Tower Height'], 'rotor_diameter': scenario['Rotor Diameter'] }, 'grid': electrolyzer_size, 'battery': { 'system_capacity_kwh': storage_size_mwh * 1000, 'system_capacity_kw': storage_size_mw * 1000 } } dispatch_options = {'battery_dispatch': 'heuristic'} hybrid_plant = HybridSimulation(technologies, site, interconnect_kw=electrolyzer_size, dispatch_options=dispatch_options) hybrid_plant.wind._system_model.Turbine.wind_resource_shear = 0.33 if custom_powercurve: powercurve_file = open(scenario['Powercurve File']) powercurve_data = json.load(powercurve_file) powercurve_file.close() hybrid_plant.wind._system_model.Turbine.wind_turbine_powercurve_windspeeds = \ powercurve_data['turbine_powercurve_specification']['wind_speed_ms'] hybrid_plant.wind._system_model.Turbine.wind_turbine_powercurve_powerout = \ powercurve_data['turbine_powercurve_specification']['turbine_power_output'] hybrid_plant.pv.system_capacity_kw = solar_size_mw * 1000 return hybrid_plant
import sys from pathlib import Path sys.path.append(str(Path(__file__).parent.parent.parent.absolute())) from hybrid.sites import SiteInfo, flatirons_site from hybrid.hybrid_simulation import HybridSimulation from hybrid.dispatch.plot_tools import plot_battery_output, plot_battery_dispatch_error, plot_generation_profile from hybrid.keys import set_developer_nrel_gov_key import yaml set_developer_nrel_gov_key('') # ADD CUSTOM WIND MODULE # download FLORIS at www.github.com/NREL/FLORIS # pip install -e floris with open(Path(__file__).absolute().parent / "floris_input.yaml", 'r') as f: floris_config = yaml.load(f, yaml.SafeLoader) # properties from floris nTurbs = len(floris_config['farm']['properties']['layout_x']) solar_size_mw = 50 #20 wind_size_mw = 50 #80 battery_capacity_mwh = 200 #30 interconnection_size_mw = 50 #100 technologies = {'pv': { 'system_capacity_kw': solar_size_mw * 1000,
from hybrid.solar_source import * from hybrid.wind_source import * from hybrid.sites import SiteInfo from hybrid.reopt import REopt from hybrid.keys import set_developer_nrel_gov_key import PySAM.Singleowner as so import pytest from dotenv import load_dotenv import os filepath = os.path.dirname(os.path.abspath(__file__)) load_dotenv() NREL_API_KEY = os.getenv("NREL_API_KEY") set_developer_nrel_gov_key(NREL_API_KEY) def test_ReOPT(): lat = 39.7555 lon = -105.2211 # get resource and create model site = SiteInfo(flatirons_site) load = [1000*(sin(x) + pi)for x in range(0, 8760)] urdb_label = "5ca4d1175457a39b23b3d45e" # https://openei.org/apps/IURDB/rate/view/5ca3d45ab718b30e03405898 solar_model = SolarPlant(site, 20000)
from dotenv import load_dotenv import os import shutil from hybrid.utility_rate import UtilityRate from hybrid.keys import set_developer_nrel_gov_key path = os.path.dirname(os.path.abspath(__file__)) load_dotenv() set_developer_nrel_gov_key(os.getenv("NREL_API_KEY")) def test_urdb_response(): path_rates = os.path.join(path, 'data') os.mkdir(path_rates) # these rates sometimes mysteriously disappear from URDB fyi urdb_label = "5ca4d1175457a39b23b3d45e" # https://openei.org/apps/IURDB/rate/view/5ca4d1175457a39b23b3d45e urdb = UtilityRate(path_rates=path_rates, urdb_label=urdb_label) resp = urdb.get_urdb_response() assert ('label' in resp) shutil.rmtree(path_rates)