Skip to main content

Tool for modeling vehicle powertrains

Project description

FASTSim Logo

Description

This is the python/rust flavor of NREL's FASTSim, which is based on the original Excel implementation. Effort will be made to keep the core methodology between this software and the Excel flavor in line with one another.

All classes and methods are self-documented.

Installation

Python

Set up and activate a python environment (compatible with Python 3.8 - 3.10; we recommend Python 3.10) with the following steps.

Anaconda

  1. Create: conda create -n fastsim python=3.10
  2. Activate: conda activate fastsim

venv

There is some variation based on your Operating System:

  • PowerShell (windows):

    1. Create: python -m venv fastsim-venv -- name is user decision
    2. Activate: fastsim-venv/Scripts/Activate.ps1
  • Bash (i.e. unix/linux/mac):

    1. Create: python -m venv fastsim-venv -- name is user decision
    2. Activate: source fastsim-venv/bin/activate
  • Command Prompt (windows):

    1. Create: python -m venv fastsim-venv -- name is user decision
    2. Activate: fastsim-venv/Scripts/activate.bat

FASTSim

Via PyPI

In an active Python environment (either venv or Conda), run pip install fastsim.

Building from Scratch

Developers might want to install the code in place so that FASTSim files can be editable (the -e flag for pip provides this behavior). This option can be handy since FASTSim will be installed in place from the installation location and any updates will be propagated each time FASTSim is freshly imported.

  • Easy way: run sh build_and_test.sh in root folder.
  • Hard way (a couple of extra steps are required):
    1. First install the python code in place:
      DEVELOP_MODE=True pip install -e ".[dev]"
      if on Mac OS, Linux, or Windows Bash (e.g. git bash, VSCode bash). On Windows in Power Shell or Command Prompt, run
      set DEVELOP_MODE=True then pip install -e ".[dev]".
    2. Within the same python environment, navigate to fastsim/rust/ and run
      pip install maturin.
    3. Optional: Within the rust/ folder (which contains the rust src/ folder), run cargo test --release to build and run the tests.
    4. In fastsim/rust/fastsim-py, you should now be able to run maturin develop --release, which will enable the tests that use rust to run. You should also now be able to run fastsim/fastsim/docs/demo.py.

After FASTSim has been installed as editable per the above instructions, you can rebuild and test everything with sh build_and_test.sh in Windows bash or ./build_and_test.sh in Linux/Unix in the fastsim/ dir.

Testing

At the root level of the git repository: pytest -v fastsim/tests/. This can also be run in the python environment directly.

Usage

To see and run examples, navigate to fastsim/docs and run the various *demo.py files to see fastsim use cases. There are other examples in fastsim/tests.

Adding FASTSim as a Depency in Rust

Via GitHub

Add this line:
fastsim-core = { git = "https://github.nrel.gov/MBAP/fastsim", branch = "rust-port" }
to your Cargo.toml file, modifying the branch key as appropriate.

Via Cargo

This has not been implemented yet.

List of Abbreviations

cur = current time step
prev = previous time step
cyc = drive cycle
secs = seconds
mps = meters per second
mph = miles per hour
kw = kilowatts, unit of power
kwh = kilowatt-hour, unit of energy
kg = kilograms, unit of mass
max = maximum
min = minimum
avg = average
fs = fuel storage (eg. gasoline/diesel tank, pressurized hydrogen tank)
fc = fuel converter (eg. internal combustion engine, fuel cell)
mc = electric motor/generator and controller
ess = energy storage system (eg. high voltage traction battery)
chg = charging of a component
dis = discharging of a component
lim = limit of a component
regen = associated with regenerative braking
des = desired value
ach = achieved value
in = component input
out = component output

Known Issues

Rust versions of classes have limited Language Server Protocol integration, and we are actively working on fixing this.

Release Notes

