@molcrafts/molrs 0.0.7 → 0.0.8
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 +40 -13
- package/molrs.d.ts +492 -250
- package/molrs.js +2 -2
- package/molrs_bg.js +785 -365
- package/molrs_bg.wasm +0 -0
- package/package.json +1 -1
package/molrs.d.ts
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
* Column-oriented data store with typed arrays.
|
|
6
6
|
*
|
|
7
7
|
* Each column is identified by a string key and has a fixed data type
|
|
8
|
-
* (`
|
|
8
|
+
* (`F`, `i32`, `u32`, `string`). All columns in a block must have
|
|
9
9
|
* the same number of rows.
|
|
10
10
|
*
|
|
11
11
|
* # Supported column types
|
|
12
12
|
*
|
|
13
13
|
* | JS type | Rust type | dtype string | Setter | Getter (copy) | Getter (view) |
|
|
14
14
|
* |---------|-----------|-------------|--------|---------------|---------------|
|
|
15
|
-
* | `Float32Array` | `
|
|
15
|
+
* | `Float32Array` / `Float64Array` | `F` | `"f32"` / `"f64"` | `setColF` | `copyColF` | `viewColF` |
|
|
16
16
|
* | `Int32Array` | `i32` | `"i32"` | `setColI32` | `copyColI32` | `viewColI32` |
|
|
17
17
|
* | `Uint32Array` | `u32` | `"u32"` | `setColU32` | `copyColU32` | `viewColU32` |
|
|
18
18
|
* | `string[]` | `String` | `"string"` | `setColStr` | `copyColStr` | -- |
|
|
@@ -21,21 +21,21 @@
|
|
|
21
21
|
*
|
|
22
22
|
* ```js
|
|
23
23
|
* const block = new Block();
|
|
24
|
-
* block.
|
|
25
|
-
* block.
|
|
24
|
+
* block.setColF("x", coordsX);
|
|
25
|
+
* block.setColF("y", coordsY);
|
|
26
26
|
* console.log(block.nrows()); // 3
|
|
27
27
|
* console.log(block.keys()); // ["x", "y"]
|
|
28
28
|
*
|
|
29
|
-
* const x = block.
|
|
29
|
+
* const x = block.copyColF("x"); // owned copy, safe to keep
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
export class Block {
|
|
33
33
|
free(): void;
|
|
34
34
|
[Symbol.dispose](): void;
|
|
35
35
|
/**
|
|
36
|
-
* Owned
|
|
36
|
+
* Owned JS float typed-array copy of a column.
|
|
37
37
|
*
|
|
38
|
-
* Returns a new JS
|
|
38
|
+
* Returns a new JS float typed array that is an independent copy of
|
|
39
39
|
* the column data. Safe to store and use across allocations.
|
|
40
40
|
*
|
|
41
41
|
* # Arguments
|
|
@@ -44,20 +44,20 @@ export class Block {
|
|
|
44
44
|
*
|
|
45
45
|
* # Returns
|
|
46
46
|
*
|
|
47
|
-
* An owned
|
|
47
|
+
* An owned JS float typed-array copy of the column.
|
|
48
48
|
*
|
|
49
49
|
* # Errors
|
|
50
50
|
*
|
|
51
|
-
* Throws if the column does not exist or is not of type
|
|
51
|
+
* Throws if the column does not exist or is not of the active float type.
|
|
52
52
|
*
|
|
53
53
|
* # Example (JavaScript)
|
|
54
54
|
*
|
|
55
55
|
* ```js
|
|
56
|
-
* const x = block.
|
|
56
|
+
* const x = block.copyColF("x");
|
|
57
57
|
* console.log(x[0]); // 1.0
|
|
58
58
|
* ```
|
|
59
59
|
*/
|
|
60
|
-
|
|
60
|
+
copyColF(key: string): Float64Array;
|
|
61
61
|
/**
|
|
62
62
|
* Owned `Int32Array` copy of a column.
|
|
63
63
|
*
|
|
@@ -120,7 +120,8 @@ export class Block {
|
|
|
120
120
|
/**
|
|
121
121
|
* Return the data type string for a column.
|
|
122
122
|
*
|
|
123
|
-
* Possible return values: `"f32"
|
|
123
|
+
* Possible return values: `"f32"` or `"f64"` for float columns,
|
|
124
|
+
* plus `"i32"`, `"u32"`, `"bool"`,
|
|
124
125
|
* `"string"`, `"u8"`. Returns `undefined` if the column does
|
|
125
126
|
* not exist.
|
|
126
127
|
*
|
|
@@ -135,7 +136,7 @@ export class Block {
|
|
|
135
136
|
* # Example (JavaScript)
|
|
136
137
|
*
|
|
137
138
|
* ```js
|
|
138
|
-
* console.log(block.dtype("x")); // "f32"
|
|
139
|
+
* console.log(block.dtype("x")); // "f32" or "f64"
|
|
139
140
|
* console.log(block.dtype("symbol")); // "string"
|
|
140
141
|
* ```
|
|
141
142
|
*/
|
|
@@ -197,7 +198,7 @@ export class Block {
|
|
|
197
198
|
*
|
|
198
199
|
* ```js
|
|
199
200
|
* const block = new Block();
|
|
200
|
-
* block.
|
|
201
|
+
* block.setColF("values", values);
|
|
201
202
|
* ```
|
|
202
203
|
*/
|
|
203
204
|
constructor();
|
|
@@ -241,12 +242,12 @@ export class Block {
|
|
|
241
242
|
*/
|
|
242
243
|
renameColumn(old_key: string, new_key: string): boolean;
|
|
243
244
|
/**
|
|
244
|
-
* Set a float column from a
|
|
245
|
+
* Set a float column from a JS float typed array.
|
|
245
246
|
*
|
|
246
247
|
* # Arguments
|
|
247
248
|
*
|
|
248
249
|
* * `key` - Column name (e.g., `"x"`, `"mass"`, `"charge"`)
|
|
249
|
-
* * `data` -
|
|
250
|
+
* * `data` - JS float typed array with the column values
|
|
250
251
|
* * `shape` - Optional shape array for multi-dimensional data
|
|
251
252
|
* (e.g., `[N, 3]` for an Nx3 matrix stored flat). If omitted,
|
|
252
253
|
* the data is stored as a 1D column.
|
|
@@ -259,12 +260,12 @@ export class Block {
|
|
|
259
260
|
* # Example (JavaScript)
|
|
260
261
|
*
|
|
261
262
|
* ```js
|
|
262
|
-
* block.
|
|
263
|
+
* block.setColF("x", xCoords);
|
|
263
264
|
* // Multi-dimensional: 2 rows x 3 columns
|
|
264
|
-
* block.
|
|
265
|
+
* block.setColF("pos", positions, [2, 3]);
|
|
265
266
|
* ```
|
|
266
267
|
*/
|
|
267
|
-
|
|
268
|
+
setColF(key: string, data: Float64Array, shape?: Uint32Array | null): void;
|
|
268
269
|
/**
|
|
269
270
|
* Set a signed integer column from an `Int32Array`.
|
|
270
271
|
*
|
|
@@ -326,13 +327,13 @@ export class Block {
|
|
|
326
327
|
*/
|
|
327
328
|
setColU32(key: string, data: Uint32Array): void;
|
|
328
329
|
/**
|
|
329
|
-
* Zero-copy
|
|
330
|
+
* Zero-copy JS float typed-array view into WASM linear memory.
|
|
330
331
|
*
|
|
331
332
|
* Returns a view backed directly by the block's storage in WASM
|
|
332
333
|
* memory. This avoids copying but the view becomes **invalid**
|
|
333
334
|
* if WASM linear memory grows (due to any allocation).
|
|
334
335
|
*
|
|
335
|
-
* Use [`
|
|
336
|
+
* Use [`copyColF`](Block::copy_col_f) for a safe, long-lived copy.
|
|
336
337
|
*
|
|
337
338
|
* # Arguments
|
|
338
339
|
*
|
|
@@ -340,20 +341,20 @@ export class Block {
|
|
|
340
341
|
*
|
|
341
342
|
* # Returns
|
|
342
343
|
*
|
|
343
|
-
* A
|
|
344
|
+
* A JS float typed-array view into WASM memory.
|
|
344
345
|
*
|
|
345
346
|
* # Errors
|
|
346
347
|
*
|
|
347
|
-
* Throws if the column does not exist or is not of type
|
|
348
|
+
* Throws if the column does not exist or is not of the active float type.
|
|
348
349
|
*
|
|
349
350
|
* # Example (JavaScript)
|
|
350
351
|
*
|
|
351
352
|
* ```js
|
|
352
|
-
* const view = block.
|
|
353
|
-
* const copy = block.
|
|
353
|
+
* const view = block.viewColF("x"); // zero-copy, use immediately
|
|
354
|
+
* const copy = block.copyColF("x"); // safe to keep
|
|
354
355
|
* ```
|
|
355
356
|
*/
|
|
356
|
-
|
|
357
|
+
viewColF(key: string): Float64Array;
|
|
357
358
|
/**
|
|
358
359
|
* Zero-copy `Int32Array` view into WASM linear memory.
|
|
359
360
|
*
|
|
@@ -411,8 +412,8 @@ export class Block {
|
|
|
411
412
|
* # Example (JavaScript)
|
|
412
413
|
*
|
|
413
414
|
* ```js
|
|
414
|
-
* const h =
|
|
415
|
-
* const origin =
|
|
415
|
+
* const h = floatArrayH;
|
|
416
|
+
* const origin = floatArrayOrigin;
|
|
416
417
|
* const box = new Box(h, origin, true, true, true);
|
|
417
418
|
* console.log(box.volume()); // 1000.0
|
|
418
419
|
* console.log(box.lengths().toCopy()); // [10, 10, 10]
|
|
@@ -427,7 +428,7 @@ export class Box {
|
|
|
427
428
|
* # Arguments
|
|
428
429
|
*
|
|
429
430
|
* * `a` - Side length of the cube in angstrom (A)
|
|
430
|
-
* * `origin` - 3D origin vector as
|
|
431
|
+
* * `origin` - 3D origin vector as a float typed array with 3 elements
|
|
431
432
|
* `[x, y, z]` in angstrom
|
|
432
433
|
* * `pbc_x` - Enable periodic boundary in x direction
|
|
433
434
|
* * `pbc_y` - Enable periodic boundary in y direction
|
|
@@ -444,12 +445,12 @@ export class Box {
|
|
|
444
445
|
* # Example (JavaScript)
|
|
445
446
|
*
|
|
446
447
|
* ```js
|
|
447
|
-
* const origin =
|
|
448
|
+
* const origin = originVec;
|
|
448
449
|
* const box = Box.cube(10.0, origin, true, true, true);
|
|
449
450
|
* console.log(box.volume()); // 1000.0
|
|
450
451
|
* ```
|
|
451
452
|
*/
|
|
452
|
-
static cube(a: number, origin:
|
|
453
|
+
static cube(a: number, origin: Float64Array, pbc_x: boolean, pbc_y: boolean, pbc_z: boolean): Box;
|
|
453
454
|
/**
|
|
454
455
|
* Calculate displacement vectors between two sets of coordinates.
|
|
455
456
|
*
|
|
@@ -478,8 +479,8 @@ export class Box {
|
|
|
478
479
|
* # Example (JavaScript)
|
|
479
480
|
*
|
|
480
481
|
* ```js
|
|
481
|
-
* const a = WasmArray.from(
|
|
482
|
-
* const b = WasmArray.from(
|
|
482
|
+
* const a = WasmArray.from(aCoords, [1, 3]);
|
|
483
|
+
* const b = WasmArray.from(bCoords, [1, 3]);
|
|
483
484
|
* const d = box.delta(a, b, true); // minimum-image displacement
|
|
484
485
|
* ```
|
|
485
486
|
*/
|
|
@@ -496,7 +497,7 @@ export class Box {
|
|
|
496
497
|
* * `b` - `WasmArray` with shape `[N, 3]` (target positions in A)
|
|
497
498
|
* * `minimum_image` - If `true`, apply minimum image convention
|
|
498
499
|
* * `out_block` - Target [`Block`] to write the result into
|
|
499
|
-
* * `out_key` - Column name for the result (
|
|
500
|
+
* * `out_key` - Column name for the result (float, shape `[N, 3]`)
|
|
500
501
|
*
|
|
501
502
|
* # Errors
|
|
502
503
|
*
|
|
@@ -538,7 +539,7 @@ export class Box {
|
|
|
538
539
|
* # Example (JavaScript)
|
|
539
540
|
*
|
|
540
541
|
* ```js
|
|
541
|
-
* const L = box.lengths().toCopy(); // Float32Array [10, 10, 10]
|
|
542
|
+
* const L = box.lengths().toCopy(); // Float32Array or Float64Array [10, 10, 10]
|
|
542
543
|
* ```
|
|
543
544
|
*/
|
|
544
545
|
lengths(): WasmArray;
|
|
@@ -547,10 +548,10 @@ export class Box {
|
|
|
547
548
|
*
|
|
548
549
|
* # Arguments
|
|
549
550
|
*
|
|
550
|
-
* * `h` - 3x3 cell matrix as
|
|
551
|
+
* * `h` - 3x3 cell matrix as a float typed array with 9 elements in
|
|
551
552
|
* row-major order: `[h00, h01, h02, h10, h11, h12, h20, h21, h22]`.
|
|
552
553
|
* All values in angstrom (A).
|
|
553
|
-
* * `origin` - 3D origin vector as
|
|
554
|
+
* * `origin` - 3D origin vector as a float typed array with 3 elements
|
|
554
555
|
* `[x, y, z]` in angstrom.
|
|
555
556
|
* * `pbc_x` - Enable periodic boundary in x direction
|
|
556
557
|
* * `pbc_y` - Enable periodic boundary in y direction
|
|
@@ -569,12 +570,12 @@ export class Box {
|
|
|
569
570
|
*
|
|
570
571
|
* ```js
|
|
571
572
|
* // Triclinic box
|
|
572
|
-
* const h =
|
|
573
|
-
* const origin =
|
|
573
|
+
* const h = hMatrix;
|
|
574
|
+
* const origin = originVec;
|
|
574
575
|
* const box = new Box(h, origin, true, true, true);
|
|
575
576
|
* ```
|
|
576
577
|
*/
|
|
577
|
-
constructor(h:
|
|
578
|
+
constructor(h: Float64Array, origin: Float64Array, pbc_x: boolean, pbc_y: boolean, pbc_z: boolean);
|
|
578
579
|
/**
|
|
579
580
|
* Return the box origin as a `WasmArray` with shape `[3]`.
|
|
580
581
|
*
|
|
@@ -587,7 +588,7 @@ export class Box {
|
|
|
587
588
|
* # Example (JavaScript)
|
|
588
589
|
*
|
|
589
590
|
* ```js
|
|
590
|
-
* const o = box.origin().toCopy(); // Float32Array [0, 0, 0]
|
|
591
|
+
* const o = box.origin().toCopy(); // Float32Array or Float64Array [0, 0, 0]
|
|
591
592
|
* ```
|
|
592
593
|
*/
|
|
593
594
|
origin(): WasmArray;
|
|
@@ -596,9 +597,9 @@ export class Box {
|
|
|
596
597
|
*
|
|
597
598
|
* # Arguments
|
|
598
599
|
*
|
|
599
|
-
* * `lengths` - Box dimensions as
|
|
600
|
+
* * `lengths` - Box dimensions as a float typed array with 3 elements
|
|
600
601
|
* `[lx, ly, lz]` in angstrom (A)
|
|
601
|
-
* * `origin` - 3D origin vector as
|
|
602
|
+
* * `origin` - 3D origin vector as a float typed array with 3 elements
|
|
602
603
|
* `[x, y, z]` in angstrom
|
|
603
604
|
* * `pbc_x` - Enable periodic boundary in x direction
|
|
604
605
|
* * `pbc_y` - Enable periodic boundary in y direction
|
|
@@ -615,12 +616,12 @@ export class Box {
|
|
|
615
616
|
* # Example (JavaScript)
|
|
616
617
|
*
|
|
617
618
|
* ```js
|
|
618
|
-
* const origin =
|
|
619
|
-
* const box = Box.ortho(
|
|
619
|
+
* const origin = originVec;
|
|
620
|
+
* const box = Box.ortho(lengthsVec, origin, true, true, true);
|
|
620
621
|
* console.log(box.volume()); // 6000.0
|
|
621
622
|
* ```
|
|
622
623
|
*/
|
|
623
|
-
static ortho(lengths:
|
|
624
|
+
static ortho(lengths: Float64Array, origin: Float64Array, pbc_x: boolean, pbc_y: boolean, pbc_z: boolean): Box;
|
|
624
625
|
/**
|
|
625
626
|
* Return the box tilt factors as a `WasmArray` with shape `[3]`.
|
|
626
627
|
*
|
|
@@ -636,7 +637,7 @@ export class Box {
|
|
|
636
637
|
* # Example (JavaScript)
|
|
637
638
|
*
|
|
638
639
|
* ```js
|
|
639
|
-
* const t = box.tilts().toCopy(); // Float32Array [0, 0, 0]
|
|
640
|
+
* const t = box.tilts().toCopy(); // Float32Array or Float64Array [0, 0, 0]
|
|
640
641
|
* ```
|
|
641
642
|
*/
|
|
642
643
|
tilts(): WasmArray;
|
|
@@ -648,7 +649,7 @@ export class Box {
|
|
|
648
649
|
*
|
|
649
650
|
* * `coords` - `WasmArray` with shape `[N, 3]` (fractional, dimensionless)
|
|
650
651
|
* * `out_block` - Target [`Block`]
|
|
651
|
-
* * `out_key` - Column name for the result (
|
|
652
|
+
* * `out_key` - Column name for the result (float, shape `[N, 3]`)
|
|
652
653
|
*
|
|
653
654
|
* # Errors
|
|
654
655
|
*
|
|
@@ -669,7 +670,7 @@ export class Box {
|
|
|
669
670
|
*
|
|
670
671
|
* * `coords` - `WasmArray` with shape `[N, 3]` (Cartesian, A)
|
|
671
672
|
* * `out_block` - Target [`Block`]
|
|
672
|
-
* * `out_key` - Column name for the result (
|
|
673
|
+
* * `out_key` - Column name for the result (float, shape `[N, 3]`)
|
|
673
674
|
*
|
|
674
675
|
* # Errors
|
|
675
676
|
*
|
|
@@ -702,7 +703,7 @@ export class Box {
|
|
|
702
703
|
* # Example (JavaScript)
|
|
703
704
|
*
|
|
704
705
|
* ```js
|
|
705
|
-
* const frac = WasmArray.from(
|
|
706
|
+
* const frac = WasmArray.from(fracCoords, [1, 3]);
|
|
706
707
|
* const cart = box.toCart(frac);
|
|
707
708
|
* console.log(cart.toCopy()); // [5, 5, 5] for a 10x10x10 box
|
|
708
709
|
* ```
|
|
@@ -731,7 +732,7 @@ export class Box {
|
|
|
731
732
|
* # Example (JavaScript)
|
|
732
733
|
*
|
|
733
734
|
* ```js
|
|
734
|
-
* const cart = WasmArray.from(
|
|
735
|
+
* const cart = WasmArray.from(coords, [1, 3]);
|
|
735
736
|
* const frac = box.toFrac(cart);
|
|
736
737
|
* console.log(frac.toCopy()); // [0.5, 0.5, 0.5] for a 10x10x10 box
|
|
737
738
|
* ```
|
|
@@ -771,7 +772,7 @@ export class Box {
|
|
|
771
772
|
* # Example (JavaScript)
|
|
772
773
|
*
|
|
773
774
|
* ```js
|
|
774
|
-
* const pos = WasmArray.from(
|
|
775
|
+
* const pos = WasmArray.from(positions, [1, 3]);
|
|
775
776
|
* const wrapped = box.wrap(pos); // wraps into [0, lx) x [0, ly) x [0, lz)
|
|
776
777
|
* ```
|
|
777
778
|
*/
|
|
@@ -787,7 +788,7 @@ export class Box {
|
|
|
787
788
|
* * `coords` - `WasmArray` with shape `[N, 3]` containing
|
|
788
789
|
* Cartesian coordinates in angstrom (A)
|
|
789
790
|
* * `out_block` - Target [`Block`] to write the result into
|
|
790
|
-
* * `out_key` - Column name for the result (
|
|
791
|
+
* * `out_key` - Column name for the result (float, shape `[N, 3]`)
|
|
791
792
|
*
|
|
792
793
|
* # Errors
|
|
793
794
|
*
|
|
@@ -816,9 +817,9 @@ export class CenterOfMass {
|
|
|
816
817
|
/**
|
|
817
818
|
* Create a center-of-mass calculator.
|
|
818
819
|
*
|
|
819
|
-
* Pass `null` for uniform masses, or a
|
|
820
|
+
* Pass `null` for uniform masses, or a float typed array of per-particle masses.
|
|
820
821
|
*/
|
|
821
|
-
constructor(masses?:
|
|
822
|
+
constructor(masses?: Float64Array | null);
|
|
822
823
|
}
|
|
823
824
|
|
|
824
825
|
/**
|
|
@@ -828,8 +829,8 @@ export class CenterOfMass {
|
|
|
828
829
|
*
|
|
829
830
|
* ```js
|
|
830
831
|
* const com = new CenterOfMass().compute(frame, clusterResult);
|
|
831
|
-
* com.centersOfMass(); // Float32Array [x0,y0,z0, ...]
|
|
832
|
-
* com.clusterMasses(); // Float32Array
|
|
832
|
+
* com.centersOfMass(); // Float32Array or Float64Array [x0,y0,z0, ...]
|
|
833
|
+
* com.clusterMasses(); // Float32Array or Float64Array
|
|
833
834
|
* ```
|
|
834
835
|
*/
|
|
835
836
|
export class CenterOfMassResult {
|
|
@@ -837,13 +838,15 @@ export class CenterOfMassResult {
|
|
|
837
838
|
free(): void;
|
|
838
839
|
[Symbol.dispose](): void;
|
|
839
840
|
/**
|
|
840
|
-
*
|
|
841
|
+
* Zero-copy `Float64Array` view of mass-weighted centers, flat
|
|
842
|
+
* `[x0,y0,z0, x1,y1,z1, ...]`. **Invalidated** on WASM memory growth.
|
|
841
843
|
*/
|
|
842
|
-
centersOfMass():
|
|
844
|
+
centersOfMass(): Float64Array;
|
|
843
845
|
/**
|
|
844
|
-
*
|
|
846
|
+
* Zero-copy `Float64Array` view of total mass per cluster.
|
|
847
|
+
* **Invalidated** on WASM memory growth.
|
|
845
848
|
*/
|
|
846
|
-
clusterMasses():
|
|
849
|
+
clusterMasses(): Float64Array;
|
|
847
850
|
/**
|
|
848
851
|
* Number of clusters.
|
|
849
852
|
*/
|
|
@@ -923,16 +926,16 @@ export class Cluster {
|
|
|
923
926
|
*
|
|
924
927
|
* ```js
|
|
925
928
|
* const centers = new ClusterCenters().compute(frame, clusterResult);
|
|
926
|
-
* // Float32Array [x0,y0,z0, x1,y1,z1, ...]
|
|
929
|
+
* // Float32Array or Float64Array [x0,y0,z0, x1,y1,z1, ...]
|
|
927
930
|
* ```
|
|
928
931
|
*/
|
|
929
932
|
export class ClusterCenters {
|
|
930
933
|
free(): void;
|
|
931
934
|
[Symbol.dispose](): void;
|
|
932
935
|
/**
|
|
933
|
-
* Compute geometric centers. Returns flat
|
|
936
|
+
* Compute geometric centers. Returns a flat float typed array `[x0,y0,z0, ...]`.
|
|
934
937
|
*/
|
|
935
|
-
compute(frame: Frame, cluster_result: ClusterResult):
|
|
938
|
+
compute(frame: Frame, cluster_result: ClusterResult): Float64Array;
|
|
936
939
|
constructor();
|
|
937
940
|
}
|
|
938
941
|
|
|
@@ -991,10 +994,10 @@ export class ClusterResult {
|
|
|
991
994
|
* # Conventions
|
|
992
995
|
*
|
|
993
996
|
* - The `"atoms"` block should contain per-atom properties: `symbol`
|
|
994
|
-
* (string), `x`/`y`/`z` (
|
|
995
|
-
* `mass` (
|
|
997
|
+
* (string), `x`/`y`/`z` (F, coordinates in angstrom), and optionally
|
|
998
|
+
* `mass` (F, atomic mass units) and `charge` (F, elementary charges).
|
|
996
999
|
* - The `"bonds"` block should contain bond topology: `i`/`j` (u32,
|
|
997
|
-
* zero-based atom indices) and `order` (
|
|
1000
|
+
* zero-based atom indices) and `order` (F, bond order: 1.0 = single,
|
|
998
1001
|
* 1.5 = aromatic, 2.0 = double, 3.0 = triple).
|
|
999
1002
|
*
|
|
1000
1003
|
* # Example (JavaScript)
|
|
@@ -1002,7 +1005,7 @@ export class ClusterResult {
|
|
|
1002
1005
|
* ```js
|
|
1003
1006
|
* const frame = new Frame();
|
|
1004
1007
|
* const atoms = frame.createBlock("atoms");
|
|
1005
|
-
* atoms.
|
|
1008
|
+
* atoms.setColF("x", xCoords);
|
|
1006
1009
|
* ```
|
|
1007
1010
|
*/
|
|
1008
1011
|
export class Frame {
|
|
@@ -1044,7 +1047,7 @@ export class Frame {
|
|
|
1044
1047
|
*
|
|
1045
1048
|
* ```js
|
|
1046
1049
|
* const atoms = frame.createBlock("atoms");
|
|
1047
|
-
* atoms.
|
|
1050
|
+
* atoms.setColF("x", xCoords);
|
|
1048
1051
|
* ```
|
|
1049
1052
|
*/
|
|
1050
1053
|
createBlock(key: string): Block;
|
|
@@ -1084,11 +1087,57 @@ export class Frame {
|
|
|
1084
1087
|
* ```js
|
|
1085
1088
|
* const atoms = frame.getBlock("atoms");
|
|
1086
1089
|
* if (atoms) {
|
|
1087
|
-
* const x = atoms.
|
|
1090
|
+
* const x = atoms.copyColF("x");
|
|
1088
1091
|
* }
|
|
1089
1092
|
* ```
|
|
1090
1093
|
*/
|
|
1091
1094
|
getBlock(key: string): Block | undefined;
|
|
1095
|
+
/**
|
|
1096
|
+
* Retrieve a named grid attached to this frame.
|
|
1097
|
+
*
|
|
1098
|
+
* Returns a cloned [`Grid`] wrapper, or `undefined` if the grid does
|
|
1099
|
+
* not exist. The returned object is independent of the frame — mutations
|
|
1100
|
+
* to it are not reflected in the frame without a subsequent
|
|
1101
|
+
* [`insertGrid`](Frame::insert_grid) call.
|
|
1102
|
+
*
|
|
1103
|
+
* # Arguments
|
|
1104
|
+
*
|
|
1105
|
+
* * `name` — Grid name to retrieve.
|
|
1106
|
+
*
|
|
1107
|
+
* # Example (JavaScript)
|
|
1108
|
+
*
|
|
1109
|
+
* ```js
|
|
1110
|
+
* const g = frame.getGrid("chgcar");
|
|
1111
|
+
* if (g) {
|
|
1112
|
+
* const arr = g.getArray("rho");
|
|
1113
|
+
* }
|
|
1114
|
+
* ```
|
|
1115
|
+
*/
|
|
1116
|
+
getGrid(name: string): Grid | undefined;
|
|
1117
|
+
/**
|
|
1118
|
+
* Return the names of all grids attached to this frame.
|
|
1119
|
+
*
|
|
1120
|
+
* # Example (JavaScript)
|
|
1121
|
+
*
|
|
1122
|
+
* ```js
|
|
1123
|
+
* const names = frame.gridNames(); // e.g. ["chgcar", "spin"]
|
|
1124
|
+
* ```
|
|
1125
|
+
*/
|
|
1126
|
+
gridNames(): Array<any>;
|
|
1127
|
+
/**
|
|
1128
|
+
* Returns `true` if a named grid is attached to this frame.
|
|
1129
|
+
*
|
|
1130
|
+
* # Arguments
|
|
1131
|
+
*
|
|
1132
|
+
* * `name` — Grid name to look up.
|
|
1133
|
+
*
|
|
1134
|
+
* # Example (JavaScript)
|
|
1135
|
+
*
|
|
1136
|
+
* ```js
|
|
1137
|
+
* frame.hasGrid("chgcar"); // true or false
|
|
1138
|
+
* ```
|
|
1139
|
+
*/
|
|
1140
|
+
hasGrid(name: string): boolean;
|
|
1092
1141
|
/**
|
|
1093
1142
|
* Insert a block by deep-copying its data into this frame's store.
|
|
1094
1143
|
*
|
|
@@ -1116,6 +1165,31 @@ export class Frame {
|
|
|
1116
1165
|
* ```
|
|
1117
1166
|
*/
|
|
1118
1167
|
insertBlock(key: string, block: Block): void;
|
|
1168
|
+
/**
|
|
1169
|
+
* Attach a grid to this frame under the given name.
|
|
1170
|
+
*
|
|
1171
|
+
* If a grid with the same name already exists it is replaced. The grid
|
|
1172
|
+
* data is moved into the frame; the JS `Grid` object becomes empty after
|
|
1173
|
+
* this call and should not be reused.
|
|
1174
|
+
*
|
|
1175
|
+
* # Arguments
|
|
1176
|
+
*
|
|
1177
|
+
* * `name` — Name to store the grid under (e.g., `"chgcar"`).
|
|
1178
|
+
* * `grid` — The [`Grid`] to attach.
|
|
1179
|
+
*
|
|
1180
|
+
* # Errors
|
|
1181
|
+
*
|
|
1182
|
+
* Throws a `JsValue` string if the frame has been dropped.
|
|
1183
|
+
*
|
|
1184
|
+
* # Example (JavaScript)
|
|
1185
|
+
*
|
|
1186
|
+
* ```js
|
|
1187
|
+
* const grid = new Grid(10, 10, 10, origin, cell, true, true, true);
|
|
1188
|
+
* grid.insertArray("rho", rhoData);
|
|
1189
|
+
* frame.insertGrid("chgcar", grid);
|
|
1190
|
+
* ```
|
|
1191
|
+
*/
|
|
1192
|
+
insertGrid(name: string, grid: Grid): void;
|
|
1119
1193
|
/**
|
|
1120
1194
|
* Create a new, empty `Frame` with no blocks and no simulation box.
|
|
1121
1195
|
*
|
|
@@ -1145,6 +1219,24 @@ export class Frame {
|
|
|
1145
1219
|
* ```
|
|
1146
1220
|
*/
|
|
1147
1221
|
removeBlock(key: string): void;
|
|
1222
|
+
/**
|
|
1223
|
+
* Remove a named grid from this frame.
|
|
1224
|
+
*
|
|
1225
|
+
* # Arguments
|
|
1226
|
+
*
|
|
1227
|
+
* * `name` — Grid name to remove.
|
|
1228
|
+
*
|
|
1229
|
+
* # Errors
|
|
1230
|
+
*
|
|
1231
|
+
* Throws a `JsValue` string if the frame has been dropped.
|
|
1232
|
+
*
|
|
1233
|
+
* # Example (JavaScript)
|
|
1234
|
+
*
|
|
1235
|
+
* ```js
|
|
1236
|
+
* frame.removeGrid("chgcar");
|
|
1237
|
+
* ```
|
|
1238
|
+
*/
|
|
1239
|
+
removeGrid(name: string): void;
|
|
1148
1240
|
/**
|
|
1149
1241
|
* Rename a block from `old_key` to `new_key`.
|
|
1150
1242
|
*
|
|
@@ -1229,13 +1321,216 @@ export class Frame {
|
|
|
1229
1321
|
* # Example (JavaScript)
|
|
1230
1322
|
*
|
|
1231
1323
|
* ```js
|
|
1232
|
-
* const origin =
|
|
1324
|
+
* const origin = originVec;
|
|
1233
1325
|
* frame.simbox = Box.cube(10.0, origin, true, true, true);
|
|
1234
1326
|
* ```
|
|
1235
1327
|
*/
|
|
1236
1328
|
set simbox(value: Box | null | undefined);
|
|
1237
1329
|
}
|
|
1238
1330
|
|
|
1331
|
+
/**
|
|
1332
|
+
* A uniform spatial grid storing multiple named scalar arrays.
|
|
1333
|
+
*
|
|
1334
|
+
* All arrays in a `Grid` share the same spatial definition: dimensions
|
|
1335
|
+
* (`[nx, ny, nz]`), Cartesian origin, cell matrix (columns are lattice
|
|
1336
|
+
* vectors, matching VASP/molrs convention), and periodic boundary flags.
|
|
1337
|
+
*
|
|
1338
|
+
* # Example (JavaScript)
|
|
1339
|
+
*
|
|
1340
|
+
* ```js
|
|
1341
|
+
* // Create a 10×10×10 cubic grid
|
|
1342
|
+
* const origin = new Float32Array([0, 0, 0]);
|
|
1343
|
+
* const cell = new Float32Array([
|
|
1344
|
+
* 10, 0, 0, // first column (a vector)
|
|
1345
|
+
* 0,10, 0, // second column (b vector)
|
|
1346
|
+
* 0, 0,10, // third column (c vector)
|
|
1347
|
+
* ]);
|
|
1348
|
+
* const grid = new Grid(10, 10, 10, origin, cell, true, true, true);
|
|
1349
|
+
*
|
|
1350
|
+
* // Insert a density array (must have length = 10*10*10 = 1000)
|
|
1351
|
+
* const rho = new Float32Array(1000).fill(1.0);
|
|
1352
|
+
* grid.insertArray("rho", rho);
|
|
1353
|
+
*
|
|
1354
|
+
* // Retrieve it
|
|
1355
|
+
* const arr = grid.getArray("rho");
|
|
1356
|
+
* console.log(arr.toCopy());
|
|
1357
|
+
* ```
|
|
1358
|
+
*/
|
|
1359
|
+
export class Grid {
|
|
1360
|
+
free(): void;
|
|
1361
|
+
[Symbol.dispose](): void;
|
|
1362
|
+
/**
|
|
1363
|
+
* Names of all scalar arrays stored in this grid.
|
|
1364
|
+
*
|
|
1365
|
+
* # Example (JavaScript)
|
|
1366
|
+
*
|
|
1367
|
+
* ```js
|
|
1368
|
+
* const names = grid.arrayNames(); // e.g. ["rho", "spin"]
|
|
1369
|
+
* ```
|
|
1370
|
+
*/
|
|
1371
|
+
arrayNames(): Array<any>;
|
|
1372
|
+
/**
|
|
1373
|
+
* Cell matrix in Ångström as a flat array of length 9 in column-major
|
|
1374
|
+
* order (columns are lattice vectors, matching VASP/molrs convention).
|
|
1375
|
+
*
|
|
1376
|
+
* Layout: `[col0_x, col0_y, col0_z, col1_x, col1_y, col1_z, col2_x, col2_y, col2_z]`
|
|
1377
|
+
*
|
|
1378
|
+
* # Example (JavaScript)
|
|
1379
|
+
*
|
|
1380
|
+
* ```js
|
|
1381
|
+
* const c = grid.cell();
|
|
1382
|
+
* const flat = c.toCopy(); // Float32Array of length 9
|
|
1383
|
+
* ```
|
|
1384
|
+
*/
|
|
1385
|
+
cell(): WasmArray;
|
|
1386
|
+
/**
|
|
1387
|
+
* Grid dimensions `[nx, ny, nz]`.
|
|
1388
|
+
*
|
|
1389
|
+
* # Example (JavaScript)
|
|
1390
|
+
*
|
|
1391
|
+
* ```js
|
|
1392
|
+
* console.log(grid.dim()); // [10, 10, 10]
|
|
1393
|
+
* ```
|
|
1394
|
+
*/
|
|
1395
|
+
dim(): Uint32Array;
|
|
1396
|
+
/**
|
|
1397
|
+
* Retrieve a named scalar array as a zero-copy `Float64Array` view
|
|
1398
|
+
* over the underlying WASM memory. Flat row-major order, length
|
|
1399
|
+
* `nx * ny * nz`. Use [`Grid::dim`] for shape.
|
|
1400
|
+
*
|
|
1401
|
+
* **Warning**: the view is invalidated on any WASM memory growth.
|
|
1402
|
+
* Copy it in JS (`new Float64Array(view)`) if it needs to outlive
|
|
1403
|
+
* subsequent allocations.
|
|
1404
|
+
*
|
|
1405
|
+
* Returns `undefined` if the named array does not exist.
|
|
1406
|
+
*
|
|
1407
|
+
* # Example (JavaScript)
|
|
1408
|
+
*
|
|
1409
|
+
* ```js
|
|
1410
|
+
* const view = grid.getArray("rho"); // zero-copy
|
|
1411
|
+
* const copy = new Float64Array(view); // owned copy if needed
|
|
1412
|
+
* ```
|
|
1413
|
+
*/
|
|
1414
|
+
getArray(name: string): Float64Array | undefined;
|
|
1415
|
+
/**
|
|
1416
|
+
* Returns `true` if a named array is present in this grid.
|
|
1417
|
+
*
|
|
1418
|
+
* # Arguments
|
|
1419
|
+
*
|
|
1420
|
+
* * `name` — Array name to look up.
|
|
1421
|
+
*
|
|
1422
|
+
* # Example (JavaScript)
|
|
1423
|
+
*
|
|
1424
|
+
* ```js
|
|
1425
|
+
* grid.hasArray("rho"); // true or false
|
|
1426
|
+
* ```
|
|
1427
|
+
*/
|
|
1428
|
+
hasArray(name: string): boolean;
|
|
1429
|
+
/**
|
|
1430
|
+
* Insert (or replace) a named scalar array.
|
|
1431
|
+
*
|
|
1432
|
+
* The provided `data` must have exactly `nx * ny * nz` elements in
|
|
1433
|
+
* row-major `(ix, iy, iz)` order.
|
|
1434
|
+
*
|
|
1435
|
+
* # Arguments
|
|
1436
|
+
*
|
|
1437
|
+
* * `name` — Array name.
|
|
1438
|
+
* * `data` — Float32Array with length equal to `grid.total()`.
|
|
1439
|
+
*
|
|
1440
|
+
* # Errors
|
|
1441
|
+
*
|
|
1442
|
+
* Throws if `data.length != nx * ny * nz`.
|
|
1443
|
+
*
|
|
1444
|
+
* # Example (JavaScript)
|
|
1445
|
+
*
|
|
1446
|
+
* ```js
|
|
1447
|
+
* const rho = new Float32Array(grid.total()).fill(0.5);
|
|
1448
|
+
* grid.insertArray("rho", rho);
|
|
1449
|
+
* ```
|
|
1450
|
+
*/
|
|
1451
|
+
insertArray(name: string, data: Float64Array): void;
|
|
1452
|
+
/**
|
|
1453
|
+
* Returns `true` if no arrays are stored.
|
|
1454
|
+
*
|
|
1455
|
+
* # Example (JavaScript)
|
|
1456
|
+
*
|
|
1457
|
+
* ```js
|
|
1458
|
+
* console.log(grid.isEmpty()); // true for a freshly created grid
|
|
1459
|
+
* ```
|
|
1460
|
+
*/
|
|
1461
|
+
isEmpty(): boolean;
|
|
1462
|
+
/**
|
|
1463
|
+
* Number of named arrays stored in this grid.
|
|
1464
|
+
*
|
|
1465
|
+
* # Example (JavaScript)
|
|
1466
|
+
*
|
|
1467
|
+
* ```js
|
|
1468
|
+
* console.log(grid.len()); // e.g. 2
|
|
1469
|
+
* ```
|
|
1470
|
+
*/
|
|
1471
|
+
len(): number;
|
|
1472
|
+
/**
|
|
1473
|
+
* Create a new empty grid with the given spatial definition.
|
|
1474
|
+
*
|
|
1475
|
+
* # Arguments
|
|
1476
|
+
*
|
|
1477
|
+
* * `dim_x`, `dim_y`, `dim_z` — Number of grid points along each axis.
|
|
1478
|
+
* * `origin` — Float32Array of length 3: Cartesian origin in Ångström.
|
|
1479
|
+
* * `cell` — Float32Array of length 9: cell matrix in column-major order.
|
|
1480
|
+
* `cell[0..3]` is the first lattice vector (a), `cell[3..6]` is b,
|
|
1481
|
+
* `cell[6..9]` is c (matching VASP/molrs convention where columns are
|
|
1482
|
+
* lattice vectors).
|
|
1483
|
+
* * `pbc_x`, `pbc_y`, `pbc_z` — Periodic boundary flags for each axis.
|
|
1484
|
+
*
|
|
1485
|
+
* # Errors
|
|
1486
|
+
*
|
|
1487
|
+
* Throws if `origin` does not have length 3, or `cell` does not have
|
|
1488
|
+
* length 9.
|
|
1489
|
+
*
|
|
1490
|
+
* # Example (JavaScript)
|
|
1491
|
+
*
|
|
1492
|
+
* ```js
|
|
1493
|
+
* const origin = new Float32Array([0, 0, 0]);
|
|
1494
|
+
* const cell = new Float32Array([10,0,0, 0,10,0, 0,0,10]);
|
|
1495
|
+
* const grid = new Grid(10, 10, 10, origin, cell, true, true, true);
|
|
1496
|
+
* ```
|
|
1497
|
+
*/
|
|
1498
|
+
constructor(dim_x: number, dim_y: number, dim_z: number, origin: Float64Array, cell: Float64Array, pbc_x: boolean, pbc_y: boolean, pbc_z: boolean);
|
|
1499
|
+
/**
|
|
1500
|
+
* Cartesian origin in Ångström as a 1-D array of length 3.
|
|
1501
|
+
*
|
|
1502
|
+
* # Example (JavaScript)
|
|
1503
|
+
*
|
|
1504
|
+
* ```js
|
|
1505
|
+
* const o = grid.origin();
|
|
1506
|
+
* const arr = o.toCopy(); // Float32Array [ox, oy, oz]
|
|
1507
|
+
* ```
|
|
1508
|
+
*/
|
|
1509
|
+
origin(): WasmArray;
|
|
1510
|
+
/**
|
|
1511
|
+
* Periodic boundary flags as a `Uint8Array`-compatible slice.
|
|
1512
|
+
*
|
|
1513
|
+
* Each element is `1` (periodic) or `0` (not periodic).
|
|
1514
|
+
*
|
|
1515
|
+
* # Example (JavaScript)
|
|
1516
|
+
*
|
|
1517
|
+
* ```js
|
|
1518
|
+
* console.log(grid.pbc()); // [1, 1, 1]
|
|
1519
|
+
* ```
|
|
1520
|
+
*/
|
|
1521
|
+
pbc(): Uint8Array;
|
|
1522
|
+
/**
|
|
1523
|
+
* Total number of voxels: `nx * ny * nz`.
|
|
1524
|
+
*
|
|
1525
|
+
* # Example (JavaScript)
|
|
1526
|
+
*
|
|
1527
|
+
* ```js
|
|
1528
|
+
* console.log(grid.total()); // 1000 for a 10×10×10 grid
|
|
1529
|
+
* ```
|
|
1530
|
+
*/
|
|
1531
|
+
total(): number;
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1239
1534
|
/**
|
|
1240
1535
|
* Gyration tensor per cluster.
|
|
1241
1536
|
*
|
|
@@ -1245,9 +1540,9 @@ export class GyrationTensor {
|
|
|
1245
1540
|
free(): void;
|
|
1246
1541
|
[Symbol.dispose](): void;
|
|
1247
1542
|
/**
|
|
1248
|
-
* Compute gyration tensors. Returns flat
|
|
1543
|
+
* Compute gyration tensors. Returns a flat float typed array (9 values per cluster).
|
|
1249
1544
|
*/
|
|
1250
|
-
compute(frame: Frame, cluster_result: ClusterResult):
|
|
1545
|
+
compute(frame: Frame, cluster_result: ClusterResult): Float64Array;
|
|
1251
1546
|
constructor();
|
|
1252
1547
|
}
|
|
1253
1548
|
|
|
@@ -1258,10 +1553,10 @@ export class InertiaTensor {
|
|
|
1258
1553
|
free(): void;
|
|
1259
1554
|
[Symbol.dispose](): void;
|
|
1260
1555
|
/**
|
|
1261
|
-
* Compute inertia tensors. Returns flat
|
|
1556
|
+
* Compute inertia tensors. Returns a flat float typed array (9 values per cluster).
|
|
1262
1557
|
*/
|
|
1263
|
-
compute(frame: Frame, cluster_result: ClusterResult):
|
|
1264
|
-
constructor(masses?:
|
|
1558
|
+
compute(frame: Frame, cluster_result: ClusterResult): Float64Array;
|
|
1559
|
+
constructor(masses?: Float64Array | null);
|
|
1265
1560
|
}
|
|
1266
1561
|
|
|
1267
1562
|
/**
|
|
@@ -1308,8 +1603,8 @@ export class LAMMPSDumpReader {
|
|
|
1308
1603
|
* Reads LAMMPS data files (the format written by `write_data`). The
|
|
1309
1604
|
* reader produces a [`Frame`] containing:
|
|
1310
1605
|
*
|
|
1311
|
-
* - `"atoms"` block: `type` (i32), `x`, `y`, `z` (
|
|
1312
|
-
* and optionally `charge` (
|
|
1606
|
+
* - `"atoms"` block: `type` (i32), `x`, `y`, `z` (F, angstrom),
|
|
1607
|
+
* and optionally `charge` (F)
|
|
1313
1608
|
* - `"bonds"` block (if present): `i`, `j` (u32), `type` (i32)
|
|
1314
1609
|
* - Simulation box (`simbox`) with PBC
|
|
1315
1610
|
*
|
|
@@ -1413,7 +1708,7 @@ export class LinkedCell {
|
|
|
1413
1708
|
* Finds all unique pairs `(i < j)` of atoms within the cutoff
|
|
1414
1709
|
* distance using the cell-list algorithm.
|
|
1415
1710
|
*
|
|
1416
|
-
* The frame must have an `"atoms"` block with `x`, `y`, `z` (
|
|
1711
|
+
* The frame must have an `"atoms"` block with `x`, `y`, `z` (F) columns.
|
|
1417
1712
|
* If the frame has a `simbox`, periodic boundary conditions are used.
|
|
1418
1713
|
* Otherwise, a free-boundary bounding box is auto-generated.
|
|
1419
1714
|
*
|
|
@@ -1434,7 +1729,7 @@ export class LinkedCell {
|
|
|
1434
1729
|
* ```js
|
|
1435
1730
|
* const lc = new LinkedCell(3.0);
|
|
1436
1731
|
* const nlist = lc.build(frame);
|
|
1437
|
-
* const dists = nlist.distances(); // Float32Array
|
|
1732
|
+
* const dists = nlist.distances(); // Float32Array or Float64Array
|
|
1438
1733
|
* ```
|
|
1439
1734
|
*/
|
|
1440
1735
|
build(frame: Frame): NeighborList;
|
|
@@ -1518,7 +1813,7 @@ export class MSD {
|
|
|
1518
1813
|
* # Arguments
|
|
1519
1814
|
*
|
|
1520
1815
|
* * `frame` - Frame with `"atoms"` block containing
|
|
1521
|
-
* `x`, `y`, `z` (
|
|
1816
|
+
* `x`, `y`, `z` (F) columns
|
|
1522
1817
|
*
|
|
1523
1818
|
* # Errors
|
|
1524
1819
|
*
|
|
@@ -1579,7 +1874,7 @@ export class MSD {
|
|
|
1579
1874
|
* ```js
|
|
1580
1875
|
* const result = msd.compute(frame);
|
|
1581
1876
|
* console.log(result.mean); // number (A^2)
|
|
1582
|
-
* console.log(result.perParticle()); // Float32Array (A^2)
|
|
1877
|
+
* console.log(result.perParticle()); // Float32Array or Float64Array (A^2)
|
|
1583
1878
|
* ```
|
|
1584
1879
|
*/
|
|
1585
1880
|
export class MSDResult {
|
|
@@ -1587,12 +1882,11 @@ export class MSDResult {
|
|
|
1587
1882
|
free(): void;
|
|
1588
1883
|
[Symbol.dispose](): void;
|
|
1589
1884
|
/**
|
|
1590
|
-
*
|
|
1591
|
-
*
|
|
1592
|
-
*
|
|
1593
|
-
* Length equals the number of atoms.
|
|
1885
|
+
* Zero-copy `Float64Array` view of per-particle squared displacements
|
|
1886
|
+
* in A². `perParticle()[i]` is `|r_i(t) - r_i(0)|²` for particle `i`.
|
|
1887
|
+
* **Invalidated** on WASM memory growth; copy in JS if needed.
|
|
1594
1888
|
*/
|
|
1595
|
-
perParticle():
|
|
1889
|
+
perParticle(): Float64Array;
|
|
1596
1890
|
/**
|
|
1597
1891
|
* System-average mean squared displacement in A^2.
|
|
1598
1892
|
*
|
|
@@ -1602,6 +1896,19 @@ export class MSDResult {
|
|
|
1602
1896
|
readonly mean: number;
|
|
1603
1897
|
}
|
|
1604
1898
|
|
|
1899
|
+
/**
|
|
1900
|
+
* Reader for MolRec Zarr v3 archives.
|
|
1901
|
+
*/
|
|
1902
|
+
export class MolRecReader {
|
|
1903
|
+
free(): void;
|
|
1904
|
+
[Symbol.dispose](): void;
|
|
1905
|
+
countAtoms(): number;
|
|
1906
|
+
countFrames(): number;
|
|
1907
|
+
free(): void;
|
|
1908
|
+
constructor(files: Map<any, any>);
|
|
1909
|
+
readFrame(t: number): Frame | undefined;
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1605
1912
|
/**
|
|
1606
1913
|
* Result of a neighbor search: all atom pairs within a distance cutoff.
|
|
1607
1914
|
*
|
|
@@ -1626,7 +1933,7 @@ export class MSDResult {
|
|
|
1626
1933
|
*
|
|
1627
1934
|
* const i = nlist.queryPointIndices(); // Uint32Array
|
|
1628
1935
|
* const j = nlist.pointIndices(); // Uint32Array
|
|
1629
|
-
* const d = nlist.distances(); // Float32Array (in A)
|
|
1936
|
+
* const d = nlist.distances(); // Float32Array or Float64Array (in A)
|
|
1630
1937
|
* ```
|
|
1631
1938
|
*/
|
|
1632
1939
|
export class NeighborList {
|
|
@@ -1634,28 +1941,26 @@ export class NeighborList {
|
|
|
1634
1941
|
free(): void;
|
|
1635
1942
|
[Symbol.dispose](): void;
|
|
1636
1943
|
/**
|
|
1637
|
-
*
|
|
1638
|
-
*
|
|
1639
|
-
* More efficient than `distances()` when you only need to
|
|
1640
|
-
* compare or threshold distances.
|
|
1944
|
+
* Zero-copy `Float64Array` view of squared pairwise distances in A^2.
|
|
1945
|
+
* Same invalidation caveat as [`queryPointIndices`](Self::query_point_indices).
|
|
1641
1946
|
*/
|
|
1642
|
-
distSq():
|
|
1947
|
+
distSq(): Float64Array;
|
|
1643
1948
|
/**
|
|
1644
|
-
* Pairwise distances in angstrom (A)
|
|
1949
|
+
* Pairwise distances in angstrom (A). Computed lazily from `distSq`.
|
|
1645
1950
|
*
|
|
1646
|
-
*
|
|
1647
|
-
*
|
|
1951
|
+
* Returns an owned copy because distances are derived on the fly
|
|
1952
|
+
* (`sqrt` per pair) rather than stored.
|
|
1648
1953
|
*/
|
|
1649
|
-
distances():
|
|
1954
|
+
distances(): Float64Array;
|
|
1650
1955
|
/**
|
|
1651
|
-
*
|
|
1956
|
+
* Zero-copy `Uint32Array` view of reference point indices (`j`).
|
|
1957
|
+
* Same invalidation caveat as [`queryPointIndices`](Self::query_point_indices).
|
|
1652
1958
|
*/
|
|
1653
1959
|
pointIndices(): Uint32Array;
|
|
1654
1960
|
/**
|
|
1655
|
-
*
|
|
1656
|
-
*
|
|
1657
|
-
*
|
|
1658
|
-
* to reference point `pointIndices()[k]`.
|
|
1961
|
+
* Zero-copy `Uint32Array` view of query point indices (`i`) over
|
|
1962
|
+
* WASM memory. **Invalidated** on any WASM memory growth — copy
|
|
1963
|
+
* in JS (`new Uint32Array(view)`) if it needs to outlive later calls.
|
|
1659
1964
|
*/
|
|
1660
1965
|
queryPointIndices(): Uint32Array;
|
|
1661
1966
|
/**
|
|
@@ -1685,8 +1990,8 @@ export class NeighborList {
|
|
|
1685
1990
|
*
|
|
1686
1991
|
* PDB files contain a single molecular structure. The reader produces
|
|
1687
1992
|
* a [`Frame`] with an `"atoms"` block containing columns such as
|
|
1688
|
-
* `name` (string), `resname` (string), `x`, `y`, `z` (
|
|
1689
|
-
* and optionally `occupancy` and `bfactor` (
|
|
1993
|
+
* `name` (string), `resname` (string), `x`, `y`, `z` (F, angstrom),
|
|
1994
|
+
* and optionally `occupancy` and `bfactor` (F).
|
|
1690
1995
|
*
|
|
1691
1996
|
* # Example (JavaScript)
|
|
1692
1997
|
*
|
|
@@ -1695,7 +2000,7 @@ export class NeighborList {
|
|
|
1695
2000
|
* const frame = reader.read(0);
|
|
1696
2001
|
* const atoms = frame.getBlock("atoms");
|
|
1697
2002
|
* const names = atoms.copyColStr("name"); // ["CA", "CB", ...]
|
|
1698
|
-
* const x = atoms.
|
|
2003
|
+
* const x = atoms.copyColF("x");
|
|
1699
2004
|
* ```
|
|
1700
2005
|
*/
|
|
1701
2006
|
export class PDBReader {
|
|
@@ -1781,8 +2086,8 @@ export class PDBReader {
|
|
|
1781
2086
|
* const rdf = new RDF(100, 5.0);
|
|
1782
2087
|
* const result = rdf.compute(frame, nlist);
|
|
1783
2088
|
*
|
|
1784
|
-
* const r = result.binCenters(); // Float32Array, bin centers in A
|
|
1785
|
-
* const gr = result.rdf(); // Float32Array, g(r) values
|
|
2089
|
+
* const r = result.binCenters(); // Float32Array or Float64Array, bin centers in A
|
|
2090
|
+
* const gr = result.rdf(); // Float32Array or Float64Array, g(r) values
|
|
1786
2091
|
* ```
|
|
1787
2092
|
*/
|
|
1788
2093
|
export class RDF {
|
|
@@ -1812,7 +2117,7 @@ export class RDF {
|
|
|
1812
2117
|
*
|
|
1813
2118
|
* ```js
|
|
1814
2119
|
* const result = rdf.compute(frame, nlist);
|
|
1815
|
-
* const gr = result.rdf(); // Float32Array
|
|
2120
|
+
* const gr = result.rdf(); // Float32Array or Float64Array
|
|
1816
2121
|
* ```
|
|
1817
2122
|
*/
|
|
1818
2123
|
compute(frame: Frame, neighbors: NeighborList): RDFResult;
|
|
@@ -1844,9 +2149,9 @@ export class RDF {
|
|
|
1844
2149
|
*
|
|
1845
2150
|
* ```js
|
|
1846
2151
|
* const result = rdf.compute(frame, nlist);
|
|
1847
|
-
* const r = result.binCenters(); // Float32Array [0.025, 0.075, ...]
|
|
1848
|
-
* const gr = result.rdf(); // Float32Array, normalized g(r)
|
|
1849
|
-
* const nr = result.pairCounts(); // Float32Array, raw counts
|
|
2152
|
+
* const r = result.binCenters(); // Float32Array or Float64Array [0.025, 0.075, ...]
|
|
2153
|
+
* const gr = result.rdf(); // Float32Array or Float64Array, normalized g(r)
|
|
2154
|
+
* const nr = result.pairCounts(); // Float32Array or Float64Array, raw counts
|
|
1850
2155
|
* console.log("Volume:", result.volume, "A^3");
|
|
1851
2156
|
* console.log("N_ref:", result.numPoints);
|
|
1852
2157
|
* ```
|
|
@@ -1856,28 +2161,26 @@ export class RDFResult {
|
|
|
1856
2161
|
free(): void;
|
|
1857
2162
|
[Symbol.dispose](): void;
|
|
1858
2163
|
/**
|
|
1859
|
-
*
|
|
1860
|
-
*
|
|
1861
|
-
*
|
|
2164
|
+
* Zero-copy `Float64Array` view of bin center positions in A.
|
|
2165
|
+
* Length equals `n_bins`. **Invalidated** on WASM memory growth;
|
|
2166
|
+
* copy in JS if it needs to outlive later calls.
|
|
1862
2167
|
*/
|
|
1863
|
-
binCenters():
|
|
2168
|
+
binCenters(): Float64Array;
|
|
1864
2169
|
/**
|
|
1865
|
-
*
|
|
1866
|
-
*
|
|
1867
|
-
* Length is `n_bins + 1` (one more than bin centers).
|
|
2170
|
+
* Zero-copy `Float64Array` view of bin edge positions in A.
|
|
2171
|
+
* Length is `n_bins + 1`. Same invalidation caveat.
|
|
1868
2172
|
*/
|
|
1869
|
-
binEdges():
|
|
2173
|
+
binEdges(): Float64Array;
|
|
1870
2174
|
/**
|
|
1871
|
-
*
|
|
2175
|
+
* Zero-copy `Float64Array` view of raw (un-normalized) pair counts
|
|
2176
|
+
* per bin. Same invalidation caveat.
|
|
1872
2177
|
*/
|
|
1873
|
-
pairCounts():
|
|
2178
|
+
pairCounts(): Float64Array;
|
|
1874
2179
|
/**
|
|
1875
|
-
*
|
|
1876
|
-
*
|
|
1877
|
-
* A uniform ideal gas has g(r) = 1.0 everywhere. Peaks indicate
|
|
1878
|
-
* preferred interatomic distances (coordination shells).
|
|
2180
|
+
* Zero-copy `Float64Array` view of normalized g(r). Same invalidation
|
|
2181
|
+
* caveat.
|
|
1879
2182
|
*/
|
|
1880
|
-
rdf():
|
|
2183
|
+
rdf(): Float64Array;
|
|
1881
2184
|
/**
|
|
1882
2185
|
* Number of reference points used in the normalization.
|
|
1883
2186
|
*/
|
|
@@ -1895,119 +2198,57 @@ export class RadiusOfGyration {
|
|
|
1895
2198
|
free(): void;
|
|
1896
2199
|
[Symbol.dispose](): void;
|
|
1897
2200
|
/**
|
|
1898
|
-
* Compute radii of gyration. Returns
|
|
2201
|
+
* Compute radii of gyration. Returns a float typed array of length `numClusters`.
|
|
1899
2202
|
*/
|
|
1900
|
-
compute(frame: Frame, cluster_result: ClusterResult):
|
|
1901
|
-
constructor(masses?:
|
|
2203
|
+
compute(frame: Frame, cluster_result: ClusterResult): Float64Array;
|
|
2204
|
+
constructor(masses?: Float64Array | null);
|
|
1902
2205
|
}
|
|
1903
2206
|
|
|
1904
2207
|
/**
|
|
1905
|
-
*
|
|
2208
|
+
* MDL molfile / SDF (V2000 CTAB) reader.
|
|
2209
|
+
*
|
|
2210
|
+
* Parses the connection table found in `.mol` files and the record
|
|
2211
|
+
* blocks of `.sdf` files. Coordinates come directly from the file —
|
|
2212
|
+
* no 3D generation is performed. Only V2000 is supported; V3000
|
|
2213
|
+
* records throw on read.
|
|
1906
2214
|
*
|
|
1907
|
-
*
|
|
1908
|
-
*
|
|
1909
|
-
*
|
|
1910
|
-
*
|
|
2215
|
+
* Produces a [`Frame`] with:
|
|
2216
|
+
* - `"atoms"` block: `element` (string), `id` (u32, 1-based),
|
|
2217
|
+
* `x`, `y`, `z` (F, angstrom)
|
|
2218
|
+
* - `"bonds"` block (if present): `atomi`, `atomj` (u32, 0-based),
|
|
2219
|
+
* `order` (u32)
|
|
2220
|
+
*
|
|
2221
|
+
* Multi-record SDF files expose each record as a separate frame via
|
|
2222
|
+
* `read(step)`.
|
|
1911
2223
|
*
|
|
1912
2224
|
* # Example (JavaScript)
|
|
1913
2225
|
*
|
|
1914
2226
|
* ```js
|
|
1915
|
-
* const
|
|
1916
|
-
*
|
|
1917
|
-
*
|
|
1918
|
-
*
|
|
1919
|
-
*
|
|
1920
|
-
* const reader = new SimulationReader(files);
|
|
1921
|
-
* const frame = reader.readFrame(0);
|
|
2227
|
+
* const reader = new SDFReader(sdfContent);
|
|
2228
|
+
* const frame = reader.read(0);
|
|
2229
|
+
* const atoms = frame.getBlock("atoms");
|
|
2230
|
+
* const x = atoms.copyColF("x");
|
|
1922
2231
|
* ```
|
|
1923
2232
|
*/
|
|
1924
|
-
export class
|
|
2233
|
+
export class SDFReader {
|
|
1925
2234
|
free(): void;
|
|
1926
2235
|
[Symbol.dispose](): void;
|
|
1927
2236
|
/**
|
|
1928
|
-
*
|
|
1929
|
-
*
|
|
1930
|
-
* # Example (JavaScript)
|
|
1931
|
-
*
|
|
1932
|
-
* ```js
|
|
1933
|
-
* console.log(reader.countAtoms()); // e.g., 256
|
|
1934
|
-
* ```
|
|
2237
|
+
* Check whether the file contains no records.
|
|
1935
2238
|
*/
|
|
1936
|
-
|
|
2239
|
+
isEmpty(): boolean;
|
|
1937
2240
|
/**
|
|
1938
|
-
* Return the number of
|
|
1939
|
-
*
|
|
1940
|
-
* Returns `0` if no trajectory data is present.
|
|
1941
|
-
*
|
|
1942
|
-
* # Errors
|
|
1943
|
-
*
|
|
1944
|
-
* Throws a `JsValue` string on I/O errors.
|
|
1945
|
-
*
|
|
1946
|
-
* # Example (JavaScript)
|
|
1947
|
-
*
|
|
1948
|
-
* ```js
|
|
1949
|
-
* console.log(reader.countFrames()); // e.g., 1000
|
|
1950
|
-
* ```
|
|
2241
|
+
* Return the total number of records in the SDF file.
|
|
1951
2242
|
*/
|
|
1952
|
-
|
|
2243
|
+
len(): number;
|
|
1953
2244
|
/**
|
|
1954
|
-
* Create a reader from a
|
|
1955
|
-
*
|
|
1956
|
-
* The map keys are relative paths within the Zarr archive
|
|
1957
|
-
* (e.g., `"zarr.json"`, `"system/.zarray"`). Values are the
|
|
1958
|
-
* raw bytes of each file as `Uint8Array`.
|
|
1959
|
-
*
|
|
1960
|
-
* # Arguments
|
|
1961
|
-
*
|
|
1962
|
-
* * `files` - `Map<string, Uint8Array>` mapping archive paths
|
|
1963
|
-
* to their binary content
|
|
1964
|
-
*
|
|
1965
|
-
* # Returns
|
|
1966
|
-
*
|
|
1967
|
-
* A new `SimulationReader` ready to read frames.
|
|
1968
|
-
*
|
|
1969
|
-
* # Errors
|
|
1970
|
-
*
|
|
1971
|
-
* Throws a `JsValue` string if the archive cannot be opened
|
|
1972
|
-
* (e.g., missing required metadata files).
|
|
1973
|
-
*
|
|
1974
|
-
* # Example (JavaScript)
|
|
1975
|
-
*
|
|
1976
|
-
* ```js
|
|
1977
|
-
* const reader = new SimulationReader(filesMap);
|
|
1978
|
-
* ```
|
|
2245
|
+
* Create a new SDF reader from a string containing the file content.
|
|
1979
2246
|
*/
|
|
1980
|
-
constructor(
|
|
2247
|
+
constructor(content: string);
|
|
1981
2248
|
/**
|
|
1982
|
-
* Read
|
|
1983
|
-
*
|
|
1984
|
-
* The returned [`Frame`] merges the static system topology
|
|
1985
|
-
* (atoms, bonds) with the per-frame trajectory data (positions,
|
|
1986
|
-
* velocities, etc.) at time step `t`.
|
|
1987
|
-
*
|
|
1988
|
-
* # Arguments
|
|
1989
|
-
*
|
|
1990
|
-
* * `t` - Zero-based time step index
|
|
1991
|
-
*
|
|
1992
|
-
* # Returns
|
|
1993
|
-
*
|
|
1994
|
-
* A [`Frame`] with merged system + trajectory data, or `undefined`
|
|
1995
|
-
* if no trajectory is present.
|
|
1996
|
-
*
|
|
1997
|
-
* # Errors
|
|
1998
|
-
*
|
|
1999
|
-
* Throws a `JsValue` string on I/O or deserialization errors.
|
|
2000
|
-
*
|
|
2001
|
-
* # Example (JavaScript)
|
|
2002
|
-
*
|
|
2003
|
-
* ```js
|
|
2004
|
-
* const frame = reader.readFrame(0);
|
|
2005
|
-
* if (frame) {
|
|
2006
|
-
* const x = frame.getBlock("atoms").copyColF32("x");
|
|
2007
|
-
* }
|
|
2008
|
-
* ```
|
|
2249
|
+
* Read the frame (SDF record) at the given step index.
|
|
2009
2250
|
*/
|
|
2010
|
-
|
|
2251
|
+
read(step: number): Frame | undefined;
|
|
2011
2252
|
}
|
|
2012
2253
|
|
|
2013
2254
|
/**
|
|
@@ -2028,7 +2269,7 @@ export class SimulationReader {
|
|
|
2028
2269
|
*
|
|
2029
2270
|
* const frame = ir.toFrame();
|
|
2030
2271
|
* const atoms = frame.getBlock("atoms");
|
|
2031
|
-
* console.log(atoms.copyColStr("
|
|
2272
|
+
* console.log(atoms.copyColStr("element")); // ["C", "C", "O", "H", ...]
|
|
2032
2273
|
* ```
|
|
2033
2274
|
*/
|
|
2034
2275
|
export class SmilesIR {
|
|
@@ -2044,7 +2285,7 @@ export class SmilesIR {
|
|
|
2044
2285
|
* are added. No 3D coordinates are present -- use
|
|
2045
2286
|
* [`generate3D`](crate::generate_3d_wasm) to embed coordinates.
|
|
2046
2287
|
* - `"bonds"` block: `i`, `j` (u32, zero-based atom indices),
|
|
2047
|
-
* `order` (
|
|
2288
|
+
* `order` (F, bond order: 1.0 = single, 1.5 = aromatic,
|
|
2048
2289
|
* 2.0 = double, 3.0 = triple).
|
|
2049
2290
|
*
|
|
2050
2291
|
* # Returns
|
|
@@ -2061,7 +2302,7 @@ export class SmilesIR {
|
|
|
2061
2302
|
* ```js
|
|
2062
2303
|
* const frame = ir.toFrame();
|
|
2063
2304
|
* const bonds = frame.getBlock("bonds");
|
|
2064
|
-
* const order = bonds.
|
|
2305
|
+
* const order = bonds.copyColF("order");
|
|
2065
2306
|
* ```
|
|
2066
2307
|
*/
|
|
2067
2308
|
toFrame(): Frame;
|
|
@@ -2239,26 +2480,26 @@ export class TopologyRingInfo {
|
|
|
2239
2480
|
}
|
|
2240
2481
|
|
|
2241
2482
|
/**
|
|
2242
|
-
* Owned
|
|
2483
|
+
* Owned float array with ndarray-compatible shape metadata.
|
|
2243
2484
|
*
|
|
2244
|
-
* Stores a flat `Vec<
|
|
2485
|
+
* Stores a flat `Vec<F>` together with a shape descriptor (e.g.,
|
|
2245
2486
|
* `[N, 3]` for an Nx3 coordinate matrix). Used for passing
|
|
2246
2487
|
* multi-dimensional numeric data across the WASM boundary.
|
|
2247
2488
|
*
|
|
2248
2489
|
* # Memory layout
|
|
2249
2490
|
*
|
|
2250
2491
|
* Data is stored in row-major (C) order, matching ndarray's default
|
|
2251
|
-
* and JavaScript's
|
|
2492
|
+
* and JavaScript's float typed-array convention.
|
|
2252
2493
|
*
|
|
2253
2494
|
* # Example (JavaScript)
|
|
2254
2495
|
*
|
|
2255
2496
|
* ```js
|
|
2256
2497
|
* // Create a 2x3 zero array
|
|
2257
2498
|
* const arr = new WasmArray([2, 3]);
|
|
2258
|
-
* arr.writeFrom(
|
|
2499
|
+
* arr.writeFrom(floatArray);
|
|
2259
2500
|
*
|
|
2260
2501
|
* // Or from existing data
|
|
2261
|
-
* const arr2 = WasmArray.from(
|
|
2502
|
+
* const arr2 = WasmArray.from(floatArray, [1, 3]);
|
|
2262
2503
|
*
|
|
2263
2504
|
* // Get data back
|
|
2264
2505
|
* const copy = arr.toCopy(); // safe owned copy
|
|
@@ -2269,15 +2510,15 @@ export class WasmArray {
|
|
|
2269
2510
|
free(): void;
|
|
2270
2511
|
[Symbol.dispose](): void;
|
|
2271
2512
|
/**
|
|
2272
|
-
* Return the
|
|
2513
|
+
* Return the concrete float dtype string for this build.
|
|
2273
2514
|
*/
|
|
2274
2515
|
dtype(): string;
|
|
2275
2516
|
/**
|
|
2276
|
-
* Create a `WasmArray` from an existing JS
|
|
2517
|
+
* Create a `WasmArray` from an existing JS float typed array.
|
|
2277
2518
|
*
|
|
2278
2519
|
* # Arguments
|
|
2279
2520
|
*
|
|
2280
|
-
* * `data` - Source `Float32Array`
|
|
2521
|
+
* * `data` - Source float typed array (`Float32Array` or `Float64Array`)
|
|
2281
2522
|
* * `shape` - Optional shape. If omitted, defaults to `[data.length]` (1D).
|
|
2282
2523
|
*
|
|
2283
2524
|
* # Returns
|
|
@@ -2291,11 +2532,11 @@ export class WasmArray {
|
|
|
2291
2532
|
* # Example (JavaScript)
|
|
2292
2533
|
*
|
|
2293
2534
|
* ```js
|
|
2294
|
-
* const arr = WasmArray.from(
|
|
2535
|
+
* const arr = WasmArray.from(floatArray, [2, 3]);
|
|
2295
2536
|
* console.log(arr.shape()); // [2, 3]
|
|
2296
2537
|
* ```
|
|
2297
2538
|
*/
|
|
2298
|
-
static from(data:
|
|
2539
|
+
static from(data: Float64Array, shape?: Uint32Array | null): WasmArray;
|
|
2299
2540
|
/**
|
|
2300
2541
|
* Check whether the array contains no elements.
|
|
2301
2542
|
*/
|
|
@@ -2355,13 +2596,13 @@ export class WasmArray {
|
|
|
2355
2596
|
* # Example (JavaScript)
|
|
2356
2597
|
*
|
|
2357
2598
|
* ```js
|
|
2358
|
-
* const arr = WasmArray.from(
|
|
2599
|
+
* const arr = WasmArray.from(floatArray);
|
|
2359
2600
|
* console.log(arr.sum()); // 6.0
|
|
2360
2601
|
* ```
|
|
2361
2602
|
*/
|
|
2362
2603
|
sum(): number;
|
|
2363
2604
|
/**
|
|
2364
|
-
* Create an owned JS
|
|
2605
|
+
* Create an owned JS float typed-array copy of the data.
|
|
2365
2606
|
*
|
|
2366
2607
|
* The returned array is an independent copy that is safe to store
|
|
2367
2608
|
* and use regardless of subsequent WASM memory operations.
|
|
@@ -2372,9 +2613,9 @@ export class WasmArray {
|
|
|
2372
2613
|
* const copy = arr.toCopy(); // safe to keep indefinitely
|
|
2373
2614
|
* ```
|
|
2374
2615
|
*/
|
|
2375
|
-
toCopy():
|
|
2616
|
+
toCopy(): Float64Array;
|
|
2376
2617
|
/**
|
|
2377
|
-
* Zero-copy
|
|
2618
|
+
* Zero-copy float typed-array view over this array's backing storage.
|
|
2378
2619
|
*
|
|
2379
2620
|
* **Warning**: The returned view becomes **invalid** if WASM linear
|
|
2380
2621
|
* memory grows (due to any allocation). Use [`toCopy`](WasmArray::to_copy)
|
|
@@ -2382,7 +2623,8 @@ export class WasmArray {
|
|
|
2382
2623
|
*
|
|
2383
2624
|
* # Safety (internal)
|
|
2384
2625
|
*
|
|
2385
|
-
* Uses
|
|
2626
|
+
* Uses the corresponding JS float typed-array `view` constructor,
|
|
2627
|
+
* which creates an unowned view into
|
|
2386
2628
|
* WASM memory. The view must not outlive the `WasmArray` and must
|
|
2387
2629
|
* not be used after any allocation that could trigger memory growth.
|
|
2388
2630
|
*
|
|
@@ -2393,16 +2635,16 @@ export class WasmArray {
|
|
|
2393
2635
|
* // Do NOT allocate between view creation and use
|
|
2394
2636
|
* ```
|
|
2395
2637
|
*/
|
|
2396
|
-
toTypedArray():
|
|
2638
|
+
toTypedArray(): Float64Array;
|
|
2397
2639
|
/**
|
|
2398
|
-
* Overwrite the array contents from a JS
|
|
2640
|
+
* Overwrite the array contents from a JS float typed array.
|
|
2399
2641
|
*
|
|
2400
2642
|
* The source array must have exactly the same number of elements
|
|
2401
2643
|
* as this `WasmArray` (i.e., the shape is preserved).
|
|
2402
2644
|
*
|
|
2403
2645
|
* # Arguments
|
|
2404
2646
|
*
|
|
2405
|
-
* * `arr` - Source
|
|
2647
|
+
* * `arr` - Source float typed array with matching length
|
|
2406
2648
|
*
|
|
2407
2649
|
* # Errors
|
|
2408
2650
|
*
|
|
@@ -2412,10 +2654,10 @@ export class WasmArray {
|
|
|
2412
2654
|
*
|
|
2413
2655
|
* ```js
|
|
2414
2656
|
* const wa = new WasmArray([3]);
|
|
2415
|
-
* wa.writeFrom(
|
|
2657
|
+
* wa.writeFrom(floatArray);
|
|
2416
2658
|
* ```
|
|
2417
2659
|
*/
|
|
2418
|
-
write_from(arr:
|
|
2660
|
+
write_from(arr: Float64Array): void;
|
|
2419
2661
|
}
|
|
2420
2662
|
|
|
2421
2663
|
/**
|
|
@@ -2423,7 +2665,7 @@ export class WasmArray {
|
|
|
2423
2665
|
*
|
|
2424
2666
|
* Supports multi-frame trajectory files. Each frame produces a
|
|
2425
2667
|
* [`Frame`] with an `"atoms"` block containing `element` (string)
|
|
2426
|
-
* and `x`, `y`, `z` (
|
|
2668
|
+
* and `x`, `y`, `z` (F, coordinates in angstrom) columns.
|
|
2427
2669
|
*
|
|
2428
2670
|
* # Example (JavaScript)
|
|
2429
2671
|
*
|
|
@@ -2434,7 +2676,7 @@ export class WasmArray {
|
|
|
2434
2676
|
*
|
|
2435
2677
|
* const frame = reader.read(0); // first frame
|
|
2436
2678
|
* const atoms = frame.getBlock("atoms");
|
|
2437
|
-
* const x = atoms.
|
|
2679
|
+
* const x = atoms.copyColF("x");
|
|
2438
2680
|
* ```
|
|
2439
2681
|
*/
|
|
2440
2682
|
export class XYZReader {
|
|
@@ -2511,13 +2753,13 @@ export class XYZReader {
|
|
|
2511
2753
|
/**
|
|
2512
2754
|
* Generate 3D coordinates for a molecular [`Frame`].
|
|
2513
2755
|
*
|
|
2514
|
-
* The input frame must have an `"atoms"` block with a `"
|
|
2756
|
+
* The input frame must have an `"atoms"` block with a `"element"`
|
|
2515
2757
|
* string column (element symbols like `"C"`, `"N"`, `"O"`). A
|
|
2516
|
-
* `"bonds"` block with `i`, `j` (u32) and `order` (
|
|
2758
|
+
* `"bonds"` block with `i`, `j` (u32) and `order` (F) columns
|
|
2517
2759
|
* is required for correct geometry.
|
|
2518
2760
|
*
|
|
2519
2761
|
* Returns a **new** [`Frame`] with 3D coordinates added as `x`, `y`,
|
|
2520
|
-
* `z` (
|
|
2762
|
+
* `z` (F, angstrom) columns in the `"atoms"` block.
|
|
2521
2763
|
*
|
|
2522
2764
|
* # Arguments
|
|
2523
2765
|
*
|
|
@@ -2550,9 +2792,9 @@ export class XYZReader {
|
|
|
2550
2792
|
* const frame3d = generate3D(frame2d, "fast", 42);
|
|
2551
2793
|
*
|
|
2552
2794
|
* const atoms = frame3d.getBlock("atoms");
|
|
2553
|
-
* const x = atoms.
|
|
2554
|
-
* const y = atoms.
|
|
2555
|
-
* const z = atoms.
|
|
2795
|
+
* const x = atoms.copyColF("x"); // Float32Array or Float64Array with 3D x-coords
|
|
2796
|
+
* const y = atoms.copyColF("y");
|
|
2797
|
+
* const z = atoms.copyColF("z");
|
|
2556
2798
|
* ```
|
|
2557
2799
|
*/
|
|
2558
2800
|
export function generate3D(frame: Frame, speed?: string | null, seed?: number | null): Frame;
|
|
@@ -2604,7 +2846,7 @@ export function start(): void;
|
|
|
2604
2846
|
*
|
|
2605
2847
|
* ```js
|
|
2606
2848
|
* const mem = wasmMemory();
|
|
2607
|
-
* const buf = new
|
|
2849
|
+
* const buf = new Float64Array(mem.buffer, ptr, len); // or Float32Array in default builds
|
|
2608
2850
|
* ```
|
|
2609
2851
|
*/
|
|
2610
2852
|
export function wasmMemory(): WebAssembly.Memory;
|