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

# Design Optimization

> Mathematical formulation of battery design optimization: parameters, metrics, actions, penalty constraints, and multi-objective tradeoffs

Design optimization finds battery design parameters that meet performance objectives without requiring experimental data. Instead of fitting a model to measurements, you define what you want to achieve and let the optimizer explore the design space through repeated simulation.

## How It Works

```mermaid theme={null}
flowchart LR
    subgraph Optimizer
        P[Parameters]
    end

    subgraph Simulation
        M[Model] --> S[Solution]
    end

    subgraph Evaluation
        S --> V[Variables]
        V --> Met[Metrics]
        Met --> A[Actions]
        A --> C[Cost]
    end

    P --> M
    C --> P
```

The optimization loop:

1. **Parameters** define the design variables being optimized (e.g., electrode thickness, porosity)
2. **Model** runs a simulation with those parameters under specified operating conditions
3. **Variables** are time-series outputs from the simulation (voltage, temperature, capacity)
4. **Metrics** extract scalar values from variables (final voltage, maximum temperature, mean current)
5. **Actions** define what to do with metrics (maximize, minimize, constrain)
6. **Cost** combines action results into a single objective for the optimizer

## Design Parameters

Design parameters are the degrees of freedom the optimizer is allowed to vary. Each parameter has a feasible range (bounds) set by manufacturing constraints or material properties — for example, electrode thickness might be bounded between $25\,\mu\text{m}$ and $150\,\mu\text{m}$, and active material volume fraction between $0.4$ and $0.85$.

Choosing parameters well is more important than choosing many: two or three influential parameters with realistic bounds usually yields more insight than a dozen loosely-bounded ones. Where parameters are physically coupled — porosity and active material fraction must sum to one, for instance — the coupling should be encoded in the problem definition rather than left to the optimizer to discover.

## Metrics

Metrics transform simulation time-series into scalar values that can be optimized. They answer questions like "What is the voltage at the end of discharge?" or "What is the maximum temperature?"

### Point metrics

Extract a value at a specific condition in the simulation:

| Metric  | Extracts value at...     | Example                   |
| ------- | ------------------------ | ------------------------- |
| Time    | Specific time point      | Voltage at $t = 100$ s    |
| SOC     | Specific state of charge | Voltage at 50% SOC        |
| Voltage | Specific voltage         | Capacity when $V = 3.0$ V |

### Aggregation metrics

Compute statistics over the entire solution:

| Metric  | Computes          | Example                   |
| ------- | ----------------- | ------------------------- |
| Mean    | Average value     | Mean current during pulse |
| Maximum | Peak value        | Maximum temperature       |
| Minimum | Lowest value      | Minimum voltage           |
| Sum     | Accumulated total | Total energy              |

### Composed metrics

Derived quantities are built by combining primitive metrics with arithmetic. For example, pulse resistance is the voltage change divided by the current:

$$
R = \frac{V_{\text{after}} - V_{\text{before}}}{\bar{I}}
$$

### Step and cycle metrics

Experiments with multiple steps or cycles need metrics that unroll along that axis — e.g. capacity measured at the end of the discharge step of every cycle, yielding a capacity-fade curve rather than a single number.

## Actions

Actions define how the optimizer should treat each metric:

| Action      | Behavior                                       |
| ----------- | ---------------------------------------------- |
| Maximize    | Maximize the metric value                      |
| Minimize    | Minimize the metric value                      |
| GreaterThan | Constraint: metric must exceed a threshold     |
| LessThan    | Constraint: metric must stay below a threshold |

Constraints are typically enforced through **penalty functions**: when the constraint is violated, a large term is added to the cost proportional to the amount of violation. This converts a constrained problem into an unconstrained one that any cost-minimizing optimizer can handle.

### Multi-objective optimization

Most design problems trade off competing goals — energy vs. power, capacity vs. charge time, performance vs. temperature. There are two ways to combine them:

* **Weighted sum**: pick weights $w_i$ and optimize $\sum_i w_i f_i$. Simple, but the weights implicitly encode a preference and can hide Pareto tradeoffs.
* **Constraint-based**: maximize the primary objective subject to the others being bounded (e.g. maximize energy density subject to $T_{\max} \leq 50\,^{\circ}\text{C}$). Often more interpretable because the constraint thresholds map directly to design requirements.

