Skip to content

Commit

Permalink
Merge remote-tracking branch 'nrel/dev/refactor' into greensteel-eco-…
Browse files Browse the repository at this point in the history
…sync
  • Loading branch information
bayc committed Aug 23, 2024
2 parents 809c397 + 2169d89 commit 685a4bc
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 3 deletions.
4 changes: 2 additions & 2 deletions hopp/utilities/utils_for_tests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from hopp import ROOT_DIR
from hopp.simulation.technologies.sites import SiteInfo, flatirons_site

DEFAULT_SOLAR_RESOURCE_FILE = ROOT_DIR / "simulation" / "resource_files" / "solar" / "35.2018863_-101.945027_psmv3_60_2012.csv"
DEFAULT_WIND_RESOURCE_FILE = ROOT_DIR / "simulation" / "resource_files" / "wind" / "35.2018863_-101.945027_windtoolkit_2012_60min_80m_100m.srw"
DEFAULT_SOLAR_RESOURCE_FILE = ROOT_DIR / "simulation" / "resource_files" / "solar" / "35.2018863_-101.945027_psmv3_60_2012.csv"
DEFAULT_WIND_RESOURCE_FILE = ROOT_DIR / "simulation" / "resource_files" / "wind" / "35.2018863_-101.945027_windtoolkit_2012_60min_80m_100m.srw"

