driftlet 1.2.3 → 1.3.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.
@@ -0,0 +1,61 @@
1
+ export class RegionTerms {
2
+ _coverages(): void;
3
+ computeConcentrations(): void;
4
+ _work(md: any): any;
5
+ _nodeStatistics(g: any, b: any, phiHat: any): void;
6
+ _statSlopes(g: any, mat: any): void;
7
+ _Kz(g: any, i: any): number;
8
+ /** zᵀKz at node g (per RT): the charge response that sets the screening length. */
9
+ screening(g: any): number;
10
+ _dlnc(g: any, i: any, w: any, d: any): void;
11
+ _nodeConductor(g: any, dt: any): void;
12
+ _portHeldAt(g: any, i: any): boolean;
13
+ _nodesDilute(g0: any, g1: any, dt: any): void;
14
+ _nodeConcentrated(g: any, dt: any): void;
15
+ _storage(g: any, i: any, dt: any, Kz?: number): void;
16
+ _chargeRows(dt: any): void;
17
+ _untransform(delta: any): void;
18
+ _bulkReactions(g: any, rxs: any): void;
19
+ _segmentDisplacement(s: any, bL: any, bR: any, mat: any, h: any): any;
20
+ _segmentsDilute(g0: any, g1: any, region: any, mat: any, vel: any): void;
21
+ _segmentConcentrated(s: any, bL: any, bR: any, mat: any, h: any, vel: any): void;
22
+ _fluxConcentrated(s: any, bL: any, bR: any, mat: any, h: any, vel: any, i: any): {
23
+ N: any;
24
+ gBcE1: any;
25
+ dNdd: any;
26
+ fL: any;
27
+ cR: any;
28
+ };
29
+ _segmentConductor(s: any, bL: any, bR: any, mat: any, h: any): void;
30
+ _segmentMixing(s: any, bL: any, bR: any, Dm: any, h: any, mat: any): void;
31
+ mixWork: Float64Array<any>[];
32
+ _mixCrowded(gL: any, gR: any, bL: any, bR: any, on: any, k0: any): void;
33
+ _dKslot(g: any, i: any, j: any, t: any): any;
34
+ _mixBase(gL: any, gR: any, bL: any, bR: any, on: any): {
35
+ Jl: Float64Array<ArrayBuffer>;
36
+ Jr: Float64Array<ArrayBuffer>;
37
+ dcs: Float64Array<ArrayBuffer>;
38
+ };
39
+ mixCrowd: {
40
+ Jl: Float64Array<ArrayBuffer>;
41
+ Jr: Float64Array<ArrayBuffer>;
42
+ dcs: Float64Array<ArrayBuffer>;
43
+ };
44
+ _Kat(g: any, i: any, j: any): any;
45
+ _dc(g: any, k: any, d: any): void;
46
+ bulkRate(rx: any, g: any): number;
47
+ bulkForward(rx: any, g: any): any;
48
+ bulkOneWay(rx: any, g: any): number;
49
+ _srhRate(law: any, cn: any, cp: any, a: any, xn?: number, xp?: number): {
50
+ rate: number;
51
+ forward: number;
52
+ oneWay: number;
53
+ Cn: number;
54
+ Cp: number;
55
+ Ca: number;
56
+ Cxn: number;
57
+ Cxp: number;
58
+ };
59
+ _srhDegen(gn: any, gq: any, law: any): any[];
60
+ _srhInto(g: any, i: any, C: any, Cx: any, d: any): void;
61
+ }
package/types/solver.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ export function profileAt({ x, values: c }: {
2
+ x: any;
3
+ values: any;
4
+ }, at: any): any;
1
5
  export class SolverError extends Error {
2
6
  constructor(message: any, details: any);
3
7
  details: any;
@@ -49,6 +53,8 @@ export class Solver {
49
53
  sheetSign: Int8Array<any>;
50
54
  conductorLast: Uint8Array<any>;
51
55
  K: Float64Array<ArrayBuffer>;
56
+ nodeDK: Uint8Array<any>;
57
+ dK: Float64Array<ArrayBuffer>;
52
58
  ex: Float64Array<ArrayBuffer>;
53
59
  zeta: Float64Array<any>;
54
60
  scratch: Map<any, any>;
@@ -56,10 +62,11 @@ export class Solver {
56
62
  dB: Float64Array<any>;
57
63
  jL: Float64Array<any>;
58
64
  jR: Float64Array<any>;
65
+ sg: Float64Array<ArrayBuffer>;
59
66
  time: number;
60
67
  lastDt: number;
61
68
  atSteady: boolean;
62
- lin: DifferenceTerms;
69
+ lin: any;
63
70
  contactFlux: {
64
71
  left: Float64Array<any>;
65
72
  right: Float64Array<any>;
@@ -126,7 +133,7 @@ export class Solver {
126
133
  _activeSlots(): void;
127
134
  active: Uint8Array<ArrayBuffer>;
128
135
  loc: Int32Array<ArrayBuffer>;
129
- sys: any;
136
+ sys: BlockTridiagonal;
130
137
  SINK: number;
131
138
  rix: Int32Array<ArrayBuffer>;
132
139
  fullOf: Int32Array<ArrayBuffer>;
@@ -224,162 +231,27 @@ export class Solver {
224
231
  nodeMaterial: Int32Array<any>;
225
232
  phiUndefined: Uint8Array<any>;
226
233
  };
227
- _directSteady(): boolean;
228
234
  _surfaceStart(g: any): void;
229
235
  /** Amount (mol per unit area) of surface column j's species, Γ Σ v·a·θ, in the current state. */
230
236
  surfaceAmount(j: any): number;
231
237
  /** Total amount (mol per unit area) of a stretch's species in the current state. */
232
238
  amount(stretch: any): number;
233
239
  redrive(): void;
234
- deltaV: Float64Array<any>;
235
- stuckReactions(): any[];
240
+ deltaV: any;
236
241
  _drivenKey(): any;
237
242
  _refreshSources(): void;
238
243
  /** η_i (μ̄/RT) of a port's outside level for species i (its electrode's carrier: at V itself). */
239
244
  portEta(port: any, i: any): number;
240
245
  /** η_i/RT that a fixed contact link imposes (or NaN if the link isn't fixed). */
241
246
  contactEta(side: any, i: any): number;
242
- /**
243
- * Cold start. Each species takes its region's c0 where one is given (for a spectator, it fixes
244
- * the conserved amount), else its contact's level. φ in each region is then chosen for local neutrality (node by node where a
245
- * profile varies), or continued across the interface dipole if nothing there responds.
246
- */
247
247
  initFromComposition(): void;
248
- _portRate(port: any, rx: any, g: any): number;
249
- _materialAt(mat: any, background: any, eta: any, mode: any, cFix: any, ph: any, zeta: any, cc: any): void;
250
- _coverages(): void;
251
- computeConcentrations(): void;
252
- _work(md: any): any;
253
- _nodeStatistics(g: any, b: any, phiHat: any): void;
254
- _Kz(g: any, i: any): number;
255
- /** zᵀKz at node g (per RT): the charge response that sets the screening length. */
256
- screening(g: any): number;
257
- _dlnc(g: any, i: any, w: any, d: any): void;
258
- _j(rb: any, rs: any, cb: any, cs: any, v: any): void;
259
- /** Assemble residual and Jacobian for a backward-Euler step of size dt. */
260
- assemble(dt: any): void;
261
- dtNow: any;
262
- transformed: any;
263
- _nodeConductor(g: any, dt: any): void;
264
- _portHeldAt(g: any, i: any): boolean;
265
- _nodesDilute(g0: any, g1: any, dt: any): void;
266
- _nodeConcentrated(g: any, dt: any): void;
267
- _storage(g: any, i: any, dt: any, Kz?: number): void;
268
- _chargeRows(dt: any): void;
269
- _untransform(delta: any): void;
270
- _bulkReactions(g: any, rxs: any): void;
271
- _segmentDisplacement(s: any, bL: any, bR: any, mat: any, h: any): void;
272
- _segmentsDilute(g0: any, g1: any, region: any, mat: any, vel: any): void;
273
- _face(f: any): void;
274
- _gateSlot(f: any, q: any): any;
275
- _gateVoltage(gt: any): number;
276
- _portVoltage(k: any, g: any): number;
277
- _faceVoltage(f: any): number;
278
- _faceGates(f: any, bf: any, bL: any, bR: any): void;
279
- _segmentConcentrated(s: any, bL: any, bR: any, mat: any, h: any, vel: any): void;
280
- _fluxConcentrated(s: any, bL: any, bR: any, mat: any, h: any, vel: any, i: any): {
281
- N: number;
282
- E: number;
283
- gBc: number;
284
- dNdd: number;
285
- fL: number;
286
- cR: number;
287
- };
288
- _segmentConductor(s: any, bL: any, bR: any, mat: any, h: any): void;
289
- _segmentMixing(s: any, bL: any, bR: any, Dm: any, h: any, mat: any): void;
290
- mixWork: Float64Array<any>[];
291
- _dc(g: any, k: any, d: any): void;
292
- bulkRate(rx: any, g: any): number;
293
- bulkForward(rx: any, g: any): any;
294
- bulkOneWay(rx: any, g: any): number;
295
- _srhRate(law: any, cn: any, cp: any, a: any, xn?: number, xp?: number, sn?: number, sp?: number): {
296
- rate: number;
297
- forward: number;
298
- oneWay: number;
299
- Cn: number;
300
- Cp: number;
301
- Ca: number;
302
- };
303
- _srhDegen(gn: any, gq: any, law: any): number[];
304
- _degen(g: any, i: any): number[];
305
- _faceReaction(rx: any, k: any, f: any, bf: any, bL: any, bR: any, Af: any): void;
306
- _liveTerms(): any;
307
- _allTerms: any;
308
- _terminals(dt: any): void;
309
- _circuit(k: any): void;
310
- _captureRow(b: any, s: any, w: any, into: any): any;
311
- _port(port: any, flux: any, k: any, dt: any, holds: any): void;
312
- _portReaction(port: any, rx: any, area: any, rates: any, flux: any, k: any): void;
313
- _portGates(port: any, k: any, dt: any): void;
314
- _open(gated: any, x: any): number;
315
- _dOpen(gated: any, q: any, p: any, x: any): number;
316
- _portCapacitance(port: any, k: any, dt: any): void;
317
- _surfaceStorage(port: any, dt: any): void;
318
- _contact(side: any, dt: any): void;
319
- _replaceRow(b: any, rs: any): void;
320
- _equilibrate(): void;
321
- _assembleDifference(dt: any): {
322
- rest: any;
323
- lin: DifferenceTerms;
324
- };
325
- sysRest: any;
326
- diffTerms: DifferenceTerms;
327
- _refine(dt: any, delta: any, deltaV: any): boolean;
328
- _maxPotentialStep(delta: any, deltaV?: Float64Array<any>): number;
329
- /**
330
- * Newton iteration for one backward-Euler step from the current cOld.
331
- * @returns {{converged: boolean, iterations: number, history: number[]}}
332
- */
333
- newton(dt: any, { maxIter, tol, maxStep, islands }?: {
334
- maxIter?: number;
335
- tol?: number;
336
- maxStep?: number;
337
- islands?: boolean;
338
- }): {
339
- converged: boolean;
340
- iterations: number;
341
- history: number[];
342
- };
343
- _kirchhoff(): number;
344
- _noteConditioning(): void;
345
- conditioning: {
346
- digits: any;
347
- x: number;
348
- where: string;
349
- nodes: any[];
350
- };
248
+ newton(dt: any, opts: any): any;
351
249
  /**
352
250
  * Advance by dt, splitting the interval into halves (recursively) wherever Newton fails.
353
251
  * The end time is always t + dt; the result reports the substeps taken.
354
252
  */
355
253
  advance(dt: any, opts: any, depth?: number): any;
356
- _addToState(d: any, scale: any): void;
357
- /**
358
- * One time step of size dt. Backward Euler by default; with `method: 'bdf2'`, variable-step
359
- * BDF2 once a previous step exists (and the step ratio is at most 2, for stability). On
360
- * failure the state is restored.
361
- *
362
- * BDF2's storage term (a0 c − (1+ω) c_n + ω²/(1+ω) c_{n−1})/dt is written in backward-Euler
363
- * form (c − c*)/(dt/a0), so assembly is shared: c* and the displacement histories replace
364
- * the start-of-step values, and dt/a0 replaces dt.
365
- */
366
- step(dt: any, opts?: {}): {
367
- converged: boolean;
368
- iterations: number;
369
- history: number[];
370
- };
371
- contactDEnd: any;
372
- sourceBefore: boolean;
373
- solvedV: any;
374
- stepped: boolean;
375
- _guess(guess: any): void;
376
- /**
377
- * Adaptive time stepping to tEnd: variable-step BDF2 (or backward Euler), with the local error
378
- * estimated against an explicit predictor through the previous states, and controlled to
379
- * `tol` thermal units per step in every potential (φ̂, each η, a surface's coverages as η). The first
380
- * step is checked by step doubling. Stops early when `budgetMs` of wall time is used, so an
381
- * animation can call it once per frame; the step size carries over between calls.
382
- */
254
+ step(dt: any, opts?: {}): any;
383
255
  integrate(tEnd: any, opts?: {}): {
384
256
  stopped?: string;
385
257
  converged: boolean;
@@ -394,19 +266,13 @@ export class Solver {
394
266
  voltage: any[];
395
267
  };
396
268
  };
397
- landing: any;
398
- _extrapolate(out: any, h: any): any;
399
- _predict(pred: any, bdf: any): {
400
- scale: number;
401
- order: number;
402
- };
403
269
  _probes(probes: any): {
404
270
  out: any;
405
271
  read: () => any;
406
272
  push: (values: any) => any;
407
273
  };
408
- _errorNorm(ref: any): number;
409
274
  _warmFrom(src: any): void;
275
+ solvedV: any;
410
276
  _snapshot(): {
411
277
  u: Float64Array<ArrayBuffer>;
412
278
  uLo: Float64Array<ArrayBuffer>;
@@ -435,113 +301,11 @@ export class Solver {
435
301
  sourceTime: number;
436
302
  };
437
303
  _restore(s: any): void;
304
+ contactDEnd: any;
438
305
  passedCurrent(k: any): any;
439
306
  _terminalCurrent(): number;
440
- /**
441
- * Small-signal impedance about the current (steady) state, seen at one terminal. Linearising
442
- * gives (J + iωM)·δx + Σ B_k δV_k = rhs for the grid's rows, and (C_k + iωC′_k)·δx +
443
- * (∂I_k/∂V_k)·δV_k = δI_set,k for each floating terminal's circuit row, with J the steady
444
- * Jacobian and M the storage part (from J(dt) = J + M/dt), B_k = ∂res/∂V_k and C_k = ∂I_k/∂x.
445
- * At the measured terminal, a held voltage is perturbed (rhs = −B δV) and its current read
446
- * from C, or a driven current is perturbed and its voltage solved for. The other terminals
447
- * keep their drives: held ones at AC ground, driven ones at AC open circuit.
448
- * Z = δV/δI with I into the device (positive real part for a passive device).
449
- * @param {ArrayLike<number>} frequencies Hz
450
- */
451
- impedance(frequencies: ArrayLike<number>, opts: any): {
452
- f: Float64Array<ArrayBuffer>;
453
- Z: {
454
- re: Float64Array<any>;
455
- im: Float64Array<any>;
456
- };
457
- };
458
- allTerminals: any;
459
- _impedance(frequencies: any, { profiles, terminal }?: {
460
- profiles?: boolean;
461
- terminal?: string;
462
- }): {
463
- f: Float64Array<ArrayBuffer>;
464
- Z: {
465
- re: Float64Array<any>;
466
- im: Float64Array<any>;
467
- };
468
- };
469
- _regionShift(yr: any, yi: any): Float64Array<any>[];
470
- _regionEdgeRows(): Uint8Array<any>;
471
- _currentCuts(): {
472
- s: any;
473
- idx: any[];
474
- g: any[];
475
- d: any[];
476
- }[];
477
307
  segmentFluxes(): Float64Array<ArrayBuffer>[];
478
308
  faceOneWay(f: any): any;
479
- _smallSignalProfiles(xr: any, xi: any): {
480
- phi: {
481
- re: Float64Array<any>;
482
- im: Float64Array<any>;
483
- };
484
- mu: {};
485
- c: {};
486
- };
487
- _assembleBookkeeping(dt: any): void;
488
309
  _accumulateBoundaryIntake(dt: any, cN: any): void;
489
- slowestTime(): number;
490
- fastestTime(): number;
491
- /**
492
- * Steady state: where a transient from the present state ends, found as the solution of the
493
- * steady equations (dt = ∞, no storage term), with no slow modes to wait out, however slow the
494
- * physics (e.g. exponentially scarce minority carriers). What the storage term held is held by
495
- * the steady system's own rows instead (see src/laws.js): each conserved amount in place of a balance
496
- * row that says nothing new, levels that carry nothing held flat, islands' summed balances.
497
- * Where Newton from here fails: continuation along the drives, then the pseudo-transient ramp.
498
- * The clock is not advanced, and open-system conservation bookkeeping restarts here.
499
- */
500
- solveSteady(opts?: {}): any;
501
- unreached: {
502
- terminal: any;
503
- target: any;
504
- low: any;
505
- high: any;
506
- };
507
- charging: {
508
- terminal: any;
509
- current: any;
510
- what: any[];
511
- };
512
- steadyAt: number;
513
- _solveSteadyAll(opts: any): any;
514
- _steadyFromHere(opts: any): any;
515
- dimmer: boolean;
516
- _bound(k: any): boolean;
517
- _floatingContinuation(opts: any, r: any): any;
518
- _generationContinuation(opts: any, r: any): {
519
- converged: boolean;
520
- steps: any;
521
- iterations: any;
522
- history: any;
523
- };
524
- _continuation(opts: any, k: any, level: any, target: any, r: any, warm: any, hold: any): any;
525
- _steadySteps({ maxSteps, tol }?: {
526
- maxSteps?: number;
527
- tol?: number;
528
- }): {
529
- converged: boolean;
530
- steps: number;
531
- iterations: number;
532
- history: ({
533
- dt: number;
534
- converged: boolean;
535
- iterations: number;
536
- maxStep?: undefined;
537
- } | {
538
- dt: number;
539
- converged: boolean;
540
- iterations: number;
541
- maxStep: number;
542
- })[];
543
- };
544
- _renormalizeSpectators(): void;
545
- _diff(): Float64Array<ArrayBuffer>;
546
310
  }
547
- import { DifferenceTerms } from './difference.js';
311
+ import { BlockTridiagonal } from './blockTridiagonal.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Cold start. Each species takes its region's c0 where one is given (for a spectator, it fixes
3
+ * the conserved amount), else its contact's level. φ in each region is then chosen for local neutrality (node by node where a
4
+ * profile varies), or continued across the interface dipole if nothing there responds.
5
+ */
6
+ export function initFromComposition(s: any): void;
@@ -0,0 +1,78 @@
1
+ export class SteadySolves {
2
+ slowestTime(): number;
3
+ _usedMaterials(): any[];
4
+ fastestTime(): number;
5
+ /**
6
+ * Steady state: where a transient from the present state ends, found as the solution of the
7
+ * steady equations (dt = ∞, no storage term), with no slow transport to wait out (e.g.
8
+ * exponentially scarce minority carriers); but a slow reaction that alone settles a closed
9
+ * combination is waited out by time steps, to ~1e12 of the slowest diffusion time (invariant
10
+ * 5). What the storage term held is held by
11
+ * the steady system's own rows instead (see src/laws.js): each conserved amount in place of a balance
12
+ * row that says nothing new, levels that carry nothing held flat, islands' summed balances.
13
+ * Where Newton from here fails: continuation along the drives, then the pseudo-transient ramp.
14
+ * The clock is not advanced, and open-system conservation bookkeeping restarts here.
15
+ */
16
+ solveSteady(opts?: {}): any;
17
+ violent: any[];
18
+ unreached: {
19
+ terminal: any;
20
+ target: any;
21
+ low: any;
22
+ high: any;
23
+ };
24
+ charging: {
25
+ terminal: any;
26
+ current: any;
27
+ what: any;
28
+ };
29
+ steady: boolean;
30
+ steadyAt: any;
31
+ drifted: any;
32
+ _solveSteadyAll(opts: any): any;
33
+ atSteady: any;
34
+ _steadyFromHere(opts: any): any;
35
+ conditioning: any;
36
+ sourceTime: any;
37
+ solvedV: any[];
38
+ stepped: boolean;
39
+ dimmer: boolean;
40
+ _bound(k: any): any;
41
+ _floatingContinuation(opts: any, r: any): any;
42
+ _generationContinuation(opts: any, r: any): {
43
+ converged: boolean;
44
+ steps: any;
45
+ iterations: any;
46
+ history: any;
47
+ };
48
+ generationScale: number;
49
+ _continuation(opts: any, k: any, level: any, target: any, r: any, warm: any, hold: any): any;
50
+ _steadySteps({ maxSteps, tol }?: {
51
+ maxSteps?: number;
52
+ tol?: number;
53
+ }): {
54
+ converged: boolean;
55
+ steps: number;
56
+ iterations: number;
57
+ history: ({
58
+ drifted?: boolean;
59
+ dt: number;
60
+ converged: any;
61
+ iterations: any;
62
+ maxStep?: undefined;
63
+ } | {
64
+ dt: number;
65
+ converged: any;
66
+ iterations: any;
67
+ maxStep: number;
68
+ })[];
69
+ };
70
+ time: any;
71
+ history: any[];
72
+ dtNext: any;
73
+ _unkeptAmounts(): any;
74
+ _renormalizeSpectators(): void;
75
+ _diff(): any;
76
+ _directSteady(): any;
77
+ stuckReactions(): any[];
78
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Advance by dt, splitting the interval into halves (recursively) wherever Newton fails.
3
+ * Converged, the end time is t + dt; failed, wherever the halves that converged got to (the
4
+ * substeps counted are those of the last attempt's halves).
5
+ */
6
+ export function advance(s: any, dt: any, opts: any, depth?: number): any;
7
+ /**
8
+ * One time step of size dt. Backward Euler by default; with `method: 'bdf2'`, variable-step
9
+ * BDF2 once a previous step exists (and the step ratio is at most 2, for stability). On
10
+ * failure the state is restored.
11
+ *
12
+ * BDF2's storage term (a0 c − (1+ω) c_n + ω²/(1+ω) c_{n−1})/dt is written in backward-Euler
13
+ * form (c − c*)/(dt/a0), so assembly is shared: c* and the displacement histories replace
14
+ * the start-of-step values, and dt/a0 replaces dt.
15
+ */
16
+ export function step(s: any, dt: any, opts?: {}): any;
17
+ /**
18
+ * Adaptive time stepping to tEnd: variable-step BDF2 (or backward Euler), with the local error
19
+ * estimated against an explicit predictor through the previous states, and controlled to
20
+ * `tol` thermal units per step in every potential (φ̂, each η, a surface's coverages as η). The first
21
+ * step is checked by step doubling. Stops early when `budgetMs` of wall time is used, so an
22
+ * animation can call it once per frame; the step size carries over between calls.
23
+ */
24
+ export function integrate(s: any, tEnd: any, opts?: {}): {
25
+ stopped?: string;
26
+ converged: boolean;
27
+ done: boolean;
28
+ steps: number;
29
+ rejected: number;
30
+ iterations: number;
31
+ trace: {
32
+ probes?: any;
33
+ t: any[];
34
+ current: any[];
35
+ voltage: any[];
36
+ };
37
+ };
38
+ export function violentStart(s: any): any[];
package/types/types.d.ts CHANGED
@@ -820,6 +820,12 @@ export type ImpedanceResult = {
820
820
  re: Float64Array;
821
821
  im: Float64Array;
822
822
  };
823
+ /**
824
+ * each Z's estimated error, relative to |Z| (on Re Z and Im Z alike): the current's round-off
825
+ * and the solves' residuals; cautious (it can exceed the true error many times). Over 1%, or over 10·|Re Z|/|Z|,
826
+ * a warning says so
827
+ */
828
+ relError: Float64Array;
823
829
  /**
824
830
  * per frequency, per unit excitation (volt, or A/m² in current mode)
825
831
  */