2.0.11 - 2.0.18 -- PyPI fixes. Also, Rust version is now >100x faster than Python version.
2.0.10 -- logging fixes, proc macro reorganization, some CAVs performance fixes
2.0.9 -- support for mac ARM/RISC architecture
2.0.8 -- performance improvements
2.0.6 -- dist_v2_m fixes and preliminary CAV functionality
2.0.5 -- added to_rust method for cycle
2.0.4 -- exposed veh.set_veh_mass
2.0.3 -- exposed veh.__post_init__
2.0.2 -- provisioned for non-default vehdb path
2.0.1 -- bug fix
2.0.0 -- All second-by-second calculations are now implemented in both rust and python. Rust provides a ~30x speedup
1.3.1 -- fastsim.simdrive.copy_sim_drive function can deepcopy jit to non-jit (and back) for pickling
1.2.6 -- time dilation bug fix for zero speed
1.2.4 -- bug fix changing == to =
1.2.3 -- veh_file can be passed as standalone argument. fcEffType can be anything if fcEffMap is provided, but typing is otherwise enforced.
1.2.2 -- added checks for some conflicting vehicle parameters. Vehicle parameters fcEffType and vehPtType must now be str type.
1.2.1 -- improved time dilation and added test for it
1.1.7 -- get_numba_veh() and get_numba_cyc() can now be called from already jitted objects
1.1.6 -- another bug fix for numba compatibility with corresponding unit test
1.1.5 -- bug fix for numba compatibility of fcPeakEffOverride and mcPeakEffOverride
1.1.4 -- nan bug fix for fcPeakEffOverride and mcPeakEffOverride
1.1.3 -- provisioned for optional load time motor and engine peak overrides
1.1.2 -- made vehicle loading more more robust
1.1.1 -- made vehicle loading more robust
1.1.0 -- separated jitclasses into own module, made vehicle engine and motor efficiency setting more robust
1.0.4 -- bug fix with custom engine curve
1.0.3 -- bug fixes, faster testing
1.0.2 -- forced type np.float64 on vehicle mass attributes
1.0.1 -- Added vehYear attribute to vehicle and other minor changes.
1.0.0 -- Implemented unittest package. Fixed energy audit calculations to be based on achieved speed. Updated this file. Improved documentation. Vehicle can be instantiated as dict.
0.1.5 -- Updated to be compatible with ADOPT
0.1.4 -- Bug fix: mcEffMap is now robust to having zero as first element
0.1.3 -- Bug fix: fastsim.vehicle.Vehicle method set_init_calcs no longer overrides fcEffMap.
0.1.2 -- Fixes os-dependency of xlwings by not running stuff that needs xlwings. Improvements in functional test. Refinment utomated typying of jitclass objects.
0.1.1 -- Now includes label fuel economy and/or battery kW-hr/mi values that match excel and test for benchmarking against Excel values and CPU time.

Contributors

Chad Baker -- Chad.Baker@nrel.gov
Aaron Brooker -- Aaron.Brooker@nrel.gov
Kyle Carow -- Kyle.Carow@nrel.gov
Jeffrey Gonder -- Jeff.Gonder@nrel.gov
Jacob Holden -- Jacob.Holden@nrel.gov
Jinghu Hu -- Jinghu.Hu@nrel.gov
Jason Lustbader -- Jason.Lustbader@nrel.gov
Sean Lopp -- sean@rstudio.com
Matthew Moniot -- Matthew.Moniot@nrel.gov
Grant Payne -- Grant.Payne@nrel.gov
Laurie Ramroth -- lramroth@ford.com
Eric Wood -- Eric.Wood@nrel.gov

Project details


Download files

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

Source Distribution

