symcrys 0.1.0 → 0.2.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 +35 -12
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -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/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 +5 -4
- package/src/index.ts +41 -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/symmetryDirections.ts +72 -0
- package/src/tolerances.ts +12 -0
- package/src/version.ts +1 -1
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
|
+
}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The 32 crystallographic point groups (crystal classes) as data: generators, settings and symbols.
|
|
3
|
+
*
|
|
4
|
+
* Generators are stored in the Birss frame (docs/conventions.md); every setting is a rotation of
|
|
5
|
+
* that frame, and the ITC settings are among them. The print anchors and their tests are listed in
|
|
6
|
+
* docs/conventions.md, "Sources"; never derive data here from symcrys output.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { IDENTITY, INVERSION, multiply, rotationX, rotationY, rotationZ, type Mat3 } from '../linalg.js';
|
|
10
|
+
import { operation, type Operation } from '../operations.js';
|
|
11
|
+
import type { CrystalSystem } from '../lattice.js';
|
|
12
|
+
|
|
13
|
+
/** Keys of the 32 crystal classes: the ITC short symbol of the class (docs/conventions.md, "Keys"). */
|
|
14
|
+
export const POINT_GROUP_KEYS = Object.freeze([
|
|
15
|
+
'1',
|
|
16
|
+
'-1',
|
|
17
|
+
'2',
|
|
18
|
+
'm',
|
|
19
|
+
'2/m',
|
|
20
|
+
'222',
|
|
21
|
+
'mm2',
|
|
22
|
+
'mmm',
|
|
23
|
+
'4',
|
|
24
|
+
'-4',
|
|
25
|
+
'4/m',
|
|
26
|
+
'422',
|
|
27
|
+
'4mm',
|
|
28
|
+
'-42m',
|
|
29
|
+
'4/mmm',
|
|
30
|
+
'3',
|
|
31
|
+
'-3',
|
|
32
|
+
'32',
|
|
33
|
+
'3m',
|
|
34
|
+
'-3m',
|
|
35
|
+
'6',
|
|
36
|
+
'-6',
|
|
37
|
+
'6/m',
|
|
38
|
+
'622',
|
|
39
|
+
'6mm',
|
|
40
|
+
'-6m2',
|
|
41
|
+
'6/mmm',
|
|
42
|
+
'23',
|
|
43
|
+
'm-3',
|
|
44
|
+
'432',
|
|
45
|
+
'-43m',
|
|
46
|
+
'm-3m',
|
|
47
|
+
] as const);
|
|
48
|
+
|
|
49
|
+
export type PointGroupKey = (typeof POINT_GROUP_KEYS)[number];
|
|
50
|
+
|
|
51
|
+
/** A symbol in one convention: the short symbol of the setting and the full symbol, positions separated by spaces. */
|
|
52
|
+
interface SymbolForms {
|
|
53
|
+
readonly short: string;
|
|
54
|
+
readonly full: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface SettingData {
|
|
58
|
+
/** Orthogonal matrix s: the setting's operations are s·W·sᵀ for the stored operations W. */
|
|
59
|
+
readonly frame: Mat3;
|
|
60
|
+
/** Monoclinic: the unique axis; orthorhombic mm2: the axis of the twofold rotation. */
|
|
61
|
+
readonly uniqueAxis?: 'a' | 'b' | 'c';
|
|
62
|
+
readonly itc: SymbolForms;
|
|
63
|
+
readonly birss: SymbolForms;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface PointGroupData {
|
|
67
|
+
readonly key: PointGroupKey;
|
|
68
|
+
readonly crystalSystem: CrystalSystem;
|
|
69
|
+
readonly schoenflies: string;
|
|
70
|
+
/** Generators in the stored (Birss) frame, which is setting 1. */
|
|
71
|
+
readonly generators: readonly Operation[];
|
|
72
|
+
/** Setting 1 first; its frame is the identity. */
|
|
73
|
+
readonly settings: readonly SettingData[];
|
|
74
|
+
/** The ITC default setting (1-based). The Birss default is always setting 1. */
|
|
75
|
+
readonly itcDefault: number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// --- Matrices in the stored (Birss) frame ---------------------------------------------------------
|
|
79
|
+
|
|
80
|
+
const ROT2_Z = rotationZ(180);
|
|
81
|
+
const ROT2_X = rotationX(180);
|
|
82
|
+
const ROT2_Y = rotationY(180);
|
|
83
|
+
const ROT4_Z = rotationZ(90);
|
|
84
|
+
const ROT3_Z = rotationZ(120);
|
|
85
|
+
const ROT6_Z = rotationZ(60);
|
|
86
|
+
const ROT4_X = rotationX(90);
|
|
87
|
+
const ROTINV4_Z = multiply(ROT4_Z, INVERSION);
|
|
88
|
+
const ROTINV3_Z = multiply(ROT3_Z, INVERSION);
|
|
89
|
+
const ROTINV6_Z = multiply(ROT6_Z, INVERSION);
|
|
90
|
+
const MIRROR_X: Mat3 = [
|
|
91
|
+
[-1, 0, 0],
|
|
92
|
+
[0, 1, 0],
|
|
93
|
+
[0, 0, 1],
|
|
94
|
+
];
|
|
95
|
+
const MIRROR_Y: Mat3 = [
|
|
96
|
+
[1, 0, 0],
|
|
97
|
+
[0, -1, 0],
|
|
98
|
+
[0, 0, 1],
|
|
99
|
+
];
|
|
100
|
+
const MIRROR_Z: Mat3 = [
|
|
101
|
+
[1, 0, 0],
|
|
102
|
+
[0, 1, 0],
|
|
103
|
+
[0, 0, -1],
|
|
104
|
+
];
|
|
105
|
+
/** Mirror with normal [1-10] (swaps x and y). */
|
|
106
|
+
const MIRROR_XY: Mat3 = [
|
|
107
|
+
[0, 1, 0],
|
|
108
|
+
[1, 0, 0],
|
|
109
|
+
[0, 0, 1],
|
|
110
|
+
];
|
|
111
|
+
/** Threefold rotation about [111], mapping the vector x to y, y to z, z to x. */
|
|
112
|
+
const ROT3_111: Mat3 = [
|
|
113
|
+
[0, 0, 1],
|
|
114
|
+
[1, 0, 0],
|
|
115
|
+
[0, 1, 0],
|
|
116
|
+
];
|
|
117
|
+
|
|
118
|
+
// --- Setting frames -------------------------------------------------------------------------------
|
|
119
|
+
|
|
120
|
+
const SAME: Mat3 = [
|
|
121
|
+
[1, 0, 0],
|
|
122
|
+
[0, 1, 0],
|
|
123
|
+
[0, 0, 1],
|
|
124
|
+
];
|
|
125
|
+
/** Monoclinic, c-unique (stored) → b-unique: z → y. Proper rotation. */
|
|
126
|
+
const MONOCLINIC_B: Mat3 = [
|
|
127
|
+
[-1, 0, 0],
|
|
128
|
+
[0, 0, 1],
|
|
129
|
+
[0, 1, 0],
|
|
130
|
+
];
|
|
131
|
+
/** Orthorhombic: the axis along z (stored) moves to x (cyclic x → y → z → x). */
|
|
132
|
+
const ORTHO_TO_A: Mat3 = [
|
|
133
|
+
[0, 0, 1],
|
|
134
|
+
[1, 0, 0],
|
|
135
|
+
[0, 1, 0],
|
|
136
|
+
];
|
|
137
|
+
/** Orthorhombic: the axis along z (stored) moves to y (cyclic x → z → y → x). */
|
|
138
|
+
const ORTHO_TO_B: Mat3 = [
|
|
139
|
+
[0, 1, 0],
|
|
140
|
+
[0, 0, 1],
|
|
141
|
+
[1, 0, 0],
|
|
142
|
+
];
|
|
143
|
+
const ROT45_Z = rotationZ(45);
|
|
144
|
+
const ROT30_Z = rotationZ(30);
|
|
145
|
+
|
|
146
|
+
// --- Helpers ---------------------------------------------------------------------------------------
|
|
147
|
+
|
|
148
|
+
const ops = (...matrices: Mat3[]): Operation[] => matrices.map(operation);
|
|
149
|
+
|
|
150
|
+
/** A setting whose symbols are the same in both conventions. */
|
|
151
|
+
function setting(frame: Mat3, short: string, full: string, uniqueAxis?: 'a' | 'b' | 'c'): SettingData {
|
|
152
|
+
const forms = { short, full };
|
|
153
|
+
return uniqueAxis ? { frame, uniqueAxis, itc: forms, birss: forms } : { frame, itc: forms, birss: forms };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** A group with one setting whose symbols agree in both conventions. */
|
|
157
|
+
function group(
|
|
158
|
+
key: PointGroupKey,
|
|
159
|
+
crystalSystem: CrystalSystem,
|
|
160
|
+
schoenflies: string,
|
|
161
|
+
generators: Operation[],
|
|
162
|
+
full: string = key,
|
|
163
|
+
): PointGroupData {
|
|
164
|
+
return { key, crystalSystem, schoenflies, generators, settings: [setting(SAME, key, full)], itcDefault: 1 };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Trigonal and hexagonal groups whose two settings differ by 30° about z. Symbol position 2 means
|
|
169
|
+
* the a direction (x) in ITC and the y direction in Birss, so each frame carries, in one
|
|
170
|
+
* convention, the symbol the other convention gives to the other frame (docs/conventions.md).
|
|
171
|
+
* `secondary` is the ITC symbol with the lateral elements in the a direction; ITC's default is
|
|
172
|
+
* that frame, setting 2. Birss's default, setting 1, carries Birss's printed short symbol, the key.
|
|
173
|
+
*/
|
|
174
|
+
function trigonalPair(
|
|
175
|
+
key: PointGroupKey,
|
|
176
|
+
crystalSystem: CrystalSystem,
|
|
177
|
+
schoenflies: string,
|
|
178
|
+
generators: Operation[],
|
|
179
|
+
secondary: SymbolForms,
|
|
180
|
+
tertiary: SymbolForms,
|
|
181
|
+
): PointGroupData {
|
|
182
|
+
return {
|
|
183
|
+
key,
|
|
184
|
+
crystalSystem,
|
|
185
|
+
schoenflies,
|
|
186
|
+
generators,
|
|
187
|
+
settings: [
|
|
188
|
+
{ frame: SAME, itc: tertiary, birss: { short: key, full: secondary.full } },
|
|
189
|
+
{ frame: ROT30_Z, itc: secondary, birss: tertiary },
|
|
190
|
+
],
|
|
191
|
+
itcDefault: 2,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function monoclinic(key: PointGroupKey, schoenflies: string, generators: Operation[], full: (axis: string) => string) {
|
|
196
|
+
const data: PointGroupData = {
|
|
197
|
+
key,
|
|
198
|
+
crystalSystem: 'monoclinic',
|
|
199
|
+
schoenflies,
|
|
200
|
+
generators,
|
|
201
|
+
settings: [setting(SAME, key, full('c'), 'c'), setting(MONOCLINIC_B, key, full('b'), 'b')],
|
|
202
|
+
itcDefault: 2,
|
|
203
|
+
};
|
|
204
|
+
return data;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// --- The 32 crystal classes -----------------------------------------------------------------------
|
|
208
|
+
|
|
209
|
+
export const POINT_GROUP_DATA: readonly PointGroupData[] = [
|
|
210
|
+
group('1', 'triclinic', 'C1', ops(IDENTITY)),
|
|
211
|
+
group('-1', 'triclinic', 'Ci', ops(INVERSION)),
|
|
212
|
+
|
|
213
|
+
monoclinic('2', 'C2', ops(ROT2_Z), (u) => (u === 'c' ? '1 1 2' : '1 2 1')),
|
|
214
|
+
monoclinic('m', 'Cs', ops(MIRROR_Z), (u) => (u === 'c' ? '1 1 m' : '1 m 1')),
|
|
215
|
+
monoclinic('2/m', 'C2h', ops(ROT2_Z, INVERSION), (u) => (u === 'c' ? '1 1 2/m' : '1 2/m 1')),
|
|
216
|
+
|
|
217
|
+
group('222', 'orthorhombic', 'D2', ops(ROT2_Z, ROT2_X), '2 2 2'),
|
|
218
|
+
{
|
|
219
|
+
key: 'mm2',
|
|
220
|
+
crystalSystem: 'orthorhombic',
|
|
221
|
+
schoenflies: 'C2v',
|
|
222
|
+
generators: ops(ROT2_Z, MIRROR_X),
|
|
223
|
+
settings: [
|
|
224
|
+
setting(SAME, 'mm2', 'm m 2', 'c'),
|
|
225
|
+
setting(ORTHO_TO_A, '2mm', '2 m m', 'a'),
|
|
226
|
+
setting(ORTHO_TO_B, 'm2m', 'm 2 m', 'b'),
|
|
227
|
+
],
|
|
228
|
+
itcDefault: 1,
|
|
229
|
+
},
|
|
230
|
+
group('mmm', 'orthorhombic', 'D2h', ops(ROT2_Z, ROT2_X, INVERSION), '2/m 2/m 2/m'),
|
|
231
|
+
|
|
232
|
+
group('4', 'tetragonal', 'C4', ops(ROT4_Z)),
|
|
233
|
+
group('-4', 'tetragonal', 'S4', ops(ROTINV4_Z)),
|
|
234
|
+
group('4/m', 'tetragonal', 'C4h', ops(ROT4_Z, INVERSION)),
|
|
235
|
+
group('422', 'tetragonal', 'D4', ops(ROT4_Z, ROT2_X), '4 2 2'),
|
|
236
|
+
group('4mm', 'tetragonal', 'C4v', ops(ROT4_Z, MIRROR_X), '4 m m'),
|
|
237
|
+
{
|
|
238
|
+
key: '-42m',
|
|
239
|
+
crystalSystem: 'tetragonal',
|
|
240
|
+
schoenflies: 'D2d',
|
|
241
|
+
generators: ops(ROTINV4_Z, ROT2_X),
|
|
242
|
+
settings: [setting(SAME, '-42m', '-4 2 m'), setting(ROT45_Z, '-4m2', '-4 m 2')],
|
|
243
|
+
itcDefault: 1,
|
|
244
|
+
},
|
|
245
|
+
group('4/mmm', 'tetragonal', 'D4h', ops(ROT4_Z, ROT2_X, INVERSION), '4/m 2/m 2/m'),
|
|
246
|
+
|
|
247
|
+
group('3', 'trigonal', 'C3', ops(ROT3_Z)),
|
|
248
|
+
group('-3', 'trigonal', 'C3i', ops(ROTINV3_Z)),
|
|
249
|
+
trigonalPair(
|
|
250
|
+
'32',
|
|
251
|
+
'trigonal',
|
|
252
|
+
'D3',
|
|
253
|
+
ops(ROT3_Z, ROT2_Y),
|
|
254
|
+
{ short: '321', full: '3 2 1' },
|
|
255
|
+
{ short: '312', full: '3 1 2' },
|
|
256
|
+
),
|
|
257
|
+
trigonalPair(
|
|
258
|
+
'3m',
|
|
259
|
+
'trigonal',
|
|
260
|
+
'C3v',
|
|
261
|
+
ops(ROT3_Z, MIRROR_Y),
|
|
262
|
+
{ short: '3m1', full: '3 m 1' },
|
|
263
|
+
{ short: '31m', full: '3 1 m' },
|
|
264
|
+
),
|
|
265
|
+
trigonalPair(
|
|
266
|
+
'-3m',
|
|
267
|
+
'trigonal',
|
|
268
|
+
'D3d',
|
|
269
|
+
ops(ROT3_Z, ROT2_Y, INVERSION),
|
|
270
|
+
{ short: '-3m1', full: '-3 2/m 1' },
|
|
271
|
+
{ short: '-31m', full: '-3 1 2/m' },
|
|
272
|
+
),
|
|
273
|
+
|
|
274
|
+
group('6', 'hexagonal', 'C6', ops(ROT6_Z)),
|
|
275
|
+
group('-6', 'hexagonal', 'C3h', ops(ROTINV6_Z)),
|
|
276
|
+
group('6/m', 'hexagonal', 'C6h', ops(ROT6_Z, INVERSION)),
|
|
277
|
+
group('622', 'hexagonal', 'D6', ops(ROT6_Z, ROT2_Y), '6 2 2'),
|
|
278
|
+
group('6mm', 'hexagonal', 'C6v', ops(ROT6_Z, MIRROR_Y), '6 m m'),
|
|
279
|
+
trigonalPair(
|
|
280
|
+
'-6m2',
|
|
281
|
+
'hexagonal',
|
|
282
|
+
'D3h',
|
|
283
|
+
ops(ROTINV6_Z, MIRROR_Y),
|
|
284
|
+
{ short: '-6m2', full: '-6 m 2' },
|
|
285
|
+
{ short: '-62m', full: '-6 2 m' },
|
|
286
|
+
),
|
|
287
|
+
group('6/mmm', 'hexagonal', 'D6h', ops(ROT6_Z, ROT2_Y, INVERSION), '6/m 2/m 2/m'),
|
|
288
|
+
|
|
289
|
+
group('23', 'cubic', 'T', ops(ROT2_Z, ROT2_X, ROT3_111), '2 3'),
|
|
290
|
+
group('m-3', 'cubic', 'Th', ops(ROT2_Z, ROT2_X, ROT3_111, INVERSION), '2/m -3'),
|
|
291
|
+
group('432', 'cubic', 'O', ops(ROT4_Z, ROT4_X, ROT3_111), '4 3 2'),
|
|
292
|
+
group('-43m', 'cubic', 'Td', ops(ROTINV4_Z, ROT3_111, MIRROR_XY), '-4 3 m'),
|
|
293
|
+
group('m-3m', 'cubic', 'Oh', ops(ROT4_Z, ROT4_X, ROT3_111, INVERSION), '4/m -3 2/m'),
|
|
294
|
+
];
|