bravais 0.2.1 → 0.3.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.0 - 2026-10-25
4
+
5
+ - `readStructure(data)` reads a crystal structure given as plain data rather
6
+ than a CIF: the lattice as parameters or vectors, the sites with their
7
+ species, and the symmetry as operations (objects or strings such as
8
+ `"-x, y+1/2, -z"`) or as space-group names. Structures read elsewhere, such
9
+ as by another CIF reader, are then expanded, drawn and analysed like those
10
+ from `readCif`, with the same checks: the operations must include the
11
+ identity and fit the atoms. The data survives JSON and `structuredClone`,
12
+ so it can cross workers, processes and IPC.
13
+ - `StructureError` is the base class of `CifStructureError` and of the new
14
+ `StructureDataError`, which reports data `readStructure` cannot read.
15
+ - `readCif` reads every file as before.
16
+
3
17
  ## 0.2.1 - 2026-10-23
4
18
 
5
19
  - `parseSymmetryOperator` is renamed `parseSymmetryOperation`, after the
package/README.md CHANGED
@@ -30,6 +30,27 @@ const scene = buildScene(expandStructure(await readCif(await response.text())));
30
30
  createViewer(document.getElementById("viewer")).setLayers([{ scene }]);
31
31
  ```
32
32
 
33
+ A structure read elsewhere, such as by a CIF reader in another language, can
34
+ be given as plain data instead, with its symmetry operations, its space group,
35
+ or neither when the sites list every atom of the cell:
36
+
37
+ ```js
38
+ import { readStructure } from "bravais";
39
+
40
+ const structure = await readStructure({
41
+ lattice: { a: 4.26, b: 4.26, c: 4.26, alpha: 90, beta: 90, gamma: 90 },
42
+ sites: [
43
+ { label: "Co", fractional: [0, 0, 0], species: [{ element: "Co" }] },
44
+ { label: "O", fractional: [0.5, 0.5, 0.5], species: [{ element: "O" }] },
45
+ ],
46
+ spaceGroup: { symbol: "F m -3 m" },
47
+ });
48
+ ```
49
+
50
+ `readStructure` checks the data and throws `StructureDataError` for anything
51
+ missing or malformed; the result works everywhere a structure from `readCif`
52
+ does.
53
+
33
54
  ## Built with
34
55
 
35
56
  - [three.js](https://threejs.org/) for rendering.