# acthelen/battery_digital_twin architecture

> Architecture diagram of the GitHub repository acthelen/battery_digital_twin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/acthelen/battery_digital_twin
- Repository: https://github.com/acthelen/battery_digital_twin

## Overview

1. **Repository purpose**
   - This is a research artifact for a battery digital twin study, not an application service.
   - The repo’s main job is to take raw lithium iron phosphate (LFP) cell cycling data, build a reusable processed dataset, and reproduce particle-filter-based prognostics and retirement-optimization figures from the paper.

2. **Raw data layer**
   - The core inputs are the folders under `124 LFP Capacity Data/`, split into `train`, `test1`, `test2`, and `test3`.
   - Each split contains many per-cell CSV files (`cell1.csv`, `cell2.csv`, etc.), representing capacity trajectories or related cycle data for individual cells.
   - `124 LFP Cell Conditions.xlsx` appears to hold metadata or operating-condition labels for the cells and is part of the preprocessing boundary.

3. **Preprocessing / dataset assembly**
   - `create_capacity_dataset_from_raw_files.py` is the ingestion and normalization step.
   - It reads the raw CSV files and compiles them into a single serialized dataset, `capacity_dataset_124_lfp.pkl`.
   - This is the main data boundary in the repo: raw experimental files on one side, analysis-ready Python object on the other.

4. **Processed dataset as shared contract**
   - `capacity_dataset_124_lfp.pkl` is the artifact consumed by the analysis scripts.
   - It lets downstream scripts avoid re-parsing all the per-cell CSVs and provides a consistent representation of the 124-cell dataset used in the paper.

5. **Single-cell prognostics workflow**
   - `plot_pf_projection_each_cycle_single_cell.py` runs a particle filter on one selected cell.
   - Its role is explanatory and diagnostic: it shows how the estimated remaining useful life / capacity projection evolves cycle by cycle as more observations arrive.
   - The script generates the figure `Figures/pf_rul_prediction.pdf`, which captures the particle-filter trajectory over time for one cell.

6. **Multi-cell prognostics + decision workflow**
   - `run_pf_and_optimize_retirement_six_cells.py` is the higher-level analysis script.
   - It applies the particle filter to six randomly selected cells and then optimizes retirement decisions for each cell individually.
   - This script is where prediction and decision-making meet: prognostic uncertainty is translated into a retirement policy.

7. **Decision logic boundary: MAUT**
   - The retirement optimization uses multi-attribute utility theory (MAUT), as noted in the README.
   - Architecturally, this is the decision layer sitting on top of the predictive layer: particle-filter outputs feed into utility-based optimization.
   - The outputs correspond to the utility-focused figures in `Figures/`, including `Ah_utility.pdf`, `MTBC_utility.pdf`, and `utility_panel_cell27.pdf`.

8. **Outputs and reproducibility artifacts**
   - The `Figures/` directory contains pre-generated PDFs used in the paper.
   - These are not source inputs; they are rendered analysis outputs, showing capacity fade, particle-filter projections, RUL prediction, and utility tradeoffs.
   - `Figures/all_124_capacity_fade_curves.pdf` and `Figures/many_pf_trajectory_predictions.pdf` suggest broader dataset-level visual summaries, while the others are cell-specific or decision-specific.

9. **Data flow summary**
   - Raw cell CSVs + cell-condition spreadsheet → preprocessing script → serialized dataset (`.pkl`) → analysis scripts → particle-filter predictions and retirement optimization → PDF figures.
   - That pipeline is the central architecture of the repository.

10. **Repo boundaries and omissions**
   - There is no web UI, service layer, or database; the repo is a self-contained scientific computing workflow.
   - External dependencies are not explicitly listed here, but the architecture is clearly Python-based and oriented around offline analysis, serialization, and figure generation.
   - The README also documents that one anomalously fast-degrading cell from the original “124-cell” dataset was excluded from the study, which is a data curation decision relevant to interpreting the processed dataset.