fastsim-2.0.18.tar.gz (5.4 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fastsim-2.0.18-cp310-cp310-win_amd64.whl (7.1 MB view details)

Uploaded CPython 3.10Windows x86-64

fastsim-2.0.18-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

fastsim-2.0.18-cp310-cp310-macosx_10_9_universal2.whl (8.5 MB view details)

Uploaded CPython 3.10macOS 10.9+ universal2 (ARM64, x86-64)

fastsim-2.0.18-cp39-cp39-win_amd64.whl (7.1 MB view details)

Uploaded CPython 3.9Windows x86-64

fastsim-2.0.18-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

fastsim-2.0.18-cp39-cp39-macosx_10_9_universal2.whl (8.5 MB view details)

Uploaded CPython 3.9macOS 10.9+ universal2 (ARM64, x86-64)

fastsim-2.0.18-cp38-cp38-win_amd64.whl (7.1 MB view details)

Uploaded CPython 3.8Windows x86-64

fastsim-2.0.18-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.3 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

fastsim-2.0.18-cp38-cp38-macosx_10_9_universal2.whl (8.5 MB view details)

Uploaded CPython 3.8macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file fastsim-2.0.18.tar.gz.

File metadata

  • Download URL: fastsim-2.0.18.tar.gz
  • Upload date:
  • Size: 5.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for fastsim-2.0.18.tar.gz
Algorithm Hash digest
SHA256 f05758ab97b0dc254d057f097a12ab928ebbf0096f253d3ab2fbdedd50c8f39e
MD5 0e6f246b89607f463d4d451f01045443
BLAKE2b-256 f6a0353c9738e63b41901985ea8e9876e56002f2ec8845beee6ade1fdf8b60d5

See more details on using hashes here.

File details

Details for the file fastsim-2.0.18-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: fastsim-2.0.18-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 7.1 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for fastsim-2.0.18-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f0795b7ca7e3d353159d8ddb8caf04dc2d2e9a965bc024475d3ed5eda3c90afd
MD5 b0467544cfbbf0723173148fff4c6202
BLAKE2b-256 15bc59588530c9cdd5eae9e610451478dbbc46dfcedab7220b4de338fcaebcaa

See more details on using hashes here.

File details

Details for the file fastsim-2.0.18-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastsim-2.0.18-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e59d38cf3727f877dfa761af27fad2af94014e029b3e89bd0840344bb7674794
MD5 473d8ce310b5f6630318e6ab590eaae0
BLAKE2b-256 ebc08092a67860111cbcd9265c639ad82bcb9f13faa6169dce0573ce306a58a1

See more details on using hashes here.

File details

Details for the file fastsim-2.0.18-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for fastsim-2.0.18-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 0ad20d39eb419581f07b7b6a934c7d7f8ced5844058579f21fa20f95558780d9
MD5 6d1b15b5921bd07d078dd978cc1b4afa
BLAKE2b-256 433f3a9abc9896b96fff16878bccfcbf176c2ecd74ebe58a32b24ab259881438

See more details on using hashes here.

File details

Details for the file fastsim-2.0.18-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: fastsim-2.0.18-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 7.1 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for fastsim-2.0.18-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 3b8c73496ced4dd63f1e96033a9c70bb60455f41a115a3749ac4358ffda7398f
MD5 df43e6bfcc66f8a90db813350628f815
BLAKE2b-256 577c2b595c9eb5080195c293c9bf5b42ded416a43a0bf8590ad932ec57adc55a

See more details on using hashes here.

File details

Details for the file fastsim-2.0.18-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastsim-2.0.18-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1225b4282cacec75a7f1bc34ef26ab1498ff0dd4b7caf2e009b4ef442343625c
MD5 a50d586050e7ea219da64228f8235a36
BLAKE2b-256 9ce2aa1b18586bdf3fedbce54ceb98ebad5aca21b808da1d583ba48168bc6569

See more details on using hashes here.

File details

Details for the file fastsim-2.0.18-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for fastsim-2.0.18-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 07848b25a65878135e5fdae96c253ad3eb441d3716d6db691fa2b3c3d9b0ad77
MD5 04ceccc8bedaf961b2454d17161b432d
BLAKE2b-256 f0e99b49f7f6ea415c93d96c37a4e4b038aec07c9c9e5f9ea8e1b00f74bc23e4

See more details on using hashes here.

File details

Details for the file fastsim-2.0.18-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: fastsim-2.0.18-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 7.1 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for fastsim-2.0.18-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 88b5f18d2b5867f4692688cb3a50d35d1af0f18d985104e447d788231b5a2369
MD5 5cbf1829c5c070994a2f17acdc5fe3a7
BLAKE2b-256 90db1e86ab3e4e0d8043493f80043201d2590dbdbd29284523ed1d1126fac89e

See more details on using hashes here.

File details

Details for the file fastsim-2.0.18-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastsim-2.0.18-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d2e744241c310b9257feadcdefa321261ba315a09e751fbb255fdbc402b9cea9
MD5 3fd5f9eab4c95152f804b70d517f1c7a
BLAKE2b-256 96d07ac3f90c462e9d622b6c73c72c7030315cdbb6b8002e333b94d5c85c0c97

See more details on using hashes here.

File details

Details for the file fastsim-2.0.18-cp38-cp38-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for fastsim-2.0.18-cp38-cp38-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 0da00557bda88e52e07ea13861815b35e0c55d1d7c0183804665f586a2e3e9f3
MD5 4fcb745e674d1536338018284e927c6b
BLAKE2b-256 2a61617d6cf428df22ee08ec4fc387f7f16bd3ebec62911ed33a262add0e1b5c

See more details on using hashes here.

Supported by

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