Migrating from PyBaMM to VoltSift: Parameter Sets, Experiment Protocols, and C99 BMS Export
Migrating from PyBaMM to VoltSift: Parameter Sets, Experiment Protocols, and C99 BMS Export
Search
Ask the AI

Migrating from PyBaMM to VoltSift: Parameter Sets, Experiment Protocols, and C99 BMS Export

Battery engineering teams that already maintain PyBaMM ParameterValues dictionaries and pybamm.Experiment protocol strings can bring those inputs into VoltSift without rewriting physics definitions, while gaining five capabilities that standalone PyBaMM scripts omit: raw cycler normalization with measured parameter identification, 48-parameter DFN identifiability auditing, solver-ready thermal SPMe execution, NMPC plating-free fast-charge synthesis, and static-allocation C99 BMS firmware export.

Local PyBaMM scripts focus on assembling forward DAEs and manual slice post-processing; VoltSift connects cycler files, parameter fitting, independent drive-cycle checks, and embedded MCU deployment in one pipeline. Across three measured drive cycles from public CALB 58 Ah cell #60129 records (515,546 scored samples in total), identified VoltSift models achieve 3.217 mV RMSE on WLTP, 5.600 mV on UDDS, and 4.504 mV on US06. Through the top-level source_job_id field, one fitted cell carries directly into fast-charge optimization, coupled aging forecasts, and C99 SDK deliverables (see the VoltSift PyBaMM migration reference, PyBaMM Architecture for Battery Modeling AI Pipelines, and the VoltSift cell modeling overview).

1. What VoltSift delivers beyond standalone PyBaMM scripts

When moving from research scripts to cell calibration and BMS delivery, engineering time goes into cleaning cycler files, keeping optimizers identifiable, stabilizing DAE solvers, and porting models to C. The table below contrasts a local PyBaMM script setup against the VoltSift production workflow:

Engineering stage Standalone PyBaMM script workflow VoltSift workflow advantage
Measured data ingestion and fitting Requires custom CSV parsing and external PyBOP scripts, where current sign flips or SOC offsets corrupt fits silently Provides POST /api/tools/normalize for Arbin .xlsx and cycler CSVs with rest-OCV initial SOC checks (deviation within 2%), plus automatic fitting for ecm_1d, a1_1rc, a1_2rc, ecm_multi_temp, and ecm_lfp_hysteresis against up to 8 independent validation records
Parameter identifiability Fitting 40+ DFN parameters directly converges slowly and risks collinear local minima Includes eis_identifiability, pairing DRT deconvolution with a 48-parameter DFN condition number and Fisher trace audit before nonlinear optimization
Solver stability and field extraction Requires local CasADi and SUNDIALS / IDAKLU builds, stalls on sharp C-rate steps, and relies on custom sol[...] array slicing Runs in a managed solver environment with zero local dependencies; one GET /api/jobs/{id}/diagnostics call returns eta_pl_mv, delta_x_neg, electrolyte concentrations, overpotential terms, and radial shell profiles
Fast-charge synthesis and aging Forward simulation evaluates fixed current schedules iteratively by trial and error Runs closed-loop SPMe + EKF + NMPC fast-charge synthesis (fast_charging_nmpc) under hard voltage, thermal, and plating bounds, alongside 1,000+ cycle coupled SEI, plating, and stress aging (aging_degradation)
Embedded MCU deployment Python scientific stack consumes hundreds of MB with dynamic heap allocation and cannot run on bare-metal BMS hardware Exports a static-allocation, zero-malloc C99 SDK (bms_sdk.zip) with online state filtering, 60 s voltage prediction, and 10 s pulse current limits, callable via REST and POST /mcp

2. Mapping PyBaMM constructs to VoltSift workflows

To port an existing Python workflow into VoltSift, map five layers—model selection, parameter overrides, experiment steps, internal fields, and downstream deliverables—while keeping your existing cell nomenclature.

