symcrys 0.8.1 → 0.9.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.
Files changed (50) hide show
  1. package/README.md +11 -2
  2. package/dist/plane.d.ts +225 -0
  3. package/dist/plane.d.ts.map +1 -0
  4. package/dist/plane.js +219 -0
  5. package/dist/plane.js.map +1 -0
  6. package/dist/spaceGroups/affine.d.ts +81 -0
  7. package/dist/spaceGroups/affine.d.ts.map +1 -0
  8. package/dist/spaceGroups/affine.js +245 -0
  9. package/dist/spaceGroups/affine.js.map +1 -0
  10. package/dist/spaceGroups/cell.d.ts +58 -0
  11. package/dist/spaceGroups/cell.d.ts.map +1 -0
  12. package/dist/spaceGroups/cell.js +297 -0
  13. package/dist/spaceGroups/cell.js.map +1 -0
  14. package/dist/spaceGroups/describe.d.ts +44 -0
  15. package/dist/spaceGroups/describe.d.ts.map +1 -0
  16. package/dist/spaceGroups/describe.js +92 -0
  17. package/dist/spaceGroups/describe.js.map +1 -0
  18. package/dist/spaceGroups/planeGroupData.d.ts +44 -0
  19. package/dist/spaceGroups/planeGroupData.d.ts.map +1 -0
  20. package/dist/spaceGroups/planeGroupData.js +371 -0
  21. package/dist/spaceGroups/planeGroupData.js.map +1 -0
  22. package/dist/spaceGroups/planeGroups.d.ts +28 -0
  23. package/dist/spaceGroups/planeGroups.d.ts.map +1 -0
  24. package/dist/spaceGroups/planeGroups.js +61 -0
  25. package/dist/spaceGroups/planeGroups.js.map +1 -0
  26. package/dist/spaceGroups/planePointGroups.d.ts +31 -0
  27. package/dist/spaceGroups/planePointGroups.d.ts.map +1 -0
  28. package/dist/spaceGroups/planePointGroups.js +77 -0
  29. package/dist/spaceGroups/planePointGroups.js.map +1 -0
  30. package/dist/spaceGroups/positions.d.ts +65 -0
  31. package/dist/spaceGroups/positions.d.ts.map +1 -0
  32. package/dist/spaceGroups/positions.js +183 -0
  33. package/dist/spaceGroups/positions.js.map +1 -0
  34. package/dist/spaceGroups/rational.d.ts +43 -0
  35. package/dist/spaceGroups/rational.d.ts.map +1 -0
  36. package/dist/spaceGroups/rational.js +95 -0
  37. package/dist/spaceGroups/rational.js.map +1 -0
  38. package/dist/version.d.ts +1 -1
  39. package/dist/version.js +1 -1
  40. package/package.json +7 -2
  41. package/src/plane.ts +455 -0
  42. package/src/spaceGroups/affine.ts +315 -0
  43. package/src/spaceGroups/cell.ts +371 -0
  44. package/src/spaceGroups/describe.ts +133 -0
  45. package/src/spaceGroups/planeGroupData.ts +407 -0
  46. package/src/spaceGroups/planeGroups.ts +75 -0
  47. package/src/spaceGroups/planePointGroups.ts +90 -0
  48. package/src/spaceGroups/positions.ts +237 -0
  49. package/src/spaceGroups/rational.ts +115 -0
  50. package/src/version.ts +1 -1
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # symcrys
2
2
 
3
3
  Crystallographic symmetry calculations in TypeScript: point groups with their settings, symbols,
4
- symmetry elements, site symmetry, Wyckoff positions and crystal forms, and the forms of property
5
- tensors they allow. A library without runtime dependencies that runs unbundled in browsers and in Node.
4
+ symmetry elements, site symmetry, Wyckoff positions and crystal forms, the forms of property
5
+ tensors they allow, and the plane groups. A library without runtime dependencies that runs unbundled in browsers and in Node.
6
6
 
7
7
  ```bash
8
8
  npm install symcrys
@@ -28,6 +28,15 @@ allowedProperties("321'"); // ['piezoelectric', 'gyrotropic']: quartz
28
28
  allowedProperties("m'm'2"); // six of the seven names, 'ferromagnetic' among them
29
29
  ```
30
30
 
31
+ The 17 plane groups and the 10 plane point groups are in `symcrys/plane`, in the lattice basis:
32
+
33
+ ```ts
34
+ import { symmetryElements, wyckoffPositionOf } from 'symcrys/plane';
35
+
36
+ wyckoffPositionOf('p6mm', [1 / 3, 2 / 3]).letter; // 'b'
37
+ symmetryElements('p4gm').rotations; // the 4- and 2-fold centres in the cell
38
+ ```
39
+
31
40
  Documentation (getting started, conventions, tensors, examples, reference):
