Skip to content

Commit ecfc6c9

Browse files
authored
Merge pull request #119 from JiaZhou-PU/aleafplugin
A-LEAF plugin
2 parents 5813b98 + f1b8178 commit ecfc6c9

File tree

10 files changed

+332
-17
lines changed

10 files changed

+332
-17
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1616
([#107](https://github.com/watts-dev/watts/pull/107))
1717
* GCMAT plugin via the `PluginGCMAT` class
1818
([#114](https://github.com/watts-dev/watts/pull/114))
19+
* A-LEAF plugin via the `PluginALEAF` class
20+
([#119](https://github.com/watts-dev/watts/pull/119))
1921

2022
### Changes
2123

doc/source/conf.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,15 @@
7878

7979
html_theme_options = {
8080
"github_url": "https://github.com/watts-dev/watts",
81-
"favicons": [
82-
{
83-
"rel": "icon",
84-
"sizes": "16x16",
85-
"href": "watts_16x16.png",
86-
},
87-
{
88-
"rel": "icon",
89-
"sizes": "32x32",
90-
"href": "watts_32x32.png",
91-
},
92-
],
9381
"switcher": {
9482
"json_url": "https://watts.readthedocs.io/en/latest/_static/switcher.json",
9583
"version_match": version if '-dev' not in version else 'dev',
9684
},
9785
"navbar_end": ["version-switcher", "navbar-icon-links"],
9886
"show_toc_level": 3,
9987
}
88+
89+
favicons = [
90+
"watts_16x16.png",
91+
"watts_32x32.png",
92+
]

doc/source/reference/index.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ API Reference
1414
watts.PluginGeneric
1515
watts.PluginABCE
1616
watts.PluginACCERT
17-
watts.PluginGCMat
17+
watts.PluginALEAF
18+
watts.PluginGCMAT
1819
watts.PluginMCNP
1920
watts.PluginMOOSE
2021
watts.PluginOpenMC
@@ -23,6 +24,10 @@ API Reference
2324
watts.PluginSAS
2425
watts.PluginSerpent
2526
watts.Results
27+
watts.ResultsABCE
28+
watts.ResultsACCERT
29+
watts.ResultsALEAF
30+
watts.ResultsGCMAT
2631
watts.ResultsMCNP
2732
watts.ResultsMOOSE
2833
watts.ResultsOpenMC

doc/source/user/plugins.rst

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,46 @@ As with other plugins, :class:`~watts.PluginABCE` is easily used by::
335335
.. note::
336336
`ABCE` is still under active development.
337337

338+
A-LEAF Plugin
339+
+++++++++++++
340+
The :class:`~watts.PluginALEAF` class enables simulations with the Argonne
341+
Low-carbon Electricity Analysis Framework (A-LEAF) code using a text-based input
342+
file for fuel price modification. The A-LEAF code uses an Excel-based input
343+
file, and the A-LEAF plugin will only modify the fuel price under the ``Fuel``
344+
section of the input file. Since the A-LEAF code is still under active
345+
development, the plugin will be updated as the code is updated.
346+
347+
The A-LEAF fuel price input file can be templated as follows:
348+
349+
.. code-block:: jinja
350+
351+
Scenario FUEL Type Unit 2022 2023 2024 2025 2026 ...
352+
353+
Reference Coal Real 2022 $/MMBtu 1.64 1.61 1.65 1.57 1.52 ...
354+
...
355+
Base Nuclear Real 2020 $/MMBTU {% for year, price in fuel_price.items() %}
356+
{{ price }}{% if not loop.last %} {% endif %}{% endfor %}
357+
Base Biomass Real 2020 $/MMBTU 5.00 5.11 5.22 5.34 5.45 ...
358+
...
359+
Low OGS Real 2020 $/MMBTU 3.30 3.00 2.73 2.58 2.56 ...
360+
361+
Before running the A-LEAF plugin, you need to specify the directory that the
362+
executable and the license key are in (they must be in the same directory). This
363+
can be done by adding the ``ALEAF_DIR`` variable to the environment or by
364+
explicitly specifying the path in the Python script as::
365+
366+
aleaf_plugin = watts.PluginALEAF(
367+
'aleaf_template',
368+
executable="/path/to/A-LEAF",
369+
extra_inputs=[]
370+
)
371+
372+
As with other plugins, :class:`~watts.PluginALEAF` can be used by calling the
373+
:meth:`~watts.PluginALEAF` instance directly the same way as other plugins::
374+
375+
aleaf_plugin = watts.PluginALEAF('aleaf_template')
376+
aleaf_result = aleaf_plugin(params)
377+
338378

339379
Dakota Plugin
340380
+++++++++++++
@@ -476,7 +516,7 @@ As with other plugins, :class:`~watts.PluginACCERT` is used by::
476516
GCMat Plugin
477517
++++++++++++
478518

479-
The :class:`~watts.PluginGCMat` class enables simulations with Argonne's global
519+
The :class:`~watts.PluginGCMAT` class enables simulations with Argonne's global
480520
critical materials agent-based model (GCMat). This code simulates dynamic
481521
economic markets that are composed of agents who have complex decision-making
482522
behaviors, and interact with and influence each other, possibly indirectly
@@ -500,15 +540,15 @@ The GCMat plugin requires a template input file that can be templated as follows
500540
501541
The GCMat plugin can be instantiated with the following command line::
502542

503-
gcmat_plugin = watts.PluginGCMat('gcmat_template')
543+
gcmat_plugin = watts.PluginGCMAT('gcmat_template')
504544

505545
Before running the GCMat plugin, the directory that contains the executable
506546
'run_repast.sh' must be set. This can be done by setting the ``GCMAT_DIR``
507547
environment variable::
508548

509549
export GCMAT_DIR='/path/to/gcmat/output'
510550

511-
As with other plugins, :class:`~watts.PluginGCMat` is used by::
551+
As with other plugins, :class:`~watts.PluginGCMAT` is used by::
512552

513-
gcmat_plugin = watts.PluginGCMat('gcmat_template')
553+
gcmat_plugin = watts.PluginGCMAT('gcmat_template')
514554
gcmat_result = gcmat_plugin(params)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Scenario FUEL Type Unit 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060
2+
Reference Coal Real 2021 $/MMBtu 1.64 1.61 1.65 1.57 1.52 1.50 1.49 1.50 1.50 1.50 1.50 1.50 1.51 1.52 1.53 1.54 1.56 1.56 1.58 1.59 1.60 1.60 1.62 1.63 1.64 1.65 1.65 1.66 1.66 1.75 1.85 1.96 2.07 2.19 2.31 2.44 2.58 2.73 2.89
3+
Reference NG Real 2021 $/MMBtu 3.84 3.49 3.17 3.00 2.98 3.08 3.25 3.36 3.46 3.54 3.58 3.65 3.64 3.64 3.65 3.67 3.68 3.69 3.72 3.73 3.70 3.71 3.65 3.61 3.60 3.60 3.62 3.60 3.59 3.80 4.01 4.24 4.48 4.74 5.01 5.29 5.59 5.91 6.25
4+
Reference Petroleum Real 2021 $/MMBtu 12.18 10.50 11.39 11.61 11.89 12.20 12.46 12.58 12.82 13.08 13.27 13.42 13.54 13.67 13.86 14.03 14.20 14.26 14.55 14.70 14.75 15.00 15.28 15.36 15.58 15.65 15.62 15.65 15.59 16.48 17.42 18.41 19.46 20.57 21.74 22.98 24.29 25.68 27.14
5+
Reference Nuclear Real 2021 $/MMBtu 0.72 0.72 0.72 0.72 0.72 0.73 0.73 0.73 0.73 0.73 0.73 0.74 0.74 0.74 0.74 0.74 0.74 0.75 0.75 0.75 0.75 0.76 0.76 0.76 0.76 0.76 0.77 0.77 0.77 0.81 0.86 0.91 0.96 1.02 1.07 1.14 1.20 1.27 1.34
6+
Reference Biomass Real 2020 $/MMBTU 5.00 5.11 5.22 5.34 5.45 5.57 5.70 5.82 5.95 6.08 6.22 6.35 6.49 6.63 6.78 6.93 7.08 7.24 7.40 7.56 7.73 7.90 8.07 8.25 8.43 8.61 8.80 9.00 9.20 9.72 10.27 10.86 11.48 12.13 12.82 13.56 14.33 15.15 16.01
7+
Reference OGS Real 2020 $/MMBTU 3.84 3.49 3.17 3.00 2.98 3.08 3.25 3.36 3.46 3.54 3.58 3.65 3.64 3.64 3.65 3.67 3.68 3.69 3.72 3.73 3.70 3.71 3.65 3.61 3.60 3.60 3.62 3.60 3.59 3.80 4.01 4.24 4.48 4.74 5.01 5.29 5.59 5.91 6.25
8+
Base Coal Real 2020 $/MMBTU 1.57 1.54 1.57 1.50 1.45 1.43 1.43 1.43 1.43 1.44 1.43 1.43 1.44 1.45 1.46 1.47 1.49 1.49 1.51 1.52 1.52 1.53 1.54 1.56 1.56 1.57 1.57 1.58 1.58 1.67 1.77 1.87 1.98 2.09 2.21 2.33 2.47 2.61 2.76
9+
Base NG Real 2020 $/MMBTU 3.67 3.34 3.03 2.87 2.84 2.94 3.10 3.21 3.30 3.38 3.42 3.48 3.48 3.47 3.48 3.50 3.52 3.52 3.55 3.56 3.54 3.54 3.48 3.45 3.44 3.43 3.46 3.44 3.43 3.62 3.83 4.05 4.28 4.52 4.78 5.05 5.34 5.65 5.97
10+
Base Petroleum Real 2020 $/MMBTU 11.63 10.03 10.88 11.09 11.35 11.65 11.90 12.01 12.24 12.49 12.68 12.82 12.93 13.05 13.24 13.40 13.56 13.61 13.90 14.04 14.09 14.32 14.60 14.67 14.88 14.95 14.92 14.94 14.89 15.74 16.63 17.58 18.58 19.64 20.76 21.95 23.20 24.52 25.92
11+
Base Nuclear Real 2020 $/MMBTU {% for year, price in fuel_price.items() %}{{ price }}{% if not loop.last %} {% endif %}{% endfor %}
12+
Base Biomass Real 2020 $/MMBTU 5.00 5.11 5.22 5.34 5.45 5.57 5.70 5.82 5.95 6.08 6.22 6.35 6.49 6.63 6.78 6.93 7.08 7.24 7.40 7.56 7.73 7.90 8.07 8.25 8.43 8.61 8.80 9.00 9.20 9.72 10.27 10.86 11.48 12.13 12.82 13.56 14.33 15.15 16.01
13+
Base OGS Real 2020 $/MMBTU 3.67 3.34 3.03 2.87 2.84 2.94 3.10 3.21 3.30 3.38 3.42 3.48 3.48 3.47 3.48 3.50 3.52 3.52 3.55 3.56 3.54 3.54 3.48 3.45 3.44 3.43 3.46 3.44 3.43 3.62 3.83 4.05 4.28 4.52 4.78 5.05 5.34 5.65 5.97
14+
Low Coal Real 2020 $/MMBTU 1.41 1.38 1.42 1.35 1.31 1.29 1.28 1.29 1.29 1.29 1.29 1.29 1.30 1.30 1.32 1.33 1.34 1.34 1.36 1.37 1.37 1.38 1.39 1.40 1.41 1.42 1.41 1.42 1.43 1.51 1.59 1.68 1.78 1.88 1.99 2.10 2.22 2.35 2.48
15+
Low NG Real 2020 $/MMBTU 3.30 3.00 2.73 2.58 2.56 2.64 2.79 2.89 2.97 3.05 3.07 3.13 3.13 3.13 3.14 3.15 3.17 3.17 3.20 3.20 3.18 3.19 3.13 3.11 3.10 3.09 3.11 3.09 3.09 3.26 3.45 3.64 3.85 4.07 4.30 4.55 4.81 5.08 5.37
16+
Low Petroleum Real 2020 $/MMBTU 10.46 9.03 9.79 9.98 10.22 10.48 10.71 10.81 11.02 11.24 11.41 11.53 11.64 11.75 11.91 12.06 12.21 12.25 12.51 12.63 12.68 12.89 13.14 13.21 13.39 13.45 13.43 13.45 13.40 14.16 14.97 15.82 16.73 17.68 18.69 19.75 20.88 22.07 23.33
17+
Low Nuclear Real 2020 $/MMBTU 0.62 0.62 0.62 0.62 0.62 0.62 0.62 0.63 0.63 0.63 0.63 0.63 0.63 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 1.03 1.09 1.15
18+
Low Biomass Real 2020 $/MMBTU 4.50 4.60 4.70 4.80 4.91 5.02 5.13 5.24 5.36 5.47 5.59 5.72 5.84 5.97 6.10 6.24 6.37 6.51 6.66 6.80 6.95 7.11 7.26 7.42 7.59 7.75 7.92 8.10 8.28 8.75 9.25 9.77 10.33 10.92 11.54 12.20 12.90 13.63 14.41
19+
Low OGS Real 2020 $/MMBTU 3.30 3.00 2.73 2.58 2.56 2.64 2.79 2.89 2.97 3.05 3.07 3.13 3.13 3.13 3.14 3.15 3.17 3.17 3.20 3.20 3.18 3.19 3.13 3.11 3.10 3.09 3.11 3.09 3.09 3.26 3.45 3.64 3.85 4.07 4.30 4.55 4.81 5.08 5.37
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# 1App_ALEAF_LCGTEP
2+
3+
## Purpose
4+
5+
This example provides a demonstration for using WATTS to run and analyze simulations with A-LEAF (Argonne Low-carbon Electricity Analysis Framework) under various supply chain disruption scenarios. The example explores different fuel price settings to understand the impact on US nuclear capacity expansion result.
6+
7+
8+
## Code(s)
9+
10+
- A-LEAF
11+
12+
## Keywords
13+
14+
- Energy Market
15+
- Capacity Expansion
16+
- Economic Modeling
17+
18+
## File descriptions
19+
20+
- [__watts_exec.py__](watts_exec.py): WATTS workflow for this example. This is the file to execute to run the problem described above.
21+
- [__A-LEAF_fuel_template__](Fuel.txt): Fuel price for this example
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# SPDX-FileCopyrightText: 2022-2025 UChicago Argonne, LLC
2+
# SPDX-License-Identifier: MIT
3+
4+
"""
5+
This example demonstrates how to use WATTS to run an A-LEAF calculation.
6+
"""
7+
8+
import watts
9+
from pathlib import Path
10+
import pandas as pd
11+
12+
params = watts.Parameters()
13+
14+
15+
fuel_price = {
16+
2022: 0.62, 2023: 0.62, 2024: 0.62, 2025: 0.62, 2026: 0.62, 2027: 0.62,
17+
2028: 0.63, 2029: 0.63, 2030: 0.63, 2031: 0.76, 2032: 0.76, 2033: 0.76,
18+
2034: 0.76, 2035: 0.76, 2036: 0.77, 2037: 0.77, 2038: 0.77, 2039: 0.77,
19+
2040: 0.77, 2041: 0.78, 2042: 0.78, 2043: 0.78, 2044: 0.78, 2045: 0.78,
20+
2046: 0.79, 2047: 0.79, 2048: 0.79, 2049: 0.79, 2050: 0.79, 2051: 0.80,
21+
2052: 0.80, 2053: 0.80, 2054: 0.80, 2055: 0.80, 2056: 0.81, 2057: 0.81,
22+
2058: 0.81, 2059: 0.81, 2060: 0.81
23+
}
24+
25+
26+
# Set nuclear prices from reference and calculated growth
27+
starting_year = 2031
28+
starting_price = 0.76
29+
30+
# Compute prices dynamically for years after the starting year
31+
growth_rates = {year: 1.0028 if year <= 2050 else 1.057 for year in range(starting_year + 1, 2061)}
32+
computed_prices = {starting_year: starting_price}
33+
for year in range(starting_year + 1, 2061):
34+
prev_price = computed_prices[year - 1]
35+
computed_prices[year] = round(prev_price * growth_rates[year], 3)
36+
37+
fuel_price.update(computed_prices)
38+
39+
# Initialize parameters and pass the fuel price dictionary
40+
params = watts.Parameters()
41+
params['fuel_price'] = fuel_price
42+
# Display parameter summary
43+
params.show_summary(show_metadata=True, sort_by='key')
44+
45+
# Set default path for results
46+
results_path = Path.cwd() / 'results'
47+
results_path.mkdir(exist_ok=True, parents=True)
48+
watts.Database.set_default_path(results_path)
49+
50+
# Create ALEAF plugin
51+
# aleaf_plugin = watts.PluginALEAF('Fuel.txt', extra_templates={'Simulation Configuration': 'Simulation Configuration.txt'})
52+
aleaf_plugin = watts.PluginALEAF('Fuel.txt')
53+
# Run ALEAF
54+
aleaf_result = aleaf_plugin(params)
55+
print('ALEAF simulation completed.')
56+
57+
# Get the technology summary
58+
techsummary = aleaf_result.csv_data
59+
# keep only the capacity columns
60+
techsummary = techsummary[['Year', 'UnitGroup', 'Unit_Type', 'Fuel', 'ICAP', 'ICap_New', 'ICap_Ret']]
61+
62+
# group the technology summary by year and fuel
63+
grouped_df = techsummary.groupby(['Year','Fuel']).sum()
64+
# print out the grouped dataframe
65+
print(grouped_df)
66+
67+

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ docs = [
4949
"pydata_sphinx_theme",
5050
"sphinx_design",
5151
"sphinx-autodoc-typehints",
52+
"sphinx-favicon",
5253
]
5354

5455
[project.urls]

src/watts/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# SPDX-License-Identifier: MIT
33

44
from .plugin import *
5+
from .plugin_aleaf import *
56
from .plugin_accert import *
67
from .plugin_openmc import *
78
from .plugin_moose import *

0 commit comments

Comments
 (0)