> ## 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.

# 区分的補間子

> Build smooth, differentiable piecewise interpolants for OCP, diffusivity, and SOC- or temperature-dependent battery parameters.

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:

$$
H_{\text{smooth}}(x; \theta, \epsilon) = \frac{1}{2}\left(1 + \tanh\left(\frac{x - \theta}{2\epsilon}\right)\right)
$$

where:

* $x$ 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 ($C^\infty$) and transitions from \~0 for $x \ll \theta$ to \~1 for $x \gg \theta$.

### 1D Piecewise Linear Interpolation

For a parameter $p$ varying with $x$, given breakpoints $\{x_0, x_1, \ldots, x_{N-1}\}$ with values $\{p_0, p_1, \ldots, p_{N-1}\}$:

$$
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:

$$
p_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), a `PiecewiseInterpolation1D` direct entry takes a base parameter name, a list of breakpoint values along the independent variable, and a smoothing parameter. The interpolant reads one parameter per breakpoint (e.g. `"Negative particle diffusivity at SOC 0.3 [m2.s-1]"`) and returns a smooth function of the independent variable.

### 2D Interpolation

For parameters varying with two variables (e.g., SOC and temperature), a `PiecewiseInterpolation2D` direct entry takes breakpoints along both axes and separate smoothing parameters for each.

<Note>
  Use different smoothing parameters for dimensions with different scales (e.g., SOC in \[0, 1] vs Temperature in \[273, 323] K).
</Note>

<Note>
  パイプラインでこれらの補間子を構成する方法については、[Pipelines → Calculations → Piecewise](/ja/pipelines/calculations/piecewise) を参照してください。
</Note>

### Formulations: Knots vs Slopes

Two equivalent parameterizations are available:

| Formulation | Parameters                                 | Best for                          |
| ----------- | ------------------------------------------ | --------------------------------- |
| **Knots**   | Values at each breakpoint                  | Direct measurements               |
| **Slopes**  | Initial value + slopes between breakpoints | Optimization (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(\theta)$ that return equilibrium voltage for a given stoichiometry.

### From Experimental Data

An `OCPDataInterpolant` calculation builds 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

An `OCPMSMRInterpolant` calculation evaluates the MSMR model over a voltage range to create an interpolant. This provides thermodynamic consistency and reliable extrapolation.

### Blended MSMR / Experimental OCP

The recommended approach combines experimental data with MSMR extrapolation via `OCPDataInterpolantMSMRExtrapolation`. The blending function smoothly transitions between data and MSMR:

$$
U(x) = w(x) \cdot U_{\text{data}}(x) + (1 - w(x)) \cdot U_{\text{MSMR}}(x)
$$

where $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.

<Warning>
  Always use MSMR blending if your simulation might access stoichiometries outside your experimental range. The MSMR model provides physically reasonable behavior at the extremes.
</Warning>

## Numerical Considerations

### Smoothing Parameter Selection

| Value       | Effect                                                             |
| ----------- | ------------------------------------------------------------------ |
| Too small   | Approaches discontinuous, may cause solver issues                  |
| Too large   | Excessive smoothing, reduces accuracy                              |
| Recommended | $\epsilon \approx 10^{-4}$ to $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

<CardGroup cols={2}>
  <Card title="SOC-Dependent Diffusivity" icon="battery-half">
    Capture phase transitions or concentration effects on transport
  </Card>

  <Card title="OCP Functions" icon="chart-line">
    Define equilibrium voltage for electrochemical models
  </Card>

  <Card title="Temperature Effects" icon="temperature-high">
    Non-Arrhenius temperature dependence
  </Card>

  <Card title="Coupled Dependencies" icon="arrows-cross">
    Parameters depending on multiple variables simultaneously
  </Card>
</CardGroup>

## 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
