{"id":28077,"library":"pybamm","title":"PyBaMM","description":"Python Battery Mathematical Modelling (PyBaMM) is an open-source battery simulation package written in Python, currently at version 26.4.2. It provides a framework for building and solving continuum models for batteries, with support for experimental protocols and parameter estimation. PyBaMM releases on a monthly cadence.","status":"active","version":"26.4.2","language":"python","source_language":"en","source_url":"https://github.com/pybamm-team/PyBaMM","tags":["battery","simulation","modelling","electrochemistry","scientific-computing"],"install":[{"cmd":"pip install pybamm","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Default solver backend; must be installed for simulation to work","package":"casadi","optional":false},{"reason":"Optional solver backend for stiff ODEs/DAEs","package":"scikits.odes","optional":true},{"reason":"Used for automatic differentiation and optional solver acceleration","package":"jax","optional":true}],"imports":[{"note":"The top-level module is imported as a namespace.","wrong":"","symbol":"pybamm","correct":"import pybamm"},{"note":"Simulation is the main class for running experiments. In v26.4.0+, Simulation was refactored into BaseSimulation and Simulation; Simulation is still the recommended import.","wrong":"","symbol":"Simulation","correct":"from pybamm import Simulation"},{"note":"Models are accessed via submodules like pybamm.lithium_ion, not directly on pybamm.","wrong":"pybamm.SPM()","symbol":"model","correct":"pybamm.lithium_ion.SPM()"}],"quickstart":{"code":"import pybamm\n\n# Create a model\nmodel = pybamm.lithium_ion.SPM()\n\n# Create a simulation\nsim = pybamm.Simulation(model)\n\n# Solve\nsolution = sim.solve()\n\n# Plot\nsolution.plot()\n","lang":"python","description":"Basic usage: import pybamm, choose a model, create a Simulation, solve, and plot."},"warnings":[{"fix":"If you have custom subclasses, inherit from BaseSimulation instead, or override as needed.","message":"In v26.4.0, Simulation was split into BaseSimulation and Simulation. Custom subclasses of Simulation may break if they relied on internal methods that moved to BaseSimulation.","severity":"breaking","affected_versions":">=26.4.0"},{"fix":"Upgrade to v26.4.2 or later, or manually set inputs before calling solve.","message":"EISSimulation.solve(initial_soc=..., inputs=...) does not forward inputs to build pre-v26.4.2. This was fixed in v26.4.2.","severity":"gotcha","affected_versions":">=26.0.0,<26.4.2"},{"fix":"Replace calls to pybamm.get_parameters_collections with pybamm.ParameterValues.create_from_... methods.","message":"The 'pybamm.get_parameters_collections' function is deprecated and will be removed in a future release. Use 'pybamm.ParameterValues' directly.","severity":"deprecated","affected_versions":">=25.0.0"},{"fix":"Upgrade to v26.4.2 or later to avoid silent fallback.","message":"Serialise.load_custom_model may silently fall back to pybamm.BaseModel if the saved base class cannot be imported. This was fixed in v26.4.2 to walk the recorded MRO.","severity":"gotcha","affected_versions":">=26.0.0,<26.4.2"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Run 'pip install pybamm' in your environment.","cause":"PyBaMM is not installed.","error":"ModuleNotFoundError: No module named 'pybamm'"},{"fix":"Use one of the supported solvers: 'casadi', 'scikits.odes', or leave default.","cause":"Unsupported solver specified.","error":"ValueError: Expected solver to be 'casadi' or 'scikits.odes', got ..."},{"fix":"Check the model's parameter list using model.parameters or model.variables.","cause":"Trying to set a parameter or variable that is not part of the selected model.","error":"pybamm.ModelError: Assigning a variable/parameter that does not exist in the model"},{"fix":"Manually set initial conditions via model.set_initial_conditions or use a model with known consistent defaults.","cause":"The model's initial conditions are inconsistent or missing.","error":"pybamm.SolverError: Could not find valid consistent initial conditions"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}