Tool for modeling and optimization of advanced locomotive powertrains for freight rail decarbonization.
Project description
ALTRIOS
The Advanced Locomotive Technology and Rail Infrastructure Optimization System (ALTRIOS) is a unique, fully integrated, open-source software tool to evaluate strategies for deploying advanced locomotive technologies and associated infrastructure for cost-effective decarbonization. ALTRIOS simulates freight-demand driven train scheduling, mainline meet-pass planning, locomotive dynamics, train dynamics, energy conversion efficiencies, and energy storage dynamics of line-haul train operations. Because new locomotives represent a significant long-term capital investment and new technologies must be thoroughly demonstrated before deployment, this tool provides guidance on the risk/reward tradeoffs of different technology rollout strategies. An open, integrated simulation tool is invaluable for identifying future research needs and making decisions on technology development, routes, and train selection. ALTRIOS was developed as part of a collaborative effort by a team comprising The National Renewable Energy Laboratory (NREL), University of Illinois Urbana-Champaign (UIUC), Southwest Research Institute (SwRI), and BNSF Railway.
Installation
All Users
Python Setup
- Python installation options:
- Option 1 -- Python: https://www.python.org/downloads/. We recommend Python 3.10. Be sure to check the
Add to PATH
option during installation. - Option 2 -- Anaconda: we recommend https://docs.conda.io/en/latest/miniconda.html.
- Option 1 -- Python: https://www.python.org/downloads/. We recommend Python 3.10. Be sure to check the
- Setup a python environment. ALTRIOS can work with Python 3.9, or 3.10, but we recommend 3.10 for better performance and user experience. Create a python environment for ALTRIOS with either of two methods:
- Option 1 -- Python Venv
- Navigate to the ALTRIOS folder you just cloned or any folder you'd like for using ALTRIOS. Remember the folder you use!
- Assuming you have Python 3.10 installed, run
python3.10 -m venv altrios-venv
in your terminal enviroment (we recommend PowerShell in Windows, which comes pre-installed). This tells Python 3.10 to use thevenv
module to create a virtual environment (which will be ignored by git if namedaltrios-venv
) in theALTRIOS/altrios-venv/
. - Activate the environment you just created to install packages or anytime you're running ALTRIOS:
- Mac and Linux:
source altrios-venv/bin/activate
- Windows:
altrios-venv/Scripts/activate.bat
in a windows command prompt or power shell orsource ./altrios-venv/scripts/activate
in git bash terminal - When the environment is activated, your terminal session will have a decorator that looks like
(altrios-venv)
.
- Mac and Linux:
- Option 2 -- Anaconda:
- Open an Anaconda prompt (in Windows, we recommend Anaconda Powershell Prompt) and run the command
conda create -n altrios python=3.10
to create an Anaconda environment namedaltrios
. - Activate the environment to install packages or anytime you're running ALTRIOS: run
conda activate altrios
.
- Open an Anaconda prompt (in Windows, we recommend Anaconda Powershell Prompt) and run the command
- Option 1 -- Python Venv
ALTRIOS Setup
With your Python environment activated, run pip install altrios
.
Congratulations, you've completed installation! Whenever you need to use ALTRIOS, be sure to activate your python environment created above.
Developers
Cloning the GitHub Repo
Clone the repository:
- Download and install git -- accept all defaults when installing.
- Create a parent directory in your preferred location to contain the repo -- e.g.
<USER_HOME>/Documents/altrios_project/
. - Open git bash, and inside the directory you created, clone the ALTRIOS repository with e.g.
git clone https://github.com/NREL/ALTRIOS.git
.
Installing the Python Package
Within the ALTRIOS folder, run pip install -e ".[dev]"
Using Pinned Package Versions
If you want to use pinned package versions to make sure you're environment is the same as the developers, you can do:
pip install -r requirements-dev.txt
Updating Pinned Package Versions
If you add a new package as a dependency, you should update the pinned requirements files.
To do this you can install pip tools: pip install pip-tools
and then:
pip-compile && pip-compile requirements-dev.in
This will generate two files: requirements.txt
and requirements-dev.txt
which you can check into the repository.
Rust Installation
Install Rust: https://www.rust-lang.org/tools/install.
Automated Building and Testing
There is a shortcut for building and running all tests, assuming you've installed the python package with develop mode. In the root of the ALTRIOS/
folder, run the build_and_test.sh
script. In Windows bash (e.g. git bash), run sh build_and_test.sh
, or in Linux/Unix, run ./build_and_test.sh
. This builds all the Rust code, runs Rust tests, builds the Python-exposed Rust code, and runs the Python tests.
Manually Building the Python API
Run maturin develop --release
. Note that not including --release
will cause a significant runtime computational performance penalty.
Testing
Manually
Whenever updating code, always run cargo test --release
inside ALTRIOS/rust/
to ensure that all tests pass. Also, be sure to rebuild the Python API regularly to ensure that it is up to date. Python unit tests run with python -m unittest discover
in the root folder of the git repository.
With GitHub Actions
Any time anyone pushes to main
or does any pull request, the GitHub Actions tests workflow is triggered.
Releasing
To PyPI With GitHub Actions
To release the package with GitHub Actions, you can follow these steps:
- With the changes already committed, create a new branch in the format
v<major>.<minor>.<patch>
. For examplev0.2.1
. - Update the version number in the
pyproject.toml
file. Commit and push to https://github.com/NREL/altrios. - Open a pull request into the main branch and make sure all checks pass.
- Once the pull request is merged into the main branch by a reviewer, create a new GitHub release and create a tag that matches the branch name. Once the release is created, a GitHub action will be launched to build the wheels and publish them to PyPI.
To crates.io
Instructions for releasing altrios-core
and altrios-proc-macros
are found in the README.md files in both of these crates. altrios-core-py
is a cdylib
crate and cannot be released.
How to run ALTRIOS
With your activated Python environment with ALTRIOS fully installed, you can download the demo scripts to the current working directory inside of a demos/
folder with:
import altrios as alt
alt.download_demo_files()
You can run the Simulation Manager through a multi-week simulation of train operations in by running python sim_manager_demo.py
in demos/
. This will create a plots/
subfolder in which the plots will be saved. To run interactively, fire up a Python IDE (e.g. VS Code, Spyder), and run the file. If you're in VS Code, you can run the file as a virtual jupyter notebook because of the "cells" that are marked with the # %%
annotation. You can click on line 2, for example, and hit <Shift> + <Enter>
to run the current cell in an interactive terminal (which will take several seconds to launch) and advance to the next cell. Alternatively, you can hit <Ctrl> + <Shift> + p
to enable interactive commands and type "run current cell". There are several other python files in the demos/
folder to demonstrate various capabilities of ALTRIOS.
Acknowledgements
The ALTRIOS Team would like to thank ARPA-E for financially supporting the research through the LOCOMOTIVES program and Dr. Robert Ledoux for his vision and support. We would also like to thank the ARPA-E team for their support and guidance: Dr. Apoorv Agarwal, Mirjana Marden, Alexis Amos, and Catherine Good. We would also like to thank BNSF for their cost share financial support, guidance, and deep understanding of the rail industry’s needs. Additionally, we would like to thank Jinghu Hu for his contributions to the core ALTRIOS code. We would like to thank Chris Hennessy at SwRI for his support. Thank you to Michael Cleveland for his help with developing and kicking off this project.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for altrios-0.1.2-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2a4134d4580f2d5a53151c7cb26f3c97c5f1f47697158c8da7f87a87902258f |
|
MD5 | bf8ecce88bffcaa0ee58b8053b93417a |
|
BLAKE2b-256 | d48794710c6f64280c2c4db9c82831b881d0c38945181b7329eb67a60d461108 |
Hashes for altrios-0.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24d53ca0ca2eab86d0fbd4a7ab1a3f906e5dfc0952d32367643ef8a3a8db7e17 |
|
MD5 | d3caa210ef1fdd79e23aeea7593afb54 |
|
BLAKE2b-256 | 69de13336882aaf3631eb3cafb905039999c0256b969e3d77b0eb1a789bf615e |
Hashes for altrios-0.1.2-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e29763207ff0b10c0e5b8fdb311b9bf70e1e802a2977eb21a9527f63536c7a52 |
|
MD5 | 562dd120f1d5eb083d838419da598180 |
|
BLAKE2b-256 | ac5cef4a5364d0243b70a000fa66a850f423646833a52e643e2b98812b7ef3d2 |
Hashes for altrios-0.1.2-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4de701a2ba257adde5310032f0cf65869cce1da4517f6b3dde0598b79fdde19 |
|
MD5 | 73601ce993af8e874af57b43bd02940a |
|
BLAKE2b-256 | 8f225b4d501bb2fbbaf1485b216360f0bf1f8371012c762cd12ad2dfef96d20d |
Hashes for altrios-0.1.2-cp39-cp39-manylinux_2_35_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aef937bd1ae068f3f1bc1ab139886dbd88e1d0076a057f4b3343dcdc23188f77 |
|
MD5 | da444f0db5ac36bf4fce3f6e36066fe2 |
|
BLAKE2b-256 | aa88ce25910acc5b48d648267f9960161a3a13a05151941fc0c5d763ed07e0b0 |
Hashes for altrios-0.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbdf413d0e53bcbb66a86e27f6f5221ad3fbbe56b76abb4a834ae193f79febdc |
|
MD5 | 082fdc044b8c20839389231e4ae0dd19 |
|
BLAKE2b-256 | 70146ab518ab8cc6b122841597bade925f8202340b10b6e9fe2e7c9d495d8c18 |
Hashes for altrios-0.1.2-cp39-cp39-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4c7f365123f92a5830550bb93bd5715c3dfcc36815d92253322ef8810cb5f0b |
|
MD5 | f0bfb8ac423d8c32aaa9a53e7610d130 |
|
BLAKE2b-256 | 514c783fa00cd97fdc57b034bd36a23978e14e1d729a0b57dd723f1ff53d3ba2 |