Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
RHammond2 committed Nov 1, 2024
2 parents 9b2d49a + 4d09063 commit 8f3cda7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 95 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@ jobs:
build:

runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
- uses: actions/checkout@v4
- name: Set up Miniconda Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channels: conda-forge
activate-environment: greenheart-test-${{ matrix.python-version }}
- name: Install dependencies
env:
SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL: True
Expand All @@ -29,6 +35,15 @@ jobs:
touch .env
# echo NREL_API_KEY=${{ secrets.NREL_API_KEY }} >> .env
# cat .env
- name: Save environment build details
run: |
mkdir ~/artifacts
conda env export --file ~/artifacts/environment.yml
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.python-version }}-environment
path: ~/artifacts/environment.yml
- name: Run tests
run: |
PYTHONPATH=. pytest tests
Expand Down
2 changes: 0 additions & 2 deletions greenheart/tools/eco/electrolysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@

from greenheart.simulation.technologies.hydrogen.electrolysis.PEM_BOP.PEM_BOP import pem_bop

# from electrolyzer import run_electrolyzer


def run_electrolyzer_physics(
hopp_results,
Expand Down
90 changes: 0 additions & 90 deletions greenheart/tools/optimization/openmdao.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import numpy as np
import openmdao.api as om

import electrolyzer.inputs.validation as val
from electrolyzer import run_lcoh

from shapely.geometry import Polygon, Point
from hopp.simulation import HoppInterface
from greenheart.simulation.greenheart_simulation import GreenHeartSimulationConfig, run_simulation
Expand Down Expand Up @@ -305,90 +302,3 @@ def compute(self, inputs, outputs):

def setup_partials(self):
self.declare_partials('*', '*', method='fd', form='forward')

class ElectrolyzerComponent(om.ExplicitComponent):
"""
This is an OpenMDAO wrapper to the generic electrolyzer model.
It makes some assumptions about the number of electrolyzers, stack size, and
how to distribute electricity across the different electrolyzers. These
could be later made into modeling options to allow for more user configuration.
"""
def initialize(self):
self.options.declare("h2_modeling_options")
self.options.declare("h2_opt_options")
self.options.declare("modeling_options")
self.options.declare("design_variables",
# ["electrolyzer_rating_kw"],
types=list,
desc="List of design variables that should be included",
default=[],
recordable=False)

def setup(self):
self.add_input("power_signal", val=np.zeros(8760), units="W")
self.add_input("lcoe_real", units="USD/kW/h")

if "electrolyzer_rating_kw" in self.options["design_variables"]:
self.add_input("electrolyzer_rating_kw", val=15000, units="kW")

if self.options["h2_opt_options"]["control"]["system_rating_MW"]["flag"] \
or self.options["modeling_options"]["rating_equals_turbine_rating"]:
self.add_input("system_rating_MW", units="MW", val=self.options["h2_modeling_options"]["electrolyzer"]["control"]["system_rating_MW"])
self.add_output("h2_produced", units="kg")
self.add_output("max_curr_density", units="A/cm**2")
self.add_output("electrolyzer_capex", units="USD")
self.add_output("electrolyzer_opex", units="USD")
self.add_output("lcoh", units="USD/kg")
self.add_output("h2_produced_hourly", units="kg", val=np.zeros(8760))
self.add_output("power_kW_curtailed", units="kW", val=np.zeros(8760))
self.add_output("power_kW_avail", units="kW", val=np.zeros(8760))
# self.add_output("deg_state", units="V", val=np.zeros(6)) # TODO we need a way to size this dynamically

def compute(self, inputs, outputs):
# Set electrolyzer parameters from model inputs
power_signal = inputs["power_signal"]
lcoe_real = inputs["lcoe_real"][0]

if "electrolyzer_rating_kw" in inputs:
self.options["h2_modeling_options"]["electrolyzer"]["control"]["system_rating_MW"] = inputs["electrolyzer_rating_kw"][0]*1E-3

elif self.options["h2_opt_options"]["control"]["system_rating_MW"]["flag"] \
or self.options["modeling_options"]["rating_equals_turbine_rating"]:
self.options["h2_modeling_options"]["electrolyzer"]["control"]["system_rating_MW"] = inputs["system_rating_MW"][0]

elif "electrolyzer_rating_MW" in self.options["modeling_options"]["overridden_values"]:
electrolyzer_rating_MW = self.options["modeling_options"]["overridden_values"]["electrolyzer_rating_MW"]
self.options["h2_modeling_options"]["electrolyzer"]["control"]["system_rating_MW"] = electrolyzer_rating_MW

h2_prod, max_curr_density, lcoh, lcoh_dict, lcoh_options_dict, = run_lcoh(
self.options["h2_modeling_options"],
power_signal,
lcoe_real,
optimize=True
)

lt = lcoh_dict["LCOH Breakdown"]["Life Totals [$]"]
capex = lt["CapEx"]
opex = lt["OM"]

# msg = (
# f"\n====== Electrolyzer ======\n"
# f" - h2 produced (kg): {h2_prod}\n"
# f" - max current density (A/cm^2): {max_curr_density}\n"
# f" - LCOH ($/kg): {lcoh}\n"
# )

# logger.info(msg)
outputs["h2_produced"] = h2_prod
outputs["max_curr_density"] = max_curr_density
outputs["electrolyzer_capex"] = capex
outputs["electrolyzer_opex"] = opex
outputs["lcoh"] = lcoh
outputs["h2_produced_hourly"] = lcoh_options_dict["kg_produced"]
outputs["power_kW_curtailed"] = lcoh_options_dict["power_kW_curtailed"]
outputs["power_kW_avail"] = lcoh_options_dict["power_kW_avail"]
# outputs["deg_state"] = lcoh_options_dict["deg_state"] # TODO we need a way to size this dynamically

def setup_partials(self):
self.declare_partials('lcoh', '*', method='fd', form='forward')

0 comments on commit 8f3cda7

Please sign in to comment.