32
41
  [manganite.github.io/symcrys](https://manganite.github.io/symcrys/). Source, issues and the Python
33
42
  package of the same version: [github.com/manganite/symcrys](https://github.com/manganite/symcrys).
@@ -0,0 +1,225 @@
1
+ /**
2
+ * The plane API of symcrys (`symcrys/plane`): the 17 plane groups and the 10 plane point groups, in
3
+ * the lattice basis, as ITA (6th ed., 2016) prints them in Chapter 2.2 and Table 3.2.1.1.
4
+ * Everything exported here is covered by SemVer (see CLAUDE.md), like the exports of `index.ts`.
5
+ *
6
+ * Inside, the operations are exact (integer matrices, rational translations); here they are plain
7
+ * numbers: a translation of 1/3 is the nearest double. Keys are the symbols ITA prints: `'p2mg'`,
8
+ * `'c2mm'` for the plane groups, `'2mm'`, `'3m'` for the plane point groups; the two sets do not
9
+ * overlap. Functions that take a point take its coordinates in the lattice basis and an optional
10
+ * `tolerance` (docs/conventions.md, "Plane groups").
11
+ */
12
+ import { type PlaneSystem } from './spaceGroups/planeGroupData.js';
13
+ import { type PlanePointGroupKey } from './spaceGroups/planePointGroups.js';
14
+ export { VERSION } from './version.js';
15
+ export type { PlaneSystem } from './spaceGroups/planeGroupData.js';
16
+ /** The short symbol of a plane group, e.g. `'p2mg'`. */
17
+ export type PlaneGroupKey = 'p1' | 'p2' | 'pm' | 'pg' | 'cm' | 'p2mm' | 'p2mg' | 'p2gg' | 'c2mm' | 'p4' | 'p4mm' | 'p4gm' | 'p3' | 'p3m1' | 'p31m' | 'p6' | 'p6mm';
18
+ /** The key of a plane point group, e.g. `'2mm'`. */
19
+ export type PointGroupKey = PlanePointGroupKey;
20
+ /** The short symbols of the 17 plane groups, in ITA's order (plane group n at index n − 1). */
21
+ export declare const PLANE_GROUP_KEYS: readonly PlaneGroupKey[];
22
+ /** The keys of the 10 plane point groups, in the order of ITA Table 3.2.1.1. */
23
+ export declare const POINT_GROUP_KEYS: readonly PointGroupKey[];
24
+ /** Options that choose the setting of a plane point group. */
25
+ export interface SettingOptions {
26
+ /** 1-based setting: for the point group `3m` 1 is `3m1` (default) and 2 is `31m`; the other point groups have one, and a plane group takes only 1. */
27
+ readonly setting?: number;
28
+ }
29
+ /** Options of the functions that take a point. */
30
+ export interface PointOptions {
31
+ /**
32
+ * Two points count as the same, modulo the lattice, if each coordinate (lattice basis) differs
33
+ * by less than this from an integer. Default 10⁻⁶; must be below 1/2.
34
+ */
35
+ readonly tolerance?: number;
36
+ }
37
+ /** An operation (W, w) in the lattice basis: x ↦ W·x + w. */
38
+ export interface PlaneOperation {
39
+ /** The linear part W, a 2 × 2 matrix with integer entries, rows first. */
40
+ readonly matrix: readonly (readonly number[])[];
41
+ /** The translation part w; for a plane group in [0, 1), for a point group zero. */
42
+ readonly translation: readonly number[];
43
+ }
44
+ /** A plane group. */
45
+ export interface PlaneGroup {
46
+ /** The short symbol, e.g. `'p2mg'`. */
47
+ readonly key: PlaneGroupKey;
48
+ /** The number of the plane group, 1 to 17. */
49
+ readonly number: number;
50
+ /** The full symbol as ITA prints it, e.g. `'p2mg'` or `'p1m1'`. */
51
+ readonly fullSymbol: string;
52
+ /** The plane point group. */
53
+ readonly pointGroup: PointGroupKey;
54
+ /** The setting of the point group: 2 for `p31m`, otherwise 1. */
55
+ readonly pointGroupSetting: number;
56
+ /** The crystal system. */
57
+ readonly crystalSystem: PlaneSystem;
58
+ /** The centring translations besides (0, 0): `[[0.5, 0.5]]` for `cm` and `c2mm`, otherwise none. */
59
+ readonly centring: readonly (readonly number[])[];
60
+ /** The block "Origin" as ITA prints it, e.g. `'at 2mm'`. */
61
+ readonly origin: string;
62
+ /** The order of the group modulo the lattice: the number of `operations`. */
63
+ readonly order: number;
64
+ }
65
+ /** A plane point group. */
66
+ export interface PointGroup {
67
+ /** The key, e.g. `'2mm'`. */
68
+ readonly key: PointGroupKey;
69
+ /** The crystal system. */
70
+ readonly crystalSystem: PlaneSystem;
71
+ /** The order of the group. */
72
+ readonly order: number;
73
+ }
74
+ /** A setting of a plane point group. */
75
+ export interface Setting {
76
+ /** 1-based. */
77
+ readonly index: number;
78
+ /** Its symbol: `'3m1'` or `'31m'` for `3m`, otherwise the key. */
79
+ readonly symbol: string;
80
+ /** True for the default setting (setting 1). */
81
+ readonly default: boolean;
82
+ }
83
+ /** What an operation is, geometrically, as ITA describes it under "Symmetry operations". */
84
+ export interface OperationDescription {
85
+ /** `'identity'`, `'translation'`, `'rotation'`, `'mirror'` (a reflection in a line) or `'glide'` (a glide reflection). */
86
+ readonly kind: 'identity' | 'translation' | 'rotation' | 'mirror' | 'glide';
87
+ /** The order of the linear part: 1 for the identity and a translation, 2 for a mirror or glide. */
88
+ readonly order: number;
89
+ /** For a rotation of order 3 or more: `'+'` if it turns a towards b, `'-'` otherwise. */
90
+ readonly sense?: '+' | '-';
91
+ /** For a translation: the translation vector. */
92
+ readonly translation?: readonly number[];
93
+ /**
94
+ * For a rotation: its centre. For a mirror or glide: a point of its line, on y = 0 unless the line
95
+ * is parallel to it, then on x = 0. Not reduced modulo the lattice.
96
+ */
97
+ readonly location?: readonly number[];
98
+ /** For a mirror or glide: the direction of its line, the shortest integer vector, first non-zero component positive. */
99
+ readonly direction?: readonly number[];
100
+ /** For a glide: the glide vector (w + W·w)/2, not reduced modulo the lattice. */
101
+ readonly glide?: readonly number[];
102
+ }
103
+ /** A Wyckoff position of a plane group, as ITA prints it. */
104
+ export interface WyckoffPosition {
105
+ /** The Wyckoff letter. */
106
+ readonly letter: string;
107
+ /** The multiplicity: the number of points in the conventional cell. */
108
+ readonly multiplicity: number;
109
+ /** The oriented site-symmetry symbol, e.g. `'.m.'`, `'2mm'` (without the spaces of the print). */
110
+ readonly siteSymmetry: string;
111
+ /** The printed coordinates of the (0,0)+ set, e.g. `['x,0', '-x,0']`; a leading `-` is an overbar. */
112
+ readonly coordinates: readonly string[];
113
+ }
114
+ /** The site symmetry of a point under a plane group. */
115
+ export interface SiteSymmetry {
116
+ /** Indices into `operations` of those that map the point onto itself modulo the lattice, ascending: a subgroup. */
117
+ readonly operations: readonly number[];
118
+ /** The point set onto the fixed space of its site symmetry, in [0, 1), which removes rounding errors within the tolerance. */
119
+ readonly point: readonly number[];
120
+ /** The number of points in the conventional cell equivalent to it. */
121
+ readonly multiplicity: number;
122
+ /** True if no operation other than the identity maps the point onto itself (general position). */
123
+ readonly general: boolean;
124
+ }
125
+ /** The asymmetric unit of a plane group, a convex polygon in the lattice basis. */
126
+ export interface AsymmetricUnit {
127
+ /** Its vertices, counter-clockwise (a towards b), starting at the lowest (smallest y, then x). */
128
+ readonly vertices: readonly (readonly number[])[];
129
+ /** Per edge, the inequality [a, b, c] for a·x + b·y ≤ c (integers, no common factor); entry i holds the edge from vertex i to vertex i + 1. */
130
+ readonly inequalities: readonly (readonly number[])[];
131
+ }
132
+ /** A rotation centre in the cell. */
133
+ export interface RotationCentre {
134
+ /** The highest order of a rotation about it. */
135
+ readonly order: number;
136
+ /** Its position in [0, 1]². */
137
+ readonly point: readonly number[];
138
+ }
139
+ /** A mirror or glide line: the part of it in the cell. */
140
+ export interface SymmetryLine {
141
+ /** `'mirror'` or `'glide'`. */
142
+ readonly kind: 'mirror' | 'glide';
143
+ /** The direction of the line, the shortest integer vector, first non-zero component positive. */
144
+ readonly direction: readonly number[];
145
+ /** For a glide line its glide vector s·direction, 0 < s < 1; for a mirror line (0, 0). */
146
+ readonly glide: readonly number[];
147
+ /** The two ends of the segment of the line in the cell [0, 1]², in the order of `direction`. */
148
+ readonly segment: readonly (readonly number[])[];
149
+ }
150
+ /** The symmetry elements of a plane group in its conventional cell [0, 1]², boundary included. */
151
+ export interface SymmetryElements {
152
+ /** The rotation centres, by descending order, then by y and x. */
153
+ readonly rotations: readonly RotationCentre[];
154
+ /** The mirror and glide lines that cross the cell, by direction, then by the start of the segment (y, then x). */
155
+ readonly lines: readonly SymmetryLine[];
156
+ }
157
+ /** The plane group with this key (short symbol). Throws a RangeError for an unknown key. */
158
+ export declare function planeGroup(key: PlaneGroupKey): PlaneGroup;
159
+ /** The plane point group with this key. Throws a RangeError for an unknown key. */
160
+ export declare function pointGroup(key: PointGroupKey): PointGroup;
161
+ /**
162
+ * The settings of a plane point group: two for `3m` (`3m1`, the default, and `31m`), one for the
163
+ * others. Throws a RangeError for an unknown key.
164
+ */
165
+ export declare function settings(key: PointGroupKey): readonly Setting[];
166
+ /** The symbol of a plane point group in a setting: `'3m1'` or `'31m'` for `3m`, otherwise the key. */
167
+ export declare function symbol(key: PointGroupKey, options?: SettingOptions): string;
168
+ /**
169
+ * The operations of a plane group or a plane point group, in ITA's order, identity first. A plane
170
+ * group: one per coset of the integer translations, translations in [0, 1), the general position
171
+ * as numbered, then for a centred group the same sequence with the centring added (the
172
+ * "(1/2,1/2)+ set"). A point group: the linear parts of its symmorphic plane group (pm for m,
173
+ * p3m1 and p31m for the settings of 3m), translation zero. Throws a RangeError for an unknown key
174
+ * or setting.
175
+ */
176
+ export declare function operations(key: PlaneGroupKey | PointGroupKey, options?: SettingOptions): readonly PlaneOperation[];
177
+ /**
178
+ * ITA's selected generators, in printed order, without the identity and the integer translations:
179
+ * for a centred plane group the centring translation first. A point group: the linear parts of the
180
+ * generators of its symmorphic plane group. Throws a RangeError for an unknown key or setting.
181
+ */
182
+ export declare function generators(key: PlaneGroupKey | PointGroupKey, options?: SettingOptions): readonly PlaneOperation[];
183
+ /**
184
+ * Each operation of `operations` (same key and setting) described geometrically, index for index:
185
+ * what it is, its order and sense, where its symmetry element lies, its glide part. Throws a
186
+ * RangeError for an unknown key or setting.
187
+ */
188
+ export declare function describeOperations(key: PlaneGroupKey | PointGroupKey, options?: SettingOptions): readonly OperationDescription[];
189
+ /**
190
+ * The Wyckoff positions of a plane group as ITA prints them, general position first. Throws a
191
+ * RangeError for an unknown key and for a plane point group, whose positions are not in symcrys
192
+ * yet.
193
+ */
194
+ export declare function wyckoffPositions(key: PlaneGroupKey): readonly WyckoffPosition[];
195
+ /**
196
+ * The site symmetry of a point (lattice basis) under a plane group: the operations that map it
197
+ * onto itself modulo the lattice within the tolerance, closed into a group, and the point set onto
198
+ * their fixed space. Throws a RangeError for an unknown key, a point that is not two finite
199
+ * numbers, or a tolerance outside (0, 1/2).
200
+ */
201
+ export declare function siteSymmetry(key: PlaneGroupKey, point: readonly number[], options?: PointOptions): SiteSymmetry;
202
+ /**
203
+ * The Wyckoff position of a point (lattice basis) under a plane group, as `wyckoffPositions` gives
204
+ * it: the printed position of the point's multiplicity whose coordinates, with the centring, reach
205
+ * the point set onto its site symmetry. Throws a RangeError as `siteSymmetry`.
206
+ */
207
+ export declare function wyckoffPositionOf(key: PlaneGroupKey, point: readonly number[], options?: PointOptions): WyckoffPosition;
208
+ /**
209
+ * The orbit of a point (lattice basis) under a plane group: its distinct images in the
210
+ * conventional cell, each in [0, 1), in the order of the operations that first give them; images
211
+ * that coincide within the tolerance are merged. Throws a RangeError as `siteSymmetry`.
212
+ */
213
+ export declare function orbit(key: PlaneGroupKey, point: readonly number[], options?: PointOptions): readonly (readonly number[])[];
214
+ /**
215
+ * The asymmetric unit of a plane group as ITA prints it: a convex polygon given by its vertices and,
216
+ * per edge, the printed inequality that holds it. Throws a RangeError for an unknown key.
217
+ */
218
+ export declare function asymmetricUnit(key: PlaneGroupKey): AsymmetricUnit;
219
+ /**
220
+ * The symmetry elements of a plane group in its conventional cell [0, 1]², boundary included:
221
+ * every rotation centre with the highest order of a rotation about it, and every mirror and glide
222
+ * line that crosses the cell, with the segment inside it. Throws a RangeError for an unknown key.
223
+ */
224
+ export declare function symmetryElements(key: PlaneGroupKey): SymmetryElements;
225
+ //# sourceMappingURL=plane.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plane.d.ts","sourceRoot":"","sources":["../src/plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAOnE,OAAO,EASL,KAAK,kBAAkB,EACxB,MAAM,mCAAmC,CAAC;AAI3C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAEnE,wDAAwD;AACxD,MAAM,MAAM,aA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aAAa,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,YAAY,CAQ/G;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,CAAC,EAAE,YAAY,GACrB,eAAe,CAMjB;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CACnB,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,CAAC,EAAE,YAAY,GACrB,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAEhC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,cAAc,CAMjE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,aAAa,GAAG,gBAAgB,CAiBrE"}
package/dist/plane.js ADDED
@@ -0,0 +1,219 @@
1
+ /**
2
+ * The plane API of symcrys (`symcrys/plane`): the 17 plane groups and the 10 plane point groups, in
3
+ * the lattice basis, as ITA (6th ed., 2016) prints them in Chapter 2.2 and Table 3.2.1.1.
4
+ * Everything exported here is covered by SemVer (see CLAUDE.md), like the exports of `index.ts`.
5
+ *
6
+ * Inside, the operations are exact (integer matrices, rational translations); here they are plain
7
+ * numbers: a translation of 1/3 is the nearest double. Keys are the symbols ITA prints: `'p2mg'`,
8
+ * `'c2mm'` for the plane groups, `'2mm'`, `'3m'` for the plane point groups; the two sets do not
9
+ * overlap. Functions that take a point take its coordinates in the lattice basis and an optional
10
+ * `tolerance` (docs/conventions.md, "Plane groups").
11
+ */
12
+ import { describePlaneOperation } from './spaceGroups/describe.js';
13
+ import { planeAsymmetricUnit, planeCellElements } from './spaceGroups/cell.js';
14
+ import { toPlain } from './spaceGroups/affine.js';
15
+ import {} from './spaceGroups/planeGroupData.js';
16
+ import { PLANE_GROUP_KEYS as GROUP_KEYS, planeGroupEntry, planeGroupGenerators, planeGroupOperations, } from './spaceGroups/planeGroups.js';
17
+ import { PLANE_POINT_GROUP_KEYS, isPlanePointGroupKey, planePointGroupGenerators, planePointGroupOf, planePointGroupOperations, planePointGroupSettingCount, planePointGroupSymbol, planePointGroupSystem, } from './spaceGroups/planePointGroups.js';
18
+ import { planeOrbit, planeSiteSymmetry, planeWyckoffPositionOf } from './spaceGroups/positions.js';
19
+ import { parseRational, toNumber } from './spaceGroups/rational.js';
20
+ export { VERSION } from './version.js';
21
+ /** The short symbols of the 17 plane groups, in ITA's order (plane group n at index n − 1). */
22
+ export const PLANE_GROUP_KEYS = Object.freeze([...GROUP_KEYS]);
23
+ /** The keys of the 10 plane point groups, in the order of ITA Table 3.2.1.1. */
24
+ export const POINT_GROUP_KEYS = Object.freeze([...PLANE_POINT_GROUP_KEYS]);
25
+ // ---------------------------------------------------------------------------------------------
26
+ const numbers = (v) => v.map(toNumber);
27
+ function isPlaneGroupKey(key) {
28
+ return typeof key === 'string' && GROUP_KEYS.includes(key);
29
+ }
30
+ function unknownKey(key, what = 'plane group or plane point group') {
31
+ throw new RangeError(`Unknown ${what}: ${JSON.stringify(key)}`);
32
+ }
33
+ /** The plane group of a key; throws for a point group or an unknown key. */
34
+ function groupKey(key, what) {
35
+ if (isPlaneGroupKey(key))
36
+ return key;
37
+ if (isPlanePointGroupKey(key)) {
38
+ throw new RangeError(`${what} takes the key of a plane group, not of the point group ${key}`);
39
+ }
40
+ return unknownKey(key, 'plane group');
41
+ }
42
+ /** The key of a plane point group; throws for a plane group or an unknown key. */
43
+ function pointKey(key, what) {
44
+ if (isPlanePointGroupKey(key))
45
+ return key;
46
+ if (isPlaneGroupKey(key)) {
47
+ throw new RangeError(`${what} takes the key of a plane point group; ${key} is a plane group (planeGroup)`);
48
+ }
49
+ return unknownKey(key, 'plane point group');
50
+ }
51
+ function settingOf(options) {
52
+ return options?.setting;
53
+ }
54
+ /** The exact operations for a key: a plane group (setting 1 only) or a point group in a setting. */
55
+ function exact(key, options, generatorsOnly) {
56
+ const setting = settingOf(options);
57
+ if (isPlaneGroupKey(key)) {
58
+ if (setting !== undefined && setting !== 1) {
59
+ throw new RangeError(`The plane group ${key} has no setting ${String(setting)}`);
60
+ }
61
+ return generatorsOnly ? planeGroupGenerators(key) : planeGroupOperations(key);
62
+ }
63
+ if (isPlanePointGroupKey(key)) {
64
+ return generatorsOnly ? planePointGroupGenerators(key, setting) : planePointGroupOperations(key, setting);
65
+ }
66
+ return unknownKey(key);
67
+ }
68
+ const plain = (op) => {
69
+ const { matrix, translation } = toPlain(op);
70
+ return Object.freeze({
71
+ matrix: Object.freeze(matrix.map((row) => Object.freeze([...row]))),
72
+ translation: Object.freeze([...translation]),
73
+ });
74
+ };
75
+ /** The plane group with this key (short symbol). Throws a RangeError for an unknown key. */
76
+ export function planeGroup(key) {
77
+ const entry = planeGroupEntry(groupKey(key, 'planeGroup'));
78
+ const point = planePointGroupOf(entry.symbol);
79
+ return Object.freeze({
80
+ key: entry.symbol,
81
+ number: entry.number,
82
+ fullSymbol: entry.fullSymbol,
83
+ pointGroup: point.key,
84
+ pointGroupSetting: point.setting,
85
+ crystalSystem: entry.system,
86
+ centring: Object.freeze(entry.centring.map((t) => Object.freeze(t.split(',').map((c) => toNumber(parseRational(c)))))),
87
+ origin: entry.origin,
88
+ order: planeGroupOperations(entry.symbol).length,
89
+ });
90
+ }
91
+ /** The plane point group with this key. Throws a RangeError for an unknown key. */
92
+ export function pointGroup(key) {
93
+ const k = pointKey(key, 'pointGroup');
94
+ return Object.freeze({ key: k, crystalSystem: planePointGroupSystem(k), order: planePointGroupOperations(k).length });
95
+ }
96
+ /**
97
+ * The settings of a plane point group: two for `3m` (`3m1`, the default, and `31m`), one for the
98
+ * others. Throws a RangeError for an unknown key.
99
+ */
100
+ export function settings(key) {
101
+ const k = pointKey(key, 'settings');
102
+ return Object.freeze(Array.from({ length: planePointGroupSettingCount(k) }, (_, i) => Object.freeze({ index: i + 1, symbol: planePointGroupSymbol(k, i + 1), default: i === 0 })));
103
+ }
104
+ /** The symbol of a plane point group in a setting: `'3m1'` or `'31m'` for `3m`, otherwise the key. */
105
+ export function symbol(key, options) {
106
+ return planePointGroupSymbol(pointKey(key, 'symbol'), settingOf(options));
107
+ }
108
+ /**
109
+ * The operations of a plane group or a plane point group, in ITA's order, identity first. A plane
110
+ * group: one per coset of the integer translations, translations in [0, 1), the general position
111
+ * as numbered, then for a centred group the same sequence with the centring added (the
112
+ * "(1/2,1/2)+ set"). A point group: the linear parts of its symmorphic plane group (pm for m,
113
+ * p3m1 and p31m for the settings of 3m), translation zero. Throws a RangeError for an unknown key
114
+ * or setting.
115
+ */
116
+ export function operations(key, options) {
117
+ return Object.freeze(exact(key, options, false).map(plain));
118
+ }
119
+ /**
120
+ * ITA's selected generators, in printed order, without the identity and the integer translations:
121
+ * for a centred plane group the centring translation first. A point group: the linear parts of the
122
+ * generators of its symmorphic plane group. Throws a RangeError for an unknown key or setting.
123
+ */
124
+ export function generators(key, options) {
125
+ return Object.freeze(exact(key, options, true).map(plain));
126
+ }
127
+ /**
128
+ * Each operation of `operations` (same key and setting) described geometrically, index for index:
129
+ * what it is, its order and sense, where its symmetry element lies, its glide part. Throws a
130
+ * RangeError for an unknown key or setting.
131
+ */
132
+ export function describeOperations(key, options) {
133
+ return Object.freeze(exact(key, options, false).map((op) => {
134
+ const d = describePlaneOperation(op);
135
+ return Object.freeze({
136
+ kind: d.kind,
137
+ order: d.order,
138
+ ...(d.sense ? { sense: d.sense } : {}),
139
+ ...(d.translation ? { translation: Object.freeze(numbers(d.translation)) } : {}),
140
+ ...(d.location ? { location: Object.freeze(numbers(d.location)) } : {}),
141
+ ...(d.direction ? { direction: Object.freeze([...d.direction]) } : {}),
142
+ ...(d.glide ? { glide: Object.freeze(numbers(d.glide)) } : {}),
143
+ });
144
+ }));
145
+ }
146
+ /**
147
+ * The Wyckoff positions of a plane group as ITA prints them, general position first. Throws a
148
+ * RangeError for an unknown key and for a plane point group, whose positions are not in symcrys
149
+ * yet.
150
+ */
151
+ export function wyckoffPositions(key) {
152
+ const entry = planeGroupEntry(groupKey(key, 'wyckoffPositions'));
153
+ return Object.freeze(entry.wyckoff.map(([multiplicity, letter, siteSymmetry, coordinates]) => Object.freeze({ letter, multiplicity, siteSymmetry, coordinates: Object.freeze([...coordinates]) })));
154
+ }
155
+ /**
156
+ * The site symmetry of a point (lattice basis) under a plane group: the operations that map it
157
+ * onto itself modulo the lattice within the tolerance, closed into a group, and the point set onto
158
+ * their fixed space. Throws a RangeError for an unknown key, a point that is not two finite
159
+ * numbers, or a tolerance outside (0, 1/2).
160
+ */
161
+ export function siteSymmetry(key, point, options) {
162
+ const site = planeSiteSymmetry(groupKey(key, 'siteSymmetry'), point, options);
163
+ return Object.freeze({
164
+ operations: Object.freeze([...site.operations]),
165
+ point: Object.freeze([...site.point]),
166
+ multiplicity: site.multiplicity,
167
+ general: site.operations.length === 1,
168
+ });
169
+ }
170
+ /**
171
+ * The Wyckoff position of a point (lattice basis) under a plane group, as `wyckoffPositions` gives
172
+ * it: the printed position of the point's multiplicity whose coordinates, with the centring, reach
173
+ * the point set onto its site symmetry. Throws a RangeError as `siteSymmetry`.
174
+ */
175
+ export function wyckoffPositionOf(key, point, options) {
176
+ const k = groupKey(key, 'wyckoffPositionOf');
177
+ const { letter } = planeWyckoffPositionOf(k, point, options);
178
+ const found = wyckoffPositions(k).find((w) => w.letter === letter);
179
+ if (!found)
180
+ throw new Error(`No Wyckoff position ${letter} in ${k}`);
181
+ return found;
182
+ }
183
+ /**
184
+ * The orbit of a point (lattice basis) under a plane group: its distinct images in the
185
+ * conventional cell, each in [0, 1), in the order of the operations that first give them; images
186
+ * that coincide within the tolerance are merged. Throws a RangeError as `siteSymmetry`.
187
+ */
188
+ export function orbit(key, point, options) {
189
+ return Object.freeze(planeOrbit(groupKey(key, 'orbit'), point, options).map((p) => Object.freeze(p)));
190
+ }
191
+ /**
192
+ * The asymmetric unit of a plane group as ITA prints it: a convex polygon given by its vertices and,
193
+ * per edge, the printed inequality that holds it. Throws a RangeError for an unknown key.
194
+ */
195
+ export function asymmetricUnit(key) {
196
+ const unit = planeAsymmetricUnit(groupKey(key, 'asymmetricUnit'));
197
+ return Object.freeze({
198
+ vertices: Object.freeze(unit.vertices.map((v) => Object.freeze(numbers(v)))),
199
+ inequalities: Object.freeze(unit.inequalities.map((q) => Object.freeze([...q]))),
200
+ });
201
+ }
202
+ /**
203
+ * The symmetry elements of a plane group in its conventional cell [0, 1]², boundary included:
204
+ * every rotation centre with the highest order of a rotation about it, and every mirror and glide
205
+ * line that crosses the cell, with the segment inside it. Throws a RangeError for an unknown key.
206
+ */
207
+ export function symmetryElements(key) {
208
+ const e = planeCellElements(groupKey(key, 'symmetryElements'));
209
+ return Object.freeze({
210
+ rotations: Object.freeze(e.rotations.map((r) => Object.freeze({ order: r.order, point: Object.freeze(numbers(r.point)) }))),
211
+ lines: Object.freeze(e.lines.map((l) => Object.freeze({
212
+ kind: l.kind,
213
+ direction: Object.freeze([...l.direction]),
214
+ glide: Object.freeze(numbers(l.glide)),
215
+ segment: Object.freeze(l.segment.map((p) => Object.freeze(numbers(p)))),
216
+ }))),
217
+ });
218
+ }
219
+ //# sourceMappingURL=plane.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plane.js","sourceRoot":"","sources":["../src/plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAuB,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAoB,MAAM,iCAAiC,CAAC;AACnE,OAAO,EACL,gBAAgB,IAAI,UAAU,EAC9B,eAAe,EACf,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,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)): the matrix W with integer entries and determinant ±1, the translation w with
4
+ * rational components. Written for any dimension d from 1 to 3 (2 for the plane groups, 3 for the
5
+ * space groups). CLAUDE.md, "Plane groups (and later space groups)".
6
+ */
7
+ import { type Rational } from './rational.js';
8
+ /** An integer matrix of size d × d, rows first. */
9
+ export type IntMatrix = readonly (readonly number[])[];
10
+ /** An exact operation (W, w): x' = W·x + w, in the lattice basis. */
11
+ export interface ExactOperation {
12
+ /** The linear part W: integer entries; an operation of a group has determinant ±1. */
13
+ readonly matrix: IntMatrix;
14
+ /** The translation part w, one rational per axis. */
15
+ readonly translation: readonly Rational[];
16
+ }
17
+ /** The plain form of an operation at the API: integer matrix, translation as the nearest doubles. */
18
+ export interface PlainOperation {
19
+ /** The linear part W, integer entries, rows first. */
20
+ readonly matrix: number[][];
21
+ /** The translation part w as doubles (1/3 as the nearest double). */
22
+ readonly translation: number[];
23
+ }
24
+ /**
25
+ * The default bound on the cosets of a closure: no plane group has more than 12 cosets of the
26
+ * integer translations, no space group in its conventional cell more than 192 (Fm-3m: 48 × 4). A
27
+ * closure in a larger cell (a supercell, a subgroup of index k) passes a larger bound.
28
+ */
29
+ export declare const MAX_COSETS = 192;
30
+ /** The dimension d of an operation; throws unless it is consistent (d = 1 to 3, integer matrix). */
31
+ export declare function dimensionOf(op: ExactOperation): number;
32
+ /** The identity of dimension d. */
33
+ export declare function identity(d: number): ExactOperation;
34
+ /** The pure translation by t, an operation (I, t). */
35
+ export declare function translationOperation(t: readonly Rational[]): ExactOperation;
36
+ /** The determinant of an integer matrix of size 1 to 3. */
37
+ export declare function determinant(m: IntMatrix): number;
38
+ /** The trace of an integer matrix. */
39
+ export declare function trace(m: IntMatrix): number;
40
+ /** Throws unless det W = ±1, as for every operation of a crystallographic group. */
41
+ export declare function checkUnimodular(op: ExactOperation): void;
42
+ /** The image of the point x (rational coordinates) under the operation, W·x + w. */
43
+ export declare function applyToPoint(op: ExactOperation, x: readonly Rational[]): Rational[];
44
+ /** The product a·b: first b, then a; (W_a, w_a)(W_b, w_b) = (W_a W_b, W_a w_b + w_a). */
45
+ export declare function compose(a: ExactOperation, b: ExactOperation): ExactOperation;
46
+ /** The inverse (W⁻¹, −W⁻¹w); throws unless det W = ±1, so that W⁻¹ is an integer matrix. */
47
+ export declare function inverse(op: ExactOperation): ExactOperation;
48
+ /** The operation with its translation reduced modulo 1 into [0, 1): the representative of its coset. */
49
+ export declare function reduceModLattice(op: ExactOperation): ExactOperation;
50
+ /** True if a and b are the same operation, translation included. */
51
+ export declare function operationsEqual(a: ExactOperation, b: ExactOperation): boolean;
52
+ /** True if a and b differ by an integer lattice translation: the same coset of the integer translations. */
53
+ export declare function equalModLattice(a: ExactOperation, b: ExactOperation): boolean;
54
+ /** Options of `closure`. */
55
+ export interface ClosureOptions {
56
+ /** The dimension; needed only for an empty list of generators. */
57
+ readonly dimension?: number;
58
+ /** The largest number of cosets allowed, `MAX_COSETS` by default. */
59
+ readonly maxCosets?: number;
60
+ }
61
+ /**
62
+ * The group generated by `generators` together with the integer translations, as one operation per
63
+ * coset of the integer translations (translations in [0, 1)). The identity comes first, the others
64
+ * in the order in which the closure finds them (breadth first, each found operation multiplied by
65
+ * the generators from the left); this order has no meaning of its own. A centring translation is
66
+ * passed as a generator. Throws if a generator has a determinant other than ±1 or the closure
67
+ * exceeds `maxCosets`, which no crystallographic group in its conventional cell does.
68
+ */
69
+ export declare function closure(generators: readonly ExactOperation[], options?: ClosureOptions): ExactOperation[];
70
+ /**
71
+ * Reads an operation from its coordinate triplet as ITA prints it in the general position, e.g.
72
+ * `-x+1/2,y` (plane) or `-y,x-y,z+1/3` (space), with `-x` for x̄. The dimension is the number of
73
+ * coordinates. Integer coefficients other than ±1 (as in `2x,x` of a Wyckoff position) are read; a
74
+ * group operation is checked for det ±1 where it is used (`closure`, `inverse`).
75
+ */
76
+ export declare function parseOperation(text: string): ExactOperation;
77
+ /** Writes an operation as ITA prints its coordinate triplet, e.g. `-x+1/2,y`, `x-y,x,z+5/6`. */
78
+ export declare function formatOperation(op: ExactOperation): string;
79
+ /** The operation as plain data for the API: integer matrix, translation as the nearest doubles. */
80
+ export declare function toPlain(op: ExactOperation): PlainOperation;
81
+ //# sourceMappingURL=affine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"affine.d.ts","sourceRoot":"","sources":["../../src/spaceGroups/affine.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAeL,KAAK,QAAQ,EACd,MAAM,eAAe,CAAC;AAEvB,mDAAmD;AACnD,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC;AAEvD,qEAAqE;AACrE,MAAM,WAAW,cAAc;IAC7B,sFAAsF;IACtF,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,qDAAqD;IACrD,QAAQ,CAAC,WAAW,EAAE,SAAS,QAAQ,EAAE,CAAC;CAC3C;AAED,qGAAqG;AACrG,MAAM,WAAW,cAAc;IAC7B,sDAAsD;IACtD,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;CAChC;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,MAAM,CAAC;AAY9B,oGAAoG;AACpG,wBAAgB,WAAW,CAAC,EAAE,EAAE,cAAc,GAAG,MAAM,CAWtD;AAED,mCAAmC;AACnC,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,cAAc,CAMlD;AAED,sDAAsD;AACtD,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,SAAS,QAAQ,EAAE,GAAG,cAAc,CAE3E;AAYD,2DAA2D;AAC3D,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAQhD;AAED,sCAAsC;AACtC,wBAAgB,KAAK,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAE1C;AAED,oFAAoF;AACpF,w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