Skip to content

Commit a7367bb

Browse files
authored
Merge branch 'develop' into demand_path
2 parents 0fe1bdd + 0d54942 commit a7367bb

648 files changed

Lines changed: 29942 additions & 28385 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.vscode/launch.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
"module": "muse",
1212
"args": ["--model", "default"]
1313
},
14+
{
15+
"name": "Model: default_retro",
16+
"type": "debugpy",
17+
"request": "launch",
18+
"module": "muse",
19+
"args": ["--model", "default_retro"]
20+
},
1421
{
1522
"name": "Model: multiple_agents",
1623
"type": "debugpy",

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ authors:
88
- family-names: Hawkes
99
given-names: Adam
1010

11-
title: SGIModel/MUSE_OS
11+
title: MUSE_OS
1212
version: v1.0.1
1313
date-released: 2022-03-25

docs/advanced-guide/extending-muse.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
"cell_type": "markdown",
170170
"metadata": {},
171171
"source": [
172-
"Next, we first copy the default model provided with muse to a local subfolder called \"model\". Then we read the `settings.toml` file and modify it using python. You may prefer to modify the `settings.toml` file using your favorite text editor. However, modifying the file programmatically allows us to\n",
172+
"Next, we first copy the `default_retro` model provided with muse to a local subfolder called \"model\". Then we read the `settings.toml` file and modify it using python. You may prefer to modify the `settings.toml` file using your favorite text editor. However, modifying the file programmatically allows us to\n",
173173
"routinely run this notebook as part of MUSE's test suite and check that the tutorial it is still up\n",
174174
"to date."
175175
]
@@ -185,7 +185,7 @@
185185
"from muse import examples\n",
186186
"from toml import dump, load\n",
187187
"\n",
188-
"model_path = examples.copy_model(overwrite=True)\n",
188+
"model_path = examples.copy_model(name=\"default_retro\", overwrite=True)\n",
189189
"settings = load(model_path / \"settings.toml\")\n",
190190
"new_output = {\n",
191191
" \"quantity\": \"consumption_zero\",\n",
@@ -204,7 +204,7 @@
204204
"source": [
205205
"We can now run the simulation. There are two ways to do this. From the command-line, where we can do:\n",
206206
"\n",
207-
" python3 -m muse data/commercial/modified_settings.toml \n",
207+
" python3 -m muse model/modified_settings.toml \n",
208208
"\n",
209209
"(note that slashes may be the other way on Windows). Or directly from the notebook:"
210210
]
@@ -366,7 +366,7 @@
366366
"from muse import examples\n",
367367
"from toml import dump, load\n",
368368
"\n",
369-
"model_path = examples.copy_model(overwrite=True)\n",
369+
"model_path = examples.copy_model(name=\"default_retro\", overwrite=True)\n",
370370
"settings = load(model_path / \"settings.toml\")\n",
371371
"new_output = {\n",
372372
" \"quantity\": \"capacity\",\n",
@@ -509,7 +509,7 @@
509509
"from muse import examples\n",
510510
"from toml import dump, load\n",
511511
"\n",
512-
"model_path = examples.copy_model(overwrite=True)\n",
512+
"model_path = examples.copy_model(name=\"default_retro\", overwrite=True)\n",
513513
"settings = load(model_path / \"settings.toml\")\n",
514514
"settings[\"sectors\"][\"residential\"][\"outputs\"] = [\n",
515515
" {\n",

docs/advanced-guide/further-extending-muse.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@
217217
"name": "python",
218218
"nbconvert_exporter": "python",
219219
"pygments_lexer": "ipython3",
220-
"version": "3.9.18"
220+
"version": "3.12.3"
221221
},
222222
"vscode": {
223223
"interpreter": {

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# -- Project information -----------------------------------------------------
77

88
project = "MUSE"
9-
copyright = "2022, Sustainable Gas Institute"
9+
copyright = "2024, Imperial College London"
1010
author = "Imperial College London"
1111
release = "1.1.0"
1212
version = ".".join(release.split(".")[:2])

docs/example-output.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"name": "python",
3434
"nbconvert_exporter": "python",
3535
"pygments_lexer": "ipython3",
36-
"version": "3.9.18"
36+
"version": "3.12.3"
3737
}
3838
},
3939
"nbformat": 4,

docs/inputs/toml.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ a whole.
7070
whether equilibrium of `demand` or `prices` should be sought. Defaults to `demand`.
7171

