symcrys 0.8.1 → 0.10.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 +11 -2
- package/dist/plane.d.ts +262 -0
- package/dist/plane.d.ts.map +1 -0
- package/dist/plane.js +300 -0
- package/dist/plane.js.map +1 -0
- package/dist/spaceGroups/affine.d.ts +81 -0
- package/dist/spaceGroups/affine.d.ts.map +1 -0
- package/dist/spaceGroups/affine.js +245 -0
- package/dist/spaceGroups/affine.js.map +1 -0
- package/dist/spaceGroups/cell.d.ts +60 -0
- package/dist/spaceGroups/cell.d.ts.map +1 -0
- package/dist/spaceGroups/cell.js +305 -0
- package/dist/spaceGroups/cell.js.map +1 -0
- package/dist/spaceGroups/describe.d.ts +51 -0
- package/dist/spaceGroups/describe.d.ts.map +1 -0
- package/dist/spaceGroups/describe.js +101 -0
- package/dist/spaceGroups/describe.js.map +1 -0
- package/dist/spaceGroups/planeGroupData.d.ts +44 -0
- package/dist/spaceGroups/planeGroupData.d.ts.map +1 -0
- package/dist/spaceGroups/planeGroupData.js +371 -0
- package/dist/spaceGroups/planeGroupData.js.map +1 -0
- package/dist/spaceGroups/planeGroups.d.ts +28 -0
- package/dist/spaceGroups/planeGroups.d.ts.map +1 -0
- package/dist/spaceGroups/planeGroups.js +61 -0
- package/dist/spaceGroups/planeGroups.js.map +1 -0
- package/dist/spaceGroups/planePointGroups.d.ts +31 -0
- package/dist/spaceGroups/planePointGroups.d.ts.map +1 -0
- package/dist/spaceGroups/planePointGroups.js +77 -0
- package/dist/spaceGroups/planePointGroups.js.map +1 -0
- package/dist/spaceGroups/positions.d.ts +65 -0
- package/dist/spaceGroups/positions.d.ts.map +1 -0
- package/dist/spaceGroups/positions.js +200 -0
- package/dist/spaceGroups/positions.js.map +1 -0
- package/dist/spaceGroups/rational.d.ts +43 -0
- package/dist/spaceGroups/rational.d.ts.map +1 -0
- package/dist/spaceGroups/rational.js +95 -0
- package/dist/spaceGroups/rational.js.map +1 -0
- package/dist/spaceGroups/snap.d.ts +20 -0
- package/dist/spaceGroups/snap.d.ts.map +1 -0
- package/dist/spaceGroups/snap.js +103 -0
- package/dist/spaceGroups/snap.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +7 -2
- package/src/plane.ts +562 -0
- package/src/spaceGroups/affine.ts +315 -0
- package/src/spaceGroups/cell.ts +382 -0
- package/src/spaceGroups/describe.ts +149 -0
- package/src/spaceGroups/planeGroupData.ts +407 -0
- package/src/spaceGroups/planeGroups.ts +75 -0
- package/src/spaceGroups/planePointGroups.ts +90 -0
- package/src/spaceGroups/positions.ts +267 -0
- package/src/spaceGroups/rational.ts +115 -0
- package/src/spaceGroups/snap.ts +121 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The geometric description of an operation of a plane group, as ITA gives it under "Symmetry
|
|
3
|
+
* operations" (ITA 2016, § 2.1.3.9, pp. 160–161): what it is, its order and sense, where its
|
|
4
|
+
* symmetry element lies and its glide part. Structured data; the symbols such as `g(1/2,1/2) x,x`
|
|
5
|
+
* stay with the applications (CLAUDE.md, "Symmetry elements as structured data").
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { determinant, dimensionOf, trace, type ExactOperation, type IntMatrix } from './affine.js';
|
|
9
|
+
import { ZERO, add, multiply, rational, scale, type Rational } from './rational.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* What an operation of a plane group is: `'mirror'` (a reflection in a line, as `'mirror'` of the
|
|
13
|
+
* point groups) and `'glide'` (a glide reflection).
|
|
14
|
+
*/
|
|
15
|
+
export type PlaneOperationKind = 'identity' | 'translation' | 'rotation' | 'mirror' | 'glide';
|
|
16
|
+
|
|
17
|
+
/** One operation of a plane group described geometrically, in the lattice basis. */
|
|
18
|
+
export interface PlaneOperationDescription {
|
|
19
|
+
/** What the operation is. */
|
|
20
|
+
readonly kind: PlaneOperationKind;
|
|
21
|
+
/** The order n of its linear part: 1 for identity and translation, 2 for a mirror or glide. */
|
|
22
|
+
readonly order: number;
|
|
23
|
+
/** For a rotation with n ≥ 3: `'+'` if it turns a towards b, `'-'` otherwise. */
|
|
24
|
+
readonly sense?: '+' | '-';
|
|
25
|
+
/** For a translation: the translation vector. */
|
|
26
|
+
readonly translation?: readonly Rational[];
|
|
27
|
+
/**
|
|
28
|
+
* For a rotation: its centre. For a mirror or glide: a point of its line, on y = 0 unless the line
|
|
29
|
+
* is parallel to it, then on x = 0. Not reduced modulo the lattice: the centre of `-y,x+1/2` is
|
|
30
|
+
* (−1/4, 1/4).
|
|
31
|
+
*/
|
|
32
|
+
readonly location?: readonly Rational[];
|
|
33
|
+
/** For a mirror or glide: the direction of its line, the shortest integer vector, first non-zero component positive. */
|
|
34
|
+
readonly direction?: readonly [number, number];
|
|
35
|
+
/**
|
|
36
|
+
* For a mirror or glide: the normal of its line in the lattice basis, its symmetry direction in
|
|
37
|
+
* the sense of ITA Table 2.1.3.1: the shortest integer vector along the columns of W − I, first
|
|
38
|
+
* non-zero component positive. Without a metric it is not the perpendicular of `direction`: in a
|
|
39
|
+
* hexagonal basis the normal of a line along [1,0] is [1,2].
|
|
40
|
+
*/
|
|
41
|
+
readonly normal?: readonly [number, number];
|
|
42
|
+
/**
|
|
43
|
+
* For a glide: the glide vector (w + W·w)/2, not reduced modulo the lattice. An operation whose
|
|
44
|
+
* glide vector is a non-zero lattice vector is a glide, as it is geometrically, although the
|
|
45
|
+
* symmetry element of its coset is the mirror line, which ITA lists.
|
|
46
|
+
*/
|
|
47
|
+
readonly glide?: readonly Rational[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function gcd(a: number, b: number): number {
|
|
51
|
+
return b === 0 ? Math.abs(a) : gcd(b, a % b);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The shortest integer vector along the non-zero column of a 2 × 2 matrix of rank 1, first non-zero component positive. */
|
|
55
|
+
function primitiveColumn(m: IntMatrix): [number, number] {
|
|
56
|
+
const col = m[0][0] !== 0 || m[1][0] !== 0 ? [m[0][0], m[1][0]] : [m[0][1], m[1][1]];
|
|
57
|
+
const g = gcd(col[0], col[1]);
|
|
58
|
+
const sign = col[0] < 0 || (col[0] === 0 && col[1] < 0) ? -1 : 1;
|
|
59
|
+
return [(sign * col[0]) / g + 0, (sign * col[1]) / g + 0];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function power(m: IntMatrix, n: number): IntMatrix {
|
|
63
|
+
let p: IntMatrix = [
|
|
64
|
+
[1, 0],
|
|
65
|
+
[0, 1],
|
|
66
|
+
];
|
|
67
|
+
for (let k = 0; k < n; k++) {
|
|
68
|
+
p = p.map((row) => [0, 1].map((j) => row[0] * m[0][j] + row[1] * m[1][j]));
|
|
69
|
+
}
|
|
70
|
+
return p;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const isIdentity = (m: IntMatrix): boolean => m[0][0] === 1 && m[0][1] === 0 && m[1][0] === 0 && m[1][1] === 1;
|
|
74
|
+
|
|
75
|
+
/** The order of the rotation part of a proper plane operation, from its trace (also in a hexagonal basis). */
|
|
76
|
+
const ORDER_BY_TRACE: Record<number, number> = { 2: 1, [-2]: 2, [-1]: 3, 0: 4, 1: 6 };
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Describes an operation of a plane group; the result is frozen. Throws unless the operation is two-dimensional with the
|
|
80
|
+
* linear part of a crystallographic plane point group (determinant ±1, order 1, 2, 3, 4 or 6).
|
|
81
|
+
*/
|
|
82
|
+
export function describePlaneOperation(op: ExactOperation): PlaneOperationDescription {
|
|
83
|
+
if (dimensionOf(op) !== 2) {
|
|
84
|
+
throw new RangeError('Not an operation of the plane');
|
|
85
|
+
}
|
|
86
|
+
const w = op.matrix;
|
|
87
|
+
const t = op.translation;
|
|
88
|
+
const det = determinant(w);
|
|
89
|
+
if (det === 1) {
|
|
90
|
+
const n = ORDER_BY_TRACE[trace(w)];
|
|
91
|
+
if (n === undefined || !isIdentity(power(w, n))) {
|
|
92
|
+
throw new RangeError(`Not a crystallographic rotation: ${JSON.stringify(w)}`);
|
|
93
|
+
}
|
|
94
|
+
if (n === 1) {
|
|
95
|
+
return t.every((v) => v[0] === 0)
|
|
96
|
+
? { kind: 'identity', order: 1 }
|
|
97
|
+
: { kind: 'translation', order: 1, translation: [...t] };
|
|
98
|
+
}
|
|
99
|
+
// The centre p solves (I − W) p = w; det(I − W) = 2 − trace W ≠ 0 for a rotation.
|
|
100
|
+
const a = [
|
|
101
|
+
[1 - w[0][0], -w[0][1]],
|
|
102
|
+
[-w[1][0], 1 - w[1][1]],
|
|
103
|
+
];
|
|
104
|
+
const d = a[0][0] * a[1][1] - a[0][1] * a[1][0];
|
|
105
|
+
const inv = rational(1, d);
|
|
106
|
+
const location = [
|
|
107
|
+
multiply(add(scale(a[1][1], t[0]), scale(-a[0][1], t[1])), inv),
|
|
108
|
+
multiply(add(scale(-a[1][0], t[0]), scale(a[0][0], t[1])), inv),
|
|
109
|
+
];
|
|
110
|
+
const description: PlaneOperationDescription = { kind: 'rotation', order: n, location: Object.freeze(location) };
|
|
111
|
+
// The sense: the sign of a × W·a with a = (1, 0), the same in any right-handed basis.
|
|
112
|
+
return Object.freeze(n === 2 ? description : { ...description, sense: w[1][0] > 0 ? '+' : '-' });
|
|
113
|
+
}
|
|
114
|
+
if (det !== -1 || trace(w) !== 0 || !isIdentity(power(w, 2))) {
|
|
115
|
+
throw new RangeError(`Not a crystallographic reflection: ${JSON.stringify(w)}`);
|
|
116
|
+
}
|
|
117
|
+
// A mirror or glide: W² = I. Glide vector g = (w + W·w)/2, along the line; the line is the set of p with (I − W) p = w − g.
|
|
118
|
+
const wt = [add(scale(w[0][0], t[0]), scale(w[0][1], t[1])), add(scale(w[1][0], t[0]), scale(w[1][1], t[1]))];
|
|
119
|
+
const half = rational(1, 2);
|
|
120
|
+
const glide = [multiply(add(t[0], wt[0]), half), multiply(add(t[1], wt[1]), half)];
|
|
121
|
+
const s = [add(t[0], scale(-1, glide[0])), add(t[1], scale(-1, glide[1]))];
|
|
122
|
+
const direction = primitiveColumn([
|
|
123
|
+
[w[0][0] + 1, w[0][1]],
|
|
124
|
+
[w[1][0], w[1][1] + 1],
|
|
125
|
+
]);
|
|
126
|
+
const normal = primitiveColumn([
|
|
127
|
+
[w[0][0] - 1, w[0][1]],
|
|
128
|
+
[w[1][0], w[1][1] - 1],
|
|
129
|
+
]);
|
|
130
|
+
// (I − W) has rank 1; one of its non-zero rows a gives a·p = s_i. A point on y = 0 if the line meets it.
|
|
131
|
+
const a = [
|
|
132
|
+
[1 - w[0][0], -w[0][1]],
|
|
133
|
+
[-w[1][0], 1 - w[1][1]],
|
|
134
|
+
];
|
|
135
|
+
const i = a[0][0] !== 0 || a[0][1] !== 0 ? 0 : 1;
|
|
136
|
+
const location: Rational[] =
|
|
137
|
+
a[i][0] !== 0 ? [multiply(s[i], rational(1, a[i][0])), ZERO] : [ZERO, multiply(s[i], rational(1, a[i][1]))];
|
|
138
|
+
const line = {
|
|
139
|
+
order: 2,
|
|
140
|
+
location: Object.freeze(location),
|
|
141
|
+
direction: Object.freeze(direction),
|
|
142
|
+
normal: Object.freeze(normal),
|
|
143
|
+
};
|
|
144
|
+
return Object.freeze(
|
|
145
|
+
glide.some((v) => v[0] !== 0)
|
|
146
|
+
? { kind: 'glide' as const, ...line, glide: Object.freeze(glide) }
|
|
147
|
+
: { kind: 'mirror' as const, ...line },
|
|
148
|
+
);
|
|
149
|
+
}
|
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The 17 plane groups as ITA prints them (6th ed., 2016, Chapter 2.2, pp. 176–192, plane group n on
|
|
3
|
+
* p. 175 + n). The same data are in references/itc/vol-a-2016-plane-groups.md, which the reference
|
|
4
|
+
* test re-parses and compares with this file; change both only by transcription from print.
|
|
5
|
+
*
|
|
6
|
+
* Notation as in the transcription: a leading `-` is an overbar; coordinates in the lattice basis
|
|
7
|
+
* a, b; `<=` for ≤. The oriented site-symmetry symbols without the spaces of the print.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** A crystal system of the plane, as ITA names it. */
|
|
11
|
+
export type PlaneSystem = 'oblique' | 'rectangular' | 'square' | 'hexagonal';
|
|
12
|
+
|
|
13
|
+
/** [multiplicity, Wyckoff letter, oriented site symmetry, coordinates of the (0,0)+ set]. */
|
|
14
|
+
export type PlaneWyckoffRow = readonly [number, string, string, readonly string[]];
|
|
15
|
+
|
|
16
|
+
/** One plane group as printed. */
|
|
17
|
+
export interface PlaneGroupEntry {
|
|
18
|
+
/** Number of the plane group, 1 to 17. */
|
|
19
|
+
readonly number: number;
|
|
20
|
+
/** Short Hermann–Mauguin symbol, e.g. `p2mg`. */
|
|
21
|
+
readonly symbol: string;
|
|
22
|
+
/** Full Hermann–Mauguin symbol, e.g. `p1m1`. */
|
|
23
|
+
readonly fullSymbol: string;
|
|
24
|
+
/** The plane point group, e.g. `2mm`. */
|
|
25
|
+
readonly pointGroup: string;
|
|
26
|
+
/** The crystal system. */
|
|
27
|
+
readonly system: PlaneSystem;
|
|
28
|
+
/** Printed page. */
|
|
29
|
+
readonly page: number;
|
|
30
|
+
/** The block "Origin" as printed, e.g. `at 21g`. */
|
|
31
|
+
readonly origin: string;
|
|
32
|
+
/** The block "Asymmetric unit" as printed. */
|
|
33
|
+
readonly asymmetricUnit: string;
|
|
34
|
+
/** The vertices of the asymmetric unit, where printed (hexagonal groups). */
|
|
35
|
+
readonly vertices?: readonly string[];
|
|
36
|
+
/** Centring translations besides (0,0): `['1/2,1/2']` for the c groups. */
|
|
37
|
+
readonly centring: readonly string[];
|
|
38
|
+
/** The general position, (0,0)+ set, in ITA's numbering. */
|
|
39
|
+
readonly generalPosition: readonly string[];
|
|
40
|
+
/** "Generators selected": numbers in the general position, after (1) and the integer translations (and the centring). */
|
|
41
|
+
readonly generators: readonly number[];
|
|
42
|
+
/** The Wyckoff positions in printed order, general position first. */
|
|
43
|
+
readonly wyckoff: readonly PlaneWyckoffRow[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The 17 plane groups in ITA's order. */
|
|
47
|
+
export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
|
|
48
|
+
{
|
|
49
|
+
number: 1,
|
|
50
|
+
symbol: 'p1',
|
|
51
|
+
fullSymbol: 'p1',
|
|
52
|
+
pointGroup: '1',
|
|
53
|
+
system: 'oblique',
|
|
54
|
+
page: 176,
|
|
55
|
+
origin: 'arbitrary',
|
|
56
|
+
asymmetricUnit: '0 <= x <= 1; 0 <= y <= 1',
|
|
57
|
+
centring: [],
|
|
58
|
+
generalPosition: ['x,y'],
|
|
59
|
+
generators: [],
|
|
60
|
+
wyckoff: [[1, 'a', '1', ['x,y']]],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
number: 2,
|
|
64
|
+
symbol: 'p2',
|
|
65
|
+
fullSymbol: 'p2',
|
|
66
|
+
pointGroup: '2',
|
|
67
|
+
system: 'oblique',
|
|
68
|
+
page: 177,
|
|
69
|
+
origin: 'at 2',
|
|
70
|
+
asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1',
|
|
71
|
+
centring: [],
|
|
72
|
+
generalPosition: ['x,y', '-x,-y'],
|
|
73
|
+
generators: [2],
|
|
74
|
+
wyckoff: [
|
|
75
|
+
[2, 'e', '1', ['x,y', '-x,-y']],
|
|
76
|
+
[1, 'd', '2', ['1/2,1/2']],
|
|
77
|
+
[1, 'c', '2', ['1/2,0']],
|
|
78
|
+
[1, 'b', '2', ['0,1/2']],
|
|
79
|
+
[1, 'a', '2', ['0,0']],
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
number: 3,
|
|
84
|
+
symbol: 'pm',
|
|
85
|
+
fullSymbol: 'p1m1',
|
|
86
|
+
pointGroup: 'm',
|
|
87
|
+
system: 'rectangular',
|
|
88
|
+
page: 178,
|
|
89
|
+
origin: 'on m',
|
|
90
|
+
asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1',
|
|
91
|
+
centring: [],
|
|
92
|
+
generalPosition: ['x,y', '-x,y'],
|
|
93
|
+
generators: [2],
|
|
94
|
+
wyckoff: [
|
|
95
|
+
[2, 'c', '1', ['x,y', '-x,y']],
|
|
96
|
+
[1, 'b', '.m.', ['1/2,y']],
|
|
97
|
+
[1, 'a', '.m.', ['0,y']],
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
number: 4,
|
|
102
|
+
symbol: 'pg',
|
|
103
|
+
fullSymbol: 'p1g1',
|
|
104
|
+
pointGroup: 'm',
|
|
105
|
+
system: 'rectangular',
|
|
106
|
+
page: 179,
|
|
107
|
+
origin: 'on g',
|
|
108
|
+
asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1',
|
|
109
|
+
centring: [],
|
|
110
|
+
generalPosition: ['x,y', '-x,y+1/2'],
|
|
111
|
+
generators: [2],
|
|
112
|
+
wyckoff: [[2, 'a', '1', ['x,y', '-x,y+1/2']]],
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
number: 5,
|
|
116
|
+
symbol: 'cm',
|
|
117
|
+
fullSymbol: 'c1m1',
|
|
118
|
+
pointGroup: 'm',
|
|
119
|
+
system: 'rectangular',
|
|
120
|
+
page: 180,
|
|
121
|
+
origin: 'on m',
|
|
122
|
+
asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1/2',
|
|
123
|
+
centring: ['1/2,1/2'],
|
|
124
|
+
generalPosition: ['x,y', '-x,y'],
|
|
125
|
+
generators: [2],
|
|
126
|
+
wyckoff: [
|
|
127
|
+
[4, 'b', '1', ['x,y', '-x,y']],
|
|
128
|
+
[2, 'a', '.m.', ['0,y']],
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
number: 6,
|
|
133
|
+
symbol: 'p2mm',
|
|
134
|
+
fullSymbol: 'p2mm',
|
|
135
|
+
pointGroup: '2mm',
|
|
136
|
+
system: 'rectangular',
|
|
137
|
+
page: 181,
|
|
138
|
+
origin: 'at 2mm',
|
|
139
|
+
asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1/2',
|
|
140
|
+
centring: [],
|
|
141
|
+
generalPosition: ['x,y', '-x,-y', '-x,y', 'x,-y'],
|
|
142
|
+
generators: [2, 3],
|
|
143
|
+
wyckoff: [
|
|
144
|
+
[4, 'i', '1', ['x,y', '-x,-y', '-x,y', 'x,-y']],
|
|
145
|
+
[2, 'h', '.m.', ['1/2,y', '1/2,-y']],
|
|
146
|
+
[2, 'g', '.m.', ['0,y', '0,-y']],
|
|
147
|
+
[2, 'f', '..m', ['x,1/2', '-x,1/2']],
|
|
148
|
+
[2, 'e', '..m', ['x,0', '-x,0']],
|
|
149
|
+
[1, 'd', '2mm', ['1/2,1/2']],
|
|
150
|
+
[1, 'c', '2mm', ['1/2,0']],
|
|
151
|
+
[1, 'b', '2mm', ['0,1/2']],
|
|
152
|
+
[1, 'a', '2mm', ['0,0']],
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
number: 7,
|
|
157
|
+
symbol: 'p2mg',
|
|
158
|
+
fullSymbol: 'p2mg',
|
|
159
|
+
pointGroup: '2mm',
|
|
160
|
+
system: 'rectangular',
|
|
161
|
+
page: 182,
|
|
162
|
+
origin: 'at 21g',
|
|
163
|
+
asymmetricUnit: '0 <= x <= 1/4; 0 <= y <= 1',
|
|
164
|
+
centring: [],
|
|
165
|
+
generalPosition: ['x,y', '-x,-y', '-x+1/2,y', 'x+1/2,-y'],
|
|
166
|
+
generators: [2, 3],
|
|
167
|
+
wyckoff: [
|
|
168
|
+
[4, 'd', '1', ['x,y', '-x,-y', '-x+1/2,y', 'x+1/2,-y']],
|
|
169
|
+
[2, 'c', '.m.', ['1/4,y', '3/4,-y']],
|
|
170
|
+
[2, 'b', '2..', ['0,1/2', '1/2,1/2']],
|
|
171
|
+
[2, 'a', '2..', ['0,0', '1/2,0']],
|
|
172
|
+
],
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
number: 8,
|
|
176
|
+
symbol: 'p2gg',
|
|
177
|
+
fullSymbol: 'p2gg',
|
|
178
|
+
pointGroup: '2mm',
|
|
179
|
+
system: 'rectangular',
|
|
180
|
+
page: 183,
|
|
181
|
+
origin: 'at 2',
|
|
182
|
+
asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1/2',
|
|
183
|
+
centring: [],
|
|
184
|
+
generalPosition: ['x,y', '-x,-y', '-x+1/2,y+1/2', 'x+1/2,-y+1/2'],
|
|
185
|
+
generators: [2, 3],
|
|
186
|
+
wyckoff: [
|
|
187
|
+
[4, 'c', '1', ['x,y', '-x,-y', '-x+1/2,y+1/2', 'x+1/2,-y+1/2']],
|
|
188
|
+
[2, 'b', '2..', ['1/2,0', '0,1/2']],
|
|
189
|
+
[2, 'a', '2..', ['0,0', '1/2,1/2']],
|
|
190
|
+
],
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
number: 9,
|
|
194
|
+
symbol: 'c2mm',
|
|
195
|
+
fullSymbol: 'c2mm',
|
|
196
|
+
pointGroup: '2mm',
|
|
197
|
+
system: 'rectangular',
|
|
198
|
+
page: 184,
|
|
199
|
+
origin: 'at 2mm',
|
|
200
|
+
asymmetricUnit: '0 <= x <= 1/4; 0 <= y <= 1/2',
|
|
201
|
+
centring: ['1/2,1/2'],
|
|
202
|
+
generalPosition: ['x,y', '-x,-y', '-x,y', 'x,-y'],
|
|
203
|
+
generators: [2, 3],
|
|
204
|
+
wyckoff: [
|
|
205
|
+
[8, 'f', '1', ['x,y', '-x,-y', '-x,y', 'x,-y']],
|
|
206
|
+
[4, 'e', '.m.', ['0,y', '0,-y']],
|
|
207
|
+
[4, 'd', '..m', ['x,0', '-x,0']],
|
|
208
|
+
[4, 'c', '2..', ['1/4,1/4', '3/4,1/4']],
|
|
209
|
+
[2, 'b', '2mm', ['0,1/2']],
|
|
210
|
+
[2, 'a', '2mm', ['0,0']],
|
|
211
|
+
],
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
number: 10,
|
|
215
|
+
symbol: 'p4',
|
|
216
|
+
fullSymbol: 'p4',
|
|
217
|
+
pointGroup: '4',
|
|
218
|
+
system: 'square',
|
|
219
|
+
page: 185,
|
|
220
|
+
origin: 'at 4',
|
|
221
|
+
asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1/2',
|
|
222
|
+
centring: [],
|
|
223
|
+
generalPosition: ['x,y', '-x,-y', '-y,x', 'y,-x'],
|
|
224
|
+
generators: [2, 3],
|
|
225
|
+
wyckoff: [
|
|
226
|
+
[4, 'd', '1', ['x,y', '-x,-y', '-y,x', 'y,-x']],
|
|
227
|
+
[2, 'c', '2..', ['1/2,0', '0,1/2']],
|
|
228
|
+
[1, 'b', '4..', ['1/2,1/2']],
|
|
229
|
+
[1, 'a', '4..', ['0,0']],
|
|
230
|
+
],
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
number: 11,
|
|
234
|
+
symbol: 'p4mm',
|
|
235
|
+
fullSymbol: 'p4mm',
|
|
236
|
+
pointGroup: '4mm',
|
|
237
|
+
system: 'square',
|
|
238
|
+
page: 186,
|
|
239
|
+
origin: 'at 4mm',
|
|
240
|
+
asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1/2; x <= y',
|
|
241
|
+
centring: [],
|
|
242
|
+
generalPosition: ['x,y', '-x,-y', '-y,x', 'y,-x', '-x,y', 'x,-y', 'y,x', '-y,-x'],
|
|
243
|
+
generators: [2, 3, 5],
|
|
244
|
+
wyckoff: [
|
|
245
|
+
[8, 'g', '1', ['x,y', '-x,-y', '-y,x', 'y,-x', '-x,y', 'x,-y', 'y,x', '-y,-x']],
|
|
246
|
+
[4, 'f', '..m', ['x,x', '-x,-x', '-x,x', 'x,-x']],
|
|
247
|
+
[4, 'e', '.m.', ['x,1/2', '-x,1/2', '1/2,x', '1/2,-x']],
|
|
248
|
+
[4, 'd', '.m.', ['x,0', '-x,0', '0,x', '0,-x']],
|
|
249
|
+
[2, 'c', '2mm.', ['1/2,0', '0,1/2']],
|
|
250
|
+
[1, 'b', '4mm', ['1/2,1/2']],
|
|
251
|
+
[1, 'a', '4mm', ['0,0']],
|
|
252
|
+
],
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
number: 12,
|
|
256
|
+
symbol: 'p4gm',
|
|
257
|
+
fullSymbol: 'p4gm',
|
|
258
|
+
pointGroup: '4mm',
|
|
259
|
+
system: 'square',
|
|
260
|
+
page: 187,
|
|
261
|
+
origin: 'at 41g',
|
|
262
|
+
asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1/2; y <= 1/2 - x',
|
|
263
|
+
centring: [],
|
|
264
|
+
generalPosition: ['x,y', '-x,-y', '-y,x', 'y,-x', '-x+1/2,y+1/2', 'x+1/2,-y+1/2', 'y+1/2,x+1/2', '-y+1/2,-x+1/2'],
|
|
265
|
+
generators: [2, 3, 5],
|
|
266
|
+
wyckoff: [
|
|
267
|
+
[8, 'd', '1', ['x,y', '-x,-y', '-y,x', 'y,-x', '-x+1/2,y+1/2', 'x+1/2,-y+1/2', 'y+1/2,x+1/2', '-y+1/2,-x+1/2']],
|
|
268
|
+
[4, 'c', '..m', ['x,x+1/2', '-x,-x+1/2', '-x+1/2,x', 'x+1/2,-x']],
|
|
269
|
+
[2, 'b', '2.mm', ['1/2,0', '0,1/2']],
|
|
270
|
+
[2, 'a', '4..', ['0,0', '1/2,1/2']],
|
|
271
|
+
],
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
number: 13,
|
|
275
|
+
symbol: 'p3',
|
|
276
|
+
fullSymbol: 'p3',
|
|
277
|
+
pointGroup: '3',
|
|
278
|
+
system: 'hexagonal',
|
|
279
|
+
page: 188,
|
|
280
|
+
origin: 'at 3',
|
|
281
|
+
asymmetricUnit: '0 <= x <= 2/3; 0 <= y <= 2/3; x <= (1 + y)/2; y <= min(1 - x, (1 + x)/2)',
|
|
282
|
+
vertices: ['0,0', '1/2,0', '2/3,1/3', '1/3,2/3', '0,1/2'],
|
|
283
|
+
centring: [],
|
|
284
|
+
generalPosition: ['x,y', '-y,x-y', '-x+y,-x'],
|
|
285
|
+
generators: [2],
|
|
286
|
+
wyckoff: [
|
|
287
|
+
[3, 'd', '1', ['x,y', '-y,x-y', '-x+y,-x']],
|
|
288
|
+
[1, 'c', '3..', ['2/3,1/3']],
|
|
289
|
+
[1, 'b', '3..', ['1/3,2/3']],
|
|
290
|
+
[1, 'a', '3..', ['0,0']],
|
|
291
|
+
],
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
number: 14,
|
|
295
|
+
symbol: 'p3m1',
|
|
296
|
+
fullSymbol: 'p3m1',
|
|
297
|
+
pointGroup: '3m',
|
|
298
|
+
system: 'hexagonal',
|
|
299
|
+
page: 189,
|
|
300
|
+
origin: 'at 3m1',
|
|
301
|
+
asymmetricUnit: '0 <= x <= 2/3; 0 <= y <= 2/3; x <= 2y; y <= min(1 - x, 2x)',
|
|
302
|
+
vertices: ['0,0', '2/3,1/3', '1/3,2/3'],
|
|
303
|
+
centring: [],
|
|
304
|
+
generalPosition: ['x,y', '-y,x-y', '-x+y,-x', '-y,-x', '-x+y,y', 'x,x-y'],
|
|
305
|
+
generators: [2, 4],
|
|
306
|
+
wyckoff: [
|
|
307
|
+
[6, 'e', '1', ['x,y', '-y,x-y', '-x+y,-x', '-y,-x', '-x+y,y', 'x,x-y']],
|
|
308
|
+
[3, 'd', '.m.', ['x,-x', 'x,2x', '-2x,-x']],
|
|
309
|
+
[1, 'c', '3m.', ['2/3,1/3']],
|
|
310
|
+
[1, 'b', '3m.', ['1/3,2/3']],
|
|
311
|
+
[1, 'a', '3m.', ['0,0']],
|
|
312
|
+
],
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
number: 15,
|
|
316
|
+
symbol: 'p31m',
|
|
317
|
+
fullSymbol: 'p31m',
|
|
318
|
+
pointGroup: '3m',
|
|
319
|
+
system: 'hexagonal',
|
|
320
|
+
page: 190,
|
|
321
|
+
origin: 'at 31m',
|
|
322
|
+
asymmetricUnit: '0 <= x <= 2/3; 0 <= y <= 1/2; x <= (1 + y)/2; y <= min(1 - x, x)',
|
|
323
|
+
vertices: ['0,0', '1/2,0', '2/3,1/3', '1/2,1/2'],
|
|
324
|
+
centring: [],
|
|
325
|
+
generalPosition: ['x,y', '-y,x-y', '-x+y,-x', 'y,x', 'x-y,-y', '-x,-x+y'],
|
|
326
|
+
generators: [2, 4],
|
|
327
|
+
wyckoff: [
|
|
328
|
+
[6, 'd', '1', ['x,y', '-y,x-y', '-x+y,-x', 'y,x', 'x-y,-y', '-x,-x+y']],
|
|
329
|
+
[3, 'c', '..m', ['x,0', '0,x', '-x,-x']],
|
|
330
|
+
[2, 'b', '3..', ['1/3,2/3', '2/3,1/3']],
|
|
331
|
+
[1, 'a', '3.m', ['0,0']],
|
|
332
|
+
],
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
number: 16,
|
|
336
|
+
symbol: 'p6',
|
|
337
|
+
fullSymbol: 'p6',
|
|
338
|
+
pointGroup: '6',
|
|
339
|
+
system: 'hexagonal',
|
|
340
|
+
page: 191,
|
|
341
|
+
origin: 'at 6',
|
|
342
|
+
asymmetricUnit: '0 <= x <= 2/3; 0 <= y <= 1/2; x <= (1 + y)/2; y <= min(1 - x, x)',
|
|
343
|
+
vertices: ['0,0', '1/2,0', '2/3,1/3', '1/2,1/2'],
|
|
344
|
+
centring: [],
|
|
345
|
+
generalPosition: ['x,y', '-y,x-y', '-x+y,-x', '-x,-y', 'y,-x+y', 'x-y,x'],
|
|
346
|
+
generators: [2, 4],
|
|
347
|
+
wyckoff: [
|
|
348
|
+
[6, 'd', '1', ['x,y', '-y,x-y', '-x+y,-x', '-x,-y', 'y,-x+y', 'x-y,x']],
|
|
349
|
+
[3, 'c', '2..', ['1/2,0', '0,1/2', '1/2,1/2']],
|
|
350
|
+
[2, 'b', '3..', ['1/3,2/3', '2/3,1/3']],
|
|
351
|
+
[1, 'a', '6..', ['0,0']],
|
|
352
|
+
],
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
number: 17,
|
|
356
|
+
symbol: 'p6mm',
|
|
357
|
+
fullSymbol: 'p6mm',
|
|
358
|
+
pointGroup: '6mm',
|
|
359
|
+
system: 'hexagonal',
|
|
360
|
+
page: 192,
|
|
361
|
+
origin: 'at 6mm',
|
|
362
|
+
asymmetricUnit: '0 <= x <= 2/3; 0 <= y <= 1/3; x <= (1 + y)/2; y <= x/2',
|
|
363
|
+
vertices: ['0,0', '1/2,0', '2/3,1/3'],
|
|
364
|
+
centring: [],
|
|
365
|
+
generalPosition: [
|
|
366
|
+
'x,y',
|
|
367
|
+
'-y,x-y',
|
|
368
|
+
'-x+y,-x',
|
|
369
|
+
'-x,-y',
|
|
370
|
+
'y,-x+y',
|
|
371
|
+
'x-y,x',
|
|
372
|
+
'-y,-x',
|
|
373
|
+
'-x+y,y',
|
|
374
|
+
'x,x-y',
|
|
375
|
+
'y,x',
|
|
376
|
+
'x-y,-y',
|
|
377
|
+
'-x,-x+y',
|
|
378
|
+
],
|
|
379
|
+
generators: [2, 4, 7],
|
|
380
|
+
wyckoff: [
|
|
381
|
+
[
|
|
382
|
+
12,
|
|
383
|
+
'f',
|
|
384
|
+
'1',
|
|
385
|
+
[
|
|
386
|
+
'x,y',
|
|
387
|
+
'-y,x-y',
|
|
388
|
+
'-x+y,-x',
|
|
389
|
+
'-x,-y',
|
|
390
|
+
'y,-x+y',
|
|
391
|
+
'x-y,x',
|
|
392
|
+
'-y,-x',
|
|
393
|
+
'-x+y,y',
|
|
394
|
+
'x,x-y',
|
|
395
|
+
'y,x',
|
|
396
|
+
'x-y,-y',
|
|
397
|
+
'-x,-x+y',
|
|
398
|
+
],
|
|
399
|
+
],
|
|
400
|
+
[6, 'e', '.m.', ['x,-x', 'x,2x', '-2x,-x', '-x,x', '-x,-2x', '2x,x']],
|
|
401
|
+
[6, 'd', '..m', ['x,0', '0,x', '-x,-x', '-x,0', '0,-x', 'x,x']],
|
|
402
|
+
[3, 'c', '2mm', ['1/2,0', '0,1/2', '1/2,1/2']],
|
|
403
|
+
[2, 'b', '3m.', ['1/3,2/3', '2/3,1/3']],
|
|
404
|
+
[1, 'a', '6mm', ['0,0']],
|
|
405
|
+
],
|
|
406
|
+
},
|
|
407
|
+
];
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The 17 plane groups as exact operations: the general position of ITA in its numbering, the
|
|
3
|
+
* centring and ITA's selected generators (CLAUDE.md, "Plane groups (and later space groups)").
|
|
4
|
+
* Internal for now; the entry point `symcrys/plane` comes later.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
closure,
|
|
9
|
+
compose,
|
|
10
|
+
equalModLattice,
|
|
11
|
+
parseOperation,
|
|
12
|
+
reduceModLattice,
|
|
13
|
+
translationOperation,
|
|
14
|
+
type ExactOperation,
|
|
15
|
+
} from './affine.js';
|
|
16
|
+
import { PLANE_GROUP_DATA, type PlaneGroupEntry } from './planeGroupData.js';
|
|
17
|
+
import { parseRational } from './rational.js';
|
|
18
|
+
|
|
19
|
+
/** The short symbols of the 17 plane groups, in ITA's order. */
|
|
20
|
+
export const PLANE_GROUP_KEYS = PLANE_GROUP_DATA.map((g) => g.symbol);
|
|
21
|
+
|
|
22
|
+
/** The printed data of a plane group, by short symbol (`'p2mg'`) or number (7); throws if unknown. */
|
|
23
|
+
export function planeGroupEntry(key: string | number): PlaneGroupEntry {
|
|
24
|
+
const entry = PLANE_GROUP_DATA.find((g) => g.symbol === key || g.number === key);
|
|
25
|
+
if (!entry) {
|
|
26
|
+
throw new RangeError(`Unknown plane group: ${JSON.stringify(key)}`);
|
|
27
|
+
}
|
|
28
|
+
return entry;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The centring translations of a plane group as operations, (0,0) first. */
|
|
32
|
+
export function centringOperations(entry: PlaneGroupEntry): ExactOperation[] {
|
|
33
|
+
return [
|
|
34
|
+
translationOperation([parseRational('0'), parseRational('0')]),
|
|
35
|
+
...entry.centring.map((t) => translationOperation(t.split(',').map(parseRational))),
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const cache = new Map<number, ExactOperation[]>();
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The operations of a plane group, one per coset of the integer translations, translations in
|
|
43
|
+
* [0, 1): the general position in ITA's numbering, then, for a centred group, the same sequence
|
|
44
|
+
* with the centring (1/2, 1/2) added, as ITA prints the "(1/2,1/2)+ set". Throws if ITA's selected
|
|
45
|
+
* generators, with the integer translations and the centring, do not give exactly this set, which
|
|
46
|
+
* would be an error in the data.
|
|
47
|
+
*/
|
|
48
|
+
export function planeGroupOperations(key: string | number): ExactOperation[] {
|
|
49
|
+
const entry = planeGroupEntry(key);
|
|
50
|
+
const cached = cache.get(entry.number);
|
|
51
|
+
if (cached) return cached;
|
|
52
|
+
const general = entry.generalPosition.map(parseOperation);
|
|
53
|
+
const ops = centringOperations(entry).flatMap((t) => general.map((op) => reduceModLattice(compose(t, op))));
|
|
54
|
+
const generated = closure(planeGroupGenerators(entry.number), { dimension: 2 });
|
|
55
|
+
const same =
|
|
56
|
+
generated.length === ops.length &&
|
|
57
|
+
generated.every((g) => ops.some((op) => equalModLattice(op, g))) &&
|
|
58
|
+
ops.every((op, i) => ops.findIndex((o) => equalModLattice(o, op)) === i);
|
|
59
|
+
if (!same) {
|
|
60
|
+
throw new Error(`The selected generators of ${entry.symbol} do not give its general position`);
|
|
61
|
+
}
|
|
62
|
+
cache.set(entry.number, ops);
|
|
63
|
+
return ops;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* ITA's "Generators selected" of a plane group as operations, in printed order: the centring
|
|
68
|
+
* translation (for a centred group), then the operations named by number. The identity and the
|
|
69
|
+
* integer translations, which begin the printed line, are left out.
|
|
70
|
+
*/
|
|
71
|
+
export function planeGroupGenerators(key: string | number): ExactOperation[] {
|
|
72
|
+
const entry = planeGroupEntry(key);
|
|
73
|
+
const general = entry.generalPosition.map(parseOperation);
|
|
74
|
+
return [...centringOperations(entry).slice(1), ...entry.generators.map((n) => general[n - 1])];
|
|
75
|
+
}
|