Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EV Simulator

A modular, object-oriented Python package for 1D backward-facing EV longitudinal simulation over a WLTC drive cycle.

Features

  • Road-load force model: rolling, aerodynamic, grade, inertial
  • Backward-facing torque/speed propagation from wheel to motor
  • Motor and battery efficiency handling with regeneration logic
  • Cycle energy integration and key performance indicators (KPIs)
  • Sensitivity sweeps for:
    • Aerodynamic drag coefficient (2.0 to 5.0 in 0.1 steps)
    • Transmission ratio (15 to 30 in 1 steps)
  • Plotly visualizations
  • Progress bars with tqdm

Project Structure

ev_simulator/
    __init__.py
    vehicle.py
    drivetrain.py
    motor.py
    battery.py
    drivecycle.py
    simulator.py
    postprocess.py
    sensitivity.py
    config.py

tests/
    test_imports.py

notebooks/
    example_usage.ipynb

scripts/
    run_simulation.py

Installation

pip install -e .

Install dev tools:

pip install pre-commit pytest
pre-commit install

Quick Run

python scripts/run_simulation.py

Outputs are written to results/:

  • KPI printout (console)
  • Timeseries summary + operating-point plots (.html)
  • Sensitivity plots (.html)
  • Sensitivity data (.csv)

WLTC Data

A packaged 1 Hz WLTC-style CSV is included at:

  • ev_simulator/data/wltc_class3_sample.csv

Expected CSV columns (loadable with DriveCycle.from_csv):

  • time_s
  • speed_mps or speed_kph
  • optional grade

API Example

from ev_simulator.config import EVConfig
from ev_simulator.drivecycle import DriveCycle
from ev_simulator.simulator import BackwardFacingSimulator
from ev_simulator.postprocess import PostProcessor

cfg = EVConfig()
cycle = DriveCycle.from_csv(cfg.wltc_csv_path, speed_col="speed_kph", speed_unit="kph")
sim = BackwardFacingSimulator.from_config(cfg)
result = sim.run(cycle)
post = PostProcessor(result)
kpis = post.compute_kpis()
fig = post.plot_timeseries_data()

Tests

pytest

Formatting and Linting

Configured in pyproject.toml and .pre-commit-config.yaml:

  • Ruff
  • Black
  • isort

About

python script to calculate parameters in longitudinal simulation for electric vehicles.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages