Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Loading Vehicle Files

import fastsim

Loading local files

FASTSim provides the Vehicle.from_file method that can load a variety of file formats (yaml, json, toml, msgpack). The file extension determines how to parse the vehicle file.

Examples

veh = fastsim.Vehicle.from_file("path/to/file/my_vehicle.yaml")
veh = fastsim.Vehicle.from_file("path/to/file/my_vehicle.json")

Loading built-in resources

FASTSim comes with a variety of built-in preconfigured vehicle models.

fastsim.Vehicle.list_resources()
[PosixPath('2012_Ford_Fusion.yaml'), PosixPath('2016 Nissan Leaf 30 kWh thrml.yaml'), PosixPath('2016_TOYOTA_Prius_Two.yaml'), PosixPath('2020 Chevrolet Bolt EV thrml.yaml'), PosixPath('2021_Hyundai_Sonata_Hybrid_Blue_thrml.yaml'), PosixPath('2022 Tesla Model 3 RWD thrml.yaml'), PosixPath('2022_Renault_Zoe_ZE50_R135.yaml'), PosixPath('2026_Chrysler_Pacifica_Select.yaml'), PosixPath('2026_Chrysler_Pacifica_Select_thrml.yaml')]
veh = fastsim.Vehicle.from_resource("2012_Ford_Fusion.yaml")

Loading from the FASTSim vehicle database

The public FASTSim vehicle database is hosted at https://github.com/NatLabRockies/fastsim-vehicles.

Database Structure

Vehicles in the database are organized in a machine-searchable directory structure, detailed below:

LevelDescriptionExample
Schema versionDescribes the format of subsequent organizational levels.v1
FASTSim versionMajor FASTSim version.fastsim-3
PowertrainPowertrain type (e.g. conv/hev/phev/bev/fcev)conv
MakeVehicle make/manufacturer name.ford
ModelVehicle model name and any applicable trim information.fusion
YearModel year or year range.2012
VariantDescription of active modeling feature set.base
RevisionModel revision number for updates and corrections.r1

Example full filepath:

v1/fastsim-3/conv/ford/fusion/2012/base/r1.yaml

Examples

FASTSim provides Vehicle.from_db to load from the default database, with flexibility to point to similarly structured databases in the local filesystem or at different URLs (e.g. https://raw.githubusercontent.com/...).

The below examples load the following vehicle from different database locations:

vehicle_path = "v1/fastsim-3/conv/ford/fusion/2012/base/r1"

From fastsim-vehicles repository

If no database base path is supplied, from_db loads from https://github.com/NatLabRockies/fastsim-vehicles:

# No URL/database path supplied, load from fastsim-vehicles repo
veh = fastsim.Vehicle.from_db(path=vehicle_path)

From local database

veh = fastsim.Vehicle.from_db(
    db_path_or_url="path/to/local/vehicle/database",
    path=vehicle_path,
)

From other remote database

veh = fastsim.Vehicle.from_db(
    # Points to the fastsim-vehicles repository as an example
    db_path_or_url="https://raw.githubusercontent.com/NatLabRockies/fastsim-vehicles/main",
    path=vehicle_path,
)

Supplying path segments

The from_db method also accepts path segments as individual fields, which is useful for programmatic searching and filtering.

fastsim.Vehicle.from_db(
    fastsim_version=3,       # optional, defaults to installed FASTSim major version
    powertrain="conv",       # required: "conv", "hev", "phev", "bev"
    make="ford",             # required
    model="fusion",          # required
    year="2012",             # required (string; supports ranges like "2020-2023")
    variant="base",          # optional, default "base"
    revision=1,              # required (int or "r1"/"R1" string)
    extension="yaml",        # optional, default "yaml"
)