Skip to main content
The ionworks-api Python package provides sub-clients for managing models and parameterized models programmatically. For installation and authentication, see the Python API client page.

Models

Use client.model to create, list, update, and delete models.

Listing models

Supported filters: name, name_exact, created_by_email, created_after, created_before, updated_after, updated_before, order_by, order.

Getting a model

The config field (e.g. {"type": "SPMe"}) is included on get responses. It may be None on the create response — re-fetch with get if you need it.

Creating a model

The type in config is the PyBaMM model class name (SPM, SPMe, DFN).
You only need to create a model when you want custom variables. For a standard model, reference a built-in system model by name (e.g. "SPMe (Full Cell)") when building a parameterized model — no model creation required. See Models.

Updating a model

Adding a custom variable

Deleting a model

Downloading an Ionworks model as a PyBaMM model

Use client.model.download() to fetch an Ionworks model (ECM, LumpedSPMR, LumpedSPMeR, the MSMR models, GITTModel, …) as a ready-to-use PyBaMM model. The server constructs the model from the licensed ionworkspipeline package and returns its serialized form, so you can run it locally with only pybamm installed — no ionworkspipeline license required.
Pass model constructor options through options=, and optionally write the serialized JSON to disk with path= so you can reload it later or re-upload it as a custom model:
The available model names match the entries listed under "ionworks_models" by client.pybamm_models(). Standard PyBaMM models (SPM, SPMe, DFN, …) are not served by this endpoint — instantiate them directly with pybamm instead.
Serialization captures the model’s mathematical structure (rhs, algebraic, variables, events, initial conditions) but not Python helper methods such as set_initial_state or classmethods.When path is given, the file may contain bare Infinity/NaN tokens (PyBaMM uses infinite bounds and event thresholds). Python’s json and Serialise.load_custom_model read these fine, but strict parsers (JSON.parse, jq, …) will reject the file.
If you only need the raw serialized document — for example, to save it, re-upload it, or inspect it — use client.model.serialize(), which returns the dict without loading it through PyBaMM:

Geometry and mesh are preserved

Downloaded models carry the serialized geometry, var_pts, spatial_methods, and submesh_types that the original Ionworks model was built with. When you re-upload one as a custom model — or feed it into a pipeline that goes through parse_model — those values are restored as the model’s default_geometry, default_var_pts, default_spatial_methods, and default_submesh_types, so a downstream pybamm.Simulation discretises against the correct mesh instead of falling back to empty defaults. You do not need to reconstruct the geometry by hand.

Parameterized models

Use client.parameterized_model to create, list, and update parameterized models. Parameterized models are scoped to a cell specification.

Listing parameterized models

You can list parameterized models scoped to a single cell specification or across every cell specification in a project.
To list every parameterized model linked to any cell specification in a project, use list_by_project. When project_id is omitted it defaults to the project_id configured on the client (see API client).
list_by_project accepts limit values up to 1000, so you can load every model for a project in a single request when populating UI selectors or bulk-processing models.

Getting a parameterized model

Creating a parameterized model

Creating or getting a parameterized model

Use create_or_get to make setup scripts safely re-runnable. If a parameterized model with the same name already exists for the cell specification, the client returns the existing one instead of raising a 409 Conflict error.
This mirrors the create_or_get behaviour already available on client.cell_spec, client.cell_instance, and client.cell_measurement — see idempotent uploads for the same pattern applied to cell data.

Updating a parameterized model

Getting parameter values

Retrieve all parameter values as a dictionary, useful as baseline parameters for data fitting or optimization workflows.

Getting variable names

List the scalar variable names available from a parameterized model.

Persisting simulation settings

A parameterized model can carry its own simulation settings — the mesh (var_pts, submesh_types), spatial discretisation (spatial_methods), and solver configuration to use whenever this model is simulated. Persisting settings ensures the model simulates the same way everywhere it’s used — a DataFit, a validation run, a downstream sweep — without you having to reconfigure the mesh and solver in each caller. Build a SimulationSettings from live PyBaMM objects with iws.models.SimulationSettings(...), then pass it under the simulation_settings key when creating or updating a parameterized model:
The stored settings come back on the parameterized model’s simulation_settings field. Omit simulation_settings on create and the model uses the built-in defaults for its underlying model type.
Two write-time limits are worth knowing before you build a settings block:
  • geometry is rejected. Persisting a geometry override returns 400 BAD_REQUEST; persist var_pts / submesh_types / spatial_methods / solver instead and let the geometry come from the model.
  • Solvers are allowlisted. Only IDAKLUSolver, AlgebraicSolver, and NonlinearSolver may be stored. The deprecated CasadiSolver and ScipySolver are rejected.
var_pts keys, submesh classes, and spatial-method classes are validated against allowlists too, so an unrecognized value fails the write rather than the later simulation.
You can find the ID for any resource from the Ionworks Studio web app. The ID is displayed in the URL when you navigate to a resource’s detail page.

ECM parameterization

Use client.ecm to fit an Equivalent Circuit Model (R0 + N RC pairs, plus optional OCV) to cycling data and persist the result as a Parameterized Model. Authenticated fits run as background jobs — fit_from_measurements and fit_from_file return an EcmFitJob handle immediately, and wait_for_completion blocks until the worker finishes (typically 10–60 s). See ECM parameterization for the full guide, including ocv_soc_curve co-capacity fits, per-segment SOC seeds, and knot-resolution tuning.

Fitting from stored measurements

Fitting from a local file

fit_from_file accepts CSV, parquet, and any cycler format that ionworksdata can detect. Use client.ecm.detect_and_read(file) to preview a file before fitting.

Saving a fit as a Parameterized Model

The returned parameterized_model_id can be used as parameterized_model in client.simulation.protocol(...).

Fitting a built-in example (no auth)

The demo endpoint is rate-limited (60/min) and synchronous. RC-pair parameters are only included for authenticated callers whose organization has ECM results access enabled.