7272
*maximum_iterations*
73-
Maximum number of iterations when searching for equilibrium. Defaults to 3.
73+
Maximum number of iterations when searching for equilibrium. Defaults to 100.
7474

7575
*tolerance*
7676
Tolerance criteria when checking for equilibrium. Defaults to 0.1. 0.1 signifies that 10% of a deviation is allowed among the iterative value of either demand or price over a year per region.
@@ -544,6 +544,10 @@ to define the timeslice simply by referring to the slices it will use at each le
544544
how much the capacity can grow during each investment event.
545545
- :py:func:`~muse.constraints.search_space`: a binary (on-off) constraint
546546
specifying which technologies are considered for investment.
547+
- :py:func:`~muse.constraints.minimum_service`: a lower constraint for
548+
production for those technologies that need to keep a minimum production.
549+
- :py:func:`~muse.constraints.demand_limiting_capacity`: limits the combined
550+
capacity to be installed to the demand of the peak timeslice.
547551

548552

549553
*output*
@@ -668,15 +672,15 @@ The following attributes are accepted:
668672
The CSV format should follow the following format:
669673

670674
.. csv-table:: Consumption
671-
:header: " ", "RegionName", "ProcessName", "TimeSlice", "electricity", "diesel", "algae"
675+
:header: " ", "RegionName", "ProcessName", "Timeslice", "electricity", "diesel", "algae"
672676
:stub-columns: 4
673677

674678
0,USA,fluorescent light,1,1.9, 0, 0
675679
1,USA,fluorescent light,2,1.8, 0, 0
676680

677681

678-
The index column as well as "RegionName", "ProcessName", and "TimeSlice" must be
679-
present. Further columns are reserved for commodities. "TimeSlice" refers to the
682+
The index column as well as "RegionName", "ProcessName", and "Timeslice" must be
683+
present. Further columns are reserved for commodities. "Timeslice" refers to the
680684
index of the timeslice. Timeslices should be defined consistently to the sectoral
681685
level timeslices.
682686
The column "ProcessName" needs to be present and filled in, in order for the data

docs/installation/pipx-based.rst

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ In the following sections, we will guide you step by step in configuring your sy
1717
The next sections will explain in detail the appropriate steps as well as commenting on possible caveats. **We strongly encourage you to read through the sections below** to understand what these steps entitle, but in the end, what we are going to do to install MUSE is the following:
1818

1919
- Open a terminal
20-
- Install `pyenv <https://github.com/pyenv/pyenv>`_ (Linux and MacOS) or `pyenv-win <https://pyenv-win.github.io/pyenv-win/>`_ (Windows) and make sure it works.
20+
- Install `pyenv <https://github.com/pyenv/pyenv>`_ (Linux and MacOS) or `pyenv-win <https://pyenv-win.github.io/pyenv-win/>`_ (Windows) and make sure it works by invoking `pyenv --version` in the terminal.
2121
- Run the following commands in the terminal:
2222

2323
.. code-block::
@@ -28,14 +28,14 @@ In the following sections, we will guide you step by step in configuring your sy
2828
python -m pipx ensurepath
2929
python -m pipx install muse-os
3030
31-
- After this, MUSE will be available to use system wide simply by invoking ``muse`` in the terminal, for example ``muse --model default``.
31+
- After this, MUSE will be available to use system wide simply by invoking muse in the terminal. To illustrate this and to test your installation, run muse --model default. You should then see a a list of outputs printed to the terminal showing the computations going on in the background.
3232

3333
.. _launch-terminal:
3434

3535
Launching a terminal
3636
~~~~~~~~~~~~~~~~~~~~
3737

38-
All operating systems have a Terminal application that let you run commands. You will need to use it extensively when using MUSE, so we strongly suggest you get familiar with it. For now, let's just figure out how to launch it:
38+
All operating systems have a Terminal application that let you run commands. You will need to use it extensively when using MUSE, so we strongly suggest you get familiar with it. For now, let's just figure out how to launch one:
3939

4040
- **Linux**: Depending on the distribution, you might have a shortcut in your tasks bar already or it should be easily found in the menu. Look for ``Console`` or ``Terminal`` to lunch the application.
4141
- **MacOS**: Press ``Super key + Space`` to open the search box. There, type ``Terminal`` and press ``Enter``.
@@ -107,13 +107,43 @@ Installing ``pyenv``
107107

108108
To install ``pyenv``, follow these steps:
109109

110-
- **Linux**: In this case, you will need to clone the GitHub repository using ``git``. Most Linux distributions come with ``git`` installed, so this should work out of the box:
110+
- **Linux**: In this case, you will need to clone the GitHub repository using ``git``. Most Linux distributions come with ``git`` installed, so this should work out of the box.
111+
Then, complete the setup by adding ``pyenv`` to your profile, so the executable can be found. You can `check the instructions in the official webpage <https://github.com/pyenv/pyenv#set-up-your-shell-environment-for-pyenv>`_,
112+
or follow the below commands that were tested on `Ubuntu 22.04 LTS` using its popular `bash shell` and `z-shell`. To be specific, we tested them
113+
on `GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)` and `zsh 5.8.1 (x86_64-ubuntu-linux-gnu)`.
111114

112-
.. code-block:: bash
115+
Now, we go through the installation procedure of ``pyenv`` on Linux, step-by-step:
113116

114-
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
117+
.. code-block::
118+
119+
# Step 1: Install essential libraries needed for pyenv
120+
sudo apt install -y make build-essential libssl-dev zlib1g-dev \
121+
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
122+
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl \
123+
git
124+
125+
126+
# Step 2: Clone the `pyenv` repository for Linux
127+
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
128+
129+
130+
# Step 3: Run one code block in this step only, depending on what shell you use:
131+
132+
# If you are on the bash shell run the following:
133+
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
134+
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
135+
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc
136+
source ~/.bashrc
137+
138+
# If you are on the z-shell, run the following:
139+
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
140+
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
141+
echo 'eval "$(pyenv init --path)"' >> ~/.zshrc
142+
source ~/.zshrc
143+
144+
# Step 4: Confirm successful installation of `pyenv` upon invoking the following command in the terminal. You should be returned something similar to `pyenv 2.4.1-10-g2e0bb023`
145+
pyenv --version
115146
116-
Then, complete the setup by adding ``pyenv`` to your profile, so the executable can be found. `Check the instructions in the official webpage <https://github.com/pyenv/pyenv#set-up-your-shell-environment-for-pyenv>`_.
117147
118148
- **MacOS**: The simplest option is to use Homebrew:
119149

@@ -124,12 +154,20 @@ To install ``pyenv``, follow these steps:
124154
125155
Then, complete the setup by adding ``pyenv`` to your profile, so the executable can be found. `Check the instructions in the official webpage <https://github.com/pyenv/pyenv#set-up-your-shell-environment-for-pyenv>`_.
126156

127-
- **Windows**: ``pyenv-win`` is a separate project but it has the same functionality and it is also simpler to setup. Just run the following command and you should be ready to go:
157+
- **Windows**: ``pyenv-win`` is a separate project but it has the same functionality and it is also simpler to setup.
158+
You can read the detailed installation instructions `from the official pyenv-win website <https://github.com/pyenv-win/pyenv-win/tree/master>`_,
159+
but the easiest way is to run the following command in the ``powershell`` and, upon closing and launching a new shell, you should be ready to go:
128160

129161
.. code-block:: powershell
130162
163+
# Step 1: In your powershell, invoke the following command:
131164
Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/pyenv-win/pyenv-win/master/pyenv-win/install-pyenv-win.ps1" -OutFile "./install-pyenv-win.ps1"; &"./install-pyenv-win.ps1"
132165
166+
# Step 2: close the shell you invoked in the command from Step 1 and re-launch powershell
167+
168+
# Step 3: Confirm success; you should be returned something similar to `pyenv 3.1.1`
169+
pyenv --version
170+
133171
.. note::
134172

135173
If you are getting any ``UnauthorizedAccess`` error, then start Windows PowerShell with the “Run as administrator” option (see figure above) and run:
@@ -140,19 +178,8 @@ To install ``pyenv``, follow these steps:
140178
141179
Finally open a normal PowerShell and re-run the above installation command.
142180

143-
After completing the above steps, you will need to close the terminal and re-open it again. After that, to check if things work run:
144-
145-
.. code-block:: bash
146-
147-
pyenv --version
148-
149-
You should get something similar to:
150-
151-
.. code-block:: output
152-
153-
pyenv 3.1.1
154181

155-
Actually installing Python
182+
Installing your chosen Python version
156183
^^^^^^^^^^^^^^^^^^^^^^^^^^
157184