Main entry points: [`create_capacity_dataset_from_raw_files.py`](https://github.com/acthelen/battery_digital_twin/blob/main/create_capacity_dataset_from_raw_files.py) (Build dataset), [`run_pf_and_optimize_retirement_six_cells.py`](https://github.com/acthelen/battery_digital_twin/blob/main/run_pf_and_optimize_retirement_six_cells.py) (Retirement opt), [`capacity_dataset_124_lfp.pkl`](https://github.com/acthelen/battery_digital_twin/blob/main/capacity_dataset_124_lfp.pkl) (Capacity dataset), [`plot_pf_projection_each_cycle_single_cell.py`](https://github.com/acthelen/battery_digital_twin/blob/main/plot_pf_projection_each_cycle_single_cell.py) (Single-cell PF)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_raw_data["Raw data"]
  node_train_split[("Train split<br/>cell CSV set")]
  node_test1_split[("Test 1<br/>cell CSV set")]
  node_test2_split[("Test 2<br/>cell CSV set")]
  node_test3_split[("Test 3<br/>cell CSV set")]
  node_cell_conditions["Cell conditions<br/>metadata spreadsheet"]
end

subgraph group_processing["Preprocessing"]
  node_dataset_builder["Build dataset<br/>ingestion script"]
  node_capacity_pickle[("Capacity dataset<br/>serialized dataset")]
end

subgraph group_analysis["Analysis"]
  node_single_cell_pf["Single-cell PF<br/>prognostics script"]
  node_multi_cell_pf["Six-cell PF<br/>analysis script"]
  node_retirement_optimizer{{"Retirement opt<br/>MAUT decision layer"}}
end

subgraph group_outputs["Figures"]
  node_capacity_fade_fig["Fade curves<br/>paper figure"]
  node_many_pf_fig["PF trajectories<br/>paper figure"]
  node_rul_fig["RUL figure<br/>paper figure"]
  node_ah_utility_fig["Ah utility<br/>paper figure<br/>[Ah_utility.pdf]"]
  node_mtbc_utility_fig["MTBC utility<br/>paper figure<br/>[MTBC_utility.pdf]"]
  node_utility_panel_fig["Utility panel<br/>paper figure"]
end

node_train_split -->|"raw CSVs"| node_dataset_builder
node_test1_split -->|"raw CSVs"| node_dataset_builder
node_test2_split -->|"raw CSVs"| node_dataset_builder
node_test3_split -->|"raw CSVs"| node_dataset_builder
node_cell_conditions -->|"metadata"| node_dataset_builder
node_dataset_builder -->|"writes"| node_capacity_pickle
node_capacity_pickle -->|"input"| node_single_cell_pf
node_capacity_pickle -->|"input"| node_multi_cell_pf
node_single_cell_pf -->|"renders"| node_rul_fig
node_multi_cell_pf -->|"prognostics"| node_retirement_optimizer
node_retirement_optimizer -->|"renders"| node_ah_utility_fig
node_retirement_optimizer -->|"renders"| node_mtbc_utility_fig
node_retirement_optimizer -->|"renders"| node_utility_panel_fig
node_multi_cell_pf -->|"renders"| node_many_pf_fig
node_dataset_builder -->|"renders"| node_capacity_fade_fig

click node_train_split "https://github.com/acthelen/battery_digital_twin/tree/main/124 LFP Capacity Data/train"
click node_test1_split "https://github.com/acthelen/battery_digital_twin/tree/main/124 LFP Capacity Data/test1"
click node_test2_split "https://github.com/acthelen/battery_digital_twin/tree/main/124 LFP Capacity Data/test2"
click node_test3_split "https://github.com/acthelen/battery_digital_twin/tree/main/124 LFP Capacity Data/test3"
click node_cell_conditions "https://github.com/acthelen/battery_digital_twin/blob/main/124 LFP Cell Conditions.xlsx"
click node_dataset_builder "https://github.com/acthelen/battery_digital_twin/blob/main/create_capacity_dataset_from_raw_files.py"
click node_capacity_pickle "https://github.com/acthelen/battery_digital_twin/blob/main/capacity_dataset_124_lfp.pkl"
click node_single_cell_pf "https://github.com/acthelen/battery_digital_twin/blob/main/plot_pf_projection_each_cycle_single_cell.py"
click node_multi_cell_pf "https://github.com/acthelen/battery_digital_twin/blob/main/run_pf_and_optimize_retirement_six_cells.py"
click node_retirement_optimizer "https://github.com/acthelen/battery_digital_twin/blob/main/run_pf_and_optimize_retirement_six_cells.py"
click node_capacity_fade_fig "https://github.com/acthelen/battery_digital_twin/blob/main/Figures/all_124_capacity_fade_curves.pdf"
click node_many_pf_fig "https://github.com/acthelen/battery_digital_twin/blob/main/Figures/many_pf_trajectory_predictions.pdf"
click node_rul_fig "https://github.com/acthelen/battery_digital_twin/blob/main/Figures/pf_rul_prediction.pdf"
click node_ah_utility_fig "https://github.com/acthelen/battery_digital_twin/blob/main/Figures/Ah_utility.pdf"
click node_mtbc_utility_fig "https://github.com/acthelen/battery_digital_twin/blob/main/Figures/MTBC_utility.pdf"
click node_utility_panel_fig "https://github.com/acthelen/battery_digital_twin/blob/main/Figures/utility_panel_cell27.pdf"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_train_split,node_test1_split,node_test2_split,node_test3_split,node_cell_conditions toneBlue
class node_dataset_builder,node_capacity_pickle toneAmber
class node_single_cell_pf,node_multi_cell_pf,node_retirement_optimizer toneMint
class node_capacity_fade_fig,node_many_pf_fig,node_rul_fig,node_ah_utility_fig,node_mtbc_utility_fig,node_utility_panel_fig toneRose
```

## Components

### Raw data

Experimental cell cycling inputs and metadata

- [Train split](https://github.com/acthelen/battery_digital_twin/tree/HEAD/124%20LFP%20Capacity%20Data/train): cell CSV set · Raw cycling data for training cells · `124 LFP Capacity Data/train`
- [Test 1](https://github.com/acthelen/battery_digital_twin/tree/HEAD/124%20LFP%20Capacity%20Data/test1): cell CSV set · Raw cycling data for one evaluation split · `124 LFP Capacity Data/test1`
- [Test 2](https://github.com/acthelen/battery_digital_twin/tree/HEAD/124%20LFP%20Capacity%20Data/test2): cell CSV set · Raw cycling data for one evaluation split · `124 LFP Capacity Data/test2`
- [Test 3](https://github.com/acthelen/battery_digital_twin/tree/HEAD/124%20LFP%20Capacity%20Data/test3): cell CSV set · Raw cycling data for one evaluation split · `124 LFP Capacity Data/test3`
- [Cell conditions](https://github.com/acthelen/battery_digital_twin/blob/HEAD/124%20LFP%20Cell%20Conditions.xlsx): metadata spreadsheet · Operating-condition and labeling metadata for cells · `124 LFP Cell Conditions.xlsx`

### Preprocessing

Dataset assembly boundary from raw files to reusable pickle

- [Build dataset](https://github.com/acthelen/battery_digital_twin/blob/main/create_capacity_dataset_from_raw_files.py): ingestion script · Reads raw CSVs and metadata, then assembles the processed capacity dataset · `create_capacity_dataset_from_raw_files.py`
- [Capacity dataset](https://github.com/acthelen/battery_digital_twin/blob/main/capacity_dataset_124_lfp.pkl): serialized dataset · Shared processed representation consumed by analysis scripts · `capacity_dataset_124_lfp.pkl`

### Analysis

Particle-filter prognostics and retirement optimization

- [Single-cell PF](https://github.com/acthelen/battery_digital_twin/blob/main/plot_pf_projection_each_cycle_single_cell.py): prognostics script · Runs particle filter projections cycle by cycle for one selected cell · `plot_pf_projection_each_cycle_single_cell.py`
- [Six-cell PF](https://github.com/acthelen/battery_digital_twin/blob/main/run_pf_and_optimize_retirement_six_cells.py): analysis script · Applies particle filtering to multiple cells and prepares prognostic trajectories · `run_pf_and_optimize_retirement_six_cells.py`
- [Retirement opt](https://github.com/acthelen/battery_digital_twin/blob/main/run_pf_and_optimize_retirement_six_cells.py): MAUT decision layer · Converts prognostic uncertainty into utility-based retirement decisions · `run_pf_and_optimize_retirement_six_cells.py`

### Figures

Rendered paper figures

- [Fade curves](https://github.com/acthelen/battery_digital_twin/blob/main/Figures/all_124_capacity_fade_curves.pdf): paper figure · Dataset-level capacity degradation summary · `Figures/all_124_capacity_fade_curves.pdf`
- [PF trajectories](https://github.com/acthelen/battery_digital_twin/blob/main/Figures/many_pf_trajectory_predictions.pdf): paper figure · Multiple particle-filter prediction trajectories across cells · `Figures/many_pf_trajectory_predictions.pdf`
- [RUL figure](https://github.com/acthelen/battery_digital_twin/blob/main/Figures/pf_rul_prediction.pdf): paper figure · Cycle-by-cycle remaining-useful-life projection for one cell · `Figures/pf_rul_prediction.pdf`
- [Ah utility](https://github.com/acthelen/battery_digital_twin/blob/main/Figures/Ah_utility.pdf): paper figure · Utility tradeoff figure for amp-hour based decision criteria · `Figures/Ah_utility.pdf`
- [MTBC utility](https://github.com/acthelen/battery_digital_twin/blob/main/Figures/MTBC_utility.pdf): paper figure · Utility tradeoff figure for mean time / cycle-based decision criteria · `Figures/MTBC_utility.pdf`
- [Utility panel](https://github.com/acthelen/battery_digital_twin/blob/main/Figures/utility_panel_cell27.pdf): paper figure · Cell-specific utility panel for retirement analysis · `Figures/utility_panel_cell27.pdf`

## Connections

- Train split → Build dataset: raw CSVs · Training split ingested during dataset assembly
- Test 1 → Build dataset: raw CSVs · Evaluation split ingested during dataset assembly
- Test 2 → Build dataset: raw CSVs · Evaluation split ingested during dataset assembly
- Test 3 → Build dataset: raw CSVs · Evaluation split ingested during dataset assembly
- Cell conditions → Build dataset: metadata · Spreadsheet supplies cell-condition labels and context
- Build dataset → Capacity dataset: writes · Build step serializes the reusable dataset
- Capacity dataset → Single-cell PF: input · Processed dataset consumed by single-cell prognostics
- Capacity dataset → Six-cell PF: input · Processed dataset consumed by multi-cell analysis
- Single-cell PF → RUL figure: renders · Single-cell prognostics generate the RUL figure
- Six-cell PF → Retirement opt: prognostics · Predictions feed the utility-based retirement layer
- Retirement opt → Ah utility: renders · Utility outputs are visualized as Ah figure
- Retirement opt → MTBC utility: renders · Utility outputs are visualized as MTBC figure
- Retirement opt → Utility panel: renders · Utility outputs are visualized for a representative cell panel
- Six-cell PF → PF trajectories: renders · Multi-cell particle-filter trajectories are plotted
- Build dataset → Fade curves: renders · Processed dataset supports capacity fade summary plot
