Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions electrolyzer/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ def calc_mass_flow_rate(self, Idc, dryer_loss=6.5):
"""
eta_F = self.calc_faradaic_efficiency(Idc)
mfr = eta_F * Idc * self.M / (self.n * F) * (1 - dryer_loss / 100.0) # [g/s]

# mfr=eta_F*(Idc/self.cell_area)*self.M/(self.n*F)*(1-dryer_loss/100.0) # [g/s]
# mfr = mfr / 1000. * 3600. # [kg/h]
mfr = mfr / 1e3 # [kg/s]
return mfr
2 changes: 1 addition & 1 deletion electrolyzer/glue_code/run_lcoh.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,6 @@ def run_lcoh(input_modeling, power_signal, lcoe, optimize=False):
lcoh_dict, lcoh = _run_lcoh_full(cost_sys)

if optimize:
return [np.sum(kg_produced), max_curr_density, lcoh]
return [np.sum(kg_produced), max_curr_density, lcoh, lcoh_dict, lcoh_options]

return lcoh_dict, lcoh
25 changes: 17 additions & 8 deletions electrolyzer/lcoh.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,17 @@ def calc_pem_capex(self):
b_capex = np.log2(1 - lr)
Sr0 = self.capex["ref_size_pem"] # ref size [kW]
Cr0 = self.capex["ref_cost_pem"] # ref cost [$/kW]
# self.plant_rating_kW
Sr = (self.stack_rating_kW / Sr0) ** b_capex # scale sized

if self.plant_rating_kW <= Sr0:
Sr = 1
else:
Sr = (self.plant_rating_kW / Sr0) ** b_capex # scale sized

adj_IF = 1 + self.IF * self.os
Cr_uninstalled = Cr0 * Sr # [$/kW]
Cr_installed = adj_IF * Cr0 * Sr # [$/kW]
capex_pem_dollars_installed = Cr_installed * self.stack_rating_kW
capex_pem_dollars_uninstalled = Cr_uninstalled * self.stack_rating_kW
capex_pem_dollars_installed = Cr_installed * self.plant_rating_kW
capex_pem_dollars_uninstalled = Cr_uninstalled * self.plant_rating_kW
self.capex_summary["PEM"] = {
"Uninstalled [$/kW]": Cr_uninstalled,
"Installed [$/kW]": Cr_installed,
Expand All @@ -164,12 +168,17 @@ def calc_bop_capex(self):
b_capex = np.log2(1 - lr)
Sr0 = self.capex["ref_size_bop"]
Cr0 = self.capex["ref_cost_bop"]
Sr = (self.stack_rating_kW / Sr0) ** b_capex # scale sized

if self.plant_rating_kW <= Sr0:
Sr = 1
else:
Sr = (self.plant_rating_kW / Sr0) ** b_capex # scale sized

adj_IF = 1 + self.IF * self.os
Cr_uninstalled = Cr0 * Sr # [$/kW]
Cr_installed = adj_IF * Cr0 * Sr # [$/kW]
capex_bop_dollars_installed = Cr_installed * self.stack_rating_kW
capex_bop_dollars_uninstalled = Cr_uninstalled * self.stack_rating_kW
capex_bop_dollars_installed = Cr_installed * self.plant_rating_kW
capex_bop_dollars_uninstalled = Cr_uninstalled * self.plant_rating_kW
self.capex_summary["BOP"] = {
"Uninstalled [$/kW]": Cr_uninstalled,
"Installed [$/kW]": Cr_installed,
Expand All @@ -187,7 +196,7 @@ def calc_total_capex(self):

# pem_capex = self.calc_pem_capex(self.plant_rating_kW)
# bop_capex = self.calc_bop_capex(self.plant_rating_kW)
sizeup_factor = self.plant_rating_kW / self.stack_rating_kW
sizeup_factor = self.plant_rating_kW / self.plant_rating_kW
pem_capex = sizeup_factor * self.calc_pem_capex()
bop_capex = sizeup_factor * self.calc_bop_capex()
total_capex = pem_capex + bop_capex
Expand Down
24 changes: 15 additions & 9 deletions tests/glue_code/test_run_lcoh.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import numpy as np
import pandas as pd
from pytest import approx
from numpy.testing import assert_array_almost_equal
from pandas.testing import assert_frame_equal

Expand All @@ -11,18 +12,23 @@

lcoh_breakdown = pd.DataFrame(
{
"Life Totals [$]": [5.388657e06, 1.079412e06, 1.1978406e07, 1.292115e06],
"Life Totals [$]": [
3644933.857141541,
1.079412e06,
1.1978406e07,
873998.0388080929,
],
"Life Totals [$/kg-H2]": [
1.3594040320184078,
0.2723048458021954,
3.021946178528131,
0.32378362036676683,
0.9355497543594925,
0.2770541303907053,
3.074512588406419,
0.22433017513212933,
],
},
index=["CapEx", "OM", "Feedstock", "Stack Rep"],
)

RESULT = (lcoh_breakdown, 5.066329157584628)
RESULT = (lcoh_breakdown, 4.511446648288746)
ROOT = Path(__file__).parent.parent.parent


Expand Down Expand Up @@ -51,7 +57,7 @@ def test_run_lcoh():
atol=1e-1,
)

assert np.isclose(calc_result[1], RESULT[1])
assert calc_result[1] == approx(RESULT[1])


def test_run_lcoh_opt():
Expand All @@ -73,9 +79,9 @@ def test_run_lcoh_opt():
lcoh_result = run_lcoh(fname_input_modeling, power_test_signal, lcoe, optimize=True)

# h2 prod, max curr density, LCOH
assert len(lcoh_result) == 3
assert len(lcoh_result) == 5

# results from regular optimize run should match
assert_array_almost_equal(h2_result, lcoh_result[:2])

assert np.isclose(lcoh_result[2], 5.0099777502488525)
assert lcoh_result[2] == approx(4.4616439830304415)