158185
With ``pyenv`` installed and correctly configured, it is now easy to install any Python version we want. To see the versions available run:
@@ -161,20 +188,20 @@ With ``pyenv`` installed and correctly configured, it is now easy to install any
161188
162189
pyenv install -l
163190
164-
You should see a very long list of versions to choose from. Let's install the latest version of the 3.9 family:
191+
You should see a long list of versions to choose from. Let's install one of the later versions of the 3.9 family:
165192

166193
.. code-block:: bash
167194
168195
pyenv install 3.9.13
169196
170-
The command will take a minute or two to complete, depending on your internet connection, and show an output similar to the following (this is just an example for Windows):
197+
The command will take a minute or two to complete, depending on your internet connection, and show an output similar to the following (this is an example from Windows):
171198

172199
.. code-block:: output
173200
174201
:: [Info] :: Mirror: https://www.python.org/ftp/python
175202
:: [Downloading] :: 3.9.13 ...
176203
:: [Downloading] :: From https://www.python.org/ftp/python/3.9.13/python-3.9.13-amd64.exe
177-
:: [Downloading] :: To C:\Users\your_username\.pyenv\pyenv-win\install_cache\python-3.9.13-amd64.exe
204+
:: [Downloading] :: To C:\Users\your_username\.pyenv\pyenv-win\install_cache\python-3.9.13-amd64.exe
178205
:: [Installing] :: 3.9.13 ...
179206
:: [Info] :: completed! 3.9.13
180207
@@ -197,7 +224,9 @@ In both cases, if you run ``python --version`` afterwards, you should get ``Pyth
197224
Installing ``pipx``
198225
~~~~~~~~~~~~~~~~~~~
199226

200-
Next we need to install ``pipx``, a Python application manager that facilitates installing, keeping applications updated and run them in their own isolated environments. We could skip this step and install MUSE directly, but that will risk to have conflicting dependencies in the future if you install any other application, breaking your MUSE installation, and we do not want that to happen.
227+
Next we need to install ``pipx``, a Python application manager that facilitates installing, keeping applications updated and running them in their own isolated environments.
228+
More specifically, ``pipx`` will create a virtual environment to run the tools it installs based on the python version that was used to install pipx to start with, unless you specify another version and that other version is system wide available.
229+
We could skip this step and install MUSE directly, but that will risk to have conflicting dependencies in the future if you install any other application, breaking your MUSE installation, and we do not want that to happen.
201230

202231
The installation instructions for ``pipx`` can be found in the `official webpage <https://pypa.github.io/pipx/installation/>`_ specific for the three operating systems. The following instructions, however, should work for the three cases:
203232

docs/installation/virtual-env-based.rst

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ Later, to recover the system-wide "normal" python, deactivate the environment wi
4848
4949
conda deactivate
5050
51+
52+
.. _python_venv:
53+
5154
Creating a virtual environment with ``venv``
5255
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5356

@@ -87,8 +90,24 @@ Later, to recover the system-wide "normal" python, deactivate the environment wi
8790
8891
deactivate
8992
90-
Installing MUSE in a virtual environment
91-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93+
Creating a virtual environment with ``pyenv + venv``
94+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
95+
96+
Alternatively to creating virtual environments in ``conda``, you can also make use of two well-tested and maintained libraries.
97+
We met the first one, ``pyenv``, already in the :ref:`pipx-based <pipx-based>` under the section :ref:`Installing pyenv <pipx-based-installing-pyenv>` and the installation procedure is exactly the same.
98+
If you go down that route, please follow the steps outlined there and chose a recent version ``Python``, say 3.9.
99+
100+
The second package we need to create virtual environments for any specific ``Python`` version is called
101+
``venv``, and it ships with ``Python`` by default. To create such an environment, we first need to ensure that the
102+
``Python`` version we wish to use is indeed the one we want. To do this, open the terminal and invoke ``pyenv versions``.
103+
To install different versions or set them to local or global scope, please refer again to
104+
:ref:`Installing pyenv <pipx-based-installing-pyenv>`.
105+
106+
We can now create virtual environments using ``Python`` directly as explained in :ref:`python_venv`.
107+
108+
109+
Installing standalone MUSE in a virtual environment
110+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
92111

93112
Regardless of the method used, **once it has been created and activated**, you can install ``MUSE`` within using:
94113

docs/objects.inv

-20.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)