MCPcopy Index your code
hub / github.com/NatLabRockies/fastsim

github.com/NatLabRockies/fastsim @v3.0.6

Chat with this repo
repository ↗ · DeepWiki ↗ · release v3.0.6 ↗ · + Follow
974 symbols 2,653 edges 92 files 354 documented · 36%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

homepage tests release python documentation github

Description

This is the fastsim-3 version of NREL's FASTSim. It introduces numerous new enhancements and features, including: - ~10x faster! -- when setting save_interval to None, which means only the state at the last time step, which includes fuel consumption and/or battery depletion, among other useful cumulative state variables.
- Roughly ~60% reduction in memory consumption (~160 mb in fastsim-2 v. 60 mb in fastsim-3 - object-oriented, hierarchical model structure - ability to control granularity of time-resolved data -- e.g. save at every time step, save at every _n_th time step, or never save at all (saving only cumulative trip-level results) - component-specific vehicle models -- i.e. the conventional vehicle contains only data for the fuel converter and other relevant components but does contain any dummy battery or motor parameters as is the case in fastsim-2 - file formats that are more robust and more human readable - backwards compatibility with fastsim-2 - flexible data structures to allow for future model types - ability to simulate standalone component models - flexible model interfacing (e.g. multiple folder/file formats for reading and/or writing data) - more accurate interpolation methods

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

Pixi (recommended for developers)

  1. pixi shell -e dev -- this creates the environment, installs all the dependencies, builds fastsim, and activates the environment

FASTSim-3

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:
    1. Run pip install -e ".[dev]"
      Optional testing steps:
    2. Run cargo test
    3. Run pytest -v python/fastsim/tests/

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 Robin Steuteville -- Robin.Steuteville@nrel.gov

Extension points exported contracts — how you extend this code

StateMethods (Interface)
Super trait to ensure that related traits are implemented together [6 implementers]
fastsim-core/src/traits.rs
TokenStreamIterator (Interface)
taken from https://github.com/lumol-org/soa-derive/blob/master/soa-derive-internal/src/input.rs [1 implementers]
fastsim-core/fastsim-proc-macros/src/utilities.rs
SetCumulative (Interface)
Trait for setting cumulative values based on rate values [9 implementers]
fastsim-core/src/traits.rs
SaveState (Interface)
Provides method that saves `self.state` to `self.history` and propagates to any fields with `state` [6 implementers]
fastsim-core/src/traits.rs
Step (Interface)
Trait that provides method for incrementing `i` field of this and all contained structs, recursively [6 implementers]
fastsim-core/src/traits.rs
HistoryMethods (Interface)
Provides methods for getting and setting the save interval [20 implementers]
fastsim-core/src/traits.rs

Core symbols most depended-on inside this repo

update
called by 293
fastsim-core/src/utils/tracked_state.rs
get_fresh
called by 242
fastsim-core/src/utils/tracked_state.rs
get_stale
called by 92
fastsim-core/src/utils/tracked_state.rs
mark_stale
called by 84
fastsim-core/src/utils/tracked_state.rs
push
called by 79
fastsim-core/src/drive_cycle.rs
max
called by 61
fastsim-core/src/vehicle/powertrain/reversible_energy_storage.rs
get_paired_cycler
called by 49
python/fastsim/demos/plot_utils.py
from_resource
called by 49
fastsim-core/src/traits/serde_api.rs

Shape

Method 543
Function 324
Class 63
Enum 24
Interface 20

Languages

Rust83%
Python17%

Modules by API surface

fastsim-core/src/drive_cycle.rs71 symbols
fastsim-core/src/vehicle/vehicle_model.rs66 symbols
fastsim-core/src/vehicle/powertrain/reversible_energy_storage.rs65 symbols
fastsim-core/src/drive_cycle/manipulation_utils.rs53 symbols
fastsim-core/src/vehicle/powertrain/fuel_converter.rs47 symbols
cal_and_val/thermal/cal_hev.py46 symbols
fastsim-core/src/simdrive.rs41 symbols
fastsim-core/src/vehicle/powertrain_type.rs40 symbols
fastsim-core/src/simdrivelabel.rs40 symbols
fastsim-core/src/vehicle/hev.rs37 symbols
fastsim-core/src/vehicle/powertrain/electric_machine.rs31 symbols
cal_and_val/thermal/cal_bev.py30 symbols

For agents

$ claude mcp add fastsim \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact