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 +14 -0
- package/README.md +21 -0
- package/dist/bravais.js +800 -608
- package/dist/bravais.js.map +1 -1
- package/dist/types/cif/errors.d.ts +2 -1
- package/dist/types/cif/structure.d.ts +6 -8
- package/dist/types/index.d.ts +2 -0
- package/dist/types/structure/elements.d.ts +2 -0
- package/dist/types/structure/errors.d.ts +8 -0
- package/dist/types/structure/from-data.d.ts +57 -0
- package/dist/types/structure/sites.d.ts +19 -0
- package/dist/types/structure/types.d.ts +14 -3
- package/dist/types/symmetry/moyo.d.ts +4 -4
- package/dist/types/symmetry/resolve.d.ts +12 -9
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StructureError } from "../structure/errors.js";
|
|
1
2
|
/** The text is not CIF the tokenizer and parser accept. */
|
|
2
3
|
export declare class CifSyntaxError extends Error {
|
|
3
4
|
/** 1-based line of the problem. */
|
|
@@ -5,6 +6,6 @@ export declare class CifSyntaxError extends Error {
|
|
|
5
6
|
constructor(message: string, line: number);
|
|
6
7
|
}
|
|
7
8
|
/** The CIF parses but does not describe a structure this package can use. */
|
|
8
|
-
export declare class CifStructureError extends
|
|
9
|
+
export declare class CifStructureError extends StructureError {
|
|
9
10
|
constructor(message: string);
|
|
10
11
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { StructureListing } from "../structure/types.js";
|
|
2
2
|
import { type CifBlock } from "./parser.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
spaceGroup: SpaceGroupInfo;
|
|
9
|
-
}
|
|
3
|
+
/**
|
|
4
|
+
* A data block's lattice, merged sites, operations (null when the file lists
|
|
5
|
+
* none; see `spaceGroup` then) and space-group tags.
|
|
6
|
+
*/
|
|
7
|
+
export type ParsedCifStructure = StructureListing;
|
|
10
8
|
/** True when the block carries atom coordinates (the one a viewer wants). */
|
|
11
9
|
export declare function isStructureBlock(block: CifBlock): boolean;
|
|
12
10
|
/** Lattice, merged sites, operations and space-group tags of one data block. */
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Structure } from "./structure/types.js";
|
|
2
2
|
export { CifStructureError, CifSyntaxError } from "./cif/errors.js";
|
|
3
|
+
export { StructureDataError, StructureError } from "./structure/errors.js";
|
|
4
|
+
export { readStructure, type SiteData, type StructureData, } from "./structure/from-data.js";
|
|
3
5
|
export { parseCif, type CifBlock, type CifDocument, type CifLoop, } from "./cif/parser.js";
|
|
4
6
|
export { parseCifStructure, type ParsedCifStructure } from "./cif/structure.js";
|
|
5
7
|
export { parseSymmetryOperation } from "./cif/symmetry-operations.js";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** Element symbols in atomic-number order. */
|
|
2
2
|
export declare const ELEMENT_SYMBOLS: string[];
|
|
3
|
+
/** True for an element symbol as written, such as "Fe", or "D" for deuterium. */
|
|
4
|
+
export declare function isElementSymbol(symbol: string): boolean;
|
|
3
5
|
/**
|
|
4
6
|
* The element behind a CIF atom label or type symbol: `Fe3+`, `O2-`, `Co1`,
|
|
5
7
|
* `OW`, `fe` and `Wat` all resolve. Null when no element symbol fits.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** A structure, read from a CIF or given as data, that this package cannot use. */
|
|
2
|
+
export declare class StructureError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
/** Structure data `readStructure` cannot use: a field is missing or malformed. */
|
|
6
|
+
export declare class StructureDataError extends StructureError {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { LatticeParameters, Mat3, SpaceGroupInfo, Structure, SymmetryOperation, Vec3 } from "./types.js";
|
|
2
|
+
/** One site of `StructureData`: a position and the species that share it. */
|
|
3
|
+
export interface SiteData {
|
|
4
|
+
/** Name of the site; `site1`, `site2` and so on by its place in the list when absent. */
|
|
5
|
+
label?: string | null;
|
|
6
|
+
/** Fractional coordinates; wrapped into the cell. */
|
|
7
|
+
fractional: Vec3;
|
|
8
|
+
/** The species at this position; an occupancy defaults to 1. */
|
|
9
|
+
species: {
|
|
10
|
+
element: string;
|
|
11
|
+
occupancy?: number | null;
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A crystal structure as plain data, for structures read or built outside
|
|
16
|
+
* this package. It survives JSON and `structuredClone`, so it can cross
|
|
17
|
+
* workers, processes and IPC.
|
|
18
|
+
*/
|
|
19
|
+
export interface StructureData {
|
|
20
|
+
/**
|
|
21
|
+
* Cell lengths in ångström and angles in degrees, set with c along z and a
|
|
22
|
+
* in the xz plane as in pymatgen, or the three cell vectors as rows in
|
|
23
|
+
* Cartesian ångström, used as given. Vectors win when both are given.
|
|
24
|
+
*/
|
|
25
|
+
lattice: LatticeParameters | {
|
|
26
|
+
vectors: Mat3;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The sites as listed: an asymmetric unit that `operations` or
|
|
30
|
+
* `spaceGroup` expands, or every atom of the cell. Species within 1e-4 of
|
|
31
|
+
* one position belong to one site, as the rows of a CIF do.
|
|
32
|
+
*/
|
|
33
|
+
sites: SiteData[];
|
|
34
|
+
/**
|
|
35
|
+
* x' = R x + t on fractional coordinates, as `SymmetryOperation`s with R
|
|
36
|
+
* row-major, or as strings such as `"-x, y+1/2, -z"`. They must include
|
|
37
|
+
* the identity. When absent or null, `spaceGroup` supplies them, and
|
|
38
|
+
* without a space group the sites list every atom of the cell.
|
|
39
|
+
*/
|
|
40
|
+
operations?: (SymmetryOperation | string)[] | null;
|
|
41
|
+
/** The space group by Hall symbol, Hermann-Mauguin symbol or number. */
|
|
42
|
+
spaceGroup?: Partial<SpaceGroupInfo> | null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Read a structure given as data instead of a CIF, such as one a CIF reader
|
|
46
|
+
* outside this package produced, so it can be expanded, drawn and analysed
|
|
47
|
+
* like a structure from `readCif`. The data is checked and then read the way
|
|
48
|
+
* a CIF's atoms are: positions wrapped into the cell, species at one position
|
|
49
|
+
* joined into a site and sorted by occupancy, overfull sites scaled to a full
|
|
50
|
+
* one, and the symmetry checked against the atoms, or looked up from the
|
|
51
|
+
* space group.
|
|
52
|
+
*
|
|
53
|
+
* Throws `StructureDataError` for data that is missing or malformed, or
|
|
54
|
+
* whose operations do not fit its atoms, and `SpaceGroupLookupError` for an
|
|
55
|
+
* unknown space group.
|
|
56
|
+
*/
|
|
57
|
+
export declare function readStructure(data: StructureData): Promise<Structure>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Site, Vec3 } from "./types.js";
|
|
2
|
+
/** Rows this close in fractional coordinates describe one site. */
|
|
3
|
+
export declare const SITE_MERGE_TOLERANCE = 0.0001;
|
|
4
|
+
/** One species at one position, as a CIF atom-site row lists it. */
|
|
5
|
+
export interface SiteRow {
|
|
6
|
+
label: string;
|
|
7
|
+
element: string;
|
|
8
|
+
occupancy: number;
|
|
9
|
+
fractional: Vec3;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Sites from rows of one species at one position, the way a CIF lists its
|
|
13
|
+
* atoms. Positions are wrapped into the cell. Rows within
|
|
14
|
+
* `SITE_MERGE_TOLERANCE` of an earlier row join its site, which keeps that
|
|
15
|
+
* row's label, adds up the occupancy of a repeated element and sorts its
|
|
16
|
+
* species by descending occupancy. A site whose occupancies add up to more
|
|
17
|
+
* than 1 is scaled down to a full site.
|
|
18
|
+
*/
|
|
19
|
+
export declare function assembleSites(rows: Iterable<SiteRow>): Site[];
|
|
@@ -33,13 +33,13 @@ export interface SymmetryOperation {
|
|
|
33
33
|
rotation: number[];
|
|
34
34
|
translation: Vec3;
|
|
35
35
|
}
|
|
36
|
-
/** What a CIF says about its space group; null for what it leaves out. */
|
|
36
|
+
/** What a CIF or structure data says about its space group; null for what it leaves out. */
|
|
37
37
|
export interface SpaceGroupInfo {
|
|
38
38
|
/** Number in the International Tables, 1 to 230. */
|
|
39
39
|
number: number | null;
|
|
40
|
-
/** Hermann-Mauguin symbol as written in the
|
|
40
|
+
/** Hermann-Mauguin symbol as written in the source. */
|
|
41
41
|
symbol: string | null;
|
|
42
|
-
/** Hall symbol as written in the
|
|
42
|
+
/** Hall symbol as written in the source. */
|
|
43
43
|
hallSymbol: string | null;
|
|
44
44
|
}
|
|
45
45
|
export interface Structure {
|
|
@@ -49,4 +49,15 @@ export interface Structure {
|
|
|
49
49
|
operations: SymmetryOperation[];
|
|
50
50
|
spaceGroup: SpaceGroupInfo;
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* A structure as its source lists it, before its symmetry is settled: the
|
|
54
|
+
* operations are null when the source gives none, and `spaceGroup` then
|
|
55
|
+
* decides them.
|
|
56
|
+
*/
|
|
57
|
+
export interface StructureListing {
|
|
58
|
+
lattice: Lattice;
|
|
59
|
+
sites: Site[];
|
|
60
|
+
operations: SymmetryOperation[] | null;
|
|
61
|
+
spaceGroup: SpaceGroupInfo;
|
|
62
|
+
}
|
|
52
63
|
export declare const IDENTITY_OPERATION: SymmetryOperation;
|
|
@@ -38,10 +38,10 @@ export interface OperationSetting {
|
|
|
38
38
|
operations: SymmetryOperation[];
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
* Every setting the space group
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
41
|
+
* Every setting the named space group admits, spglib's standard one first:
|
|
42
|
+
* one for most symbols, several for a short symbol such as `P 21/c` or a
|
|
43
|
+
* rhombohedral symbol without `:H` or `:R`. A bare number gives the standard
|
|
44
|
+
* setting alone.
|
|
45
45
|
*/
|
|
46
46
|
export declare function operationSettings(info: SpaceGroupInfo): Promise<OperationSetting[]>;
|
|
47
47
|
/**
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { type SymmetryOperation } from "../structure/types.js";
|
|
1
|
+
import type { StructureError } from "../structure/errors.js";
|
|
2
|
+
import { type StructureListing, type SymmetryOperation } from "../structure/types.js";
|
|
3
|
+
/** The error a reader reports with, such as `CifStructureError`. */
|
|
4
|
+
export type StructureErrorClass = new (message: string) => StructureError;
|
|
3
5
|
/**
|
|
4
|
-
* The operations a
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* The operations a listing's atoms are expanded with: its own operations,
|
|
7
|
+
* checked to fit the atoms, or else the setting of its space group that fits
|
|
8
|
+
* them. A symbol admitting several settings, such as a rhombohedral group
|
|
9
|
+
* with no `:H` or `:R`, is settled by the atoms when the list is already
|
|
10
|
+
* expanded, since only the right setting maps it onto itself, and otherwise
|
|
11
|
+
* by the cell shape, then by the standard setting. Operations that do not
|
|
12
|
+
* fit are reported as `ErrorClass`.
|
|
10
13
|
*/
|
|
11
|
-
export declare function resolveOperations(parsed:
|
|
14
|
+
export declare function resolveOperations(parsed: StructureListing, ErrorClass: StructureErrorClass): Promise<SymmetryOperation[]>;
|