symcrys 0.1.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/README.md +28 -5
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/lattice.d.ts +22 -0
- package/dist/lattice.d.ts.map +1 -0
- package/dist/lattice.js +43 -0
- package/dist/lattice.js.map +1 -0
- package/dist/linalg.d.ts +32 -0
- package/dist/linalg.d.ts.map +1 -0
- package/dist/linalg.js +120 -0
- package/dist/linalg.js.map +1 -0
- package/dist/operations.d.ts +30 -0
- package/dist/operations.d.ts.map +1 -0
- package/dist/operations.js +49 -0
- package/dist/operations.js.map +1 -0
- package/dist/pointGroups/data.d.ts +40 -0
- package/dist/pointGroups/data.d.ts.map +1 -0
- package/dist/pointGroups/data.js +204 -0
- package/dist/pointGroups/data.js.map +1 -0
- package/dist/pointGroups/elements.d.ts +75 -0
- package/dist/pointGroups/elements.d.ts.map +1 -0
- package/dist/pointGroups/elements.js +181 -0
- package/dist/pointGroups/elements.js.map +1 -0
- package/dist/pointGroups/itaOrder.d.ts +22 -0
- package/dist/pointGroups/itaOrder.d.ts.map +1 -0
- package/dist/pointGroups/itaOrder.js +675 -0
- package/dist/pointGroups/itaOrder.js.map +1 -0
- package/dist/pointGroups/pointGroups.d.ts +84 -0
- package/dist/pointGroups/pointGroups.d.ts.map +1 -0
- package/dist/pointGroups/pointGroups.js +229 -0
- package/dist/pointGroups/pointGroups.js.map +1 -0
- package/dist/pointGroups/properties.d.ts +18 -0
- package/dist/pointGroups/properties.d.ts.map +1 -0
- package/dist/pointGroups/properties.js +60 -0
- package/dist/pointGroups/properties.js.map +1 -0
- package/dist/pointGroups/wyckoff.d.ts +53 -0
- package/dist/pointGroups/wyckoff.d.ts.map +1 -0
- package/dist/pointGroups/wyckoff.js +189 -0
- package/dist/pointGroups/wyckoff.js.map +1 -0
- package/dist/pointGroups/wyckoffData.d.ts +24 -0
- package/dist/pointGroups/wyckoffData.d.ts.map +1 -0
- package/dist/pointGroups/wyckoffData.js +423 -0
- package/dist/pointGroups/wyckoffData.js.map +1 -0
- package/dist/siteSymmetry.d.ts +40 -0
- package/dist/siteSymmetry.d.ts.map +1 -0
- package/dist/siteSymmetry.js +57 -0
- package/dist/siteSymmetry.js.map +1 -0
- package/dist/symmetryDirections.d.ts +18 -0
- package/dist/symmetryDirections.d.ts.map +1 -0
- package/dist/symmetryDirections.js +65 -0
- package/dist/symmetryDirections.js.map +1 -0
- package/dist/tolerances.d.ts +11 -0
- package/dist/tolerances.d.ts.map +1 -0
- package/dist/tolerances.js +11 -0
- package/dist/tolerances.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -4
- package/src/index.ts +49 -0
- package/src/lattice.ts +59 -0
- package/src/linalg.ts +138 -0
- package/src/operations.ts +63 -0
- package/src/pointGroups/data.ts +294 -0
- package/src/pointGroups/elements.ts +264 -0
- package/src/pointGroups/itaOrder.ts +688 -0
- package/src/pointGroups/pointGroups.ts +304 -0
- package/src/pointGroups/properties.ts +62 -0
- package/src/pointGroups/wyckoff.ts +233 -0
- package/src/pointGroups/wyckoffData.ts +437 -0
- package/src/siteSymmetry.ts +89 -0
- package/src/symmetryDirections.ts +72 -0
- package/src/tolerances.ts +12 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wyckoffData.js","sourceRoot":"","sources":["../../src/pointGroups/wyckoffData.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAgBH,MAAM,CAAC,MAAM,WAAW,GAA4B;IAClD;QACE,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,GAAG;QACT,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;KACxC;IACD;QACE,MAAM,EAAE,IAAI;QAC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AAG,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC;YAClC,CAAC,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC;YACnC,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC;YACjC,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC;YAClC,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC;SAC9B;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Site symmetry of a direction under any list of point operations: which operations leave it
|
|
3
|
+
* fixed (docs/conventions.md, "Site symmetry and Wyckoff positions").
|
|
4
|
+
*/
|
|
5
|
+
import { type Vec3 } from './linalg.js';
|
|
6
|
+
import type { Operation } from './operations.js';
|
|
7
|
+
export interface SiteSymmetryOptions {
|
|
8
|
+
/**
|
|
9
|
+
* A direction counts as fixed by an operation if the operation moves its unit vector by less
|
|
10
|
+
* than this (Euclidean distance). Default `EPSILON` (10⁻⁶); a caller whose directions carry
|
|
11
|
+
* rounding errors (e.g. read from a rounded link) passes a larger value.
|
|
12
|
+
*/
|
|
13
|
+
readonly tolerance?: number;
|
|
14
|
+
}
|
|
15
|
+
/** The site symmetry of a direction. */
|
|
16
|
+
export interface SiteSymmetry {
|
|
17
|
+
/** Indices into the given operations of those that leave the direction fixed, ascending. */
|
|
18
|
+
readonly operations: readonly number[];
|
|
19
|
+
/**
|
|
20
|
+
* The unit vector of the direction, set onto the fixed space of its site symmetry (the mean of
|
|
21
|
+
* its images under the site symmetry, normalised), which removes rounding errors within the
|
|
22
|
+
* tolerance.
|
|
23
|
+
*/
|
|
24
|
+
readonly direction: Vec3;
|
|
25
|
+
/** Number of operations divided by the order of the site symmetry: the number of equivalent directions. */
|
|
26
|
+
readonly multiplicity: number;
|
|
27
|
+
/** True if no operation other than the identity leaves the direction fixed (general position). */
|
|
28
|
+
readonly general: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** The tolerance of the options, checked. */
|
|
31
|
+
export declare function siteTolerance(options?: SiteSymmetryOptions): number;
|
|
32
|
+
/**
|
|
33
|
+
* The site symmetry of `direction` (any non-zero vector, Cartesian) under `operations`, which may
|
|
34
|
+
* be any list of point operations (for instance those of a distorted crystal). Time reversal is
|
|
35
|
+
* ignored: a direction or a face normal is not changed by it. `direction` and `multiplicity` are
|
|
36
|
+
* meaningful when the operations form a group (then the fixing ones do too); for another list
|
|
37
|
+
* `multiplicity` may not be an integer. Throws a RangeError for a zero vector.
|
|
38
|
+
*/
|
|
39
|
+
export declare function siteSymmetry(operations: readonly Operation[], direction: Vec3, options?: SiteSymmetryOptions): SiteSymmetry;
|
|
40
|
+
//# sourceMappingURL=siteSymmetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"siteSymmetry.d.ts","sourceRoot":"","sources":["../src/siteSymmetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAS,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,wCAAwC;AACxC,MAAM,WAAW,YAAY;IAC3B,4FAA4F;IAC5F,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,2GAA2G;IAC3G,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,kGAAkG;IAClG,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAiBD,6CAA6C;AAC7C,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAInE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,SAAS,SAAS,EAAE,EAChC,SAAS,EAAE,IAAI,EACf,OAAO,CAAC,EAAE,mBAAmB,GAC5B,YAAY,CAqBd"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Site symmetry of a direction under any list of point operations: which operations leave it
|
|
3
|
+
* fixed (docs/conventions.md, "Site symmetry and Wyckoff positions").
|
|
4
|
+
*/
|
|
5
|
+
import { apply } from './linalg.js';
|
|
6
|
+
import { EPSILON } from './tolerances.js';
|
|
7
|
+
function unit(v) {
|
|
8
|
+
const n = Math.hypot(v[0], v[1], v[2]);
|
|
9
|
+
if (!(n > 0) || !Number.isFinite(n))
|
|
10
|
+
throw new RangeError(`Not a direction: ${JSON.stringify(v)}`);
|
|
11
|
+
return [v[0] / n, v[1] / n, v[2] / n];
|
|
12
|
+
}
|
|
13
|
+
function fixes(op, v, tolerance) {
|
|
14
|
+
const w = apply(op.matrix, v);
|
|
15
|
+
return Math.hypot(w[0] - v[0], w[1] - v[1], w[2] - v[2]) < tolerance;
|
|
16
|
+
}
|
|
17
|
+
function isIdentity(op) {
|
|
18
|
+
return op.matrix.every((row, i) => row.every((v, j) => Math.abs(v - (i === j ? 1 : 0)) < EPSILON));
|
|
19
|
+
}
|
|
20
|
+
/** The tolerance of the options, checked. */
|
|
21
|
+
export function siteTolerance(options) {
|
|
22
|
+
const t = options?.tolerance ?? EPSILON;
|
|
23
|
+
if (!(typeof t === 'number' && t > 0 && t < 1))
|
|
24
|
+
throw new RangeError(`Invalid tolerance: ${String(t)}`);
|
|
25
|
+
return t;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The site symmetry of `direction` (any non-zero vector, Cartesian) under `operations`, which may
|
|
29
|
+
* be any list of point operations (for instance those of a distorted crystal). Time reversal is
|
|
30
|
+
* ignored: a direction or a face normal is not changed by it. `direction` and `multiplicity` are
|
|
31
|
+
* meaningful when the operations form a group (then the fixing ones do too); for another list
|
|
32
|
+
* `multiplicity` may not be an integer. Throws a RangeError for a zero vector.
|
|
33
|
+
*/
|
|
34
|
+
export function siteSymmetry(operations, direction, options) {
|
|
35
|
+
const tolerance = siteTolerance(options);
|
|
36
|
+
const v = unit(direction);
|
|
37
|
+
const indices = [];
|
|
38
|
+
operations.forEach((op, i) => {
|
|
39
|
+
if (fixes(op, v, tolerance))
|
|
40
|
+
indices.push(i);
|
|
41
|
+
});
|
|
42
|
+
const sum = [0, 0, 0];
|
|
43
|
+
for (const i of indices) {
|
|
44
|
+
const w = apply(operations[i].matrix, v);
|
|
45
|
+
sum[0] += w[0];
|
|
46
|
+
sum[1] += w[1];
|
|
47
|
+
sum[2] += w[2];
|
|
48
|
+
}
|
|
49
|
+
const projected = indices.length > 0 ? unit(sum) : v;
|
|
50
|
+
return Object.freeze({
|
|
51
|
+
operations: Object.freeze(indices),
|
|
52
|
+
direction: Object.freeze(projected),
|
|
53
|
+
multiplicity: indices.length > 0 ? operations.length / indices.length : operations.length,
|
|
54
|
+
general: indices.every((i) => isIdentity(operations[i])),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=siteSymmetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"siteSymmetry.js","sourceRoot":"","sources":["../src/siteSymmetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAa,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AA2B1C,SAAS,IAAI,CAAC,CAAO;IACnB,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,IAAI,CAAC,CAAC,CAAC,GAAG,CAA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CAAC,MAAM,CAAC,SAAS,CAAS;QAC3C,YAAY,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM;QACzF,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;KACzD,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The symmetry directions of the crystal families: the lattice directions along which the
|
|
3
|
+
* symmetry elements of a crystallographic point group lie, grouped by their position in the full
|
|
4
|
+
* Hermann–Mauguin symbol. Data from ITA Table 2.1.3.1 (docs/conventions.md, "Symmetry
|
|
5
|
+
* directions and elements"); `symmetryDirections.reference.test.ts` re-reads the transcription and requires the
|
|
6
|
+
* same directions, in the same order and with the same signs.
|
|
7
|
+
*/
|
|
8
|
+
import type { CrystalFamily } from './lattice.js';
|
|
9
|
+
/** A lattice direction [uvw]: integer coordinates in the conventional basis a, b, c. */
|
|
10
|
+
export type Uvw = readonly [number, number, number];
|
|
11
|
+
/**
|
|
12
|
+
* The directions of each position of the full symbol, per family, as printed in ITA Table 2.1.3.1
|
|
13
|
+
* (hexagonal family: the row "Hexagonal", which also serves the trigonal classes with hexagonal
|
|
14
|
+
* axes). Monoclinic: the full symbol reads along a, b, c (ITA 6th ed. § 2.1.3.15, p. 171), the
|
|
15
|
+
* orthorhombic row. Triclinic: no symmetry direction.
|
|
16
|
+
*/
|
|
17
|
+
export declare const LATTICE_SYMMETRY_DIRECTIONS: Readonly<Record<CrystalFamily, readonly (readonly Uvw[])[]>>;
|
|
18
|
+
//# sourceMappingURL=symmetryDirections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"symmetryDirections.d.ts","sourceRoot":"","sources":["../src/symmetryDirections.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,wFAAwF;AACxF,MAAM,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAKpD;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,SAAS,CAAC,SAAS,GAAG,EAAE,CAAC,EAAE,CAAC,CAiDnG,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The symmetry directions of the crystal families: the lattice directions along which the
|
|
3
|
+
* symmetry elements of a crystallographic point group lie, grouped by their position in the full
|
|
4
|
+
* Hermann–Mauguin symbol. Data from ITA Table 2.1.3.1 (docs/conventions.md, "Symmetry
|
|
5
|
+
* directions and elements"); `symmetryDirections.reference.test.ts` re-reads the transcription and requires the
|
|
6
|
+
* same directions, in the same order and with the same signs.
|
|
7
|
+
*/
|
|
8
|
+
const frozen = (rows) => Object.freeze(rows.map((dirs) => Object.freeze(dirs.map((d) => Object.freeze(d)))));
|
|
9
|
+
/**
|
|
10
|
+
* The directions of each position of the full symbol, per family, as printed in ITA Table 2.1.3.1
|
|
11
|
+
* (hexagonal family: the row "Hexagonal", which also serves the trigonal classes with hexagonal
|
|
12
|
+
* axes). Monoclinic: the full symbol reads along a, b, c (ITA 6th ed. § 2.1.3.15, p. 171), the
|
|
13
|
+
* orthorhombic row. Triclinic: no symmetry direction.
|
|
14
|
+
*/
|
|
15
|
+
export const LATTICE_SYMMETRY_DIRECTIONS = Object.freeze({
|
|
16
|
+
triclinic: frozen([]),
|
|
17
|
+
monoclinic: frozen([[[1, 0, 0]], [[0, 1, 0]], [[0, 0, 1]]]),
|
|
18
|
+
orthorhombic: frozen([[[1, 0, 0]], [[0, 1, 0]], [[0, 0, 1]]]),
|
|
19
|
+
tetragonal: frozen([
|
|
20
|
+
[[0, 0, 1]],
|
|
21
|
+
[
|
|
22
|
+
[1, 0, 0],
|
|
23
|
+
[0, 1, 0],
|
|
24
|
+
],
|
|
25
|
+
[
|
|
26
|
+
[1, -1, 0],
|
|
27
|
+
[1, 1, 0],
|
|
28
|
+
],
|
|
29
|
+
]),
|
|
30
|
+
hexagonal: frozen([
|
|
31
|
+
[[0, 0, 1]],
|
|
32
|
+
[
|
|
33
|
+
[1, 0, 0],
|
|
34
|
+
[0, 1, 0],
|
|
35
|
+
[-1, -1, 0],
|
|
36
|
+
],
|
|
37
|
+
[
|
|
38
|
+
[1, -1, 0],
|
|
39
|
+
[1, 2, 0],
|
|
40
|
+
[-2, -1, 0],
|
|
41
|
+
],
|
|
42
|
+
]),
|
|
43
|
+
cubic: frozen([
|
|
44
|
+
[
|
|
45
|
+
[1, 0, 0],
|
|
46
|
+
[0, 1, 0],
|
|
47
|
+
[0, 0, 1],
|
|
48
|
+
],
|
|
49
|
+
[
|
|
50
|
+
[1, 1, 1],
|
|
51
|
+
[1, -1, -1],
|
|
52
|
+
[-1, 1, -1],
|
|
53
|
+
[-1, -1, 1],
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
[1, -1, 0],
|
|
57
|
+
[1, 1, 0],
|
|
58
|
+
[0, 1, -1],
|
|
59
|
+
[0, 1, 1],
|
|
60
|
+
[-1, 0, 1],
|
|
61
|
+
[1, 0, 1],
|
|
62
|
+
],
|
|
63
|
+
]),
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=symmetryDirections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"symmetryDirections.js","sourceRoot":"","sources":["../src/symmetryDirections.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,MAAM,MAAM,GAAG,CAAC,IAAkC,EAA+B,EAAE,CACjF,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,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,CAAC,CAAC,EAAE,CAAC,CAAC;SACZ;QACD;YACE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;YACV,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACT,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SACZ;KACF,CAAC;IACF,KAAK,EAAE,MAAM,CAAC;QACZ;YACE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACT,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACT,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;SACV;QACD;YACE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACT,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACX,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YACX,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;SACZ;QACD;YACE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;YACV,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACT,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YACV,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACT,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACV,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;SACV;KACF,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Numeric tolerances, in one place. The values differ on purpose: each gates a different quantity.
|
|
3
|
+
*/
|
|
4
|
+
/** Two matrix entries (or vector components) closer than this are equal. */
|
|
5
|
+
export declare const EPSILON = 0.000001;
|
|
6
|
+
/**
|
|
7
|
+
* During group closure, an entry closer than this to one of the exact values in `SNAP_VALUES`
|
|
8
|
+
* (linalg.ts) is replaced by it, so rounding errors cannot accumulate over repeated products.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SNAP_EPSILON = 1e-9;
|
|
11
|
+
//# sourceMappingURL=tolerances.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tolerances.d.ts","sourceRoot":"","sources":["../src/tolerances.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,4EAA4E;AAC5E,eAAO,MAAM,OAAO,WAAO,CAAC;AAE5B;;;GAGG;AACH,eAAO,MAAM,YAAY,OAAO,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Numeric tolerances, in one place. The values differ on purpose: each gates a different quantity.
|
|
3
|
+
*/
|
|
4
|
+
/** Two matrix entries (or vector components) closer than this are equal. */
|
|
5
|
+
export const EPSILON = 1e-6;
|
|
6
|
+
/**
|
|
7
|
+
* During group closure, an entry closer than this to one of the exact values in `SNAP_VALUES`
|
|
8
|
+
* (linalg.ts) is replaced by it, so rounding errors cannot accumulate over repeated products.
|
|
9
|
+
*/
|
|
10
|
+
export const SNAP_EPSILON = 1e-9;
|
|
11
|
+
//# sourceMappingURL=tolerances.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tolerances.js","sourceRoot":"","sources":["../src/tolerances.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,4EAA4E;AAC5E,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC;AAE5B;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC"}
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "symcrys",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Crystallographic symmetry calculations: point groups (crystallographic and magnetic), their settings, symbols and properties, and property tensors. TypeScript library without dependencies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"crystallography",
|
|
@@ -47,16 +47,18 @@
|
|
|
47
47
|
"build": "node node_modules/typescript/bin/tsc -p tsconfig.build.json",
|
|
48
48
|
"check:dist": "node scripts/check-dist.mjs",
|
|
49
49
|
"prepack": "npm run build",
|
|
50
|
-
"audit:point-groups": "vitest run --config audit/point-groups/vitest.config.ts"
|
|
50
|
+
"audit:point-groups": "vitest run --config audit/point-groups/vitest.config.ts",
|
|
51
|
+
"audit:birss-app": "vitest run --config audit/birss-app/vitest.config.ts && prettier --write src/pointGroups/birssApp.pins.fixtures.ts",
|
|
52
|
+
"audit:wyckoff-2006": "vitest run --config audit/wyckoff-2006/vitest.config.ts"
|
|
51
53
|
},
|
|
52
54
|
"devDependencies": {
|
|
53
55
|
"@eslint/js": "10.0.1",
|
|
54
56
|
"@types/node": "22.20.5",
|
|
55
|
-
"eslint": "10.
|
|
57
|
+
"eslint": "10.15.0",
|
|
56
58
|
"globals": "17.14.0",
|
|
57
59
|
"prettier": "3.9.10",
|
|
58
60
|
"typescript": "6.0.3",
|
|
59
|
-
"typescript-eslint": "8.
|
|
61
|
+
"typescript-eslint": "8.73.0",
|
|
60
62
|
"typescript7": "npm:typescript@7.0.2",
|
|
61
63
|
"vitest": "5.1.0"
|
|
62
64
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,3 +3,52 @@
|
|
|
3
3
|
* everything else is internal.
|
|
4
4
|
*/
|
|
5
5
|
export { VERSION } from './version.js';
|
|
6
|
+
|
|
7
|
+
export type { Mat3, Vec3 } from './linalg.js';
|
|
8
|
+
export type { Operation } from './operations.js';
|
|
9
|
+
export {
|
|
10
|
+
crystalFamily,
|
|
11
|
+
latticeBasis,
|
|
12
|
+
type CrystalFamily,
|
|
13
|
+
type CrystalSystem,
|
|
14
|
+
type FixedAngleFamily,
|
|
15
|
+
} from './lattice.js';
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
POINT_GROUP_KEYS,
|
|
19
|
+
findPointGroup,
|
|
20
|
+
generators,
|
|
21
|
+
isPointGroupKey,
|
|
22
|
+
operations,
|
|
23
|
+
pointGroup,
|
|
24
|
+
pointGroups,
|
|
25
|
+
settings,
|
|
26
|
+
symbol,
|
|
27
|
+
type Convention,
|
|
28
|
+
type PointGroup,
|
|
29
|
+
type PointGroupInSetting,
|
|
30
|
+
type PointGroupKey,
|
|
31
|
+
type PointGroupType,
|
|
32
|
+
type Setting,
|
|
33
|
+
type SettingOptions,
|
|
34
|
+
type SymbolOptions,
|
|
35
|
+
} from './pointGroups/pointGroups.js';
|
|
36
|
+
export { isCentrosymmetric, isChiral, isPolar, laueClass } from './pointGroups/properties.js';
|
|
37
|
+
export { LATTICE_SYMMETRY_DIRECTIONS, type Uvw } from './symmetryDirections.js';
|
|
38
|
+
export {
|
|
39
|
+
describeOperations,
|
|
40
|
+
symmetryDirections,
|
|
41
|
+
type Axis,
|
|
42
|
+
type DirectionElements,
|
|
43
|
+
type OperationDescription,
|
|
44
|
+
type OperationKind,
|
|
45
|
+
type SymmetryDirection,
|
|
46
|
+
} from './pointGroups/elements.js';
|
|
47
|
+
export { siteSymmetry, type SiteSymmetry, type SiteSymmetryOptions } from './siteSymmetry.js';
|
|
48
|
+
export {
|
|
49
|
+
wyckoffPositionOf,
|
|
50
|
+
wyckoffPositions,
|
|
51
|
+
type Hkl,
|
|
52
|
+
type WyckoffOptions,
|
|
53
|
+
type WyckoffPosition,
|
|
54
|
+
} from './pointGroups/wyckoff.js';
|
package/src/lattice.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Crystal systems and families, and how the conventional lattice basis sits in the Cartesian frame
|
|
3
|
+
* of symcrys (docs/conventions.md, "Cartesian frame").
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Mat3 } from './linalg.js';
|
|
7
|
+
|
|
8
|
+
export type CrystalSystem =
|
|
9
|
+
'triclinic' | 'monoclinic' | 'orthorhombic' | 'tetragonal' | 'trigonal' | 'hexagonal' | 'cubic';
|
|
10
|
+
|
|
11
|
+
export type CrystalFamily = 'triclinic' | 'monoclinic' | 'orthorhombic' | 'tetragonal' | 'hexagonal' | 'cubic';
|
|
12
|
+
|
|
13
|
+
/** The crystal family of a crystal system: trigonal and hexagonal form the hexagonal family. */
|
|
14
|
+
export function crystalFamily(system: CrystalSystem): CrystalFamily {
|
|
15
|
+
return system === 'trigonal' ? 'hexagonal' : system;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The families whose cell angles are fixed, so that their lattice basis is fixed up to edge lengths. */
|
|
19
|
+
export type FixedAngleFamily = 'orthorhombic' | 'tetragonal' | 'hexagonal' | 'cubic';
|
|
20
|
+
|
|
21
|
+
const S3_2 = Math.sqrt(3) / 2;
|
|
22
|
+
|
|
23
|
+
/** A deeply frozen matrix: the apps run dist/ as plain JavaScript, where `readonly` does not hold. */
|
|
24
|
+
const frozen = (m: [number, number, number][]): Mat3 =>
|
|
25
|
+
Object.freeze(m.map((row) => Object.freeze(row))) as unknown as Mat3;
|
|
26
|
+
|
|
27
|
+
const ORTHONORMAL = frozen([
|
|
28
|
+
[1, 0, 0],
|
|
29
|
+
[0, 1, 0],
|
|
30
|
+
[0, 0, 1],
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
const HEXAGONAL = frozen([
|
|
34
|
+
[1, -0.5, 0],
|
|
35
|
+
[0, S3_2, 0],
|
|
36
|
+
[0, 0, 1],
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The conventional basis vectors a, b, c as the **columns** of a Cartesian matrix, with unit edge
|
|
41
|
+
* lengths (a frozen array, shared between calls). Hexagonal family (hexagonal axes): x ∥ a, z ∥ c, y = z × x, so b points at 120° from a.
|
|
42
|
+
* Orthorhombic, tetragonal, cubic: x ∥ a, y ∥ b, z ∥ c.
|
|
43
|
+
*
|
|
44
|
+
* The edge lengths are set to 1 because the symmetry directions of these families, and so the
|
|
45
|
+
* point operations, do not depend on them. For a direction [uvw] that is not a symmetry direction,
|
|
46
|
+
* scale the columns by the real edge lengths first.
|
|
47
|
+
*/
|
|
48
|
+
export function latticeBasis(family: FixedAngleFamily): Mat3 {
|
|
49
|
+
switch (family) {
|
|
50
|
+
case 'hexagonal':
|
|
51
|
+
return HEXAGONAL;
|
|
52
|
+
case 'orthorhombic':
|
|
53
|
+
case 'tetragonal':
|
|
54
|
+
case 'cubic':
|
|
55
|
+
return ORTHONORMAL;
|
|
56
|
+
default:
|
|
57
|
+
throw new RangeError(`latticeBasis: no fixed basis for the crystal family ${String(family)}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
package/src/linalg.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 3×3 linear algebra on Cartesian vectors and matrices. Matrices are row-major: `m[i][j]` is row
|
|
3
|
+
* i, column j, and a matrix acts on a column vector from the left.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { EPSILON, SNAP_EPSILON } from './tolerances.js';
|
|
7
|
+
|
|
8
|
+
/** A Cartesian vector. */
|
|
9
|
+
export type Vec3 = readonly [number, number, number];
|
|
10
|
+
|
|
11
|
+
/** A Cartesian 3×3 matrix, as three rows. */
|
|
12
|
+
export type Mat3 = readonly [Vec3, Vec3, Vec3];
|
|
13
|
+
|
|
14
|
+
export const IDENTITY: Mat3 = [
|
|
15
|
+
[1, 0, 0],
|
|
16
|
+
[0, 1, 0],
|
|
17
|
+
[0, 0, 1],
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
export const INVERSION: Mat3 = [
|
|
21
|
+
[-1, 0, 0],
|
|
22
|
+
[0, -1, 0],
|
|
23
|
+
[0, 0, -1],
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
/** Builds a matrix from a row accessor. */
|
|
27
|
+
function build(f: (i: number, j: number) => number): Mat3 {
|
|
28
|
+
return [
|
|
29
|
+
[f(0, 0), f(0, 1), f(0, 2)],
|
|
30
|
+
[f(1, 0), f(1, 1), f(1, 2)],
|
|
31
|
+
[f(2, 0), f(2, 1), f(2, 2)],
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The product a·b. */
|
|
36
|
+
export function multiply(a: Mat3, b: Mat3): Mat3 {
|
|
37
|
+
return build((i, j) => a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The matrix applied to a vector, m·v. */
|
|
41
|
+
export function apply(m: Mat3, v: Vec3): Vec3 {
|
|
42
|
+
return [
|
|
43
|
+
m[0][0] * v[0] + m[0][1] * v[1] + m[0][2] * v[2],
|
|
44
|
+
m[1][0] * v[0] + m[1][1] * v[1] + m[1][2] * v[2],
|
|
45
|
+
m[2][0] * v[0] + m[2][1] * v[1] + m[2][2] * v[2],
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function transpose(a: Mat3): Mat3 {
|
|
50
|
+
return build((i, j) => a[j][i]);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function det(a: Mat3): number {
|
|
54
|
+
return (
|
|
55
|
+
a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) -
|
|
56
|
+
a[0][1] * (a[1][0] * a[2][2] - a[1][2] * a[2][0]) +
|
|
57
|
+
a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0])
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function trace(a: Mat3): number {
|
|
62
|
+
return a[0][0] + a[1][1] + a[2][2];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Proper rotation by `angleDeg` degrees about the z axis (counter-clockwise seen from +z). */
|
|
66
|
+
export function rotationZ(angleDeg: number): Mat3 {
|
|
67
|
+
const r = (angleDeg * Math.PI) / 180;
|
|
68
|
+
const c = Math.cos(r);
|
|
69
|
+
const s = Math.sin(r);
|
|
70
|
+
return snap([
|
|
71
|
+
[c, -s, 0],
|
|
72
|
+
[s, c, 0],
|
|
73
|
+
[0, 0, 1],
|
|
74
|
+
]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Proper rotation by `angleDeg` degrees about the x axis. */
|
|
78
|
+
export function rotationX(angleDeg: number): Mat3 {
|
|
79
|
+
const r = (angleDeg * Math.PI) / 180;
|
|
80
|
+
const c = Math.cos(r);
|
|
81
|
+
const s = Math.sin(r);
|
|
82
|
+
return snap([
|
|
83
|
+
[1, 0, 0],
|
|
84
|
+
[0, c, -s],
|
|
85
|
+
[0, s, c],
|
|
86
|
+
]);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Proper rotation by `angleDeg` degrees about the y axis. */
|
|
90
|
+
export function rotationY(angleDeg: number): Mat3 {
|
|
91
|
+
const r = (angleDeg * Math.PI) / 180;
|
|
92
|
+
const c = Math.cos(r);
|
|
93
|
+
const s = Math.sin(r);
|
|
94
|
+
return snap([
|
|
95
|
+
[c, 0, s],
|
|
96
|
+
[0, 1, 0],
|
|
97
|
+
[-s, 0, c],
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Exact values for snapping: the entries of every point-group operation in the frames of symcrys
|
|
103
|
+
* (0, ±1, and ±1/2, ±√3/2 in the trigonal and hexagonal groups), and ±√2/2, the entries of the
|
|
104
|
+
* 45° setting frame (rotationZ(45), which is snapped as well).
|
|
105
|
+
*/
|
|
106
|
+
const SNAP_VALUES = [0, 1, -1, 0.5, -0.5, Math.SQRT1_2, -Math.SQRT1_2, Math.sqrt(3) / 2, -Math.sqrt(3) / 2];
|
|
107
|
+
|
|
108
|
+
/** Replaces each entry within SNAP_EPSILON of an exact value by that value (this also turns −0 into 0). */
|
|
109
|
+
export function snap(a: Mat3): Mat3 {
|
|
110
|
+
return build((i, j) => {
|
|
111
|
+
const v = a[i][j];
|
|
112
|
+
for (const s of SNAP_VALUES) if (Math.abs(v - s) < SNAP_EPSILON) return s;
|
|
113
|
+
return v;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** True if all entries agree within EPSILON. */
|
|
118
|
+
export function matricesEqual(a: Mat3, b: Mat3): boolean {
|
|
119
|
+
for (let i = 0; i < 3; i++) for (let j = 0; j < 3; j++) if (Math.abs(a[i][j] - b[i][j]) > EPSILON) return false;
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** The inverse of a regular matrix (by the adjugate); throws for a singular one. */
|
|
124
|
+
export function inverse(a: Mat3): Mat3 {
|
|
125
|
+
const d = det(a);
|
|
126
|
+
if (Math.abs(d) < EPSILON) throw new RangeError('inverse: singular matrix');
|
|
127
|
+
const c = (i: number, j: number): number => {
|
|
128
|
+
const [r0, r1] = [0, 1, 2].filter((k) => k !== i);
|
|
129
|
+
const [s0, s1] = [0, 1, 2].filter((k) => k !== j);
|
|
130
|
+
return a[r0][s0] * a[r1][s1] - a[r0][s1] * a[r1][s0];
|
|
131
|
+
};
|
|
132
|
+
return build((i, j) => ((i + j) % 2 === 0 ? 1 : -1) * (c(j, i) / d));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** The transformed matrix s·a·sᵀ, for an orthogonal s. */
|
|
136
|
+
export function conjugate(a: Mat3, s: Mat3): Mat3 {
|
|
137
|
+
return multiply(multiply(s, a), transpose(s));
|
|
138
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Point operations: a Cartesian matrix, optionally combined with time reversal, and the closure of
|
|
3
|
+
* a set of generators into a group.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { IDENTITY, conjugate, matricesEqual, multiply, snap, type Mat3 } from './linalg.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A point operation: an orthogonal Cartesian matrix (rotation, rotoinversion, mirror, inversion),
|
|
10
|
+
* combined with time reversal if `timeReversal` is true (a primed operation).
|
|
11
|
+
*/
|
|
12
|
+
export interface Operation {
|
|
13
|
+
readonly matrix: Mat3;
|
|
14
|
+
readonly timeReversal: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** No point group has more than 48 operations (96 with time reversal); a closure beyond this is a data error. */
|
|
18
|
+
export const MAX_GROUP_ORDER = 200;
|
|
19
|
+
|
|
20
|
+
export const IDENTITY_OPERATION: Operation = { matrix: IDENTITY, timeReversal: false };
|
|
21
|
+
|
|
22
|
+
/** A unitary operation (no time reversal). */
|
|
23
|
+
export function operation(matrix: Mat3): Operation {
|
|
24
|
+
return { matrix, timeReversal: false };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The product a·b: first b, then a. */
|
|
28
|
+
export function compose(a: Operation, b: Operation): Operation {
|
|
29
|
+
return { matrix: snap(multiply(a.matrix, b.matrix)), timeReversal: a.timeReversal !== b.timeReversal };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function operationsEqual(a: Operation, b: Operation): boolean {
|
|
33
|
+
return a.timeReversal === b.timeReversal && matricesEqual(a.matrix, b.matrix);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The operation expressed in a frame rotated by `s` (orthogonal): s·W·sᵀ. */
|
|
37
|
+
export function transformOperation(op: Operation, s: Mat3): Operation {
|
|
38
|
+
return { matrix: snap(conjugate(op.matrix, s)), timeReversal: op.timeReversal };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The group generated by `generators`: the identity first, then the generators, then products in
|
|
43
|
+
* the order they are found. The order of the result is therefore fixed by the generators.
|
|
44
|
+
* Throws if the closure exceeds the order of any point group (a sign of wrong input data).
|
|
45
|
+
*/
|
|
46
|
+
export function closeGroup(generators: readonly Operation[]): Operation[] {
|
|
47
|
+
const group: Operation[] = [IDENTITY_OPERATION];
|
|
48
|
+
const add = (op: Operation): boolean => {
|
|
49
|
+
if (group.some((g) => operationsEqual(g, op))) return false;
|
|
50
|
+
if (group.length >= MAX_GROUP_ORDER)
|
|
51
|
+
throw new Error('closeGroup: closure does not terminate; check the generators');
|
|
52
|
+
group.push(op);
|
|
53
|
+
return true;
|
|
54
|
+
};
|
|
55
|
+
for (const g of generators) add({ matrix: snap(g.matrix), timeReversal: g.timeReversal });
|
|
56
|
+
for (let i = 0; i < group.length; i++) {
|
|
57
|
+
for (let j = 0; j <= i; j++) {
|
|
58
|
+
add(compose(group[i], group[j]));
|
|
59
|
+
add(compose(group[j], group[i]));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return group;
|
|
63
|
+
}
|