Skip to main content

Tool for modeling and optimization of advanced locomotive powertrains for freight rail decarbonization.

Project description

ALTRIOS

Tests wheels Release Python

Model Framework Schematic

The Advanced Locomotive Technology and Rail Infrastructure Optimization System (ALTRIOS) is a tool for simulating and optimizing the rollout of advanced locomotive technologies and associated infrastructure with the goal of decarbonizing freight rail. ALTRIOS-lite will be released no later than June 2023, but for a richer, full-featured experience, we recommend using ALTRIOS through the Python API user interface, and we offer full installation instructions and numerous usage examples.

Installation

All Users

Python Setup

  1. Python installation options:
  2. Setup a python environment. ALTRIOS can work with Python 3.8, 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
      1. Navigate to the ALTRIOS folder you just cloned or any folder you'd like for using ALTRIOS. Remember the folder you use!
      2. 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 the venv module to create a virtual environment (which will be ignored by git if named altrios-venv) in the ALTRIOS/altrios-venv/.
      3. 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 or source ./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).
    • Option 2 -- Anaconda:
      1. 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 named altrios.
      2. Activate the environment to install packages or anytime you're running ALTRIOS: run conda activate altrios.

ALTRIOS Setup

  1. Download an all-wheels.zip file from ALTRIOS release.
  2. Unzip the release in the folder where you want to install ALTRIOS.
  3. With your Python environment activated, run pip install --find-links <path-to-release-folder> 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:

  1. Download and install git -- accept all defaults when installing.
  2. Create a parent directory in your preferred location to contain the repo -- e.g. <USER_HOME>/Documents/altrios_project/.
  3. 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 computational performance penalty.

Manually Testing

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.

How to run ALTRIOS

With your activated Python environment with ALTRIOS fully installed, you can run several scripts in ALTRIOS/applications/demos/.

You can run the Simulation Manager through a multi-week simulation of train operations with ALTRIOS/applications/demos/sim_manager_demo.py by running python sim_manager_demo.py in ALTRIOS/applications/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".

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

altrios-0.1.0-cp310-none-win_amd64.whl (3.9 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

altrios-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.2 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

altrios-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl (4.0 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

altrios-0.1.0-cp39-none-win_amd64.whl (3.9 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

altrios-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

altrios-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl (4.0 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

altrios-0.1.0-cp38-none-win_amd64.whl (3.9 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

altrios-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.2 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

altrios-0.1.0-cp38-cp38-macosx_10_9_x86_64.whl (4.0 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page