Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.ionworks.com/llms.txt

Use this file to discover all available pages before exploring further.

Many battery parameters depend on state of charge, temperature, or both. Piecewise interpolation enables the creation of smooth parameter functions suitable for physics-based models. This guide covers both general piecewise interpolants and specialized OCP interpolants.

Overview

Piecewise interpolation addresses several needs:
  • SOC-dependent parameters: Diffusivity, exchange current density, and other transport properties often vary significantly with lithiation state
  • Temperature dependence: Non-Arrhenius behavior requires more flexible functional forms
  • OCP functions: Open-circuit potential must be defined across the full stoichiometry range for simulation
The implementation uses smooth heaviside functions to create continuous, differentiable interpolants that work well with differential equation solvers.

Mathematical Formulation

Smooth Heaviside Function

Traditional piecewise functions use discontinuous step functions, which cause convergence issues in ODE/DAE solvers. Instead, we use a smooth approximation: Hsmooth(x;θ,ϵ)=12(1+tanh(xθ2ϵ))H_{\text{smooth}}(x; \theta, \epsilon) = \frac{1}{2}\left(1 + \tanh\left(\frac{x - \theta}{2\epsilon}\right)\right) where:
  • xx is the input variable (e.g., SOC)
  • θ\theta is the threshold value
  • ϵ\epsilon is the smoothing parameter (larger = smoother transition)
The smooth heaviside is infinitely differentiable (CC^\infty) and transitions from ~0 for xθx \ll \theta to ~1 for xθx \gg \theta.

1D Piecewise Linear Interpolation

For a parameter pp varying with xx, given breakpoints {x0,x1,,xN1}\{x_0, x_1, \ldots, x_{N-1}\} with values {p0,p1,,pN1}\{p_0, p_1, \ldots, p_{N-1}\}: p(x)=p0H0(x)+i=0N2piseg(x)Hiseg(x)+pN1HN1+(x)p(x) = p_0 H_0^-(x) + \sum_{i=0}^{N-2} p_i^{\text{seg}}(x) H_i^{\text{seg}}(x) + p_{N-1} H_{N-1}^+(x) Each linear segment interpolates between adjacent knots: piseg(x)=pi+(pi+1pi)xxixi+1xip_i^{\text{seg}}(x) = p_i + (p_{i+1} - p_i) \frac{x - x_i}{x_{i+1} - x_i}

Piecewise Parameter Functions

1D Interpolation

For parameters that vary with a single variable (typically SOC):
entry = iwp.direct_entries.PiecewiseInterpolation1D(
    base_parameter_name="Negative particle diffusivity [m2.s-1]",
    breakpoint_values=[0.0, 0.3, 0.7, 1.0],
    breakpoint_parameter_name="SOC",
    smoothing=1e-4,
)

param_values = {
    "Negative particle diffusivity at SOC 0 [m2.s-1]": 3.9e-14,
    "Negative particle diffusivity at SOC 0.3 [m2.s-1]": 5.2e-14,
    "Negative particle diffusivity at SOC 0.7 [m2.s-1]": 4.8e-14,
    "Negative particle diffusivity at SOC 1 [m2.s-1]": 3.5e-14,
}
result = entry.run(param_values)

2D Interpolation

For parameters varying with two variables (e.g., SOC and temperature):
entry = iwp.direct_entries.PiecewiseInterpolation2D(
    base_parameter_name="Negative particle diffusivity [m2.s-1]",
    breakpoint1_values=[0.0, 0.5, 1.0],
    breakpoint1_parameter_name="SOC",
    breakpoint2_values=[273.15, 298.15, 323.15],
    breakpoint2_parameter_name="Temperature [K]",
    smoothing1=1e-4,
    smoothing2=0.1,  # Larger for temperature scale
)
Use different smoothing parameters for dimensions with different scales (e.g., SOC in [0, 1] vs Temperature in [273, 323] K).
The piecewise interpolant types and options shown are not exhaustive. See the API reference for full details.

Formulations: Knots vs Slopes

Two equivalent parameterizations are available:
FormulationParametersBest for
KnotsValues at each breakpointDirect measurements
SlopesInitial value + slopes between breakpointsOptimization (smoother landscape)
Both have the same degrees of freedom. Slopes can be converted to knots using SlopesToKnots.

OCP Interpolants

Open-circuit potential (OCP) interpolants are specialized functions U(θ)U(\theta) that return equilibrium voltage for a given stoichiometry.

From Experimental Data

calc = iwp.calculations.OCPDataInterpolant(electrode="positive")
Creates a smooth interpolant from half-cell OCP measurements. Data should be collected at low C-rates (C/20 or slower) to approximate equilibrium.

From MSMR Parameters

calc = iwp.calculations.MSMROCPInterpolant(electrode="positive")
Evaluates the MSMR model over a voltage range to create an interpolant. Provides thermodynamic consistency and reliable extrapolation.

Blended MSMR / Experimental OCP

The recommended approach combines experimental data with MSMR extrapolation:
calc = iwp.calculations.OCPDataInterpolantMSMRExtrapolation(
    electrode="positive"
)
The blending function smoothly transitions between data and MSMR: U(x)=w(x)Udata(x)+(1w(x))UMSMR(x)U(x) = w(x) \cdot U_{\text{data}}(x) + (1 - w(x)) \cdot U_{\text{MSMR}}(x) where w(x)w(x) is a bump function that equals ~1 inside the data range and ~0 outside.

The Inaccessible Lithium Problem

Experimental OCP data never covers the full 0-1 stoichiometry range due to:
  • Electrolyte decomposition at low voltages
  • Structural instability at high voltages
Without physics-based extrapolation, simulations that access stoichiometries outside the data range produce unreliable results.
Always use MSMR blending if your simulation might access stoichiometries outside your experimental range. The MSMR model provides physically reasonable behavior at the extremes.

Numerical Considerations

Smoothing Parameter Selection

ValueEffect
Too smallApproaches discontinuous, may cause solver issues
Too largeExcessive smoothing, reduces accuracy
Recommendedϵ104\epsilon \approx 10^{-4} to 103×10^{-3} \times (range of variable)

Extrapolation Behavior

Both piecewise and OCP interpolants use constant extrapolation outside their defined ranges. This prevents unbounded values and is physically reasonable for many battery parameters.

Common Use Cases

SOC-Dependent Diffusivity

Capture phase transitions or concentration effects on transport

OCP Functions

Define equilibrium voltage for electrochemical models

Temperature Effects

Non-Arrhenius temperature dependence

Coupled Dependencies

Parameters depending on multiple variables simultaneously

Best Practices

  1. Breakpoint placement: Place more breakpoints where the parameter changes rapidly
  2. Smoothing selection: Start with defaults; increase if solver has trouble
  3. Visualization: Always plot interpolants across the full range to check for artifacts
  4. MSMR for OCP: Use blended interpolants for robust extrapolation