## Example: Maximizing Energy Density

This example illustrates the full workflow on a classic battery design problem.

### Problem description

Electrode thickness presents a fundamental design tradeoff:

* **Thicker electrodes** increase capacity (more active material per unit area) but worsen rate capability because lithium must diffuse further
* **Thinner electrodes** improve power delivery but reduce total energy storage

We seek the thickness that maximizes energy density at a given discharge rate, subject to a temperature limit.

### Mathematical formulation

The optimization problem is:

$$
\max_{L_{\text{pos}}} \; E_g(L_{\text{pos}})
$$

subject to:

$$
L_{\text{pos}}^{\min} \leq L_{\text{pos}} \leq L_{\text{pos}}^{\max}
$$

$$
T_{\max}(L_{\text{pos}}) \leq T_{\text{limit}}
$$

where $L_{\text{pos}}$ is the positive electrode thickness, $E_g$ is the gravimetric energy density at end of discharge, $T_{\max}$ is the maximum cell temperature during discharge, and $T_{\text{limit}}$ is the temperature safety limit (e.g. $323\,\text{K}$).

The energy density is computed from the simulation as:

$$
E_g = \frac{\int_0^{t_f} V(t) \cdot I(t) \, dt}{m_{\text{cell}}}
$$

where $V(t)$ is voltage, $I(t)$ is current (positive = discharge), $t_f$ is the discharge end time, and $m_{\text{cell}}$ is the cell mass.

### What the optimizer does

For each candidate thickness, a simulation is run and the metrics are evaluated:

1. The model solves the electrochemical equations to get $V(t)$, $T(t)$, etc.
2. A point metric at $t_f$ extracts the final energy density
3. An aggregation metric extracts the peak temperature
4. The actions convert these into a cost: negative $E_g$ (for maximization) plus a penalty if $T_{\max} > T_{\text{limit}}$
5. The optimizer uses this cost to propose the next candidate

The converged solution balances energy density against thermal constraints — thicker electrodes store more energy but generate more heat from ohmic and kinetic losses.

## Choosing an Optimizer

Design optimization is a black-box problem: each evaluation is a full simulation, so optimizer choice mostly depends on simulation cost, parameter count, and available parallelism.

| Situation                                                       | Recommended approach                                                                                            |
| --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| Cheap, fast simulations with many parameters                    | Evolutionary search (differential evolution) with a small population over many generations                      |
| Expensive simulations, ten or fewer parameters, small budget    | Bayesian optimization — a surrogate model makes every evaluation count                                          |
| Expensive simulations evaluated in parallel at wide batch sizes | Trust-region Bayesian optimization (TuRBO) — scales surrogate efficiency to large batches and higher dimensions |
| No strong prior on problem structure                            | CMA-ES, a robust general-purpose default                                                                        |

Surrogate methods (Bayesian optimization, TuRBO, SOBER) do more work per round to save expensive simulations. Population methods (CMA-ES, differential evolution, particle swarm) are cheaper per iteration and suit faster objectives.

When simulations run in parallel, wall-clock time is driven by the number of optimization rounds rather than the total number of evaluations. TuRBO is designed for that regime; set its warm-up size to the batch width so the first round uses the available workers.

<Note>
  SOBER is useful when you want quadrature-style batch selection. For pure optimization, prefer TuRBO, Bayesian optimization, or differential evolution.
</Note>

## Best practices

**Parameter selection** — Choose parameters that have significant influence on the objective. Use bounds that reflect physical and manufacturing limits, and link coupled parameters (e.g. porosity $= 1 - $ active-material fraction) rather than treating them as independent.

**Operating conditions** — Simulate at conditions that reflect actual usage. A cell optimized for 1C discharge may perform poorly at 5C, and vice versa. Include rest periods and realistic duty cycles when they matter.

**Start simple** — Two or three parameters with a single clear objective will teach you more about the design space than a high-dimensional problem that takes hours to converge. Add complexity only once the simple version behaves as expected.

**Validate physically** — The optimizer will happily return mathematically optimal parameters that are physically unreasonable. Always sanity-check the solution against physical intuition and known design constraints.
