Tool for modeling vehicle powertrains
Project description
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
- 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 (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):
- 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
thenpip install -e ".[dev]"
. - Within the same python environment, navigate to
fastsim/rust/
and run
pip install maturin
. - Optional: Within the
rust/
folder (which contains the rustsrc/
folder), runcargo test --release
to build and run the tests. - In
fastsim/rust/fastsim-py
, you should now be able to runmaturin develop --release
, which will enable the tests that use rust to run. You should also now be able to runfastsim/fastsim/docs/demo.py
.
- First install the python code in place:
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.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
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
Hashes for fastsim-2.0.22-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 185ee0024c7cf3b8a85580876260626d020025f29388b503f4da0049484a04e6 |
|
MD5 | 1e3ba04b0d17cdc531cd94bbb9238caf |
|
BLAKE2b-256 | e01e9d5c542df95c311520f4fec5d81be96fd7de789cf4fa5dbc3bef73883488 |
Hashes for fastsim-2.0.22-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2c71e63c8c99a43fb6a35e801202375c0dff7158467bc6f8b6c198ebdf5f494 |
|
MD5 | 8e7ba72b4a444dc5f10dc002d4e19eeb |
|
BLAKE2b-256 | 9ad8801e8d69aca474a309170e5649de5880f04618aac0c42ac1756ac0e56443 |
Hashes for fastsim-2.0.22-cp310-cp310-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2d0948079f0dfd2b1e13e05834f375db39223975b841728e369d17f7409e0fb |
|
MD5 | 6117c6250438ee0cfa6e7c9e1e2e5b62 |
|
BLAKE2b-256 | 891ad34a1ba5fa9dccc0e05ab4d7c1b31b6916e2caa8a5352361dcc968bc4fc7 |
Hashes for fastsim-2.0.22-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79b27a66a0e655cae04798d2e8036a2a2ee6afda35923ead0562146353fbca1c |
|
MD5 | 53b7ef62447197882f8f5ef6488e8128 |
|
BLAKE2b-256 | ac0145b95d8b54bb16bd0ebc141cae34e31ea8f55def094a7ebc583ca0a47e72 |
Hashes for fastsim-2.0.22-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97146215199b746eb1355b84245b769f13bd23781b8566b1704395c44939f8b7 |
|
MD5 | 51f3e023967c513407d835a6fcdb6b4e |
|
BLAKE2b-256 | 0a67f37dd32faa9c9644f01e7f0e6c835d16e8fb12da18bd6b2d251036508a6b |
Hashes for fastsim-2.0.22-cp39-cp39-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 193761d9b5499ba2f238a070d110ce5cf5e2b6769f72e2a695a55b760f7d5b16 |
|
MD5 | 94ab31470eb0ca5c007ea6d9fce28e11 |
|
BLAKE2b-256 | 8080e7a28746c04bc42d2382c3a656576f7956455445957e29e42edce5b198d7 |
Hashes for fastsim-2.0.22-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d4d2e35a9977c05b055bf2b5e0454957635d5c2412e6a9fb769fc3f6c100b3f |
|
MD5 | 2d5dcd1bff892af8e2a9fb2b91015310 |
|
BLAKE2b-256 | 9f67228e87b2881f278adc30a6c9196a7131cae781df9072dab9287323b61144 |
Hashes for fastsim-2.0.22-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbb0b91e3edf873da89e24e85bd93650d7e2a36f33bec32283d33529295046cb |
|
MD5 | 6766107f19dfdb1b542c0d9c7bb76fe5 |
|
BLAKE2b-256 | 19fc77a3a6e1d08f7cdf0e2952fb179c024124658f0e713a2aa2f9400440bdba |
Hashes for fastsim-2.0.22-cp38-cp38-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25128f30d0ccc5ed39ac3368bb5d37cf0fe6ea8d786bcf4064d7e29bddf9d2b1 |
|
MD5 | 487e796c4c0c92719191f78650abcb88 |
|
BLAKE2b-256 | 04cb65ec281dd9095a666755094fc954d7e8a7ff05345ff1ecb8fcf11b1e8277 |