def create_default_site_info(**kwargs):
return SiteInfo(
Expand Down
152 changes: 152 additions & 0 deletions tests/greenheart/test_hydrogen/test_greenheart_system.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
from re import S
from greenheart.tools.eco.hybrid_system import run_simulation
from pytest import approx
import unittest

import os

from hopp.utilities.keys import set_nrel_key_dot_env
set_nrel_key_dot_env()

from pathlib import Path
from ORBIT.core.library import initialize_library


dirname = os.path.dirname(__file__)
orbit_library_path = os.path.join(dirname, "input_files/")

initialize_library(orbit_library_path)

class TestSimulationWind(unittest.TestCase):
def setUp(self) -> None:
return super().setUp()

@classmethod
def setUpClass(self):
super(TestSimulationWind, self).setUpClass()

turbine_model = "osw_18MW"
filename_turbine_config = os.path.join(orbit_library_path, f"turbines/{turbine_model}.yaml")
filename_orbit_config = os.path.join(orbit_library_path, f"plant/orbit-config-{turbine_model}.yaml")
filename_floris_config = os.path.join(orbit_library_path, f"floris/floris_input_{turbine_model}.yaml")
filename_greenheart_config = os.path.join(orbit_library_path, f"plant/greenheart_config.yaml")
filename_hopp_config = os.path.join(orbit_library_path, f"plant/hopp_config.yaml")

self.lcoe, self.lcoh, _ = run_simulation(filename_hopp_config, filename_greenheart_config, filename_turbine_config, filename_orbit_config, filename_floris_config, verbose=False, show_plots=False, save_plots=False, use_profast=True, post_processing=False,incentive_option=1, plant_design_scenario=1, output_level=4)

def test_lcoh(self):
assert self.lcoh == approx(7.057994298481547) # TODO base this test value on something
def test_lcoe(self):
assert self.lcoe == approx(0.10816180445700445) # TODO base this test value on something

class TestSimulationWindWave(unittest.TestCase):
def setUp(self) -> None:
return super().setUp()

@classmethod
def setUpClass(self):
super(TestSimulationWindWave, self).setUpClass()

turbine_model = "osw_18MW"
filename_turbine_config = os.path.join(orbit_library_path, f"turbines/{turbine_model}.yaml")
filename_orbit_config = os.path.join(orbit_library_path, f"plant/orbit-config-{turbine_model}.yaml")
filename_floris_config = os.path.join(orbit_library_path, f"floris/floris_input_{turbine_model}.yaml")
filename_greenheart_config = os.path.join(orbit_library_path, f"plant/greenheart_config.yaml")
filename_hopp_config = os.path.join(orbit_library_path, f"plant/hopp_config_wind_wave.yaml")

self.lcoe, self.lcoh, _ = run_simulation(filename_hopp_config, filename_greenheart_config, filename_turbine_config, filename_orbit_config, filename_floris_config, verbose=False, show_plots=False, save_plots=False, use_profast=True, post_processing=False,incentive_option=1, plant_design_scenario=1, output_level=4)

def test_lcoh(self):
assert self.lcoh == approx(8.120065296802442) #TODO base this test value on something
def test_lcoe(self):
assert self.lcoe == approx(0.12863386719193057) # prior to 20240207 value was approx(0.11051228251811765) # TODO base this test value on something

class TestSimulationWindWaveSolar(unittest.TestCase):
def setUp(self) -> None:
return super().setUp()

@classmethod
def setUpClass(self):
super(TestSimulationWindWaveSolar, self).setUpClass()

turbine_model = "osw_18MW"
filename_turbine_config = os.path.join(orbit_library_path, f"turbines/{turbine_model}.yaml")
filename_orbit_config = os.path.join(orbit_library_path, f"plant/orbit-config-{turbine_model}.yaml")
filename_floris_config = os.path.join(orbit_library_path, f"floris/floris_input_{turbine_model}.yaml")
filename_greenheart_config = os.path.join(orbit_library_path, f"plant/greenheart_config.yaml")
filename_hopp_config = os.path.join(orbit_library_path, f"plant/hopp_config_wind_wave_solar.yaml")

self.lcoe, self.lcoh, _ = run_simulation(filename_hopp_config,
filename_greenheart_config,
filename_turbine_config,
filename_orbit_config,
filename_floris_config,
verbose=False,
show_plots=False,
save_plots=False,
use_profast=True,
post_processing=False,
incentive_option=1,
plant_design_scenario=7,
output_level=4)

def test_lcoh(self):
assert self.lcoh == approx(12.583155204831298) # prior to 20240207 value was approx(10.823798551850347) #TODO base this test value on something. Currently just based on output at writing.
def test_lcoe(self):
assert self.lcoe == approx(0.1284376127848134) # prior to 20240207 value was approx(0.11035426429749774) # TODO base this test value on something. Currently just based on output at writing.

class TestSimulationWindWaveSolarBattery(unittest.TestCase):
def setUp(self) -> None:
return super().setUp()

@classmethod
def setUpClass(self):
super(TestSimulationWindWaveSolarBattery, self).setUpClass()

turbine_model = "osw_18MW"
filename_turbine_config = os.path.join(orbit_library_path, f"turbines/{turbine_model}.yaml")
filename_orbit_config = os.path.join(orbit_library_path, f"plant/orbit-config-{turbine_model}.yaml")
filename_floris_config = os.path.join(orbit_library_path, f"floris/floris_input_{turbine_model}.yaml")
filename_greenheart_config = os.path.join(orbit_library_path, f"plant/greenheart_config.yaml")
filename_hopp_config = os.path.join(orbit_library_path, f"plant/hopp_config_wind_wave_solar_battery.yaml")

self.lcoe, self.lcoh, _ = run_simulation(filename_hopp_config,
filename_greenheart_config,
filename_turbine_config,
filename_orbit_config,
filename_floris_config,
verbose=False,
show_plots=False,
save_plots=False,
use_profast=True,
post_processing=False,
incentive_option=1,
plant_design_scenario=7,
output_level=4)

def test_lcoh(self):
assert self.lcoh == approx(13.240698497098025) #TODO base this test value on something. Currently just based on output at writing.
def test_lcoe(self):
assert self.lcoe == approx(0.1401530976083388) # TODO base this test value on something. Currently just based on output at writing.

# class TestSimulationWindOnshore(unittest.TestCase):
# def setUp(self) -> None:
# return super().setUp()

# @classmethod
# def setUpClass(self):
# super(TestSimulationWind, self).setUpClass()

# turbine_model = "osw_18MW"
# filename_turbine_config = os.path.join(orbit_library_path, f"turbines/{turbine_model}.yaml")
# filename_orbit_config = os.path.join(orbit_library_path, f"plant/orbit-config-{turbine_model}.yaml")
# filename_floris_config = os.path.join(orbit_library_path, f"floris/floris_input_{turbine_model}.yaml")
# filename_greenheart_config = os.path.join(orbit_library_path, f"plant/greenheart_config.yaml")
# filename_hopp_config = os.path.join(orbit_library_path, f"plant/hopp_config.yaml")

# self.lcoe, self.lcoh, _ = run_simulation(filename_hopp_config, filename_greenheart_config, filename_turbine_config, filename_orbit_config, filename_floris_config, verbose=False, show_plots=False, save_plots=False, use_profast=True, post_processing=False,incentive_option=1, plant_design_scenario=1, output_level=4)

# def test_lcoh(self):
# assert self.lcoh == approx(7.057994298481547) # TODO base this test value on something
# def test_lcoe(self):
# assert self.lcoe == approx(0.10816180445700445) # TODO base this test value on something
4 changes: 3 additions & 1 deletion tests/greenheart/test_openmdao.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
from greenheart.simulation.greenheart_simulation import GreenHeartSimulationConfig
from hopp import ROOT_DIR

import unittest

solar_resource_file = ROOT_DIR / "simulation" / "resource_files" / "solar" / "35.2018863_-101.945027_psmv3_60_2012.csv"
wind_resource_file = ROOT_DIR / "simulation" / "resource_files" / "wind" / "35.2018863_-101.945027_windtoolkit_2012_60min_80m_100m.srw"
floris_input_filename = Path(__file__).absolute().parent / "inputs" / "floris_input.yaml"
floris_input_file = Path(__file__).absolute().parent / "inputs" / "floris_input.yaml"
hopp_config_filename = Path(__file__).absolute().parent / "inputs" / "hopp_config.yaml"
hopp_config_steel_ammonia_filename = Path(__file__).absolute().parent / "input_files" / "plant" / "hopp_config.yaml"
greenheart_config_onshore_filename = Path(__file__).absolute().parent / "input_files" / "plant" / "greenheart_config_onshore.yaml"
Expand Down

0 comments on commit 685a4bc

Please sign in to comment.