driftlet 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,21 +8,33 @@
8
8
  [![test](https://github.com/markblundeberg/driftlet/actions/workflows/test.yml/badge.svg)](https://github.com/markblundeberg/driftlet/actions/workflows/test.yml)
9
9
  [![npm](https://img.shields.io/npm/v/driftlet)](https://www.npmjs.com/package/driftlet)
10
10
 
11
- **driftlet is a fast, pure-JavaScript solver for 1D drift–diffusion–reaction problems**, built
12
- to be the engine of live, thermodynamically honest web demos of charge transport: in
13
- semiconductors, electrochemical cells, membranes and solid ionic conductors. It handles any mix
14
- of charged and neutral species, Poisson electrostatics (or strict neutrality), bulk and
15
- interfacial reactions, heterointerfaces, metals and external circuits, in steady state, in time
16
- and as small-signal impedance. It's small enough to run in a web page: no dependencies,
17
- millisecond solves.
11
+ **driftlet simulates charged species moving through one-dimensional devices**: semiconductor
12
+ junctions and solar cells, electrochemical cells and batteries, double layers, membranes and
13
+ nerves. It's a small JavaScript library with no dependencies, fast enough to solve live in a
14
+ web page as you drag a slider.
18
15
 
19
16
  [Live demos](https://markblundeberg.github.io/driftlet/demos/) · [npm](https://www.npmjs.com/package/driftlet) ·
20
17
  [reading level diagrams](docs/visualization.md) · [device reference](docs/device.md) ·
21
18
  [agent guide](llms.txt)
22
19
 
20
+ **One kind of physics.** Those look like different subjects, but underneath they're the same
21
+ one. Each is a cast of species (electrons, holes, ions, neutral molecules) that drift and
22
+ diffuse, each down its own electrochemical potential; their charge sets the electric field,
23
+ reactions turn one into another, and at interfaces they pass from one material to the next or
24
+ are stopped. A pn junction is electrons and holes in silicon. A silver electrode is Ag⁺ and NO₃⁻
25
+ in water, with Ag⁺ trading places with the metal's electrons at its surface. A nerve is Na⁺ and
26
+ K⁺ on either side of a membrane, crossing it through channels that open with voltage, and the
27
+ impulse travels along the fibre on the current those same ions carry inside it. Even the levels
28
+ each field draws are one quantity: a quasi-Fermi level, an electrode potential and a Nernst
29
+ potential are each a species' electrochemical potential. driftlet solves that one problem, in
30
+ steady state, in time and as small-signal impedance, so a new field is mostly a new cast, and
31
+ the work that makes it reliable in one field makes it reliable in the others.
32
+
23
33
  **Built to be relied on.** A drift–diffusion solver that handles a textbook pn junction is a
24
- weekend's work; one that keeps working on the devices people actually build is not. driftlet is
25
- tested two ways: every physics feature against an analytic result or an independent code, and
34
+ weekend's work; one that keeps working on the devices people actually build is not. In real
35
+ devices concentrations span 30 orders of magnitude and double layers are a millionth of the
36
+ device's length, and there a plain Newton solver fails or, worse, quietly converges to a wrong
37
+ answer. driftlet is tested two ways: every physics feature against an analytic result or an independent code, and
26
38
  thousands of randomly generated devices (junctions, MOS capacitors, solar cells, electrolyte
27
39
  cells, electrodes) put through cold solves, sweeps, transients and impedance, every result
28
40
  checked. A solve that fails reports it, with what went wrong where it can tell.
@@ -44,7 +56,7 @@ import { bandDiagram } from 'driftlet/plot'; // a level diagram as an SVG str
44
56
  ```
45
57
 
46
58
  Or straight from a CDN in a page, pinned to a version:
47
- `https://cdn.jsdelivr.net/npm/driftlet@0.12.0/src/index.js` (and `src/kit.js`, `src/plot.js`).
59
+ `https://cdn.jsdelivr.net/npm/driftlet@0.13.0/src/index.js` (and `src/kit.js`, `src/plot.js`).
48
60
  TypeScript declarations ship in the package. Writing a demo with an LLM agent? Point it at
49
61
  [`llms.txt`](llms.txt).
50
62
 
@@ -149,19 +161,19 @@ them locally, serve the repository root (e.g. `python3 -m http.server`) and open
149
161
  The same equations go by different names in different fields. If your problem is one-dimensional
150
162
  (planar, or radial: spheres and cylinders, or any cross-section varying along x), it's probably here:
151
163
 
152
- | If you work on | you may call it | start from | checked against |
153
- |---|---|---|---|
154
- | Semiconductor devices | drift–diffusion, van Roosbroeck, quasi-Fermi levels, Scharfetter–Gummel; pn, Schottky, MOS, heterojunctions; thin-film transistors (gradual channel, in the [saturation demo](https://markblundeberg.github.io/driftlet/demos/saturation.html#transistor)) | [first example](#a-semiconductor-junction), [pn](https://markblundeberg.github.io/driftlet/demos/pn.html) and [MOS](https://markblundeberg.github.io/driftlet/demos/mos.html) demos, [`contacts`](test/contacts.test.js), [`metal`](test/metal.test.js) tests | exact built-in potential, Shockley J–V, depletion charge, MOS C–V |
155
- | Solar cells | photogeneration, radiative and SRH recombination | [solar](https://markblundeberg.github.io/driftlet/demos/solar.html) [organic (excitons)](https://markblundeberg.github.io/driftlet/demos/organic.html) and [perovskite (mobile ions)](https://markblundeberg.github.io/driftlet/demos/perovskite.html) demos, [`ionmonger`](test/ionmonger.test.js), [`reactions`](test/reactions.test.js) and [`generation`](test/generation.test.js) tests: generation is a reaction from a photon reservoir (uniform, or Beer–Lambert with `photogeneration()`), SRH as a rate law, in the bulk and at faces | `J_sc = qG(L_n + L_p + W)`; J_sc under Beer–Lambert against collection theory; Shockley J–V in the dark |
156
- | Electrochemistry, corrosion | Nernst–Planck, concentration polarization, limiting current, Butler–Volmer, Warburg, cyclic voltammetry, salt bridges and liquid junctions, mixed potentials, electrodes under a film | [second example](#an-electrochemical-cell), [cyclic voltammetry](https://markblundeberg.github.io/driftlet/demos/redox.html), [Daniell cell](https://markblundeberg.github.io/driftlet/demos/daniell.html), [saturation](https://markblundeberg.github.io/driftlet/demos/saturation.html), [impedance](https://markblundeberg.github.io/driftlet/demos/impedance.html) and [liquid-junction](https://markblundeberg.github.io/driftlet/demos/junction.html) demos, [`circuit`](test/circuit.test.js), [`kinetics`](test/kinetics.test.js), [`impedance`](test/impedance.test.js), [`junction`](test/junction.test.js), [`ports`](test/ports.test.js) tests | `i_lim·tanh(V/4V_T)`, Butler–Volmer closed form, finite-length Warburg; junction potentials against Henderson, Planck, JPCalc and LJPcalc; Wagner–Traud |
157
- | Batteries, intercalation | OCV, insertion hosts, chemical diffusion | [insertion demo](https://markblundeberg.github.io/driftlet/demos/insertion.html), [`statistics`](test/statistics.test.js) test | composition vs OCV, π²D/4L² relaxation |
158
- | Double layers, colloids | Poisson–Boltzmann, Gouy–Chapman–Stern, Debye screening, crowding (Bikerman) | [double-layer demo](https://markblundeberg.github.io/driftlet/demos/double-layer.html), [`equilibrium`](test/equilibrium.test.js) test | Gouy–Chapman charge and profile, Kilic–Bazant–Ajdari |
159
- | Membranes, desalination | Donnan, ion exchange, liquid junctions, water dissociation | [membrane demo](https://markblundeberg.github.io/driftlet/demos/membrane.html), [`equilibrium`](test/equilibrium.test.js), [`neutral`](test/neutral.test.js) tests | Donnan partition, Planck EMF |
160
- | Solid-state ionics | mixed ionic–electronic conduction, defect chemistry, mobile ions | [`statistics`](test/statistics.test.js), [`reactions`](test/reactions.test.js) tests | mass action from standard potentials |
161
- | Biophysics, nanofluidics | charged nanochannels and pores, resting potentials, Goldman–Hodgkin–Katz, Nernst, Donnan, pumps and leaks | [charged-nanochannel](https://markblundeberg.github.io/driftlet/demos/channel.html), [resting-potential](https://markblundeberg.github.io/driftlet/demos/cell.html), [action-potential](https://markblundeberg.github.io/driftlet/demos/axon.html) and [liquid-junction](https://markblundeberg.github.io/driftlet/demos/junction.html) (a patch pipette's) demos, [`pore`](test/pore.test.js) test; a membrane as a face: a capacitor with ion permeabilities, and the Na⁺/K⁺ pump as a reaction on it ([`membrane`](test/membrane.test.js) test); voltage-gated channels with Hodgkin–Huxley kinetics, action potentials, and their propagation along an axon ([`gates`](test/gates.test.js), [`cable`](test/cable.test.js) tests) | GHK potential and current–voltage curve; a resolved lipid layer; Mullins–Noda; the pump's static head; Donnan; HH gating under voltage clamp; the space-clamped HH equations |
162
-
163
- The tests are worked setups, each with its analytic check, so they double as recipes. The
164
- [validation table](#validation) lists them all.
164
+ | If you work on | you may call it | start from |
165
+ |---|---|---|
166
+ | Semiconductor devices | drift–diffusion, van Roosbroeck, quasi-Fermi levels, Scharfetter–Gummel; pn, Schottky, MOS, heterojunctions, thin-film transistors | the [first example](#a-semiconductor-junction); [pn](https://markblundeberg.github.io/driftlet/demos/pn.html), [MOS](https://markblundeberg.github.io/driftlet/demos/mos.html) and [transistor](https://markblundeberg.github.io/driftlet/demos/saturation.html#transistor) demos |
167
+ | Solar cells | photogeneration, Beer–Lambert, radiative and SRH recombination, excitons, mobile ions | [solar](https://markblundeberg.github.io/driftlet/demos/solar.html), [organic](https://markblundeberg.github.io/driftlet/demos/organic.html) and [perovskite](https://markblundeberg.github.io/driftlet/demos/perovskite.html) demos |
168
+ | Electrochemistry, corrosion | Nernst–Planck, concentration polarization, limiting current, Butler–Volmer, Warburg, cyclic voltammetry, salt bridges, liquid junctions, mixed potentials | the [second example](#an-electrochemical-cell); [cyclic voltammetry](https://markblundeberg.github.io/driftlet/demos/redox.html), [Daniell cell](https://markblundeberg.github.io/driftlet/demos/daniell.html), [limiting current](https://markblundeberg.github.io/driftlet/demos/saturation.html), [impedance](https://markblundeberg.github.io/driftlet/demos/impedance.html) and [liquid-junction](https://markblundeberg.github.io/driftlet/demos/junction.html) demos |
169
+ | Batteries, intercalation | OCV, insertion hosts, chemical diffusion | [insertion](https://markblundeberg.github.io/driftlet/demos/insertion.html) demo |
170
+ | Double layers, colloids | Poisson–Boltzmann, Gouy–Chapman–Stern, Debye screening, crowding (Bikerman) | [double-layer](https://markblundeberg.github.io/driftlet/demos/double-layer.html) demo |
171
+ | Membranes, nanofluidics | Donnan, ion exchange, Teorell–Meyer–Sievers, charged nanochannels and pores | [membrane](https://markblundeberg.github.io/driftlet/demos/membrane.html) and [nanochannel](https://markblundeberg.github.io/driftlet/demos/channel.html) demos |
172
+ | Solid-state ionics | mixed ionic–electronic conduction, defect chemistry, mobile ions | [`statistics`](test/statistics.test.js) and [`reactions`](test/reactions.test.js) tests |
173
+ | Cell physiology, neuroscience | resting potential, Nernst, Goldman–Hodgkin–Katz, the Na⁺/K⁺ pump, patch pipettes, Hodgkin–Huxley, action potentials, the cable equation, myelin | [resting-potential](https://markblundeberg.github.io/driftlet/demos/cell.html), [action-potential](https://markblundeberg.github.io/driftlet/demos/axon.html), [propagation](https://markblundeberg.github.io/driftlet/demos/propagation.html) and [myelin](https://markblundeberg.github.io/driftlet/demos/myelin.html) demos |
174
+
175
+ The tests are worked setups, each with its analytic check, so they double as recipes; the
176
+ [validation table](docs/reliability.md#the-validation-table) lists them all.
165
177
 
166
178
  ## How to think about it
167
179
 
@@ -180,10 +192,12 @@ driftlet insists on thermodynamically honest concepts ([conventions](docs/conven
180
192
  - The species voltage `V_i = μ̄_i / (z_i F)` and standard level `V°_i` are available as views,
181
193
  alongside redox levels: [reading level diagrams](docs/visualization.md) explains them.
182
194
 
195
+ ## What it does
196
+
183
197
  A device is a line of **regions** (each a **material** plus a length, fixed charge and
184
198
  initial composition), joined at **interfaces**, with a **contact** at each end. The contacts
185
199
  and any internal **ports** are its **terminals**, each held at a voltage or driven by a
186
- current. Supported physics:
200
+ current. Within that:
187
201
 
188
202
  - any mix of charged and neutral species; per-material diffusivities and standard potentials;
189
203
  species absent from some materials;
@@ -196,11 +210,15 @@ current. Supported physics:
196
210
  conductivity: Schottky and MOS gates as regions, electrodes with reactions at their faces,
197
211
  bipolar electrodes;
198
212
  - contacts as outside phases with known levels, joined by the same laws as internal faces:
199
- ohmic contacts, reversible electrodes, baths, pinned barriers, conductance links, gates and
213
+ ohmic contacts, reversible electrodes, baths, pinned barriers, conductance links, surface
214
+ velocities (thermionic emission over a Schottky barrier, surface recombination), gates and
200
215
  Stern layers;
201
216
  - interfaces with explicit alignment, blocking, interface resistance, and Butler–Volmer
202
217
  reactions with participants on either side (electrode reactions, ion and electron transfer,
203
218
  mixed potentials), and a choice of electrostatic law (pinned, neutral, Helmholtz);
219
+ - membranes as capacitive faces with ion permeabilities (Goldman–Hodgkin–Katz), pumps as
220
+ reactions on them and voltage-gated channels with Hodgkin–Huxley kinetics; or spread along a
221
+ region through a port, as an axon's wall;
204
222
  - bulk reactions with thermodynamically consistent mass action (recombination, water
205
223
  autoionisation, …);
206
224
  - imposed flow (advection) and current-free eddy mixing;
@@ -235,57 +253,11 @@ How it works numerically is in [numerics](docs/numerics.md).
235
253
 
236
254
  ## Validation
237
255
 
238
- Every physics feature is tested against analytic results (`npm test`, node's built-in runner).
239
-
240
- | What | Checked against | Tolerance |
241
- |---|---|---|
242
- | Equilibrium of any device | μ̄ of every species flat; zero current | 1e-9 RT or better |
243
- | Gouy–Chapman double layer | analytic charge and full nonlinear profile | 2e-3 |
244
- | Debye screening (linear limit) | gate in series with `ε/λ_D` | 1e-3 |
245
- | Donnan potential | analytic partition, between floating layers and real baths | 1e-8 |
246
- | Heterointerfaces with unequal dipoles (A \| B \| A) | per-face analytic double-layer split | 3e-3 |
247
- | Floating island | Gauss's law; conserved amounts through gate sweeps | 1e-12 |
248
- | pn junction | exact built-in potential; depletion charge; short-diode J–V | 1e-12; 1%; 2e-3 |
249
- | Long pn diode with recombination | Shockley J–V incl. depletion recombination | 2e-3 |
250
- | Haynes–Shockley pulse | an injected hole packet's drift, spread and decay at the ambipolar μ*, D*, 1/τ*; nothing lost while it goes in | 2e-4; 1e-2; 2e-3 |
251
- | A packet laid down as a `c0` profile | the same rates from a Gaussian at t = 0: μ*E t, σ₀² + 2D*t, e^(−t/τ*) | 3e-4; 1e-2; 1e-3 |
252
- | Beer–Lambert photogeneration in an n⁺p cell | J_sc = qΦ∫αe^(−αx)η(x)dx with the emitter's, depletion layer's and base's collection, α from 1e3 to 1e7 /m on one coarse grid | 5e-4 (3e-3 in the emitter) |
253
- | Organic bilayer: excitons | J_sc from excitons diffusing to the donor/acceptor interface (Beer–Lambert, a blocking anode, the splitting reaction's finite velocity); V_oc from charge-transfer detailed balance | 5e-4; 1e-6 V |
254
- | SRH recombination | bulk: G = R_SRH(n, p) with n = N_D + p, midgap and shallow traps, low to high injection; at a face: zero in the dark, the law between the two edge nodes, every pair collected or recombined | 1e-6; 1e-9 |
255
- | Perovskite J–V hysteresis, against IonMonger | an independent code (finite elements, Octave): mobile iodide vacancies, interface SRH, scans from 1 mV/s to 1 kV/s — hysteresis index, P_max, V_oc, the whole loop (as current where it's gentle, as a voltage offset near V_oc, where it falls at up to 1100 mA/cm² per volt) | 1.5e-3; 0.05 mW/cm²; 2 mV; 0.03 mA/cm² and 1 mV (0.010 and 0.31 mV found) |
256
- | Illuminated long pn diode | `J_sc = qG(L_n + L_p + W)` from a cold start; superposition at low injection | 5e-3; 1e-2 |
257
- | Schottky barrier (metal region \| n-Si) | surface density from the alignment; depletion charge | 5e-3; 2% |
258
- | Charged pore or nanochannel (resolved Donnan layers at each mouth) | conductance against salt, down to its plateau, as Teorell–Meyer–Sievers in a long pore (short ones short by end layers ∝ 1/L); the zero-current voltage across a salt gradient; a symmetric pore's I–V odd, rectification with charge on one side or bipolar | 1%; 5e-3 to 1e-4; 1e-9 |
259
- | Cell membrane (a capacitive face with permeabilities) | GHK resting potential (neutral or resolved solutions) and current–voltage curve; the same as a resolved 5 nm lipid layer; charging at I/C; with the Na⁺/K⁺ pump in a closed cell, Mullins–Noda, the static head 3Δμ̄_Na − 2Δμ̄_K = ΔG_ATP, and Donnan with the pump off | 1e-5 V; 3e-3; 2e-5 V; 1%; 1e-9 |
260
- | Voltage-gated channels (Hodgkin–Huxley gates on a membrane face) | each gate at α/(α + β) under a voltage clamp, and relaxing at α + β after a step; a squid axon's action potential against the space-clamped HH equations with GHK currents; its impedance at rest (inductive, resonant) against the linearised equations | 1e-12; 2e-4; 1 mV; 5e-4 |
261
- | A propagating action potential (a squid axon along x: gated membrane port, ions drifting in the axoplasm) | rest at HH's −65 mV and gate values; conduction velocity against the cable equation solved directly, and HH's 18.8 m/s; a myelinated axon's saltatory conduction, node by node, against a compartmental cable | 0.01 mV, 1e-4; 2e-3; 1%; 1 µs of ~25 per node |
262
- | Liquid junctions in mixtures | Henderson's formula against JPCalc's published values; driftlet's steady junction against Planck by shooting and the stationary Nernst–Planck codes LJPcalc and JLJP, a patch pipette's K-gluconate among them; a free-diffusion junction constant in time, between the two | 0.015 mV; 2e-4 and 0.02 mV; 5e-3 mV |
263
- | Liquid junction, open circuit | cell EMF 2t₊(RT/F) ln(c₁/c₂); Planck diffusion potential | 1e-4 |
264
- | Salt diffusion mode from a `c0` profile | c̄ + a·sin(πx/2L) decaying at π²D/4L², D = 2D₊D₋/(D₊ + D₋) | 2e-5 |
265
- | Concentration polarization | `i = i_lim tanh(V/4V_T)`, incl. galvanostatic and load modes | 2e-4 |
266
- | Butler–Volmer electrode | Nernst equilibrium; mixed kinetic/diffusion closed form | 5e-4 |
267
- | Redox couple between inert electrodes | Nernst level of Fe³⁺/Fe²⁺; the couple's total conserved at equilibrium and under current | 1e-9; 1e-10 |
268
- | Interface conductance and ion transfer | series 1/G; BV rate law at the interface state | 1e-4; 1e-8 |
269
- | Mass action | `c(H⁺)c(OH⁻) = K_w` from standard potentials; moiety conservation | 1e-9 |
270
- | Second law | free energy in through the terminals (Σ N μ̄ over every species) equals the dissipation, every term ≥ 0: a pn diode, an open-circuit junction running on chemical input alone, electrodes with a bipolar plate, a port and a contact behind conductances | 1e-10 |
271
- | Transients | RC charging of a gated island; water relaxation rate | 1%; 2e-3 |
272
- | Time integration | BE first order, BDF2 second order; adaptive error control | ratios 2, 4 |
273
- | Advection and eddy mixing | exact convection–diffusion profile; `D + D_mix`; junction EMF unchanged by mixing | 1e-12; 1e-12; 1e-5 |
274
- | Metal regions | ohmic; Schottky face and MOS gate equal their contact forms; Ag \| AgNO₃ \| Ag with metal electrodes; bipolar electrode at V/2 | 1e-12; 1e-9; 1e-9; 1e-9 |
275
- | Internal ports | transmission line σV tanh(L/λ)/λ (O(h²)); held level; MOS low-frequency C–V with a grounded channel, and without one the same equilibrium, and a gate step filling the inversion layer to it | 1e-4; 1e-9; 2e-3; 1e-6; 1e-3 |
276
- | Cross-sections (spherical, cylindrical, any A(x)) | steady diffusion to a sphere and a cylinder (exact on any grid); Cottrell with the spherical term; uptake by a sphere filling from its surface; Debye–Hückel around a charged sphere, potential and charge | 1e-10; 3e-4; 2e-4; 1e-3, 3e-4 |
277
- | A capacitance through a port | a thin-film transistor against the charge-sheet model (below threshold to saturation, second order); de Levie impedance; gate impedance against dQ/dV | 5e-4; 1e-3; 1e-6 |
278
- | Electrode surfaces (coverage) | Langmuir isotherm against potential; the charge to fill a surface; the active–passive curve, blocking exactly (1 − θ) | 1e-9; 1e-3; 1e-9 |
279
- | Electrodes spread through a port | transmission line with the reaction's linear kinetics as the conductance (O(h²)), rates along it; Wagner–Traud mixed potential of two Butler–Volmer couples, floating | 1e-4, 2e-3; 1e-6 V |
280
- | Impedance | Macdonald blocking-electrode spectrum, 100 Hz–1 GHz; finite-length Warburg (Ag \| AgNO₃ \| Ag); DC limit = differential resistance; a p⁺n⁺ junction without recombination, Re Y → dI/dV and C = dQ/dV; a redox electrode against a bath at its open circuit, Re Y → dI/dV | 3e-4; 3e-5; 1e-6; 1e-4, 1e-6; 1e-4 |
281
- | Conservation | per step, and against time-integrated contact fluxes | 1e-11 relative |
282
- | Strictly neutral limit (ε = 0) | Planck EMF; polarization with no overlimiting; Donnan at neutral faces | 1e-5; 1e-4; 1e-9 |
283
- | Fermi–Dirac statistics | `𝓕_{±1/2}` vs quadrature; degenerate bulk; accumulation charge via `𝓕_{3/2}` | 1e-13; 1e-12; 1e-3 |
284
- | Crowded double layer (lattice gas) | Kilic–Bazant–Ajdari charge, up to `ψ = 40 V_T`; custom function reproduces it | 5e-4; 1e-10 |
285
- | Non-ideal transport | steady flux −(D/L)ΔP of the grand potential (lattice exact, Redlich–Kister O(h²)) | 1e-12; 1e-4 |
286
- | Debye–Hückel | junction EMF 2t₊(RT/F) ln(a₁/a₂) with activities | 1e-6 |
287
- | Data library | ion μ° against the electrochemical series and `K_w`; D against limiting conductivities; band data against `n_i` | 10 mV; 0.5%; 15% |
288
- | Intercalation host (OCV) | composition vs table and isotherm; chemical diffusion flux and relaxation rate | 1e-12; 1e-5; 1e-4 |
256
+ Every physics feature lands with a test against an analytic result, or against an independent
257
+ code where there isn't one: over 300 tests (`npm test`), from Shockley's diode equation and the
258
+ Gouy–Chapman double layer to Hodgkin and Huxley's conduction velocity, and against IonMonger,
259
+ JPCalc, LJPcalc and JLJP. [How far to trust it](docs/reliability.md) lists every check with its
260
+ tolerance, alongside the random-device stress tests and the known limits.
289
261
 
290
262
  ## Performance
291
263
 
package/docs/device.md CHANGED
@@ -275,7 +275,9 @@ Na⁺/K⁺-ATPase between the outside (left) and the cytoplasm (right):
275
275
  together). Membrane potentials are $`\phi`$ differences between the two solutions, $`\phi_{\mathrm{in}} - \phi_{\mathrm{out}}`$,
276
276
  read from `sol.phi` (or a `'phi'` probe in a transient). A bath contact's terminal voltage is
277
277
  its reference species' level instead, what an electrode reversible to that species would read,
278
- so between two different solutions it differs from $`\Delta\phi`$ by that species' Nernst term.
278
+ so between two different solutions it differs from $`\Delta\phi`$ by that species' Nernst term;
279
+ a bath given no reference has its $`\phi`$ as its terminal voltage, and between two of those the
280
+ terminals read $`\Delta\phi`$ itself.
279
281
 
280
282
  ### Voltage-gated channels
281
283
 
@@ -329,7 +331,12 @@ Two things differ from the textbook equations. The currents are GHK's, which rec
329
331
  conductance depends on the voltage, so a permeability matches a conductance $`g`$ at one voltage
330
332
  only (above, the chord conductances at rest, −65 mV, for Hodgkin and Huxley's 120, 36 and 0.3
331
333
  mS/cm²; matched at the reversal potentials instead, the rest depolarises itself and the axon
332
- fires on its own). And a cell without a pump has no resting steady state: `solve()` finds its
334
+ fires on its own). Their own linear channels are conductance links: $`G\,(V_{i,L} - V_{i,R})`$
335
+ toward +x is $`g\,(E_i - V)`$, with $`E_i`$ the Nernst potential at the edge concentrations, so
336
+ `{ type: 'conductance', G: 360, gates: { n: 4 } }` is their K⁺ channel exactly
337
+ (`hodgkinHuxley({ T, linear: true })` writes all three). Between two baths whose terminal
338
+ voltage is their $`\phi`$, a held step is their voltage clamp, and the K⁺ current at its end is
339
+ $`g_K n_\infty^4 (V - E_K)`$ to 2e-3. And a cell without a pump has no resting steady state: `solve()` finds its
333
340
  Donnan equilibrium, every permeant ion level across the membrane, which the real cell reaches
334
341
  only over hours. Start a transient from the concentrations given (it settles to rest within
335
342
  milliseconds), or keep the gradients with the Na⁺/K⁺ pump on the same face. Started from the
@@ -447,13 +454,22 @@ contacts: {
447
454
  at $`V + \mathtt{offset}`$, $`J = G \cdot (V_{\mathrm{out}} - V_i)`$, G in S/m².
448
455
  - `{ type: 'exchange', k, mu }` (neutral species):
449
456
  $`N_{\mathrm{in}} = k \cdot (\mu_{\mathrm{out}} - \mu)/RT`$, k in mol/(m²·s).
457
+ - `{ type: 'velocity', v, offset }` (or `mu`, for a neutral species): a surface velocity,
458
+ $`N_{\mathrm{in}} = v\,(c_{\mathrm{eq}} - c)`$ with v in m/s and $`c_{\mathrm{eq}}`$ the end node's
459
+ concentration in equilibrium with the outside level, i.e.
460
+ $`v\,c\,(e^{(\bar\mu_{\mathrm{out}} - \bar\mu)/RT} - 1)`$, which keeps the flux's sign that of the
461
+ level difference whatever the statistics. It lies between `'blocked'` (v → 0) and
462
+ `'equilibrium'` (v → ∞): a contact's surface recombination velocity, or thermionic emission
463
+ over a Schottky barrier (below).
450
464
  - `'blocked'`: no flux.
451
465
 
452
466
  **`bath`** (instead of `species` and `phi`): the outside phase is a neutral composition `c`
453
467
  held in place by a charged `reference` species (as for a reversible reference electrode, e.g.
454
468
  Cl⁻ for Ag/AgCl), which is the terminal. Every bath species is in equilibrium at the level its
455
469
  composition implies, and the $`\phi`$ law is `'bulk'`. An optional `offset` places the reference
456
- species relative to V.
470
+ species relative to V. Without a `reference`, V is the bath's own $`\phi`$: an ideal salt bridge
471
+ (no junction potential), the convention by which membrane potentials are $`\phi`$ differences.
472
+ Between two such baths, a held $`V_{\mathrm{right}} - V_{\mathrm{left}}`$ is a voltage clamp.
457
473
 
458
474
  **`phi`**, required whenever any species or reaction connects at the contact (default
459
475
  `'neutral'`):
@@ -471,6 +487,18 @@ species relative to V.
471
487
  means. For example, a Schottky barrier $`\phi_B`$ on n-type material with
472
488
  $`\mu^\circ_{\mathrm{e}^-} = 0`$ is `zeroCharge: φ_B`.
473
489
 
490
+ A Schottky contact is that pinned barrier with its carriers passing at their emission velocities:
491
+ `{ V, terminal: 'e-', species: { 'e-': { type: 'velocity', v }, 'h+': { type: 'velocity', v: vp, offset: 0 } }, phi: 'pinned', zeroCharge: φ_B }`,
492
+ with Bethe's thermionic-emission velocity $`v = A^* T^2/(F N_c)`$ ($`N_c`$ in mol/m³, the data
493
+ library's `cRef` for e⁻; about $`2 \times 10^4`$ m/s in n-Si with $`A^*`$ = 112 A/(cm²K²)). The
494
+ forward current is then thermionic emission's, $`J = A^* T^2 e^{-\phi_B/V_T}(e^{V/V_T} - 1)`$,
495
+ lowered where the drift–diffusion through the depletion region can't keep up (Crowell and Sze's
496
+ combination): 4–6% short of it for a 0.85 eV barrier on 1e16 cm⁻³ n-Si from 0.1 to 0.4 V
497
+ ([`contacts`](../test/contacts.test.js) test). With `'equilibrium'` links instead (an infinite
498
+ velocity) the barrier passes whatever the semiconductor brings to it, which is the diffusion
499
+ theory of the Schottky diode: there, 17 to 27 times more current. Neither has image-force
500
+ lowering or tunnelling.
501
+
474
502
  Like every alignment, `zeroCharge` is a property of that interface. To estimate it from vacuum
475
503
  levels, `vacuumZeroCharge(def, W, inside)` from `driftlet/kit` takes the work function W of the
476
504
  conductor at the terminal voltage and the inside material's anchor and offset (see the
@@ -688,22 +716,22 @@ its window, each gate is a fraction open with Hodgkin–Huxley kinetics in the v
688
716
  port's capacitance there, $`V_m = \phi - (V - \mathtt{zeroCharge})`$, and its conductance links name
689
717
  the gates that scale them (`G × m³h`). That's a membrane all along a region, between it and an
690
718
  outside held by the port: an axon's, with x running along the axon. Per volume of axoplasm, a
691
- cylinder of radius a has $`2/a`$ of membrane (`area`); held at `V: 0` with `zeroCharge: 0`, the port's
692
- V is the outside's $`\phi`$, and a charged species' `offset` is its level there against that,
693
- $`(\mu^\circ + RT\ln(c_{out}/c_{\mathrm{ref}}))/(zF)`$. A conductance link's current is then
694
- $`G\,(V_{i,out} - V_i)`$, which is $`g\,a_m (E_i - V_m)`$: Hodgkin and Huxley's linear channel, with $`E_i`$ the
695
- Nernst potential at the inside's concentration there.
719
+ cylinder of radius a has $`2/a`$ of membrane (`area`). Give the port the outside's composition as a
720
+ `bath`: its V is then the outside's $`\phi`$ (held at 0, with `zeroCharge: 0`), and each linked ion's
721
+ level there follows from the composition, $`(\mu^\circ + RT\ln(c_{out}/c_{\mathrm{ref}}))/(zF)`$ against
722
+ it, as an `offset` would give it. (Only the linked ions' levels are taken, so the bath needn't list
723
+ or balance the rest.) A conductance link's current is then $`G\,(V_{i,out} - V_i)`$, which is
724
+ $`g\,a_m (E_i - V_m)`$: Hodgkin and Huxley's linear channel, with $`E_i`$ the Nernst potential at the
725
+ inside's concentration there. The kit's `hodgkinHuxley({ T, area })` writes their links so:
696
726
 
697
727
  ```js nocheck
728
+ const hh = hodgkinHuxley({ T, area: 2 / 238e-6 }); // a squid giant axon, radius 238 µm
698
729
  ports: [{
699
- name: 'membrane', region: 'axon', V: 0, terminal: 'K+', area: 2 / 238e-6, // a squid giant axon
730
+ name: 'membrane', region: 'axon', V: 0, area: 2 / 238e-6,
700
731
  capacitance: { C: 0.01, zeroCharge: 0 },
701
- gates: hodgkinHuxley({ /* … */ T }).gates,
702
- species: {
703
- 'Na+': { type: 'conductance', G: 1200 * 2 / 238e-6, offset: offsetNa, gates: { m: 3, h: 1 } },
704
- 'K+': { type: 'conductance', G: 360 * 2 / 238e-6, offset: offsetK, gates: { n: 4 } },
705
- 'Cl-': { type: 'conductance', G: 3 * 2 / 238e-6, offset: offsetCl }, // the leak
706
- },
732
+ bath: { c: { 'Na+': 367, 'K+': 18.6, 'Cl-': 459 } }, // sea water, as far as the channels go
733
+ gates: hh.gates,
734
+ species: hh.species, // Na⁺ (G × m³h), K⁺ (G × n⁴), and the leak (Cl⁻), G = g × area
707
735
  }]
708
736
  ```
709
737
 
@@ -841,12 +869,14 @@ const now = dev.solution(); // snapshot of the current state
841
869
  - `solve()` finds the steady state from the current state without advancing time. If every
842
870
  species is fed by a contact, it solves the steady equations directly. Otherwise conserved
843
871
  amounts (blocked species, reactive moieties) are kept exactly. If a direct solve fails at a
844
- bias (a cold start far from equilibrium), it solves with both terminals level and ramps the
845
- right terminal's voltage to its target; with generation reactions (below), it ramps their
846
- rates up from nearly nothing. A terminal driven by a current (open circuit, say) is held at a
847
- voltage instead, the voltage marched until the current crosses its target, and floated from
848
- there. If 20 V either way brings no crossing (a current beyond the limiting one), the solve
849
- fails with a warning giving the range of currents the held voltages passed.
872
+ bias, it ramps the contacts' voltages from where they were last solved (the left one first,
873
+ where it moved), or from level terminals on a cold start; with generation reactions (below),
874
+ it ramps their rates up from nearly nothing. A terminal driven by a current (open circuit,
875
+ say) is held at a voltage instead, the voltage marched until the current crosses its target,
876
+ and floated from there. If 20 V either way brings no crossing (a current beyond the limiting
877
+ one, or a device that only stores what comes in, which has no steady state at a current), the
878
+ solve fails with a warning giving the range of currents the held voltages passed. A solve that
879
+ fails reports the state it failed in, then leaves the device as it was before it.
850
880
  - `step(dt, { method })` advances the transient by dt seconds, halving internally where Newton
851
881
  needs it. `method` is `'be'` (backward Euler, the default) or `'bdf2'`.
852
882
  - `advance(tEnd, opts)` integrates adaptively to `tEnd` with variable-step BDF2, controlling
package/docs/kit.md CHANGED
@@ -57,8 +57,12 @@ console.log(`I = ${sol.current.toFixed(1)} A/m²`);
57
57
  - **Contacts** are the first and last items. `ohmic(drive, carriers)` holds each carrier in
58
58
  equilibrium with a metal at the terminal voltage (default `['e-', 'h+']`, an
59
59
  infinite-recombination contact; `['e-']` alone is selective, and is the current collector on
60
- a metal region). `bath(c, reference, drive, { offset })` is a bath (`offset` places the reference species
61
- relative to the terminal voltage, e.g. to read a solution's potentials against SHE). A drive is a voltage, a waveform, or
60
+ a metal region). `bath(c, reference, drive, { offset })` is a bath whose terminal voltage is
61
+ the level of its `reference` species, as an electrode reversible to it would read (`offset`
62
+ places that species relative to the terminal voltage, e.g. to read a solution's potentials
63
+ against SHE). `bath(c, drive)`, without a reference, is a bath whose terminal voltage is its
64
+ φ: an ideal salt bridge, the convention of membrane potentials, so that between two such baths
65
+ V_right − V_left is the φ difference a voltage clamp sets. A drive is a voltage, a waveform, or
62
66
  `{ V }`, `{ I }`, `{ V, R }`.
63
67
  - **`library`** takes pieces with `species` and `materials`, merged with any given directly
64
68
  (`combine()` does the merging on its own). A species or material given twice must be given
@@ -144,7 +148,7 @@ which is the transport the full solve accounts for.
144
148
 
145
149
  ## Channels
146
150
 
147
- **`hodgkinHuxley({ inside, outside, T, g, leak, leakZ, at, names })`**: Hodgkin and Huxley's
151
+ **`hodgkinHuxley({ inside, outside, T, g, leak, leakZ, at, names, linear, area })`**: Hodgkin and Huxley's
148
152
  squid-axon channels for a [membrane face](device.md#voltage-gated-channels) with the outside on its
149
153
  left: `{ gates, species }`, the face's `gates` (m, h and n, their 1952 rates at 6.3 °C scaled to
150
154
  `T` by Q₁₀ = 3) and links for Na⁺ (P·m³h), K⁺ (P·n⁴) and the leak (one ion, `leak`, of charge
@@ -152,6 +156,13 @@ left: `{ gates, species }`, the face's `gates` (m, h and n, their 1952 rates at
152
156
  whose chord conductance at `at` (−65 mV) is HH's `g` (120, 36 and 0.3 mS/cm²) at the
153
157
  concentrations given. Spread it into the face beside its $`\phi`$ law, adding the other species'
154
158
  links: `{ phi: { type: 'capacitive', C: 0.01 }, gates: hh.gates, species: { ...hh.species, 'A-': 'blocked' } }`.
159
+ With `linear: true` (and no concentrations) the face gets HH's own linear channels instead:
160
+ conductance links, `G` = g, gated the same, whose currents are g(V − E) with E each ion's Nernst
161
+ level at the concentrations either side; between two `bath`s without a reference species, that's
162
+ their voltage clamp. For a [membrane port](device.md#a-membrane-through-a-window-gated-channels) along a region (an axon
163
+ along x), give `area`, the membrane per volume (2/a for radius a), in place of `inside`, `outside`
164
+ and `at`: the links are then their linear conductances, `G` = g × area, gated the same, each ion's
165
+ reversal potential following from the port's `bath` and the concentrations inside.
155
166
  `ghkCurrent(z, inside, outside, V, T)` is the GHK current (outward, A/m²) at unit permeability.
156
167
 
157
168
  ## Sources
@@ -24,17 +24,74 @@ Every physics feature is checked against an analytic result, or an independent c
24
24
  there isn't one: `npm test`, over 300 tests, each a worked device with its closed form. They include
25
25
  Shockley's diode equation, depletion and MOS charge, collection theory under Beer–Lambert light,
26
26
  Gouy–Chapman and Kilic–Bazant–Ajdari double layers, Donnan and Teorell–Meyer–Sievers
27
- partitions, Goldman–Hodgkin–Katz, the limiting current and Butler–Volmer kinetics, the
27
+ partitions, Goldman–Hodgkin–Katz, Hodgkin and Huxley's action potential and its conduction
28
+ velocity, the limiting current and Butler–Volmer kinetics, the
28
29
  Macdonald and finite-length Warburg impedances, Cottrell and spherical diffusion, and the
29
30
  second law (the free energy in through the terminals equals what's dissipated, every term
30
31
  non-negative). Against other codes: IonMonger's perovskite J–V hysteresis (finite elements,
31
- Octave), and liquid-junction potentials against JPCalc, LJPcalc and JLJP. The README's
32
- [validation table](../README.md#validation) lists each with its tolerance.
32
+ Octave), and liquid-junction potentials against JPCalc, LJPcalc and JLJP. The
33
+ [table below](#the-validation-table) lists each with its tolerance.
33
34
 
34
35
  Each solution can check itself too: `check()` from `driftlet/kit` balances every species'
35
36
  ledger (what comes in through each terminal, is made or destroyed), the conservation
36
37
  bookkeeping of a transient, and the grid (the device solved again on a grid twice as fine).
37
38
 
39
+ ### The validation table
40
+
41
+ Each check, with the tolerance it's held to. The tests are worked setups, so they double as
42
+ recipes.
43
+
44
+ | What | Checked against | Tolerance |
45
+ |---|---|---|
46
+ | Equilibrium of any device | μ̄ of every species flat; zero current | 1e-9 RT or better |
47
+ | Gouy–Chapman double layer | analytic charge and full nonlinear profile | 2e-3 |
48
+ | Debye screening (linear limit) | gate in series with `ε/λ_D` | 1e-3 |
49
+ | Donnan potential | analytic partition, between floating layers and real baths | 1e-8 |
50
+ | Heterointerfaces with unequal dipoles (A \| B \| A) | per-face analytic double-layer split | 3e-3 |
51
+ | Floating island | Gauss's law; conserved amounts through gate sweeps | 1e-12 |
52
+ | pn junction | exact built-in potential; depletion charge; short-diode J–V | 1e-12; 1%; 2e-3 |
53
+ | Long pn diode with recombination | Shockley J–V incl. depletion recombination | 2e-3 |
54
+ | Haynes–Shockley pulse | an injected hole packet's drift, spread and decay at the ambipolar μ*, D*, 1/τ*; nothing lost while it goes in | 2e-4; 1e-2; 2e-3 |
55
+ | A packet laid down as a `c0` profile | the same rates from a Gaussian at t = 0: μ*E t, σ₀² + 2D*t, e^(−t/τ*) | 3e-4; 1e-2; 1e-3 |
56
+ | Beer–Lambert photogeneration in an n⁺p cell | J_sc = qΦ∫αe^(−αx)η(x)dx with the emitter's, depletion layer's and base's collection, α from 1e3 to 1e7 /m on one coarse grid | 5e-4 (3e-3 in the emitter) |
57
+ | Organic bilayer: excitons | J_sc from excitons diffusing to the donor/acceptor interface (Beer–Lambert, a blocking anode, the splitting reaction's finite velocity); V_oc from charge-transfer detailed balance | 5e-4; 1e-6 V |
58
+ | SRH recombination | bulk: G = R_SRH(n, p) with n = N_D + p, midgap and shallow traps, low to high injection; at a face: zero in the dark, the law between the two edge nodes, every pair collected or recombined | 1e-6; 1e-9 |
59
+ | Perovskite J–V hysteresis, against IonMonger | an independent code (finite elements, Octave): mobile iodide vacancies, interface SRH, scans from 1 mV/s to 1 kV/s — hysteresis index, P_max, V_oc, the whole loop (as current where it's gentle, as a voltage offset near V_oc, where it falls at up to 1100 mA/cm² per volt) | 1.5e-3; 0.05 mW/cm²; 2 mV; 0.03 mA/cm² and 1 mV (0.010 and 0.31 mV found) |
60
+ | Illuminated long pn diode | `J_sc = qG(L_n + L_p + W)` from a cold start; superposition at low injection | 5e-3; 1e-2 |
61
+ | Schottky barrier (metal region \| n-Si) | surface density from the alignment; depletion charge | 5e-3; 2% |
62
+ | Surface velocity at a contact | minority electrons through a base to a contact of velocity S, n₀(e^(V/V_T) − 1)/(W/D + 1/S), S from 10 to 1e5 m/s; a Schottky diode's thermionic emission, short of A*T²e^(−φ_B/V_T)(e^(V/V_T) − 1) by its depletion region in series, the same swept as built cold | 1e-5; 3–7%; 1e-6 |
63
+ | Charged pore or nanochannel (resolved Donnan layers at each mouth) | conductance against salt, down to its plateau, as Teorell–Meyer–Sievers in a long pore (short ones short by end layers ∝ 1/L); the zero-current voltage across a salt gradient; a symmetric pore's I–V odd, rectification with charge on one side or bipolar | 1%; 5e-3 to 1e-4; 1e-9 |
64
+ | Cell membrane (a capacitive face with permeabilities) | GHK resting potential (neutral or resolved solutions) and current–voltage curve; the same as a resolved 5 nm lipid layer; charging at I/C; with the Na⁺/K⁺ pump in a closed cell, Mullins–Noda, the static head 3Δμ̄_Na − 2Δμ̄_K = ΔG_ATP, and Donnan with the pump off | 1e-5 V; 3e-3; 2e-5 V; 1%; 1e-9 |
65
+ | Voltage-gated channels (Hodgkin–Huxley gates on a membrane face) | each gate at α/(α + β) under a voltage clamp, and relaxing at α + β after a step; HH's voltage clamp with their linear channels between baths, the K⁺ current g_K n∞⁴ (V − E_K); a squid axon's action potential against the space-clamped HH equations with GHK currents; its impedance at rest (inductive, resonant) against the linearised equations | 1e-12; 2e-4; 2e-3; 1 mV; 5e-4 |
66
+ | A propagating action potential (a squid axon along x: gated membrane port, ions drifting in the axoplasm) | rest at HH's −65 mV and gate values; conduction velocity against the cable equation solved directly, and HH's 18.8 m/s; a myelinated axon's saltatory conduction, node by node, against a compartmental cable | 0.01 mV, 1e-4; 2e-3; 1%; 1 µs of ~25 per node |
67
+ | Liquid junctions in mixtures | Henderson's formula against JPCalc's published values; driftlet's steady junction against Planck by shooting and the stationary Nernst–Planck codes LJPcalc and JLJP, a patch pipette's K-gluconate among them; a free-diffusion junction constant in time, between the two | 0.015 mV; 2e-4 and 0.02 mV; 5e-3 mV |
68
+ | Liquid junction, open circuit | cell EMF 2t₊(RT/F) ln(c₁/c₂); Planck diffusion potential | 1e-4 |
69
+ | Salt diffusion mode from a `c0` profile | c̄ + a·sin(πx/2L) decaying at π²D/4L², D = 2D₊D₋/(D₊ + D₋) | 2e-5 |
70
+ | Concentration polarization | `i = i_lim tanh(V/4V_T)`, incl. galvanostatic and load modes | 2e-4 |
71
+ | Butler–Volmer electrode | Nernst equilibrium; mixed kinetic/diffusion closed form | 5e-4 |
72
+ | Redox couple between inert electrodes | Nernst level of Fe³⁺/Fe²⁺; the couple's total conserved at equilibrium and under current | 1e-9; 1e-10 |
73
+ | Interface conductance and ion transfer | series 1/G; BV rate law at the interface state | 1e-4; 1e-8 |
74
+ | Mass action | `c(H⁺)c(OH⁻) = K_w` from standard potentials; moiety conservation | 1e-9 |
75
+ | Second law | free energy in through the terminals (Σ N μ̄ over every species) equals the dissipation, every term ≥ 0: a pn diode, an open-circuit junction running on chemical input alone, electrodes with a bipolar plate, a port and a contact behind conductances | 1e-10 |
76
+ | Transients | RC charging of a gated island; water relaxation rate | 1%; 2e-3 |
77
+ | Time integration | BE first order, BDF2 second order; adaptive error control | ratios 2, 4 |
78
+ | Advection and eddy mixing | exact convection–diffusion profile; `D + D_mix`; junction EMF unchanged by mixing | 1e-12; 1e-12; 1e-5 |
79
+ | Metal regions | ohmic; Schottky face and MOS gate equal their contact forms; Ag \| AgNO₃ \| Ag with metal electrodes; bipolar electrode at V/2 | 1e-12; 1e-9; 1e-9; 1e-9 |
80
+ | Internal ports | transmission line σV tanh(L/λ)/λ (O(h²)); held level; MOS low-frequency C–V with a grounded channel, and without one the same equilibrium, and a gate step filling the inversion layer to it | 1e-4; 1e-9; 2e-3; 1e-6; 1e-3 |
81
+ | Cross-sections (spherical, cylindrical, any A(x)) | steady diffusion to a sphere and a cylinder (exact on any grid); Cottrell with the spherical term; uptake by a sphere filling from its surface; Debye–Hückel around a charged sphere, potential and charge | 1e-10; 3e-4; 2e-4; 1e-3, 3e-4 |
82
+ | A capacitance through a port | a thin-film transistor against the charge-sheet model (below threshold to saturation, second order); de Levie impedance; gate impedance against dQ/dV | 5e-4; 1e-3; 1e-6 |
83
+ | Electrode surfaces (coverage) | Langmuir isotherm against potential; the charge to fill a surface; the active–passive curve, blocking exactly (1 − θ) | 1e-9; 1e-3; 1e-9 |
84
+ | Electrodes spread through a port | transmission line with the reaction's linear kinetics as the conductance (O(h²)), rates along it; Wagner–Traud mixed potential of two Butler–Volmer couples, floating | 1e-4, 2e-3; 1e-6 V |
85
+ | Impedance | Macdonald blocking-electrode spectrum, 100 Hz–1 GHz; finite-length Warburg (Ag \| AgNO₃ \| Ag); DC limit = differential resistance; a p⁺n⁺ junction without recombination, Re Y → dI/dV and C = dQ/dV; a redox electrode against a bath at its open circuit, Re Y → dI/dV; a MOS capacitor with a metal gate and a channel port, C = dQ/dV at the gate, passive at the back | 3e-4; 3e-5; 1e-6; 1e-4, 1e-6; 1e-4; 1e-3 |
86
+ | Conservation | per step, and against time-integrated contact fluxes | 1e-11 relative |
87
+ | Strictly neutral limit (ε = 0) | Planck EMF; polarization with no overlimiting; Donnan at neutral faces | 1e-5; 1e-4; 1e-9 |
88
+ | Fermi–Dirac statistics | `𝓕_{±1/2}` vs quadrature; degenerate bulk; accumulation charge via `𝓕_{3/2}` | 1e-13; 1e-12; 1e-3 |
89
+ | Crowded double layer (lattice gas) | Kilic–Bazant–Ajdari charge, up to `ψ = 40 V_T`; custom function reproduces it | 5e-4; 1e-10 |
90
+ | Non-ideal transport | steady flux −(D/L)ΔP of the grand potential (lattice exact, Redlich–Kister O(h²)) | 1e-12; 1e-4 |
91
+ | Debye–Hückel | junction EMF 2t₊(RT/F) ln(a₁/a₂) with activities | 1e-6 |
92
+ | Data library | ion μ° against the electrochemical series and `K_w`; D against limiting conductivities; band data against `n_i` | 10 mV; 0.5%; 15% |
93
+ | Intercalation host (OCV) | composition vs table and isotherm; chemical diffusion flux and relaxation rate | 1e-12; 1e-5; 1e-4 |
94
+
38
95
  ## Robust: random devices
39
96
 
40
97
  The validation suite shows driftlet is right where it converges. Whether it converges, on
@@ -146,6 +146,16 @@ conducting when it's empty. With no fixed charge, the carriers are only those th
146
146
  the ions. The carrier's `cRef` plays no part (only the combination's $`\mu^\circ`$ and the ion's
147
147
  `cRef` enter), but it must still be given.
148
148
 
149
+ The ion's `D` is its dilute-limit coefficient, as everywhere: the chemical diffusivity, $`D`$
150
+ times the thermodynamic factor, follows from the OCV's slope. For an ideal-solution curve,
151
+ $`E = E^\circ - (RT/F)\ln(x/(1-x))`$, it's $`D/(1-x)`$, so a host filling toward $`x = 1`$
152
+ diffuses ever faster, and a $`D`$ measured mid-range isn't the one to give. (A constant chemical
153
+ diffusivity isn't expressible.) A host that only stores what comes in, filling at a constant
154
+ current through its collector, has no steady state: `advance()` it from its `c0`. In a sphere,
155
+ `geometry: { type: 'spherical', r0: 0 }`, with the centre sealed (`{ phi: 'neutral' }`, every
156
+ species blocked), the ion held at the surface by its reference and the electrons fed by a port
157
+ there (a current into the device: negative, to fill a cathode).
158
+
149
159
  An insertion host belongs with [conductor regions](device.md#materials) more than with the other
150
160
  statistics here. Both are conductors with no $`\phi`$ of their own:
151
161
  - **A metal** is the one-carrier case: its Fermi level is its only unknown.