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

# 区分的補間

> ionworks-schema で SOC や温度に依存するパラメータの滑らかな区分的補間を構築する方法を説明します

区分的補間は、1 つまたは 2 つの分岐変数の滑らかかつ微分可能な関数を生成します。SOC 依存の拡散係数、温度依存輸送、OCP 曲線などに有用です。数学的背景(平滑化ヘビサイド、ノット vs スロープ、ブレンディング)は [区分的補間 (英語ガイド)](/guide/calculations/piecewise) を参照してください。

## 1D 区分的補間

```python theme={null}
import ionworks_schema as iws

D_neg = iws.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,
)

values = iws.direct_entries.DirectEntry(
    parameters={
        "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,
    },
)

pipeline = iws.Pipeline({"D_neg values": values, "D_neg": D_neg})
```

補間器は分岐ごとに 1 つのパラメータを読み込みます(命名規則は `"<base> at <breakpoint_parameter_name> <value> [units]"`)。出力は分岐変数の滑らかな関数となります。

## 2D 区分的補間

2 変数(例: SOC と温度)に依存するパラメータには次を使用します。

```python theme={null}
import ionworks_schema as iws

D_neg = iws.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,
)
```

2 つの軸のスケールが大きく異なる場合(SOC ∈ \[0, 1] vs 温度 ∈ \[273, 323] K)は、平滑化パラメータを別々に指定します。

## OCP 補間器

| スキーマ                                                                  | 構築内容                         |
| --------------------------------------------------------------------- | ---------------------------- |
| `iws.calculations.OCPDataInterpolant(electrode=...)`                  | ハーフセル OCP 測定値から滑らかな補間器を構築    |
| `iws.calculations.OCPMSMRInterpolant(electrode=...)`                  | 電圧範囲で MSMR モデルを評価して補間器を構築    |
| `iws.calculations.OCPDataInterpolantMSMRExtrapolation(electrode=...)` | データ範囲内は測定値、範囲外は MSMR 外挿をブレンド |

```python theme={null}
import ionworks_schema as iws

ocp_pos = iws.calculations.OCPDataInterpolantMSMRExtrapolation(electrode="positive")

pipeline = iws.Pipeline({"ocp_pos": ocp_pos})
```

シミュレーションが測定データ範囲外の化学量論にアクセスする可能性がある場合は、ブレンド版補間器の使用を推奨します。MSMR が両端で熱力学的に整合した外挿を提供します。

## 補間方式の選択

1 次元補間を行うすべての計算 — OCP 補間 (`OCPDataInterpolant`、`OCPMSMRInterpolant`、`OCPDataInterpolantMSMRExtrapolation`)、拡散係数補間 (`DiffusivityDataInterpolant`、`DiffusivityFromMSMRData`、`DiffusivityFromMSMRFunction`、`ArrheniusDiffusivityFromMSMRData`、`ArrheniusDiffusivityFromMSMRFunction`)、エントロピー変化補間 (`EntropicChangeDataInterpolant`、`EntropicChangeFromMSMRFunction`) — はデータ点間の補間方式を選ぶ `"interpolator"` オプションを受け取ります。

| 値                    | 挙動                | 推奨用途                                            |
| -------------------- | ----------------- | ----------------------------------------------- |
| `"linear"` *(デフォルト)* | 隣接ノット間を直線で結ぶ      | データが粗い場合や過適合を避けたい場合                             |
| `"cubic"`            | 3 次スプライン補間        | 密にサンプリングされた滑らかな関係                               |
| `"pchip"`            | 単調 3 次 (PCHIP) 補間 | 単調なデータ(例: OCP 曲線)。通常の 3 次スプラインで発生し得るオーバーシュートを防ぐ |

```python theme={null}
import ionworks_schema as iws

ocp_pos = iws.calculations.OCPDataInterpolantMSMRExtrapolation(
    electrode="positive",
    options={"interpolator": "pchip"},
)
```

<Tip>
  OCP 曲線などの単調なデータでは、`"pchip"` が最も物理的に妥当な補間器となることが多いです。ノット間でも単調性を保ち、急峻な箇所で 3 次スプラインに起こり得る非物理的な振動を抑えます。
</Tip>

<CardGroup cols={2}>
  <Card title="区分的補間 (理論)" icon="stairs" href="/guide/calculations/piecewise">
    平滑化ヘビサイドの数学、ノット vs スロープ、MSMR ブレンディング (英語ガイド)。
  </Card>

  <Card title="パイプライン概要" icon="diagram-project" href="/ja/pipelines/overview">
    補間器がパイプラインでどう連結されるか。
  </Card>
</CardGroup>
