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
Useclient.model to create, list, update, and delete models.
Listing models
name, name_exact, created_by_email, created_after, created_before, updated_after, updated_before, order_by, order.
Getting a model
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
type in config is the PyBaMM model class name (SPM, SPMe, DFN).
Updating a model
Adding a custom variable
Deleting a model
Downloading an Ionworks model as a PyBaMM model
Useclient.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.
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:
"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.client.model.serialize(), which returns
the dict without loading it through PyBaMM:
Geometry and mesh are preserved
Downloaded models carry the serializedgeometry, 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
Useclient.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.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
Usecreate_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.
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:
simulation_settings
field. Omit simulation_settings on create and the model uses the built-in
defaults for its underlying model type.
ECM parameterization
Useclient.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
parameterized_model_id can be used as parameterized_model in client.simulation.protocol(...).