celltwin 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. celltwin-0.3.0/.gitignore +38 -0
  2. celltwin-0.3.0/CHANGELOG.md +286 -0
  3. celltwin-0.3.0/CONTRIBUTING.md +61 -0
  4. celltwin-0.3.0/LICENSE +21 -0
  5. celltwin-0.3.0/PKG-INFO +523 -0
  6. celltwin-0.3.0/README.md +480 -0
  7. celltwin-0.3.0/datasets/synthetic/README.md +29 -0
  8. celltwin-0.3.0/docs/ageing.md +116 -0
  9. celltwin-0.3.0/docs/api.md +77 -0
  10. celltwin-0.3.0/docs/data-format.md +99 -0
  11. celltwin-0.3.0/docs/datasets/lg_hg2.md +580 -0
  12. celltwin-0.3.0/docs/datasets/nasa.md +151 -0
  13. celltwin-0.3.0/docs/datasets/samsung_50e.md +219 -0
  14. celltwin-0.3.0/docs/datasets/samsung_50e_rehearsal.md +267 -0
  15. celltwin-0.3.0/docs/datasets/stanford_m50t.md +239 -0
  16. celltwin-0.3.0/docs/digital-twin.md +244 -0
  17. celltwin-0.3.0/docs/electrochemical.md +142 -0
  18. celltwin-0.3.0/docs/getting-started.md +131 -0
  19. celltwin-0.3.0/docs/images/calibration_fit.png +0 -0
  20. celltwin-0.3.0/docs/images/calibration_states.png +0 -0
  21. celltwin-0.3.0/docs/images/lg_hg2_digital_twin.png +0 -0
  22. celltwin-0.3.0/docs/images/lg_hg2_electrochemical.png +0 -0
  23. celltwin-0.3.0/docs/images/lg_hg2_hppc_pulses.png +0 -0
  24. celltwin-0.3.0/docs/images/lg_hg2_model_comparison.png +0 -0
  25. celltwin-0.3.0/docs/images/lg_hg2_ocv.png +0 -0
  26. celltwin-0.3.0/docs/images/lg_hg2_parameter_tracking.png +0 -0
  27. celltwin-0.3.0/docs/images/lg_hg2_soc_parameters.png +0 -0
  28. celltwin-0.3.0/docs/images/lg_hg2_state_estimation.png +0 -0
  29. celltwin-0.3.0/docs/images/lg_hg2_temperature_arrhenius.png +0 -0
  30. celltwin-0.3.0/docs/images/lg_hg2_temperature_rmse.png +0 -0
  31. celltwin-0.3.0/docs/images/lg_hg2_temperature_us06_n20.png +0 -0
  32. celltwin-0.3.0/docs/images/lg_hg2_thermal.png +0 -0
  33. celltwin-0.3.0/docs/images/lg_hg2_us06_prediction.png +0 -0
  34. celltwin-0.3.0/docs/images/lg_hg2_us06_selected_prediction.png +0 -0
  35. celltwin-0.3.0/docs/images/lg_hg2_validation_rmse.png +0 -0
  36. celltwin-0.3.0/docs/images/nasa_ageing.png +0 -0
  37. celltwin-0.3.0/docs/images/nasa_capacity_fade.png +0 -0
  38. celltwin-0.3.0/docs/images/ocv_curve.png +0 -0
  39. celltwin-0.3.0/docs/images/samsung_50e_ageing.png +0 -0
  40. celltwin-0.3.0/docs/images/stanford_aged_capacity.png +0 -0
  41. celltwin-0.3.0/docs/images/stanford_aged_resistance.png +0 -0
  42. celltwin-0.3.0/docs/images/validation_prediction.png +0 -0
  43. celltwin-0.3.0/docs/index.md +52 -0
  44. celltwin-0.3.0/docs/javascripts/mathjax.js +4 -0
  45. celltwin-0.3.0/docs/parameter-estimation.md +238 -0
  46. celltwin-0.3.0/docs/parameter-tracking.md +232 -0
  47. celltwin-0.3.0/docs/persistence.md +161 -0
  48. celltwin-0.3.0/docs/roadmap.md +57 -0
  49. celltwin-0.3.0/docs/state-estimation.md +251 -0
  50. celltwin-0.3.0/docs/theory.md +267 -0
  51. celltwin-0.3.0/docs/thermal.md +98 -0
  52. celltwin-0.3.0/docs/validation.md +191 -0
  53. celltwin-0.3.0/examples/end_to_end_synthetic.py +208 -0
  54. celltwin-0.3.0/examples/lg_hg2_digital_twin.py +480 -0
  55. celltwin-0.3.0/examples/lg_hg2_electrochemical.py +351 -0
  56. celltwin-0.3.0/examples/lg_hg2_parameter_tracking.py +388 -0
  57. celltwin-0.3.0/examples/lg_hg2_state_estimation.py +403 -0
  58. celltwin-0.3.0/examples/lg_hg2_temperature.py +595 -0
  59. celltwin-0.3.0/examples/lg_hg2_thermal.py +312 -0
  60. celltwin-0.3.0/examples/lg_hg2_validation.py +592 -0
  61. celltwin-0.3.0/examples/nasa_ageing.py +249 -0
  62. celltwin-0.3.0/examples/nasa_validation.py +240 -0
  63. celltwin-0.3.0/examples/samsung_50e_ageing.py +517 -0
  64. celltwin-0.3.0/examples/samsung_50e_rehearsal.py +778 -0
  65. celltwin-0.3.0/examples/sdk_quickstart.py +70 -0
  66. celltwin-0.3.0/examples/stanford_aged_capacity.py +337 -0
  67. celltwin-0.3.0/examples/stanford_aged_resistance.py +361 -0
  68. celltwin-0.3.0/mkdocs.yml +62 -0
  69. celltwin-0.3.0/pyproject.toml +122 -0
  70. celltwin-0.3.0/scripts/check_distribution.py +67 -0
  71. celltwin-0.3.0/src/celltwin/__init__.py +119 -0
  72. celltwin-0.3.0/src/celltwin/core/__init__.py +13 -0
  73. celltwin-0.3.0/src/celltwin/core/history.py +252 -0
  74. celltwin-0.3.0/src/celltwin/core/persistence.py +372 -0
  75. celltwin-0.3.0/src/celltwin/core/twin.py +1078 -0
  76. celltwin-0.3.0/src/celltwin/data/__init__.py +55 -0
  77. celltwin-0.3.0/src/celltwin/data/adapters/__init__.py +61 -0
  78. celltwin-0.3.0/src/celltwin/data/adapters/mcmaster.py +248 -0
  79. celltwin-0.3.0/src/celltwin/data/adapters/nasa.py +387 -0
  80. celltwin-0.3.0/src/celltwin/data/adapters/stanford.py +216 -0
  81. celltwin-0.3.0/src/celltwin/data/dataset.py +274 -0
  82. celltwin-0.3.0/src/celltwin/data/loader.py +305 -0
  83. celltwin-0.3.0/src/celltwin/data/preprocessing.py +386 -0
  84. celltwin-0.3.0/src/celltwin/data/synthetic.py +528 -0
  85. celltwin-0.3.0/src/celltwin/data/validation.py +397 -0
  86. celltwin-0.3.0/src/celltwin/estimation/__init__.py +106 -0
  87. celltwin-0.3.0/src/celltwin/estimation/ageing_fitting.py +403 -0
  88. celltwin-0.3.0/src/celltwin/estimation/capacity.py +489 -0
  89. celltwin-0.3.0/src/celltwin/estimation/checkpoint.py +220 -0
  90. celltwin-0.3.0/src/celltwin/estimation/electrochemical_fitting.py +296 -0
  91. celltwin-0.3.0/src/celltwin/estimation/metrics.py +94 -0
  92. celltwin-0.3.0/src/celltwin/estimation/ocv_extraction.py +225 -0
  93. celltwin-0.3.0/src/celltwin/estimation/parameter_fitting.py +966 -0
  94. celltwin-0.3.0/src/celltwin/estimation/parameter_tracking.py +355 -0
  95. celltwin-0.3.0/src/celltwin/estimation/prediction.py +290 -0
  96. celltwin-0.3.0/src/celltwin/estimation/resistance.py +142 -0
  97. celltwin-0.3.0/src/celltwin/estimation/soc_dependent_fitting.py +558 -0
  98. celltwin-0.3.0/src/celltwin/estimation/state_estimation.py +1004 -0
  99. celltwin-0.3.0/src/celltwin/estimation/temperature.py +643 -0
  100. celltwin-0.3.0/src/celltwin/estimation/thermal_fitting.py +187 -0
  101. celltwin-0.3.0/src/celltwin/exceptions.py +70 -0
  102. celltwin-0.3.0/src/celltwin/models/__init__.py +81 -0
  103. celltwin-0.3.0/src/celltwin/models/degradation.py +313 -0
  104. celltwin-0.3.0/src/celltwin/models/electrical.py +1300 -0
  105. celltwin-0.3.0/src/celltwin/models/electrochemical.py +515 -0
  106. celltwin-0.3.0/src/celltwin/models/ocv.py +268 -0
  107. celltwin-0.3.0/src/celltwin/models/temperature.py +318 -0
  108. celltwin-0.3.0/src/celltwin/models/thermal.py +325 -0
  109. celltwin-0.3.0/src/celltwin/py.typed +0 -0
  110. celltwin-0.3.0/src/celltwin/utils/__init__.py +6 -0
  111. celltwin-0.3.0/src/celltwin/utils/arrays.py +66 -0
  112. celltwin-0.3.0/src/celltwin/utils/units.py +121 -0
  113. celltwin-0.3.0/src/celltwin/visualization/__init__.py +31 -0
  114. celltwin-0.3.0/src/celltwin/visualization/plots.py +332 -0
  115. celltwin-0.3.0/tests/conftest.py +67 -0
  116. celltwin-0.3.0/tests/test_charge_transfer.py +268 -0
  117. celltwin-0.3.0/tests/test_checkpoints.py +232 -0
  118. celltwin-0.3.0/tests/test_concentration.py +328 -0
  119. celltwin-0.3.0/tests/test_data_ingestion.py +208 -0
  120. celltwin-0.3.0/tests/test_digital_twin_layer.py +514 -0
  121. celltwin-0.3.0/tests/test_electrical_model.py +210 -0
  122. celltwin-0.3.0/tests/test_electrochemical.py +331 -0
  123. celltwin-0.3.0/tests/test_mcmaster_adapter.py +188 -0
  124. celltwin-0.3.0/tests/test_nasa_adapter.py +249 -0
  125. celltwin-0.3.0/tests/test_ocv.py +111 -0
  126. celltwin-0.3.0/tests/test_parameter_fitting.py +224 -0
  127. celltwin-0.3.0/tests/test_parameter_tracking.py +601 -0
  128. celltwin-0.3.0/tests/test_persistence.py +233 -0
  129. celltwin-0.3.0/tests/test_preprocessing.py +135 -0
  130. celltwin-0.3.0/tests/test_rc2_hysteresis.py +307 -0
  131. celltwin-0.3.0/tests/test_samsung_example.py +129 -0
  132. celltwin-0.3.0/tests/test_sdk_api.py +120 -0
  133. celltwin-0.3.0/tests/test_soc_dependent.py +280 -0
  134. celltwin-0.3.0/tests/test_stanford_adapter.py +260 -0
  135. celltwin-0.3.0/tests/test_state_estimation.py +445 -0
  136. celltwin-0.3.0/tests/test_synthetic_and_plots.py +86 -0
  137. celltwin-0.3.0/tests/test_temperature.py +330 -0
  138. celltwin-0.3.0/tests/test_thermal_ageing.py +484 -0
  139. celltwin-0.3.0/tests/test_twin.py +114 -0
  140. celltwin-0.3.0/tests/test_units.py +36 -0
  141. celltwin-0.3.0/tests/typing/public_api.py +96 -0
