Skip to content

Commit

Permalink
merge dev/refactor into feature/profast-fin-model
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredthomas68 committed Oct 2, 2024
2 parents f729937 + c94c1b6 commit 8db9a9e
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 11 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
11 changes: 6 additions & 5 deletions tests/greenheart/hopp_tools_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import matplotlib.pyplot as plt
import yaml
import re
from yamlinclude import YamlIncludeConstructor
YamlIncludeConstructor.add_to_loader_class(loader_class=yaml.FullLoader, base_dir='/your/conf/dir')

# from yamlinclude import YamlIncludeConstructor
# YamlIncludeConstructor.add_to_loader_class(loader_class=yaml.FullLoader, base_dir='/your/conf/dir')

# HOPP functionss
from hopp.utilities import load_yaml
from greenheart.to_organize.H2_Analysis.hopp_for_h2 import hopp_for_h2
from hopp.simulation.technologies.sites import SiteInfo
from greenheart.to_organize.H2_Analysis.simple_dispatch import SimpleDispatch
Expand Down Expand Up @@ -88,8 +88,9 @@ def set_turbine_model(turbine_model, scenario, parent_path, floris_dir):
################################

turbine_file = floris_dir + 'floris_input' + turbine_model + '_' + site_number + '.yaml'
with open(turbine_file, 'r') as f:
floris_config = yaml.load(f, yaml.FullLoader)
floris_config = load_yaml(turbine_file)
# with open(turbine_file, 'r') as f:
# floris_config = yaml.load(f, yaml.FullLoader)
# floris_config = yaml.load(f, yaml.SafeLoader)
nTurbs = len(floris_config['farm']['layout_x'])
# turbine_type = floris_config['farm']['turbine_type'][0]
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
10 changes: 6 additions & 4 deletions tests/greenheart/test_openmdao.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
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 Expand Up @@ -60,8 +63,7 @@ def setup_hopp():
hybrid_config_dict["site"]["solar"] = "true"

hybrid_config_dict["site"]["wind_resource_file"] = wind_resource_file
hybrid_config_dict["technologies"]["wind"]["floris_config"] = floris_input_filename

hybrid_config_dict["technologies"]["wind"]["floris_config"] = floris_input_file

hybrid_config_dict["site"]["desired_schedule"] = [80000.0]*8760
hybrid_config_dict["technologies"]["battery"] = {"system_capacity_kwh": 400,
Expand Down Expand Up @@ -243,7 +245,7 @@ def test_boundary_distance_component(subtests):

config_dict = load_yaml(hopp_config_filename)
config_dict["site"]["wind_resource_file"] = wind_resource_file
config_dict["technologies"]["wind"]["floris_config"] = floris_input_filename
config_dict["technologies"]["wind"]["floris_config"] = floris_input_file
hi = HoppInterface(config_dict)

model = om.Group()
Expand Down

0 comments on commit 8db9a9e

Please sign in to comment.