Array Data Fits

Fit the same model separately at each value of an independent variable (e.g. temperature, pulse SOC) and return the fitted parameter as a 2xN array.

An ArrayDataFit runs the same fit independently at each value of an independent variable, and returns the fitted parameter as a 2xN array — one row holding the independent-variable values and the other holding the corresponding fitted values.

This is the right tool when the parameter you are fitting is expected to depend on a state variable, and you want a sampled function rather than a single scalar. Common examples:

  • Diffusivity vs. stoichiometry from a GITT or pulse experiment — one fit per pulse, keyed by the midpoint stoichiometry of that pulse.
  • Exchange-current density or diffusivity vs. temperature — one fit per chamber temperature.
  • OCP-derived parameters vs. SOC — one fit per SOC setpoint.

How it differs from a regular DataFit

A regular DataFit runs one optimization against all of its objectives together, producing a single best-fit value per parameter. An ArrayDataFit runs one optimization per key of objectives, producing a fitted value per key. The keys themselves are the independent-variable values.

DataFitArrayDataFit
Number of optimizationsOneOne per objectives key
Result shape per parameterScalar2xN array ([independent_var_values, fitted_values])
Use whenParameter is a single numberParameter is a sampled function of an independent variable

Python usage

import ionworks as iw

# objectives keyed by the independent-variable value (here: midpoint
# stoichiometry of each pulse)
objectives = {
    0.25: iw.pipeline.objectives.Pulse(data_pulse_25, options={"model": model}),
    0.50: iw.pipeline.objectives.Pulse(data_pulse_50, options={"model": model}),
    0.75: iw.pipeline.objectives.Pulse(data_pulse_75, options={"model": model}),
}

array_fit = iw.pipeline.ArrayDataFit(
    objectives,
    parameters={
        "Positive particle diffusivity [m2.s-1]": iw.pipeline.Parameter(
            "D_p", initial_value=1e-14, bounds=(1e-15, 1e-13)
        ),
    },
)

config = array_fit.to_config()

# Submit the config with client.pipeline.create(...) — see API usage below.
# The fitted parameter comes back as a 2x3 array:
# row 0 = [0.25, 0.50, 0.75], row 1 = fitted D_p values.

API usage

The pipeline API accepts an array_data_fit element with the same top-level fields as data_fit. The keys of objectives are the independent-variable values:

pipeline_config = {
    "elements": {
        "known values": {"element_type": "entry", "values": parameter_values},
        "fit diffusivity vs sto": {
            "element_type": "array_data_fit",
            "objectives": {
                0.25: {"objective": "Pulse", "data": "db:meas-pulse-25", ...},
                0.50: {"objective": "Pulse", "data": "db:meas-pulse-50", ...},
                0.75: {"objective": "Pulse", "data": "db:meas-pulse-75", ...},
            },
            "parameters": {
                "Positive particle diffusivity [m2.s-1]": {
                    "bounds": [1e-15, 1e-13],
                    "initial_value": 1e-14,
                },
            },
        },
    },
}

pipeline = client.pipeline.create(pipeline_config)

See the Pipelines API how-to for submitting and polling, and the Data Fitting Overview for the full set of options shared with DataFit (cost, optimizer, multistarts, priors, etc.).

On this page