@@ -0,0 +1,38 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ build/
6
+ dist/
7
+ .eggs/
8
+
9
+ # Environments
10
+ .venv/
11
+ venv/
12
+ .env
13
+
14
+ # Tooling
15
+ .pytest_cache/
16
+ .ruff_cache/
17
+ .mypy_cache/
18
+ .coverage
19
+ coverage.xml
20
+ htmlcov/
21
+
22
+ # Docs build
23
+ site/
24
+
25
+ # Example output (regenerated by examples/end_to_end_synthetic.py)
26
+ examples/output/
27
+ sdk-output/
28
+
29
+ # Notebooks
30
+ .ipynb_checkpoints/
31
+
32
+ # OS / editors
33
+ .DS_Store
34
+ .idea/
35
+ .vscode/
36
+
37
+ # Third-party raw datasets (downloaded locally, never committed)
38
+ datasets/external/
@@ -0,0 +1,286 @@
1
+ # Changelog
2
+
3
+ All notable changes are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
5
+ [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.3.0] - 2026-12-05
10
+
11
+ First release on PyPI.
12
+
13
+ ### Added
14
+
15
+ - `load_stanford_test` reads the capacity, pulse and ageing records of the Stanford
16
+ INR21700-M50T ageing dataset (CC BY 4.0, downloaded by the user).
17
+ - `examples/stanford_aged_capacity.py` and its results page: a check of capacity
18
+ estimation on one ageing cell over eleven check-ups. At the ten aged ones it read
19
+ 0.4–2.8 % low while the measured capacity fell 6 %. One cell is not a validation.
20
+ - `examples/stanford_aged_resistance.py`: the parameter tracker on the same cell. Its
21
+ resistance did not grow, so it could not test growth tracking. With a calibrated
22
+ hysteresis model and only a discharge OCV curve, capacity read 2.0–4.6 % high.
23
+ - `examples/samsung_50e_ageing.py` and its results page: resistance and capacity
24
+ tracking on a cell whose resistance grew about 20 %. The resistance factor followed
25
+ the growth, as did a model-free step ratio; capacity read about 3 % high, about half
26
+ of it from the hysteresis correction at rests. Two ageing cells are not a validation.
27
+ - `CapacityEstimator` settings `rest_hysteresis_v` and `hysteresis_uncertainty`.
28
+ - `fit_thevenin_soc_dependent(smoothing_order=1)`: penalize differences between
29
+ neighbouring SOC breakpoints, so thinly measured breakpoints keep their neighbours'
30
+ value.
31
+ - `PseudoOCVResult.hysteresis_bound_v`: an upper bound on the hysteresis magnitude from
32
+ a low-rate charge and discharge test.
33
+ - `examples/samsung_50e_rehearsal.py` and its results page: one ageing cell's records
34
+ ingested in order and scored against pass marks. The twin did not pass, also with a
35
+ model calibrated at three temperatures, which tracked resistance better on average.
36
+ A revised model (resistances over SOC, bounded hysteresis) lets the corrections
37
+ improve cycling predictions late in life; the rehearsal still does not pass.
38
+
39
+ ### Changed
40
+
41
+ - With a hysteresis model, the capacity standard deviation now includes the uncertainty
42
+ of the hysteresis correction, which does not average out over rests. It is larger than
43
+ before; the capacity estimate is unchanged.
44
+ - `CapacitySegment` has a `soc_change_bias` field, and history files are written with
45
+ `schema_version` 2. Version 1 files are still read.
46
+ - Releases are published to PyPI from GitHub by trusted publishing.
47
+
48
+ ## [0.2.0] - 2026-12-03
49
+
50
+ Not published to PyPI.
51
+
52
+ ### Added
53
+
54
+ - `ThermalParameters`, `AgeingParameters` and `ElectrochemicalModel` have `save` and
55
+ `load` (versioned JSON, atomic writes, strict validation).
56
+ - `ModelVersion` is exported from `celltwin`; `CellHistory`, `HistoryRecord`,
57
+ `ModelVersion` and `RecalibrationReport` from `celltwin.core`. The API reference now
58
+ covers the OCV extraction and dataset adapter modules.
59
+ - Optional electrochemical models (`pip install celltwin[pybamm]`): `ElectrochemicalModel`
60
+ runs PyBaMM's SPM and SPMe with CellTwin's conventions and adapts a parameter set to a
61
+ cell; `fit_stoichiometry_window` and `fit_electrochemical` fit it. Runs stop, with NaN
62
+ voltages, where the electrolyte is depleted. On the LG HG2 at 25 degC with another
63
+ cell's parameter set they are **worse than the equivalent-circuit model**: the SPM
64
+ matches it on one of seven drive cycles, and the fitted SPMe cannot finish them.
65
+ - `examples/lg_hg2_electrochemical.py`, a guide, and a CI job that installs PyBaMM.
66
+ - Lumped thermal model (`ThermalParameters`, `simulate_temperature`,
67
+ `heat_generation_w`, `fit_thermal`) and coupled electrothermal simulation
68
+ (`ElectroThermalModel`). On the LG HG2, median temperature RMSE on test cycles is
69
+ 0.12-0.43 K from the current alone; the fitted values are effective ones for that
70
+ fixture.
71
+ - Semi-empirical ageing model (`AgeingParameters`, `UsageProfile`, `simulate_ageing`,
72
+ `fit_ageing`, `forecast_ageing`, `aged_parameters`). On NASA batteries 5, 6, 7 and 18
73
+ its forecasts are **not reliable**: the fitted power law beats a straight line in 2 of
74
+ 8 capacity forecasts. Calendar, temperature and stress dependence are unvalidated.
75
+ - `examples/lg_hg2_thermal.py`, `examples/nasa_ageing.py` and guides for both models.
76
+ - Digital-twin layer: `DigitalTwin.update` ingests records into a persistent
77
+ `CellHistory` (capacity segments and resistance factor carried between sessions, a
78
+ baseline for state-of-health ratios, factors tied to the parameter set they were
79
+ measured against); `DigitalTwin.recalibrate` adopts refitted parameters only if they
80
+ predict a separate record better, with `rollback`; `predict_ahead` gives voltage, SOC
81
+ and cut-off-time quantiles from the filter's estimate.
82
+ - `ParameterTracker(resistance_baseline=...)` and
83
+ `CapacityEstimator(previous_segments=...)`.
84
+ - `examples/lg_hg2_digital_twin.py` and a digital-twin guide.
85
+ On one new LG cell the prediction bands are too narrow, badly so in the cold; nothing
86
+ has been validated on an ageing cell.
87
+ - Online parameter tracking (`ParameterTracker`, `DigitalTwin.parameter_tracker`):
88
+ `CapacityEstimator` measures total capacity from counted charge between rested-OCV
89
+ readings by weighted total least squares; `ResistanceEstimator` measures a factor on
90
+ R0 plus the Butler-Volmer drop from voltage changes over 1 s windows. Corrections go
91
+ to the filter through `ExtendedKalmanFilter.set_parameter_corrections`; the tracker
92
+ applies capacity by default and resistance only relative to a baseline or with
93
+ `apply_resistance=True`.
94
+ - `examples/lg_hg2_parameter_tracking.py` and a parameter-tracking guide.
95
+
96
+ ### Changed
97
+
98
+ - EKF checkpoints use schema version 2, which adds the parameter corrections; version 1
99
+ files are still read.
100
+
101
+ ### Fixed
102
+
103
+ - `fit_ageing` failed with a misleading message if any record had no observed loss.
104
+ - `UsageProfile` and `AgeingRecord` built directly, not through `from_arrays`, were not
105
+ validated.
106
+ - `measured_heat_w` accepted a negative or infinite capacity and returned wrong heat.
107
+ - `fit_thermal` and `fit_electrochemical` rejected bounds that excluded their own
108
+ default initial guess.
109
+ - An `ambient_c` of the wrong length raised a NumPy error instead of `ParameterError`.
110
+ - Results from one prepared electrochemical record shared their time, current and SOC
111
+ arrays with each other and with the caller.
112
+
113
+ ### Also added since 0.1.0
114
+
115
+ - Live EKF checkpoint/resume: self-contained, versioned JSON preserves model, noise,
116
+ mean, full covariance, previous input/temperature/time, fixed capacity and last
117
+ voltage-update time. Atomic writes and strict structural/numerical validation.
118
+ - Exact restart tests across all model types, both input interpolations, optional
119
+ current bias and missing-voltage gaps, including a fresh Python process. The SDK
120
+ quickstart now demonstrates resuming an online filter midway through a record.
121
+
122
+ - SDK persistence: `DigitalTwin.save` / `DigitalTwin.load` with versioned JSON for
123
+ all parameter types, OCV, operating settings and calibration provenance. Atomic
124
+ writes, explicit overwrite, strict format validation and prediction round-trip tests.
125
+ Model snapshots do not contain raw data, result histories or a running EKF.
126
+ - `py.typed`, package and consumer mypy checks, and a CI job validating the sdist/wheel
127
+ in a fresh virtual environment outside the source checkout.
128
+ - Standalone `examples/sdk_quickstart.py`, persistence/API compatibility documentation,
129
+ and expanded API reference. Constructor validation for interpolation and rest threshold;
130
+ explicit guidance when a temperature model is passed to SOC-only fitting.
131
+
132
+ - State estimation: `ExtendedKalmanFilter` estimates SOC and every other model state
133
+ (RC voltages, hysteresis, diffusion state) from measured current, voltage and,
134
+ where needed, temperature.
135
+ - Works with constant, SOC-dependent and temperature-dependent parameters and with
136
+ the Butler-Volmer and concentration terms.
137
+ - Uses the simulator's exact discretization, so without updates it reproduces
138
+ `TheveninModel.simulate`. Joseph-form covariance update.
139
+ - Batch (`run` → `StateEstimationResult`) and online (`reset`/`step` →
140
+ `StateEstimate`) use. Missing voltages skip the update and are never filled.
141
+ - `EKFNoise` noise model, including a voltage-error correlation time that inflates
142
+ the update variance for autocorrelated model error. `EKFNoise.from_residuals` and
143
+ `voltage_error_statistics` identify it from open-loop residuals.
144
+ - Optional current-sensor offset state (`current_bias=True`, state `i_bias`,
145
+ random walk `EKFNoise.current_bias_rate`); all state equations and the voltage
146
+ use the corrected current.
147
+ - `DigitalTwin.estimate_states` and `DigitalTwin.state_estimator`.
148
+ - `examples/lg_hg2_state_estimation.py`: unknown-initial-SOC and biased-current-sensor
149
+ scenarios on held-out LG HG2 drive cycles at six temperatures, with and without the
150
+ offset state.
151
+ - `OCVCurve.derivative` builds the PCHIP derivative once and caches it.
152
+ - Concentration (diffusion) overpotential: a dimensionless diffusion state x with
153
+ τ_d dx/dt = I/I_lim − x (integrated exactly) and η_c = (RT/F)·ln((1+x)/(1−x)),
154
+ using the measured cell temperature. Two new parameters: limiting current `ILIM`
155
+ (`limiting_current_a`) and diffusion time constant `TAUD` (`diffusion_time_s`).
156
+ - Supported in constant, SOC-dependent and temperature-dependent parameters, in
157
+ `fit_thevenin`, `fit_thevenin_soc_dependent`, `fit_thevenin_arrhenius` and
158
+ `DigitalTwin`.
159
+ - Where the limiting current is sustained (|x| ≥ 1) the terminal voltage is NaN
160
+ and an `OperatingLimitWarning` is issued. By default the fitted `ILIM` is bounded
161
+ below by the largest calibration current (`limiting_current_floor`).
162
+ - `SimulationResult` reports `diffusion_state` and `concentration_overpotential_v`.
163
+ `concentration_overpotential` and `integrate_diffusion_state` are exported from
164
+ `celltwin.models`.
165
+ - LG HG2 examples include the term (25 °C structure selection; B, C and E at all six
166
+ temperatures).
167
+ - Current-dependent resistance: optional symmetric Butler-Volmer charge-transfer
168
+ overpotential η = (RT/αF)·asinh(I/2I0), α = 0.5, using the measured cell
169
+ temperature. One new parameter, the cell-level exchange current I0 [A]
170
+ (`exchange_current_a`, symbol `I0`).
171
+ - Supported in `TheveninParameters`, `SOCDependentParameters` (scalar I0) and
172
+ `TemperatureDependentParameters` (I0 interpolated in temperature).
173
+ - `TheveninModel.simulate` requires `temperature_c` when the term is present and
174
+ reports `charge_transfer_overpotential_v`. `charge_transfer_overpotential` is
175
+ exported from `celltwin.models`.
176
+ - `fit_thevenin`, `fit_thevenin_soc_dependent` and `fit_thevenin_arrhenius` estimate
177
+ `I0`. The first two take a new `temperature_c` argument; the global fit uses each
178
+ record's measured temperature. `DigitalTwin` passes the dataset temperature
179
+ automatically.
180
+ - LG HG2 examples compare models with and without the term (25 °C structure
181
+ selection and all six temperatures).
182
+ - `TemperatureDependentParameters`: one parameter set per calibration temperature
183
+ (constant or SOC tables), with piecewise-Arrhenius interpolation (ln p linear in 1/T)
184
+ and end values held.
185
+ - `TheveninModel.simulate(temperature_c=...)` schedules parameters on the measured
186
+ cell temperature.
187
+ - `DigitalTwin.evaluate` uses the dataset's temperature automatically.
188
+ - `fit_arrhenius` / `ArrheniusFit`: apparent activation energies of calibrated
189
+ parameters.
190
+ - `fit_thevenin_arrhenius` / `CalibrationRecord` / `ArrheniusModelFit`: joint fit of
191
+ Arrhenius laws (reference value plus activation energy per parameter, optional
192
+ shared-activation R0 SOC table) to several calibration tests. It uses each sample's
193
+ measured temperature and defaults to a centroid reference temperature.
194
+ - `examples/lg_hg2_temperature.py`: calibration at all six LG HG2 temperatures and a
195
+ six-model comparison on held-out drive cycles, including two
196
+ leave-one-temperature-out variants. Data problems found (10 °C LA92, 40 °C Mixed4–8,
197
+ missing Mixed3) are documented.
198
+ - Optional second RC branch (`r2_ohm`, `c2_farad`) and one-state hysteresis
199
+ (`hysteresis_v` M, `hysteresis_rate` γ) in `TheveninParameters` and
200
+ `SOCDependentParameters`.
201
+ - Exact discrete-time integration (`integrate_hysteresis`).
202
+ - `initial_hysteresis` in simulation, fitting and evaluation.
203
+ - Per-branch voltages and the hysteresis state in `SimulationResult`.
204
+ - `fit_thevenin` estimates `R2`, `C2`, `M` and `GAMMA`; the model structure follows from
205
+ the estimated or supplied symbols.
206
+ - `fit_thevenin_soc_dependent` tabulates R2/C2 and estimates M/γ as scalars.
207
+ - A note is issued when RC branch 1 ends up slower than branch 2.
208
+ - LG HG2 example: model-structure selection over eight candidates, plus a drive-cycle
209
+ calibration diagnostic.
210
+ - The selected model (1RC + hysteresis + R0(SOC)) lowers the test median RMSE from
211
+ 34.0 to 27.5 mV and US06 from 42.3 to 25.6 mV.
212
+ - The second RC branch does not improve prediction when calibrated on HPPC.
213
+
214
+ - `SOCDependentParameters`: R0, R1 and C1 as look-up tables over SOC. Linear
215
+ interpolation, end values held.
216
+ - `TheveninModel` simulates them with midpoint-SOC evaluation of the exact RC update
217
+ (second-order accurate, unconditionally stable).
218
+ - `fit_thevenin_soc_dependent` and `DigitalTwin.fit(model="thevenin_soc")`: estimate the
219
+ tables by bounded least squares.
220
+ - Warm start from a constant fit.
221
+ - Optional smoothness penalty, scaled as an RMS-voltage weight.
222
+ - Per-breakpoint identifiability diagnostics.
223
+ - LG HG2 example: SOC-dependent candidates selected on tuning cycles and reported on
224
+ separate test cycles.
225
+ - R0(SOC) lowers the test median RMSE from 34.0 to 32.7 mV and improves all seven
226
+ test cycles.
227
+ - Full R0/R1/C1 tables overfit and are not selected.
228
+ - `FitResult.notes`; `DigitalTwin.set_parameters(parameters=...)`.
229
+ - `celltwin.data.adapters.mcmaster`: adapter for McMaster University cell-test exports.
230
+ - Verified on the LG 18650HG2 dataset (CC BY 4.0).
231
+ - Charge-positive current is converted on import.
232
+ - Repeated cycler timestamps follow a documented keep-last policy, recorded in the
233
+ metadata.
234
+ - Includes file-name parsing and test lookup.
235
+ - `celltwin.estimation.pseudo_ocv_from_low_rate_test`: OCV-SOC curve from a C/20
236
+ discharge/charge test (branch average, each branch normalized by its own throughput).
237
+ - `examples/lg_hg2_validation.py`: first experimental validation of the 1RC model.
238
+ - Calibrated on HPPC; predicts 11 unseen drive cycles at 25 °C.
239
+ - Median RMSE 34.0 mV over the whole cycle; 14.7–22.3 mV between 20 % and 100 % SOC,
240
+ 66.2 mV below 20 %.
241
+ - LG 18650HG2 dataset documentation page with observed data characteristics and results.
242
+ - `celltwin.data.adapters.nasa`: adapter for the NASA PCoE Li-ion Battery Data Set.
243
+ - Loads `B00xx.mat` files into `NASABatteryRecord`.
244
+ - Converts charge/discharge operations to discharge-positive `CyclingData`.
245
+ - Summarizes capacity (NASA-reported vs CellTwin-integrated) and EIS resistances.
246
+ - Documents format differences from the bundled README and the empirical meaning of
247
+ the `Capacity` field (integral to the first loaded sample below 2.7 V).
248
+ - `discharge_capacity_to_cutoff`: discharge capacity until a voltage cut-off, ignoring
249
+ rest-period recovery.
250
+ - `SERIES_COLORS` and `SEQUENTIAL_BLUES` plotting palettes.
251
+ - `examples/nasa_validation.py`: first analysis on experimental data. Integrated
252
+ capacity agrees with NASA's values (median relative difference ≤ 1e-6 except
253
+ square-wave cells 25–28, ≤ 1.2e-4); it also covers capacity fade, EIS trends, and
254
+ why the dataset cannot validate ECM dynamics.
255
+ - Dataset documentation page with download, checksum, terms and citation.
256
+
257
+ ### Changed
258
+
259
+ - Fit summaries collapse fixed tables that are constant across breakpoints.
260
+ - Correlation warnings are capped at ten, with a count of the rest.
261
+
262
+ ## [0.1.0] - 2026-11-29
263
+
264
+ First development release: a calibrated static equivalent-circuit model.
265
+
266
+ ### Added
267
+
268
+ - `CyclingData`: standardized representation of cycling data with a documented schema
269
+ and discharge-positive current convention.
270
+ - CSV/DataFrame import with `ColumnMapping` (column names, units, absolute timestamps,
271
+ sign-convention conversion) and a `ValidationReport` covering missing values,
272
+ unparseable values, duplicates, non-monotonic timestamps, sampling gaps and
273
+ implausible ranges. Data are never silently filled or dropped.
274
+ - Preprocessing: operating-mode identification, step labelling, Coulomb counting,
275
+ throughput integration and per-cycle statistics (capacity, energy, efficiencies).
276
+ - `OCVCurve` with PCHIP/linear interpolation, derivative and inverse, with no
277
+ extrapolation.
278
+ - `TheveninModel`: first-order RC model with an exact discretization (zero- or
279
+ first-order hold) for irregular sampling, plus operating limits.
280
+ - `fit_thevenin`: bounded nonlinear least squares for R0, R1, C1 and initial SOC, with
281
+ standard errors, correlations and identifiability warnings; error metrics.
282
+ - `DigitalTwin` workflow object: load, set OCV, fit, simulate, evaluate on independent
283
+ data (warns on calibration-data reuse and temperature mismatch), plot.
284
+ - Reproducible, labelled synthetic datasets (HPPC-style, dynamic, constant-current).
285
+ - Publication-style Matplotlib figures.
286
+ - End-to-end example, test suite, documentation and GitHub Actions CI.
@@ -0,0 +1,61 @@
1
+ # Contributing to CellTwin
2
+
3
+ Thank you for helping. CellTwin aims to be research-grade software, so scientific
4
+ correctness and reproducibility come before feature count.
5
+
6
+ ## Development setup
7
+
8
+ ```bash
9
+ python -m venv .venv && source .venv/bin/activate
10
+ pip install -e ".[dev]"
11
+ pytest # run the test suite
12
+ python -m mypy # package and consumer API type checks
13
+ ruff check . && ruff format --check . # lint and formatting
14
+ python examples/end_to_end_synthetic.py # full workflow
15
+ ```
16
+
17
+ Verify the source distribution and wheel with `python scripts/check_distribution.py`.
18
+ This builds a wheel from the sdist, creates a fresh temporary environment, installs
19
+ runtime dependencies and pytest, and runs the tests plus standalone SDK workflow
20
+ outside the checkout. It needs network access to install dependencies. External-data
21
+ tests are explicitly skipped in this distribution check.
22
+
23
+ Optional documentation tooling: `pip install -e ".[docs]"`, then `mkdocs serve`.
24
+
25
+ ## Coding standards
26
+
27
+ - Python 3.11+, full type hints, NumPy-style docstrings with units for every physical
28
+ argument and return value.
29
+ - Descriptive scientific names with unit suffixes (`capacity_ah`, `time_s`, `r0_ohm`).
30
+ SI units internally, except Ah, Wh and °C, which are labelled explicitly.
31
+ - Current is **positive during discharge** everywhere inside the package.
32
+ - Never silently fill, interpolate, clip or drop measurements. Report problems through
33
+ `ValidationReport`, warnings (`DataQualityWarning`, `IdentifiabilityWarning`,
34
+ `OperatingLimitWarning`) or exceptions.
35
+ - Prefer a simple physics-based method over machine learning when it is sufficient.
36
+ - Add no runtime dependency without discussion; optional features use extras.
37
+ - No speculative abstractions: add a base class when a second implementation exists.
38
+
39
+ ## Scientific validation requirements
40
+
41
+ Every new model or estimator must come with:
42
+
43
+ 1. **Verification tests** against analytical solutions or conservation laws where they
44
+ exist, including irregular time steps and extreme step sizes.
45
+ 2. **Parameter-recovery tests** on synthetic data from known parameters, both noise-free
46
+ (near-exact recovery) and noisy (recovery within reported uncertainty).
47
+ 3. **Negative tests** showing that poorly excited data trigger identifiability warnings
48
+ and that invalid inputs raise informative errors.
49
+ 4. Documentation of the governing equations, assumptions, parameter units and physical
50
+ meaning, and known limitations.
51
+
52
+ Never invent validation metrics, citations or performance claims. Synthetic data must
53
+ be labelled as synthetic. Use only public, appropriately licensed, or synthetic data,
54
+ and record the source and licence of any dataset added to the repository. Do not
55
+ contribute proprietary datasets or confidential characterization methods.
56
+
57
+ ## Pull requests
58
+
59
+ - Keep changes focused; include tests and update `CHANGELOG.md`.
60
+ - CI (lint + tests on Python 3.11–3.13) must pass.
61
+ - Describe the scientific motivation and how the change was validated.
celltwin-0.3.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CellTwin contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.