@molcrafts/molrs 0.0.4 → 0.0.5
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 +60 -46
- package/molrs.d.ts +153 -255
- package/molrs.js +1 -1
- package/molrs_bg.js +220 -377
- package/molrs_bg.wasm +0 -0
- package/package.json +1 -1
package/molrs_bg.js
CHANGED
|
@@ -1,133 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Axis-aligned bounding box spatial query for neighbor search.
|
|
3
|
-
*
|
|
4
|
-
* Builds a cell-list spatial index from a [`Frame`]'s atom positions
|
|
5
|
-
* and simulation box, then supports both self-queries (unique pairs
|
|
6
|
-
* within the reference set) and cross-queries (pairs between a
|
|
7
|
-
* query set and the reference set).
|
|
8
|
-
*
|
|
9
|
-
* All distances are in angstrom (A).
|
|
10
|
-
*
|
|
11
|
-
* # Example (JavaScript)
|
|
12
|
-
*
|
|
13
|
-
* ```js
|
|
14
|
-
* const nq = new AABBQuery(frame, 3.0); // cutoff = 3.0 A
|
|
15
|
-
* const selfPairs = nq.querySelf(); // unique pairs (i < j)
|
|
16
|
-
* const crossPairs = nq.query(otherFrame); // cross-query
|
|
17
|
-
*
|
|
18
|
-
* console.log(selfPairs.numPairs);
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export class AABBQuery {
|
|
22
|
-
__destroy_into_raw() {
|
|
23
|
-
const ptr = this.__wbg_ptr;
|
|
24
|
-
this.__wbg_ptr = 0;
|
|
25
|
-
AABBQueryFinalization.unregister(this);
|
|
26
|
-
return ptr;
|
|
27
|
-
}
|
|
28
|
-
free() {
|
|
29
|
-
const ptr = this.__destroy_into_raw();
|
|
30
|
-
wasm.__wbg_aabbquery_free(ptr, 0);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Create a spatial query from a [`Frame`] with a given distance cutoff.
|
|
34
|
-
*
|
|
35
|
-
* The frame must have:
|
|
36
|
-
* - An `"atoms"` block with `x`, `y`, `z` (f32) columns
|
|
37
|
-
* - A `simbox` (simulation box) set on the frame
|
|
38
|
-
*
|
|
39
|
-
* # Arguments
|
|
40
|
-
*
|
|
41
|
-
* * `frame` - Reference frame with atom positions and simbox
|
|
42
|
-
* * `cutoff` - Maximum neighbor distance in angstrom (A)
|
|
43
|
-
*
|
|
44
|
-
* # Returns
|
|
45
|
-
*
|
|
46
|
-
* A new `AABBQuery` ready for `query()` or `querySelf()`.
|
|
47
|
-
*
|
|
48
|
-
* # Errors
|
|
49
|
-
*
|
|
50
|
-
* Throws if the frame has no `"atoms"` block, is missing `x`/`y`/`z`
|
|
51
|
-
* columns, or has no `simbox`.
|
|
52
|
-
*
|
|
53
|
-
* # Example (JavaScript)
|
|
54
|
-
*
|
|
55
|
-
* ```js
|
|
56
|
-
* const nq = new AABBQuery(frame, 5.0);
|
|
57
|
-
* ```
|
|
58
|
-
* @param {Frame} frame
|
|
59
|
-
* @param {number} cutoff
|
|
60
|
-
*/
|
|
61
|
-
constructor(frame, cutoff) {
|
|
62
|
-
_assertClass(frame, Frame);
|
|
63
|
-
const ret = wasm.aabbquery_new(frame.__wbg_ptr, cutoff);
|
|
64
|
-
if (ret[2]) {
|
|
65
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
66
|
-
}
|
|
67
|
-
this.__wbg_ptr = ret[0] >>> 0;
|
|
68
|
-
AABBQueryFinalization.register(this, this.__wbg_ptr, this);
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Cross-query: find all pairs where `i` indexes query points and
|
|
73
|
-
* `j` indexes the reference points (from the constructor frame).
|
|
74
|
-
*
|
|
75
|
-
* # Arguments
|
|
76
|
-
*
|
|
77
|
-
* * `query_frame` - Frame with query atom positions (must have
|
|
78
|
-
* `"atoms"` block with `x`, `y`, `z` columns)
|
|
79
|
-
*
|
|
80
|
-
* # Returns
|
|
81
|
-
*
|
|
82
|
-
* A [`NeighborList`] containing all `(i, j, distance)` pairs
|
|
83
|
-
* within the cutoff.
|
|
84
|
-
*
|
|
85
|
-
* # Errors
|
|
86
|
-
*
|
|
87
|
-
* Throws if `query_frame` is missing required columns.
|
|
88
|
-
*
|
|
89
|
-
* # Example (JavaScript)
|
|
90
|
-
*
|
|
91
|
-
* ```js
|
|
92
|
-
* const crossPairs = nq.query(otherFrame);
|
|
93
|
-
* console.log(crossPairs.numPairs);
|
|
94
|
-
* ```
|
|
95
|
-
* @param {Frame} query_frame
|
|
96
|
-
* @returns {NeighborList}
|
|
97
|
-
*/
|
|
98
|
-
query(query_frame) {
|
|
99
|
-
_assertClass(query_frame, Frame);
|
|
100
|
-
const ret = wasm.aabbquery_query(this.__wbg_ptr, query_frame.__wbg_ptr);
|
|
101
|
-
if (ret[2]) {
|
|
102
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
103
|
-
}
|
|
104
|
-
return NeighborList.__wrap(ret[0]);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Self-query: find all unique pairs `(i < j)` within the reference
|
|
108
|
-
* point set (the frame used to construct this query).
|
|
109
|
-
*
|
|
110
|
-
* # Returns
|
|
111
|
-
*
|
|
112
|
-
* A [`NeighborList`] containing all unique pairs within the cutoff.
|
|
113
|
-
* The `isSelfQuery` property will be `true`.
|
|
114
|
-
*
|
|
115
|
-
* # Example (JavaScript)
|
|
116
|
-
*
|
|
117
|
-
* ```js
|
|
118
|
-
* const pairs = nq.querySelf();
|
|
119
|
-
* console.log(pairs.isSelfQuery); // true
|
|
120
|
-
* console.log(pairs.numPairs); // number of unique pairs
|
|
121
|
-
* ```
|
|
122
|
-
* @returns {NeighborList}
|
|
123
|
-
*/
|
|
124
|
-
querySelf() {
|
|
125
|
-
const ret = wasm.aabbquery_querySelf(this.__wbg_ptr);
|
|
126
|
-
return NeighborList.__wrap(ret);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
if (Symbol.dispose) AABBQuery.prototype[Symbol.dispose] = AABBQuery.prototype.free;
|
|
130
|
-
|
|
131
1
|
/**
|
|
132
2
|
* Column-oriented data store with typed arrays.
|
|
133
3
|
*
|
|
@@ -142,7 +12,7 @@ if (Symbol.dispose) AABBQuery.prototype[Symbol.dispose] = AABBQuery.prototype.fr
|
|
|
142
12
|
* | `Float32Array` | `f32` | `"f32"` | `setColF32` | `copyColF32` | `viewColF32` |
|
|
143
13
|
* | `Int32Array` | `i32` | `"i32"` | `setColI32` | `copyColI32` | `viewColI32` |
|
|
144
14
|
* | `Uint32Array` | `u32` | `"u32"` | `setColU32` | `copyColU32` | `viewColU32` |
|
|
145
|
-
* | `
|
|
15
|
+
* | `string[]` | `String` | `"string"` | `setColStr` | `copyColStr` | -- |
|
|
146
16
|
*
|
|
147
17
|
* # Example (JavaScript)
|
|
148
18
|
*
|
|
@@ -239,7 +109,7 @@ export class Block {
|
|
|
239
109
|
return takeFromExternrefTable0(ret[0]);
|
|
240
110
|
}
|
|
241
111
|
/**
|
|
242
|
-
* Owned `
|
|
112
|
+
* Owned `string[]` copy of a string column.
|
|
243
113
|
*
|
|
244
114
|
* # Arguments
|
|
245
115
|
*
|
|
@@ -344,7 +214,7 @@ export class Block {
|
|
|
344
214
|
* # Example (JavaScript)
|
|
345
215
|
*
|
|
346
216
|
* ```js
|
|
347
|
-
* if (block.isEmpty()) {
|
|
217
|
+
* if (block.isEmpty()) { // no columns yet }
|
|
348
218
|
* ```
|
|
349
219
|
* @returns {boolean}
|
|
350
220
|
*/
|
|
@@ -356,7 +226,7 @@ export class Block {
|
|
|
356
226
|
return ret[0] !== 0;
|
|
357
227
|
}
|
|
358
228
|
/**
|
|
359
|
-
* Return all column names as a JS `
|
|
229
|
+
* Return all column names as a JS `string[]`.
|
|
360
230
|
*
|
|
361
231
|
* # Errors
|
|
362
232
|
*
|
|
@@ -549,7 +419,7 @@ export class Block {
|
|
|
549
419
|
}
|
|
550
420
|
}
|
|
551
421
|
/**
|
|
552
|
-
* Set a string column from a JS `
|
|
422
|
+
* Set a string column from a JS `string[]`.
|
|
553
423
|
*
|
|
554
424
|
* # Arguments
|
|
555
425
|
*
|
|
@@ -1290,8 +1160,8 @@ if (Symbol.dispose) Box.prototype[Symbol.dispose] = Box.prototype.free;
|
|
|
1290
1160
|
* # Example (JavaScript)
|
|
1291
1161
|
*
|
|
1292
1162
|
* ```js
|
|
1293
|
-
* const
|
|
1294
|
-
* const nlist =
|
|
1163
|
+
* const lc = new LinkedCell(2.0);
|
|
1164
|
+
* const nlist = lc.build(frame);
|
|
1295
1165
|
*
|
|
1296
1166
|
* const cluster = new Cluster(5); // min 5 particles per cluster
|
|
1297
1167
|
* const result = cluster.compute(frame, nlist);
|
|
@@ -1936,117 +1806,255 @@ export class LAMMPSReader {
|
|
|
1936
1806
|
if (Symbol.dispose) LAMMPSReader.prototype[Symbol.dispose] = LAMMPSReader.prototype.free;
|
|
1937
1807
|
|
|
1938
1808
|
/**
|
|
1939
|
-
*
|
|
1809
|
+
* Cell-list (linked-cell) based neighbor search.
|
|
1940
1810
|
*
|
|
1941
|
-
*
|
|
1942
|
-
*
|
|
1943
|
-
*
|
|
1811
|
+
* Creates a spatial index from a [`Frame`]'s atom positions and
|
|
1812
|
+
* simulation box, then finds all neighbor pairs within the cutoff
|
|
1813
|
+
* distance.
|
|
1944
1814
|
*
|
|
1945
|
-
* All distances are in angstrom (A)
|
|
1815
|
+
* All distances are in angstrom (A).
|
|
1946
1816
|
*
|
|
1947
1817
|
* # Example (JavaScript)
|
|
1948
1818
|
*
|
|
1949
1819
|
* ```js
|
|
1950
|
-
* const
|
|
1820
|
+
* const lc = new LinkedCell(3.0); // cutoff = 3.0 A
|
|
1821
|
+
* const nlist = lc.build(frame); // self-query (unique pairs i < j)
|
|
1822
|
+
* const cross = lc.query(ref, other); // cross-query
|
|
1951
1823
|
*
|
|
1952
|
-
*
|
|
1953
|
-
* const frame = reader.read(t);
|
|
1954
|
-
* const result = msd.compute(frame);
|
|
1955
|
-
* console.log(`t=${t}: MSD = ${result.mean} A^2`);
|
|
1956
|
-
* }
|
|
1824
|
+
* console.log(nlist.numPairs);
|
|
1957
1825
|
* ```
|
|
1958
|
-
*
|
|
1959
|
-
* # References
|
|
1960
|
-
*
|
|
1961
|
-
* - Einstein, A. (1905). *Annalen der Physik*, 322(8), 549-560.
|
|
1962
1826
|
*/
|
|
1963
|
-
export class
|
|
1964
|
-
static __wrap(ptr) {
|
|
1965
|
-
ptr = ptr >>> 0;
|
|
1966
|
-
const obj = Object.create(MSD.prototype);
|
|
1967
|
-
obj.__wbg_ptr = ptr;
|
|
1968
|
-
MSDFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1969
|
-
return obj;
|
|
1970
|
-
}
|
|
1827
|
+
export class LinkedCell {
|
|
1971
1828
|
__destroy_into_raw() {
|
|
1972
1829
|
const ptr = this.__wbg_ptr;
|
|
1973
1830
|
this.__wbg_ptr = 0;
|
|
1974
|
-
|
|
1831
|
+
LinkedCellFinalization.unregister(this);
|
|
1975
1832
|
return ptr;
|
|
1976
1833
|
}
|
|
1977
1834
|
free() {
|
|
1978
1835
|
const ptr = this.__destroy_into_raw();
|
|
1979
|
-
wasm.
|
|
1836
|
+
wasm.__wbg_linkedcell_free(ptr, 0);
|
|
1980
1837
|
}
|
|
1981
1838
|
/**
|
|
1982
|
-
*
|
|
1839
|
+
* Build a neighbor list from a [`Frame`] (self-query).
|
|
1840
|
+
*
|
|
1841
|
+
* Finds all unique pairs `(i < j)` of atoms within the cutoff
|
|
1842
|
+
* distance using the cell-list algorithm.
|
|
1843
|
+
*
|
|
1844
|
+
* The frame must have an `"atoms"` block with `x`, `y`, `z` (f32) columns.
|
|
1845
|
+
* If the frame has a `simbox`, periodic boundary conditions are used.
|
|
1846
|
+
* Otherwise, a free-boundary bounding box is auto-generated.
|
|
1983
1847
|
*
|
|
1984
1848
|
* # Arguments
|
|
1985
1849
|
*
|
|
1986
|
-
* * `frame` -
|
|
1987
|
-
* `x`, `y`, `z` (f32) columns
|
|
1850
|
+
* * `frame` - Frame with atom positions
|
|
1988
1851
|
*
|
|
1989
1852
|
* # Returns
|
|
1990
1853
|
*
|
|
1991
|
-
*
|
|
1992
|
-
* values in A^2.
|
|
1854
|
+
* A [`NeighborList`] containing all unique pairs within the cutoff.
|
|
1993
1855
|
*
|
|
1994
1856
|
* # Errors
|
|
1995
1857
|
*
|
|
1996
|
-
* Throws if the frame is missing required
|
|
1858
|
+
* Throws if the frame is missing required data.
|
|
1997
1859
|
*
|
|
1998
1860
|
* # Example (JavaScript)
|
|
1999
1861
|
*
|
|
2000
1862
|
* ```js
|
|
2001
|
-
* const
|
|
2002
|
-
*
|
|
1863
|
+
* const lc = new LinkedCell(3.0);
|
|
1864
|
+
* const nlist = lc.build(frame);
|
|
1865
|
+
* const dists = nlist.distances(); // Float32Array
|
|
2003
1866
|
* ```
|
|
2004
1867
|
* @param {Frame} frame
|
|
2005
|
-
* @returns {
|
|
1868
|
+
* @returns {NeighborList}
|
|
2006
1869
|
*/
|
|
2007
|
-
|
|
1870
|
+
build(frame) {
|
|
2008
1871
|
_assertClass(frame, Frame);
|
|
2009
|
-
const ret = wasm.
|
|
1872
|
+
const ret = wasm.linkedcell_build(this.__wbg_ptr, frame.__wbg_ptr);
|
|
2010
1873
|
if (ret[2]) {
|
|
2011
1874
|
throw takeFromExternrefTable0(ret[1]);
|
|
2012
1875
|
}
|
|
2013
|
-
return
|
|
1876
|
+
return NeighborList.__wrap(ret[0]);
|
|
2014
1877
|
}
|
|
2015
1878
|
/**
|
|
2016
|
-
* Create
|
|
1879
|
+
* Create a linked-cell neighbor search with the given distance cutoff.
|
|
1880
|
+
*
|
|
1881
|
+
* # Arguments
|
|
1882
|
+
*
|
|
1883
|
+
* * `cutoff` - Maximum neighbor distance in angstrom (A)
|
|
1884
|
+
*
|
|
1885
|
+
* # Example (JavaScript)
|
|
2017
1886
|
*
|
|
2018
|
-
*
|
|
2019
|
-
*
|
|
2020
|
-
*
|
|
1887
|
+
* ```js
|
|
1888
|
+
* const lc = new LinkedCell(5.0);
|
|
1889
|
+
* ```
|
|
1890
|
+
* @param {number} cutoff
|
|
1891
|
+
*/
|
|
1892
|
+
constructor(cutoff) {
|
|
1893
|
+
const ret = wasm.linkedcell_new(cutoff);
|
|
1894
|
+
this.__wbg_ptr = ret >>> 0;
|
|
1895
|
+
LinkedCellFinalization.register(this, this.__wbg_ptr, this);
|
|
1896
|
+
return this;
|
|
1897
|
+
}
|
|
1898
|
+
/**
|
|
1899
|
+
* Cross-query: find all pairs where `i` indexes query points and
|
|
1900
|
+
* `j` indexes the reference points.
|
|
2021
1901
|
*
|
|
2022
1902
|
* # Arguments
|
|
2023
1903
|
*
|
|
2024
|
-
* * `ref_frame` -
|
|
2025
|
-
*
|
|
1904
|
+
* * `ref_frame` - Frame with reference atom positions
|
|
1905
|
+
* * `query_frame` - Frame with query atom positions (must have
|
|
1906
|
+
* `"atoms"` block with `x`, `y`, `z` columns)
|
|
2026
1907
|
*
|
|
2027
1908
|
* # Returns
|
|
2028
1909
|
*
|
|
2029
|
-
* A
|
|
1910
|
+
* A [`NeighborList`] containing all `(i, j, distance)` pairs
|
|
1911
|
+
* within the cutoff.
|
|
2030
1912
|
*
|
|
2031
1913
|
* # Errors
|
|
2032
1914
|
*
|
|
2033
|
-
* Throws if
|
|
1915
|
+
* Throws if either frame is missing required columns.
|
|
2034
1916
|
*
|
|
2035
1917
|
* # Example (JavaScript)
|
|
2036
1918
|
*
|
|
2037
1919
|
* ```js
|
|
2038
|
-
* const
|
|
1920
|
+
* const lc = new LinkedCell(3.0);
|
|
1921
|
+
* const crossPairs = lc.query(refFrame, otherFrame);
|
|
1922
|
+
* console.log(crossPairs.numPairs);
|
|
2039
1923
|
* ```
|
|
2040
1924
|
* @param {Frame} ref_frame
|
|
2041
|
-
* @
|
|
1925
|
+
* @param {Frame} query_frame
|
|
1926
|
+
* @returns {NeighborList}
|
|
2042
1927
|
*/
|
|
2043
|
-
|
|
1928
|
+
query(ref_frame, query_frame) {
|
|
2044
1929
|
_assertClass(ref_frame, Frame);
|
|
2045
|
-
|
|
1930
|
+
_assertClass(query_frame, Frame);
|
|
1931
|
+
const ret = wasm.linkedcell_query(this.__wbg_ptr, ref_frame.__wbg_ptr, query_frame.__wbg_ptr);
|
|
2046
1932
|
if (ret[2]) {
|
|
2047
1933
|
throw takeFromExternrefTable0(ret[1]);
|
|
2048
1934
|
}
|
|
2049
|
-
return
|
|
1935
|
+
return NeighborList.__wrap(ret[0]);
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
if (Symbol.dispose) LinkedCell.prototype[Symbol.dispose] = LinkedCell.prototype.free;
|
|
1939
|
+
|
|
1940
|
+
/**
|
|
1941
|
+
* Mean squared displacement (MSD) analysis.
|
|
1942
|
+
*
|
|
1943
|
+
* Computes MSD = |r(t) - r(0)|^2 for each particle and the system
|
|
1944
|
+
* average. The first frame fed is automatically used as the reference.
|
|
1945
|
+
* Useful for measuring diffusion coefficients via D = MSD / (6t).
|
|
1946
|
+
*
|
|
1947
|
+
* All distances are in angstrom (A), so MSD is in A^2.
|
|
1948
|
+
*
|
|
1949
|
+
* # Example (JavaScript)
|
|
1950
|
+
*
|
|
1951
|
+
* ```js
|
|
1952
|
+
* const msd = new MSD();
|
|
1953
|
+
* for (const frame of trajectory) {
|
|
1954
|
+
* msd.feed(frame); // first frame = reference
|
|
1955
|
+
* }
|
|
1956
|
+
* const results = msd.results(); // MSDResult[] per frame
|
|
1957
|
+
* console.log(results[10].mean); // MSD at frame 10 in A^2
|
|
1958
|
+
* ```
|
|
1959
|
+
*
|
|
1960
|
+
* # References
|
|
1961
|
+
*
|
|
1962
|
+
* - Einstein, A. (1905). *Annalen der Physik*, 322(8), 549-560.
|
|
1963
|
+
*/
|
|
1964
|
+
export class MSD {
|
|
1965
|
+
__destroy_into_raw() {
|
|
1966
|
+
const ptr = this.__wbg_ptr;
|
|
1967
|
+
this.__wbg_ptr = 0;
|
|
1968
|
+
MSDFinalization.unregister(this);
|
|
1969
|
+
return ptr;
|
|
1970
|
+
}
|
|
1971
|
+
free() {
|
|
1972
|
+
const ptr = this.__destroy_into_raw();
|
|
1973
|
+
wasm.__wbg_msd_free(ptr, 0);
|
|
1974
|
+
}
|
|
1975
|
+
/**
|
|
1976
|
+
* Number of frames accumulated.
|
|
1977
|
+
* @returns {number}
|
|
1978
|
+
*/
|
|
1979
|
+
get count() {
|
|
1980
|
+
const ret = wasm.msd_count(this.__wbg_ptr);
|
|
1981
|
+
return ret >>> 0;
|
|
1982
|
+
}
|
|
1983
|
+
/**
|
|
1984
|
+
* Feed a frame into the MSD analysis.
|
|
1985
|
+
*
|
|
1986
|
+
* The first frame sets the reference configuration.
|
|
1987
|
+
* Subsequent frames compute MSD relative to that reference.
|
|
1988
|
+
*
|
|
1989
|
+
* # Arguments
|
|
1990
|
+
*
|
|
1991
|
+
* * `frame` - Frame with `"atoms"` block containing
|
|
1992
|
+
* `x`, `y`, `z` (f32) columns
|
|
1993
|
+
*
|
|
1994
|
+
* # Errors
|
|
1995
|
+
*
|
|
1996
|
+
* Throws if the frame is missing required columns or has a
|
|
1997
|
+
* different number of atoms than the reference.
|
|
1998
|
+
*
|
|
1999
|
+
* # Example (JavaScript)
|
|
2000
|
+
*
|
|
2001
|
+
* ```js
|
|
2002
|
+
* const msd = new MSD();
|
|
2003
|
+
* msd.feed(frame0); // sets reference
|
|
2004
|
+
* msd.feed(frame1); // computes MSD vs frame0
|
|
2005
|
+
* ```
|
|
2006
|
+
* @param {Frame} frame
|
|
2007
|
+
*/
|
|
2008
|
+
feed(frame) {
|
|
2009
|
+
_assertClass(frame, Frame);
|
|
2010
|
+
const ret = wasm.msd_feed(this.__wbg_ptr, frame.__wbg_ptr);
|
|
2011
|
+
if (ret[1]) {
|
|
2012
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
/**
|
|
2016
|
+
* Create an empty MSD analysis.
|
|
2017
|
+
*
|
|
2018
|
+
* The first frame passed to [`feed`] becomes the reference
|
|
2019
|
+
* configuration (t=0).
|
|
2020
|
+
*
|
|
2021
|
+
* # Example (JavaScript)
|
|
2022
|
+
*
|
|
2023
|
+
* ```js
|
|
2024
|
+
* const msd = new MSD();
|
|
2025
|
+
* ```
|
|
2026
|
+
*/
|
|
2027
|
+
constructor() {
|
|
2028
|
+
const ret = wasm.msd_new();
|
|
2029
|
+
this.__wbg_ptr = ret >>> 0;
|
|
2030
|
+
MSDFinalization.register(this, this.__wbg_ptr, this);
|
|
2031
|
+
return this;
|
|
2032
|
+
}
|
|
2033
|
+
/**
|
|
2034
|
+
* Reset the analysis, clearing reference and all results.
|
|
2035
|
+
*/
|
|
2036
|
+
reset() {
|
|
2037
|
+
wasm.msd_reset(this.__wbg_ptr);
|
|
2038
|
+
}
|
|
2039
|
+
/**
|
|
2040
|
+
* Return all accumulated MSD results as an array.
|
|
2041
|
+
*
|
|
2042
|
+
* Returns one [`MSDResult`] per frame fed (including the
|
|
2043
|
+
* reference frame, which has MSD = 0).
|
|
2044
|
+
*
|
|
2045
|
+
* # Example (JavaScript)
|
|
2046
|
+
*
|
|
2047
|
+
* ```js
|
|
2048
|
+
* const results = msd.results();
|
|
2049
|
+
* results.forEach((r, t) => console.log(`t=${t}: MSD=${r.mean}`));
|
|
2050
|
+
* ```
|
|
2051
|
+
* @returns {MSDResult[]}
|
|
2052
|
+
*/
|
|
2053
|
+
results() {
|
|
2054
|
+
const ret = wasm.msd_results(this.__wbg_ptr);
|
|
2055
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
2056
|
+
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
2057
|
+
return v1;
|
|
2050
2058
|
}
|
|
2051
2059
|
}
|
|
2052
2060
|
if (Symbol.dispose) MSD.prototype[Symbol.dispose] = MSD.prototype.free;
|
|
@@ -2111,9 +2119,8 @@ if (Symbol.dispose) MSDResult.prototype[Symbol.dispose] = MSDResult.prototype.fr
|
|
|
2111
2119
|
* Result of a neighbor search: all atom pairs within a distance cutoff.
|
|
2112
2120
|
*
|
|
2113
2121
|
* Contains pair indices, distances, and squared distances for every
|
|
2114
|
-
* neighbor pair found. This object is produced by [`
|
|
2115
|
-
*
|
|
2116
|
-
* and [`Cluster`].
|
|
2122
|
+
* neighbor pair found. This object is produced by [`LinkedCell`]
|
|
2123
|
+
* and consumed by analysis classes like [`RDF`] and [`Cluster`].
|
|
2117
2124
|
*
|
|
2118
2125
|
* # Properties
|
|
2119
2126
|
*
|
|
@@ -2127,7 +2134,7 @@ if (Symbol.dispose) MSDResult.prototype[Symbol.dispose] = MSDResult.prototype.fr
|
|
|
2127
2134
|
* # Example (JavaScript)
|
|
2128
2135
|
*
|
|
2129
2136
|
* ```js
|
|
2130
|
-
* const nlist =
|
|
2137
|
+
* const nlist = lc.build(frame);
|
|
2131
2138
|
* console.log(nlist.numPairs);
|
|
2132
2139
|
*
|
|
2133
2140
|
* const i = nlist.queryPointIndices(); // Uint32Array
|
|
@@ -2180,31 +2187,7 @@ export class NeighborList {
|
|
|
2180
2187
|
return v1;
|
|
2181
2188
|
}
|
|
2182
2189
|
/**
|
|
2183
|
-
*
|
|
2184
|
-
*
|
|
2185
|
-
* First particle index per pair as `Uint32Array`.
|
|
2186
|
-
* @returns {Uint32Array}
|
|
2187
|
-
*/
|
|
2188
|
-
idxI() {
|
|
2189
|
-
const ret = wasm.neighborlist_idxI(this.__wbg_ptr);
|
|
2190
|
-
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
2191
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
2192
|
-
return v1;
|
|
2193
|
-
}
|
|
2194
|
-
/**
|
|
2195
|
-
* **Deprecated**: Use `pointIndices()` instead.
|
|
2196
|
-
*
|
|
2197
|
-
* Second particle index per pair as `Uint32Array`.
|
|
2198
|
-
* @returns {Uint32Array}
|
|
2199
|
-
*/
|
|
2200
|
-
idxJ() {
|
|
2201
|
-
const ret = wasm.neighborlist_idxJ(this.__wbg_ptr);
|
|
2202
|
-
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
2203
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
2204
|
-
return v1;
|
|
2205
|
-
}
|
|
2206
|
-
/**
|
|
2207
|
-
* Whether this result came from a self-query (`querySelf()`).
|
|
2190
|
+
* Whether this result came from a self-query (`build()`).
|
|
2208
2191
|
*
|
|
2209
2192
|
* In self-queries, only unique pairs `(i < j)` are reported.
|
|
2210
2193
|
* @returns {boolean}
|
|
@@ -2265,154 +2248,6 @@ export class NeighborList {
|
|
|
2265
2248
|
}
|
|
2266
2249
|
if (Symbol.dispose) NeighborList.prototype[Symbol.dispose] = NeighborList.prototype.free;
|
|
2267
2250
|
|
|
2268
|
-
/**
|
|
2269
|
-
* **Deprecated**: backward-compatible alias for [`NeighborList`].
|
|
2270
|
-
*
|
|
2271
|
-
* Use [`NeighborList`] instead. This type is kept only for API
|
|
2272
|
-
* compatibility with older code.
|
|
2273
|
-
*/
|
|
2274
|
-
export class NeighborResult {
|
|
2275
|
-
__destroy_into_raw() {
|
|
2276
|
-
const ptr = this.__wbg_ptr;
|
|
2277
|
-
this.__wbg_ptr = 0;
|
|
2278
|
-
NeighborResultFinalization.unregister(this);
|
|
2279
|
-
return ptr;
|
|
2280
|
-
}
|
|
2281
|
-
free() {
|
|
2282
|
-
const ptr = this.__destroy_into_raw();
|
|
2283
|
-
wasm.__wbg_neighborresult_free(ptr, 0);
|
|
2284
|
-
}
|
|
2285
|
-
/**
|
|
2286
|
-
* Squared pairwise distances in A^2 as `Float32Array`.
|
|
2287
|
-
* @returns {Float32Array}
|
|
2288
|
-
*/
|
|
2289
|
-
distSq() {
|
|
2290
|
-
const ret = wasm.neighborresult_distSq(this.__wbg_ptr);
|
|
2291
|
-
var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
2292
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
2293
|
-
return v1;
|
|
2294
|
-
}
|
|
2295
|
-
/**
|
|
2296
|
-
* First particle index per pair as `Uint32Array`.
|
|
2297
|
-
* @returns {Uint32Array}
|
|
2298
|
-
*/
|
|
2299
|
-
idxI() {
|
|
2300
|
-
const ret = wasm.neighborresult_idxI(this.__wbg_ptr);
|
|
2301
|
-
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
2302
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
2303
|
-
return v1;
|
|
2304
|
-
}
|
|
2305
|
-
/**
|
|
2306
|
-
* Second particle index per pair as `Uint32Array`.
|
|
2307
|
-
* @returns {Uint32Array}
|
|
2308
|
-
*/
|
|
2309
|
-
idxJ() {
|
|
2310
|
-
const ret = wasm.neighborresult_idxJ(this.__wbg_ptr);
|
|
2311
|
-
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
2312
|
-
wasm.__wbindgen_free_command_export(ret[0], ret[1] * 4, 4);
|
|
2313
|
-
return v1;
|
|
2314
|
-
}
|
|
2315
|
-
/**
|
|
2316
|
-
* Total number of neighbor pairs found.
|
|
2317
|
-
* @returns {number}
|
|
2318
|
-
*/
|
|
2319
|
-
get numPairs() {
|
|
2320
|
-
const ret = wasm.neighborresult_numPairs(this.__wbg_ptr);
|
|
2321
|
-
return ret >>> 0;
|
|
2322
|
-
}
|
|
2323
|
-
}
|
|
2324
|
-
if (Symbol.dispose) NeighborResult.prototype[Symbol.dispose] = NeighborResult.prototype.free;
|
|
2325
|
-
|
|
2326
|
-
/**
|
|
2327
|
-
* Neighbor search using the cell-list (link-cell) algorithm.
|
|
2328
|
-
*
|
|
2329
|
-
* This is a simpler, backward-compatible interface compared to
|
|
2330
|
-
* [`AABBQuery`]. It performs a self-query in a single `build()` call.
|
|
2331
|
-
*
|
|
2332
|
-
* Prefer [`AABBQuery`] for more flexibility (cross-queries, reusable
|
|
2333
|
-
* spatial index).
|
|
2334
|
-
*
|
|
2335
|
-
* # Example (JavaScript)
|
|
2336
|
-
*
|
|
2337
|
-
* ```js
|
|
2338
|
-
* const ns = new NeighborSearch(3.0); // cutoff = 3.0 A
|
|
2339
|
-
* const nbrs = ns.build(frame);
|
|
2340
|
-
* console.log(nbrs.numPairs);
|
|
2341
|
-
* ```
|
|
2342
|
-
*/
|
|
2343
|
-
export class NeighborSearch {
|
|
2344
|
-
__destroy_into_raw() {
|
|
2345
|
-
const ptr = this.__wbg_ptr;
|
|
2346
|
-
this.__wbg_ptr = 0;
|
|
2347
|
-
NeighborSearchFinalization.unregister(this);
|
|
2348
|
-
return ptr;
|
|
2349
|
-
}
|
|
2350
|
-
free() {
|
|
2351
|
-
const ptr = this.__destroy_into_raw();
|
|
2352
|
-
wasm.__wbg_neighborsearch_free(ptr, 0);
|
|
2353
|
-
}
|
|
2354
|
-
/**
|
|
2355
|
-
* Build a neighbor list from a [`Frame`].
|
|
2356
|
-
*
|
|
2357
|
-
* Performs a self-query: finds all unique pairs `(i < j)` of atoms
|
|
2358
|
-
* within the cutoff distance, using the cell-list algorithm.
|
|
2359
|
-
*
|
|
2360
|
-
* The frame must have:
|
|
2361
|
-
* - An `"atoms"` block with `x`, `y`, `z` (f32) columns
|
|
2362
|
-
* - A `simbox` (simulation box) set on the frame
|
|
2363
|
-
*
|
|
2364
|
-
* # Arguments
|
|
2365
|
-
*
|
|
2366
|
-
* * `frame` - Frame with atom positions and simbox
|
|
2367
|
-
*
|
|
2368
|
-
* # Returns
|
|
2369
|
-
*
|
|
2370
|
-
* A [`NeighborList`] containing all pairs within the cutoff.
|
|
2371
|
-
*
|
|
2372
|
-
* # Errors
|
|
2373
|
-
*
|
|
2374
|
-
* Throws if the frame is missing required data.
|
|
2375
|
-
*
|
|
2376
|
-
* # Example (JavaScript)
|
|
2377
|
-
*
|
|
2378
|
-
* ```js
|
|
2379
|
-
* const nbrs = ns.build(frame);
|
|
2380
|
-
* const dists = nbrs.distances(); // Float32Array
|
|
2381
|
-
* ```
|
|
2382
|
-
* @param {Frame} frame
|
|
2383
|
-
* @returns {NeighborList}
|
|
2384
|
-
*/
|
|
2385
|
-
build(frame) {
|
|
2386
|
-
_assertClass(frame, Frame);
|
|
2387
|
-
const ret = wasm.neighborsearch_build(this.__wbg_ptr, frame.__wbg_ptr);
|
|
2388
|
-
if (ret[2]) {
|
|
2389
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
2390
|
-
}
|
|
2391
|
-
return NeighborList.__wrap(ret[0]);
|
|
2392
|
-
}
|
|
2393
|
-
/**
|
|
2394
|
-
* Create a neighbor search with the given distance cutoff.
|
|
2395
|
-
*
|
|
2396
|
-
* # Arguments
|
|
2397
|
-
*
|
|
2398
|
-
* * `cutoff` - Maximum neighbor distance in angstrom (A)
|
|
2399
|
-
*
|
|
2400
|
-
* # Example (JavaScript)
|
|
2401
|
-
*
|
|
2402
|
-
* ```js
|
|
2403
|
-
* const ns = new NeighborSearch(5.0);
|
|
2404
|
-
* ```
|
|
2405
|
-
* @param {number} cutoff
|
|
2406
|
-
*/
|
|
2407
|
-
constructor(cutoff) {
|
|
2408
|
-
const ret = wasm.neighborsearch_new(cutoff);
|
|
2409
|
-
this.__wbg_ptr = ret >>> 0;
|
|
2410
|
-
NeighborSearchFinalization.register(this, this.__wbg_ptr, this);
|
|
2411
|
-
return this;
|
|
2412
|
-
}
|
|
2413
|
-
}
|
|
2414
|
-
if (Symbol.dispose) NeighborSearch.prototype[Symbol.dispose] = NeighborSearch.prototype.free;
|
|
2415
|
-
|
|
2416
2251
|
/**
|
|
2417
2252
|
* Protein Data Bank (PDB) file reader.
|
|
2418
2253
|
*
|
|
@@ -2547,8 +2382,8 @@ if (Symbol.dispose) PDBReader.prototype[Symbol.dispose] = PDBReader.prototype.fr
|
|
|
2547
2382
|
* # Example (JavaScript)
|
|
2548
2383
|
*
|
|
2549
2384
|
* ```js
|
|
2550
|
-
* const
|
|
2551
|
-
* const nlist =
|
|
2385
|
+
* const lc = new LinkedCell(5.0);
|
|
2386
|
+
* const nlist = lc.build(frame);
|
|
2552
2387
|
*
|
|
2553
2388
|
* const rdf = new RDF(100, 5.0);
|
|
2554
2389
|
* const result = rdf.compute(frame, nlist);
|
|
@@ -2577,8 +2412,7 @@ export class RDF {
|
|
|
2577
2412
|
* # Arguments
|
|
2578
2413
|
*
|
|
2579
2414
|
* * `frame` - Frame with a `simbox` set (for volume normalization)
|
|
2580
|
-
* * `neighbors` - Pre-built [`NeighborList`] from [`
|
|
2581
|
-
* or [`NeighborSearch`]
|
|
2415
|
+
* * `neighbors` - Pre-built [`NeighborList`] from [`LinkedCell`]
|
|
2582
2416
|
*
|
|
2583
2417
|
* # Returns
|
|
2584
2418
|
*
|
|
@@ -3634,6 +3468,10 @@ export function __wbg_length_ea16607d7b61445b(arg0) {
|
|
|
3634
3468
|
const ret = arg0.length;
|
|
3635
3469
|
return ret;
|
|
3636
3470
|
}
|
|
3471
|
+
export function __wbg_msdresult_new(arg0) {
|
|
3472
|
+
const ret = MSDResult.__wrap(arg0);
|
|
3473
|
+
return ret;
|
|
3474
|
+
}
|
|
3637
3475
|
export function __wbg_new_227d7c05414eb861() {
|
|
3638
3476
|
const ret = new Error();
|
|
3639
3477
|
return ret;
|
|
@@ -3718,9 +3556,6 @@ export function __wbindgen_init_externref_table() {
|
|
|
3718
3556
|
table.set(offset + 2, true);
|
|
3719
3557
|
table.set(offset + 3, false);
|
|
3720
3558
|
}
|
|
3721
|
-
const AABBQueryFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3722
|
-
? { register: () => {}, unregister: () => {} }
|
|
3723
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_aabbquery_free(ptr >>> 0, 1));
|
|
3724
3559
|
const BlockFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3725
3560
|
? { register: () => {}, unregister: () => {} }
|
|
3726
3561
|
: new FinalizationRegistry(ptr => wasm.__wbg_block_free(ptr >>> 0, 1));
|
|
@@ -3739,6 +3574,9 @@ const FrameFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
3739
3574
|
const LAMMPSReaderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3740
3575
|
? { register: () => {}, unregister: () => {} }
|
|
3741
3576
|
: new FinalizationRegistry(ptr => wasm.__wbg_lammpsreader_free(ptr >>> 0, 1));
|
|
3577
|
+
const LinkedCellFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3578
|
+
? { register: () => {}, unregister: () => {} }
|
|
3579
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_linkedcell_free(ptr >>> 0, 1));
|
|
3742
3580
|
const MSDFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3743
3581
|
? { register: () => {}, unregister: () => {} }
|
|
3744
3582
|
: new FinalizationRegistry(ptr => wasm.__wbg_msd_free(ptr >>> 0, 1));
|
|
@@ -3748,12 +3586,6 @@ const MSDResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
3748
3586
|
const NeighborListFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3749
3587
|
? { register: () => {}, unregister: () => {} }
|
|
3750
3588
|
: new FinalizationRegistry(ptr => wasm.__wbg_neighborlist_free(ptr >>> 0, 1));
|
|
3751
|
-
const NeighborResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3752
|
-
? { register: () => {}, unregister: () => {} }
|
|
3753
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_neighborresult_free(ptr >>> 0, 1));
|
|
3754
|
-
const NeighborSearchFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3755
|
-
? { register: () => {}, unregister: () => {} }
|
|
3756
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_neighborsearch_free(ptr >>> 0, 1));
|
|
3757
3589
|
const PDBReaderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3758
3590
|
? { register: () => {}, unregister: () => {} }
|
|
3759
3591
|
: new FinalizationRegistry(ptr => wasm.__wbg_pdbreader_free(ptr >>> 0, 1));
|
|
@@ -3863,6 +3695,17 @@ function getArrayI32FromWasm0(ptr, len) {
|
|
|
3863
3695
|
return getInt32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
3864
3696
|
}
|
|
3865
3697
|
|
|
3698
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
3699
|
+
ptr = ptr >>> 0;
|
|
3700
|
+
const mem = getDataViewMemory0();
|
|
3701
|
+
const result = [];
|
|
3702
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
3703
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
3704
|
+
}
|
|
3705
|
+
wasm.__externref_drop_slice_command_export(ptr, len);
|
|
3706
|
+
return result;
|
|
3707
|
+
}
|
|
3708
|
+
|
|
3866
3709
|
function getArrayU32FromWasm0(ptr, len) {
|
|
3867
3710
|
ptr = ptr >>> 0;
|
|
3868
3711
|
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|