Skip to content

Commit 4565781

Browse files
authored
Merge branch 'develop' into new-data-input
2 parents 323a834 + 478e99c commit 4565781

697 files changed

Lines changed: 30332 additions & 28762 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.

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repos:
99
- id: trailing-whitespace
1010
- id: end-of-file-fixer
1111
- repo: https://github.com/astral-sh/ruff-pre-commit
12-
rev: v0.4.9
12+
rev: v0.5.0
1313
hooks:
1414
- id: ruff-format
1515
types_or: [python, pyi, jupyter]

.vscode/extensions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
44
// List of extensions which should be recommended for users of this workspace.
55
"recommendations": [
6-
"bungcip.better-toml",
6+
"bungcip.even-better-toml",
77
"janisdd.vscode-edit-csv",
88
"github.vscode-pull-request-github",
99
"ms-python.python",

.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",

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/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/commodities_io.rst

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,20 @@ Time
6060
represents the period of the simulation to which the value applies; it needs to
6161
contain at least the base year of the simulation.
6262

63-
Level
64-
characterises either a fixed or a flexible input type the following columns should
65-
contain the list of commodities the row.
66-
67-
Unit
68-
reports the unit in which the technology consumption is defined; it is for the user
69-
internal reference only.
63+
Level (for **input** commodities only)
64+
characterises inputs as either "fixed" or "flexible".
65+
Fixed inputs are always used by a technology in a fixed proportion.
66+
Flexible inputs allow a technology to choose amongst several alternative fuels,
67+
depending on which one is cheapest at the time.
68+
For example, if a vehicle can use either petrodiesel or biodiesel, these
69+
should be specified as "flexible" inputs, and the technology will choose between
70+
them based on the price of each.
71+
If a process has a mix of fixed and flexible inputs, these should be split over two rows.
72+
Defaults to "fixed".
73+
74+
The remaining columns should contain the full list of commodities.
75+
76+
The first row of the table reports the units for each column; it is for user reference only.
7077

7178
The input data has to be provided for the base year. Additional years within the time
7279
framework of the overall simulation can be defined. In this case, MUSE would interpolate

docs/inputs/technodata.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ the electric boiler used in households is taken as an example for a generic regi
1111

1212

1313
.. csv-table:: Techno-data: cost inputs
14-
:header: ProcessName, RegionName, Time, Level, cap_par, cap_exp, fix_par, ...
14+
:header: ProcessName, RegionName, Time, cap_par, cap_exp, fix_par, ...
1515

16-
resBoilerElectric, region1, 2010, fixed, 3.81, 1.00, 0.38, ...
17-
resBoilerElectric, region1, 2030, fixed, 3.81, 1.00, 0.38, ...
16+
resBoilerElectric, region1, 2010, 3.81, 1.00, 0.38, ...
17+
resBoilerElectric, region1, 2030, 3.81, 1.00, 0.38, ...
1818

1919

2020
ProcessName
@@ -27,9 +27,6 @@ Time
2727
represents the period of the simulation to which the value applies; it needs to
2828
contain at least the base year of the simulation
2929

30-
Level
31-
characterises either a fixed or a flexible input type
32-
3330
cap_par, cap_exp
3431
are used in the capital cost estimation. Capital costs are calculated as:
3532

@@ -115,7 +112,10 @@ TechnicalLife
115112
represents the number of years that a technology operates before it is decommissioned.
116113

117114
UtilizationFactor
118-
represents the maximum actual output of the technology in a year, divided by the theoretical maximum output if the technology were operating at full capacity for the whole year. Must be between 0 and 1.
115+
represents the *maximum* actual output of the technology in a year, divided by the theoretical maximum output if the technology were operating at full capacity for the whole year. Must be between 0 and 1.
116+
117+
MinimumServiceFactor
118+
Is the *minimum* output of the technology in a year, divided by the theoretical maximum output if the technology were operating at full capacity for the whole year. Must be between 0 and 1 and be smaller or equal than the `UtilizationFactor`. It is used to define the minimum service level that a technology must provide due to, typically, technical or efficiency constraints.
119119

120120
ScalingSize
121121
represents the reference capacity at which capital costs are estimated when used as agents' objective as described in :ref:`inputs-agents`.

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

0 commit comments

Comments
 (0)