PyBaMM construct VoltSift workflow / endpoint Key fields and deliverables
pybamm.lithium_ion.SPMe() / DFN() workflow: "spme_dfn_sim" config.chemistry_preset, config.protocol_text, and download electrochem_sim (electrochem_bundle.zip)
ParameterValues("Chen2020") / Marquis2019 / Prada2013 config.chemistry_preset NMC811_CHEN2020 (5.0 Ah), NMC_MARQUIS2019 (2.5 Ah), LFP_PRADA2013 (2.3 Ah), NCA_HIGH_POWER (3.2 Ah)
param.update({...}) PUT /api/jobs/{id}/files/cell_params_json Overrides L_neg, L_pos, L_sep, rs_neg, rs_pos, Ds_neg_0, Ds_pos_0, k_neg_0, k_pos_0, epse_*, cs_max_*, R_contact, electrode_area, heat_capacity_j_per_k, and h_cooling_w_per_k
pybamm.Experiment([...]) spme_dfn_sim (config.protocol_text) or POST /api/jobs/{id}/simulate Supports Discharge, Charge, Hold, Rest, and Chinese step clauses with protocol_cycles (1–10)
sol["Negative particle ..."] GET /api/jobs/{id}/diagnostics Returns electrochem_sim.series (including eta_pl_mv, delta_x_neg, ce_*_mol_m3, eta_kin_*_mv, eta_elec_conc_mv, and eta_ohm_total_mv) plus radial_snapshots
Coupled SEI / plating / particle-stress aging workflow: "aging_degradation" Uses config.n_cycles, charge_c_rate, discharge_c_rate, and top-level temperature_c; exports aging_forecast (aging_bundle.zip)
Fast charging and embedded C deployment fast_charging_nmpc and bms_embedded_sdk Reuses upstream cell jobs via source_job_id and exports fast_charging_protocol (fast_charging_bundle.zip) or bms_sdk (bms_sdk.zip)

When your team already holds cycler test files, run a1_1rc, a1_2rc, ecm_multi_temp, or eis_identifiability first, check voltage RMSE and in-domain coverage using the battery modeling CSV guide and the independent validation guide, and then continue into forward simulation and C99 SDK export from the same job record.

3. Chemistry presets, CellParameters overrides, and governing equations

When a PyBaMM script starts from a literature parameter set and adjusts only electrode geometry or transport coefficients, select config.chemistry_preset at job creation and upload only the modified keys via cell_params_json. For measured-cell deviations across published parameter sets, see PyBaMM Built-in Parameter Sets vs. Measured Data.

Preset key (chemistry_preset) Default capacity Voltage window Reference chemistry
NMC811_CHEN2020 5.0 Ah 2.50–4.20 V Chen et al. (2020) high-nickel cylindrical cell
NMC_MARQUIS2019 2.5 Ah 2.80–4.20 V Marquis et al. (2019) mid-rate NMC cell
LFP_PRADA2013 2.3 Ah 2.50–3.65 V Prada et al. (2013) LFP cell
NCA_HIGH_POWER 3.2 Ah 2.70–4.20 V High-power NCA cylindrical cell

Inside the micro-transport solver, discrete radial shells track solid-phase lithium diffusion in each active particle. Across the radial coordinate \(r\), where the temperature-dependent solid diffusivity is denoted \(D_s(T)\), the solid lithium concentration \(c_s(r, t)\) satisfies the spherical diffusion equation

\[\frac{\partial c_s}{\partial t} = \frac{1}{r^2}\frac{\partial}{\partial r}\left(r^2 D_s(T)\frac{\partial c_s}{\partial r}\right),\]

which yields surface and core stoichiometry fractions (such as x_neg_surf and x_neg_core) alongside the radial surface-to-core difference delta_x_neg. Passing lumped thermal parameters heat_capacity_j_per_k and h_cooling_w_per_k through cell_params_json enables coupled temperature evolution and Arrhenius updates during high-rate protocols.

To evaluate lithium plating risk quantitatively at every time step, the spme_dfn_sim workflow computes the anode plating overpotential from the anode solid potential \(\phi_{s,\text{neg}}(t)\) and the electrolyte potential at the negative electrode \(\phi_{e,\text{neg}}(t)\) via

\[\eta_{\text{pl}}(t) = \phi_{s,\text{neg}}(t)-\phi_{e,\text{neg}}(t).\]

