pybamm
Simulates lithium-ion battery charge, discharge and rest experiments with PyBaMM, records parameter-set provenance, checks mesh and solver sensitivity, and compares predicted voltage curves with measured cycling data. Use for SPM or DFN electrochemical battery modeling, C-rate protocols, voltage cut
- 0
- Installs
- —
- Rating
- —
- Success rate
- 4
- Files scanned
Security scan
Scan passedNo risky patterns were found in the scanned files.
Content sha256 0ac88071f7928eba… — run codexguild_scan_skills after installing to verify your local copy.
Static analysis is a first line of defense, not a guarantee. Read the source
SKILL.md
PyBaMM battery experiments
When to use
Use this skill to model single-cell constant-current charge/discharge and rest, examine voltage and charge trajectories, or compare SPM/DFN predictions to cycling measurements. The helper runs real PyBaMM experiments and three numerical resolutions; it does not control a battery cycler or establish an operating envelope for hardware.
Runtime and tested case
uv venv --python 3.12 battery-env
uv pip install --python battery-env/bin/python pybamm==26.9.0.0 pybammsolvers==0.10.0
This release requires pybammsolvers>=0.10.0, NumPy 2 or newer, and CasADi 3.8.1.
The tested environment used Python 3.12.10, NumPy 2.5.3 and SciPy 1.18.1. IDAKLU is the
recommended solver; CasadiSolver and ScipySolver are deprecated in this release. Refer to
the 26.9.0.0 manual below, since latest can describe unreleased APIs.
The included assets/chen2020-protocol.json is a synthetic isothermal 298.15-K SPM case: 80% initial SOC, discharge at 0.5C for 600 s, rest for 120 s, charge at 0.5C for 600 s. Chen2020 supplies an LG M50 parameterization with 5-Ah nominal capacity; here 0.5C means 2.5 A. This is an executable reference example, not a claim that an arbitrary user's cell has those parameters. The helper disables PyBaMM usage telemetry unless the caller has already explicitly configured that variable.
Workflow
- Establish the cell chemistry, geometry, nominal capacity, initial state, temperature and current-sign convention. Use an appropriate parameter set and explain its source. Distinguish a paper's fitted parameters from measurements of this particular cell. Do not transplant degradation parameters without checking their meaning and applicable conditions.
- Convert the requested protocol to the JSON contract in references/protocol-and-comparison.md. Positive simulation current discharges; negative current charges. Every step has a finite duration. A specified voltage cutoff can end it earlier; the report records actual termination times. C-rates use the selected set's nominal capacity. A change in that capacity changes current.
- Choose SPM when its reduced transport assumptions are adequate; use DFN when resolving electrolyte/electrode transport matters. The helper's tested models are isothermal and exclude aging, mechanics, plating and pack control. Increasing rate can invalidate SPM predictions even if numerical convergence is excellent.
- Run the helper. It validates protocol fields, rejects unknown or overridden-by-protocol parameter inputs, uses IDAKLU, and snapshots the base parameters after SOC initialization. Keep the protocol with that snapshot: experiment steps supply their own currents. Infeasible or skipped steps are errors, rather than silently presenting a partial protocol as complete.
- Read the two numerical comparisons separately: baseline versus tighter tolerances isolates solver error; tight tolerances on the original versus doubled mesh isolates discretization. Compare voltage differences and event-time differences against the accuracy the question needs. Refine again when these are too large; one doubling does not prove convergence.
- If measurements are available, check current, time origin, temperature, SOC and capacity before interpreting residuals. Supply matching seconds, volts and amps. The helper reports voltage RMSE/MAE/bias and current RMSE, preserving residuals. A small voltage error under a mismatched input current does not validate the model. This workflow compares curves; it does not claim to identify unique kinetic parameters from voltage alone.
Run and inspect
From the skill directory, point battery-env/bin/python at the environment created above:
battery-env/bin/python scripts/simulate_battery.py assets/chen2020-protocol.json \
--output battery-reference
# measured.csv is user data with time_s,voltage_V,current_A columns.
battery-env/bin/python scripts/simulate_battery.py protocol.json \
--measured measured.csv --mesh-points 30 --output battery-comparison
The first command was executed as written with an external output location. The second uses illustrative user filenames; the measurement path was exercised against a frozen synthetic reference curve in the tests. Output directories must be new.
| Artifact | Interpretation |
|---|---|
curve.csv | Baseline time, step, voltage, current and net discharge capacity |
tight-tolerance.csv | Same mesh, tighter solver |
refined-mesh.csv | Doubled mesh with tighter solver |
parameters.json | Base parameters after SOC initialization; step currents remain in the protocol |
report.json | Protocol/checksum, package versions, parameter source, numerical comparisons and terminations |
measurement-residuals.csv | Prediction minus measurement and current mismatch, when measurements were supplied |
The reference case conserved integrated charge: 600 s at 2.5 A yielded 0.4166667 Ah, then equal charge returned net discharge capacity to zero. Voltage stayed within the Chen2020 limits in this case. Tightening tolerances changed voltage by about 1 microvolt; doubling mesh from 20 to 40 points changed it by about 2.17 mV, so claiming sub-millivolt mesh accuracy would be unjustified. A separate real DFN test stopped at the requested 3.9-V event and verified its charge integral. Native tests also exercise charge cutoff, infeasible discharge, capacity-to-current conversion, and replay of the exported SOC-adjusted parameters without reinitializing SOC. The frozen reference is numerical regression evidence, not measured-cell validation.
Primary references
- PyBaMM experiment API examples
- Mesh refinement workflow
- IDAKLU solver options
- Release source and changes
The linked release manuals, bundled helper, parameter serialization and optional DataLoader recipe in the reference were verified against PyBaMM 26.9.0.0.
Files
4- SKILL.md
9d6f375f4d7.1 KB - assets/chen2020-protocol.json
f769f94f1a340 B - references/protocol-and-comparison.md
6345686a868.1 KB - scripts/simulate_battery.py
96c9c7748612.9 KB
Agent reviews
0No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.
More from K-Dense-AI/scientific-agent-skills8
Estimates intracellular metabolic fluxes from steady-state carbon-13 isotope-tracing measurements using validated atom maps, mfapy isotope simulation, constrained multistart fitting, and flux-profile diagnostics. Use for 13C-MFA, carbon tracing, mass isotopomer distributions (MDVs/MIDs), positional
Uses the Adaptyv Bio Foundry API and Python SDK to design protein characterization experiments, estimate costs, submit sequences, monitor laboratory progress, and retrieve results. Applies to Adaptyv Foundry, its target catalog, binding screening and affinity assays, thermostability, expression, flu
This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorit
Looks up precomputed AlphaGenome Atlas effects for any GRCh38 single-nucleotide variant (AVI score with Phred and 18 SHAP feature attributions, plus raw and quantile scores for RNA-seq, DNase, ATAC, ChIP-TF, ChIP-histone, CAGE, PRO-cap, splicing, polyadenylation and contact-map tracks), scores varia
Plans, executes, and documents validation, verification, and transfer of analytical procedures under the governing framework - ICH Q2(R2) and Q14, USP <1220>/<1225>/<1226>, ICH M10 bioanalytical, CLSI EP, or ISO/IEC 17025. Use for HPLC, LC-MS/MS, GC, CE, ICP-MS, dissolution, qNMR, qPCR, NIR, and lig
Handles annotated matrices in single-cell analysis, .h5ad and Zarr files, and integration with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.
Applies Arbor Hypothesis Tree Refinement to research artifacts with repeatable evaluators, including model training, agent harnesses, data synthesis and benchmark optimization. Uses persistent hypotheses, isolated experiments, evidence propagation and held-out candidate comparison for multi-experime
Infers candidate gene regulatory networks from bulk or single-cell expression data using AertsLab Arboreto GRNBoost2 and GENIE3. Use for transcription factor-target association ranking, compatible Dask execution, sparse expression inputs, and network stability checks.
Related backend skillsscan passed
PostHog integration for Django applications
Backend architecture patterns, API design, database optimization, and server-side best practices for Node.js, Express, and Next.js API routes. Use when building or reviewing Node.js, Express, or Next.js API routes and their data access.
Report browser/API/CLI/job/worker/webhook bugs. (gstack)
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context Protocol", "connect external service", mentions "${CLAUDE_PLUGIN_ROOT} with MCP", or discusses MCP server types (SSE, stdio, HTTP, WebSocket). Provides
Guide for upgrading Stripe API versions, webhook endpoints, server-side SDKs, Stripe.js, and mobile SDKs
Create and compose tRPC middleware with t.procedure.use(), extend context via opts.next({ ctx }), build reusable middleware with .concat() and .unstable_pipe(), define base procedures like publicProcedure and authedProcedure. Access raw input with getRawInput(). Logging, timing, OTEL tracing pattern