Skip to content

Commit

Permalink
update examples with optimization code setup
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrunik committed Apr 29, 2024
1 parent f5827c9 commit 7bf03fe
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 52 deletions.
66 changes: 54 additions & 12 deletions examples/09-green-steel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,21 @@
"name": "stdout",
"output_type": "stream",
"text": [
"/Users/kbrunik/github/HOPP/examples/log/hybrid_systems_2024-04-29T10.29.03.572285.log\n"
"/Users/kbrunik/github/HOPP/examples/log/hybrid_systems_2024-04-29T10.42.33.514657.log\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"UserWarning: /Users/kbrunik/anaconda3/envs/gh/lib/python3.8/site-packages/fastkml/config.py:28\n",
"Package `lxml` missing. Pretty print will be disabled"
]
}
],
"source": [
"from greenheart.simulation.greenheart_simulation import (\n",
" run_simulation,\n",
" GreenHeartSimulationConfig,\n",
")"
"from greenheart.simulation.greenheart_simulation import GreenHeartSimulationConfig\n",
"from greenheart.tools.optimization.gc_run_greenheart import run_greenheart"
]
},
{
Expand Down Expand Up @@ -139,7 +145,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -195,7 +201,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand All @@ -209,9 +215,9 @@
"Hybrid Annual Energy: {\"pv\": 145446392.30989665, \"wind\": 3919162140.838302, \"battery\": 6746.053954919761, \"hybrid\": 4063634075.7827663}\n",
"Capacity factors: {\"pv\": 21.584510274299735, \"wind\": 34.52106006573001, \"battery\": 0, \"hybrid\": 31.50179294905199}\n",
"Real LCOE from HOPP: {\"pv\": null, \"wind\": 0, \"battery\": null, \"hybrid\": null}\n",
"Took 0.53 sec to run the create clusters\n",
"Took 0.019 sec to run even_split_power function\n",
"Took 0.429 sec to run the RUN function\n",
"Took 0.536 sec to run the create clusters\n",
"Took 0.02 sec to run even_split_power function\n",
"Took 0.421 sec to run the RUN function\n",
"\n",
"Electrolyzer Physics:\n",
"H2 Produced Annually (tonnes): 72333.20073625928\n",
Expand Down Expand Up @@ -295,7 +301,7 @@
"h2_storage 6.52 M\n",
"\n",
"Total Annual OPEX: $80.72 M\n",
"{'wind_and_electrical': 41275125.281676605, 'platform': 0.0, 'wave': 0.0, 'solar': array([2001.]), 'battery': 42.888, 'desal': 0.0, 'electrolyzer': 32925985.047892097, 'h2_pipe_array': 0.0, 'h2_transport_compressor': 0.0, 'h2_transport_pipeline': 0.0, 'h2_storage': 6517706.148364854}\n",
"{'wind_and_electrical': 41275150.0816766, 'platform': 0.0, 'wave': 0.0, 'solar': array([2017.2]), 'battery': 9.25, 'desal': 0.0, 'electrolyzer': 32925985.047892097, 'h2_pipe_array': 0.0, 'h2_transport_compressor': 0.0, 'h2_transport_pipeline': 0.0, 'h2_storage': 6517706.148364854}\n",
"hybrid plant capacity factor: 0.31007563496190266\n",
"\n",
"ProFAST LCOE: 70.02 $/MWh\n",
Expand Down Expand Up @@ -327,7 +333,43 @@
}
],
"source": [
"lcoe, lcoh, steel_finance, _ = run_simulation(config)"
"# for analysis\n",
"prob, config = run_greenheart(config, run_only=True)\n",
"\n",
"# for optimization\n",
"# prob, config = run_greenheart(config, run_only=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Key Output Values"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"LCOE: [70.01990098] [$/MWh]\n",
"LCOH: [5.56372339] [$/kg]\n",
"LCOS: [1046.78172868] [$/metric-tonne]\n"
]
}
],
"source": [
"lcoe = prob.get_val(\"lcoe\", units=\"USD/(MW*h)\")\n",
"lcoh = prob.get_val(\"lcoh\", units=\"USD/kg\")\n",
"lcos = prob.get_val(\"lcos\", units=\"USD/t\")\n",
"\n",
"print(\"LCOE: \", lcoe, \"[$/MWh]\")\n",
"print(\"LCOH: \", lcoh, \"[$/kg]\")\n",
"print(\"LCOS: \", lcos, \"[$/metric-tonne]\")"
]
},
{
Expand Down
102 changes: 62 additions & 40 deletions examples/10-offshore-green-hydrogen.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,16 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"/Users/kbrunik/github/HOPP/examples/log/hybrid_systems_2024-04-29T10.27.08.706358.log\n",
"ORBIT library intialized at '/Users/kbrunik/github/HOPP/examples/./inputs/10-inputs/'\n"
]
}
],
"outputs": [],
"source": [
"#general imports\n",
"import os\n",
"\n",
"# GreenHEART imports\n",
"from greenheart.simulation.greenheart_simulation import (\n",
" run_simulation,\n",
" GreenHeartSimulationConfig,\n",
")\n",
"from greenheart.simulation.greenheart_simulation import GreenHeartSimulationConfig\n",
"from greenheart.tools.optimization.gc_run_greenheart import run_greenheart\n",
"\n",
"# ORBIT imports\n",
"from ORBIT.core.library import initialize_library\n",
Expand Down Expand Up @@ -78,7 +67,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -101,7 +90,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -122,7 +111,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -146,7 +135,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -171,7 +160,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -253,7 +242,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -284,24 +273,24 @@
"Hybrid Annual Energy: {\"pv\": 1851330.6142037676, \"wind\": 3755361454.261004, \"battery\": 75138.86048135585, \"hybrid\": 3757287923.7356806}\n",
"Capacity factors: {\"pv\": 27.474084457361847, \"wind\": 43.47811662661976, \"battery\": 0, \"hybrid\": 39.46690193295024}\n",
"Real LCOE from HOPP: {\"pv\": null, \"wind\": 0, \"battery\": null, \"hybrid\": null}\n",
"Took 0.431 sec to run the create clusters\n",
"Took 0.019 sec to run even_split_power function\n",
"Took 0.372 sec to run the RUN function\n",
"Took 0.445 sec to run the create clusters\n",
"Took 0.018 sec to run even_split_power function\n",
"Took 0.4 sec to run the RUN function\n",
"\n",
"Electrolyzer Physics:\n",
"H2 Produced Annually (tonnes): 67104.72637840555\n",
"Max H2 hourly (tonnes): 16.861262913426195\n",
"Max H2 daily (tonnes): 374.8664551941889\n",
"Energy to electrolyzer (kWh): 3756152035.2829084\n",
"Energy per kg (kWh/kg): 53.03230200713463\n",
"Max hourly based on est kg/kWh (kg): 16732.02278176251\n",
"Max daily rough est (tonnes): 369.2200172815904\n",
"Electrolyzer Life Average Capacity Factor: 0.42518032786981863\n",
"H2 Produced Annually (tonnes): 67046.83636666572\n",
"Max H2 hourly (tonnes): 16.845396595785363\n",
"Max H2 daily (tonnes): 374.52842729971854\n",
"Energy to electrolyzer (kWh): 3756204506.396499\n",
"Energy per kg (kWh/kg): 53.071625889636096\n",
"Max hourly based on est kg/kWh (kg): 16732.022781762502\n",
"Max daily rough est (tonnes): 369.2200172815903\n",
"Electrolyzer Life Average Capacity Factor: 0.42873488831631185\n",
"\n",
"Hydrogen Cost Results:\n",
"Electrolyzer Total CAPEX $/kW: 1159.0975361199842\n",
"Electrolyzer O&M $/kW: 28.384469868872504\n",
"Electrolyzer O&M $/kg: 0.41706581341064214\n",
"Electrolyzer O&M $/kg: 0.4174259190642868\n",
"\n",
"\n",
"Desal Results\n",
Expand Down Expand Up @@ -386,7 +375,7 @@
"h2_storage 0.00 M\n",
"\n",
"Total Annual OPEX: $78.83 M\n",
"{'wind_and_electrical': 50842355.20761452, 'platform': 0.0, 'wave': 0.0, 'solar': array([2001.]), 'battery': 42.888, 'desal': 0.0, 'electrolyzer': 27987087.29070829, 'h2_pipe_array': 0.0, 'h2_transport_compressor': 0.0, 'h2_transport_pipeline': 0.0, 'h2_storage': 0.0}\n",
"{'wind_and_electrical': 50842355.20761452, 'platform': 0.0, 'wave': 0.0, 'solar': array([2017.2]), 'battery': 9.25, 'desal': 0.0, 'electrolyzer': 27987087.29070829, 'h2_pipe_array': 0.0, 'h2_transport_compressor': 0.0, 'h2_transport_pipeline': 0.0, 'h2_storage': 0.0}\n",
"hybrid plant capacity factor: 0.39449703413097015\n",
"\n",
"ProFAST LCOE: 147.78 $/MWh\n",
Expand All @@ -398,25 +387,58 @@
"ProFAST grid only Profit Index: 3.00\n",
"ProFAST grid only payback period: 9\n",
"\n",
"ProFAST LCOH: 7.49 $/kg\n",
"ProFAST LCOH: 7.50 $/kg\n",
"ProFAST NPV: -0.00\n",
"ProFAST IRR: 0.11000\n",
"ProFAST LCO: 7.49 $/kg\n",
"ProFAST LCO: 7.50 $/kg\n",
"ProFAST Profit Index: 2.53\n",
"ProFAST payback period: 8\n",
"Investor NPV: 2235.02 M USD\n",
"Investor NPV: 2235.11 M USD\n",
"Investor MIRR: 0.10294 \n",
"Investor ROI: 0.56617 \n",
"Investor ROI: 0.56619 \n",
"LCOE: 147.78 $/MWh\n",
"LCOH: 7.49 $/kg\n",
"LCOH: 7.5 $/kg\n",
"hybrid electricity plant capacity factor: 0.39\n",
"electrolyzer capacity factor: 0.43\n",
"Electorlyzer CAPEX installed $/kW: 1159.1\n"
]
}
],
"source": [
"lcoe, lcoh, _, _ = run_simulation(config)"
"# for analysis\n",
"prob, config = run_greenheart(config, run_only=True)\n",
"\n",
"# for optimization\n",
"# prob, config = run_greenheart(config, run_only=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Key Output Values"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"LCOE: [147.7791448] [$/MWh]\n",
"LCOH: [7.50007302] [$/kg]\n"
]
}
],
"source": [
"lcoe = prob.get_val(\"lcoe\", units=\"USD/(MW*h)\")\n",
"lcoh = prob.get_val(\"lcoh\", units=\"USD/kg\")\n",
"\n",
"print(\"LCOE: \", lcoe, \"[$/MWh]\")\n",
"print(\"LCOH: \", lcoh, \"[$/kg]\")"
]
},
{
Expand Down

0 comments on commit 7bf03fe

Please sign in to comment.