driftlet 0.1.0 → 0.1.1
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 +24 -16
- package/llms.txt +12 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
# driftlet
|
|
2
2
|
|
|
3
3
|
[](https://github.com/markblundeberg/driftlet/actions/workflows/test.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/driftlet)
|
|
4
5
|
|
|
5
|
-
**driftlet
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
**driftlet is a fast, pure-JavaScript solver for 1D drift–diffusion–reaction problems**, built
|
|
7
|
+
to be the engine of live, thermodynamically honest web demos of charge transport: in
|
|
8
|
+
semiconductors, electrochemical cells, membranes and solid ionic conductors. It handles any mix
|
|
9
|
+
of charged and neutral species, Poisson electrostatics (or strict neutrality), bulk and
|
|
10
|
+
interfacial reactions, heterointerfaces, metals and external circuits, in steady state, in time
|
|
11
|
+
and as small-signal impedance. Every physics feature is validated against analytic results, and
|
|
12
|
+
it's small enough to run in a web page: no dependencies, millisecond solves.
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
[Live demos](https://markblundeberg.github.io/driftlet/demos/) · [npm](https://www.npmjs.com/package/driftlet) ·
|
|
15
|
+
[reading level diagrams](docs/visualization.md) · [device reference](docs/device.md) ·
|
|
16
|
+
[agent guide](llms.txt)
|
|
17
|
+
|
|
18
|
+
**Status: 0.x.** Released on npm and used by the demos, but the API may still change between
|
|
19
|
+
minor versions.
|
|
12
20
|
|
|
13
21
|
## Is it for your problem?
|
|
14
22
|
|
|
@@ -17,12 +25,12 @@ The same equations go by different names in different fields. If your problem is
|
|
|
17
25
|
|
|
18
26
|
| If you work on | you may call it | start from | checked against |
|
|
19
27
|
|---|---|---|---|
|
|
20
|
-
| Semiconductor devices | drift–diffusion, van Roosbroeck, quasi-Fermi levels, Scharfetter–Gummel; pn, Schottky, MOS, heterojunctions | [first example](#a-semiconductor-junction), [pn
|
|
21
|
-
| Solar cells | photogeneration, radiative and SRH recombination | [`reactions`](test/reactions.test.js) test: generation is a reaction from a photon reservoir (uniform per material), SRH runs through explicit trap species | `J_sc = qG(L_n + L_p + W)`; Shockley J–V in the dark |
|
|
22
|
-
| Electrochemistry | Nernst–Planck, concentration polarization, limiting current, Butler–Volmer, Warburg, cyclic voltammetry | [second example](#an-electrochemical-cell), [saturation](https://markblundeberg.github.io/driftlet/demos/saturation.html) and [impedance](https://markblundeberg.github.io/driftlet/demos/impedance.html) demos, [`circuit`](test/circuit.test.js), [`kinetics`](test/kinetics.test.js), [`impedance`](test/impedance.test.js) tests | `i_lim·tanh(V/4V_T)`, Butler–Volmer closed form, finite-length Warburg |
|
|
28
|
+
| Semiconductor devices | drift–diffusion, van Roosbroeck, quasi-Fermi levels, Scharfetter–Gummel; pn, Schottky, MOS, heterojunctions | [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 |
|
|
29
|
+
| Solar cells | photogeneration, radiative and SRH recombination | [solar demo](https://markblundeberg.github.io/driftlet/demos/solar.html), [`reactions`](test/reactions.test.js) test: generation is a reaction from a photon reservoir (uniform per material), SRH runs through explicit trap species | `J_sc = qG(L_n + L_p + W)`; Shockley J–V in the dark |
|
|
30
|
+
| Electrochemistry | Nernst–Planck, concentration polarization, limiting current, Butler–Volmer, Warburg, cyclic voltammetry, salt bridges and liquid junctions | [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) and [impedance](https://markblundeberg.github.io/driftlet/demos/impedance.html) demos, [`circuit`](test/circuit.test.js), [`kinetics`](test/kinetics.test.js), [`impedance`](test/impedance.test.js) tests | `i_lim·tanh(V/4V_T)`, Butler–Volmer closed form, finite-length Warburg |
|
|
23
31
|
| 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 |
|
|
24
32
|
| 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 |
|
|
25
|
-
| Membranes, desalination | Donnan, ion exchange, liquid junctions, water dissociation | [`equilibrium`](test/equilibrium.test.js), [`neutral`](test/neutral.test.js) tests | Donnan partition, Planck EMF |
|
|
33
|
+
| 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 |
|
|
26
34
|
| 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 |
|
|
27
35
|
| Biophysics | Poisson–Nernst–Planck, ion channels, membrane potentials | the electrochemistry setups, with fixed charge in the channel region | no dedicated check yet |
|
|
28
36
|
|
|
@@ -42,7 +50,7 @@ import { bandDiagram } from 'driftlet/plot'; // a level diagram as an SVG str
|
|
|
42
50
|
```
|
|
43
51
|
|
|
44
52
|
Or straight from a CDN in a page, pinned to a version:
|
|
45
|
-
`https://cdn.jsdelivr.net/npm/driftlet@0.1.
|
|
53
|
+
`https://cdn.jsdelivr.net/npm/driftlet@0.1.1/src/index.js` (and `src/kit.js`, `src/plot.js`).
|
|
46
54
|
TypeScript declarations ship in the package. Writing a demo with an LLM agent? Point it at
|
|
47
55
|
[`llms.txt`](llms.txt).
|
|
48
56
|
|
|
@@ -131,10 +139,10 @@ them locally, serve the repository root (e.g. `python3 -m http.server`) and open
|
|
|
131
139
|
| **pn junction**: quasi-Fermi levels under bias; I–V against Shockley | **Solar cell**: J<sub>sc</sub> and V<sub>oc</sub> against collection theory | **MOS capacitor**: band bending; C–V against ideal theory |
|
|
132
140
|
| [](https://markblundeberg.github.io/driftlet/demos/redox.html) | [](https://markblundeberg.github.io/driftlet/demos/daniell.html) | [](https://markblundeberg.github.io/driftlet/demos/saturation.html) |
|
|
133
141
|
| **Cyclic voltammetry**: a Fermi level against a redox level | **Daniell cell**: a real salt bridge, leaking, ion by ion | **Saturation**: Ag \| AgNO₃ \| Ag under a square wave, up to its limiting current |
|
|
134
|
-
| [](https://markblundeberg.github.io/driftlet/demos/impedance.html) | | |
|
|
135
|
-
| **Impedance**: the Warburg arc, and the cell's small-signal response inside | | |
|
|
136
|
-
| [](https://markblundeberg.github.io/driftlet/demos/impedance.html) | [](https://markblundeberg.github.io/driftlet/demos/membrane.html) | [](https://markblundeberg.github.io/driftlet/demos/double-layer.html) |
|
|
143
|
+
| **Impedance**: the Warburg arc, and the cell's small-signal response inside | **Ion-exchange membrane**: Donnan steps, ion by ion, against TMS theory | **Double layer**: dilute vs crowded ions, against closed forms |
|
|
144
|
+
| [](https://markblundeberg.github.io/driftlet/demos/insertion.html) | | |
|
|
145
|
+
| **Intercalation host**: cycling between cutoffs against the OCV | | |
|
|
138
146
|
|
|
139
147
|
## How to think about it
|
|
140
148
|
|
|
@@ -268,7 +276,7 @@ statistics can't be, and must be built inside the worker.)
|
|
|
268
276
|
|
|
269
277
|
## Development
|
|
270
278
|
|
|
271
|
-
No dependencies. Tests use node's built-in runner (Node ≥
|
|
279
|
+
No dependencies. Tests use node's built-in runner (Node ≥ 22):
|
|
272
280
|
|
|
273
281
|
```sh
|
|
274
282
|
npm test # the validation suite
|
package/llms.txt
CHANGED
|
@@ -14,9 +14,9 @@ docs/conventions.md (signs and levels) and docs/data.md (the data library).
|
|
|
14
14
|
From a CDN, pin the version:
|
|
15
15
|
|
|
16
16
|
```js nocheck
|
|
17
|
-
import { Device, units } from 'https://cdn.jsdelivr.net/npm/driftlet@0.1.
|
|
18
|
-
import { build, layer, ohmic, semiconductor, live } from 'https://cdn.jsdelivr.net/npm/driftlet@0.1.
|
|
19
|
-
import { bandDiagram } from 'https://cdn.jsdelivr.net/npm/driftlet@0.1.
|
|
17
|
+
import { Device, units } from 'https://cdn.jsdelivr.net/npm/driftlet@0.1.1/src/index.js';
|
|
18
|
+
import { build, layer, ohmic, semiconductor, live } from 'https://cdn.jsdelivr.net/npm/driftlet@0.1.1/src/kit.js';
|
|
19
|
+
import { bandDiagram } from 'https://cdn.jsdelivr.net/npm/driftlet@0.1.1/src/plot.js';
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
From npm: `driftlet`, `driftlet/kit`, `driftlet/plot`.
|
|
@@ -199,9 +199,9 @@ a Web Worker.
|
|
|
199
199
|
<span id="readout"></span>
|
|
200
200
|
<div id="figure"></div>
|
|
201
201
|
<script type="module">
|
|
202
|
-
import { units } from 'https://cdn.jsdelivr.net/npm/driftlet@0.1.
|
|
203
|
-
import { build, layer, ohmic, semiconductor, live } from 'https://cdn.jsdelivr.net/npm/driftlet@0.1.
|
|
204
|
-
import { bandDiagram } from 'https://cdn.jsdelivr.net/npm/driftlet@0.1.
|
|
202
|
+
import { units } from 'https://cdn.jsdelivr.net/npm/driftlet@0.1.1/src/index.js';
|
|
203
|
+
import { build, layer, ohmic, semiconductor, live } from 'https://cdn.jsdelivr.net/npm/driftlet@0.1.1/src/kit.js';
|
|
204
|
+
import { bandDiagram } from 'https://cdn.jsdelivr.net/npm/driftlet@0.1.1/src/plot.js';
|
|
205
205
|
|
|
206
206
|
const def = build({
|
|
207
207
|
T: 300,
|
|
@@ -236,13 +236,14 @@ has the long form):
|
|
|
236
236
|
- **Standard redox level** (`{ standard: true }`), thin and dashed: every participant at reference
|
|
237
237
|
concentration. The redox level sits RT/(zF) ln(a_Ox/a_Red) from it (Nernst, locally).
|
|
238
238
|
- **Electrode potentials** are gaps to the SHE's standard level V°_e⁻(SHE): E = V_e⁻(electrode) −
|
|
239
|
-
V°_e⁻(SHE), E° = V°_e⁻(Ox/Red) − V°_e⁻(SHE), η = E − E_eq. With the data library's μ°,
|
|
240
|
-
in water is φ, so `phi: true` draws it. It slopes under current: "vs SHE" needs a
|
|
241
|
-
the stirred bulk).
|
|
239
|
+
V°_e⁻(SHE), E° = V°_e⁻(Ox/Red) − V°_e⁻(SHE), η = E − E_eq. With the data library's μ°,
|
|
240
|
+
V°_e⁻(SHE) in water is φ, so `phi: true` draws it. It slopes under current: "vs SHE" needs a
|
|
241
|
+
place (say, the stirred bulk).
|
|
242
242
|
- **Species voltage** V_i = μ̄_i/(z_iF) (thick, solid) for every charged species: the Fermi level
|
|
243
243
|
for e⁻, a quasi-Fermi level for e⁻ and h⁺ in a semiconductor, what a reversible electrode reads
|
|
244
|
-
for an ion.
|
|
245
|
-
|
|
244
|
+
for an ion. The current a species carries flows down slopes in its own V_i (drift and diffusion
|
|
245
|
+
together; cations and holes move downhill, electrons and anions uphill), and it's in equilibrium
|
|
246
|
+
where V_i is flat. A step at a face means resistance there.
|
|
246
247
|
- **Standard level** V°_i = φ + μ°_i/(z_iF) (thin, solid): a band edge for e⁻ and h⁺; V_i − V°_i =
|
|
247
248
|
(RT/z_iF) ln(c/c_ref) for ideal species. Steps in V°_i at faces (Donnan, junctions, dipoles) are
|
|
248
249
|
bookkeeping. In volts the conduction band sits below the valence band.
|