@molcrafts/molrs 0.0.4 → 0.0.6
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/README.md
CHANGED
|
@@ -1,72 +1,86 @@
|
|
|
1
|
-
# molrs
|
|
1
|
+
# @molcrafts/molrs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@molcrafts/molrs)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
WebAssembly bindings for the [molrs](https://github.com/MolCrafts/molrs) molecular modeling toolkit.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
|
-
|
|
9
|
-
bash scripts/postprocess-pkg.sh
|
|
10
|
+
npm install @molcrafts/molrs
|
|
10
11
|
```
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
## Quick start
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
```js
|
|
16
|
+
import init, { parseSMILES, generate3D, writeFrame } from "@molcrafts/molrs";
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
await init();
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
// Parse SMILES → 3D coordinates → XYZ string
|
|
21
|
+
const ir = parseSMILES("CCO");
|
|
22
|
+
const frame = ir.toFrame();
|
|
23
|
+
const mol3d = generate3D(frame, "fast");
|
|
24
|
+
console.log(writeFrame(mol3d, "xyz"));
|
|
25
|
+
```
|
|
21
26
|
|
|
22
|
-
|
|
27
|
+
## API
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
const atoms = frame.createBlock("atoms");
|
|
26
|
-
atoms.set("x", new Float32Array([0.0, 1.0, 2.0]));
|
|
29
|
+
### Data model
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
- **`Frame`** — container mapping string keys (`"atoms"`, `"bonds"`) to `Block`s
|
|
32
|
+
- **`Block`** — column store with typed arrays (`Float32Array`, `Int32Array`, `Uint32Array`, `string[]`)
|
|
33
|
+
- **`Box`** — simulation box with periodic boundary conditions
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
console.log(xyz);
|
|
33
|
-
```
|
|
35
|
+
### I/O
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
- `parseSMILES(smiles)` → `SmilesIR` → `.toFrame()`
|
|
38
|
+
- `XYZReader`, `PDBReader`, `LAMMPSReader` — file format parsers
|
|
39
|
+
- `writeFrame(frame, "xyz" | "pdb")` — serialize to string
|
|
40
|
+
- `SimulationReader` — Zarr V3 trajectory reader
|
|
36
41
|
|
|
37
|
-
|
|
38
|
-
import init, { Frame, WasmArray, XyzReader, writeFrame } from "./pkg/molwasm.js";
|
|
39
|
-
import { typedArrayView, columnViewMeta } from "./pkg/typed-views.js";
|
|
42
|
+
### 3D generation
|
|
40
43
|
|
|
41
|
-
|
|
44
|
+
- `generate3D(frame, speed?)` — MMFF94 coordinate generation (`"fast"` | `"normal"` | `"thorough"`)
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
const atoms = frame.createBlock("atoms");
|
|
45
|
-
atoms.set("x", new Float32Array([0.0, 1.0, 2.0]));
|
|
46
|
+
### Analysis
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const xTypedArray = typedArrayView(xView); // Float32Array | Uint32Array | Uint8Array
|
|
50
|
-
const xMeta = columnViewMeta(xView);
|
|
48
|
+
```js
|
|
49
|
+
import { LinkedCell, RDF } from "@molcrafts/molrs";
|
|
51
50
|
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
|
|
51
|
+
const lc = new LinkedCell(5.0); // cutoff = 5.0 A
|
|
52
|
+
const nlist = lc.build(frame); // self-query (unique pairs i < j)
|
|
53
|
+
const cross = lc.query(refFrame, other); // cross-query
|
|
54
|
+
|
|
55
|
+
const rdf = new RDF(100, 5.0);
|
|
56
|
+
const result = rdf.compute(frame, nlist);
|
|
57
|
+
console.log(result.binCenters(), result.rdf());
|
|
56
58
|
```
|
|
57
59
|
|
|
58
|
-
|
|
60
|
+
- **`LinkedCell`** — cell-list neighbor search (`build()` for self-query, `query()` for cross-query)
|
|
61
|
+
- **`RDF`** — radial distribution function (periodic and free-boundary)
|
|
62
|
+
- **`MSD`** — mean squared displacement
|
|
63
|
+
- **`Cluster`** — distance-based cluster analysis
|
|
64
|
+
|
|
65
|
+
Frames without a simulation box are supported — a non-periodic bounding box is auto-generated.
|
|
66
|
+
|
|
67
|
+
### Block column conventions
|
|
59
68
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
| Block | Column | Type | Description |
|
|
70
|
+
|-------|--------|------|-------------|
|
|
71
|
+
| `atoms` | `symbol` | `string` | Element symbol |
|
|
72
|
+
| `atoms` | `x`, `y`, `z` | `f32` | Cartesian coordinates |
|
|
73
|
+
| `atoms` | `mass` | `f32` | Atomic mass |
|
|
74
|
+
| `atoms` | `charge` | `f32` | Partial charge |
|
|
75
|
+
| `bonds` | `i`, `j` | `u32` | Atom indices |
|
|
76
|
+
| `bonds` | `order` | `f32` | Bond order (1.0, 1.5, 2.0, 3.0) |
|
|
66
77
|
|
|
67
|
-
##
|
|
78
|
+
## Build from source
|
|
68
79
|
|
|
69
80
|
```bash
|
|
70
|
-
|
|
71
|
-
wasm-pack test --node
|
|
81
|
+
wasm-pack build --target bundler --scope molcrafts --out-name molrs
|
|
72
82
|
```
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
BSD-3-Clause
|
package/molrs.d.ts
CHANGED
|
@@ -1,103 +1,6 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Axis-aligned bounding box spatial query for neighbor search.
|
|
6
|
-
*
|
|
7
|
-
* Builds a cell-list spatial index from a [`Frame`]'s atom positions
|
|
8
|
-
* and simulation box, then supports both self-queries (unique pairs
|
|
9
|
-
* within the reference set) and cross-queries (pairs between a
|
|
10
|
-
* query set and the reference set).
|
|
11
|
-
*
|
|
12
|
-
* All distances are in angstrom (A).
|
|
13
|
-
*
|
|
14
|
-
* # Example (JavaScript)
|
|
15
|
-
*
|
|
16
|
-
* ```js
|
|
17
|
-
* const nq = new AABBQuery(frame, 3.0); // cutoff = 3.0 A
|
|
18
|
-
* const selfPairs = nq.querySelf(); // unique pairs (i < j)
|
|
19
|
-
* const crossPairs = nq.query(otherFrame); // cross-query
|
|
20
|
-
*
|
|
21
|
-
* console.log(selfPairs.numPairs);
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export class AABBQuery {
|
|
25
|
-
free(): void;
|
|
26
|
-
[Symbol.dispose](): void;
|
|
27
|
-
/**
|
|
28
|
-
* Create a spatial query from a [`Frame`] with a given distance cutoff.
|
|
29
|
-
*
|
|
30
|
-
* The frame must have:
|
|
31
|
-
* - An `"atoms"` block with `x`, `y`, `z` (f32) columns
|
|
32
|
-
* - A `simbox` (simulation box) set on the frame
|
|
33
|
-
*
|
|
34
|
-
* # Arguments
|
|
35
|
-
*
|
|
36
|
-
* * `frame` - Reference frame with atom positions and simbox
|
|
37
|
-
* * `cutoff` - Maximum neighbor distance in angstrom (A)
|
|
38
|
-
*
|
|
39
|
-
* # Returns
|
|
40
|
-
*
|
|
41
|
-
* A new `AABBQuery` ready for `query()` or `querySelf()`.
|
|
42
|
-
*
|
|
43
|
-
* # Errors
|
|
44
|
-
*
|
|
45
|
-
* Throws if the frame has no `"atoms"` block, is missing `x`/`y`/`z`
|
|
46
|
-
* columns, or has no `simbox`.
|
|
47
|
-
*
|
|
48
|
-
* # Example (JavaScript)
|
|
49
|
-
*
|
|
50
|
-
* ```js
|
|
51
|
-
* const nq = new AABBQuery(frame, 5.0);
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
constructor(frame: Frame, cutoff: number);
|
|
55
|
-
/**
|
|
56
|
-
* Cross-query: find all pairs where `i` indexes query points and
|
|
57
|
-
* `j` indexes the reference points (from the constructor frame).
|
|
58
|
-
*
|
|
59
|
-
* # Arguments
|
|
60
|
-
*
|
|
61
|
-
* * `query_frame` - Frame with query atom positions (must have
|
|
62
|
-
* `"atoms"` block with `x`, `y`, `z` columns)
|
|
63
|
-
*
|
|
64
|
-
* # Returns
|
|
65
|
-
*
|
|
66
|
-
* A [`NeighborList`] containing all `(i, j, distance)` pairs
|
|
67
|
-
* within the cutoff.
|
|
68
|
-
*
|
|
69
|
-
* # Errors
|
|
70
|
-
*
|
|
71
|
-
* Throws if `query_frame` is missing required columns.
|
|
72
|
-
*
|
|
73
|
-
* # Example (JavaScript)
|
|
74
|
-
*
|
|
75
|
-
* ```js
|
|
76
|
-
* const crossPairs = nq.query(otherFrame);
|
|
77
|
-
* console.log(crossPairs.numPairs);
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
query(query_frame: Frame): NeighborList;
|
|
81
|
-
/**
|
|
82
|
-
* Self-query: find all unique pairs `(i < j)` within the reference
|
|
83
|
-
* point set (the frame used to construct this query).
|
|
84
|
-
*
|
|
85
|
-
* # Returns
|
|
86
|
-
*
|
|
87
|
-
* A [`NeighborList`] containing all unique pairs within the cutoff.
|
|
88
|
-
* The `isSelfQuery` property will be `true`.
|
|
89
|
-
*
|
|
90
|
-
* # Example (JavaScript)
|
|
91
|
-
*
|
|
92
|
-
* ```js
|
|
93
|
-
* const pairs = nq.querySelf();
|
|
94
|
-
* console.log(pairs.isSelfQuery); // true
|
|
95
|
-
* console.log(pairs.numPairs); // number of unique pairs
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
querySelf(): NeighborList;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
4
|
/**
|
|
102
5
|
* Column-oriented data store with typed arrays.
|
|
103
6
|
*
|
|
@@ -112,7 +15,7 @@ export class AABBQuery {
|
|
|
112
15
|
* | `Float32Array` | `f32` | `"f32"` | `setColF32` | `copyColF32` | `viewColF32` |
|
|
113
16
|
* | `Int32Array` | `i32` | `"i32"` | `setColI32` | `copyColI32` | `viewColI32` |
|
|
114
17
|
* | `Uint32Array` | `u32` | `"u32"` | `setColU32` | `copyColU32` | `viewColU32` |
|
|
115
|
-
* | `
|
|
18
|
+
* | `string[]` | `String` | `"string"` | `setColStr` | `copyColStr` | -- |
|
|
116
19
|
*
|
|
117
20
|
* # Example (JavaScript)
|
|
118
21
|
*
|
|
@@ -174,7 +77,7 @@ export class Block {
|
|
|
174
77
|
*/
|
|
175
78
|
copyColI32(key: string): Int32Array;
|
|
176
79
|
/**
|
|
177
|
-
* Owned `
|
|
80
|
+
* Owned `string[]` copy of a string column.
|
|
178
81
|
*
|
|
179
82
|
* # Arguments
|
|
180
83
|
*
|
|
@@ -247,12 +150,12 @@ export class Block {
|
|
|
247
150
|
* # Example (JavaScript)
|
|
248
151
|
*
|
|
249
152
|
* ```js
|
|
250
|
-
* if (block.isEmpty()) {
|
|
153
|
+
* if (block.isEmpty()) { // no columns yet }
|
|
251
154
|
* ```
|
|
252
155
|
*/
|
|
253
156
|
isEmpty(): boolean;
|
|
254
157
|
/**
|
|
255
|
-
* Return all column names as a JS `
|
|
158
|
+
* Return all column names as a JS `string[]`.
|
|
256
159
|
*
|
|
257
160
|
* # Errors
|
|
258
161
|
*
|
|
@@ -382,7 +285,7 @@ export class Block {
|
|
|
382
285
|
*/
|
|
383
286
|
setColI32(key: string, data: Int32Array): void;
|
|
384
287
|
/**
|
|
385
|
-
* Set a string column from a JS `
|
|
288
|
+
* Set a string column from a JS `string[]`.
|
|
386
289
|
*
|
|
387
290
|
* # Arguments
|
|
388
291
|
*
|
|
@@ -911,8 +814,8 @@ export class Box {
|
|
|
911
814
|
* # Example (JavaScript)
|
|
912
815
|
*
|
|
913
816
|
* ```js
|
|
914
|
-
* const
|
|
915
|
-
* const nlist =
|
|
817
|
+
* const lc = new LinkedCell(2.0);
|
|
818
|
+
* const nlist = lc.build(frame);
|
|
916
819
|
*
|
|
917
820
|
* const cluster = new Cluster(5); // min 5 particles per cluster
|
|
918
821
|
* const result = cluster.compute(frame, nlist);
|
|
@@ -1350,86 +1253,189 @@ export class LAMMPSReader {
|
|
|
1350
1253
|
}
|
|
1351
1254
|
|
|
1352
1255
|
/**
|
|
1353
|
-
*
|
|
1256
|
+
* Cell-list (linked-cell) based neighbor search.
|
|
1354
1257
|
*
|
|
1355
|
-
*
|
|
1356
|
-
*
|
|
1357
|
-
*
|
|
1258
|
+
* Creates a spatial index from a [`Frame`]'s atom positions and
|
|
1259
|
+
* simulation box, then finds all neighbor pairs within the cutoff
|
|
1260
|
+
* distance.
|
|
1358
1261
|
*
|
|
1359
|
-
* All distances are in angstrom (A)
|
|
1262
|
+
* All distances are in angstrom (A).
|
|
1360
1263
|
*
|
|
1361
1264
|
* # Example (JavaScript)
|
|
1362
1265
|
*
|
|
1363
1266
|
* ```js
|
|
1364
|
-
* const
|
|
1267
|
+
* const lc = new LinkedCell(3.0); // cutoff = 3.0 A
|
|
1268
|
+
* const nlist = lc.build(frame); // self-query (unique pairs i < j)
|
|
1269
|
+
* const cross = lc.query(ref, other); // cross-query
|
|
1365
1270
|
*
|
|
1366
|
-
*
|
|
1367
|
-
* const frame = reader.read(t);
|
|
1368
|
-
* const result = msd.compute(frame);
|
|
1369
|
-
* console.log(`t=${t}: MSD = ${result.mean} A^2`);
|
|
1370
|
-
* }
|
|
1271
|
+
* console.log(nlist.numPairs);
|
|
1371
1272
|
* ```
|
|
1372
|
-
*
|
|
1373
|
-
* # References
|
|
1374
|
-
*
|
|
1375
|
-
* - Einstein, A. (1905). *Annalen der Physik*, 322(8), 549-560.
|
|
1376
1273
|
*/
|
|
1377
|
-
export class
|
|
1378
|
-
private constructor();
|
|
1274
|
+
export class LinkedCell {
|
|
1379
1275
|
free(): void;
|
|
1380
1276
|
[Symbol.dispose](): void;
|
|
1381
1277
|
/**
|
|
1382
|
-
*
|
|
1278
|
+
* Build a neighbor list from a [`Frame`] (self-query).
|
|
1279
|
+
*
|
|
1280
|
+
* Finds all unique pairs `(i < j)` of atoms within the cutoff
|
|
1281
|
+
* distance using the cell-list algorithm.
|
|
1282
|
+
*
|
|
1283
|
+
* The frame must have an `"atoms"` block with `x`, `y`, `z` (f32) columns.
|
|
1284
|
+
* If the frame has a `simbox`, periodic boundary conditions are used.
|
|
1285
|
+
* Otherwise, a free-boundary bounding box is auto-generated.
|
|
1383
1286
|
*
|
|
1384
1287
|
* # Arguments
|
|
1385
1288
|
*
|
|
1386
|
-
* * `frame` -
|
|
1387
|
-
* `x`, `y`, `z` (f32) columns
|
|
1289
|
+
* * `frame` - Frame with atom positions
|
|
1388
1290
|
*
|
|
1389
1291
|
* # Returns
|
|
1390
1292
|
*
|
|
1391
|
-
*
|
|
1392
|
-
* values in A^2.
|
|
1293
|
+
* A [`NeighborList`] containing all unique pairs within the cutoff.
|
|
1393
1294
|
*
|
|
1394
1295
|
* # Errors
|
|
1395
1296
|
*
|
|
1396
|
-
* Throws if the frame is missing required
|
|
1297
|
+
* Throws if the frame is missing required data.
|
|
1397
1298
|
*
|
|
1398
1299
|
* # Example (JavaScript)
|
|
1399
1300
|
*
|
|
1400
1301
|
* ```js
|
|
1401
|
-
* const
|
|
1402
|
-
*
|
|
1302
|
+
* const lc = new LinkedCell(3.0);
|
|
1303
|
+
* const nlist = lc.build(frame);
|
|
1304
|
+
* const dists = nlist.distances(); // Float32Array
|
|
1403
1305
|
* ```
|
|
1404
1306
|
*/
|
|
1405
|
-
|
|
1307
|
+
build(frame: Frame): NeighborList;
|
|
1406
1308
|
/**
|
|
1407
|
-
* Create
|
|
1309
|
+
* Create a linked-cell neighbor search with the given distance cutoff.
|
|
1310
|
+
*
|
|
1311
|
+
* # Arguments
|
|
1408
1312
|
*
|
|
1409
|
-
*
|
|
1410
|
-
*
|
|
1411
|
-
*
|
|
1313
|
+
* * `cutoff` - Maximum neighbor distance in angstrom (A)
|
|
1314
|
+
*
|
|
1315
|
+
* # Example (JavaScript)
|
|
1316
|
+
*
|
|
1317
|
+
* ```js
|
|
1318
|
+
* const lc = new LinkedCell(5.0);
|
|
1319
|
+
* ```
|
|
1320
|
+
*/
|
|
1321
|
+
constructor(cutoff: number);
|
|
1322
|
+
/**
|
|
1323
|
+
* Cross-query: find all pairs where `i` indexes query points and
|
|
1324
|
+
* `j` indexes the reference points.
|
|
1412
1325
|
*
|
|
1413
1326
|
* # Arguments
|
|
1414
1327
|
*
|
|
1415
|
-
* * `ref_frame` -
|
|
1416
|
-
*
|
|
1328
|
+
* * `ref_frame` - Frame with reference atom positions
|
|
1329
|
+
* * `query_frame` - Frame with query atom positions (must have
|
|
1330
|
+
* `"atoms"` block with `x`, `y`, `z` columns)
|
|
1417
1331
|
*
|
|
1418
1332
|
* # Returns
|
|
1419
1333
|
*
|
|
1420
|
-
* A
|
|
1334
|
+
* A [`NeighborList`] containing all `(i, j, distance)` pairs
|
|
1335
|
+
* within the cutoff.
|
|
1336
|
+
*
|
|
1337
|
+
* # Errors
|
|
1338
|
+
*
|
|
1339
|
+
* Throws if either frame is missing required columns.
|
|
1340
|
+
*
|
|
1341
|
+
* # Example (JavaScript)
|
|
1342
|
+
*
|
|
1343
|
+
* ```js
|
|
1344
|
+
* const lc = new LinkedCell(3.0);
|
|
1345
|
+
* const crossPairs = lc.query(refFrame, otherFrame);
|
|
1346
|
+
* console.log(crossPairs.numPairs);
|
|
1347
|
+
* ```
|
|
1348
|
+
*/
|
|
1349
|
+
query(ref_frame: Frame, query_frame: Frame): NeighborList;
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
/**
|
|
1353
|
+
* Mean squared displacement (MSD) analysis.
|
|
1354
|
+
*
|
|
1355
|
+
* Computes MSD = |r(t) - r(0)|^2 for each particle and the system
|
|
1356
|
+
* average. The first frame fed is automatically used as the reference.
|
|
1357
|
+
* Useful for measuring diffusion coefficients via D = MSD / (6t).
|
|
1358
|
+
*
|
|
1359
|
+
* All distances are in angstrom (A), so MSD is in A^2.
|
|
1360
|
+
*
|
|
1361
|
+
* # Example (JavaScript)
|
|
1362
|
+
*
|
|
1363
|
+
* ```js
|
|
1364
|
+
* const msd = new MSD();
|
|
1365
|
+
* for (const frame of trajectory) {
|
|
1366
|
+
* msd.feed(frame); // first frame = reference
|
|
1367
|
+
* }
|
|
1368
|
+
* const results = msd.results(); // MSDResult[] per frame
|
|
1369
|
+
* console.log(results[10].mean); // MSD at frame 10 in A^2
|
|
1370
|
+
* ```
|
|
1371
|
+
*
|
|
1372
|
+
* # References
|
|
1373
|
+
*
|
|
1374
|
+
* - Einstein, A. (1905). *Annalen der Physik*, 322(8), 549-560.
|
|
1375
|
+
*/
|
|
1376
|
+
export class MSD {
|
|
1377
|
+
free(): void;
|
|
1378
|
+
[Symbol.dispose](): void;
|
|
1379
|
+
/**
|
|
1380
|
+
* Feed a frame into the MSD analysis.
|
|
1381
|
+
*
|
|
1382
|
+
* The first frame sets the reference configuration.
|
|
1383
|
+
* Subsequent frames compute MSD relative to that reference.
|
|
1384
|
+
*
|
|
1385
|
+
* # Arguments
|
|
1386
|
+
*
|
|
1387
|
+
* * `frame` - Frame with `"atoms"` block containing
|
|
1388
|
+
* `x`, `y`, `z` (f32) columns
|
|
1421
1389
|
*
|
|
1422
1390
|
* # Errors
|
|
1423
1391
|
*
|
|
1424
|
-
* Throws if the frame is missing required columns
|
|
1392
|
+
* Throws if the frame is missing required columns or has a
|
|
1393
|
+
* different number of atoms than the reference.
|
|
1425
1394
|
*
|
|
1426
1395
|
* # Example (JavaScript)
|
|
1427
1396
|
*
|
|
1428
1397
|
* ```js
|
|
1429
|
-
* const msd = MSD
|
|
1398
|
+
* const msd = new MSD();
|
|
1399
|
+
* msd.feed(frame0); // sets reference
|
|
1400
|
+
* msd.feed(frame1); // computes MSD vs frame0
|
|
1430
1401
|
* ```
|
|
1431
1402
|
*/
|
|
1432
|
-
|
|
1403
|
+
feed(frame: Frame): void;
|
|
1404
|
+
/**
|
|
1405
|
+
* Create an empty MSD analysis.
|
|
1406
|
+
*
|
|
1407
|
+
* The first frame passed to [`feed`] becomes the reference
|
|
1408
|
+
* configuration (t=0).
|
|
1409
|
+
*
|
|
1410
|
+
* # Example (JavaScript)
|
|
1411
|
+
*
|
|
1412
|
+
* ```js
|
|
1413
|
+
* const msd = new MSD();
|
|
1414
|
+
* ```
|
|
1415
|
+
*/
|
|
1416
|
+
constructor();
|
|
1417
|
+
/**
|
|
1418
|
+
* Reset the analysis, clearing reference and all results.
|
|
1419
|
+
*/
|
|
1420
|
+
reset(): void;
|
|
1421
|
+
/**
|
|
1422
|
+
* Return all accumulated MSD results as an array.
|
|
1423
|
+
*
|
|
1424
|
+
* Returns one [`MSDResult`] per frame fed (including the
|
|
1425
|
+
* reference frame, which has MSD = 0).
|
|
1426
|
+
*
|
|
1427
|
+
* # Example (JavaScript)
|
|
1428
|
+
*
|
|
1429
|
+
* ```js
|
|
1430
|
+
* const results = msd.results();
|
|
1431
|
+
* results.forEach((r, t) => console.log(`t=${t}: MSD=${r.mean}`));
|
|
1432
|
+
* ```
|
|
1433
|
+
*/
|
|
1434
|
+
results(): MSDResult[];
|
|
1435
|
+
/**
|
|
1436
|
+
* Number of frames accumulated.
|
|
1437
|
+
*/
|
|
1438
|
+
readonly count: number;
|
|
1433
1439
|
}
|
|
1434
1440
|
|
|
1435
1441
|
/**
|
|
@@ -1467,9 +1473,8 @@ export class MSDResult {
|
|
|
1467
1473
|
* Result of a neighbor search: all atom pairs within a distance cutoff.
|
|
1468
1474
|
*
|
|
1469
1475
|
* Contains pair indices, distances, and squared distances for every
|
|
1470
|
-
* neighbor pair found. This object is produced by [`
|
|
1471
|
-
*
|
|
1472
|
-
* and [`Cluster`].
|
|
1476
|
+
* neighbor pair found. This object is produced by [`LinkedCell`]
|
|
1477
|
+
* and consumed by analysis classes like [`RDF`] and [`Cluster`].
|
|
1473
1478
|
*
|
|
1474
1479
|
* # Properties
|
|
1475
1480
|
*
|
|
@@ -1483,7 +1488,7 @@ export class MSDResult {
|
|
|
1483
1488
|
* # Example (JavaScript)
|
|
1484
1489
|
*
|
|
1485
1490
|
* ```js
|
|
1486
|
-
* const nlist =
|
|
1491
|
+
* const nlist = lc.build(frame);
|
|
1487
1492
|
* console.log(nlist.numPairs);
|
|
1488
1493
|
*
|
|
1489
1494
|
* const i = nlist.queryPointIndices(); // Uint32Array
|
|
@@ -1509,18 +1514,6 @@ export class NeighborList {
|
|
|
1509
1514
|
* `queryPointIndices()[k]` and reference point `pointIndices()[k]`.
|
|
1510
1515
|
*/
|
|
1511
1516
|
distances(): Float32Array;
|
|
1512
|
-
/**
|
|
1513
|
-
* **Deprecated**: Use `queryPointIndices()` instead.
|
|
1514
|
-
*
|
|
1515
|
-
* First particle index per pair as `Uint32Array`.
|
|
1516
|
-
*/
|
|
1517
|
-
idxI(): Uint32Array;
|
|
1518
|
-
/**
|
|
1519
|
-
* **Deprecated**: Use `pointIndices()` instead.
|
|
1520
|
-
*
|
|
1521
|
-
* Second particle index per pair as `Uint32Array`.
|
|
1522
|
-
*/
|
|
1523
|
-
idxJ(): Uint32Array;
|
|
1524
1517
|
/**
|
|
1525
1518
|
* Reference point indices (`j`) for each pair, as a `Uint32Array`.
|
|
1526
1519
|
*/
|
|
@@ -1533,7 +1526,7 @@ export class NeighborList {
|
|
|
1533
1526
|
*/
|
|
1534
1527
|
queryPointIndices(): Uint32Array;
|
|
1535
1528
|
/**
|
|
1536
|
-
* Whether this result came from a self-query (`
|
|
1529
|
+
* Whether this result came from a self-query (`build()`).
|
|
1537
1530
|
*
|
|
1538
1531
|
* In self-queries, only unique pairs `(i < j)` are reported.
|
|
1539
1532
|
*/
|
|
@@ -1554,100 +1547,6 @@ export class NeighborList {
|
|
|
1554
1547
|
readonly numQueryPoints: number;
|
|
1555
1548
|
}
|
|
1556
1549
|
|
|
1557
|
-
/**
|
|
1558
|
-
* **Deprecated**: backward-compatible alias for [`NeighborList`].
|
|
1559
|
-
*
|
|
1560
|
-
* Use [`NeighborList`] instead. This type is kept only for API
|
|
1561
|
-
* compatibility with older code.
|
|
1562
|
-
*/
|
|
1563
|
-
export class NeighborResult {
|
|
1564
|
-
private constructor();
|
|
1565
|
-
free(): void;
|
|
1566
|
-
[Symbol.dispose](): void;
|
|
1567
|
-
/**
|
|
1568
|
-
* Squared pairwise distances in A^2 as `Float32Array`.
|
|
1569
|
-
*/
|
|
1570
|
-
distSq(): Float32Array;
|
|
1571
|
-
/**
|
|
1572
|
-
* First particle index per pair as `Uint32Array`.
|
|
1573
|
-
*/
|
|
1574
|
-
idxI(): Uint32Array;
|
|
1575
|
-
/**
|
|
1576
|
-
* Second particle index per pair as `Uint32Array`.
|
|
1577
|
-
*/
|
|
1578
|
-
idxJ(): Uint32Array;
|
|
1579
|
-
/**
|
|
1580
|
-
* Total number of neighbor pairs found.
|
|
1581
|
-
*/
|
|
1582
|
-
readonly numPairs: number;
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
/**
|
|
1586
|
-
* Neighbor search using the cell-list (link-cell) algorithm.
|
|
1587
|
-
*
|
|
1588
|
-
* This is a simpler, backward-compatible interface compared to
|
|
1589
|
-
* [`AABBQuery`]. It performs a self-query in a single `build()` call.
|
|
1590
|
-
*
|
|
1591
|
-
* Prefer [`AABBQuery`] for more flexibility (cross-queries, reusable
|
|
1592
|
-
* spatial index).
|
|
1593
|
-
*
|
|
1594
|
-
* # Example (JavaScript)
|
|
1595
|
-
*
|
|
1596
|
-
* ```js
|
|
1597
|
-
* const ns = new NeighborSearch(3.0); // cutoff = 3.0 A
|
|
1598
|
-
* const nbrs = ns.build(frame);
|
|
1599
|
-
* console.log(nbrs.numPairs);
|
|
1600
|
-
* ```
|
|
1601
|
-
*/
|
|
1602
|
-
export class NeighborSearch {
|
|
1603
|
-
free(): void;
|
|
1604
|
-
[Symbol.dispose](): void;
|
|
1605
|
-
/**
|
|
1606
|
-
* Build a neighbor list from a [`Frame`].
|
|
1607
|
-
*
|
|
1608
|
-
* Performs a self-query: finds all unique pairs `(i < j)` of atoms
|
|
1609
|
-
* within the cutoff distance, using the cell-list algorithm.
|
|
1610
|
-
*
|
|
1611
|
-
* The frame must have:
|
|
1612
|
-
* - An `"atoms"` block with `x`, `y`, `z` (f32) columns
|
|
1613
|
-
* - A `simbox` (simulation box) set on the frame
|
|
1614
|
-
*
|
|
1615
|
-
* # Arguments
|
|
1616
|
-
*
|
|
1617
|
-
* * `frame` - Frame with atom positions and simbox
|
|
1618
|
-
*
|
|
1619
|
-
* # Returns
|
|
1620
|
-
*
|
|
1621
|
-
* A [`NeighborList`] containing all pairs within the cutoff.
|
|
1622
|
-
*
|
|
1623
|
-
* # Errors
|
|
1624
|
-
*
|
|
1625
|
-
* Throws if the frame is missing required data.
|
|
1626
|
-
*
|
|
1627
|
-
* # Example (JavaScript)
|
|
1628
|
-
*
|
|
1629
|
-
* ```js
|
|
1630
|
-
* const nbrs = ns.build(frame);
|
|
1631
|
-
* const dists = nbrs.distances(); // Float32Array
|
|
1632
|
-
* ```
|
|
1633
|
-
*/
|
|
1634
|
-
build(frame: Frame): NeighborList;
|
|
1635
|
-
/**
|
|
1636
|
-
* Create a neighbor search with the given distance cutoff.
|
|
1637
|
-
*
|
|
1638
|
-
* # Arguments
|
|
1639
|
-
*
|
|
1640
|
-
* * `cutoff` - Maximum neighbor distance in angstrom (A)
|
|
1641
|
-
*
|
|
1642
|
-
* # Example (JavaScript)
|
|
1643
|
-
*
|
|
1644
|
-
* ```js
|
|
1645
|
-
* const ns = new NeighborSearch(5.0);
|
|
1646
|
-
* ```
|
|
1647
|
-
*/
|
|
1648
|
-
constructor(cutoff: number);
|
|
1649
|
-
}
|
|
1650
|
-
|
|
1651
1550
|
/**
|
|
1652
1551
|
* Protein Data Bank (PDB) file reader.
|
|
1653
1552
|
*
|
|
@@ -1743,8 +1642,8 @@ export class PDBReader {
|
|
|
1743
1642
|
* # Example (JavaScript)
|
|
1744
1643
|
*
|
|
1745
1644
|
* ```js
|
|
1746
|
-
* const
|
|
1747
|
-
* const nlist =
|
|
1645
|
+
* const lc = new LinkedCell(5.0);
|
|
1646
|
+
* const nlist = lc.build(frame);
|
|
1748
1647
|
*
|
|
1749
1648
|
* const rdf = new RDF(100, 5.0);
|
|
1750
1649
|
* const result = rdf.compute(frame, nlist);
|
|
@@ -1765,8 +1664,7 @@ export class RDF {
|
|
|
1765
1664
|
* # Arguments
|
|
1766
1665
|
*
|
|
1767
1666
|
* * `frame` - Frame with a `simbox` set (for volume normalization)
|
|
1768
|
-
* * `neighbors` - Pre-built [`NeighborList`] from [`
|
|
1769
|
-
* or [`NeighborSearch`]
|
|
1667
|
+
* * `neighbors` - Pre-built [`NeighborList`] from [`LinkedCell`]
|
|
1770
1668
|
*
|
|
1771
1669
|
* # Returns
|
|
1772
1670
|
*
|
package/molrs.js
CHANGED
|
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./molrs_bg.js";
|
|
|
5
5
|
__wbg_set_wasm(wasm);
|
|
6
6
|
wasm.__wbindgen_start();
|
|
7
7
|
export {
|
|
8
|
-
|
|
8
|
+
Block, Box, Cluster, ClusterResult, Frame, LAMMPSReader, LinkedCell, MSD, MSDResult, NeighborList, PDBReader, RDF, RDFResult, SimulationReader, SmilesIR, WasmArray, XYZReader, generate3D, parseSMILES, start, wasmMemory, writeFrame
|
|
9
9
|
} from "./molrs_bg.js";
|