Tool for modeling vehicle powertrains
Project description
FASTSim
Description
This is the python/rust flavor of NREL's FASTSimTM, 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
- Create:
conda create -n fastsim python=3.10
- Activate:
conda activate fastsim
venv
There is some variation based on your Operating System:
-
PowerShell (windows):
- Create:
python -m venv fastsim-venv
-- name is user decision - Activate:
fastsim-venv/Scripts/Activate.ps1
- Create:
-
Bash (i.e. unix/linux/mac):
- Create:
python -m venv fastsim-venv
-- name is user decision - Activate:
source fastsim-venv/bin/activate
- Create:
-
Command Prompt (windows):
- Create:
python -m venv fastsim-venv
-- name is user decision - Activate:
fastsim-venv/Scripts/activate.bat
- Create:
FASTSim
Via PyPI
In an active Python environment created above, 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. To do this, you'll need to have the Rust toolchain installed.
- Option 1: run
sh build_and_test.sh
in root folder. - Option 2:
- Run
pip install -e ".[dev]"
Optional testing steps: - Run
cd rust/ && cargo test
- Run
pytest -v python/fastsim/tests/
- Run
Usage
To see and run examples, navigate to ./python/fastsim/demos
and run the various *demo.py files to see fastsim use cases. There are other examples in fastsim/tests.
Adding FASTSim as a Dependency in Rust
Via GitHub
Add this line:
fastsim-core = { git = "https://github.com/NREL/fastsim/", branch = "fastsim-2" }
to your Cargo.toml file, modifying the branch
key as appropriate.
Via Cargo
FASTSim is available as a Rust crate, which can be added to your dependencies via the following command:
cargo add fastsim-core
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.1.2 -- SerdeAPI revamp with many new functions, various new vehicles, calibration demo, better error propagation, demo testing
2.1.1 -- license changed to Apache 2.0, default cycle grade and road type to zero if not provided, defaults to regenerative braking parameters, optional documentation fields now generated in Rust
2.1.0 -- release and installation improvements, RustVehicle init cleanup, calibration improvements
2.0.11 - 2.0.22 -- 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
Robin Steuteville -- Robin.Steuteville@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
Built Distributions
File details
Details for the file fastsim-2.1.2.tar.gz
.
File metadata
- Download URL: fastsim-2.1.2.tar.gz
- Upload date:
- Size: 5.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5fb4d5be7a63314cde926eaac44eb6e44f46f3db45bfc92ef1b0c65c632e599 |
|
MD5 | 726863a1306ac0e13ce6689aca19e8e7 |
|
BLAKE2b-256 | 8c68ec1c95bf87feb0e00f5f95e0b3d29ed1741beaaa30fdd369e60f6adf7fa5 |
File details
Details for the file fastsim-2.1.2-cp310-none-win_amd64.whl
.
File metadata
- Download URL: fastsim-2.1.2-cp310-none-win_amd64.whl
- Upload date:
- Size: 10.1 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88f3014104ed428351c0b22955826632bc54fd04537bf0170863d30dd30c1129 |
|
MD5 | 6e8fe98c090da4b673c1f4d3400492e1 |
|
BLAKE2b-256 | 26aba26e6553096cf64ab1a279249949d14742d343c8c829977f51d06e3537ef |
File details
Details for the file fastsim-2.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: fastsim-2.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 11.6 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e03f42a1e2d7cd7f24b2d9205bd0a3a04b20a21a125491cf85581581b48e782e |
|
MD5 | 7bc80ca005e1a76d26791c74b2ed76e3 |
|
BLAKE2b-256 | 354c5806b4ad8accf9df03630288771bce9a259872226675eff19269874c17fb |
File details
Details for the file fastsim-2.1.2-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
.
File metadata
- Download URL: fastsim-2.1.2-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 13.0 MB
- Tags: CPython 3.10, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37264477d1ed7ba75bbc04062e74c8f259a4b73ba0c813c07a98d46b712c4382 |
|
MD5 | 363687affe72dac3146c237dd4dbee54 |
|
BLAKE2b-256 | 4bcf3f900af535012a12e0aae49f42536435e851d5ea349dbcfefdabf8b4e711 |
File details
Details for the file fastsim-2.1.2-cp39-none-win_amd64.whl
.
File metadata
- Download URL: fastsim-2.1.2-cp39-none-win_amd64.whl
- Upload date:
- Size: 10.1 MB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdd55f1772c3ea0d54ad79c0ce96af8c38caf6ee45efde6ff23da002adb29af9 |
|
MD5 | 73545c9bdc8e23c7279da28228781661 |
|
BLAKE2b-256 | 0faa688599f25939f2dd95f8dc8a99be4f6f4b0fa6d681cbc261a93a93790e35 |
File details
Details for the file fastsim-2.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: fastsim-2.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 11.6 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc4a7873104342de48e27e9f04ba5e17af8cf7b6f8329d4dea6fe167a7f49034 |
|
MD5 | ac1f44be86ffd916c4fdb346faecb084 |
|
BLAKE2b-256 | 6abddb5e0d35d8dff3e59d72ff30511d93571dbb42c5719dbafe5b3fb874e095 |
File details
Details for the file fastsim-2.1.2-cp39-cp39-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
.
File metadata
- Download URL: fastsim-2.1.2-cp39-cp39-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 13.0 MB
- Tags: CPython 3.9, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7776f7379331bda0fcd9bb2b8d7dc6392c6a6e1224fafdc5d8d5f9e868e55f85 |
|
MD5 | 632d30722773ee297ce007c445bc9f25 |
|
BLAKE2b-256 | a13a2521a14edd6a276105a1ee69317ace9a6d5b679dc4d5bd383f6f339b4912 |
File details
Details for the file fastsim-2.1.2-cp38-none-win_amd64.whl
.
File metadata
- Download URL: fastsim-2.1.2-cp38-none-win_amd64.whl
- Upload date:
- Size: 10.1 MB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e66bfe45cc39f4f2a9be08b60fa056561997df721bb34bf15105168ba21991a |
|
MD5 | 487594ff9a1c6d54bf68c2e41a5e1951 |
|
BLAKE2b-256 | fbaaee0e68e3d2e4579fbe4158ff5bdbd38e9f32c753df12b788cbc743357ab5 |
File details
Details for the file fastsim-2.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: fastsim-2.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 11.6 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 384709e0c6dc84052fc27eff324d3343eaf911c51192bca5f68db87af4230f51 |
|
MD5 | 456a8033a4f59061e570e32d759a677a |
|
BLAKE2b-256 | b9662bb692433cea9cf9900088b8328c1a5d95c35c1fb622d083bb4d3a7ffaab |
File details
Details for the file fastsim-2.1.2-cp38-cp38-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
.
File metadata
- Download URL: fastsim-2.1.2-cp38-cp38-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 13.0 MB
- Tags: CPython 3.8, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 412882398281b974f878b9de7f97787598bfc2ce587e33b5254afdae237e3e78 |
|
MD5 | 8fba231dd84d8567cfc4e9be5c14c3ca |
|
BLAKE2b-256 | be1a2aef1c983abe5e90b11e35fa531f1e8bc881bc9fe88e34eec9c85059df31 |