Whenever the thermodynamic plating overpotential \(\eta_{\text{pl}}(t)\) drops below \(0\,\text{mV}\), metallic lithium deposition becomes thermodynamically favorable, and electrochem_sim.metrics records both the minimum margin min_eta_pl_mv and the count of risk samples plating_risk_points.

4. Reusing pybamm.Experiment strings via Python REST

Local PyBaMM scripts frequently hit sign mismatches or ambiguous rest cutoffs across tester conventions, as examined in Silent Traps in PyBaMM Experiment Protocols. VoltSift enforces discharge-positive current across datasets while allowing protocol_text to retain standard pybamm.Experiment wording: clauses such as Discharge at 1C until 2.50V, Rest for 180s, Charge at 1.5C until 4.20V, and Hold at 4.20V until 0.05C (as well as Chinese equivalents) can be joined with semicolons, arrows (->), or newlines up to 40 steps per cycle and protocol_cycles between 1 and 10.

The Python example below creates an spme_dfn_sim job, uploads targeted CellParameters overrides via PUT /api/jobs/{id}/files/cell_params_json, polls until the job reaches the review state to read internal diagnostics, and replays the exact same step string against an identified ECM job:

import time
import requests

BASE = "https://app.voltsift.com"
HEADERS = {"Authorization": "Bearer vs_live_your_api_key"}

# 1. Create an SPMe job from the Chen2020 preset and a PyBaMM-style protocol string
job = requests.post(
    f"{BASE}/api/jobs",
    headers=HEADERS,
    json={
        "name": "Chen2020-FastCharge-Check",
        "cell_id": "NMC811-5AH",
        "authorized": True,
        "workflow": "spme_dfn_sim",
        "config": {
            "chemistry_preset": "NMC811_CHEN2020",
            "protocol_text": (
                "Discharge at 1C until 2.50V; "
                "Rest for 180s; "
                "Charge at 1.5C until 4.20V; "
                "Hold at 4.20V until 0.05C"
            ),
            "protocol_cycles": 1,
            "n_shells": 10,
        },
    },
    timeout=30,
).json()
job_id = job["id"]

# 2. Optional: override selected CellParameters fields (raw JSON body)
requests.put(
    f"{BASE}/api/jobs/{job_id}/files/cell_params_json",
    headers={**HEADERS, "Content-Type": "application/json"},
    json={
        "L_neg": 8.52e-5,
        "Ds_neg_0": 3.3e-14,
        "R_contact": 0.0012,
        "heat_capacity_j_per_k": 48.0,
        "h_cooling_w_per_k": 1.8,
    },
    timeout=30,
).raise_for_status()

# 3. Submit and poll until completion (state == "review")
requests.post(f"{BASE}/api/jobs/{job_id}/submit", headers=HEADERS, timeout=30).raise_for_status()
while True:
    state = requests.get(f"{BASE}/api/jobs/{job_id}", headers=HEADERS, timeout=30).json()["state"]
    if state in {"review", "failed", "canceled"}:
        break
    time.sleep(2.0)

# 4. Read internal concentration, overpotential, and radial-shell diagnostics
diag = requests.get(f"{BASE}/api/jobs/{job_id}/diagnostics", headers=HEADERS, timeout=30).json()
echem = diag["electrochem_sim"]
print("Min plating overpotential (mV):", echem["metrics"]["min_eta_pl_mv"])
print("Plating risk points:", echem["metrics"]["plating_risk_points"])
print("Peak-gradient radial x_neg:", echem["radial_snapshots"]["peak_gradient"]["x_neg"])

# 5. Replay the exact same protocol string on an identified ECM job
ecm_sim = requests.post(
    f"{BASE}/api/jobs/{existing_ecm_job_id}/simulate",
    headers=HEADERS,
    json={
        "preset": "PROTOCOL",
        "protocol_text": "Discharge at 1C until 2.80V; Rest for 60s; Charge at 1.5C until 4.20V",
        "initial_soc": 0.9,
        "temperature_c": 25.0,
        "dt_s": 1.0,
    },
    timeout=30,
).json()

5. Inspecting internal electrochemical fields and radial profiles

