@molcrafts/molrs 0.0.8 → 0.0.13
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/molrs.d.ts +322 -76
- package/molrs.js +1 -1
- package/molrs_bg.js +550 -122
- package/molrs_bg.wasm +0 -0
- package/package.json +1 -1
package/molrs.d.ts
CHANGED
|
@@ -117,6 +117,50 @@ export class Block {
|
|
|
117
117
|
* ```
|
|
118
118
|
*/
|
|
119
119
|
copyColU32(key: string): Uint32Array;
|
|
120
|
+
/**
|
|
121
|
+
* Allocate a zero-filled float column at `key` with the given shape.
|
|
122
|
+
*
|
|
123
|
+
* Pair with [`viewColF`](Block::view_col_f) for zero-copy writes from JS:
|
|
124
|
+
*
|
|
125
|
+
* ```js
|
|
126
|
+
* block.createColF("x", [N]); // allocate
|
|
127
|
+
* const view = block.viewColF("x"); // zero-copy view into the column
|
|
128
|
+
* for (let i = 0; i < N; i++) view[i] = src[i]; // direct write
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* # Arguments
|
|
132
|
+
*
|
|
133
|
+
* * `key` - Column name
|
|
134
|
+
* * `shape` - Shape of the column (e.g. `[N]` for 1D, `[N, 3]` for Nx3)
|
|
135
|
+
*
|
|
136
|
+
* # Errors
|
|
137
|
+
*
|
|
138
|
+
* Throws if the shape is empty, or if the leading dimension conflicts
|
|
139
|
+
* with existing columns in this block.
|
|
140
|
+
*/
|
|
141
|
+
createColF(key: string, shape: Uint32Array): void;
|
|
142
|
+
/**
|
|
143
|
+
* Allocate a zero-filled i32 column at `key` with the given shape.
|
|
144
|
+
*
|
|
145
|
+
* See [`createColF`](Block::create_col_f) for the zero-copy write pattern.
|
|
146
|
+
*
|
|
147
|
+
* # Errors
|
|
148
|
+
*
|
|
149
|
+
* Throws if the shape is empty, or if the leading dimension conflicts
|
|
150
|
+
* with existing columns.
|
|
151
|
+
*/
|
|
152
|
+
createColI32(key: string, shape: Uint32Array): void;
|
|
153
|
+
/**
|
|
154
|
+
* Allocate a zero-filled u32 column at `key` with the given shape.
|
|
155
|
+
*
|
|
156
|
+
* See [`createColF`](Block::create_col_f) for the zero-copy write pattern.
|
|
157
|
+
*
|
|
158
|
+
* # Errors
|
|
159
|
+
*
|
|
160
|
+
* Throws if the shape is empty, or if the leading dimension conflicts
|
|
161
|
+
* with existing columns.
|
|
162
|
+
*/
|
|
163
|
+
createColU32(key: string, shape: Uint32Array): void;
|
|
120
164
|
/**
|
|
121
165
|
* Return the data type string for a column.
|
|
122
166
|
*
|
|
@@ -1114,6 +1158,31 @@ export class Frame {
|
|
|
1114
1158
|
* ```
|
|
1115
1159
|
*/
|
|
1116
1160
|
getGrid(name: string): Grid | undefined;
|
|
1161
|
+
/**
|
|
1162
|
+
* Read a per-frame metadata value as a numeric scalar.
|
|
1163
|
+
*
|
|
1164
|
+
* Returns `Some(v)` if the meta key exists AND its string value parses
|
|
1165
|
+
* as an `f64`. Returns `None` if the key is missing or the value is
|
|
1166
|
+
* non-numeric (e.g., `config="trans"`).
|
|
1167
|
+
*
|
|
1168
|
+
* `frame.meta` is a `HashMap<String, String>`; the ExtXYZ parser stores
|
|
1169
|
+
* all comment-line values as strings. This accessor reads numeric ones
|
|
1170
|
+
* via `str::parse::<f64>`.
|
|
1171
|
+
*
|
|
1172
|
+
* # Arguments
|
|
1173
|
+
*
|
|
1174
|
+
* * `name` — Meta key to look up (e.g., `"energy"`, `"temp"`).
|
|
1175
|
+
*
|
|
1176
|
+
* # Example (JavaScript)
|
|
1177
|
+
*
|
|
1178
|
+
* ```js
|
|
1179
|
+
* const energy = frame.getMetaScalar("energy");
|
|
1180
|
+
* if (energy !== undefined) {
|
|
1181
|
+
* console.log("Energy:", energy);
|
|
1182
|
+
* }
|
|
1183
|
+
* ```
|
|
1184
|
+
*/
|
|
1185
|
+
getMetaScalar(name: string): number | undefined;
|
|
1117
1186
|
/**
|
|
1118
1187
|
* Return the names of all grids attached to this frame.
|
|
1119
1188
|
*
|
|
@@ -1190,6 +1259,20 @@ export class Frame {
|
|
|
1190
1259
|
* ```
|
|
1191
1260
|
*/
|
|
1192
1261
|
insertGrid(name: string, grid: Grid): void;
|
|
1262
|
+
/**
|
|
1263
|
+
* Return the names of all metadata keys on this frame.
|
|
1264
|
+
*
|
|
1265
|
+
* Includes all keys regardless of whether their values are numeric
|
|
1266
|
+
* or categorical. To filter to numeric keys, iterate and call
|
|
1267
|
+
* [`getMetaScalar`](Self::get_meta_scalar) on each.
|
|
1268
|
+
*
|
|
1269
|
+
* # Example (JavaScript)
|
|
1270
|
+
*
|
|
1271
|
+
* ```js
|
|
1272
|
+
* const names = frame.metaNames(); // e.g. ["energy", "config", "temp"]
|
|
1273
|
+
* ```
|
|
1274
|
+
*/
|
|
1275
|
+
metaNames(): string[];
|
|
1193
1276
|
/**
|
|
1194
1277
|
* Create a new, empty `Frame` with no blocks and no simulation box.
|
|
1195
1278
|
*
|
|
@@ -1286,6 +1369,33 @@ export class Frame {
|
|
|
1286
1369
|
* ```
|
|
1287
1370
|
*/
|
|
1288
1371
|
renameColumn(block_key: string, old_col: string, new_col: string): boolean;
|
|
1372
|
+
/**
|
|
1373
|
+
* Set a per-frame metadata value.
|
|
1374
|
+
*
|
|
1375
|
+
* Stores `value` as the string backing for `name` on `frame.meta`.
|
|
1376
|
+
* Numeric values are read back via
|
|
1377
|
+
* [`getMetaScalar`](Self::get_meta_scalar) by parsing the string
|
|
1378
|
+
* form. `frame.meta` is the single source of truth for per-frame
|
|
1379
|
+
* scalars — no separate aggregation layer is needed on the JS side.
|
|
1380
|
+
*
|
|
1381
|
+
* # Arguments
|
|
1382
|
+
*
|
|
1383
|
+
* * `name` — Meta key (e.g., `"energy"`, `"temp"`).
|
|
1384
|
+
* * `value` — String value. For numeric labels, the caller is
|
|
1385
|
+
* responsible for converting (e.g., `num.toString()`).
|
|
1386
|
+
*
|
|
1387
|
+
* # Errors
|
|
1388
|
+
*
|
|
1389
|
+
* Throws a `JsValue` string if the frame has been dropped.
|
|
1390
|
+
*
|
|
1391
|
+
* # Example (JavaScript)
|
|
1392
|
+
*
|
|
1393
|
+
* ```js
|
|
1394
|
+
* frame.setMeta("energy", "-3.14");
|
|
1395
|
+
* frame.setMeta("note", "run-42");
|
|
1396
|
+
* ```
|
|
1397
|
+
*/
|
|
1398
|
+
setMeta(name: string, value: string): void;
|
|
1289
1399
|
/**
|
|
1290
1400
|
* Get the simulation box attached to this frame (if any).
|
|
1291
1401
|
*
|
|
@@ -1541,6 +1651,10 @@ export class GyrationTensor {
|
|
|
1541
1651
|
[Symbol.dispose](): void;
|
|
1542
1652
|
/**
|
|
1543
1653
|
* Compute gyration tensors. Returns a flat float typed array (9 values per cluster).
|
|
1654
|
+
*
|
|
1655
|
+
* Internally computes the cluster geometric centers (via
|
|
1656
|
+
* [`RsClusterCenters`]) since the new compute trait exposes them as a
|
|
1657
|
+
* required upstream — the old single-frame wasm API hides this detail.
|
|
1544
1658
|
*/
|
|
1545
1659
|
compute(frame: Frame, cluster_result: ClusterResult): Float64Array;
|
|
1546
1660
|
constructor();
|
|
@@ -1554,49 +1668,15 @@ export class InertiaTensor {
|
|
|
1554
1668
|
[Symbol.dispose](): void;
|
|
1555
1669
|
/**
|
|
1556
1670
|
* Compute inertia tensors. Returns a flat float typed array (9 values per cluster).
|
|
1671
|
+
*
|
|
1672
|
+
* Internally computes the cluster centers of mass (via
|
|
1673
|
+
* [`RsCenterOfMass`]) since the new compute trait consumes them as a
|
|
1674
|
+
* required upstream — the old single-frame wasm API hides this detail.
|
|
1557
1675
|
*/
|
|
1558
1676
|
compute(frame: Frame, cluster_result: ClusterResult): Float64Array;
|
|
1559
1677
|
constructor(masses?: Float64Array | null);
|
|
1560
1678
|
}
|
|
1561
1679
|
|
|
1562
|
-
/**
|
|
1563
|
-
* LAMMPS dump trajectory file reader.
|
|
1564
|
-
*
|
|
1565
|
-
* Reads multi-frame LAMMPS dump files (the format produced by the
|
|
1566
|
-
* `dump` command). Each frame produces a [`Frame`] containing an
|
|
1567
|
-
* `"atoms"` block with columns matching the dump header (e.g.
|
|
1568
|
-
* `id`, `type`, `x`, `y`, `z`, `vx`, `vy`, `vz`).
|
|
1569
|
-
*
|
|
1570
|
-
* # Example (JavaScript)
|
|
1571
|
-
*
|
|
1572
|
-
* ```js
|
|
1573
|
-
* const reader = new LAMMPSDumpReader(dumpContent);
|
|
1574
|
-
* console.log(reader.len()); // number of timesteps
|
|
1575
|
-
* const frame = reader.read(0);
|
|
1576
|
-
* const atoms = frame.getBlock("atoms");
|
|
1577
|
-
* ```
|
|
1578
|
-
*/
|
|
1579
|
-
export class LAMMPSDumpReader {
|
|
1580
|
-
free(): void;
|
|
1581
|
-
[Symbol.dispose](): void;
|
|
1582
|
-
/**
|
|
1583
|
-
* Check whether the file contains no frames.
|
|
1584
|
-
*/
|
|
1585
|
-
isEmpty(): boolean;
|
|
1586
|
-
/**
|
|
1587
|
-
* Return the number of frames in the dump file.
|
|
1588
|
-
*/
|
|
1589
|
-
len(): number;
|
|
1590
|
-
/**
|
|
1591
|
-
* Create a new LAMMPS dump reader from string content.
|
|
1592
|
-
*/
|
|
1593
|
-
constructor(content: string);
|
|
1594
|
-
/**
|
|
1595
|
-
* Read a frame at the given step index.
|
|
1596
|
-
*/
|
|
1597
|
-
read(step: number): Frame | undefined;
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
1680
|
/**
|
|
1601
1681
|
* LAMMPS data file reader.
|
|
1602
1682
|
*
|
|
@@ -1680,6 +1760,44 @@ export class LAMMPSReader {
|
|
|
1680
1760
|
read(step: number): Frame | undefined;
|
|
1681
1761
|
}
|
|
1682
1762
|
|
|
1763
|
+
/**
|
|
1764
|
+
* LAMMPS dump trajectory file reader.
|
|
1765
|
+
*
|
|
1766
|
+
* Reads multi-frame LAMMPS dump files (the format produced by the
|
|
1767
|
+
* `dump` command). Each frame produces a [`Frame`] containing an
|
|
1768
|
+
* `"atoms"` block with columns matching the dump header (e.g.
|
|
1769
|
+
* `id`, `type`, `x`, `y`, `z`, `vx`, `vy`, `vz`).
|
|
1770
|
+
*
|
|
1771
|
+
* # Example (JavaScript)
|
|
1772
|
+
*
|
|
1773
|
+
* ```js
|
|
1774
|
+
* const reader = new LAMMPSTrajReader(dumpContent);
|
|
1775
|
+
* console.log(reader.len()); // number of timesteps
|
|
1776
|
+
* const frame = reader.read(0);
|
|
1777
|
+
* const atoms = frame.getBlock("atoms");
|
|
1778
|
+
* ```
|
|
1779
|
+
*/
|
|
1780
|
+
export class LAMMPSTrajReader {
|
|
1781
|
+
free(): void;
|
|
1782
|
+
[Symbol.dispose](): void;
|
|
1783
|
+
/**
|
|
1784
|
+
* Check whether the file contains no frames.
|
|
1785
|
+
*/
|
|
1786
|
+
isEmpty(): boolean;
|
|
1787
|
+
/**
|
|
1788
|
+
* Return the number of frames in the dump file.
|
|
1789
|
+
*/
|
|
1790
|
+
len(): number;
|
|
1791
|
+
/**
|
|
1792
|
+
* Create a new LAMMPS dump reader from string content.
|
|
1793
|
+
*/
|
|
1794
|
+
constructor(content: string);
|
|
1795
|
+
/**
|
|
1796
|
+
* Read a frame at the given step index.
|
|
1797
|
+
*/
|
|
1798
|
+
read(step: number): Frame | undefined;
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1683
1801
|
/**
|
|
1684
1802
|
* Cell-list (linked-cell) based neighbor search.
|
|
1685
1803
|
*
|
|
@@ -1807,25 +1925,23 @@ export class MSD {
|
|
|
1807
1925
|
/**
|
|
1808
1926
|
* Feed a frame into the MSD analysis.
|
|
1809
1927
|
*
|
|
1810
|
-
*
|
|
1811
|
-
*
|
|
1928
|
+
* Internally clones the frame's core data so subsequent mutations on
|
|
1929
|
+
* the JS side (e.g. trajectory playback overwriting buffers) do not
|
|
1930
|
+
* race against pending [`results`](Self::results) calls. The first
|
|
1931
|
+
* frame sets the reference configuration.
|
|
1812
1932
|
*
|
|
1813
1933
|
* # Arguments
|
|
1814
1934
|
*
|
|
1815
1935
|
* * `frame` - Frame with `"atoms"` block containing
|
|
1816
1936
|
* `x`, `y`, `z` (F) columns
|
|
1817
1937
|
*
|
|
1818
|
-
* # Errors
|
|
1819
|
-
*
|
|
1820
|
-
* Throws if the frame is missing required columns or has a
|
|
1821
|
-
* different number of atoms than the reference.
|
|
1822
|
-
*
|
|
1823
1938
|
* # Example (JavaScript)
|
|
1824
1939
|
*
|
|
1825
1940
|
* ```js
|
|
1826
1941
|
* const msd = new MSD();
|
|
1827
1942
|
* msd.feed(frame0); // sets reference
|
|
1828
|
-
* msd.feed(frame1); //
|
|
1943
|
+
* msd.feed(frame1); // added to trajectory
|
|
1944
|
+
* const series = msd.results();
|
|
1829
1945
|
* ```
|
|
1830
1946
|
*/
|
|
1831
1947
|
feed(frame: Frame): void;
|
|
@@ -1843,14 +1959,14 @@ export class MSD {
|
|
|
1843
1959
|
*/
|
|
1844
1960
|
constructor();
|
|
1845
1961
|
/**
|
|
1846
|
-
* Reset the analysis, clearing
|
|
1962
|
+
* Reset the analysis, clearing the trajectory buffer.
|
|
1847
1963
|
*/
|
|
1848
1964
|
reset(): void;
|
|
1849
1965
|
/**
|
|
1850
|
-
*
|
|
1966
|
+
* Run the stateless [`molrs_compute::MSD`] over every fed frame and
|
|
1967
|
+
* return the per-frame time series.
|
|
1851
1968
|
*
|
|
1852
|
-
*
|
|
1853
|
-
* reference frame, which has MSD = 0).
|
|
1969
|
+
* The first frame is always the reference, so `results()[0].mean ≈ 0`.
|
|
1854
1970
|
*
|
|
1855
1971
|
* # Example (JavaScript)
|
|
1856
1972
|
*
|
|
@@ -2066,15 +2182,16 @@ export class PDBReader {
|
|
|
2066
2182
|
/**
|
|
2067
2183
|
* Radial distribution function g(r) analysis.
|
|
2068
2184
|
*
|
|
2069
|
-
*
|
|
2070
|
-
*
|
|
2071
|
-
*
|
|
2185
|
+
* Bins neighbor-pair distances in `[rMin, rMax]` and normalizes by the
|
|
2186
|
+
* ideal-gas pair density. Defaults follow freud (`rMin = 0`). Periodic
|
|
2187
|
+
* systems take their normalization volume from `frame.simbox`; non-periodic
|
|
2188
|
+
* systems must supply it explicitly via [`computeWithVolume`].
|
|
2072
2189
|
*
|
|
2073
2190
|
* # Algorithm
|
|
2074
2191
|
*
|
|
2075
2192
|
* g(r) = n(r) / (rho * V_shell(r) * N_ref)
|
|
2076
2193
|
*
|
|
2077
|
-
* where `n(r)` is the pair count in bin `r`, `rho` is the number
|
|
2194
|
+
* where `n(r)` is the pair count in bin `r`, `rho = N/V` is the number
|
|
2078
2195
|
* density, and `V_shell(r)` is the shell volume for that bin.
|
|
2079
2196
|
*
|
|
2080
2197
|
* # Example (JavaScript)
|
|
@@ -2083,60 +2200,73 @@ export class PDBReader {
|
|
|
2083
2200
|
* const lc = new LinkedCell(5.0);
|
|
2084
2201
|
* const nlist = lc.build(frame);
|
|
2085
2202
|
*
|
|
2086
|
-
* const rdf = new RDF(100, 5.0);
|
|
2203
|
+
* const rdf = new RDF(100, 5.0); // rMin defaults to 0
|
|
2087
2204
|
* const result = rdf.compute(frame, nlist);
|
|
2088
2205
|
*
|
|
2089
|
-
*
|
|
2090
|
-
* const
|
|
2206
|
+
* // Non-periodic frame: supply the normalization volume.
|
|
2207
|
+
* const resultFree = rdf.computeWithVolume(nlist, volumeA3);
|
|
2208
|
+
*
|
|
2209
|
+
* const r = result.binCenters();
|
|
2210
|
+
* const gr = result.rdf();
|
|
2091
2211
|
* ```
|
|
2092
2212
|
*/
|
|
2093
2213
|
export class RDF {
|
|
2094
2214
|
free(): void;
|
|
2095
2215
|
[Symbol.dispose](): void;
|
|
2096
2216
|
/**
|
|
2097
|
-
* Compute
|
|
2098
|
-
*
|
|
2099
|
-
* The frame is needed to read the simulation box volume for
|
|
2100
|
-
* normalization.
|
|
2217
|
+
* Compute g(r) using the simulation-box volume from `frame.simbox`.
|
|
2101
2218
|
*
|
|
2102
2219
|
* # Arguments
|
|
2103
2220
|
*
|
|
2104
|
-
* * `frame` - Frame with a `simbox` set (for volume
|
|
2221
|
+
* * `frame` - Frame with a `simbox` set (used only for volume)
|
|
2105
2222
|
* * `neighbors` - Pre-built [`NeighborList`] from [`LinkedCell`]
|
|
2106
2223
|
*
|
|
2107
|
-
* #
|
|
2224
|
+
* # Errors
|
|
2108
2225
|
*
|
|
2109
|
-
*
|
|
2110
|
-
*
|
|
2226
|
+
* Throws if the frame has no `simbox` — use
|
|
2227
|
+
* [`computeWithVolume`](Self::compute_with_volume) for non-periodic frames.
|
|
2228
|
+
*/
|
|
2229
|
+
compute(frame: Frame, neighbors: NeighborList): RDFResult;
|
|
2230
|
+
/**
|
|
2231
|
+
* Compute g(r) using an explicit normalization volume (A^3).
|
|
2111
2232
|
*
|
|
2112
|
-
*
|
|
2233
|
+
* Use this for non-periodic systems or to override the box volume.
|
|
2234
|
+
* Internally wraps the supplied volume as a cubic SimBox since the
|
|
2235
|
+
* underlying [`molrs_compute::RDF`] pulls its normalization volume from
|
|
2236
|
+
* `frame.simbox`.
|
|
2237
|
+
*
|
|
2238
|
+
* # Arguments
|
|
2113
2239
|
*
|
|
2114
|
-
*
|
|
2240
|
+
* * `neighbors` - Pre-built [`NeighborList`]
|
|
2241
|
+
* * `volume` - Normalization volume in A^3 (must be finite and > 0)
|
|
2115
2242
|
*
|
|
2116
2243
|
* # Example (JavaScript)
|
|
2117
2244
|
*
|
|
2118
2245
|
* ```js
|
|
2119
|
-
* const result = rdf.
|
|
2120
|
-
* const gr = result.rdf(); // Float32Array or Float64Array
|
|
2246
|
+
* const result = rdf.computeWithVolume(nlist, 1000.0);
|
|
2121
2247
|
* ```
|
|
2122
2248
|
*/
|
|
2123
|
-
|
|
2249
|
+
computeWithVolume(neighbors: NeighborList, volume: number): RDFResult;
|
|
2124
2250
|
/**
|
|
2125
|
-
* Create a new RDF analysis
|
|
2251
|
+
* Create a new RDF analysis.
|
|
2126
2252
|
*
|
|
2127
2253
|
* # Arguments
|
|
2128
2254
|
*
|
|
2129
2255
|
* * `n_bins` - Number of histogram bins
|
|
2130
|
-
* * `r_max` -
|
|
2131
|
-
*
|
|
2256
|
+
* * `r_max` - Upper radial cutoff in angstrom (A). Should be ≤ the
|
|
2257
|
+
* neighbor-search cutoff.
|
|
2258
|
+
* * `r_min` - Lower radial cutoff in angstrom (A). Optional, defaults
|
|
2259
|
+
* to 0 (freud convention). Pairs with `d < rMin` or `d == 0` are
|
|
2260
|
+
* excluded from the histogram.
|
|
2132
2261
|
*
|
|
2133
2262
|
* # Example (JavaScript)
|
|
2134
2263
|
*
|
|
2135
2264
|
* ```js
|
|
2136
|
-
* const rdf = new RDF(100, 5.0);
|
|
2265
|
+
* const rdf = new RDF(100, 5.0); // rMin = 0
|
|
2266
|
+
* const rdf2 = new RDF(100, 5.0, 0.5); // exclude d < 0.5 A
|
|
2137
2267
|
* ```
|
|
2138
2268
|
*/
|
|
2139
|
-
constructor(n_bins: number, r_max: number);
|
|
2269
|
+
constructor(n_bins: number, r_max: number, r_min?: number | null);
|
|
2140
2270
|
}
|
|
2141
2271
|
|
|
2142
2272
|
/**
|
|
@@ -2186,7 +2316,11 @@ export class RDFResult {
|
|
|
2186
2316
|
*/
|
|
2187
2317
|
readonly numPoints: number;
|
|
2188
2318
|
/**
|
|
2189
|
-
*
|
|
2319
|
+
* Inner cutoff in A (lower edge of bin 0).
|
|
2320
|
+
*/
|
|
2321
|
+
readonly rMin: number;
|
|
2322
|
+
/**
|
|
2323
|
+
* Normalization volume in A^3 (from the SimBox or the explicit caller value).
|
|
2190
2324
|
*/
|
|
2191
2325
|
readonly volume: number;
|
|
2192
2326
|
}
|
|
@@ -2199,6 +2333,10 @@ export class RadiusOfGyration {
|
|
|
2199
2333
|
[Symbol.dispose](): void;
|
|
2200
2334
|
/**
|
|
2201
2335
|
* Compute radii of gyration. Returns a float typed array of length `numClusters`.
|
|
2336
|
+
*
|
|
2337
|
+
* Internally computes the cluster centers of mass so the single-frame
|
|
2338
|
+
* wasm signature `(frame, cluster)` stays stable despite the new
|
|
2339
|
+
* compute trait needing explicit COM upstream.
|
|
2202
2340
|
*/
|
|
2203
2341
|
compute(frame: Frame, cluster_result: ClusterResult): Float64Array;
|
|
2204
2342
|
constructor(masses?: Float64Array | null);
|
|
@@ -2660,6 +2798,114 @@ export class WasmArray {
|
|
|
2660
2798
|
write_from(arr: Float64Array): void;
|
|
2661
2799
|
}
|
|
2662
2800
|
|
|
2801
|
+
/**
|
|
2802
|
+
* Wrapper for [`molrs_compute::kmeans::KMeans`].
|
|
2803
|
+
*
|
|
2804
|
+
* # Example (JavaScript)
|
|
2805
|
+
*
|
|
2806
|
+
* ```js
|
|
2807
|
+
* const km = new WasmKMeans(3, 100, 42);
|
|
2808
|
+
* const labels = km.fit(coords, nRows, 2); // Int32Array
|
|
2809
|
+
* ```
|
|
2810
|
+
*/
|
|
2811
|
+
export class WasmKMeans {
|
|
2812
|
+
free(): void;
|
|
2813
|
+
[Symbol.dispose](): void;
|
|
2814
|
+
/**
|
|
2815
|
+
* Cluster a row-major `n_rows × n_dims` coordinate matrix.
|
|
2816
|
+
*
|
|
2817
|
+
* # Returns
|
|
2818
|
+
*
|
|
2819
|
+
* Cluster labels in `0..k` as an owned `Int32Array`, one per row.
|
|
2820
|
+
*
|
|
2821
|
+
* # Errors
|
|
2822
|
+
*
|
|
2823
|
+
* Throws if `k > n_rows`, `n_dims == 0`, the length does not match
|
|
2824
|
+
* `n_rows * n_dims`, or any element is non-finite.
|
|
2825
|
+
*/
|
|
2826
|
+
fit(coords: Float64Array, n_rows: number, n_dims: number): Int32Array;
|
|
2827
|
+
/**
|
|
2828
|
+
* Create a new k-means configuration.
|
|
2829
|
+
*
|
|
2830
|
+
* # Arguments
|
|
2831
|
+
*
|
|
2832
|
+
* * `k` — number of clusters (>= 1).
|
|
2833
|
+
* * `max_iter` — maximum Lloyd iterations (>= 1).
|
|
2834
|
+
* * `seed` — RNG seed for k-means++ initialization. Cast to `u64`
|
|
2835
|
+
* internally (JS numbers are `f64`; integers up to 2^53 pass
|
|
2836
|
+
* through losslessly).
|
|
2837
|
+
*
|
|
2838
|
+
* # Errors
|
|
2839
|
+
*
|
|
2840
|
+
* Throws if `k == 0` or `max_iter == 0`.
|
|
2841
|
+
*/
|
|
2842
|
+
constructor(k: number, max_iter: number, seed: number);
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2845
|
+
/**
|
|
2846
|
+
* Stateless wrapper for [`molrs_compute::pca::Pca2`].
|
|
2847
|
+
*
|
|
2848
|
+
* All configuration lives on [`fitTransform`](Self::fit_transform).
|
|
2849
|
+
*
|
|
2850
|
+
* # Example (JavaScript)
|
|
2851
|
+
*
|
|
2852
|
+
* ```js
|
|
2853
|
+
* const pca = new WasmPca2();
|
|
2854
|
+
* const result = pca.fitTransform(matrix, nRows, nCols);
|
|
2855
|
+
* const coords = result.coords(); // Float64Array, length 2 * nRows
|
|
2856
|
+
* const variance = result.variance(); // Float64Array, length 2
|
|
2857
|
+
* ```
|
|
2858
|
+
*/
|
|
2859
|
+
export class WasmPca2 {
|
|
2860
|
+
free(): void;
|
|
2861
|
+
[Symbol.dispose](): void;
|
|
2862
|
+
/**
|
|
2863
|
+
* Fit 2-component PCA on a row-major observation matrix and return the
|
|
2864
|
+
* projected coordinates + per-component variance.
|
|
2865
|
+
*
|
|
2866
|
+
* # Arguments
|
|
2867
|
+
*
|
|
2868
|
+
* * `matrix` — row-major `n_rows × n_cols` observation matrix.
|
|
2869
|
+
* * `n_rows` — number of observations.
|
|
2870
|
+
* * `n_cols` — number of features.
|
|
2871
|
+
*
|
|
2872
|
+
* # Errors
|
|
2873
|
+
*
|
|
2874
|
+
* Throws if `n_rows < 3`, `n_cols < 2`, the length does not match
|
|
2875
|
+
* `n_rows * n_cols`, any element is non-finite, or any column has
|
|
2876
|
+
* zero variance.
|
|
2877
|
+
*/
|
|
2878
|
+
fitTransform(matrix: Float64Array, n_rows: number, n_cols: number): WasmPcaResult;
|
|
2879
|
+
/**
|
|
2880
|
+
* Create a new PCA calculator. The struct carries no state — all
|
|
2881
|
+
* parameters are supplied on [`fitTransform`](Self::fit_transform).
|
|
2882
|
+
*/
|
|
2883
|
+
constructor();
|
|
2884
|
+
}
|
|
2885
|
+
|
|
2886
|
+
/**
|
|
2887
|
+
* Result of a [`WasmPca2::fit_transform`] call.
|
|
2888
|
+
*
|
|
2889
|
+
* Each accessor returns an **owned** `Float64Array` (copy of the underlying
|
|
2890
|
+
* `Vec`) so JS is free to let this wrapper be GC'd without dangling views.
|
|
2891
|
+
*/
|
|
2892
|
+
export class WasmPcaResult {
|
|
2893
|
+
private constructor();
|
|
2894
|
+
free(): void;
|
|
2895
|
+
[Symbol.dispose](): void;
|
|
2896
|
+
/**
|
|
2897
|
+
* Projected 2D coordinates as a row-major `Float64Array` of length
|
|
2898
|
+
* `2 * n_rows`. `coords[2 * i + 0]` is the PC1 score for row `i`,
|
|
2899
|
+
* `coords[2 * i + 1]` is PC2.
|
|
2900
|
+
*/
|
|
2901
|
+
coords(): Float64Array;
|
|
2902
|
+
/**
|
|
2903
|
+
* Explained variance per component as `Float64Array` of length 2.
|
|
2904
|
+
* `variance[0] >= variance[1]` by construction.
|
|
2905
|
+
*/
|
|
2906
|
+
variance(): Float64Array;
|
|
2907
|
+
}
|
|
2908
|
+
|
|
2663
2909
|
/**
|
|
2664
2910
|
* XYZ / Extended XYZ file reader.
|
|
2665
2911
|
*
|
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
|
-
Block, Box, CenterOfMass, CenterOfMassResult, Cluster, ClusterCenters, ClusterResult, Frame, Grid, GyrationTensor, InertiaTensor,
|
|
8
|
+
Block, Box, CenterOfMass, CenterOfMassResult, Cluster, ClusterCenters, ClusterResult, Frame, Grid, GyrationTensor, InertiaTensor, LAMMPSReader, LAMMPSTrajReader, LinkedCell, MSD, MSDResult, MolRecReader, NeighborList, PDBReader, RDF, RDFResult, RadiusOfGyration, SDFReader, SmilesIR, Topology, TopologyRingInfo, WasmArray, WasmKMeans, WasmPca2, WasmPcaResult, XYZReader, generate3D, parseSMILES, start, wasmMemory, writeFrame
|
|
9
9
|
} from "./molrs_bg.js";
|