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.
Models belong to a project. list, create and upload_custom take a project_id, which defaults to the client’s project (Ionworks(project_id=...) or the IONWORKS_PROJECT_ID environment variable); without either they raise ValueError. Each project has its own copy of the built-in models (SPM, SPMe, DFN, ECM and the rest), listed alongside the project’s own models. A copy carries the built-in model’s name, and its source_model_id is the built-in model it came from. Copies are the project’s own: edit or delete them like any other model.
Listing models
list returns a paginated response with items, count, and total. Pass project_id= to list another project’s models.
Supported filters: name, name_exact, created_by_email, created_after, created_before, updated_after, updated_before, order_by, order. Filters and sort parameters are applied server-side, so you can drill into large model libraries without pulling every page.
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).
You can also attach persistent simulation_settings (mesh + solver) that will
be re-applied whenever the model is simulated — see
Simulation settings for the full field list and
precedence rules:
Creating a model from the PyBaMM model zoo
For a model from the PyBaMM model zoo,create_from_zoo uploads it as a custom model and creates a parameterized model
for it in one call. Install the zoo first with pip install pybamm-model-zoo; a
zoo model with its own dependencies also needs its extra
(pip install "pybamm-model-zoo[zoo-<slug>]").
parameter_values takes a parameter-set name, a pybamm.ParameterValues or a
parameters dict. Under a cell specification, its capacity, voltage cut-offs and
current replace the parameter set’s; without one, the parameterized model keeps
the parameter set’s own. Models whose constructors take more than options get
them through model_kwargs, e.g. model_kwargs={"num_physical_layers": 4} for
MultiLayer3DThermalSPM.
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 builds the model and returns its
serialized form, so you can run it locally with only pybamm installed —
no additional 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. A parameterized model usually belongs to a cell specification, whose capacity and voltage cut-offs override the parameter set’s. It can instead belong to a project with no cell specification, and keep the parameter set’s own values.
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
simulation_settings to pin parameter-specific mesh or solver
requirements. Parameter-level settings take precedence over the base model’s,
so this is the usual place to record the grid a fit was performed on — see
Simulation settings:
None as the cell specification to create a parameterized model in a
project instead. project_id defaults to the client’s project. parameters can
also be a pybamm.ParameterValues or the name of a PyBaMM parameter set:
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
Deleting a parameterized model
update() and delete() take the parameterized model’s cell_spec_id, or None
for one with no cell specification. A ParameterizedModel carries it as
param_model.cell_spec_id.
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.
Model builders
A model builder is a recipe that turns a cell specification into a model’s parameters. The recipe is a pipeline of direct entries and calculations. An entry reads the cell specification with the same dottedmapping paths as a
cell specification direct entry,
but without a cell_spec_id, since a builder reads whichever cell specification
it builds from. Data fits and validations are not allowed in a recipe.
config takes the dict above or an ionworks_schema.Pipeline. A builder belongs
to a project, which defaults to the client’s.
Building from a cell specification
check lists everything the cell specification lacks, each issue naming its path
in the cell specification and the model parameter it feeds. build returns the
parameters, any the model still needs (missing) and the readiness warnings.
With save=True it also saves them as a parameterized model on the cell
specification. Saving needs a name and is refused while any parameter is
missing. Pass set_as_default=True to make it the cell specification’s default.
Writing a mapping
client.model_builder.readiness(cell_spec_id) lists the builders a cell
specification is ready for. list, get, update and delete manage builders.
Deleting a builder keeps the parameterized models it produced.
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(...).