@molcrafts/molrs 0.0.7 → 0.0.12
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 +729 -285
- package/molrs.js +2 -2
- package/molrs_bg.js +1179 -408
- package/molrs_bg.wasm +0 -0
- package/package.json +1 -1
package/molrs_bg.js
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* Column-oriented data store with typed arrays.
|
|
3
3
|
*
|
|
4
4
|
* Each column is identified by a string key and has a fixed data type
|
|
5
|
-
* (`
|
|
5
|
+
* (`F`, `i32`, `u32`, `string`). All columns in a block must have
|
|
6
6
|
* the same number of rows.
|
|
7
7
|
*
|
|
8
8
|
* # Supported column types
|
|
9
9
|
*
|
|
10
10
|
* | JS type | Rust type | dtype string | Setter | Getter (copy) | Getter (view) |
|
|
11
11
|
* |---------|-----------|-------------|--------|---------------|---------------|
|
|
12
|
-
* | `Float32Array` | `
|
|
12
|
+
* | `Float32Array` / `Float64Array` | `F` | `"f32"` / `"f64"` | `setColF` | `copyColF` | `viewColF` |
|
|
13
13
|
* | `Int32Array` | `i32` | `"i32"` | `setColI32` | `copyColI32` | `viewColI32` |
|
|
14
14
|
* | `Uint32Array` | `u32` | `"u32"` | `setColU32` | `copyColU32` | `viewColU32` |
|
|
15
15
|
* | `string[]` | `String` | `"string"` | `setColStr` | `copyColStr` | -- |
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
*
|
|
19
19
|
* ```js
|
|
20
20
|
* const block = new Block();
|
|
21
|
-
* block.
|
|
22
|
-
* block.
|
|
21
|
+
* block.setColF("x", coordsX);
|
|
22
|
+
* block.setColF("y", coordsY);
|
|
23
23
|
* console.log(block.nrows()); // 3
|
|
24
24
|
* console.log(block.keys()); // ["x", "y"]
|
|
25
25
|
*
|
|
26
|
-
* const x = block.
|
|
26
|
+
* const x = block.copyColF("x"); // owned copy, safe to keep
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
export class Block {
|
|
@@ -45,9 +45,9 @@ export class Block {
|
|
|
45
45
|
wasm.__wbg_block_free(ptr, 0);
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* Owned
|
|
48
|
+
* Owned JS float typed-array copy of a column.
|
|
49
49
|
*
|
|
50
|
-
* Returns a new JS
|
|
50
|
+
* Returns a new JS float typed array that is an independent copy of
|
|
51
51
|
* the column data. Safe to store and use across allocations.
|
|
52
52
|
*
|
|
53
53
|
* # Arguments
|
|
@@ -56,25 +56,25 @@ export class Block {
|
|
|
56
56
|
*
|
|
57
57
|
* # Returns
|
|
58
58
|
*
|
|
59
|
-
* An owned
|
|
59
|
+
* An owned JS float typed-array copy of the column.
|
|
60
60
|
*
|
|
61
61
|
* # Errors
|
|
62
62
|
*
|
|
63
|
-
* Throws if the column does not exist or is not of type
|
|
63
|
+
* Throws if the column does not exist or is not of the active float type.
|
|
64
64
|
*
|
|
65
65
|
* # Example (JavaScript)
|
|
66
66
|
*
|
|
67
67
|
* ```js
|
|
68
|
-
* const x = block.
|
|
68
|
+
* const x = block.copyColF("x");
|
|
69
69
|
* console.log(x[0]); // 1.0
|
|
70
70
|
* ```
|
|
71
71
|
* @param {string} key
|
|
72
|
-
* @returns {
|
|
72
|
+
* @returns {Float64Array}
|
|
73
73
|
*/
|
|
74
|
-
|
|
74
|
+
copyColF(key) {
|
|
75
75
|
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
76
76
|
const len0 = WASM_VECTOR_LEN;
|
|
77
|
-
const ret = wasm.
|
|
77
|
+
const ret = wasm.block_copyColF(this.__wbg_ptr, ptr0, len0);
|
|
78
78
|
if (ret[2]) {
|
|
79
79
|
throw takeFromExternrefTable0(ret[1]);
|
|
80
80
|
}
|
|
@@ -172,7 +172,8 @@ export class Block {
|
|
|
172
172
|
/**
|
|
173
173
|
* Return the data type string for a column.
|
|
174
174
|
*
|
|
175
|
-
* Possible return values: `"f32"
|
|
175
|
+
* Possible return values: `"f32"` or `"f64"` for float columns,
|
|
176
|
+
* plus `"i32"`, `"u32"`, `"bool"`,
|
|
176
177
|
* `"string"`, `"u8"`. Returns `undefined` if the column does
|
|
177
178
|
* not exist.
|
|
178
179
|
*
|
|
@@ -187,7 +188,7 @@ export class Block {
|
|
|
187
188
|
* # Example (JavaScript)
|
|
188
189
|
*
|
|
189
190
|
* ```js
|
|
190
|
-
* console.log(block.dtype("x")); // "f32"
|
|
191
|
+
* console.log(block.dtype("x")); // "f32" or "f64"
|
|
191
192
|
* console.log(block.dtype("symbol")); // "string"
|
|
192
193
|
* ```
|
|
193
194
|
* @param {string} key
|
|
@@ -282,7 +283,7 @@ export class Block {
|
|
|
282
283
|
*
|
|
283
284
|
* ```js
|
|
284
285
|
* const block = new Block();
|
|
285
|
-
* block.
|
|
286
|
+
* block.setColF("values", values);
|
|
286
287
|
* ```
|
|
287
288
|
*/
|
|
288
289
|
constructor() {
|
|
@@ -354,12 +355,12 @@ export class Block {
|
|
|
354
355
|
return ret[0] !== 0;
|
|
355
356
|
}
|
|
356
357
|
/**
|
|
357
|
-
* Set a float column from a
|
|
358
|
+
* Set a float column from a JS float typed array.
|
|
358
359
|
*
|
|
359
360
|
* # Arguments
|
|
360
361
|
*
|
|
361
362
|
* * `key` - Column name (e.g., `"x"`, `"mass"`, `"charge"`)
|
|
362
|
-
* * `data` -
|
|
363
|
+
* * `data` - JS float typed array with the column values
|
|
363
364
|
* * `shape` - Optional shape array for multi-dimensional data
|
|
364
365
|
* (e.g., `[N, 3]` for an Nx3 matrix stored flat). If omitted,
|
|
365
366
|
* the data is stored as a 1D column.
|
|
@@ -372,20 +373,20 @@ export class Block {
|
|
|
372
373
|
* # Example (JavaScript)
|
|
373
374
|
*
|
|
374
375
|
* ```js
|
|
375
|
-
* block.
|
|
376
|
+
* block.setColF("x", xCoords);
|
|
376
377
|
* // Multi-dimensional: 2 rows x 3 columns
|
|
377
|
-
* block.
|
|
378
|
+
* block.setColF("pos", positions, [2, 3]);
|
|
378
379
|
* ```
|
|
379
380
|
* @param {string} key
|
|
380
|
-
* @param {
|
|
381
|
+
* @param {Float64Array} data
|
|
381
382
|
* @param {Uint32Array | null} [shape]
|
|
382
383
|
*/
|
|
383
|
-
|
|
384
|
+
setColF(key, data, shape) {
|
|
384
385
|
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
385
386
|
const len0 = WASM_VECTOR_LEN;
|
|
386
387
|
var ptr1 = isLikeNone(shape) ? 0 : passArray32ToWasm0(shape, wasm.__wbindgen_malloc_command_export);
|
|
387
388
|
var len1 = WASM_VECTOR_LEN;
|
|
388
|
-
const ret = wasm.
|
|
389
|
+
const ret = wasm.block_setColF(this.__wbg_ptr, ptr0, len0, data, ptr1, len1);
|
|
389
390
|
if (ret[1]) {
|
|
390
391
|
throw takeFromExternrefTable0(ret[0]);
|
|
391
392
|
}
|
|
@@ -478,13 +479,13 @@ export class Block {
|
|
|
478
479
|
}
|
|
479
480
|
}
|
|
480
481
|
/**
|
|
481
|
-
* Zero-copy
|
|
482
|
+
* Zero-copy JS float typed-array view into WASM linear memory.
|
|
482
483
|
*
|
|
483
484
|
* Returns a view backed directly by the block's storage in WASM
|
|
484
485
|
* memory. This avoids copying but the view becomes **invalid**
|
|
485
486
|
* if WASM linear memory grows (due to any allocation).
|
|
486
487
|
*
|
|
487
|
-
* Use [`
|
|
488
|
+
* Use [`copyColF`](Block::copy_col_f) for a safe, long-lived copy.
|
|
488
489
|
*
|
|
489
490
|
* # Arguments
|
|
490
491
|
*
|
|
@@ -492,25 +493,25 @@ export class Block {
|
|
|
492
493
|
*
|
|
493
494
|
* # Returns
|
|
494
495
|
*
|
|
495
|
-
* A
|
|
496
|
+
* A JS float typed-array view into WASM memory.
|
|
496
497
|
*
|
|
497
498
|
* # Errors
|
|
498
499
|
*
|
|
499
|
-
* Throws if the column does not exist or is not of type
|
|
500
|
+
* Throws if the column does not exist or is not of the active float type.
|
|
500
501
|
*
|
|
501
502
|
* # Example (JavaScript)
|
|
502
503
|
*
|
|
503
504
|
* ```js
|
|
504
|
-
* const view = block.
|
|
505
|
-
* const copy = block.
|
|
505
|
+
* const view = block.viewColF("x"); // zero-copy, use immediately
|
|
506
|
+
* const copy = block.copyColF("x"); // safe to keep
|
|
506
507
|
* ```
|
|
507
508
|
* @param {string} key
|
|
508
|
-
* @returns {
|
|
509
|
+
* @returns {Float64Array}
|
|
509
510
|
*/
|
|
510
|
-
|
|
511
|
+
viewColF(key) {
|
|
511
512
|
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
512
513
|
const len0 = WASM_VECTOR_LEN;
|
|
513
|
-
const ret = wasm.
|
|
514
|
+
const ret = wasm.block_viewColF(this.__wbg_ptr, ptr0, len0);
|
|
514
515
|
if (ret[2]) {
|
|
515
516
|
throw takeFromExternrefTable0(ret[1]);
|
|
516
517
|
}
|
|
@@ -594,8 +595,8 @@ if (Symbol.dispose) Block.prototype[Symbol.dispose] = Block.prototype.free;
|
|
|
594
595
|
* # Example (JavaScript)
|
|
595
596
|
*
|
|
596
597
|
* ```js
|
|
597
|
-
* const h =
|
|
598
|
-
* const origin =
|
|
598
|
+
* const h = floatArrayH;
|
|
599
|
+
* const origin = floatArrayOrigin;
|
|
599
600
|
* const box = new Box(h, origin, true, true, true);
|
|
600
601
|
* console.log(box.volume()); // 1000.0
|
|
601
602
|
* console.log(box.lengths().toCopy()); // [10, 10, 10]
|
|
@@ -625,7 +626,7 @@ export class Box {
|
|
|
625
626
|
* # Arguments
|
|
626
627
|
*
|
|
627
628
|
* * `a` - Side length of the cube in angstrom (A)
|
|
628
|
-
* * `origin` - 3D origin vector as
|
|
629
|
+
* * `origin` - 3D origin vector as a float typed array with 3 elements
|
|
629
630
|
* `[x, y, z]` in angstrom
|
|
630
631
|
* * `pbc_x` - Enable periodic boundary in x direction
|
|
631
632
|
* * `pbc_y` - Enable periodic boundary in y direction
|
|
@@ -642,12 +643,12 @@ export class Box {
|
|
|
642
643
|
* # Example (JavaScript)
|
|
643
644
|
*
|
|
644
645
|
* ```js
|
|
645
|
-
* const origin =
|
|
646
|
+
* const origin = originVec;
|
|
646
647
|
* const box = Box.cube(10.0, origin, true, true, true);
|
|
647
648
|
* console.log(box.volume()); // 1000.0
|
|
648
649
|
* ```
|
|
649
650
|
* @param {number} a
|
|
650
|
-
* @param {
|
|
651
|
+
* @param {Float64Array} origin
|
|
651
652
|
* @param {boolean} pbc_x
|
|
652
653
|
* @param {boolean} pbc_y
|
|
653
654
|
* @param {boolean} pbc_z
|
|
@@ -688,8 +689,8 @@ export class Box {
|
|
|
688
689
|
* # Example (JavaScript)
|
|
689
690
|
*
|
|
690
691
|
* ```js
|
|
691
|
-
* const a = WasmArray.from(
|
|
692
|
-
* const b = WasmArray.from(
|
|
692
|
+
* const a = WasmArray.from(aCoords, [1, 3]);
|
|
693
|
+
* const b = WasmArray.from(bCoords, [1, 3]);
|
|
693
694
|
* const d = box.delta(a, b, true); // minimum-image displacement
|
|
694
695
|
* ```
|
|
695
696
|
* @param {WasmArray} a
|
|
@@ -718,7 +719,7 @@ export class Box {
|
|
|
718
719
|
* * `b` - `WasmArray` with shape `[N, 3]` (target positions in A)
|
|
719
720
|
* * `minimum_image` - If `true`, apply minimum image convention
|
|
720
721
|
* * `out_block` - Target [`Block`] to write the result into
|
|
721
|
-
* * `out_key` - Column name for the result (
|
|
722
|
+
* * `out_key` - Column name for the result (float, shape `[N, 3]`)
|
|
722
723
|
*
|
|
723
724
|
* # Errors
|
|
724
725
|
*
|
|
@@ -779,7 +780,7 @@ export class Box {
|
|
|
779
780
|
* # Example (JavaScript)
|
|
780
781
|
*
|
|
781
782
|
* ```js
|
|
782
|
-
* const L = box.lengths().toCopy(); // Float32Array [10, 10, 10]
|
|
783
|
+
* const L = box.lengths().toCopy(); // Float32Array or Float64Array [10, 10, 10]
|
|
783
784
|
* ```
|
|
784
785
|
* @returns {WasmArray}
|
|
785
786
|
*/
|
|
@@ -792,10 +793,10 @@ export class Box {
|
|
|
792
793
|
*
|
|
793
794
|
* # Arguments
|
|
794
795
|
*
|
|
795
|
-
* * `h` - 3x3 cell matrix as
|
|
796
|
+
* * `h` - 3x3 cell matrix as a float typed array with 9 elements in
|
|
796
797
|
* row-major order: `[h00, h01, h02, h10, h11, h12, h20, h21, h22]`.
|
|
797
798
|
* All values in angstrom (A).
|
|
798
|
-
* * `origin` - 3D origin vector as
|
|
799
|
+
* * `origin` - 3D origin vector as a float typed array with 3 elements
|
|
799
800
|
* `[x, y, z]` in angstrom.
|
|
800
801
|
* * `pbc_x` - Enable periodic boundary in x direction
|
|
801
802
|
* * `pbc_y` - Enable periodic boundary in y direction
|
|
@@ -814,12 +815,12 @@ export class Box {
|
|
|
814
815
|
*
|
|
815
816
|
* ```js
|
|
816
817
|
* // Triclinic box
|
|
817
|
-
* const h =
|
|
818
|
-
* const origin =
|
|
818
|
+
* const h = hMatrix;
|
|
819
|
+
* const origin = originVec;
|
|
819
820
|
* const box = new Box(h, origin, true, true, true);
|
|
820
821
|
* ```
|
|
821
|
-
* @param {
|
|
822
|
-
* @param {
|
|
822
|
+
* @param {Float64Array} h
|
|
823
|
+
* @param {Float64Array} origin
|
|
823
824
|
* @param {boolean} pbc_x
|
|
824
825
|
* @param {boolean} pbc_y
|
|
825
826
|
* @param {boolean} pbc_z
|
|
@@ -845,7 +846,7 @@ export class Box {
|
|
|
845
846
|
* # Example (JavaScript)
|
|
846
847
|
*
|
|
847
848
|
* ```js
|
|
848
|
-
* const o = box.origin().toCopy(); // Float32Array [0, 0, 0]
|
|
849
|
+
* const o = box.origin().toCopy(); // Float32Array or Float64Array [0, 0, 0]
|
|
849
850
|
* ```
|
|
850
851
|
* @returns {WasmArray}
|
|
851
852
|
*/
|
|
@@ -858,9 +859,9 @@ export class Box {
|
|
|
858
859
|
*
|
|
859
860
|
* # Arguments
|
|
860
861
|
*
|
|
861
|
-
* * `lengths` - Box dimensions as
|
|
862
|
+
* * `lengths` - Box dimensions as a float typed array with 3 elements
|
|
862
863
|
* `[lx, ly, lz]` in angstrom (A)
|
|
863
|
-
* * `origin` - 3D origin vector as
|
|
864
|
+
* * `origin` - 3D origin vector as a float typed array with 3 elements
|
|
864
865
|
* `[x, y, z]` in angstrom
|
|
865
866
|
* * `pbc_x` - Enable periodic boundary in x direction
|
|
866
867
|
* * `pbc_y` - Enable periodic boundary in y direction
|
|
@@ -877,12 +878,12 @@ export class Box {
|
|
|
877
878
|
* # Example (JavaScript)
|
|
878
879
|
*
|
|
879
880
|
* ```js
|
|
880
|
-
* const origin =
|
|
881
|
-
* const box = Box.ortho(
|
|
881
|
+
* const origin = originVec;
|
|
882
|
+
* const box = Box.ortho(lengthsVec, origin, true, true, true);
|
|
882
883
|
* console.log(box.volume()); // 6000.0
|
|
883
884
|
* ```
|
|
884
|
-
* @param {
|
|
885
|
-
* @param {
|
|
885
|
+
* @param {Float64Array} lengths
|
|
886
|
+
* @param {Float64Array} origin
|
|
886
887
|
* @param {boolean} pbc_x
|
|
887
888
|
* @param {boolean} pbc_y
|
|
888
889
|
* @param {boolean} pbc_z
|
|
@@ -910,7 +911,7 @@ export class Box {
|
|
|
910
911
|
* # Example (JavaScript)
|
|
911
912
|
*
|
|
912
913
|
* ```js
|
|
913
|
-
* const t = box.tilts().toCopy(); // Float32Array [0, 0, 0]
|
|
914
|
+
* const t = box.tilts().toCopy(); // Float32Array or Float64Array [0, 0, 0]
|
|
914
915
|
* ```
|
|
915
916
|
* @returns {WasmArray}
|
|
916
917
|
*/
|
|
@@ -926,7 +927,7 @@ export class Box {
|
|
|
926
927
|
*
|
|
927
928
|
* * `coords` - `WasmArray` with shape `[N, 3]` (fractional, dimensionless)
|
|
928
929
|
* * `out_block` - Target [`Block`]
|
|
929
|
-
* * `out_key` - Column name for the result (
|
|
930
|
+
* * `out_key` - Column name for the result (float, shape `[N, 3]`)
|
|
930
931
|
*
|
|
931
932
|
* # Errors
|
|
932
933
|
*
|
|
@@ -959,7 +960,7 @@ export class Box {
|
|
|
959
960
|
*
|
|
960
961
|
* * `coords` - `WasmArray` with shape `[N, 3]` (Cartesian, A)
|
|
961
962
|
* * `out_block` - Target [`Block`]
|
|
962
|
-
* * `out_key` - Column name for the result (
|
|
963
|
+
* * `out_key` - Column name for the result (float, shape `[N, 3]`)
|
|
963
964
|
*
|
|
964
965
|
* # Errors
|
|
965
966
|
*
|
|
@@ -1004,7 +1005,7 @@ export class Box {
|
|
|
1004
1005
|
* # Example (JavaScript)
|
|
1005
1006
|
*
|
|
1006
1007
|
* ```js
|
|
1007
|
-
* const frac = WasmArray.from(
|
|
1008
|
+
* const frac = WasmArray.from(fracCoords, [1, 3]);
|
|
1008
1009
|
* const cart = box.toCart(frac);
|
|
1009
1010
|
* console.log(cart.toCopy()); // [5, 5, 5] for a 10x10x10 box
|
|
1010
1011
|
* ```
|
|
@@ -1042,7 +1043,7 @@ export class Box {
|
|
|
1042
1043
|
* # Example (JavaScript)
|
|
1043
1044
|
*
|
|
1044
1045
|
* ```js
|
|
1045
|
-
* const cart = WasmArray.from(
|
|
1046
|
+
* const cart = WasmArray.from(coords, [1, 3]);
|
|
1046
1047
|
* const frac = box.toFrac(cart);
|
|
1047
1048
|
* console.log(frac.toCopy()); // [0.5, 0.5, 0.5] for a 10x10x10 box
|
|
1048
1049
|
* ```
|
|
@@ -1095,7 +1096,7 @@ export class Box {
|
|
|
1095
1096
|
* # Example (JavaScript)
|
|
1096
1097
|
*
|
|
1097
1098
|
* ```js
|
|
1098
|
-
* const pos = WasmArray.from(
|
|
1099
|
+
* const pos = WasmArray.from(positions, [1, 3]);
|
|
1099
1100
|
* const wrapped = box.wrap(pos); // wraps into [0, lx) x [0, ly) x [0, lz)
|
|
1100
1101
|
* ```
|
|
1101
1102
|
* @param {WasmArray} coords
|
|
@@ -1120,7 +1121,7 @@ export class Box {
|
|
|
1120
1121
|
* * `coords` - `WasmArray` with shape `[N, 3]` containing
|
|
1121
1122
|
* Cartesian coordinates in angstrom (A)
|
|
1122
1123
|
* * `out_block` - Target [`Block`] to write the result into
|
|
1123
|
-
* * `out_key` - Column name for the result (
|
|
1124
|
+
* * `out_key` - Column name for the result (float, shape `[N, 3]`)
|
|
1124
1125
|
*
|
|
1125
1126
|
* # Errors
|
|
1126
1127
|
*
|
|
@@ -1181,11 +1182,11 @@ export class CenterOfMass {
|
|
|
1181
1182
|
/**
|
|
1182
1183
|
* Create a center-of-mass calculator.
|
|
1183
1184
|
*
|
|
1184
|
-
* Pass `null` for uniform masses, or a
|
|
1185
|
-
* @param {
|
|
1185
|
+
* Pass `null` for uniform masses, or a float typed array of per-particle masses.
|
|
1186
|
+
* @param {Float64Array | null} [masses]
|
|
1186
1187
|
*/
|
|
1187
1188
|
constructor(masses) {
|
|
1188
|
-
var ptr0 = isLikeNone(masses) ? 0 :
|
|
1189
|
+
var ptr0 = isLikeNone(masses) ? 0 : passArrayF64ToWasm0(masses, wasm.__wbindgen_malloc_command_export);
|
|
1189
1190
|
var len0 = WASM_VECTOR_LEN;
|
|
1190
1191
|
const ret = wasm.centerofmass_new(ptr0, len0);
|
|
1191
1192
|
this.__wbg_ptr = ret >>> 0;
|
|
@@ -1202,8 +1203,8 @@ if (Symbol.dispose) CenterOfMass.prototype[Symbol.dispose] = CenterOfMass.protot
|
|
|
1202
1203
|
*
|
|
1203
1204
|
* ```js
|
|
1204
1205
|
* const com = new CenterOfMass().compute(frame, clusterResult);
|
|
1205
|
-
* com.centersOfMass(); // Float32Array [x0,y0,z0, ...]
|
|
1206
|
-
* com.clusterMasses(); // Float32Array
|
|
1206
|
+
* com.centersOfMass(); // Float32Array or Float64Array [x0,y0,z0, ...]
|
|
1207
|
+
* com.clusterMasses(); // Float32Array or Float64Array
|
|
1207
1208
|
* ```
|
|
1208
1209
|
*/
|
|
1209
1210
|
export class CenterOfMassResult {
|
|
@@ -1225,24 +1226,22 @@ export class CenterOfMassResult {
|
|
|
1225
1226
|
wasm.__wbg_centerofmassresult_free(ptr, 0);
|
|
1226
1227
|
}
|
|
1227
1228
|
/**
|
|
1228
|
-
*
|
|
1229
|
-
*
|
|
1229
|
+
* Zero-copy `Float64Array` view of mass-weighted centers, flat
|
|
1230
|
+
* `[x0,y0,z0, x1,y1,z1, ...]`. **Invalidated** on WASM memory growth.
|
|
1231
|
+
* @returns {Float64Array}
|
|
1230
1232
|
*/
|
|
1231
1233
|
centersOfMass() {
|
|
1232
1234
|
const ret = wasm.centerofmassresult_centersOfMass(this.__wbg_ptr);
|
|
1233
|
-
|
|
1234
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
1235
|
-
return v1;
|
|
1235
|
+
return ret;
|
|
1236
1236
|
}
|
|
1237
1237
|
/**
|
|
1238
|
-
*
|
|
1239
|
-
*
|
|
1238
|
+
* Zero-copy `Float64Array` view of total mass per cluster.
|
|
1239
|
+
* **Invalidated** on WASM memory growth.
|
|
1240
|
+
* @returns {Float64Array}
|
|
1240
1241
|
*/
|
|
1241
1242
|
clusterMasses() {
|
|
1242
1243
|
const ret = wasm.centerofmassresult_clusterMasses(this.__wbg_ptr);
|
|
1243
|
-
|
|
1244
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
1245
|
-
return v1;
|
|
1244
|
+
return ret;
|
|
1246
1245
|
}
|
|
1247
1246
|
/**
|
|
1248
1247
|
* Number of clusters.
|
|
@@ -1354,7 +1353,7 @@ if (Symbol.dispose) Cluster.prototype[Symbol.dispose] = Cluster.prototype.free;
|
|
|
1354
1353
|
*
|
|
1355
1354
|
* ```js
|
|
1356
1355
|
* const centers = new ClusterCenters().compute(frame, clusterResult);
|
|
1357
|
-
* // Float32Array [x0,y0,z0, x1,y1,z1, ...]
|
|
1356
|
+
* // Float32Array or Float64Array [x0,y0,z0, x1,y1,z1, ...]
|
|
1358
1357
|
* ```
|
|
1359
1358
|
*/
|
|
1360
1359
|
export class ClusterCenters {
|
|
@@ -1369,10 +1368,10 @@ export class ClusterCenters {
|
|
|
1369
1368
|
wasm.__wbg_clustercenters_free(ptr, 0);
|
|
1370
1369
|
}
|
|
1371
1370
|
/**
|
|
1372
|
-
* Compute geometric centers. Returns flat
|
|
1371
|
+
* Compute geometric centers. Returns a flat float typed array `[x0,y0,z0, ...]`.
|
|
1373
1372
|
* @param {Frame} frame
|
|
1374
1373
|
* @param {ClusterResult} cluster_result
|
|
1375
|
-
* @returns {
|
|
1374
|
+
* @returns {Float64Array}
|
|
1376
1375
|
*/
|
|
1377
1376
|
compute(frame, cluster_result) {
|
|
1378
1377
|
_assertClass(frame, Frame);
|
|
@@ -1381,8 +1380,8 @@ export class ClusterCenters {
|
|
|
1381
1380
|
if (ret[3]) {
|
|
1382
1381
|
throw takeFromExternrefTable0(ret[2]);
|
|
1383
1382
|
}
|
|
1384
|
-
var v1 =
|
|
1385
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] *
|
|
1383
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
1384
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 8, 8);
|
|
1386
1385
|
return v1;
|
|
1387
1386
|
}
|
|
1388
1387
|
constructor() {
|
|
@@ -1480,10 +1479,10 @@ if (Symbol.dispose) ClusterResult.prototype[Symbol.dispose] = ClusterResult.prot
|
|
|
1480
1479
|
* # Conventions
|
|
1481
1480
|
*
|
|
1482
1481
|
* - The `"atoms"` block should contain per-atom properties: `symbol`
|
|
1483
|
-
* (string), `x`/`y`/`z` (
|
|
1484
|
-
* `mass` (
|
|
1482
|
+
* (string), `x`/`y`/`z` (F, coordinates in angstrom), and optionally
|
|
1483
|
+
* `mass` (F, atomic mass units) and `charge` (F, elementary charges).
|
|
1485
1484
|
* - The `"bonds"` block should contain bond topology: `i`/`j` (u32,
|
|
1486
|
-
* zero-based atom indices) and `order` (
|
|
1485
|
+
* zero-based atom indices) and `order` (F, bond order: 1.0 = single,
|
|
1487
1486
|
* 1.5 = aromatic, 2.0 = double, 3.0 = triple).
|
|
1488
1487
|
*
|
|
1489
1488
|
* # Example (JavaScript)
|
|
@@ -1491,7 +1490,7 @@ if (Symbol.dispose) ClusterResult.prototype[Symbol.dispose] = ClusterResult.prot
|
|
|
1491
1490
|
* ```js
|
|
1492
1491
|
* const frame = new Frame();
|
|
1493
1492
|
* const atoms = frame.createBlock("atoms");
|
|
1494
|
-
* atoms.
|
|
1493
|
+
* atoms.setColF("x", xCoords);
|
|
1495
1494
|
* ```
|
|
1496
1495
|
*/
|
|
1497
1496
|
export class Frame {
|
|
@@ -1553,7 +1552,7 @@ export class Frame {
|
|
|
1553
1552
|
*
|
|
1554
1553
|
* ```js
|
|
1555
1554
|
* const atoms = frame.createBlock("atoms");
|
|
1556
|
-
* atoms.
|
|
1555
|
+
* atoms.setColF("x", xCoords);
|
|
1557
1556
|
* ```
|
|
1558
1557
|
* @param {string} key
|
|
1559
1558
|
* @returns {Block}
|
|
@@ -1608,7 +1607,7 @@ export class Frame {
|
|
|
1608
1607
|
* ```js
|
|
1609
1608
|
* const atoms = frame.getBlock("atoms");
|
|
1610
1609
|
* if (atoms) {
|
|
1611
|
-
* const x = atoms.
|
|
1610
|
+
* const x = atoms.copyColF("x");
|
|
1612
1611
|
* }
|
|
1613
1612
|
* ```
|
|
1614
1613
|
* @param {string} key
|
|
@@ -1620,6 +1619,111 @@ export class Frame {
|
|
|
1620
1619
|
const ret = wasm.frame_getBlock(this.__wbg_ptr, ptr0, len0);
|
|
1621
1620
|
return ret === 0 ? undefined : Block.__wrap(ret);
|
|
1622
1621
|
}
|
|
1622
|
+
/**
|
|
1623
|
+
* Retrieve a named grid attached to this frame.
|
|
1624
|
+
*
|
|
1625
|
+
* Returns a cloned [`Grid`] wrapper, or `undefined` if the grid does
|
|
1626
|
+
* not exist. The returned object is independent of the frame — mutations
|
|
1627
|
+
* to it are not reflected in the frame without a subsequent
|
|
1628
|
+
* [`insertGrid`](Frame::insert_grid) call.
|
|
1629
|
+
*
|
|
1630
|
+
* # Arguments
|
|
1631
|
+
*
|
|
1632
|
+
* * `name` — Grid name to retrieve.
|
|
1633
|
+
*
|
|
1634
|
+
* # Example (JavaScript)
|
|
1635
|
+
*
|
|
1636
|
+
* ```js
|
|
1637
|
+
* const g = frame.getGrid("chgcar");
|
|
1638
|
+
* if (g) {
|
|
1639
|
+
* const arr = g.getArray("rho");
|
|
1640
|
+
* }
|
|
1641
|
+
* ```
|
|
1642
|
+
* @param {string} name
|
|
1643
|
+
* @returns {Grid | undefined}
|
|
1644
|
+
*/
|
|
1645
|
+
getGrid(name) {
|
|
1646
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
1647
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1648
|
+
const ret = wasm.frame_getGrid(this.__wbg_ptr, ptr0, len0);
|
|
1649
|
+
if (ret[2]) {
|
|
1650
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1651
|
+
}
|
|
1652
|
+
return ret[0] === 0 ? undefined : Grid.__wrap(ret[0]);
|
|
1653
|
+
}
|
|
1654
|
+
/**
|
|
1655
|
+
* Read a per-frame metadata value as a numeric scalar.
|
|
1656
|
+
*
|
|
1657
|
+
* Returns `Some(v)` if the meta key exists AND its string value parses
|
|
1658
|
+
* as an `f64`. Returns `None` if the key is missing or the value is
|
|
1659
|
+
* non-numeric (e.g., `config="trans"`).
|
|
1660
|
+
*
|
|
1661
|
+
* `frame.meta` is a `HashMap<String, String>`; the ExtXYZ parser stores
|
|
1662
|
+
* all comment-line values as strings. This accessor reads numeric ones
|
|
1663
|
+
* via `str::parse::<f64>`.
|
|
1664
|
+
*
|
|
1665
|
+
* # Arguments
|
|
1666
|
+
*
|
|
1667
|
+
* * `name` — Meta key to look up (e.g., `"energy"`, `"temp"`).
|
|
1668
|
+
*
|
|
1669
|
+
* # Example (JavaScript)
|
|
1670
|
+
*
|
|
1671
|
+
* ```js
|
|
1672
|
+
* const energy = frame.getMetaScalar("energy");
|
|
1673
|
+
* if (energy !== undefined) {
|
|
1674
|
+
* console.log("Energy:", energy);
|
|
1675
|
+
* }
|
|
1676
|
+
* ```
|
|
1677
|
+
* @param {string} name
|
|
1678
|
+
* @returns {number | undefined}
|
|
1679
|
+
*/
|
|
1680
|
+
getMetaScalar(name) {
|
|
1681
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
1682
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1683
|
+
const ret = wasm.frame_getMetaScalar(this.__wbg_ptr, ptr0, len0);
|
|
1684
|
+
return ret[0] === 0 ? undefined : ret[1];
|
|
1685
|
+
}
|
|
1686
|
+
/**
|
|
1687
|
+
* Return the names of all grids attached to this frame.
|
|
1688
|
+
*
|
|
1689
|
+
* # Example (JavaScript)
|
|
1690
|
+
*
|
|
1691
|
+
* ```js
|
|
1692
|
+
* const names = frame.gridNames(); // e.g. ["chgcar", "spin"]
|
|
1693
|
+
* ```
|
|
1694
|
+
* @returns {Array<any>}
|
|
1695
|
+
*/
|
|
1696
|
+
gridNames() {
|
|
1697
|
+
const ret = wasm.frame_gridNames(this.__wbg_ptr);
|
|
1698
|
+
if (ret[2]) {
|
|
1699
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1700
|
+
}
|
|
1701
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1702
|
+
}
|
|
1703
|
+
/**
|
|
1704
|
+
* Returns `true` if a named grid is attached to this frame.
|
|
1705
|
+
*
|
|
1706
|
+
* # Arguments
|
|
1707
|
+
*
|
|
1708
|
+
* * `name` — Grid name to look up.
|
|
1709
|
+
*
|
|
1710
|
+
* # Example (JavaScript)
|
|
1711
|
+
*
|
|
1712
|
+
* ```js
|
|
1713
|
+
* frame.hasGrid("chgcar"); // true or false
|
|
1714
|
+
* ```
|
|
1715
|
+
* @param {string} name
|
|
1716
|
+
* @returns {boolean}
|
|
1717
|
+
*/
|
|
1718
|
+
hasGrid(name) {
|
|
1719
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
1720
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1721
|
+
const ret = wasm.frame_hasGrid(this.__wbg_ptr, ptr0, len0);
|
|
1722
|
+
if (ret[2]) {
|
|
1723
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1724
|
+
}
|
|
1725
|
+
return ret[0] !== 0;
|
|
1726
|
+
}
|
|
1623
1727
|
/**
|
|
1624
1728
|
* Insert a block by deep-copying its data into this frame's store.
|
|
1625
1729
|
*
|
|
@@ -1658,6 +1762,62 @@ export class Frame {
|
|
|
1658
1762
|
throw takeFromExternrefTable0(ret[0]);
|
|
1659
1763
|
}
|
|
1660
1764
|
}
|
|
1765
|
+
/**
|
|
1766
|
+
* Attach a grid to this frame under the given name.
|
|
1767
|
+
*
|
|
1768
|
+
* If a grid with the same name already exists it is replaced. The grid
|
|
1769
|
+
* data is moved into the frame; the JS `Grid` object becomes empty after
|
|
1770
|
+
* this call and should not be reused.
|
|
1771
|
+
*
|
|
1772
|
+
* # Arguments
|
|
1773
|
+
*
|
|
1774
|
+
* * `name` — Name to store the grid under (e.g., `"chgcar"`).
|
|
1775
|
+
* * `grid` — The [`Grid`] to attach.
|
|
1776
|
+
*
|
|
1777
|
+
* # Errors
|
|
1778
|
+
*
|
|
1779
|
+
* Throws a `JsValue` string if the frame has been dropped.
|
|
1780
|
+
*
|
|
1781
|
+
* # Example (JavaScript)
|
|
1782
|
+
*
|
|
1783
|
+
* ```js
|
|
1784
|
+
* const grid = new Grid(10, 10, 10, origin, cell, true, true, true);
|
|
1785
|
+
* grid.insertArray("rho", rhoData);
|
|
1786
|
+
* frame.insertGrid("chgcar", grid);
|
|
1787
|
+
* ```
|
|
1788
|
+
* @param {string} name
|
|
1789
|
+
* @param {Grid} grid
|
|
1790
|
+
*/
|
|
1791
|
+
insertGrid(name, grid) {
|
|
1792
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
1793
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1794
|
+
_assertClass(grid, Grid);
|
|
1795
|
+
var ptr1 = grid.__destroy_into_raw();
|
|
1796
|
+
const ret = wasm.frame_insertGrid(this.__wbg_ptr, ptr0, len0, ptr1);
|
|
1797
|
+
if (ret[1]) {
|
|
1798
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
/**
|
|
1802
|
+
* Return the names of all metadata keys on this frame.
|
|
1803
|
+
*
|
|
1804
|
+
* Includes all keys regardless of whether their values are numeric
|
|
1805
|
+
* or categorical. To filter to numeric keys, iterate and call
|
|
1806
|
+
* [`getMetaScalar`](Self::get_meta_scalar) on each.
|
|
1807
|
+
*
|
|
1808
|
+
* # Example (JavaScript)
|
|
1809
|
+
*
|
|
1810
|
+
* ```js
|
|
1811
|
+
* const names = frame.metaNames(); // e.g. ["energy", "config", "temp"]
|
|
1812
|
+
* ```
|
|
1813
|
+
* @returns {string[]}
|
|
1814
|
+
*/
|
|
1815
|
+
metaNames() {
|
|
1816
|
+
const ret = wasm.frame_metaNames(this.__wbg_ptr);
|
|
1817
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
1818
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
1819
|
+
return v1;
|
|
1820
|
+
}
|
|
1661
1821
|
/**
|
|
1662
1822
|
* Create a new, empty `Frame` with no blocks and no simulation box.
|
|
1663
1823
|
*
|
|
@@ -1700,6 +1860,32 @@ export class Frame {
|
|
|
1700
1860
|
throw takeFromExternrefTable0(ret[0]);
|
|
1701
1861
|
}
|
|
1702
1862
|
}
|
|
1863
|
+
/**
|
|
1864
|
+
* Remove a named grid from this frame.
|
|
1865
|
+
*
|
|
1866
|
+
* # Arguments
|
|
1867
|
+
*
|
|
1868
|
+
* * `name` — Grid name to remove.
|
|
1869
|
+
*
|
|
1870
|
+
* # Errors
|
|
1871
|
+
*
|
|
1872
|
+
* Throws a `JsValue` string if the frame has been dropped.
|
|
1873
|
+
*
|
|
1874
|
+
* # Example (JavaScript)
|
|
1875
|
+
*
|
|
1876
|
+
* ```js
|
|
1877
|
+
* frame.removeGrid("chgcar");
|
|
1878
|
+
* ```
|
|
1879
|
+
* @param {string} name
|
|
1880
|
+
*/
|
|
1881
|
+
removeGrid(name) {
|
|
1882
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
1883
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1884
|
+
const ret = wasm.frame_removeGrid(this.__wbg_ptr, ptr0, len0);
|
|
1885
|
+
if (ret[1]) {
|
|
1886
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1703
1889
|
/**
|
|
1704
1890
|
* Rename a block from `old_key` to `new_key`.
|
|
1705
1891
|
*
|
|
@@ -1778,6 +1964,44 @@ export class Frame {
|
|
|
1778
1964
|
}
|
|
1779
1965
|
return ret[0] !== 0;
|
|
1780
1966
|
}
|
|
1967
|
+
/**
|
|
1968
|
+
* Set a per-frame metadata value.
|
|
1969
|
+
*
|
|
1970
|
+
* Stores `value` as the string backing for `name` on `frame.meta`.
|
|
1971
|
+
* Numeric values are read back via
|
|
1972
|
+
* [`getMetaScalar`](Self::get_meta_scalar) by parsing the string
|
|
1973
|
+
* form. `frame.meta` is the single source of truth for per-frame
|
|
1974
|
+
* scalars — no separate aggregation layer is needed on the JS side.
|
|
1975
|
+
*
|
|
1976
|
+
* # Arguments
|
|
1977
|
+
*
|
|
1978
|
+
* * `name` — Meta key (e.g., `"energy"`, `"temp"`).
|
|
1979
|
+
* * `value` — String value. For numeric labels, the caller is
|
|
1980
|
+
* responsible for converting (e.g., `num.toString()`).
|
|
1981
|
+
*
|
|
1982
|
+
* # Errors
|
|
1983
|
+
*
|
|
1984
|
+
* Throws a `JsValue` string if the frame has been dropped.
|
|
1985
|
+
*
|
|
1986
|
+
* # Example (JavaScript)
|
|
1987
|
+
*
|
|
1988
|
+
* ```js
|
|
1989
|
+
* frame.setMeta("energy", "-3.14");
|
|
1990
|
+
* frame.setMeta("note", "run-42");
|
|
1991
|
+
* ```
|
|
1992
|
+
* @param {string} name
|
|
1993
|
+
* @param {string} value
|
|
1994
|
+
*/
|
|
1995
|
+
setMeta(name, value) {
|
|
1996
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
1997
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1998
|
+
const ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
1999
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2000
|
+
const ret = wasm.frame_setMeta(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
2001
|
+
if (ret[1]) {
|
|
2002
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
1781
2005
|
/**
|
|
1782
2006
|
* Attach or detach a simulation box.
|
|
1783
2007
|
*
|
|
@@ -1795,7 +2019,7 @@ export class Frame {
|
|
|
1795
2019
|
* # Example (JavaScript)
|
|
1796
2020
|
*
|
|
1797
2021
|
* ```js
|
|
1798
|
-
* const origin =
|
|
2022
|
+
* const origin = originVec;
|
|
1799
2023
|
* frame.simbox = Box.cube(10.0, origin, true, true, true);
|
|
1800
2024
|
* ```
|
|
1801
2025
|
* @param {Box | null} [simbox]
|
|
@@ -1836,6 +2060,306 @@ export class Frame {
|
|
|
1836
2060
|
}
|
|
1837
2061
|
if (Symbol.dispose) Frame.prototype[Symbol.dispose] = Frame.prototype.free;
|
|
1838
2062
|
|
|
2063
|
+
/**
|
|
2064
|
+
* A uniform spatial grid storing multiple named scalar arrays.
|
|
2065
|
+
*
|
|
2066
|
+
* All arrays in a `Grid` share the same spatial definition: dimensions
|
|
2067
|
+
* (`[nx, ny, nz]`), Cartesian origin, cell matrix (columns are lattice
|
|
2068
|
+
* vectors, matching VASP/molrs convention), and periodic boundary flags.
|
|
2069
|
+
*
|
|
2070
|
+
* # Example (JavaScript)
|
|
2071
|
+
*
|
|
2072
|
+
* ```js
|
|
2073
|
+
* // Create a 10×10×10 cubic grid
|
|
2074
|
+
* const origin = new Float32Array([0, 0, 0]);
|
|
2075
|
+
* const cell = new Float32Array([
|
|
2076
|
+
* 10, 0, 0, // first column (a vector)
|
|
2077
|
+
* 0,10, 0, // second column (b vector)
|
|
2078
|
+
* 0, 0,10, // third column (c vector)
|
|
2079
|
+
* ]);
|
|
2080
|
+
* const grid = new Grid(10, 10, 10, origin, cell, true, true, true);
|
|
2081
|
+
*
|
|
2082
|
+
* // Insert a density array (must have length = 10*10*10 = 1000)
|
|
2083
|
+
* const rho = new Float32Array(1000).fill(1.0);
|
|
2084
|
+
* grid.insertArray("rho", rho);
|
|
2085
|
+
*
|
|
2086
|
+
* // Retrieve it
|
|
2087
|
+
* const arr = grid.getArray("rho");
|
|
2088
|
+
* console.log(arr.toCopy());
|
|
2089
|
+
* ```
|
|
2090
|
+
*/
|
|
2091
|
+
export class Grid {
|
|
2092
|
+
static __wrap(ptr) {
|
|
2093
|
+
ptr = ptr >>> 0;
|
|
2094
|
+
const obj = Object.create(Grid.prototype);
|
|
2095
|
+
obj.__wbg_ptr = ptr;
|
|
2096
|
+
GridFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
2097
|
+
return obj;
|
|
2098
|
+
}
|
|
2099
|
+
__destroy_into_raw() {
|
|
2100
|
+
const ptr = this.__wbg_ptr;
|
|
2101
|
+
this.__wbg_ptr = 0;
|
|
2102
|
+
GridFinalization.unregister(this);
|
|
2103
|
+
return ptr;
|
|
2104
|
+
}
|
|
2105
|
+
free() {
|
|
2106
|
+
const ptr = this.__destroy_into_raw();
|
|
2107
|
+
wasm.__wbg_grid_free(ptr, 0);
|
|
2108
|
+
}
|
|
2109
|
+
/**
|
|
2110
|
+
* Names of all scalar arrays stored in this grid.
|
|
2111
|
+
*
|
|
2112
|
+
* # Example (JavaScript)
|
|
2113
|
+
*
|
|
2114
|
+
* ```js
|
|
2115
|
+
* const names = grid.arrayNames(); // e.g. ["rho", "spin"]
|
|
2116
|
+
* ```
|
|
2117
|
+
* @returns {Array<any>}
|
|
2118
|
+
*/
|
|
2119
|
+
arrayNames() {
|
|
2120
|
+
const ret = wasm.grid_arrayNames(this.__wbg_ptr);
|
|
2121
|
+
return ret;
|
|
2122
|
+
}
|
|
2123
|
+
/**
|
|
2124
|
+
* Cell matrix in Ångström as a flat array of length 9 in column-major
|
|
2125
|
+
* order (columns are lattice vectors, matching VASP/molrs convention).
|
|
2126
|
+
*
|
|
2127
|
+
* Layout: `[col0_x, col0_y, col0_z, col1_x, col1_y, col1_z, col2_x, col2_y, col2_z]`
|
|
2128
|
+
*
|
|
2129
|
+
* # Example (JavaScript)
|
|
2130
|
+
*
|
|
2131
|
+
* ```js
|
|
2132
|
+
* const c = grid.cell();
|
|
2133
|
+
* const flat = c.toCopy(); // Float32Array of length 9
|
|
2134
|
+
* ```
|
|
2135
|
+
* @returns {WasmArray}
|
|
2136
|
+
*/
|
|
2137
|
+
cell() {
|
|
2138
|
+
const ret = wasm.grid_cell(this.__wbg_ptr);
|
|
2139
|
+
return WasmArray.__wrap(ret);
|
|
2140
|
+
}
|
|
2141
|
+
/**
|
|
2142
|
+
* Grid dimensions `[nx, ny, nz]`.
|
|
2143
|
+
*
|
|
2144
|
+
* # Example (JavaScript)
|
|
2145
|
+
*
|
|
2146
|
+
* ```js
|
|
2147
|
+
* console.log(grid.dim()); // [10, 10, 10]
|
|
2148
|
+
* ```
|
|
2149
|
+
* @returns {Uint32Array}
|
|
2150
|
+
*/
|
|
2151
|
+
dim() {
|
|
2152
|
+
const ret = wasm.grid_dim(this.__wbg_ptr);
|
|
2153
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
2154
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
2155
|
+
return v1;
|
|
2156
|
+
}
|
|
2157
|
+
/**
|
|
2158
|
+
* Retrieve a named scalar array as a zero-copy `Float64Array` view
|
|
2159
|
+
* over the underlying WASM memory. Flat row-major order, length
|
|
2160
|
+
* `nx * ny * nz`. Use [`Grid::dim`] for shape.
|
|
2161
|
+
*
|
|
2162
|
+
* **Warning**: the view is invalidated on any WASM memory growth.
|
|
2163
|
+
* Copy it in JS (`new Float64Array(view)`) if it needs to outlive
|
|
2164
|
+
* subsequent allocations.
|
|
2165
|
+
*
|
|
2166
|
+
* Returns `undefined` if the named array does not exist.
|
|
2167
|
+
*
|
|
2168
|
+
* # Example (JavaScript)
|
|
2169
|
+
*
|
|
2170
|
+
* ```js
|
|
2171
|
+
* const view = grid.getArray("rho"); // zero-copy
|
|
2172
|
+
* const copy = new Float64Array(view); // owned copy if needed
|
|
2173
|
+
* ```
|
|
2174
|
+
* @param {string} name
|
|
2175
|
+
* @returns {Float64Array | undefined}
|
|
2176
|
+
*/
|
|
2177
|
+
getArray(name) {
|
|
2178
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
2179
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2180
|
+
const ret = wasm.grid_getArray(this.__wbg_ptr, ptr0, len0);
|
|
2181
|
+
return ret;
|
|
2182
|
+
}
|
|
2183
|
+
/**
|
|
2184
|
+
* Returns `true` if a named array is present in this grid.
|
|
2185
|
+
*
|
|
2186
|
+
* # Arguments
|
|
2187
|
+
*
|
|
2188
|
+
* * `name` — Array name to look up.
|
|
2189
|
+
*
|
|
2190
|
+
* # Example (JavaScript)
|
|
2191
|
+
*
|
|
2192
|
+
* ```js
|
|
2193
|
+
* grid.hasArray("rho"); // true or false
|
|
2194
|
+
* ```
|
|
2195
|
+
* @param {string} name
|
|
2196
|
+
* @returns {boolean}
|
|
2197
|
+
*/
|
|
2198
|
+
hasArray(name) {
|
|
2199
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
2200
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2201
|
+
const ret = wasm.grid_hasArray(this.__wbg_ptr, ptr0, len0);
|
|
2202
|
+
return ret !== 0;
|
|
2203
|
+
}
|
|
2204
|
+
/**
|
|
2205
|
+
* Insert (or replace) a named scalar array.
|
|
2206
|
+
*
|
|
2207
|
+
* The provided `data` must have exactly `nx * ny * nz` elements in
|
|
2208
|
+
* row-major `(ix, iy, iz)` order.
|
|
2209
|
+
*
|
|
2210
|
+
* # Arguments
|
|
2211
|
+
*
|
|
2212
|
+
* * `name` — Array name.
|
|
2213
|
+
* * `data` — Float32Array with length equal to `grid.total()`.
|
|
2214
|
+
*
|
|
2215
|
+
* # Errors
|
|
2216
|
+
*
|
|
2217
|
+
* Throws if `data.length != nx * ny * nz`.
|
|
2218
|
+
*
|
|
2219
|
+
* # Example (JavaScript)
|
|
2220
|
+
*
|
|
2221
|
+
* ```js
|
|
2222
|
+
* const rho = new Float32Array(grid.total()).fill(0.5);
|
|
2223
|
+
* grid.insertArray("rho", rho);
|
|
2224
|
+
* ```
|
|
2225
|
+
* @param {string} name
|
|
2226
|
+
* @param {Float64Array} data
|
|
2227
|
+
*/
|
|
2228
|
+
insertArray(name, data) {
|
|
2229
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
2230
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2231
|
+
const ptr1 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc_command_export);
|
|
2232
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2233
|
+
const ret = wasm.grid_insertArray(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
2234
|
+
if (ret[1]) {
|
|
2235
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
/**
|
|
2239
|
+
* Returns `true` if no arrays are stored.
|
|
2240
|
+
*
|
|
2241
|
+
* # Example (JavaScript)
|
|
2242
|
+
*
|
|
2243
|
+
* ```js
|
|
2244
|
+
* console.log(grid.isEmpty()); // true for a freshly created grid
|
|
2245
|
+
* ```
|
|
2246
|
+
* @returns {boolean}
|
|
2247
|
+
*/
|
|
2248
|
+
isEmpty() {
|
|
2249
|
+
const ret = wasm.grid_isEmpty(this.__wbg_ptr);
|
|
2250
|
+
return ret !== 0;
|
|
2251
|
+
}
|
|
2252
|
+
/**
|
|
2253
|
+
* Number of named arrays stored in this grid.
|
|
2254
|
+
*
|
|
2255
|
+
* # Example (JavaScript)
|
|
2256
|
+
*
|
|
2257
|
+
* ```js
|
|
2258
|
+
* console.log(grid.len()); // e.g. 2
|
|
2259
|
+
* ```
|
|
2260
|
+
* @returns {number}
|
|
2261
|
+
*/
|
|
2262
|
+
len() {
|
|
2263
|
+
const ret = wasm.grid_len(this.__wbg_ptr);
|
|
2264
|
+
return ret >>> 0;
|
|
2265
|
+
}
|
|
2266
|
+
/**
|
|
2267
|
+
* Create a new empty grid with the given spatial definition.
|
|
2268
|
+
*
|
|
2269
|
+
* # Arguments
|
|
2270
|
+
*
|
|
2271
|
+
* * `dim_x`, `dim_y`, `dim_z` — Number of grid points along each axis.
|
|
2272
|
+
* * `origin` — Float32Array of length 3: Cartesian origin in Ångström.
|
|
2273
|
+
* * `cell` — Float32Array of length 9: cell matrix in column-major order.
|
|
2274
|
+
* `cell[0..3]` is the first lattice vector (a), `cell[3..6]` is b,
|
|
2275
|
+
* `cell[6..9]` is c (matching VASP/molrs convention where columns are
|
|
2276
|
+
* lattice vectors).
|
|
2277
|
+
* * `pbc_x`, `pbc_y`, `pbc_z` — Periodic boundary flags for each axis.
|
|
2278
|
+
*
|
|
2279
|
+
* # Errors
|
|
2280
|
+
*
|
|
2281
|
+
* Throws if `origin` does not have length 3, or `cell` does not have
|
|
2282
|
+
* length 9.
|
|
2283
|
+
*
|
|
2284
|
+
* # Example (JavaScript)
|
|
2285
|
+
*
|
|
2286
|
+
* ```js
|
|
2287
|
+
* const origin = new Float32Array([0, 0, 0]);
|
|
2288
|
+
* const cell = new Float32Array([10,0,0, 0,10,0, 0,0,10]);
|
|
2289
|
+
* const grid = new Grid(10, 10, 10, origin, cell, true, true, true);
|
|
2290
|
+
* ```
|
|
2291
|
+
* @param {number} dim_x
|
|
2292
|
+
* @param {number} dim_y
|
|
2293
|
+
* @param {number} dim_z
|
|
2294
|
+
* @param {Float64Array} origin
|
|
2295
|
+
* @param {Float64Array} cell
|
|
2296
|
+
* @param {boolean} pbc_x
|
|
2297
|
+
* @param {boolean} pbc_y
|
|
2298
|
+
* @param {boolean} pbc_z
|
|
2299
|
+
*/
|
|
2300
|
+
constructor(dim_x, dim_y, dim_z, origin, cell, pbc_x, pbc_y, pbc_z) {
|
|
2301
|
+
const ptr0 = passArrayF64ToWasm0(origin, wasm.__wbindgen_malloc_command_export);
|
|
2302
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2303
|
+
const ptr1 = passArrayF64ToWasm0(cell, wasm.__wbindgen_malloc_command_export);
|
|
2304
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2305
|
+
const ret = wasm.grid_new(dim_x, dim_y, dim_z, ptr0, len0, ptr1, len1, pbc_x, pbc_y, pbc_z);
|
|
2306
|
+
if (ret[2]) {
|
|
2307
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2308
|
+
}
|
|
2309
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
2310
|
+
GridFinalization.register(this, this.__wbg_ptr, this);
|
|
2311
|
+
return this;
|
|
2312
|
+
}
|
|
2313
|
+
/**
|
|
2314
|
+
* Cartesian origin in Ångström as a 1-D array of length 3.
|
|
2315
|
+
*
|
|
2316
|
+
* # Example (JavaScript)
|
|
2317
|
+
*
|
|
2318
|
+
* ```js
|
|
2319
|
+
* const o = grid.origin();
|
|
2320
|
+
* const arr = o.toCopy(); // Float32Array [ox, oy, oz]
|
|
2321
|
+
* ```
|
|
2322
|
+
* @returns {WasmArray}
|
|
2323
|
+
*/
|
|
2324
|
+
origin() {
|
|
2325
|
+
const ret = wasm.grid_origin(this.__wbg_ptr);
|
|
2326
|
+
return WasmArray.__wrap(ret);
|
|
2327
|
+
}
|
|
2328
|
+
/**
|
|
2329
|
+
* Periodic boundary flags as a `Uint8Array`-compatible slice.
|
|
2330
|
+
*
|
|
2331
|
+
* Each element is `1` (periodic) or `0` (not periodic).
|
|
2332
|
+
*
|
|
2333
|
+
* # Example (JavaScript)
|
|
2334
|
+
*
|
|
2335
|
+
* ```js
|
|
2336
|
+
* console.log(grid.pbc()); // [1, 1, 1]
|
|
2337
|
+
* ```
|
|
2338
|
+
* @returns {Uint8Array}
|
|
2339
|
+
*/
|
|
2340
|
+
pbc() {
|
|
2341
|
+
const ret = wasm.grid_pbc(this.__wbg_ptr);
|
|
2342
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
2343
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 1, 1);
|
|
2344
|
+
return v1;
|
|
2345
|
+
}
|
|
2346
|
+
/**
|
|
2347
|
+
* Total number of voxels: `nx * ny * nz`.
|
|
2348
|
+
*
|
|
2349
|
+
* # Example (JavaScript)
|
|
2350
|
+
*
|
|
2351
|
+
* ```js
|
|
2352
|
+
* console.log(grid.total()); // 1000 for a 10×10×10 grid
|
|
2353
|
+
* ```
|
|
2354
|
+
* @returns {number}
|
|
2355
|
+
*/
|
|
2356
|
+
total() {
|
|
2357
|
+
const ret = wasm.grid_total(this.__wbg_ptr);
|
|
2358
|
+
return ret >>> 0;
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
if (Symbol.dispose) Grid.prototype[Symbol.dispose] = Grid.prototype.free;
|
|
2362
|
+
|
|
1839
2363
|
/**
|
|
1840
2364
|
* Gyration tensor per cluster.
|
|
1841
2365
|
*
|
|
@@ -1853,10 +2377,14 @@ export class GyrationTensor {
|
|
|
1853
2377
|
wasm.__wbg_gyrationtensor_free(ptr, 0);
|
|
1854
2378
|
}
|
|
1855
2379
|
/**
|
|
1856
|
-
* Compute gyration tensors. Returns flat
|
|
2380
|
+
* Compute gyration tensors. Returns a flat float typed array (9 values per cluster).
|
|
2381
|
+
*
|
|
2382
|
+
* Internally computes the cluster geometric centers (via
|
|
2383
|
+
* [`RsClusterCenters`]) since the new compute trait exposes them as a
|
|
2384
|
+
* required upstream — the old single-frame wasm API hides this detail.
|
|
1857
2385
|
* @param {Frame} frame
|
|
1858
2386
|
* @param {ClusterResult} cluster_result
|
|
1859
|
-
* @returns {
|
|
2387
|
+
* @returns {Float64Array}
|
|
1860
2388
|
*/
|
|
1861
2389
|
compute(frame, cluster_result) {
|
|
1862
2390
|
_assertClass(frame, Frame);
|
|
@@ -1865,8 +2393,8 @@ export class GyrationTensor {
|
|
|
1865
2393
|
if (ret[3]) {
|
|
1866
2394
|
throw takeFromExternrefTable0(ret[2]);
|
|
1867
2395
|
}
|
|
1868
|
-
var v1 =
|
|
1869
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] *
|
|
2396
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2397
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 8, 8);
|
|
1870
2398
|
return v1;
|
|
1871
2399
|
}
|
|
1872
2400
|
constructor() {
|
|
@@ -1893,10 +2421,14 @@ export class InertiaTensor {
|
|
|
1893
2421
|
wasm.__wbg_inertiatensor_free(ptr, 0);
|
|
1894
2422
|
}
|
|
1895
2423
|
/**
|
|
1896
|
-
* Compute inertia tensors. Returns flat
|
|
2424
|
+
* Compute inertia tensors. Returns a flat float typed array (9 values per cluster).
|
|
2425
|
+
*
|
|
2426
|
+
* Internally computes the cluster centers of mass (via
|
|
2427
|
+
* [`RsCenterOfMass`]) since the new compute trait consumes them as a
|
|
2428
|
+
* required upstream — the old single-frame wasm API hides this detail.
|
|
1897
2429
|
* @param {Frame} frame
|
|
1898
2430
|
* @param {ClusterResult} cluster_result
|
|
1899
|
-
* @returns {
|
|
2431
|
+
* @returns {Float64Array}
|
|
1900
2432
|
*/
|
|
1901
2433
|
compute(frame, cluster_result) {
|
|
1902
2434
|
_assertClass(frame, Frame);
|
|
@@ -1905,15 +2437,15 @@ export class InertiaTensor {
|
|
|
1905
2437
|
if (ret[3]) {
|
|
1906
2438
|
throw takeFromExternrefTable0(ret[2]);
|
|
1907
2439
|
}
|
|
1908
|
-
var v1 =
|
|
1909
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] *
|
|
2440
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
2441
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 8, 8);
|
|
1910
2442
|
return v1;
|
|
1911
2443
|
}
|
|
1912
2444
|
/**
|
|
1913
|
-
* @param {
|
|
2445
|
+
* @param {Float64Array | null} [masses]
|
|
1914
2446
|
*/
|
|
1915
2447
|
constructor(masses) {
|
|
1916
|
-
var ptr0 = isLikeNone(masses) ? 0 :
|
|
2448
|
+
var ptr0 = isLikeNone(masses) ? 0 : passArrayF64ToWasm0(masses, wasm.__wbindgen_malloc_command_export);
|
|
1917
2449
|
var len0 = WASM_VECTOR_LEN;
|
|
1918
2450
|
const ret = wasm.inertiatensor_new(ptr0, len0);
|
|
1919
2451
|
this.__wbg_ptr = ret >>> 0;
|
|
@@ -2006,8 +2538,8 @@ if (Symbol.dispose) LAMMPSDumpReader.prototype[Symbol.dispose] = LAMMPSDumpReade
|
|
|
2006
2538
|
* Reads LAMMPS data files (the format written by `write_data`). The
|
|
2007
2539
|
* reader produces a [`Frame`] containing:
|
|
2008
2540
|
*
|
|
2009
|
-
* - `"atoms"` block: `type` (i32), `x`, `y`, `z` (
|
|
2010
|
-
* and optionally `charge` (
|
|
2541
|
+
* - `"atoms"` block: `type` (i32), `x`, `y`, `z` (F, angstrom),
|
|
2542
|
+
* and optionally `charge` (F)
|
|
2011
2543
|
* - `"bonds"` block (if present): `i`, `j` (u32), `type` (i32)
|
|
2012
2544
|
* - Simulation box (`simbox`) with PBC
|
|
2013
2545
|
*
|
|
@@ -2158,7 +2690,7 @@ export class LinkedCell {
|
|
|
2158
2690
|
* Finds all unique pairs `(i < j)` of atoms within the cutoff
|
|
2159
2691
|
* distance using the cell-list algorithm.
|
|
2160
2692
|
*
|
|
2161
|
-
* The frame must have an `"atoms"` block with `x`, `y`, `z` (
|
|
2693
|
+
* The frame must have an `"atoms"` block with `x`, `y`, `z` (F) columns.
|
|
2162
2694
|
* If the frame has a `simbox`, periodic boundary conditions are used.
|
|
2163
2695
|
* Otherwise, a free-boundary bounding box is auto-generated.
|
|
2164
2696
|
*
|
|
@@ -2179,7 +2711,7 @@ export class LinkedCell {
|
|
|
2179
2711
|
* ```js
|
|
2180
2712
|
* const lc = new LinkedCell(3.0);
|
|
2181
2713
|
* const nlist = lc.build(frame);
|
|
2182
|
-
* const dists = nlist.distances(); // Float32Array
|
|
2714
|
+
* const dists = nlist.distances(); // Float32Array or Float64Array
|
|
2183
2715
|
* ```
|
|
2184
2716
|
* @param {Frame} frame
|
|
2185
2717
|
* @returns {NeighborList}
|
|
@@ -2300,25 +2832,23 @@ export class MSD {
|
|
|
2300
2832
|
/**
|
|
2301
2833
|
* Feed a frame into the MSD analysis.
|
|
2302
2834
|
*
|
|
2303
|
-
*
|
|
2304
|
-
*
|
|
2835
|
+
* Internally clones the frame's core data so subsequent mutations on
|
|
2836
|
+
* the JS side (e.g. trajectory playback overwriting buffers) do not
|
|
2837
|
+
* race against pending [`results`](Self::results) calls. The first
|
|
2838
|
+
* frame sets the reference configuration.
|
|
2305
2839
|
*
|
|
2306
2840
|
* # Arguments
|
|
2307
2841
|
*
|
|
2308
2842
|
* * `frame` - Frame with `"atoms"` block containing
|
|
2309
|
-
* `x`, `y`, `z` (
|
|
2310
|
-
*
|
|
2311
|
-
* # Errors
|
|
2312
|
-
*
|
|
2313
|
-
* Throws if the frame is missing required columns or has a
|
|
2314
|
-
* different number of atoms than the reference.
|
|
2843
|
+
* `x`, `y`, `z` (F) columns
|
|
2315
2844
|
*
|
|
2316
2845
|
* # Example (JavaScript)
|
|
2317
2846
|
*
|
|
2318
2847
|
* ```js
|
|
2319
2848
|
* const msd = new MSD();
|
|
2320
2849
|
* msd.feed(frame0); // sets reference
|
|
2321
|
-
* msd.feed(frame1); //
|
|
2850
|
+
* msd.feed(frame1); // added to trajectory
|
|
2851
|
+
* const series = msd.results();
|
|
2322
2852
|
* ```
|
|
2323
2853
|
* @param {Frame} frame
|
|
2324
2854
|
*/
|
|
@@ -2348,16 +2878,16 @@ export class MSD {
|
|
|
2348
2878
|
return this;
|
|
2349
2879
|
}
|
|
2350
2880
|
/**
|
|
2351
|
-
* Reset the analysis, clearing
|
|
2881
|
+
* Reset the analysis, clearing the trajectory buffer.
|
|
2352
2882
|
*/
|
|
2353
2883
|
reset() {
|
|
2354
2884
|
wasm.msd_reset(this.__wbg_ptr);
|
|
2355
2885
|
}
|
|
2356
2886
|
/**
|
|
2357
|
-
*
|
|
2887
|
+
* Run the stateless [`molrs_compute::MSD`] over every fed frame and
|
|
2888
|
+
* return the per-frame time series.
|
|
2358
2889
|
*
|
|
2359
|
-
*
|
|
2360
|
-
* reference frame, which has MSD = 0).
|
|
2890
|
+
* The first frame is always the reference, so `results()[0].mean ≈ 0`.
|
|
2361
2891
|
*
|
|
2362
2892
|
* # Example (JavaScript)
|
|
2363
2893
|
*
|
|
@@ -2369,6 +2899,9 @@ export class MSD {
|
|
|
2369
2899
|
*/
|
|
2370
2900
|
results() {
|
|
2371
2901
|
const ret = wasm.msd_results(this.__wbg_ptr);
|
|
2902
|
+
if (ret[3]) {
|
|
2903
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2904
|
+
}
|
|
2372
2905
|
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
2373
2906
|
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
2374
2907
|
return v1;
|
|
@@ -2384,7 +2917,7 @@ if (Symbol.dispose) MSD.prototype[Symbol.dispose] = MSD.prototype.free;
|
|
|
2384
2917
|
* ```js
|
|
2385
2918
|
* const result = msd.compute(frame);
|
|
2386
2919
|
* console.log(result.mean); // number (A^2)
|
|
2387
|
-
* console.log(result.perParticle()); // Float32Array (A^2)
|
|
2920
|
+
* console.log(result.perParticle()); // Float32Array or Float64Array (A^2)
|
|
2388
2921
|
* ```
|
|
2389
2922
|
*/
|
|
2390
2923
|
export class MSDResult {
|
|
@@ -2417,21 +2950,78 @@ export class MSDResult {
|
|
|
2417
2950
|
return ret;
|
|
2418
2951
|
}
|
|
2419
2952
|
/**
|
|
2420
|
-
*
|
|
2421
|
-
*
|
|
2422
|
-
*
|
|
2423
|
-
*
|
|
2424
|
-
* @returns {Float32Array}
|
|
2953
|
+
* Zero-copy `Float64Array` view of per-particle squared displacements
|
|
2954
|
+
* in A². `perParticle()[i]` is `|r_i(t) - r_i(0)|²` for particle `i`.
|
|
2955
|
+
* **Invalidated** on WASM memory growth; copy in JS if needed.
|
|
2956
|
+
* @returns {Float64Array}
|
|
2425
2957
|
*/
|
|
2426
2958
|
perParticle() {
|
|
2427
2959
|
const ret = wasm.msdresult_perParticle(this.__wbg_ptr);
|
|
2428
|
-
|
|
2429
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
2430
|
-
return v1;
|
|
2960
|
+
return ret;
|
|
2431
2961
|
}
|
|
2432
2962
|
}
|
|
2433
2963
|
if (Symbol.dispose) MSDResult.prototype[Symbol.dispose] = MSDResult.prototype.free;
|
|
2434
2964
|
|
|
2965
|
+
/**
|
|
2966
|
+
* Reader for MolRec Zarr v3 archives.
|
|
2967
|
+
*/
|
|
2968
|
+
export class MolRecReader {
|
|
2969
|
+
__destroy_into_raw() {
|
|
2970
|
+
const ptr = this.__wbg_ptr;
|
|
2971
|
+
this.__wbg_ptr = 0;
|
|
2972
|
+
MolRecReaderFinalization.unregister(this);
|
|
2973
|
+
return ptr;
|
|
2974
|
+
}
|
|
2975
|
+
free() {
|
|
2976
|
+
const ptr = this.__destroy_into_raw();
|
|
2977
|
+
wasm.__wbg_molrecreader_free(ptr, 0);
|
|
2978
|
+
}
|
|
2979
|
+
/**
|
|
2980
|
+
* @returns {number}
|
|
2981
|
+
*/
|
|
2982
|
+
countAtoms() {
|
|
2983
|
+
const ret = wasm.molrecreader_countAtoms(this.__wbg_ptr);
|
|
2984
|
+
return ret >>> 0;
|
|
2985
|
+
}
|
|
2986
|
+
/**
|
|
2987
|
+
* @returns {number}
|
|
2988
|
+
*/
|
|
2989
|
+
countFrames() {
|
|
2990
|
+
const ret = wasm.molrecreader_countFrames(this.__wbg_ptr);
|
|
2991
|
+
if (ret[2]) {
|
|
2992
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2993
|
+
}
|
|
2994
|
+
return ret[0] >>> 0;
|
|
2995
|
+
}
|
|
2996
|
+
free() {
|
|
2997
|
+
wasm.molrecreader_free(this.__wbg_ptr);
|
|
2998
|
+
}
|
|
2999
|
+
/**
|
|
3000
|
+
* @param {Map<any, any>} files
|
|
3001
|
+
*/
|
|
3002
|
+
constructor(files) {
|
|
3003
|
+
const ret = wasm.molrecreader_new(files);
|
|
3004
|
+
if (ret[2]) {
|
|
3005
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3006
|
+
}
|
|
3007
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
3008
|
+
MolRecReaderFinalization.register(this, this.__wbg_ptr, this);
|
|
3009
|
+
return this;
|
|
3010
|
+
}
|
|
3011
|
+
/**
|
|
3012
|
+
* @param {number} t
|
|
3013
|
+
* @returns {Frame | undefined}
|
|
3014
|
+
*/
|
|
3015
|
+
readFrame(t) {
|
|
3016
|
+
const ret = wasm.molrecreader_readFrame(this.__wbg_ptr, t);
|
|
3017
|
+
if (ret[2]) {
|
|
3018
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3019
|
+
}
|
|
3020
|
+
return ret[0] === 0 ? undefined : Frame.__wrap(ret[0]);
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
3023
|
+
if (Symbol.dispose) MolRecReader.prototype[Symbol.dispose] = MolRecReader.prototype.free;
|
|
3024
|
+
|
|
2435
3025
|
/**
|
|
2436
3026
|
* Result of a neighbor search: all atom pairs within a distance cutoff.
|
|
2437
3027
|
*
|
|
@@ -2456,7 +3046,7 @@ if (Symbol.dispose) MSDResult.prototype[Symbol.dispose] = MSDResult.prototype.fr
|
|
|
2456
3046
|
*
|
|
2457
3047
|
* const i = nlist.queryPointIndices(); // Uint32Array
|
|
2458
3048
|
* const j = nlist.pointIndices(); // Uint32Array
|
|
2459
|
-
* const d = nlist.distances(); // Float32Array (in A)
|
|
3049
|
+
* const d = nlist.distances(); // Float32Array or Float64Array (in A)
|
|
2460
3050
|
* ```
|
|
2461
3051
|
*/
|
|
2462
3052
|
export class NeighborList {
|
|
@@ -2478,29 +3068,25 @@ export class NeighborList {
|
|
|
2478
3068
|
wasm.__wbg_neighborlist_free(ptr, 0);
|
|
2479
3069
|
}
|
|
2480
3070
|
/**
|
|
2481
|
-
*
|
|
2482
|
-
*
|
|
2483
|
-
*
|
|
2484
|
-
* compare or threshold distances.
|
|
2485
|
-
* @returns {Float32Array}
|
|
3071
|
+
* Zero-copy `Float64Array` view of squared pairwise distances in A^2.
|
|
3072
|
+
* Same invalidation caveat as [`queryPointIndices`](Self::query_point_indices).
|
|
3073
|
+
* @returns {Float64Array}
|
|
2486
3074
|
*/
|
|
2487
3075
|
distSq() {
|
|
2488
3076
|
const ret = wasm.neighborlist_distSq(this.__wbg_ptr);
|
|
2489
|
-
|
|
2490
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
2491
|
-
return v1;
|
|
3077
|
+
return ret;
|
|
2492
3078
|
}
|
|
2493
3079
|
/**
|
|
2494
|
-
* Pairwise distances in angstrom (A)
|
|
3080
|
+
* Pairwise distances in angstrom (A). Computed lazily from `distSq`.
|
|
2495
3081
|
*
|
|
2496
|
-
*
|
|
2497
|
-
*
|
|
2498
|
-
* @returns {
|
|
3082
|
+
* Returns an owned copy because distances are derived on the fly
|
|
3083
|
+
* (`sqrt` per pair) rather than stored.
|
|
3084
|
+
* @returns {Float64Array}
|
|
2499
3085
|
*/
|
|
2500
3086
|
distances() {
|
|
2501
3087
|
const ret = wasm.neighborlist_distances(this.__wbg_ptr);
|
|
2502
|
-
var v1 =
|
|
2503
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] *
|
|
3088
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3089
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 8, 8);
|
|
2504
3090
|
return v1;
|
|
2505
3091
|
}
|
|
2506
3092
|
/**
|
|
@@ -2540,27 +3126,23 @@ export class NeighborList {
|
|
|
2540
3126
|
return ret >>> 0;
|
|
2541
3127
|
}
|
|
2542
3128
|
/**
|
|
2543
|
-
*
|
|
3129
|
+
* Zero-copy `Uint32Array` view of reference point indices (`j`).
|
|
3130
|
+
* Same invalidation caveat as [`queryPointIndices`](Self::query_point_indices).
|
|
2544
3131
|
* @returns {Uint32Array}
|
|
2545
3132
|
*/
|
|
2546
3133
|
pointIndices() {
|
|
2547
3134
|
const ret = wasm.neighborlist_pointIndices(this.__wbg_ptr);
|
|
2548
|
-
|
|
2549
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
2550
|
-
return v1;
|
|
3135
|
+
return ret;
|
|
2551
3136
|
}
|
|
2552
3137
|
/**
|
|
2553
|
-
*
|
|
2554
|
-
*
|
|
2555
|
-
*
|
|
2556
|
-
* to reference point `pointIndices()[k]`.
|
|
3138
|
+
* Zero-copy `Uint32Array` view of query point indices (`i`) over
|
|
3139
|
+
* WASM memory. **Invalidated** on any WASM memory growth — copy
|
|
3140
|
+
* in JS (`new Uint32Array(view)`) if it needs to outlive later calls.
|
|
2557
3141
|
* @returns {Uint32Array}
|
|
2558
3142
|
*/
|
|
2559
3143
|
queryPointIndices() {
|
|
2560
3144
|
const ret = wasm.neighborlist_queryPointIndices(this.__wbg_ptr);
|
|
2561
|
-
|
|
2562
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
2563
|
-
return v1;
|
|
3145
|
+
return ret;
|
|
2564
3146
|
}
|
|
2565
3147
|
}
|
|
2566
3148
|
if (Symbol.dispose) NeighborList.prototype[Symbol.dispose] = NeighborList.prototype.free;
|
|
@@ -2570,8 +3152,8 @@ if (Symbol.dispose) NeighborList.prototype[Symbol.dispose] = NeighborList.protot
|
|
|
2570
3152
|
*
|
|
2571
3153
|
* PDB files contain a single molecular structure. The reader produces
|
|
2572
3154
|
* a [`Frame`] with an `"atoms"` block containing columns such as
|
|
2573
|
-
* `name` (string), `resname` (string), `x`, `y`, `z` (
|
|
2574
|
-
* and optionally `occupancy` and `bfactor` (
|
|
3155
|
+
* `name` (string), `resname` (string), `x`, `y`, `z` (F, angstrom),
|
|
3156
|
+
* and optionally `occupancy` and `bfactor` (F).
|
|
2575
3157
|
*
|
|
2576
3158
|
* # Example (JavaScript)
|
|
2577
3159
|
*
|
|
@@ -2580,7 +3162,7 @@ if (Symbol.dispose) NeighborList.prototype[Symbol.dispose] = NeighborList.protot
|
|
|
2580
3162
|
* const frame = reader.read(0);
|
|
2581
3163
|
* const atoms = frame.getBlock("atoms");
|
|
2582
3164
|
* const names = atoms.copyColStr("name"); // ["CA", "CB", ...]
|
|
2583
|
-
* const x = atoms.
|
|
3165
|
+
* const x = atoms.copyColF("x");
|
|
2584
3166
|
* ```
|
|
2585
3167
|
*/
|
|
2586
3168
|
export class PDBReader {
|
|
@@ -2685,15 +3267,16 @@ if (Symbol.dispose) PDBReader.prototype[Symbol.dispose] = PDBReader.prototype.fr
|
|
|
2685
3267
|
/**
|
|
2686
3268
|
* Radial distribution function g(r) analysis.
|
|
2687
3269
|
*
|
|
2688
|
-
*
|
|
2689
|
-
*
|
|
2690
|
-
*
|
|
3270
|
+
* Bins neighbor-pair distances in `[rMin, rMax]` and normalizes by the
|
|
3271
|
+
* ideal-gas pair density. Defaults follow freud (`rMin = 0`). Periodic
|
|
3272
|
+
* systems take their normalization volume from `frame.simbox`; non-periodic
|
|
3273
|
+
* systems must supply it explicitly via [`computeWithVolume`].
|
|
2691
3274
|
*
|
|
2692
3275
|
* # Algorithm
|
|
2693
3276
|
*
|
|
2694
3277
|
* g(r) = n(r) / (rho * V_shell(r) * N_ref)
|
|
2695
3278
|
*
|
|
2696
|
-
* where `n(r)` is the pair count in bin `r`, `rho` is the number
|
|
3279
|
+
* where `n(r)` is the pair count in bin `r`, `rho = N/V` is the number
|
|
2697
3280
|
* density, and `V_shell(r)` is the shell volume for that bin.
|
|
2698
3281
|
*
|
|
2699
3282
|
* # Example (JavaScript)
|
|
@@ -2702,11 +3285,14 @@ if (Symbol.dispose) PDBReader.prototype[Symbol.dispose] = PDBReader.prototype.fr
|
|
|
2702
3285
|
* const lc = new LinkedCell(5.0);
|
|
2703
3286
|
* const nlist = lc.build(frame);
|
|
2704
3287
|
*
|
|
2705
|
-
* const rdf = new RDF(100, 5.0);
|
|
3288
|
+
* const rdf = new RDF(100, 5.0); // rMin defaults to 0
|
|
2706
3289
|
* const result = rdf.compute(frame, nlist);
|
|
2707
3290
|
*
|
|
2708
|
-
*
|
|
2709
|
-
* const
|
|
3291
|
+
* // Non-periodic frame: supply the normalization volume.
|
|
3292
|
+
* const resultFree = rdf.computeWithVolume(nlist, volumeA3);
|
|
3293
|
+
*
|
|
3294
|
+
* const r = result.binCenters();
|
|
3295
|
+
* const gr = result.rdf();
|
|
2710
3296
|
* ```
|
|
2711
3297
|
*/
|
|
2712
3298
|
export class RDF {
|
|
@@ -2721,64 +3307,88 @@ export class RDF {
|
|
|
2721
3307
|
wasm.__wbg_rdf_free(ptr, 0);
|
|
2722
3308
|
}
|
|
2723
3309
|
/**
|
|
2724
|
-
* Compute
|
|
3310
|
+
* Compute g(r) using the simulation-box volume from `frame.simbox`.
|
|
3311
|
+
*
|
|
3312
|
+
* # Arguments
|
|
3313
|
+
*
|
|
3314
|
+
* * `frame` - Frame with a `simbox` set (used only for volume)
|
|
3315
|
+
* * `neighbors` - Pre-built [`NeighborList`] from [`LinkedCell`]
|
|
3316
|
+
*
|
|
3317
|
+
* # Errors
|
|
3318
|
+
*
|
|
3319
|
+
* Throws if the frame has no `simbox` — use
|
|
3320
|
+
* [`computeWithVolume`](Self::compute_with_volume) for non-periodic frames.
|
|
3321
|
+
* @param {Frame} frame
|
|
3322
|
+
* @param {NeighborList} neighbors
|
|
3323
|
+
* @returns {RDFResult}
|
|
3324
|
+
*/
|
|
3325
|
+
compute(frame, neighbors) {
|
|
3326
|
+
_assertClass(frame, Frame);
|
|
3327
|
+
_assertClass(neighbors, NeighborList);
|
|
3328
|
+
const ret = wasm.rdf_compute(this.__wbg_ptr, frame.__wbg_ptr, neighbors.__wbg_ptr);
|
|
3329
|
+
if (ret[2]) {
|
|
3330
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3331
|
+
}
|
|
3332
|
+
return RDFResult.__wrap(ret[0]);
|
|
3333
|
+
}
|
|
3334
|
+
/**
|
|
3335
|
+
* Compute g(r) using an explicit normalization volume (A^3).
|
|
2725
3336
|
*
|
|
2726
|
-
*
|
|
2727
|
-
*
|
|
3337
|
+
* Use this for non-periodic systems or to override the box volume.
|
|
3338
|
+
* Internally wraps the supplied volume as a cubic SimBox since the
|
|
3339
|
+
* underlying [`molrs_compute::RDF`] pulls its normalization volume from
|
|
3340
|
+
* `frame.simbox`.
|
|
2728
3341
|
*
|
|
2729
3342
|
* # Arguments
|
|
2730
3343
|
*
|
|
2731
|
-
* * `
|
|
2732
|
-
* * `
|
|
2733
|
-
*
|
|
2734
|
-
* # Returns
|
|
2735
|
-
*
|
|
2736
|
-
* An [`RDFResult`] containing bin centers, g(r) values, and raw
|
|
2737
|
-
* pair counts.
|
|
2738
|
-
*
|
|
2739
|
-
* # Errors
|
|
2740
|
-
*
|
|
2741
|
-
* Throws if the frame cannot be cloned or the computation fails.
|
|
3344
|
+
* * `neighbors` - Pre-built [`NeighborList`]
|
|
3345
|
+
* * `volume` - Normalization volume in A^3 (must be finite and > 0)
|
|
2742
3346
|
*
|
|
2743
3347
|
* # Example (JavaScript)
|
|
2744
3348
|
*
|
|
2745
3349
|
* ```js
|
|
2746
|
-
* const result = rdf.
|
|
2747
|
-
* const gr = result.rdf(); // Float32Array
|
|
3350
|
+
* const result = rdf.computeWithVolume(nlist, 1000.0);
|
|
2748
3351
|
* ```
|
|
2749
|
-
* @param {Frame} frame
|
|
2750
3352
|
* @param {NeighborList} neighbors
|
|
3353
|
+
* @param {number} volume
|
|
2751
3354
|
* @returns {RDFResult}
|
|
2752
3355
|
*/
|
|
2753
|
-
|
|
2754
|
-
_assertClass(frame, Frame);
|
|
3356
|
+
computeWithVolume(neighbors, volume) {
|
|
2755
3357
|
_assertClass(neighbors, NeighborList);
|
|
2756
|
-
const ret = wasm.
|
|
3358
|
+
const ret = wasm.rdf_computeWithVolume(this.__wbg_ptr, neighbors.__wbg_ptr, volume);
|
|
2757
3359
|
if (ret[2]) {
|
|
2758
3360
|
throw takeFromExternrefTable0(ret[1]);
|
|
2759
3361
|
}
|
|
2760
3362
|
return RDFResult.__wrap(ret[0]);
|
|
2761
3363
|
}
|
|
2762
3364
|
/**
|
|
2763
|
-
* Create a new RDF analysis
|
|
3365
|
+
* Create a new RDF analysis.
|
|
2764
3366
|
*
|
|
2765
3367
|
* # Arguments
|
|
2766
3368
|
*
|
|
2767
3369
|
* * `n_bins` - Number of histogram bins
|
|
2768
|
-
* * `r_max` -
|
|
2769
|
-
*
|
|
3370
|
+
* * `r_max` - Upper radial cutoff in angstrom (A). Should be ≤ the
|
|
3371
|
+
* neighbor-search cutoff.
|
|
3372
|
+
* * `r_min` - Lower radial cutoff in angstrom (A). Optional, defaults
|
|
3373
|
+
* to 0 (freud convention). Pairs with `d < rMin` or `d == 0` are
|
|
3374
|
+
* excluded from the histogram.
|
|
2770
3375
|
*
|
|
2771
3376
|
* # Example (JavaScript)
|
|
2772
3377
|
*
|
|
2773
3378
|
* ```js
|
|
2774
|
-
* const rdf = new RDF(100, 5.0);
|
|
3379
|
+
* const rdf = new RDF(100, 5.0); // rMin = 0
|
|
3380
|
+
* const rdf2 = new RDF(100, 5.0, 0.5); // exclude d < 0.5 A
|
|
2775
3381
|
* ```
|
|
2776
3382
|
* @param {number} n_bins
|
|
2777
3383
|
* @param {number} r_max
|
|
3384
|
+
* @param {number | null} [r_min]
|
|
2778
3385
|
*/
|
|
2779
|
-
constructor(n_bins, r_max) {
|
|
2780
|
-
const ret = wasm.rdf_new(n_bins, r_max);
|
|
2781
|
-
|
|
3386
|
+
constructor(n_bins, r_max, r_min) {
|
|
3387
|
+
const ret = wasm.rdf_new(n_bins, r_max, !isLikeNone(r_min), isLikeNone(r_min) ? 0 : r_min);
|
|
3388
|
+
if (ret[2]) {
|
|
3389
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3390
|
+
}
|
|
3391
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
2782
3392
|
RDFFinalization.register(this, this.__wbg_ptr, this);
|
|
2783
3393
|
return this;
|
|
2784
3394
|
}
|
|
@@ -2795,9 +3405,9 @@ if (Symbol.dispose) RDF.prototype[Symbol.dispose] = RDF.prototype.free;
|
|
|
2795
3405
|
*
|
|
2796
3406
|
* ```js
|
|
2797
3407
|
* const result = rdf.compute(frame, nlist);
|
|
2798
|
-
* const r = result.binCenters(); // Float32Array [0.025, 0.075, ...]
|
|
2799
|
-
* const gr = result.rdf(); // Float32Array, normalized g(r)
|
|
2800
|
-
* const nr = result.pairCounts(); // Float32Array, raw counts
|
|
3408
|
+
* const r = result.binCenters(); // Float32Array or Float64Array [0.025, 0.075, ...]
|
|
3409
|
+
* const gr = result.rdf(); // Float32Array or Float64Array, normalized g(r)
|
|
3410
|
+
* const nr = result.pairCounts(); // Float32Array or Float64Array, raw counts
|
|
2801
3411
|
* console.log("Volume:", result.volume, "A^3");
|
|
2802
3412
|
* console.log("N_ref:", result.numPoints);
|
|
2803
3413
|
* ```
|
|
@@ -2821,28 +3431,23 @@ export class RDFResult {
|
|
|
2821
3431
|
wasm.__wbg_rdfresult_free(ptr, 0);
|
|
2822
3432
|
}
|
|
2823
3433
|
/**
|
|
2824
|
-
*
|
|
2825
|
-
*
|
|
2826
|
-
*
|
|
2827
|
-
* @returns {
|
|
3434
|
+
* Zero-copy `Float64Array` view of bin center positions in A.
|
|
3435
|
+
* Length equals `n_bins`. **Invalidated** on WASM memory growth;
|
|
3436
|
+
* copy in JS if it needs to outlive later calls.
|
|
3437
|
+
* @returns {Float64Array}
|
|
2828
3438
|
*/
|
|
2829
3439
|
binCenters() {
|
|
2830
3440
|
const ret = wasm.rdfresult_binCenters(this.__wbg_ptr);
|
|
2831
|
-
|
|
2832
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
2833
|
-
return v1;
|
|
3441
|
+
return ret;
|
|
2834
3442
|
}
|
|
2835
3443
|
/**
|
|
2836
|
-
*
|
|
2837
|
-
*
|
|
2838
|
-
*
|
|
2839
|
-
* @returns {Float32Array}
|
|
3444
|
+
* Zero-copy `Float64Array` view of bin edge positions in A.
|
|
3445
|
+
* Length is `n_bins + 1`. Same invalidation caveat.
|
|
3446
|
+
* @returns {Float64Array}
|
|
2840
3447
|
*/
|
|
2841
3448
|
binEdges() {
|
|
2842
3449
|
const ret = wasm.rdfresult_binEdges(this.__wbg_ptr);
|
|
2843
|
-
|
|
2844
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
2845
|
-
return v1;
|
|
3450
|
+
return ret;
|
|
2846
3451
|
}
|
|
2847
3452
|
/**
|
|
2848
3453
|
* Number of reference points used in the normalization.
|
|
@@ -2853,30 +3458,33 @@ export class RDFResult {
|
|
|
2853
3458
|
return ret >>> 0;
|
|
2854
3459
|
}
|
|
2855
3460
|
/**
|
|
2856
|
-
*
|
|
2857
|
-
*
|
|
3461
|
+
* Zero-copy `Float64Array` view of raw (un-normalized) pair counts
|
|
3462
|
+
* per bin. Same invalidation caveat.
|
|
3463
|
+
* @returns {Float64Array}
|
|
2858
3464
|
*/
|
|
2859
3465
|
pairCounts() {
|
|
2860
3466
|
const ret = wasm.rdfresult_pairCounts(this.__wbg_ptr);
|
|
2861
|
-
|
|
2862
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
2863
|
-
return v1;
|
|
3467
|
+
return ret;
|
|
2864
3468
|
}
|
|
2865
3469
|
/**
|
|
2866
|
-
*
|
|
2867
|
-
*
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
3470
|
+
* Inner cutoff in A (lower edge of bin 0).
|
|
3471
|
+
* @returns {number}
|
|
3472
|
+
*/
|
|
3473
|
+
get rMin() {
|
|
3474
|
+
const ret = wasm.rdfresult_rMin(this.__wbg_ptr);
|
|
3475
|
+
return ret;
|
|
3476
|
+
}
|
|
3477
|
+
/**
|
|
3478
|
+
* Zero-copy `Float64Array` view of normalized g(r). Same invalidation
|
|
3479
|
+
* caveat.
|
|
3480
|
+
* @returns {Float64Array}
|
|
2871
3481
|
*/
|
|
2872
3482
|
rdf() {
|
|
2873
3483
|
const ret = wasm.rdfresult_rdf(this.__wbg_ptr);
|
|
2874
|
-
|
|
2875
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
2876
|
-
return v1;
|
|
3484
|
+
return ret;
|
|
2877
3485
|
}
|
|
2878
3486
|
/**
|
|
2879
|
-
*
|
|
3487
|
+
* Normalization volume in A^3 (from the SimBox or the explicit caller value).
|
|
2880
3488
|
* @returns {number}
|
|
2881
3489
|
*/
|
|
2882
3490
|
get volume() {
|
|
@@ -2901,10 +3509,14 @@ export class RadiusOfGyration {
|
|
|
2901
3509
|
wasm.__wbg_radiusofgyration_free(ptr, 0);
|
|
2902
3510
|
}
|
|
2903
3511
|
/**
|
|
2904
|
-
* Compute radii of gyration. Returns
|
|
3512
|
+
* Compute radii of gyration. Returns a float typed array of length `numClusters`.
|
|
3513
|
+
*
|
|
3514
|
+
* Internally computes the cluster centers of mass so the single-frame
|
|
3515
|
+
* wasm signature `(frame, cluster)` stays stable despite the new
|
|
3516
|
+
* compute trait needing explicit COM upstream.
|
|
2905
3517
|
* @param {Frame} frame
|
|
2906
3518
|
* @param {ClusterResult} cluster_result
|
|
2907
|
-
* @returns {
|
|
3519
|
+
* @returns {Float64Array}
|
|
2908
3520
|
*/
|
|
2909
3521
|
compute(frame, cluster_result) {
|
|
2910
3522
|
_assertClass(frame, Frame);
|
|
@@ -2913,15 +3525,15 @@ export class RadiusOfGyration {
|
|
|
2913
3525
|
if (ret[3]) {
|
|
2914
3526
|
throw takeFromExternrefTable0(ret[2]);
|
|
2915
3527
|
}
|
|
2916
|
-
var v1 =
|
|
2917
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] *
|
|
3528
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
3529
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 8, 8);
|
|
2918
3530
|
return v1;
|
|
2919
3531
|
}
|
|
2920
3532
|
/**
|
|
2921
|
-
* @param {
|
|
3533
|
+
* @param {Float64Array | null} [masses]
|
|
2922
3534
|
*/
|
|
2923
3535
|
constructor(masses) {
|
|
2924
|
-
var ptr0 = isLikeNone(masses) ? 0 :
|
|
3536
|
+
var ptr0 = isLikeNone(masses) ? 0 : passArrayF64ToWasm0(masses, wasm.__wbindgen_malloc_command_export);
|
|
2925
3537
|
var len0 = WASM_VECTOR_LEN;
|
|
2926
3538
|
const ret = wasm.radiusofgyration_new(ptr0, len0);
|
|
2927
3539
|
this.__wbg_ptr = ret >>> 0;
|
|
@@ -2932,150 +3544,90 @@ export class RadiusOfGyration {
|
|
|
2932
3544
|
if (Symbol.dispose) RadiusOfGyration.prototype[Symbol.dispose] = RadiusOfGyration.prototype.free;
|
|
2933
3545
|
|
|
2934
3546
|
/**
|
|
2935
|
-
*
|
|
3547
|
+
* MDL molfile / SDF (V2000 CTAB) reader.
|
|
3548
|
+
*
|
|
3549
|
+
* Parses the connection table found in `.mol` files and the record
|
|
3550
|
+
* blocks of `.sdf` files. Coordinates come directly from the file —
|
|
3551
|
+
* no 3D generation is performed. Only V2000 is supported; V3000
|
|
3552
|
+
* records throw on read.
|
|
3553
|
+
*
|
|
3554
|
+
* Produces a [`Frame`] with:
|
|
3555
|
+
* - `"atoms"` block: `element` (string), `id` (u32, 1-based),
|
|
3556
|
+
* `x`, `y`, `z` (F, angstrom)
|
|
3557
|
+
* - `"bonds"` block (if present): `atomi`, `atomj` (u32, 0-based),
|
|
3558
|
+
* `order` (u32)
|
|
2936
3559
|
*
|
|
2937
|
-
*
|
|
2938
|
-
*
|
|
2939
|
-
* is populated from a `Map<string, Uint8Array>` of file paths to
|
|
2940
|
-
* binary content.
|
|
3560
|
+
* Multi-record SDF files expose each record as a separate frame via
|
|
3561
|
+
* `read(step)`.
|
|
2941
3562
|
*
|
|
2942
3563
|
* # Example (JavaScript)
|
|
2943
3564
|
*
|
|
2944
3565
|
* ```js
|
|
2945
|
-
* const
|
|
2946
|
-
*
|
|
2947
|
-
*
|
|
2948
|
-
*
|
|
2949
|
-
*
|
|
2950
|
-
* const reader = new SimulationReader(files);
|
|
2951
|
-
* const frame = reader.readFrame(0);
|
|
3566
|
+
* const reader = new SDFReader(sdfContent);
|
|
3567
|
+
* const frame = reader.read(0);
|
|
3568
|
+
* const atoms = frame.getBlock("atoms");
|
|
3569
|
+
* const x = atoms.copyColF("x");
|
|
2952
3570
|
* ```
|
|
2953
3571
|
*/
|
|
2954
|
-
export class
|
|
3572
|
+
export class SDFReader {
|
|
2955
3573
|
__destroy_into_raw() {
|
|
2956
3574
|
const ptr = this.__wbg_ptr;
|
|
2957
3575
|
this.__wbg_ptr = 0;
|
|
2958
|
-
|
|
3576
|
+
SDFReaderFinalization.unregister(this);
|
|
2959
3577
|
return ptr;
|
|
2960
3578
|
}
|
|
2961
3579
|
free() {
|
|
2962
3580
|
const ptr = this.__destroy_into_raw();
|
|
2963
|
-
wasm.
|
|
3581
|
+
wasm.__wbg_sdfreader_free(ptr, 0);
|
|
2964
3582
|
}
|
|
2965
3583
|
/**
|
|
2966
|
-
*
|
|
2967
|
-
*
|
|
2968
|
-
* # Example (JavaScript)
|
|
2969
|
-
*
|
|
2970
|
-
* ```js
|
|
2971
|
-
* console.log(reader.countAtoms()); // e.g., 256
|
|
2972
|
-
* ```
|
|
2973
|
-
* @returns {number}
|
|
3584
|
+
* Check whether the file contains no records.
|
|
3585
|
+
* @returns {boolean}
|
|
2974
3586
|
*/
|
|
2975
|
-
|
|
2976
|
-
const ret = wasm.
|
|
2977
|
-
|
|
3587
|
+
isEmpty() {
|
|
3588
|
+
const ret = wasm.sdfreader_isEmpty(this.__wbg_ptr);
|
|
3589
|
+
if (ret[2]) {
|
|
3590
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
3591
|
+
}
|
|
3592
|
+
return ret[0] !== 0;
|
|
2978
3593
|
}
|
|
2979
3594
|
/**
|
|
2980
|
-
* Return the number of
|
|
2981
|
-
*
|
|
2982
|
-
* Returns `0` if no trajectory data is present.
|
|
2983
|
-
*
|
|
2984
|
-
* # Errors
|
|
2985
|
-
*
|
|
2986
|
-
* Throws a `JsValue` string on I/O errors.
|
|
2987
|
-
*
|
|
2988
|
-
* # Example (JavaScript)
|
|
2989
|
-
*
|
|
2990
|
-
* ```js
|
|
2991
|
-
* console.log(reader.countFrames()); // e.g., 1000
|
|
2992
|
-
* ```
|
|
3595
|
+
* Return the total number of records in the SDF file.
|
|
2993
3596
|
* @returns {number}
|
|
2994
3597
|
*/
|
|
2995
|
-
|
|
2996
|
-
const ret = wasm.
|
|
3598
|
+
len() {
|
|
3599
|
+
const ret = wasm.sdfreader_len(this.__wbg_ptr);
|
|
2997
3600
|
if (ret[2]) {
|
|
2998
3601
|
throw takeFromExternrefTable0(ret[1]);
|
|
2999
3602
|
}
|
|
3000
3603
|
return ret[0] >>> 0;
|
|
3001
3604
|
}
|
|
3002
3605
|
/**
|
|
3003
|
-
* Create a reader from a
|
|
3004
|
-
*
|
|
3005
|
-
* The map keys are relative paths within the Zarr archive
|
|
3006
|
-
* (e.g., `"zarr.json"`, `"system/.zarray"`). Values are the
|
|
3007
|
-
* raw bytes of each file as `Uint8Array`.
|
|
3008
|
-
*
|
|
3009
|
-
* # Arguments
|
|
3010
|
-
*
|
|
3011
|
-
* * `files` - `Map<string, Uint8Array>` mapping archive paths
|
|
3012
|
-
* to their binary content
|
|
3013
|
-
*
|
|
3014
|
-
* # Returns
|
|
3015
|
-
*
|
|
3016
|
-
* A new `SimulationReader` ready to read frames.
|
|
3017
|
-
*
|
|
3018
|
-
* # Errors
|
|
3019
|
-
*
|
|
3020
|
-
* Throws a `JsValue` string if the archive cannot be opened
|
|
3021
|
-
* (e.g., missing required metadata files).
|
|
3022
|
-
*
|
|
3023
|
-
* # Example (JavaScript)
|
|
3024
|
-
*
|
|
3025
|
-
* ```js
|
|
3026
|
-
* const reader = new SimulationReader(filesMap);
|
|
3027
|
-
* ```
|
|
3028
|
-
* @param {Map<any, any>} files
|
|
3606
|
+
* Create a new SDF reader from a string containing the file content.
|
|
3607
|
+
* @param {string} content
|
|
3029
3608
|
*/
|
|
3030
|
-
constructor(
|
|
3031
|
-
const
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
this.__wbg_ptr
|
|
3036
|
-
SimulationReaderFinalization.register(this, this.__wbg_ptr, this);
|
|
3609
|
+
constructor(content) {
|
|
3610
|
+
const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
3611
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3612
|
+
const ret = wasm.sdfreader_new(ptr0, len0);
|
|
3613
|
+
this.__wbg_ptr = ret >>> 0;
|
|
3614
|
+
SDFReaderFinalization.register(this, this.__wbg_ptr, this);
|
|
3037
3615
|
return this;
|
|
3038
3616
|
}
|
|
3039
3617
|
/**
|
|
3040
|
-
* Read
|
|
3041
|
-
*
|
|
3042
|
-
* The returned [`Frame`] merges the static system topology
|
|
3043
|
-
* (atoms, bonds) with the per-frame trajectory data (positions,
|
|
3044
|
-
* velocities, etc.) at time step `t`.
|
|
3045
|
-
*
|
|
3046
|
-
* # Arguments
|
|
3047
|
-
*
|
|
3048
|
-
* * `t` - Zero-based time step index
|
|
3049
|
-
*
|
|
3050
|
-
* # Returns
|
|
3051
|
-
*
|
|
3052
|
-
* A [`Frame`] with merged system + trajectory data, or `undefined`
|
|
3053
|
-
* if no trajectory is present.
|
|
3054
|
-
*
|
|
3055
|
-
* # Errors
|
|
3056
|
-
*
|
|
3057
|
-
* Throws a `JsValue` string on I/O or deserialization errors.
|
|
3058
|
-
*
|
|
3059
|
-
* # Example (JavaScript)
|
|
3060
|
-
*
|
|
3061
|
-
* ```js
|
|
3062
|
-
* const frame = reader.readFrame(0);
|
|
3063
|
-
* if (frame) {
|
|
3064
|
-
* const x = frame.getBlock("atoms").copyColF32("x");
|
|
3065
|
-
* }
|
|
3066
|
-
* ```
|
|
3067
|
-
* @param {number} t
|
|
3618
|
+
* Read the frame (SDF record) at the given step index.
|
|
3619
|
+
* @param {number} step
|
|
3068
3620
|
* @returns {Frame | undefined}
|
|
3069
3621
|
*/
|
|
3070
|
-
|
|
3071
|
-
const ret = wasm.
|
|
3622
|
+
read(step) {
|
|
3623
|
+
const ret = wasm.sdfreader_read(this.__wbg_ptr, step);
|
|
3072
3624
|
if (ret[2]) {
|
|
3073
3625
|
throw takeFromExternrefTable0(ret[1]);
|
|
3074
3626
|
}
|
|
3075
3627
|
return ret[0] === 0 ? undefined : Frame.__wrap(ret[0]);
|
|
3076
3628
|
}
|
|
3077
3629
|
}
|
|
3078
|
-
if (Symbol.dispose)
|
|
3630
|
+
if (Symbol.dispose) SDFReader.prototype[Symbol.dispose] = SDFReader.prototype.free;
|
|
3079
3631
|
|
|
3080
3632
|
/**
|
|
3081
3633
|
* Intermediate representation of a parsed SMILES string.
|
|
@@ -3095,7 +3647,7 @@ if (Symbol.dispose) SimulationReader.prototype[Symbol.dispose] = SimulationReade
|
|
|
3095
3647
|
*
|
|
3096
3648
|
* const frame = ir.toFrame();
|
|
3097
3649
|
* const atoms = frame.getBlock("atoms");
|
|
3098
|
-
* console.log(atoms.copyColStr("
|
|
3650
|
+
* console.log(atoms.copyColStr("element")); // ["C", "C", "O", "H", ...]
|
|
3099
3651
|
* ```
|
|
3100
3652
|
*/
|
|
3101
3653
|
export class SmilesIR {
|
|
@@ -3143,7 +3695,7 @@ export class SmilesIR {
|
|
|
3143
3695
|
* are added. No 3D coordinates are present -- use
|
|
3144
3696
|
* [`generate3D`](crate::generate_3d_wasm) to embed coordinates.
|
|
3145
3697
|
* - `"bonds"` block: `i`, `j` (u32, zero-based atom indices),
|
|
3146
|
-
* `order` (
|
|
3698
|
+
* `order` (F, bond order: 1.0 = single, 1.5 = aromatic,
|
|
3147
3699
|
* 2.0 = double, 3.0 = triple).
|
|
3148
3700
|
*
|
|
3149
3701
|
* # Returns
|
|
@@ -3160,7 +3712,7 @@ export class SmilesIR {
|
|
|
3160
3712
|
* ```js
|
|
3161
3713
|
* const frame = ir.toFrame();
|
|
3162
3714
|
* const bonds = frame.getBlock("bonds");
|
|
3163
|
-
* const order = bonds.
|
|
3715
|
+
* const order = bonds.copyColF("order");
|
|
3164
3716
|
* ```
|
|
3165
3717
|
* @returns {Frame}
|
|
3166
3718
|
*/
|
|
@@ -3495,26 +4047,26 @@ export class TopologyRingInfo {
|
|
|
3495
4047
|
if (Symbol.dispose) TopologyRingInfo.prototype[Symbol.dispose] = TopologyRingInfo.prototype.free;
|
|
3496
4048
|
|
|
3497
4049
|
/**
|
|
3498
|
-
* Owned
|
|
4050
|
+
* Owned float array with ndarray-compatible shape metadata.
|
|
3499
4051
|
*
|
|
3500
|
-
* Stores a flat `Vec<
|
|
4052
|
+
* Stores a flat `Vec<F>` together with a shape descriptor (e.g.,
|
|
3501
4053
|
* `[N, 3]` for an Nx3 coordinate matrix). Used for passing
|
|
3502
4054
|
* multi-dimensional numeric data across the WASM boundary.
|
|
3503
4055
|
*
|
|
3504
4056
|
* # Memory layout
|
|
3505
4057
|
*
|
|
3506
4058
|
* Data is stored in row-major (C) order, matching ndarray's default
|
|
3507
|
-
* and JavaScript's
|
|
4059
|
+
* and JavaScript's float typed-array convention.
|
|
3508
4060
|
*
|
|
3509
4061
|
* # Example (JavaScript)
|
|
3510
4062
|
*
|
|
3511
4063
|
* ```js
|
|
3512
4064
|
* // Create a 2x3 zero array
|
|
3513
4065
|
* const arr = new WasmArray([2, 3]);
|
|
3514
|
-
* arr.writeFrom(
|
|
4066
|
+
* arr.writeFrom(floatArray);
|
|
3515
4067
|
*
|
|
3516
4068
|
* // Or from existing data
|
|
3517
|
-
* const arr2 = WasmArray.from(
|
|
4069
|
+
* const arr2 = WasmArray.from(floatArray, [1, 3]);
|
|
3518
4070
|
*
|
|
3519
4071
|
* // Get data back
|
|
3520
4072
|
* const copy = arr.toCopy(); // safe owned copy
|
|
@@ -3540,7 +4092,7 @@ export class WasmArray {
|
|
|
3540
4092
|
wasm.__wbg_wasmarray_free(ptr, 0);
|
|
3541
4093
|
}
|
|
3542
4094
|
/**
|
|
3543
|
-
* Return the
|
|
4095
|
+
* Return the concrete float dtype string for this build.
|
|
3544
4096
|
* @returns {string}
|
|
3545
4097
|
*/
|
|
3546
4098
|
dtype() {
|
|
@@ -3556,11 +4108,11 @@ export class WasmArray {
|
|
|
3556
4108
|
}
|
|
3557
4109
|
}
|
|
3558
4110
|
/**
|
|
3559
|
-
* Create a `WasmArray` from an existing JS
|
|
4111
|
+
* Create a `WasmArray` from an existing JS float typed array.
|
|
3560
4112
|
*
|
|
3561
4113
|
* # Arguments
|
|
3562
4114
|
*
|
|
3563
|
-
* * `data` - Source `Float32Array`
|
|
4115
|
+
* * `data` - Source float typed array (`Float32Array` or `Float64Array`)
|
|
3564
4116
|
* * `shape` - Optional shape. If omitted, defaults to `[data.length]` (1D).
|
|
3565
4117
|
*
|
|
3566
4118
|
* # Returns
|
|
@@ -3574,10 +4126,10 @@ export class WasmArray {
|
|
|
3574
4126
|
* # Example (JavaScript)
|
|
3575
4127
|
*
|
|
3576
4128
|
* ```js
|
|
3577
|
-
* const arr = WasmArray.from(
|
|
4129
|
+
* const arr = WasmArray.from(floatArray, [2, 3]);
|
|
3578
4130
|
* console.log(arr.shape()); // [2, 3]
|
|
3579
4131
|
* ```
|
|
3580
|
-
* @param {
|
|
4132
|
+
* @param {Float64Array} data
|
|
3581
4133
|
* @param {Uint32Array | null} [shape]
|
|
3582
4134
|
* @returns {WasmArray}
|
|
3583
4135
|
*/
|
|
@@ -3675,7 +4227,7 @@ export class WasmArray {
|
|
|
3675
4227
|
* # Example (JavaScript)
|
|
3676
4228
|
*
|
|
3677
4229
|
* ```js
|
|
3678
|
-
* const arr = WasmArray.from(
|
|
4230
|
+
* const arr = WasmArray.from(floatArray);
|
|
3679
4231
|
* console.log(arr.sum()); // 6.0
|
|
3680
4232
|
* ```
|
|
3681
4233
|
* @returns {number}
|
|
@@ -3685,7 +4237,7 @@ export class WasmArray {
|
|
|
3685
4237
|
return ret;
|
|
3686
4238
|
}
|
|
3687
4239
|
/**
|
|
3688
|
-
* Create an owned JS
|
|
4240
|
+
* Create an owned JS float typed-array copy of the data.
|
|
3689
4241
|
*
|
|
3690
4242
|
* The returned array is an independent copy that is safe to store
|
|
3691
4243
|
* and use regardless of subsequent WASM memory operations.
|
|
@@ -3695,14 +4247,14 @@ export class WasmArray {
|
|
|
3695
4247
|
* ```js
|
|
3696
4248
|
* const copy = arr.toCopy(); // safe to keep indefinitely
|
|
3697
4249
|
* ```
|
|
3698
|
-
* @returns {
|
|
4250
|
+
* @returns {Float64Array}
|
|
3699
4251
|
*/
|
|
3700
4252
|
toCopy() {
|
|
3701
4253
|
const ret = wasm.wasmarray_toCopy(this.__wbg_ptr);
|
|
3702
4254
|
return ret;
|
|
3703
4255
|
}
|
|
3704
4256
|
/**
|
|
3705
|
-
* Zero-copy
|
|
4257
|
+
* Zero-copy float typed-array view over this array's backing storage.
|
|
3706
4258
|
*
|
|
3707
4259
|
* **Warning**: The returned view becomes **invalid** if WASM linear
|
|
3708
4260
|
* memory grows (due to any allocation). Use [`toCopy`](WasmArray::to_copy)
|
|
@@ -3710,7 +4262,8 @@ export class WasmArray {
|
|
|
3710
4262
|
*
|
|
3711
4263
|
* # Safety (internal)
|
|
3712
4264
|
*
|
|
3713
|
-
* Uses
|
|
4265
|
+
* Uses the corresponding JS float typed-array `view` constructor,
|
|
4266
|
+
* which creates an unowned view into
|
|
3714
4267
|
* WASM memory. The view must not outlive the `WasmArray` and must
|
|
3715
4268
|
* not be used after any allocation that could trigger memory growth.
|
|
3716
4269
|
*
|
|
@@ -3720,21 +4273,21 @@ export class WasmArray {
|
|
|
3720
4273
|
* const view = arr.toTypedArray(); // use immediately
|
|
3721
4274
|
* // Do NOT allocate between view creation and use
|
|
3722
4275
|
* ```
|
|
3723
|
-
* @returns {
|
|
4276
|
+
* @returns {Float64Array}
|
|
3724
4277
|
*/
|
|
3725
4278
|
toTypedArray() {
|
|
3726
4279
|
const ret = wasm.wasmarray_toTypedArray(this.__wbg_ptr);
|
|
3727
4280
|
return ret;
|
|
3728
4281
|
}
|
|
3729
4282
|
/**
|
|
3730
|
-
* Overwrite the array contents from a JS
|
|
4283
|
+
* Overwrite the array contents from a JS float typed array.
|
|
3731
4284
|
*
|
|
3732
4285
|
* The source array must have exactly the same number of elements
|
|
3733
4286
|
* as this `WasmArray` (i.e., the shape is preserved).
|
|
3734
4287
|
*
|
|
3735
4288
|
* # Arguments
|
|
3736
4289
|
*
|
|
3737
|
-
* * `arr` - Source
|
|
4290
|
+
* * `arr` - Source float typed array with matching length
|
|
3738
4291
|
*
|
|
3739
4292
|
* # Errors
|
|
3740
4293
|
*
|
|
@@ -3744,9 +4297,9 @@ export class WasmArray {
|
|
|
3744
4297
|
*
|
|
3745
4298
|
* ```js
|
|
3746
4299
|
* const wa = new WasmArray([3]);
|
|
3747
|
-
* wa.writeFrom(
|
|
4300
|
+
* wa.writeFrom(floatArray);
|
|
3748
4301
|
* ```
|
|
3749
|
-
* @param {
|
|
4302
|
+
* @param {Float64Array} arr
|
|
3750
4303
|
*/
|
|
3751
4304
|
write_from(arr) {
|
|
3752
4305
|
const ret = wasm.wasmarray_write_from(this.__wbg_ptr, arr);
|
|
@@ -3757,12 +4310,201 @@ export class WasmArray {
|
|
|
3757
4310
|
}
|
|
3758
4311
|
if (Symbol.dispose) WasmArray.prototype[Symbol.dispose] = WasmArray.prototype.free;
|
|
3759
4312
|
|
|
4313
|
+
/**
|
|
4314
|
+
* Wrapper for [`molrs_compute::kmeans::KMeans`].
|
|
4315
|
+
*
|
|
4316
|
+
* # Example (JavaScript)
|
|
4317
|
+
*
|
|
4318
|
+
* ```js
|
|
4319
|
+
* const km = new WasmKMeans(3, 100, 42);
|
|
4320
|
+
* const labels = km.fit(coords, nRows, 2); // Int32Array
|
|
4321
|
+
* ```
|
|
4322
|
+
*/
|
|
4323
|
+
export class WasmKMeans {
|
|
4324
|
+
__destroy_into_raw() {
|
|
4325
|
+
const ptr = this.__wbg_ptr;
|
|
4326
|
+
this.__wbg_ptr = 0;
|
|
4327
|
+
WasmKMeansFinalization.unregister(this);
|
|
4328
|
+
return ptr;
|
|
4329
|
+
}
|
|
4330
|
+
free() {
|
|
4331
|
+
const ptr = this.__destroy_into_raw();
|
|
4332
|
+
wasm.__wbg_wasmkmeans_free(ptr, 0);
|
|
4333
|
+
}
|
|
4334
|
+
/**
|
|
4335
|
+
* Cluster a row-major `n_rows × n_dims` coordinate matrix.
|
|
4336
|
+
*
|
|
4337
|
+
* # Returns
|
|
4338
|
+
*
|
|
4339
|
+
* Cluster labels in `0..k` as an owned `Int32Array`, one per row.
|
|
4340
|
+
*
|
|
4341
|
+
* # Errors
|
|
4342
|
+
*
|
|
4343
|
+
* Throws if `k > n_rows`, `n_dims == 0`, the length does not match
|
|
4344
|
+
* `n_rows * n_dims`, or any element is non-finite.
|
|
4345
|
+
* @param {Float64Array} coords
|
|
4346
|
+
* @param {number} n_rows
|
|
4347
|
+
* @param {number} n_dims
|
|
4348
|
+
* @returns {Int32Array}
|
|
4349
|
+
*/
|
|
4350
|
+
fit(coords, n_rows, n_dims) {
|
|
4351
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc_command_export);
|
|
4352
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4353
|
+
const ret = wasm.wasmkmeans_fit(this.__wbg_ptr, ptr0, len0, n_rows, n_dims);
|
|
4354
|
+
if (ret[2]) {
|
|
4355
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
4356
|
+
}
|
|
4357
|
+
return takeFromExternrefTable0(ret[0]);
|
|
4358
|
+
}
|
|
4359
|
+
/**
|
|
4360
|
+
* Create a new k-means configuration.
|
|
4361
|
+
*
|
|
4362
|
+
* # Arguments
|
|
4363
|
+
*
|
|
4364
|
+
* * `k` — number of clusters (>= 1).
|
|
4365
|
+
* * `max_iter` — maximum Lloyd iterations (>= 1).
|
|
4366
|
+
* * `seed` — RNG seed for k-means++ initialization. Cast to `u64`
|
|
4367
|
+
* internally (JS numbers are `f64`; integers up to 2^53 pass
|
|
4368
|
+
* through losslessly).
|
|
4369
|
+
*
|
|
4370
|
+
* # Errors
|
|
4371
|
+
*
|
|
4372
|
+
* Throws if `k == 0` or `max_iter == 0`.
|
|
4373
|
+
* @param {number} k
|
|
4374
|
+
* @param {number} max_iter
|
|
4375
|
+
* @param {number} seed
|
|
4376
|
+
*/
|
|
4377
|
+
constructor(k, max_iter, seed) {
|
|
4378
|
+
const ret = wasm.wasmkmeans_new(k, max_iter, seed);
|
|
4379
|
+
if (ret[2]) {
|
|
4380
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
4381
|
+
}
|
|
4382
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
4383
|
+
WasmKMeansFinalization.register(this, this.__wbg_ptr, this);
|
|
4384
|
+
return this;
|
|
4385
|
+
}
|
|
4386
|
+
}
|
|
4387
|
+
if (Symbol.dispose) WasmKMeans.prototype[Symbol.dispose] = WasmKMeans.prototype.free;
|
|
4388
|
+
|
|
4389
|
+
/**
|
|
4390
|
+
* Stateless wrapper for [`molrs_compute::pca::Pca2`].
|
|
4391
|
+
*
|
|
4392
|
+
* All configuration lives on [`fitTransform`](Self::fit_transform).
|
|
4393
|
+
*
|
|
4394
|
+
* # Example (JavaScript)
|
|
4395
|
+
*
|
|
4396
|
+
* ```js
|
|
4397
|
+
* const pca = new WasmPca2();
|
|
4398
|
+
* const result = pca.fitTransform(matrix, nRows, nCols);
|
|
4399
|
+
* const coords = result.coords(); // Float64Array, length 2 * nRows
|
|
4400
|
+
* const variance = result.variance(); // Float64Array, length 2
|
|
4401
|
+
* ```
|
|
4402
|
+
*/
|
|
4403
|
+
export class WasmPca2 {
|
|
4404
|
+
__destroy_into_raw() {
|
|
4405
|
+
const ptr = this.__wbg_ptr;
|
|
4406
|
+
this.__wbg_ptr = 0;
|
|
4407
|
+
WasmPca2Finalization.unregister(this);
|
|
4408
|
+
return ptr;
|
|
4409
|
+
}
|
|
4410
|
+
free() {
|
|
4411
|
+
const ptr = this.__destroy_into_raw();
|
|
4412
|
+
wasm.__wbg_wasmpca2_free(ptr, 0);
|
|
4413
|
+
}
|
|
4414
|
+
/**
|
|
4415
|
+
* Fit 2-component PCA on a row-major observation matrix and return the
|
|
4416
|
+
* projected coordinates + per-component variance.
|
|
4417
|
+
*
|
|
4418
|
+
* # Arguments
|
|
4419
|
+
*
|
|
4420
|
+
* * `matrix` — row-major `n_rows × n_cols` observation matrix.
|
|
4421
|
+
* * `n_rows` — number of observations.
|
|
4422
|
+
* * `n_cols` — number of features.
|
|
4423
|
+
*
|
|
4424
|
+
* # Errors
|
|
4425
|
+
*
|
|
4426
|
+
* Throws if `n_rows < 3`, `n_cols < 2`, the length does not match
|
|
4427
|
+
* `n_rows * n_cols`, any element is non-finite, or any column has
|
|
4428
|
+
* zero variance.
|
|
4429
|
+
* @param {Float64Array} matrix
|
|
4430
|
+
* @param {number} n_rows
|
|
4431
|
+
* @param {number} n_cols
|
|
4432
|
+
* @returns {WasmPcaResult}
|
|
4433
|
+
*/
|
|
4434
|
+
fitTransform(matrix, n_rows, n_cols) {
|
|
4435
|
+
const ptr0 = passArrayF64ToWasm0(matrix, wasm.__wbindgen_malloc_command_export);
|
|
4436
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4437
|
+
const ret = wasm.wasmpca2_fitTransform(this.__wbg_ptr, ptr0, len0, n_rows, n_cols);
|
|
4438
|
+
if (ret[2]) {
|
|
4439
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
4440
|
+
}
|
|
4441
|
+
return WasmPcaResult.__wrap(ret[0]);
|
|
4442
|
+
}
|
|
4443
|
+
/**
|
|
4444
|
+
* Create a new PCA calculator. The struct carries no state — all
|
|
4445
|
+
* parameters are supplied on [`fitTransform`](Self::fit_transform).
|
|
4446
|
+
*/
|
|
4447
|
+
constructor() {
|
|
4448
|
+
const ret = wasm.wasmpca2_new();
|
|
4449
|
+
this.__wbg_ptr = ret >>> 0;
|
|
4450
|
+
WasmPca2Finalization.register(this, this.__wbg_ptr, this);
|
|
4451
|
+
return this;
|
|
4452
|
+
}
|
|
4453
|
+
}
|
|
4454
|
+
if (Symbol.dispose) WasmPca2.prototype[Symbol.dispose] = WasmPca2.prototype.free;
|
|
4455
|
+
|
|
4456
|
+
/**
|
|
4457
|
+
* Result of a [`WasmPca2::fit_transform`] call.
|
|
4458
|
+
*
|
|
4459
|
+
* Each accessor returns an **owned** `Float64Array` (copy of the underlying
|
|
4460
|
+
* `Vec`) so JS is free to let this wrapper be GC'd without dangling views.
|
|
4461
|
+
*/
|
|
4462
|
+
export class WasmPcaResult {
|
|
4463
|
+
static __wrap(ptr) {
|
|
4464
|
+
ptr = ptr >>> 0;
|
|
4465
|
+
const obj = Object.create(WasmPcaResult.prototype);
|
|
4466
|
+
obj.__wbg_ptr = ptr;
|
|
4467
|
+
WasmPcaResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
4468
|
+
return obj;
|
|
4469
|
+
}
|
|
4470
|
+
__destroy_into_raw() {
|
|
4471
|
+
const ptr = this.__wbg_ptr;
|
|
4472
|
+
this.__wbg_ptr = 0;
|
|
4473
|
+
WasmPcaResultFinalization.unregister(this);
|
|
4474
|
+
return ptr;
|
|
4475
|
+
}
|
|
4476
|
+
free() {
|
|
4477
|
+
const ptr = this.__destroy_into_raw();
|
|
4478
|
+
wasm.__wbg_wasmpcaresult_free(ptr, 0);
|
|
4479
|
+
}
|
|
4480
|
+
/**
|
|
4481
|
+
* Projected 2D coordinates as a row-major `Float64Array` of length
|
|
4482
|
+
* `2 * n_rows`. `coords[2 * i + 0]` is the PC1 score for row `i`,
|
|
4483
|
+
* `coords[2 * i + 1]` is PC2.
|
|
4484
|
+
* @returns {Float64Array}
|
|
4485
|
+
*/
|
|
4486
|
+
coords() {
|
|
4487
|
+
const ret = wasm.wasmpcaresult_coords(this.__wbg_ptr);
|
|
4488
|
+
return ret;
|
|
4489
|
+
}
|
|
4490
|
+
/**
|
|
4491
|
+
* Explained variance per component as `Float64Array` of length 2.
|
|
4492
|
+
* `variance[0] >= variance[1]` by construction.
|
|
4493
|
+
* @returns {Float64Array}
|
|
4494
|
+
*/
|
|
4495
|
+
variance() {
|
|
4496
|
+
const ret = wasm.wasmpcaresult_variance(this.__wbg_ptr);
|
|
4497
|
+
return ret;
|
|
4498
|
+
}
|
|
4499
|
+
}
|
|
4500
|
+
if (Symbol.dispose) WasmPcaResult.prototype[Symbol.dispose] = WasmPcaResult.prototype.free;
|
|
4501
|
+
|
|
3760
4502
|
/**
|
|
3761
4503
|
* XYZ / Extended XYZ file reader.
|
|
3762
4504
|
*
|
|
3763
4505
|
* Supports multi-frame trajectory files. Each frame produces a
|
|
3764
4506
|
* [`Frame`] with an `"atoms"` block containing `element` (string)
|
|
3765
|
-
* and `x`, `y`, `z` (
|
|
4507
|
+
* and `x`, `y`, `z` (F, coordinates in angstrom) columns.
|
|
3766
4508
|
*
|
|
3767
4509
|
* # Example (JavaScript)
|
|
3768
4510
|
*
|
|
@@ -3773,7 +4515,7 @@ if (Symbol.dispose) WasmArray.prototype[Symbol.dispose] = WasmArray.prototype.fr
|
|
|
3773
4515
|
*
|
|
3774
4516
|
* const frame = reader.read(0); // first frame
|
|
3775
4517
|
* const atoms = frame.getBlock("atoms");
|
|
3776
|
-
* const x = atoms.
|
|
4518
|
+
* const x = atoms.copyColF("x");
|
|
3777
4519
|
* ```
|
|
3778
4520
|
*/
|
|
3779
4521
|
export class XYZReader {
|
|
@@ -3889,13 +4631,13 @@ if (Symbol.dispose) XYZReader.prototype[Symbol.dispose] = XYZReader.prototype.fr
|
|
|
3889
4631
|
/**
|
|
3890
4632
|
* Generate 3D coordinates for a molecular [`Frame`].
|
|
3891
4633
|
*
|
|
3892
|
-
* The input frame must have an `"atoms"` block with a `"
|
|
4634
|
+
* The input frame must have an `"atoms"` block with a `"element"`
|
|
3893
4635
|
* string column (element symbols like `"C"`, `"N"`, `"O"`). A
|
|
3894
|
-
* `"bonds"` block with `i`, `j` (u32) and `order` (
|
|
4636
|
+
* `"bonds"` block with `i`, `j` (u32) and `order` (F) columns
|
|
3895
4637
|
* is required for correct geometry.
|
|
3896
4638
|
*
|
|
3897
4639
|
* Returns a **new** [`Frame`] with 3D coordinates added as `x`, `y`,
|
|
3898
|
-
* `z` (
|
|
4640
|
+
* `z` (F, angstrom) columns in the `"atoms"` block.
|
|
3899
4641
|
*
|
|
3900
4642
|
* # Arguments
|
|
3901
4643
|
*
|
|
@@ -3928,9 +4670,9 @@ if (Symbol.dispose) XYZReader.prototype[Symbol.dispose] = XYZReader.prototype.fr
|
|
|
3928
4670
|
* const frame3d = generate3D(frame2d, "fast", 42);
|
|
3929
4671
|
*
|
|
3930
4672
|
* const atoms = frame3d.getBlock("atoms");
|
|
3931
|
-
* const x = atoms.
|
|
3932
|
-
* const y = atoms.
|
|
3933
|
-
* const z = atoms.
|
|
4673
|
+
* const x = atoms.copyColF("x"); // Float32Array or Float64Array with 3D x-coords
|
|
4674
|
+
* const y = atoms.copyColF("y");
|
|
4675
|
+
* const z = atoms.copyColF("z");
|
|
3934
4676
|
* ```
|
|
3935
4677
|
* @param {Frame} frame
|
|
3936
4678
|
* @param {string | null} [speed]
|
|
@@ -4007,7 +4749,7 @@ export function start() {
|
|
|
4007
4749
|
*
|
|
4008
4750
|
* ```js
|
|
4009
4751
|
* const mem = wasmMemory();
|
|
4010
|
-
* const buf = new
|
|
4752
|
+
* const buf = new Float64Array(mem.buffer, ptr, len); // or Float32Array in default builds
|
|
4011
4753
|
* ```
|
|
4012
4754
|
* @returns {WebAssembly.Memory}
|
|
4013
4755
|
*/
|
|
@@ -4078,18 +4820,18 @@ export function writeFrame(frame, format) {
|
|
|
4078
4820
|
wasm.__wbindgen_free_command_export(deferred3_0, deferred3_1, 1);
|
|
4079
4821
|
}
|
|
4080
4822
|
}
|
|
4081
|
-
export function
|
|
4823
|
+
export function __wbg___wbindgen_debug_string_ab4b34d23d6778bd(arg0, arg1) {
|
|
4082
4824
|
const ret = debugString(arg1);
|
|
4083
4825
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
4084
4826
|
const len1 = WASM_VECTOR_LEN;
|
|
4085
4827
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
4086
4828
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
4087
4829
|
}
|
|
4088
|
-
export function
|
|
4830
|
+
export function __wbg___wbindgen_memory_dfa12096f400c9bd() {
|
|
4089
4831
|
const ret = wasm.memory;
|
|
4090
4832
|
return ret;
|
|
4091
4833
|
}
|
|
4092
|
-
export function
|
|
4834
|
+
export function __wbg___wbindgen_string_get_7ed5322991caaec5(arg0, arg1) {
|
|
4093
4835
|
const obj = arg1;
|
|
4094
4836
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
4095
4837
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
@@ -4097,10 +4839,10 @@ export function __wbg___wbindgen_string_get_395e606bd0ee4427(arg0, arg1) {
|
|
|
4097
4839
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
4098
4840
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
4099
4841
|
}
|
|
4100
|
-
export function
|
|
4842
|
+
export function __wbg___wbindgen_throw_6b64449b9b9ed33c(arg0, arg1) {
|
|
4101
4843
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
4102
4844
|
}
|
|
4103
|
-
export function
|
|
4845
|
+
export function __wbg_done_9158f7cc8751ba32(arg0) {
|
|
4104
4846
|
const ret = arg0.done;
|
|
4105
4847
|
return ret;
|
|
4106
4848
|
}
|
|
@@ -4118,35 +4860,35 @@ export function __wbg_error_a6fa202b58aa1cd3(arg0, arg1) {
|
|
|
4118
4860
|
export function __wbg_getRandomValues_3f44b700395062e5() { return handleError(function (arg0, arg1) {
|
|
4119
4861
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
4120
4862
|
}, arguments); }
|
|
4121
|
-
export function
|
|
4863
|
+
export function __wbg_get_ef70f6ce70a05af6(arg0, arg1) {
|
|
4122
4864
|
const ret = arg0.get(arg1);
|
|
4123
4865
|
return ret;
|
|
4124
4866
|
}
|
|
4125
|
-
export function
|
|
4867
|
+
export function __wbg_get_unchecked_17f53dad852b9588(arg0, arg1) {
|
|
4126
4868
|
const ret = arg0[arg1 >>> 0];
|
|
4127
4869
|
return ret;
|
|
4128
4870
|
}
|
|
4129
|
-
export function
|
|
4871
|
+
export function __wbg_keys_7fc58fd5f4899356(arg0) {
|
|
4130
4872
|
const ret = arg0.keys();
|
|
4131
4873
|
return ret;
|
|
4132
4874
|
}
|
|
4133
|
-
export function
|
|
4875
|
+
export function __wbg_length_3d4ecd04bd8d22f1(arg0) {
|
|
4134
4876
|
const ret = arg0.length;
|
|
4135
4877
|
return ret;
|
|
4136
4878
|
}
|
|
4137
|
-
export function
|
|
4879
|
+
export function __wbg_length_7da87610a31a2ef9(arg0) {
|
|
4138
4880
|
const ret = arg0.length;
|
|
4139
4881
|
return ret;
|
|
4140
4882
|
}
|
|
4141
|
-
export function
|
|
4883
|
+
export function __wbg_length_9f1775224cf1d815(arg0) {
|
|
4142
4884
|
const ret = arg0.length;
|
|
4143
4885
|
return ret;
|
|
4144
4886
|
}
|
|
4145
|
-
export function
|
|
4887
|
+
export function __wbg_length_d807629e96c741b8(arg0) {
|
|
4146
4888
|
const ret = arg0.length;
|
|
4147
4889
|
return ret;
|
|
4148
4890
|
}
|
|
4149
|
-
export function
|
|
4891
|
+
export function __wbg_length_fab29957ea6bdb8c(arg0) {
|
|
4150
4892
|
const ret = arg0.length;
|
|
4151
4893
|
return ret;
|
|
4152
4894
|
}
|
|
@@ -4154,50 +4896,64 @@ export function __wbg_msdresult_new(arg0) {
|
|
|
4154
4896
|
const ret = MSDResult.__wrap(arg0);
|
|
4155
4897
|
return ret;
|
|
4156
4898
|
}
|
|
4157
|
-
export function
|
|
4158
|
-
const ret = new
|
|
4899
|
+
export function __wbg_new_0c7403db6e782f19(arg0) {
|
|
4900
|
+
const ret = new Uint8Array(arg0);
|
|
4159
4901
|
return ret;
|
|
4160
4902
|
}
|
|
4161
|
-
export function
|
|
4162
|
-
const ret = new
|
|
4903
|
+
export function __wbg_new_227d7c05414eb861() {
|
|
4904
|
+
const ret = new Error();
|
|
4163
4905
|
return ret;
|
|
4164
4906
|
}
|
|
4165
|
-
export function
|
|
4907
|
+
export function __wbg_new_682678e2f47e32bc() {
|
|
4166
4908
|
const ret = new Array();
|
|
4167
4909
|
return ret;
|
|
4168
4910
|
}
|
|
4169
|
-
export function
|
|
4911
|
+
export function __wbg_new_from_slice_01793f7edd3b321a(arg0, arg1) {
|
|
4170
4912
|
const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
|
|
4171
4913
|
return ret;
|
|
4172
4914
|
}
|
|
4173
|
-
export function
|
|
4915
|
+
export function __wbg_new_from_slice_3115b094b1002246(arg0, arg1) {
|
|
4916
|
+
const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
|
|
4917
|
+
return ret;
|
|
4918
|
+
}
|
|
4919
|
+
export function __wbg_new_from_slice_ede497d29b90a4ad(arg0, arg1) {
|
|
4174
4920
|
const ret = new Int32Array(getArrayI32FromWasm0(arg0, arg1));
|
|
4175
4921
|
return ret;
|
|
4176
4922
|
}
|
|
4177
|
-
export function
|
|
4178
|
-
const ret = new
|
|
4923
|
+
export function __wbg_new_with_length_33f0a4c41f7ce2fc(arg0) {
|
|
4924
|
+
const ret = new Int32Array(arg0 >>> 0);
|
|
4179
4925
|
return ret;
|
|
4180
4926
|
}
|
|
4181
|
-
export function
|
|
4927
|
+
export function __wbg_new_with_length_5cfd777b51078805(arg0) {
|
|
4928
|
+
const ret = new Float64Array(arg0 >>> 0);
|
|
4929
|
+
return ret;
|
|
4930
|
+
}
|
|
4931
|
+
export function __wbg_next_0340c4ae324393c3() { return handleError(function (arg0) {
|
|
4182
4932
|
const ret = arg0.next();
|
|
4183
4933
|
return ret;
|
|
4184
4934
|
}, arguments); }
|
|
4185
|
-
export function
|
|
4186
|
-
Float32Array.prototype.set.call(getArrayF32FromWasm0(arg0, arg1), arg2);
|
|
4187
|
-
}
|
|
4188
|
-
export function __wbg_prototypesetcall_52ca14fb142bc37b(arg0, arg1, arg2) {
|
|
4189
|
-
Int32Array.prototype.set.call(getArrayI32FromWasm0(arg0, arg1), arg2);
|
|
4190
|
-
}
|
|
4191
|
-
export function __wbg_prototypesetcall_d62e5099504357e6(arg0, arg1, arg2) {
|
|
4935
|
+
export function __wbg_prototypesetcall_a6b02eb00b0f4ce2(arg0, arg1, arg2) {
|
|
4192
4936
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
4193
4937
|
}
|
|
4194
|
-
export function
|
|
4938
|
+
export function __wbg_prototypesetcall_c5875dab42ff6b97(arg0, arg1, arg2) {
|
|
4939
|
+
Float64Array.prototype.set.call(getArrayF64FromWasm0(arg0, arg1), arg2);
|
|
4940
|
+
}
|
|
4941
|
+
export function __wbg_prototypesetcall_d412f763861ea165(arg0, arg1, arg2) {
|
|
4195
4942
|
Uint32Array.prototype.set.call(getArrayU32FromWasm0(arg0, arg1), arg2);
|
|
4196
4943
|
}
|
|
4197
|
-
export function
|
|
4944
|
+
export function __wbg_prototypesetcall_db677c7a1d7d3039(arg0, arg1, arg2) {
|
|
4945
|
+
Int32Array.prototype.set.call(getArrayI32FromWasm0(arg0, arg1), arg2);
|
|
4946
|
+
}
|
|
4947
|
+
export function __wbg_push_471a5b068a5295f6(arg0, arg1) {
|
|
4198
4948
|
const ret = arg0.push(arg1);
|
|
4199
4949
|
return ret;
|
|
4200
4950
|
}
|
|
4951
|
+
export function __wbg_set_5637e648df81c8e5(arg0, arg1, arg2) {
|
|
4952
|
+
arg0.set(getArrayF64FromWasm0(arg1, arg2));
|
|
4953
|
+
}
|
|
4954
|
+
export function __wbg_set_6c7215e0274bbbf2(arg0, arg1, arg2) {
|
|
4955
|
+
arg0.set(getArrayI32FromWasm0(arg1, arg2));
|
|
4956
|
+
}
|
|
4201
4957
|
export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
|
|
4202
4958
|
const ret = arg1.stack;
|
|
4203
4959
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
@@ -4205,13 +4961,13 @@ export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
|
|
|
4205
4961
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
4206
4962
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
4207
4963
|
}
|
|
4208
|
-
export function
|
|
4964
|
+
export function __wbg_value_ee3a06f4579184fa(arg0) {
|
|
4209
4965
|
const ret = arg0.value;
|
|
4210
4966
|
return ret;
|
|
4211
4967
|
}
|
|
4212
4968
|
export function __wbindgen_cast_0000000000000001(arg0, arg1) {
|
|
4213
|
-
// Cast intrinsic for `Ref(Slice(
|
|
4214
|
-
const ret =
|
|
4969
|
+
// Cast intrinsic for `Ref(Slice(F64)) -> NamedExternref("Float64Array")`.
|
|
4970
|
+
const ret = getArrayF64FromWasm0(arg0, arg1);
|
|
4215
4971
|
return ret;
|
|
4216
4972
|
}
|
|
4217
4973
|
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
@@ -4262,6 +5018,9 @@ const ClusterResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
4262
5018
|
const FrameFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4263
5019
|
? { register: () => {}, unregister: () => {} }
|
|
4264
5020
|
: new FinalizationRegistry(ptr => wasm.__wbg_frame_free(ptr >>> 0, 1));
|
|
5021
|
+
const GridFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
5022
|
+
? { register: () => {}, unregister: () => {} }
|
|
5023
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_grid_free(ptr >>> 0, 1));
|
|
4265
5024
|
const GyrationTensorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4266
5025
|
? { register: () => {}, unregister: () => {} }
|
|
4267
5026
|
: new FinalizationRegistry(ptr => wasm.__wbg_gyrationtensor_free(ptr >>> 0, 1));
|
|
@@ -4283,6 +5042,9 @@ const MSDFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
4283
5042
|
const MSDResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4284
5043
|
? { register: () => {}, unregister: () => {} }
|
|
4285
5044
|
: new FinalizationRegistry(ptr => wasm.__wbg_msdresult_free(ptr >>> 0, 1));
|
|
5045
|
+
const MolRecReaderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
5046
|
+
? { register: () => {}, unregister: () => {} }
|
|
5047
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_molrecreader_free(ptr >>> 0, 1));
|
|
4286
5048
|
const NeighborListFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4287
5049
|
? { register: () => {}, unregister: () => {} }
|
|
4288
5050
|
: new FinalizationRegistry(ptr => wasm.__wbg_neighborlist_free(ptr >>> 0, 1));
|
|
@@ -4298,15 +5060,24 @@ const RDFResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
4298
5060
|
const RadiusOfGyrationFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4299
5061
|
? { register: () => {}, unregister: () => {} }
|
|
4300
5062
|
: new FinalizationRegistry(ptr => wasm.__wbg_radiusofgyration_free(ptr >>> 0, 1));
|
|
4301
|
-
const
|
|
5063
|
+
const SDFReaderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4302
5064
|
? { register: () => {}, unregister: () => {} }
|
|
4303
|
-
: new FinalizationRegistry(ptr => wasm.
|
|
5065
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_sdfreader_free(ptr >>> 0, 1));
|
|
4304
5066
|
const TopologyRingInfoFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4305
5067
|
? { register: () => {}, unregister: () => {} }
|
|
4306
5068
|
: new FinalizationRegistry(ptr => wasm.__wbg_topologyringinfo_free(ptr >>> 0, 1));
|
|
4307
5069
|
const WasmArrayFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4308
5070
|
? { register: () => {}, unregister: () => {} }
|
|
4309
5071
|
: new FinalizationRegistry(ptr => wasm.__wbg_wasmarray_free(ptr >>> 0, 1));
|
|
5072
|
+
const WasmKMeansFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
5073
|
+
? { register: () => {}, unregister: () => {} }
|
|
5074
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmkmeans_free(ptr >>> 0, 1));
|
|
5075
|
+
const WasmPca2Finalization = (typeof FinalizationRegistry === 'undefined')
|
|
5076
|
+
? { register: () => {}, unregister: () => {} }
|
|
5077
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmpca2_free(ptr >>> 0, 1));
|
|
5078
|
+
const WasmPcaResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
5079
|
+
? { register: () => {}, unregister: () => {} }
|
|
5080
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmpcaresult_free(ptr >>> 0, 1));
|
|
4310
5081
|
const SmilesIRFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
4311
5082
|
? { register: () => {}, unregister: () => {} }
|
|
4312
5083
|
: new FinalizationRegistry(ptr => wasm.__wbg_smilesir_free(ptr >>> 0, 1));
|
|
@@ -4394,9 +5165,9 @@ function debugString(val) {
|
|
|
4394
5165
|
return className;
|
|
4395
5166
|
}
|
|
4396
5167
|
|
|
4397
|
-
function
|
|
5168
|
+
function getArrayF64FromWasm0(ptr, len) {
|
|
4398
5169
|
ptr = ptr >>> 0;
|
|
4399
|
-
return
|
|
5170
|
+
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
4400
5171
|
}
|
|
4401
5172
|
|
|
4402
5173
|
function getArrayI32FromWasm0(ptr, len) {
|
|
@@ -4433,12 +5204,12 @@ function getDataViewMemory0() {
|
|
|
4433
5204
|
return cachedDataViewMemory0;
|
|
4434
5205
|
}
|
|
4435
5206
|
|
|
4436
|
-
let
|
|
4437
|
-
function
|
|
4438
|
-
if (
|
|
4439
|
-
|
|
5207
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
5208
|
+
function getFloat64ArrayMemory0() {
|
|
5209
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
5210
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
4440
5211
|
}
|
|
4441
|
-
return
|
|
5212
|
+
return cachedFloat64ArrayMemory0;
|
|
4442
5213
|
}
|
|
4443
5214
|
|
|
4444
5215
|
let cachedInt32ArrayMemory0 = null;
|
|
@@ -4490,9 +5261,9 @@ function passArray32ToWasm0(arg, malloc) {
|
|
|
4490
5261
|
return ptr;
|
|
4491
5262
|
}
|
|
4492
5263
|
|
|
4493
|
-
function
|
|
4494
|
-
const ptr = malloc(arg.length *
|
|
4495
|
-
|
|
5264
|
+
function passArrayF64ToWasm0(arg, malloc) {
|
|
5265
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
5266
|
+
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
4496
5267
|
WASM_VECTOR_LEN = arg.length;
|
|
4497
5268
|
return ptr;
|
|
4498
5269
|
}
|