In standalone PyBaMM scripts, separating terminal voltage into activation, electrolyte concentration, ohmic drop, and equilibrium open-circuit contributions requires querying multiple variable keys. Calling GET /api/jobs/{id}/diagnostics returns the structured electrochem_sim object that aligns every channel on one time grid:

  • Macroscopic signals and thermal state (series): time grid t_s, applied current current_a, terminal voltage voltage_v, equilibrium voltage ocv_v, state of charge soc, and cell temperature temp_c.
  • Particle stoichiometry and plating margin (series): negative surface stoichiometry x_neg_surf, core stoichiometry x_neg_core, radial difference delta_x_neg, positive fractions y_pos_surf and y_pos_core, and anode plating overpotential eta_pl_mv.
  • Electrolyte salt profile (series): average electrolyte concentrations across the negative electrode, separator, and positive electrode (ce_neg_mol_m3, ce_sep_mol_m3, and ce_pos_mol_m3) plus the domain minimum ce_min_mol_m3 in mol/m3 to detect transport depletion.
  • Overpotential decomposition (series): negative activation overpotential eta_kin_neg_mv, positive activation overpotential eta_kin_pos_mv, electrolyte concentration polarization eta_elec_conc_mv, and total ohmic polarization eta_ohm_total_mv.
  • Radial concentration snapshots (radial_snapshots): three profiles at initial, peak_gradient, and final over normalized particle radius r_norm containing x_neg and y_pos; full tables and plots are archived in GET /api/jobs/{id}/downloads/electrochem_sim (electrochem_bundle.zip).

6. Chaining fast charging, aging, and C99 BMS SDK export via source_job_id

Once a reference SPMe cell or an identified ECM job enters review, downstream engineering tasks require no second file upload. Passing "source_job_id": job_id in a new POST /api/jobs payload carries the cell parameters directly into three deliverables:

  • Plating-free fast charging (fast_charging_nmpc): combine the SPMe observer with nonlinear model predictive control (NMPC) to synthesize a current trajectory that obeys upper voltage limits v_max, thermal limits t_max_c, and plating overpotential margins, exported through GET /api/jobs/{id}/downloads/fast_charging_protocol (fast_charging_bundle.zip).
  • Coupled aging forecast (aging_degradation): specify n_cycles, charge_c_rate, and discharge_c_rate inside config alongside top-level temperature_c to compute capacity fade and resistance growth from SEI growth, lithium plating, and particle diffusion stress, downloadable via GET /api/jobs/{id}/downloads/aging_forecast (aging_bundle.zip).
  • Embedded BMS and SOP C99 SDK (bms_embedded_sdk): download the static-allocation C99 bundle bms_sdk.zip containing pb_engine.h, pb_engine.c, ps3_kernel.c, ps3_gf.c, vs_cell_preset.h (with your exported OCV table and rated capacity), and buildable hosts pb_bench.c and example_csv.c.

The C99 snippet below shows how the exported host header pb_engine.h initializes one cell, advances online filtering per sample, and evaluates 60-second voltage forecasts alongside 10-second discharge and charge current limits (matching the shipped example_csv.c host example):

#include "pb_engine.h"

static pb_engine_t eng;

/* Initialize a single-cell engine with rated capacity, monotone OCV table, and initial SOC */
if (pb_init(&eng, 1, q_rated_ah, ocv_soc, ocv_v, n_ocv, &soc0) != 0) {
    return -1;
}

/* Update online filter on each sample (discharge current positive, measured voltage v_cell) */
pb_step(&eng, t_s, i_dis_a, &v_cell);

/* Predict forward voltage trajectory or query 10 s pulse discharge/charge current limits */
if (pb_predict_v(&eng, 0, horizon, i_future, dt_future, v_pred)) {
    double i_dis_lim = 0.0, i_chg_lim = 0.0;
    const double i_cap = 10.0 * eng.q_ah;
    pb_sop_pack_limit(&eng, 10.0, v_min, v_max, i_cap, i_cap, &i_dis_lim, &i_chg_lim);
}

For agent-driven pipelines, VoltSift exposes matching MCP tools (create_and_run_job, get_job_diagnostics, and simulate_cell) on POST /mcp alongside /llms-full.txt and /openapi.json. Start with your own cell measurements or an existing PyBaMM parameter set to verify the complete workflow online.

Open the VoltSift workspace to run your first cell model, independent validation, and PyBaMM migration

Leave a Reply

Scroll down