driftlet 0.11.4 → 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 +50 -74
- package/docs/device.md +143 -9
- package/docs/kit.md +25 -2
- package/docs/numerics.md +8 -1
- package/docs/reliability.md +60 -3
- package/docs/statistics.md +10 -0
- package/llms.txt +572 -259
- package/package.json +1 -1
- package/src/channels.js +96 -0
- package/src/describe.js +4 -2
- package/src/device.js +108 -21
- package/src/index.js +6 -1
- package/src/kit.js +1 -0
- package/src/recorder.js +1 -1
- package/src/solution.js +28 -3
- package/src/solver.js +292 -67
- package/src/stack.js +6 -4
- package/src/types.js +2 -1
- package/types/channels.d.ts +50 -0
- package/types/kit.d.ts +1 -0
- package/types/recorder.d.ts +7 -3
- package/types/solver.d.ts +32 -5
- package/types/stack.d.ts +6 -5
- package/types/types.d.ts +5 -0
package/src/stack.js
CHANGED
|
@@ -87,16 +87,18 @@ export function ohmic(d = 0, carriers = ['e-', 'h+']) {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
|
-
* A bath: a neutral composition `c` (mol/m³) held at the contact
|
|
91
|
-
*
|
|
92
|
-
*
|
|
90
|
+
* A bath: a neutral composition `c` (mol/m³) held at the contact. With a `reference`, the charged
|
|
91
|
+
* species a reference electrode would sense (Cl⁻ for Ag/AgCl), its levels are referred to that
|
|
92
|
+
* species, which is the terminal. Without one, `bath(c, drive)`, the terminal voltage is the
|
|
93
|
+
* bath's φ: an ideal salt bridge, the convention of membrane potentials.
|
|
93
94
|
* @param {Record<string, number>} c
|
|
94
|
-
* @param {string} reference
|
|
95
|
+
* @param {string | number | object} [reference] the reference species, or the drive
|
|
95
96
|
* @param {number | object} [drive]
|
|
96
97
|
* @param {{ offset?: number }} [opts] where the reference species sits relative to the terminal
|
|
97
98
|
* voltage, V_ref = V + offset (V)
|
|
98
99
|
*/
|
|
99
100
|
export function bath(c, reference, d = 0, { offset } = {}) {
|
|
101
|
+
if (typeof reference !== 'string') return { ...drive(reference ?? 0, 'bath'), bath: { c: { ...c } } };
|
|
100
102
|
return { ...drive(d, 'bath'), bath: { c: { ...c }, reference, ...(offset === undefined ? {} : { offset }) } };
|
|
101
103
|
}
|
|
102
104
|
|
package/src/types.js
CHANGED
|
@@ -114,7 +114,8 @@
|
|
|
114
114
|
* @typedef {'blocked' | 'equilibrium'
|
|
115
115
|
* | { type: 'equilibrium', offset?: number, mu?: number }
|
|
116
116
|
* | { type: 'conductance', G: number, offset?: number }
|
|
117
|
-
* | { type: 'exchange', k: number, mu: number }
|
|
117
|
+
* | { type: 'exchange', k: number, mu: number }
|
|
118
|
+
* | { type: 'velocity', v: number, offset?: number, mu?: number }} ContactSpeciesLink
|
|
118
119
|
*/
|
|
119
120
|
/**
|
|
120
121
|
* 'bulk': the end node is plain bulk (locally neutral, no double layer); 'neutral': no charge at
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export function ghkCurrent(z: any, inside: any, outside: any, V: any, T: any): number;
|
|
2
|
+
/**
|
|
3
|
+
* Hodgkin and Huxley's squid-axon channels: for a membrane face with the outside on its left
|
|
4
|
+
* (so the gates' voltage, φ_right − φ_left, is the membrane potential): the face's `gates`, and
|
|
5
|
+
* `species` links for Na⁺ (P·m³h), K⁺ (P·n⁴) and the leak (ungated), to spread into the face
|
|
6
|
+
* beside its φ law, `{ phi: { type: 'capacitive', C: 0.01 }, ...hh }`, adding links (or blocks)
|
|
7
|
+
* for any other species.
|
|
8
|
+
*
|
|
9
|
+
* The currents are GHK's, which rectify, so a permeability matches a conductance at one voltage
|
|
10
|
+
* only: each is the one whose chord conductance at `at` (rest, −65 mV) is Hodgkin and Huxley's
|
|
11
|
+
* (`g`: 120, 36 and 0.3 mS/cm²), at the concentrations given. The leak is carried by one ion
|
|
12
|
+
* (`leak`, of charge `leakZ`: Cl⁻ by default, whose Nernst level in squid is near their leak
|
|
13
|
+
* reversal, −54 mV). The
|
|
14
|
+
* rates are theirs at 6.3 °C, scaled to `T` by Q₁₀ = 3.
|
|
15
|
+
*
|
|
16
|
+
* Or with `linear: true`, Hodgkin and Huxley's own linear channels on the face: conductance links,
|
|
17
|
+
* G = g, gated the same, whose currents are g(V − E) with E each ion's Nernst level at the
|
|
18
|
+
* concentrations on either side (so `inside`, `outside` and `at` aren't needed).
|
|
19
|
+
*
|
|
20
|
+
* Or, given `area` (membrane per volume of the region, 2/a for an axon of radius a), for a membrane
|
|
21
|
+
* port along a region: links that are their linear conductances, G = g × area per volume, gated the
|
|
22
|
+
* same, each ion's reversal potential following from the port's bath and the concentrations inside
|
|
23
|
+
* (so `inside`, `outside` and `at` aren't needed).
|
|
24
|
+
* @param {{ inside: object, outside: object, T?: number, g?: { Na?: number, K?: number, leak?: number },
|
|
25
|
+
* leak?: string, leakZ?: number, at?: number, names?: { Na?: string, K?: string }, linear?: boolean, area?: number }} opts concentrations in
|
|
26
|
+
* mol/m³ by species name, K, S/m², V
|
|
27
|
+
* @returns {{ gates: object, species: object }}
|
|
28
|
+
*/
|
|
29
|
+
export function hodgkinHuxley({ inside, outside, T, g, leak, leakZ, at, names, linear, area }?: {
|
|
30
|
+
inside: object;
|
|
31
|
+
outside: object;
|
|
32
|
+
T?: number;
|
|
33
|
+
g?: {
|
|
34
|
+
Na?: number;
|
|
35
|
+
K?: number;
|
|
36
|
+
leak?: number;
|
|
37
|
+
};
|
|
38
|
+
leak?: string;
|
|
39
|
+
leakZ?: number;
|
|
40
|
+
at?: number;
|
|
41
|
+
names?: {
|
|
42
|
+
Na?: string;
|
|
43
|
+
K?: string;
|
|
44
|
+
};
|
|
45
|
+
linear?: boolean;
|
|
46
|
+
area?: number;
|
|
47
|
+
}): {
|
|
48
|
+
gates: object;
|
|
49
|
+
species: object;
|
|
50
|
+
};
|
package/types/kit.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export { build, combine, layer, ohmic, bath } from "./stack.js";
|
|
|
61
61
|
export { parseEquation, stoichiometry, half, SHE, level } from "./equation.js";
|
|
62
62
|
export { traces, speciesRole, typeset } from "./traces.js";
|
|
63
63
|
export { pulse, square, triangle, ramp, injector, recombination, photogeneration } from "./sources.js";
|
|
64
|
+
export { hodgkinHuxley, ghkCurrent } from "./channels.js";
|
|
64
65
|
export { describe, unitWarnings } from "./describe.js";
|
|
65
66
|
export { henderson, planck } from "./junction.js";
|
|
66
67
|
export { perovskiteCell, PEROVSKITE_SCANS, hysteresis } from "./devices.js";
|
package/types/recorder.d.ts
CHANGED
|
@@ -4,17 +4,21 @@
|
|
|
4
4
|
* neither, at the end of each `advance()` call. The trace (`t`, `current`, `voltage`, and
|
|
5
5
|
* `probes` if given) runs from the start through every accepted step of every call.
|
|
6
6
|
* @param {import('./index.js').Device} device
|
|
7
|
-
* @param {{ every?: number, times?: number[], probes?: { x: number, species?: string, quantity?: 'c' | 'V' | 'phi', region?: string | number }[] }} [opts]
|
|
7
|
+
* @param {{ every?: number, times?: number[], probes?: ({ x: number, species?: string, quantity?: 'c' | 'V' | 'phi', region?: string | number } | { interface: number, species?: string, gate?: string })[] }} [opts]
|
|
8
8
|
*/
|
|
9
9
|
export function recorder(device: import("./index.js").Device, opts?: {
|
|
10
10
|
every?: number;
|
|
11
11
|
times?: number[];
|
|
12
|
-
probes?: {
|
|
12
|
+
probes?: ({
|
|
13
13
|
x: number;
|
|
14
14
|
species?: string;
|
|
15
15
|
quantity?: "c" | "V" | "phi";
|
|
16
16
|
region?: string | number;
|
|
17
|
-
}
|
|
17
|
+
} | {
|
|
18
|
+
interface: number;
|
|
19
|
+
species?: string;
|
|
20
|
+
gate?: string;
|
|
21
|
+
})[];
|
|
18
22
|
}): {
|
|
19
23
|
advance: (tEnd: number, aopts?: object) => import("./types.js").Solution;
|
|
20
24
|
frame: (t: number) => import("./types.js").Solution;
|
package/types/solver.d.ts
CHANGED
|
@@ -23,6 +23,11 @@ export class Solver {
|
|
|
23
23
|
thOld: Float64Array<ArrayBuffer>;
|
|
24
24
|
th0: Float64Array<any>;
|
|
25
25
|
th0Old: Float64Array<any>;
|
|
26
|
+
gatePort: Int32Array<any>;
|
|
27
|
+
gateList: any[];
|
|
28
|
+
gateOld: Float64Array<ArrayBuffer>;
|
|
29
|
+
gateIndex: Int32Array<ArrayBuffer>;
|
|
30
|
+
portGateIndex: any;
|
|
26
31
|
present: Uint8Array<ArrayBuffer>;
|
|
27
32
|
cRef: Float64Array<ArrayBuffer>;
|
|
28
33
|
mu0hat: Float64Array<ArrayBuffer>;
|
|
@@ -181,6 +186,7 @@ export class Solver {
|
|
|
181
186
|
_j(rb: any, rs: any, cb: any, cs: any, v: any): void;
|
|
182
187
|
/** Assemble residual and Jacobian for a backward-Euler step of size dt. */
|
|
183
188
|
assemble(dt: any): void;
|
|
189
|
+
dtNow: any;
|
|
184
190
|
transformed: any;
|
|
185
191
|
_nodeConductor(g: any, dt: any): void;
|
|
186
192
|
_nodesDilute(g0: any, g1: any, dt: any): void;
|
|
@@ -192,6 +198,11 @@ export class Solver {
|
|
|
192
198
|
_segmentDisplacement(s: any, bL: any, bR: any, mat: any, h: any): void;
|
|
193
199
|
_segmentsDilute(g0: any, g1: any, region: any, mat: any, vel: any): void;
|
|
194
200
|
_face(f: any): void;
|
|
201
|
+
_gateSlot(f: any, q: any): any;
|
|
202
|
+
_gateVoltage(gt: any): number;
|
|
203
|
+
_portVoltage(k: any, g: any): number;
|
|
204
|
+
_faceVoltage(f: any): number;
|
|
205
|
+
_faceGates(f: any, bf: any, bL: any, bR: any): void;
|
|
195
206
|
_segmentConcentrated(s: any, bL: any, bR: any, mat: any, h: any, vel: any): void;
|
|
196
207
|
_segmentConductor(s: any, bL: any, bR: any, mat: any, h: any): void;
|
|
197
208
|
_segmentMixing(s: any, bL: any, bR: any, Dm: any, h: any, mat: any): void;
|
|
@@ -207,11 +218,16 @@ export class Solver {
|
|
|
207
218
|
Ca: number;
|
|
208
219
|
};
|
|
209
220
|
_faceReaction(rx: any, k: any, f: any, bf: any, bL: any, bR: any, Af: any): void;
|
|
221
|
+
_liveTerms(): any;
|
|
222
|
+
_allTerms: any;
|
|
210
223
|
_terminals(dt: any): void;
|
|
211
224
|
_circuit(k: any): void;
|
|
212
225
|
_captureRow(b: any, s: any, w: any, into: any): any;
|
|
213
226
|
_port(port: any, flux: any, k: any, dt: any, holds: any): void;
|
|
214
227
|
_portReaction(port: any, rx: any, area: any, rates: any, flux: any, k: any): void;
|
|
228
|
+
_portGates(port: any, k: any, dt: any): void;
|
|
229
|
+
_open(gated: any, x: any): number;
|
|
230
|
+
_dOpen(gated: any, q: any, p: any, x: any): number;
|
|
215
231
|
_portCapacitance(port: any, k: any, dt: any): void;
|
|
216
232
|
_surfaceStorage(port: any, dt: any): void;
|
|
217
233
|
_contact(side: any, dt: any): void;
|
|
@@ -278,6 +294,7 @@ export class Solver {
|
|
|
278
294
|
* animation can call it once per frame; the step size carries over between calls.
|
|
279
295
|
*/
|
|
280
296
|
integrate(tEnd: any, opts?: {}): {
|
|
297
|
+
stopped?: string;
|
|
281
298
|
converged: boolean;
|
|
282
299
|
done: boolean;
|
|
283
300
|
steps: number;
|
|
@@ -291,7 +308,7 @@ export class Solver {
|
|
|
291
308
|
};
|
|
292
309
|
};
|
|
293
310
|
landing: any;
|
|
294
|
-
_extrapolate(out: any,
|
|
311
|
+
_extrapolate(out: any, h: any): any;
|
|
295
312
|
_predict(pred: any, bdf: any): {
|
|
296
313
|
scale: number;
|
|
297
314
|
order: number;
|
|
@@ -310,6 +327,7 @@ export class Solver {
|
|
|
310
327
|
cOld: Float64Array<ArrayBuffer>;
|
|
311
328
|
thOld: Float64Array<ArrayBuffer>;
|
|
312
329
|
th0Old: Float64Array<ArrayBuffer>;
|
|
330
|
+
gateOld: Float64Array<ArrayBuffer>;
|
|
313
331
|
time: number;
|
|
314
332
|
lastDt: number;
|
|
315
333
|
atSteady: boolean;
|
|
@@ -343,19 +361,28 @@ export class Solver {
|
|
|
343
361
|
* Z = δV/δI with I into the device (positive real part for a passive device).
|
|
344
362
|
* @param {ArrayLike<number>} frequencies Hz
|
|
345
363
|
*/
|
|
346
|
-
impedance(frequencies: ArrayLike<number>,
|
|
364
|
+
impedance(frequencies: ArrayLike<number>, opts: any): {
|
|
365
|
+
f: Float64Array<ArrayBuffer>;
|
|
366
|
+
Z: {
|
|
367
|
+
re: Float64Array<any>;
|
|
368
|
+
im: Float64Array<any>;
|
|
369
|
+
};
|
|
370
|
+
};
|
|
371
|
+
allTerminals: any;
|
|
372
|
+
_impedance(frequencies: any, { profiles, terminal }?: {
|
|
347
373
|
profiles?: boolean;
|
|
348
374
|
terminal?: string;
|
|
349
375
|
}): {
|
|
350
376
|
f: Float64Array<ArrayBuffer>;
|
|
351
377
|
Z: {
|
|
352
|
-
re: Float64Array<
|
|
353
|
-
im: Float64Array<
|
|
378
|
+
re: Float64Array<any>;
|
|
379
|
+
im: Float64Array<any>;
|
|
354
380
|
};
|
|
355
381
|
};
|
|
356
382
|
_regionShift(yr: any, yi: any): Float64Array<any>[];
|
|
357
383
|
_regionEdgeRows(): Uint8Array<any>;
|
|
358
384
|
_currentCuts(): {
|
|
385
|
+
s: any;
|
|
359
386
|
idx: any[];
|
|
360
387
|
g: any[];
|
|
361
388
|
d: any[];
|
|
@@ -399,7 +426,7 @@ export class Solver {
|
|
|
399
426
|
iterations: any;
|
|
400
427
|
history: any;
|
|
401
428
|
};
|
|
402
|
-
_continuation(opts: any, level: any, target: any, r: any, warm: any): any;
|
|
429
|
+
_continuation(opts: any, k: any, level: any, target: any, r: any, warm: any, hold: any): any;
|
|
403
430
|
_solveSteady(opts?: {}): {
|
|
404
431
|
converged: boolean;
|
|
405
432
|
steps: number;
|
package/types/stack.d.ts
CHANGED
|
@@ -31,16 +31,17 @@ export function drive(d: any, path: any): any;
|
|
|
31
31
|
*/
|
|
32
32
|
export function ohmic(d?: number, carriers?: string[]): any;
|
|
33
33
|
/**
|
|
34
|
-
* A bath: a neutral composition `c` (mol/m³) held at the contact
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* A bath: a neutral composition `c` (mol/m³) held at the contact. With a `reference`, the charged
|
|
35
|
+
* species a reference electrode would sense (Cl⁻ for Ag/AgCl), its levels are referred to that
|
|
36
|
+
* species, which is the terminal. Without one, `bath(c, drive)`, the terminal voltage is the
|
|
37
|
+
* bath's φ: an ideal salt bridge, the convention of membrane potentials.
|
|
37
38
|
* @param {Record<string, number>} c
|
|
38
|
-
* @param {string} reference
|
|
39
|
+
* @param {string | number | object} [reference] the reference species, or the drive
|
|
39
40
|
* @param {number | object} [drive]
|
|
40
41
|
* @param {{ offset?: number }} [opts] where the reference species sits relative to the terminal
|
|
41
42
|
* voltage, V_ref = V + offset (V)
|
|
42
43
|
*/
|
|
43
|
-
export function bath(c: Record<string, number>, reference
|
|
44
|
+
export function bath(c: Record<string, number>, reference?: string | number | object, d?: number, { offset }?: {
|
|
44
45
|
offset?: number;
|
|
45
46
|
}): any;
|
|
46
47
|
/**
|
package/types/types.d.ts
CHANGED
|
@@ -264,6 +264,11 @@ export type ContactSpeciesLink = "blocked" | "equilibrium" | {
|
|
|
264
264
|
type: "exchange";
|
|
265
265
|
k: number;
|
|
266
266
|
mu: number;
|
|
267
|
+
} | {
|
|
268
|
+
type: "velocity";
|
|
269
|
+
v: number;
|
|
270
|
+
offset?: number;
|
|
271
|
+
mu?: number;
|
|
267
272
|
};
|
|
268
273
|
/**
|
|
269
274
|
* 'bulk': the end node is plain bulk (locally neutral, no double layer); 'neutral': no charge at
|