Skip to content

Commit

Permalink
Style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
paulromano committed Aug 17, 2024
1 parent 28a098c commit e8faa3e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
5 changes: 1 addition & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Added

* GCMAT plugin via the `PluginGCMAT` class ([114](https://github.com/watts-dev/watts/pull/114))

### Added

* The `Plugin.__call__` method now accepts an `output_dir` argument that
specifies the directory created in the database
([#107](https://github.com/watts-dev/watts/pull/107))
* GCMAT plugin via the `PluginGCMAT` class ([114](https://github.com/watts-dev/watts/pull/114))

### Changes

Expand Down
23 changes: 15 additions & 8 deletions doc/source/user/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -476,28 +476,35 @@ As with other plugins, :class:`~watts.PluginACCERT` is used by::
GCMat Plugin
++++++++++++

The :class:`~watts.PluginGCMat` class enables simulations with Argonne’s global critical materials agent-based model (GCMat) to simulate dynamic economic markets that are composed of agents who have complex decision-making behaviors, and interact with and influence each other, possibly indirectly through market signals.
The :class:`~watts.PluginGCMat` class enables simulations with Argonne's global
critical materials agent-based model (GCMat). This code simulates dynamic
economic markets that are composed of agents who have complex decision-making
behaviors, and interact with and influence each other, possibly indirectly
through market signals.

The GCMat plugin requires a template input file that can be templated as follows:

.. code-block:: jinja
region final demand agent final demand product reference product unit 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030
final demand U U U tonnes 111847.841748839 112977.61792812 114118.805988 115271.5212 116435.88 117612 118800 120000 121200 122412 123636.12 124872.4812 126121.206012 127382.41807212 128656.242252841 {{final_demand_2025}} {{final_demand_2026}} {{final_demand_2027}} {{final_demand_2028}} {{final_demand_2029}} {{final_demand_2030}}
region final demand agent final demand product reference product unit 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030
final demand U U U tonnes 111847.841748839 112977.61792812 114118.805988 115271.5212 116435.88 117612 118800 120000 121200 122412 123636.12 124872.4812 126121.206012 127382.41807212 128656.242252841 {{final_demand_2025}} {{final_demand_2026}} {{final_demand_2027}} {{final_demand_2028}} {{final_demand_2029}} {{final_demand_2030}}
China final demand U U shares of total 0.107142857142857 0.106698999696878 0.112674964564139 0.114434523188336 0.116194081812533 0.1278 0.1299 0.132 0.1341 0.1362 0.1383 0.1404 0.1425 0.1446 0.1467 {{china_2025}} {{china_2026}} {{china_2027}} {{china_2028}} {{china_2029}} {{china_2030}}
China final demand U U shares of total 0.107142857142857 0.106698999696878 0.112674964564139 0.114434523188336 0.116194081812533 0.1278 0.1299 0.132 0.1341 0.1362 0.1383 0.1404 0.1425 0.1446 0.1467 {{china_2025}} {{china_2026}} {{china_2027}} {{china_2028}} {{china_2029}} {{china_2030}}
US final demand U U shares of total 0.206589879692216 0.201409879668034 0.199574650237538 0.196450274218913 0.194620873740305 0.193447312012611 0.190358597294858 0.187635077997256 0.185744587021863 0.183688235605066 0.180393178767648 0.177208294866757 0.174389224194135 0.171923735369984 0.169723351626385 {{us_2025}} {{us_2026}} {{us_2027}} {{us_2028}} {{us_2029}} {{us_2030}}
US final demand U U shares of total 0.206589879692216 0.201409879668034 0.199574650237538 0.196450274218913 0.194620873740305 0.193447312012611 0.190358597294858 0.187635077997256 0.185744587021863 0.183688235605066 0.180393178767648 0.177208294866757 0.174389224194135 0.171923735369984 0.169723351626385 {{us_2025}} {{us_2026}} {{us_2027}} {{us_2028}} {{us_2029}} {{us_2030}}
Europe final demand U U shares of total 0.16491345183516 0.160710857760063 0.154355276635327 0.149054613139685 0.145906896593099 0.143775880528747 0.141896860630669 0.140266791187998 0.138026220404039 0.135574967728323 0.132758006582095 0.130102830325263 0.127653579579804 0.125407763844851 0.123338987757727 {{eu_2025}} {{eu_2026}} {{eu_2027}} {{eu_2028}} {{eu_2029}} {{eu_2030}}
Europe final demand U U shares of total 0.16491345183516 0.160710857760063 0.154355276635327 0.149054613139685 0.145906896593099 0.143775880528747 0.141896860630669 0.140266791187998 0.138026220404039 0.135574967728323 0.132758006582095 0.130102830325263 0.127653579579804 0.125407763844851 0.123338987757727 {{eu_2025}} {{eu_2026}} {{eu_2027}} {{eu_2028}} {{eu_2029}} {{eu_2030}}
ROW final demand U U shares of total 0.521353811330767 0.531180262874025 0.533394108562996 0.539080588452066 0.543278147354063 0.535073807414382 0.536243130077473 0.536734120790743 0.541204905572035 0.541712831061545 0.548846808065192 0.554835894215335 0.556026422605261 0.556024685007383 0.556929270113103 {{row_2025}} {{row_2026}} {{row_2027}} {{row_2028}} {{row_2029}} {{row_2030}}
ROW final demand U U shares of total 0.521353811330767 0.531180262874025 0.533394108562996 0.539080588452066 0.543278147354063 0.535073807414382 0.536243130077473 0.536734120790743 0.541204905572035 0.541712831061545 0.548846808065192 0.554835894215335 0.556026422605261 0.556024685007383 0.556929270113103 {{row_2025}} {{row_2026}} {{row_2027}} {{row_2028}} {{row_2029}} {{row_2030}}
The GCMat plugin can be instantiated with the following command line::

gcmat_plugin = watts.PluginGCMat('gcmat_template')

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

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

Expand Down
7 changes: 4 additions & 3 deletions src/watts/plugin_gcmat.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .parameters import Parameters
from .template import TemplateRenderer


class ResultsGCMAT(Results):
"""GCMAT simulation results
Expand Down Expand Up @@ -48,6 +49,7 @@ def _get_gcmat_csv_data(self) -> pd.DataFrame:
else:
return pd.DataFrame() # Return an empty DataFrame if no CSV file is found


class PluginGCMAT(Plugin):
"""Plugin for running GCMAT
Expand Down Expand Up @@ -77,7 +79,7 @@ def __init__(self, template_file: PathLike,
# Include './run_repast.sh' as the executable and all files in the 'data' folder as default extra inputs
self.executable = Path(self.gcmat_dir) / "run_repast.sh"
self.default_extra_inputs = list((Path(self.gcmat_dir) / "complete_model" / "data").glob("**/*"))

# Initialize output_folder attribute
self.output_folder = None

Expand All @@ -99,7 +101,6 @@ def prerun(self, params: Parameters) -> None:
target_directory.mkdir(parents=True, exist_ok=True)
shutil.copy(input_file, target_directory / "demandScenarioV2.txt")


def run(self, end_year: int = 2080, output_folder: str = "testout", **kwargs):
"""Run GCMAT
Expand Down Expand Up @@ -133,7 +134,7 @@ def postrun(self, params: Parameters, exec_info: ExecInfo) -> ResultsGCMAT:
-------
GCMAT results object
"""
output_folder = Path(self.output_folder) # Retrieve the stored
output_folder = Path(self.output_folder) # Retrieve the stored
# Only collect the GUIOutputs.csv file
# can add more files if needed
outputs = []
Expand Down

0 comments on commit e8faa3e

Please sign in to comment.