Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Battery Simulation & Data Pipeline Take-Home Assessment


Database Query CLI (src.query)

A lightweight command-line tool that answers the four Phase 3 query patterns directly from the SQLite database. It prints results to the terminal and, where applicable, generates plots into outputs/plots/cycle_N/.

Prerequisites

The database must already be populated (Phases 1–4):

python -m src.clean
python -m src.simulate
python -m src.database
python -m src.visualize

Commands

1. Show all cycles for a cell

python -m src.query cycles CELL_A

Prints every cycle recorded for the cell together with point count, duration, and voltage range.

2. Compare simulation vs experiment for one cell and cycle

python -m src.query compare CELL_A 2

Computes RMSE for each model config that has simulation data for this cell/cycle, prints the values, and saves an overlay plot to outputs/plots/cycle_2/compare_CELL_A_cycle2.png.

3. List all parameter sets used with a given model type

python -m src.query params DFN

Lists every model_configs row whose model_type matches, along with the number of cell-cycles that have simulation results under that config.

4. Show voltage curves for all cells under a model config

python -m src.query voltage DFN Chen2020
python -m src.query voltage DFN Mohtat2020 --cycle 3

Plots simulated voltage curves for every cell that was run with the given model/parameter-set combination. Without --cycle, generates one plot per available cycle. With --cycle N, restricts to that single cycle. Plots are saved to outputs/plots/cycle_N/voltage_all_cells_<param_set>_cycleN.png.


Multi-cycle concatenated plots (src.visualize)

src.visualize can also produce one long voltage trace by placing every available cycle back-to-back on a cumulative time axis (spacing follows each cycle’s experimental duration). The plot includes experiment vs simulation for that cell’s parameter set (Chen2020 or Mohtat2020), gray dotted vertical lines at cycle boundaries, and the mean per-cycle RMSE in the title.

Commands

python -m src.visualize --concat CELL_A
python -m src.visualize --concat-all
  • --concatone cell; if you omit the cell id, it defaults to CELL_A (python -m src.visualize --concat is the same as --concat CELL_A).
  • --concat-all — runs --concat for every cell (CELL_ACELL_E).

Output

Files are written to:

outputs/plots/combined/concatenated_<CELL_ID>_<parameter_set>_cycles<first>_<last>.png

Example: concatenated_CELL_A_Chen2020_cycles1_10.png.

Requires the same populated database as the per-cycle plots (python -m src.database).


SoC over concatenated cycles (src.soc_track)

Estimates state of charge on the same cumulative time axis as the concatenated voltage plot, using:

  • Coulomb counting (main curve): per cycle, initial SoC from OCV inversion of the first voltage sample (same PyBaMM DFN “1 s rest” OCV table as estimate_initial_soc in src.simulate), then trapezoidal integration of experimental current_A with that cycle’s protocol capacity (Ah) from estimate_capacity(extract_protocol(...)).
  • OCV lookup (sparse scatter): SoC from voltage only where |I| < 5 mA (approximate rest). Under load, voltage ≠ OCV, so those points are not shown.

Commands

python -m src.soc_track CELL_A
python -m src.soc_track --all

Output

Written next to the concatenated figures:

  • outputs/plots/combined/soc_concat_<CELL_ID>_<parameter_set>.png
  • outputs/plots/combined/soc_concat_<CELL_ID>_<parameter_set>.csv

Needs experimental_data in SQLite (run python -m src.database) and data/cleaned_cycling_data.csv for per-cycle capacity extraction.


ML residual correction (src.mlopt, optional)

Trains a GradientBoostingRegressor to predict DFN voltage error V_exp − V_sim from (time, current, coulomb SoC, temperature) on cycle 2, adds the prediction to the DFN curve, and writes plots to outputs/plots/mlopt/. Uses a time-ordered 70% / 30% train–test split for reported test RMSE.

python -m src.mlopt

About

Battery Data Pipeline Data Cleaning, Simulation, Database, Visualization

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages