symcrys 0.10.0 → 0.11.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 +6 -6
- package/dist/cell.d.ts +19 -16
- package/dist/cell.d.ts.map +1 -1
- package/dist/cell.js +63 -35
- package/dist/cell.js.map +1 -1
- package/dist/checks.d.ts +29 -0
- package/dist/checks.d.ts.map +1 -0
- package/dist/checks.js +79 -0
- package/dist/checks.js.map +1 -0
- package/dist/closure.d.ts +43 -0
- package/dist/closure.d.ts.map +1 -0
- package/dist/closure.js +201 -0
- package/dist/closure.js.map +1 -0
- package/dist/crystalClasses.d.ts +146 -118
- package/dist/crystalClasses.d.ts.map +1 -1
- package/dist/crystalClasses.js +163 -124
- package/dist/crystalClasses.js.map +1 -1
- package/dist/freeze.d.ts +7 -0
- package/dist/freeze.d.ts.map +1 -0
- package/dist/freeze.js +15 -0
- package/dist/freeze.js.map +1 -0
- package/dist/index.d.ts +11 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/indices.d.ts +31 -5
- package/dist/indices.d.ts.map +1 -1
- package/dist/indices.js +104 -13
- package/dist/indices.js.map +1 -1
- package/dist/lattice.d.ts +15 -1
- package/dist/lattice.d.ts.map +1 -1
- package/dist/lattice.js +30 -1
- package/dist/lattice.js.map +1 -1
- package/dist/linalg.d.ts +2 -2
- package/dist/linalg.d.ts.map +1 -1
- package/dist/linalg.js +3 -3
- package/dist/linalg.js.map +1 -1
- package/dist/magnetic.d.ts +12 -10
- package/dist/magnetic.d.ts.map +1 -1
- package/dist/magnetic.js +8 -6
- package/dist/magnetic.js.map +1 -1
- package/dist/notation.d.ts +16 -0
- package/dist/notation.d.ts.map +1 -0
- package/dist/notation.js +66 -0
- package/dist/notation.js.map +1 -0
- package/dist/operations.d.ts +40 -26
- package/dist/operations.d.ts.map +1 -1
- package/dist/operations.js +48 -60
- package/dist/operations.js.map +1 -1
- package/dist/plane.d.ts +141 -79
- package/dist/plane.d.ts.map +1 -1
- package/dist/plane.js +147 -77
- package/dist/plane.js.map +1 -1
- package/dist/pointGroups/crystalForms.d.ts +6 -21
- package/dist/pointGroups/crystalForms.d.ts.map +1 -1
- package/dist/pointGroups/crystalForms.js +9 -16
- package/dist/pointGroups/crystalForms.js.map +1 -1
- package/dist/pointGroups/crystalFormsData.d.ts +4 -1
- package/dist/pointGroups/crystalFormsData.d.ts.map +1 -1
- package/dist/pointGroups/crystalFormsData.js +64 -1
- package/dist/pointGroups/crystalFormsData.js.map +1 -1
- package/dist/pointGroups/elements.d.ts +19 -17
- package/dist/pointGroups/elements.d.ts.map +1 -1
- package/dist/pointGroups/elements.js +65 -83
- package/dist/pointGroups/elements.js.map +1 -1
- package/dist/pointGroups/identify.d.ts +10 -18
- package/dist/pointGroups/identify.d.ts.map +1 -1
- package/dist/pointGroups/identify.js +27 -79
- package/dist/pointGroups/identify.js.map +1 -1
- package/dist/pointGroups/itaOrder.d.ts +15 -14
- package/dist/pointGroups/itaOrder.d.ts.map +1 -1
- package/dist/pointGroups/itaOrder.js +116 -94
- package/dist/pointGroups/itaOrder.js.map +1 -1
- package/dist/pointGroups/itcData.d.ts +96 -0
- package/dist/pointGroups/itcData.d.ts.map +1 -0
- package/dist/pointGroups/itcData.js +336 -0
- package/dist/pointGroups/itcData.js.map +1 -0
- package/dist/pointGroups/itcMagneticData.d.ts +55 -0
- package/dist/pointGroups/itcMagneticData.d.ts.map +1 -0
- package/dist/pointGroups/itcMagneticData.js +172 -0
- package/dist/pointGroups/itcMagneticData.js.map +1 -0
- package/dist/pointGroups/keys.d.ts +32 -0
- package/dist/pointGroups/keys.d.ts.map +1 -0
- package/dist/pointGroups/keys.js +120 -0
- package/dist/pointGroups/keys.js.map +1 -0
- package/dist/pointGroups/magneticSymbols.d.ts +6 -5
- package/dist/pointGroups/magneticSymbols.d.ts.map +1 -1
- package/dist/pointGroups/magneticSymbols.js +15 -12
- package/dist/pointGroups/magneticSymbols.js.map +1 -1
- package/dist/pointGroups/orbits.d.ts +23 -42
- package/dist/pointGroups/orbits.d.ts.map +1 -1
- package/dist/pointGroups/orbits.js +20 -62
- package/dist/pointGroups/orbits.js.map +1 -1
- package/dist/pointGroups/pointGroups.d.ts +135 -67
- package/dist/pointGroups/pointGroups.d.ts.map +1 -1
- package/dist/pointGroups/pointGroups.js +409 -244
- package/dist/pointGroups/pointGroups.js.map +1 -1
- package/dist/pointGroups/properties.d.ts +21 -22
- package/dist/pointGroups/properties.d.ts.map +1 -1
- package/dist/pointGroups/properties.js +40 -37
- package/dist/pointGroups/properties.js.map +1 -1
- package/dist/pointGroups/seitzData.d.ts +26 -0
- package/dist/pointGroups/seitzData.d.ts.map +1 -0
- package/dist/pointGroups/seitzData.js +130 -0
- package/dist/pointGroups/seitzData.js.map +1 -0
- package/dist/pointGroups/wyckoff.d.ts +70 -40
- package/dist/pointGroups/wyckoff.d.ts.map +1 -1
- package/dist/pointGroups/wyckoff.js +98 -91
- package/dist/pointGroups/wyckoff.js.map +1 -1
- package/dist/pointGroups/wyckoffData.d.ts +7 -4
- package/dist/pointGroups/wyckoffData.d.ts.map +1 -1
- package/dist/pointGroups/wyckoffData.js +789 -168
- package/dist/pointGroups/wyckoffData.js.map +1 -1
- package/dist/siteSymmetry.d.ts +9 -17
- package/dist/siteSymmetry.d.ts.map +1 -1
- package/dist/siteSymmetry.js +62 -47
- package/dist/siteSymmetry.js.map +1 -1
- package/dist/spaceGroups/affine.d.ts.map +1 -1
- package/dist/spaceGroups/affine.js +3 -2
- package/dist/spaceGroups/affine.js.map +1 -1
- package/dist/spaceGroups/cell.d.ts +43 -31
- package/dist/spaceGroups/cell.d.ts.map +1 -1
- package/dist/spaceGroups/cell.js +173 -85
- package/dist/spaceGroups/cell.js.map +1 -1
- package/dist/spaceGroups/describe.d.ts +12 -10
- package/dist/spaceGroups/describe.d.ts.map +1 -1
- package/dist/spaceGroups/describe.js +11 -10
- package/dist/spaceGroups/describe.js.map +1 -1
- package/dist/spaceGroups/planeGroupData.d.ts +1 -1
- package/dist/spaceGroups/planeGroupData.d.ts.map +1 -1
- package/dist/spaceGroups/planeGroupData.js +8 -8
- package/dist/spaceGroups/planeGroupData.js.map +1 -1
- package/dist/spaceGroups/planeGroups.d.ts.map +1 -1
- package/dist/spaceGroups/planeGroups.js +2 -1
- package/dist/spaceGroups/planeGroups.js.map +1 -1
- package/dist/spaceGroups/positions.d.ts +48 -19
- package/dist/spaceGroups/positions.d.ts.map +1 -1
- package/dist/spaceGroups/positions.js +166 -67
- package/dist/spaceGroups/positions.js.map +1 -1
- package/dist/tensors/propertyTable.d.ts +3 -1
- package/dist/tensors/propertyTable.d.ts.map +1 -1
- package/dist/tensors/propertyTable.js +17 -10
- package/dist/tensors/propertyTable.js.map +1 -1
- package/dist/tensors/rowEchelon.d.ts +12 -4
- package/dist/tensors/rowEchelon.d.ts.map +1 -1
- package/dist/tensors/rowEchelon.js +24 -11
- package/dist/tensors/rowEchelon.js.map +1 -1
- package/dist/tensors/tensorForm.d.ts +75 -34
- package/dist/tensors/tensorForm.d.ts.map +1 -1
- package/dist/tensors/tensorForm.js +173 -68
- package/dist/tensors/tensorForm.js.map +1 -1
- package/dist/tensors/tensorProperties.d.ts +10 -9
- package/dist/tensors/tensorProperties.d.ts.map +1 -1
- package/dist/tensors/tensorProperties.js +22 -12
- package/dist/tensors/tensorProperties.js.map +1 -1
- package/dist/tolerances.d.ts +56 -1
- package/dist/tolerances.d.ts.map +1 -1
- package/dist/tolerances.js +51 -1
- package/dist/tolerances.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/cell.ts +78 -51
- package/src/checks.ts +84 -0
- package/src/closure.ts +214 -0
- package/src/crystalClasses.ts +234 -160
- package/src/freeze.ts +14 -0
- package/src/index.ts +21 -10
- package/src/indices.ts +108 -18
- package/src/lattice.ts +41 -1
- package/src/linalg.ts +3 -3
- package/src/magnetic.ts +14 -9
- package/src/notation.ts +73 -0
- package/src/operations.ts +78 -69
- package/src/plane.ts +253 -127
- package/src/pointGroups/crystalForms.ts +11 -44
- package/src/pointGroups/crystalFormsData.ts +66 -1
- package/src/pointGroups/elements.ts +82 -92
- package/src/pointGroups/identify.ts +38 -97
- package/src/pointGroups/itaOrder.ts +117 -101
- package/src/pointGroups/itcData.ts +404 -0
- package/src/pointGroups/itcMagneticData.ts +206 -0
- package/src/pointGroups/keys.ts +144 -0
- package/src/pointGroups/magneticSymbols.ts +18 -17
- package/src/pointGroups/orbits.ts +41 -89
- package/src/pointGroups/pointGroups.ts +540 -297
- package/src/pointGroups/properties.ts +44 -40
- package/src/pointGroups/seitzData.ts +147 -0
- package/src/pointGroups/wyckoff.ts +137 -112
- package/src/pointGroups/wyckoffData.ts +793 -170
- package/src/siteSymmetry.ts +71 -64
- package/src/spaceGroups/affine.ts +3 -2
- package/src/spaceGroups/cell.ts +227 -116
- package/src/spaceGroups/describe.ts +22 -19
- package/src/spaceGroups/planeGroupData.ts +9 -9
- package/src/spaceGroups/planeGroups.ts +2 -1
- package/src/spaceGroups/positions.ts +202 -78
- package/src/tensors/propertyTable.ts +29 -17
- package/src/tensors/rowEchelon.ts +28 -9
- package/src/tensors/tensorForm.ts +260 -89
- package/src/tensors/tensorProperties.ts +34 -14
- package/src/tolerances.ts +66 -1
- package/src/version.ts +1 -1
- package/dist/pointGroups/data.d.ts +0 -75
- package/dist/pointGroups/data.d.ts.map +0 -1
- package/dist/pointGroups/data.js +0 -212
- package/dist/pointGroups/data.js.map +0 -1
- package/dist/pointGroups/magneticData.d.ts +0 -66
- package/dist/pointGroups/magneticData.d.ts.map +0 -1
- package/dist/pointGroups/magneticData.js +0 -184
- package/dist/pointGroups/magneticData.js.map +0 -1
- package/dist/spaceGroups/snap.d.ts +0 -20
- package/dist/spaceGroups/snap.d.ts.map +0 -1
- package/dist/spaceGroups/snap.js +0 -103
- package/dist/spaceGroups/snap.js.map +0 -1
- package/src/pointGroups/data.ts +0 -305
- package/src/pointGroups/magneticData.ts +0 -328
- package/src/spaceGroups/snap.ts +0 -121
|
@@ -1,36 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Public API for the point groups: the 32 crystallographic point groups (crystal classes) and the
|
|
3
3
|
* 90 magnetic point groups with time reversal (32 grey, 58 black-and-white). Lookup, settings,
|
|
4
|
-
* operations, generators and symbols,
|
|
4
|
+
* operations, generators and symbols, as ITC gives them (CLAUDE.md, "Pure ITC").
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { checkOptions, SETTING_KEYS, shown } from '../checks.js';
|
|
8
|
+
import { INVERSION, det, inverse, matricesEqual, multiply, type Mat3 } from '../linalg.js';
|
|
8
9
|
import { EPSILON } from '../tolerances.js';
|
|
10
|
+
import { compactSymbol } from '../notation.js';
|
|
11
|
+
import { compose, operation, operationsEqual, type CartesianOperation, type Operation } from '../operations.js';
|
|
9
12
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import
|
|
13
|
+
ITC_CLASSES,
|
|
14
|
+
itcBasis,
|
|
15
|
+
itcCartesianGenerators,
|
|
16
|
+
itcCartesianOperations,
|
|
17
|
+
itcClass,
|
|
18
|
+
itcLatticeGenerators,
|
|
19
|
+
itcLatticeOperations,
|
|
20
|
+
itcSetting,
|
|
21
|
+
} from './itcData.js';
|
|
22
|
+
import type { IntMat3 } from './itaOrder.js';
|
|
23
|
+
import {
|
|
24
|
+
ITC_BLACK_WHITE,
|
|
25
|
+
itcBlackWhiteClassSetting,
|
|
26
|
+
itcBlackWhiteOperations,
|
|
27
|
+
itcBlackWhiteSetting,
|
|
28
|
+
} from './itcMagneticData.js';
|
|
29
|
+
import { crystalFamily, latticeSystemsOfSystem, type CrystalSystem, type LatticeSystem } from '../lattice.js';
|
|
20
30
|
import {
|
|
21
|
-
BLACK_WHITE_DATA,
|
|
22
31
|
MAGNETIC_POINT_GROUP_KEYS,
|
|
32
|
+
POINT_GROUP_KEYS,
|
|
23
33
|
TIME_REVERSAL,
|
|
24
34
|
greySchoenflies,
|
|
35
|
+
type BlackWhitePointGroupKey,
|
|
25
36
|
type MagneticPointGroupKey,
|
|
26
|
-
|
|
37
|
+
type PointGroupKey,
|
|
38
|
+
} from './keys.js';
|
|
27
39
|
import { primedSymbols } from './magneticSymbols.js';
|
|
40
|
+
import { deepFreeze } from '../freeze.js';
|
|
28
41
|
|
|
29
|
-
export { POINT_GROUP_KEYS, type PointGroupKey } from './
|
|
30
|
-
export { MAGNETIC_POINT_GROUP_KEYS, type MagneticPointGroupKey } from './magneticData.js';
|
|
31
|
-
|
|
32
|
-
/** `'itc'`: International Tables for Crystallography (default). `'birss'`: Birss, Symmetry and Magnetism (1966). */
|
|
33
|
-
export type Convention = 'itc' | 'birss';
|
|
42
|
+
export { MAGNETIC_POINT_GROUP_KEYS, POINT_GROUP_KEYS, type MagneticPointGroupKey, type PointGroupKey } from './keys.js';
|
|
34
43
|
|
|
35
44
|
/**
|
|
36
45
|
* Type of a magnetic point group. `'I'`: a crystallographic point group, no operation with time
|
|
@@ -42,7 +51,7 @@ export type PointGroupType = 'I' | 'II' | 'III';
|
|
|
42
51
|
|
|
43
52
|
/**
|
|
44
53
|
* A point group with the properties that are fixed by its operations. None of them depends on the
|
|
45
|
-
* setting
|
|
54
|
+
* setting (docs/conventions.md, "Properties").
|
|
46
55
|
*/
|
|
47
56
|
export interface PointGroup<K extends MagneticPointGroupKey = PointGroupKey> {
|
|
48
57
|
/** The key (docs/conventions.md, "Keys"). */
|
|
@@ -65,45 +74,92 @@ export interface PointGroup<K extends MagneticPointGroupKey = PointGroupKey> {
|
|
|
65
74
|
* does not change a polar vector, so a magnetic group is polar if its crystal class is.
|
|
66
75
|
*/
|
|
67
76
|
readonly polar: boolean;
|
|
68
|
-
/**
|
|
69
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Enantiomorphic: proper rotations only, with or without time reversal. ITA § 3.2.2.1.3 (p. 738):
|
|
79
|
+
* "All these terms [enantiomorphism, enantiomerism, chirality, dissymmetry] refer to the same
|
|
80
|
+
* symmetry restriction, the absence of improper rotations (rotoinversions, rotoreflections)".
|
|
81
|
+
*/
|
|
82
|
+
readonly enantiomorphic: boolean;
|
|
70
83
|
/** The Laue class: the centrosymmetric crystal class generated by the crystal class and the inversion. */
|
|
71
84
|
readonly laueClass: PointGroupKey;
|
|
72
85
|
}
|
|
73
86
|
|
|
74
87
|
/** A setting of a point group: an orientation of its symmetry directions in the Cartesian frame (docs/conventions.md, "Settings"). */
|
|
75
88
|
export interface Setting {
|
|
76
|
-
/** 1-based
|
|
89
|
+
/** 1-based. */
|
|
77
90
|
readonly index: number;
|
|
78
|
-
/** Short symbol of the setting
|
|
91
|
+
/** Short symbol of the setting. */
|
|
79
92
|
readonly symbol: string;
|
|
80
93
|
/** Full symbol, symmetry directions separated by single spaces. */
|
|
81
94
|
readonly fullSymbol: string;
|
|
95
|
+
/** Monoclinic settings only: the unique axis. */
|
|
96
|
+
readonly uniqueAxis?: 'a' | 'b' | 'c';
|
|
97
|
+
/** Trigonal settings only: the axes of the conventional basis, `'hexagonal'` or `'rhombohedral'`. */
|
|
98
|
+
readonly axes?: 'hexagonal' | 'rhombohedral';
|
|
99
|
+
/** True for the ITC default setting. */
|
|
100
|
+
readonly isDefault: boolean;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The criteria of ITA's headlines (Table 3.2.3.2) that choose among the settings a symbol names:
|
|
105
|
+
* the options of `findPointGroup`, and with `setting` those of every function of a group in a
|
|
106
|
+
* setting.
|
|
107
|
+
*/
|
|
108
|
+
export interface AxesOptions {
|
|
109
|
+
/**
|
|
110
|
+
* The axes, as ITA's headlines name them: `'rhombohedral'` chooses the setting with rhombohedral
|
|
111
|
+
* axes of a trigonal group, `'hexagonal'` one with hexagonal axes, which every group of the
|
|
112
|
+
* hexagonal family has. A RangeError for another family.
|
|
113
|
+
*/
|
|
114
|
+
readonly axes?: 'hexagonal' | 'rhombohedral';
|
|
82
115
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* `2'm'm`, with six settings, two for each axis, the normal of the mirror plane without time
|
|
86
|
-
* reversal (there the axis does not identify a setting).
|
|
116
|
+
* The unique axis of a monoclinic group, as ITA's headlines name it (`'b'`, the standard, `'c'`,
|
|
117
|
+
* `'a'`). A RangeError for another system.
|
|
87
118
|
*/
|
|
88
119
|
readonly uniqueAxis?: 'a' | 'b' | 'c';
|
|
89
|
-
/** True for the default setting of the requested convention. */
|
|
90
|
-
readonly isDefault: boolean;
|
|
91
120
|
}
|
|
92
121
|
|
|
93
|
-
/** Which
|
|
94
|
-
export interface SettingOptions {
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
122
|
+
/** Which setting: by index or symbol, and by the criteria of ITA's headlines. */
|
|
123
|
+
export interface SettingOptions extends AxesOptions {
|
|
124
|
+
/**
|
|
125
|
+
* The setting: its 1-based index, or a symbol, read as `findPointGroup` reads it (spaces ignored:
|
|
126
|
+
* `'312'`, `'3 1 2'`, `'1 1 2'`). A symbol that several settings share (the key `'32'`, `'2'` for
|
|
127
|
+
* unique axis b, c and a) gives the standard (ITC default) setting, unless `axes` or `uniqueAxis`
|
|
128
|
+
* chooses another. Default: the ITC default setting.
|
|
129
|
+
*/
|
|
130
|
+
readonly setting?: number | string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The second argument of `findPointGroup`: the criteria, checked. A string is the convention that
|
|
135
|
+
* up to 0.10 came here (`findPointGroup(symbol, 'birss')`), a RangeError that names the change.
|
|
136
|
+
*/
|
|
137
|
+
function criteriaArgument(arg: unknown): AxesOptions | undefined {
|
|
138
|
+
if (arg === undefined) return undefined;
|
|
139
|
+
if (typeof arg === 'string') rejectConventionArgument(2);
|
|
140
|
+
checkOptions(arg, ['axes', 'uniqueAxis'], 'findPointGroup');
|
|
141
|
+
// The values are checked here, before a group is found, so that a wrong value is an error also
|
|
142
|
+
// for a symbol that names no group.
|
|
143
|
+
const { axes, uniqueAxis } = arg as AxesOptions;
|
|
144
|
+
if (axes !== undefined && axes !== 'hexagonal' && axes !== 'rhombohedral') {
|
|
145
|
+
throw new RangeError(`axes must be 'hexagonal' or 'rhombohedral', not ${shown(axes)}`);
|
|
146
|
+
}
|
|
147
|
+
if (uniqueAxis !== undefined && uniqueAxis !== 'a' && uniqueAxis !== 'b' && uniqueAxis !== 'c') {
|
|
148
|
+
throw new RangeError(`uniqueAxis must be 'a', 'b' or 'c', not ${shown(uniqueAxis)}`);
|
|
149
|
+
}
|
|
150
|
+
return arg as AxesOptions;
|
|
99
151
|
}
|
|
100
152
|
|
|
101
|
-
/**
|
|
153
|
+
/** Setting and form of a symbol. */
|
|
102
154
|
export interface SymbolOptions extends SettingOptions {
|
|
103
155
|
/**
|
|
104
|
-
* `'short'` (default): short symbol of the setting, e.g. `321`
|
|
156
|
+
* `'short'` (default): short symbol of the setting, e.g. `321` for class `32` (ITA Table
|
|
157
|
+
* 3.2.3.2); in the magnetic API the default setting of a grey or black-and-white group has its
|
|
158
|
+
* key as short symbol (`32'` as ITC Vol. D Table 1.5.2.3 prints it; `321'`, the class key and `1'`).
|
|
105
159
|
* `'full'`: full symbol, positions separated by spaces, e.g. `-3 2/m 1`.
|
|
106
|
-
* `'schoenflies'`: Schoenflies symbol, subscripts written inline (`C3v`, `D2d`, `Oh`)
|
|
160
|
+
* `'schoenflies'`: Schoenflies symbol, subscripts written inline (`C3v`, `D2d`, `Oh`); `C3i` for
|
|
161
|
+
* the class -3 in the crystallographic API (ITA), `S6` in the magnetic API (ITC Vol. D: `S6(C3)`,
|
|
162
|
+
* `D3d(S6)`).
|
|
107
163
|
*/
|
|
108
164
|
readonly form?: 'short' | 'full' | 'schoenflies';
|
|
109
165
|
}
|
|
@@ -119,58 +175,58 @@ interface GroupData {
|
|
|
119
175
|
readonly crystalClass: GroupData;
|
|
120
176
|
readonly crystalSystem: CrystalSystem;
|
|
121
177
|
readonly schoenflies: string;
|
|
122
|
-
/**
|
|
123
|
-
readonly generators: readonly Operation[];
|
|
124
|
-
readonly settings: readonly { readonly frame: SettingData['frame']; readonly uniqueAxis?: 'a' | 'b' | 'c' }[];
|
|
178
|
+
/** The ITC default setting (itcData.ts, itcMagneticData.ts). */
|
|
125
179
|
readonly itcDefault: number;
|
|
126
|
-
/**
|
|
127
|
-
readonly
|
|
180
|
+
/** The number of settings. */
|
|
181
|
+
readonly settingCount: number;
|
|
128
182
|
}
|
|
129
183
|
|
|
184
|
+
/** The ITC default setting of a class, from the ITC class data (itcData.ts). */
|
|
185
|
+
function itcDefaultOf(key: PointGroupKey): number {
|
|
186
|
+
return itcClass(key).settings.find((s) => s.isDefault)!.index;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Built from the ITC data, in their order (that of POINT_GROUP_KEYS and
|
|
190
|
+
// BLACK_WHITE_POINT_GROUP_KEYS).
|
|
130
191
|
const BY_KEY = new Map<string, GroupData>();
|
|
131
|
-
for (const
|
|
192
|
+
for (const c of ITC_CLASSES) {
|
|
132
193
|
const self: GroupData = {
|
|
133
|
-
key:
|
|
194
|
+
key: c.key,
|
|
134
195
|
type: 'I',
|
|
135
196
|
get crystalClass() {
|
|
136
197
|
return self;
|
|
137
198
|
},
|
|
138
|
-
crystalSystem:
|
|
139
|
-
schoenflies:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
itcDefault: d.itcDefault,
|
|
143
|
-
symbols: d.settings,
|
|
199
|
+
crystalSystem: c.crystalSystem,
|
|
200
|
+
schoenflies: c.schoenflies,
|
|
201
|
+
itcDefault: itcDefaultOf(c.key),
|
|
202
|
+
settingCount: c.settings.length,
|
|
144
203
|
};
|
|
145
|
-
BY_KEY.set(
|
|
204
|
+
BY_KEY.set(c.key, self);
|
|
146
205
|
}
|
|
147
|
-
// Grey groups: the class and time reversal (ITC Vol. D, eq. (1.5.2.1)).
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
const key: MagneticPointGroupKey = `${d.key}1'`;
|
|
206
|
+
// Grey groups: the class and time reversal (ITC Vol. D, eq. (1.5.2.1)).
|
|
207
|
+
for (const c of ITC_CLASSES) {
|
|
208
|
+
const crystalClass = BY_KEY.get(c.key)!;
|
|
209
|
+
const key: MagneticPointGroupKey = `${c.key}1'`;
|
|
152
210
|
BY_KEY.set(key, {
|
|
153
211
|
key,
|
|
154
212
|
type: 'II',
|
|
155
213
|
crystalClass,
|
|
156
|
-
crystalSystem:
|
|
157
|
-
schoenflies: greySchoenflies(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
itcDefault: d.itcDefault,
|
|
214
|
+
crystalSystem: c.crystalSystem,
|
|
215
|
+
schoenflies: greySchoenflies(c.schoenflies),
|
|
216
|
+
itcDefault: crystalClass.itcDefault,
|
|
217
|
+
settingCount: crystalClass.settingCount,
|
|
161
218
|
});
|
|
162
219
|
}
|
|
163
|
-
for (const
|
|
164
|
-
const crystalClass = BY_KEY.get(
|
|
165
|
-
BY_KEY.set(
|
|
166
|
-
key:
|
|
220
|
+
for (const g of ITC_BLACK_WHITE) {
|
|
221
|
+
const crystalClass = BY_KEY.get(g.crystalClass)!;
|
|
222
|
+
BY_KEY.set(g.key, {
|
|
223
|
+
key: g.key,
|
|
167
224
|
type: 'III',
|
|
168
225
|
crystalClass,
|
|
169
226
|
crystalSystem: crystalClass.crystalSystem,
|
|
170
|
-
schoenflies:
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
itcDefault: d.itcDefault,
|
|
227
|
+
schoenflies: g.schoenflies,
|
|
228
|
+
itcDefault: g.settings.find((s) => s.isDefault)!.index,
|
|
229
|
+
settingCount: g.settings.length,
|
|
174
230
|
});
|
|
175
231
|
}
|
|
176
232
|
|
|
@@ -186,108 +242,215 @@ export function isMagneticPointGroupKey(key: string): key is MagneticPointGroupK
|
|
|
186
242
|
|
|
187
243
|
function data(key: string): GroupData {
|
|
188
244
|
const d = BY_KEY.get(key);
|
|
189
|
-
if (!d) throw new RangeError(`Unknown point group key: ${
|
|
245
|
+
if (!d) throw new RangeError(`Unknown point group key: ${shown(key)}`);
|
|
190
246
|
return d;
|
|
191
247
|
}
|
|
192
248
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
249
|
+
/**
|
|
250
|
+
* Throws for a second argument of `settings` or `findPointGroup`, which took a convention up to
|
|
251
|
+
* 0.10 (`settings('32', 'birss')`): TypeScript refuses it, plain JavaScript would ignore it and
|
|
252
|
+
* answer for the ITC frame. Internal.
|
|
253
|
+
*/
|
|
254
|
+
export function rejectConventionArgument(argumentCount: number): void {
|
|
255
|
+
if (argumentCount > 1) {
|
|
256
|
+
throw new RangeError(
|
|
257
|
+
'The convention argument was removed in symcrys 0.11.0: symcrys follows ITC only (CHANGELOG.md, 0.11.0)',
|
|
258
|
+
);
|
|
259
|
+
}
|
|
197
260
|
}
|
|
198
261
|
|
|
199
|
-
|
|
200
|
-
|
|
262
|
+
/** The settings a symbol names, spaces ignored: by its key, its short or full symbol, or Birss's cubic form. */
|
|
263
|
+
function settingsNamed(d: GroupData, text: string): number[] {
|
|
264
|
+
const compactText = compact(text);
|
|
265
|
+
const target = birssCubic(compactText) === d.key ? d.key : compactText;
|
|
266
|
+
return allSettings(d).filter((i) => {
|
|
267
|
+
if (target === d.key && i === d.itcDefault) return true;
|
|
268
|
+
const s = settingSymbols(d, i);
|
|
269
|
+
return compact(s.short) === target || compact(derivedSymbols(d, i).short) === target || compact(s.full) === target;
|
|
270
|
+
});
|
|
201
271
|
}
|
|
202
272
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
273
|
+
const allSettings = (d: GroupData): number[] => Array.from({ length: d.settingCount }, (_, i) => i + 1);
|
|
274
|
+
|
|
275
|
+
/** The settings of `d`, listed for an error message. */
|
|
276
|
+
function listSettings(d: GroupData, indices: readonly number[]): string {
|
|
277
|
+
return indices
|
|
278
|
+
.map((i) => {
|
|
279
|
+
const axes = settingAxes(d, i);
|
|
280
|
+
const unique = settingUniqueAxis(d, i);
|
|
281
|
+
const note = axes ? `, ${axes} axes` : unique ? `, unique axis ${unique}` : '';
|
|
282
|
+
return `${i}: ${settingSymbols(d, i).short} (${settingSymbols(d, i).full}${note})`;
|
|
283
|
+
})
|
|
284
|
+
.join(', ');
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** `axes` and `uniqueAxis` of the options, checked against the family of the group. */
|
|
288
|
+
function criteriaOf(
|
|
289
|
+
d: GroupData,
|
|
290
|
+
options: SettingOptions | undefined,
|
|
291
|
+
): { readonly axes?: 'hexagonal' | 'rhombohedral'; readonly uniqueAxis?: 'a' | 'b' | 'c' } {
|
|
292
|
+
const axes = options?.axes;
|
|
293
|
+
const uniqueAxis = options?.uniqueAxis;
|
|
294
|
+
if (axes !== undefined) {
|
|
295
|
+
if (axes !== 'hexagonal' && axes !== 'rhombohedral') {
|
|
296
|
+
throw new RangeError(`axes must be 'hexagonal' or 'rhombohedral', not ${shown(axes)}`);
|
|
297
|
+
}
|
|
298
|
+
if (crystalFamily(d.crystalSystem) !== 'hexagonal') {
|
|
299
|
+
throw new RangeError(
|
|
300
|
+
`Point group ${d.key} (${d.crystalSystem}): axes applies to the trigonal and hexagonal groups`,
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (uniqueAxis !== undefined) {
|
|
305
|
+
if (uniqueAxis !== 'a' && uniqueAxis !== 'b' && uniqueAxis !== 'c') {
|
|
306
|
+
throw new RangeError(`uniqueAxis must be 'a', 'b' or 'c', not ${shown(uniqueAxis)}`);
|
|
307
|
+
}
|
|
308
|
+
if (d.crystalSystem !== 'monoclinic') {
|
|
309
|
+
throw new RangeError(`Point group ${d.key} (${d.crystalSystem}): uniqueAxis applies to the monoclinic groups`);
|
|
310
|
+
}
|
|
209
311
|
}
|
|
210
|
-
return
|
|
312
|
+
return { ...(axes ? { axes } : {}), ...(uniqueAxis ? { uniqueAxis } : {}) };
|
|
211
313
|
}
|
|
212
314
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}) as Operation;
|
|
315
|
+
/** Whether setting `i` meets the criteria (`axes: 'hexagonal'` holds for every hexagonal group). */
|
|
316
|
+
function meets(d: GroupData, i: number, c: ReturnType<typeof criteriaOf>): boolean {
|
|
317
|
+
if (c.axes && (settingAxes(d, i) ?? 'hexagonal') !== c.axes) return false;
|
|
318
|
+
if (c.uniqueAxis && settingUniqueAxis(d, i) !== c.uniqueAxis) return false;
|
|
319
|
+
return true;
|
|
219
320
|
}
|
|
220
321
|
|
|
221
|
-
|
|
222
|
-
|
|
322
|
+
/**
|
|
323
|
+
* The setting among `candidates` that meets the criteria: the only one, or the standard (ITC
|
|
324
|
+
* default) where it is one of several, as a name without a criterion means the standard (Thomas,
|
|
325
|
+
* 2026-11-23, #96). None, or several without the standard, is a RangeError that lists them.
|
|
326
|
+
*/
|
|
327
|
+
function choose(
|
|
328
|
+
d: GroupData,
|
|
329
|
+
candidates: readonly number[],
|
|
330
|
+
criteria: ReturnType<typeof criteriaOf>,
|
|
331
|
+
what: string,
|
|
332
|
+
): number {
|
|
333
|
+
const met = candidates.filter((i) => meets(d, i, criteria));
|
|
334
|
+
if (met.length === 1) return met[0]!;
|
|
335
|
+
if (met.includes(d.itcDefault)) return d.itcDefault;
|
|
336
|
+
const crit = [criteria.axes && `${criteria.axes} axes`, criteria.uniqueAxis && `unique axis ${criteria.uniqueAxis}`]
|
|
337
|
+
.filter(Boolean)
|
|
338
|
+
.join(', ');
|
|
339
|
+
const asked = what ? [what, crit].filter(Boolean).join(', ') : `with ${crit}`;
|
|
340
|
+
throw new RangeError(
|
|
341
|
+
met.length === 0
|
|
342
|
+
? `Point group ${d.key} has no setting ${asked} (settings ${listSettings(d, allSettings(d))})`
|
|
343
|
+
: `Point group ${d.key}: ${asked} names ${met.length} settings; give the index (${listSettings(d, met)})`,
|
|
344
|
+
);
|
|
345
|
+
}
|
|
223
346
|
|
|
224
|
-
/** The
|
|
225
|
-
function
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
if (
|
|
229
|
-
|
|
230
|
-
result = Object.freeze(d.generators.map((g) => freezeOperation(transformOperation(g, frame))));
|
|
231
|
-
generatorCache.set(cacheKey, result);
|
|
347
|
+
/** The requested setting index, checked; the ITC default if none is given. */
|
|
348
|
+
function settingIndex(d: GroupData, options?: SettingOptions): number {
|
|
349
|
+
const criteria = criteriaOf(d, options);
|
|
350
|
+
const requested = options?.setting;
|
|
351
|
+
if (requested !== undefined && requested !== null && typeof requested !== 'number' && typeof requested !== 'string') {
|
|
352
|
+
throw new RangeError(`The setting must be an index or a symbol, not ${shown(requested)}`);
|
|
232
353
|
}
|
|
233
|
-
|
|
354
|
+
if (typeof requested === 'string') {
|
|
355
|
+
const named = settingsNamed(d, requested);
|
|
356
|
+
if (named.length === 0) {
|
|
357
|
+
throw new RangeError(
|
|
358
|
+
`Point group ${d.key} has no setting ${shown(requested)} (settings ${listSettings(d, allSettings(d))})`,
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
return choose(d, named, criteria, shown(requested));
|
|
362
|
+
}
|
|
363
|
+
if (requested === undefined || requested === null) return choose(d, allSettings(d), criteria, '');
|
|
364
|
+
const count = d.settingCount;
|
|
365
|
+
if (!Number.isInteger(requested) || requested < 1 || requested > count) {
|
|
366
|
+
throw new RangeError(`Point group ${d.key} has no setting ${String(requested)} (settings 1 to ${count})`);
|
|
367
|
+
}
|
|
368
|
+
if (!meets(d, requested, criteria)) {
|
|
369
|
+
throw new RangeError(
|
|
370
|
+
`Point group ${d.key}: setting ${requested} does not have the ${[criteria.axes && `${criteria.axes} axes`, criteria.uniqueAxis && `unique axis ${criteria.uniqueAxis}`].filter(Boolean).join(', ')} (settings ${listSettings(d, allSettings(d))})`,
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
return requested;
|
|
234
374
|
}
|
|
235
375
|
|
|
376
|
+
/**
|
|
377
|
+
* The index of the requested setting (an index or a symbol; the ITC default if none), checked.
|
|
378
|
+
* Internal: for the modules that cache by setting.
|
|
379
|
+
*/
|
|
380
|
+
export function settingIndexOf(key: MagneticPointGroupKey, options?: SettingOptions): number {
|
|
381
|
+
return settingIndex(data(key), options);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function freezeOperation(op: CartesianOperation): CartesianOperation {
|
|
385
|
+
const [r0, r1, r2] = op.cartesian;
|
|
386
|
+
return Object.freeze({
|
|
387
|
+
cartesian: Object.freeze([Object.freeze([...r0]), Object.freeze([...r1]), Object.freeze([...r2])] as const),
|
|
388
|
+
timeReversal: op.timeReversal,
|
|
389
|
+
}) as CartesianOperation;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
const operationCache = new Map<string, readonly CartesianOperation[]>();
|
|
393
|
+
|
|
236
394
|
/** The operation of `ops` with the matrix of `op`, whatever its time reversal. */
|
|
237
|
-
function withMatrix(ops: readonly
|
|
238
|
-
const found = ops.find((x) => matricesEqual(x.
|
|
395
|
+
function withMatrix(ops: readonly CartesianOperation[], op: CartesianOperation): CartesianOperation {
|
|
396
|
+
const found = ops.find((x) => matricesEqual(x.cartesian, op.cartesian));
|
|
239
397
|
if (!found) throw new Error('Operation of the crystal class missing in the magnetic group');
|
|
240
398
|
return found;
|
|
241
399
|
}
|
|
242
400
|
|
|
243
|
-
const classSettingCache = new Map<string, number>();
|
|
244
|
-
|
|
245
401
|
/**
|
|
246
402
|
* The setting of the crystal class whose frame is that of setting `index` of the group: the one
|
|
247
403
|
* in which the class has the operations of the group without their time reversal. For a class and
|
|
248
|
-
* a grey group it is `index` itself
|
|
249
|
-
*
|
|
404
|
+
* a grey group it is `index` itself; for a black-and-white group, the class setting named by its
|
|
405
|
+
* ITC symbol without primes (itcMagneticData.ts). A black-and-white group may have its settings in
|
|
406
|
+
* another order than its class, and settings its class does not tell apart (docs/conventions.md,
|
|
250
407
|
* "Settings").
|
|
251
408
|
*/
|
|
252
409
|
function classSetting(d: GroupData, index: number): number {
|
|
253
|
-
|
|
254
|
-
const cacheKey = `${d.key}#${index}`;
|
|
255
|
-
let result = classSettingCache.get(cacheKey);
|
|
256
|
-
if (!result) {
|
|
257
|
-
const ops = closeGroup(settingGenerators(d, index));
|
|
258
|
-
const c = d.crystalClass;
|
|
259
|
-
result =
|
|
260
|
-
c.settings.findIndex((_, i) => {
|
|
261
|
-
const classOps = settingOperations(c, i + 1);
|
|
262
|
-
return (
|
|
263
|
-
classOps.length === ops.length && classOps.every((x) => ops.some((y) => matricesEqual(x.matrix, y.matrix)))
|
|
264
|
-
);
|
|
265
|
-
}) + 1;
|
|
266
|
-
if (!result) throw new Error(`Point group ${d.key}, setting ${index}: no setting of class ${c.key} has this frame`);
|
|
267
|
-
classSettingCache.set(cacheKey, result);
|
|
268
|
-
}
|
|
269
|
-
return result;
|
|
410
|
+
return d.type === 'III' ? itcBlackWhiteClassSetting(d.key as BlackWhitePointGroupKey, index) : index;
|
|
270
411
|
}
|
|
271
412
|
|
|
272
|
-
|
|
413
|
+
/** The unique axis of a monoclinic setting; undefined in other systems. */
|
|
414
|
+
function settingUniqueAxis(d: GroupData, index: number): 'a' | 'b' | 'c' | undefined {
|
|
415
|
+
return d.type === 'III'
|
|
416
|
+
? itcBlackWhiteSetting(d.key as BlackWhitePointGroupKey, index).uniqueAxis
|
|
417
|
+
: itcSetting(d.crystalClass.key as PointGroupKey, index).uniqueAxis;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/** The axes of a trigonal setting, `'hexagonal'` or `'rhombohedral'`; undefined in other systems. */
|
|
421
|
+
function settingAxes(d: GroupData, index: number): 'hexagonal' | 'rhombohedral' | undefined {
|
|
422
|
+
return d.type === 'III'
|
|
423
|
+
? itcBlackWhiteSetting(d.key as BlackWhitePointGroupKey, index).axes
|
|
424
|
+
: itcSetting(d.crystalClass.key as PointGroupKey, index).axes;
|
|
425
|
+
}
|
|
273
426
|
|
|
274
427
|
/**
|
|
275
|
-
*
|
|
428
|
+
* The crystal class of a group and the setting of the class whose frame and basis the requested
|
|
429
|
+
* setting of the group has. Internal: for the modules that need the basis or the symmetry
|
|
430
|
+
* directions of a setting.
|
|
431
|
+
*/
|
|
432
|
+
export function classSettingOf(
|
|
433
|
+
key: MagneticPointGroupKey,
|
|
434
|
+
options?: SettingOptions,
|
|
435
|
+
): { readonly key: PointGroupKey; readonly index: number } {
|
|
436
|
+
const d = data(key);
|
|
437
|
+
return { key: d.crystalClass.key as PointGroupKey, index: classSetting(d, settingIndex(d, options)) };
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
const itaGeneratorCache = new Map<string, readonly CartesianOperation[]>();
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* ITA's generators of a setting (see `generators`); for a class from the ITC class data. For a
|
|
276
444
|
* magnetic group: ITA's generators of its class in the same frame, each with the time reversal it
|
|
277
445
|
* has in the group; for a grey group followed by time reversal 1'.
|
|
278
446
|
*/
|
|
279
|
-
function settingItaGenerators(d: GroupData, index: number): readonly
|
|
447
|
+
function settingItaGenerators(d: GroupData, index: number): readonly CartesianOperation[] {
|
|
280
448
|
const cacheKey = `${d.key}#${index}`;
|
|
281
449
|
let result = itaGeneratorCache.get(cacheKey);
|
|
282
450
|
if (!result) {
|
|
283
|
-
let gens:
|
|
451
|
+
let gens: CartesianOperation[];
|
|
284
452
|
if (d.type === 'I') {
|
|
285
|
-
|
|
286
|
-
if (ita) gens = ita;
|
|
287
|
-
else {
|
|
288
|
-
if (index === 1) throw new Error(`Point group ${d.key}: no ITA generators for setting 1`);
|
|
289
|
-
gens = settingItaGenerators(d, 1).map((op) => transformOperation(op, d.settings[index - 1].frame));
|
|
290
|
-
}
|
|
453
|
+
gens = itcCartesianGenerators(d.key as PointGroupKey, index).map((m) => operation(m));
|
|
291
454
|
} else {
|
|
292
455
|
const classGens = settingItaGenerators(d.crystalClass, classSetting(d, index));
|
|
293
456
|
gens =
|
|
@@ -301,72 +464,25 @@ function settingItaGenerators(d: GroupData, index: number): readonly Operation[]
|
|
|
301
464
|
return result;
|
|
302
465
|
}
|
|
303
466
|
|
|
304
|
-
const birssOperationCache = new Map<string, readonly Operation[]>();
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* The operations of a setting in the Birss convention, in birss-app's order (docs/conventions.md,
|
|
308
|
-
* "Birss convention and birss-app"): the generators of the setting first, then repeated passes
|
|
309
|
-
* that append every new product g·h of two operations found before the pass, in the order of g,
|
|
310
|
-
* then h, until a pass adds nothing.
|
|
311
|
-
*/
|
|
312
|
-
function birssOperations(d: GroupData, index: number): readonly Operation[] {
|
|
313
|
-
const cacheKey = `${d.key}#${index}`;
|
|
314
|
-
let result = birssOperationCache.get(cacheKey);
|
|
315
|
-
if (!result) {
|
|
316
|
-
const group = [...settingGenerators(d, index)];
|
|
317
|
-
for (let changed = true; changed;) {
|
|
318
|
-
changed = false;
|
|
319
|
-
const size = group.length;
|
|
320
|
-
for (let i = 0; i < size; i++) {
|
|
321
|
-
for (let j = 0; j < size; j++) {
|
|
322
|
-
const product = compose(group[i], group[j]);
|
|
323
|
-
if (!group.some((g) => operationsEqual(g, product))) {
|
|
324
|
-
if (group.length >= MAX_GROUP_ORDER) throw new Error(`Point group ${d.key}: closure does not terminate`);
|
|
325
|
-
group.push(product);
|
|
326
|
-
changed = true;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
if (!sameSet(group, settingOperations(d, index))) {
|
|
332
|
-
throw new Error(`Point group ${d.key}, setting ${index}: Birss operations differ from the closure`);
|
|
333
|
-
}
|
|
334
|
-
result = Object.freeze(group.map(freezeOperation));
|
|
335
|
-
birssOperationCache.set(cacheKey, result);
|
|
336
|
-
}
|
|
337
|
-
return result;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
467
|
/**
|
|
341
468
|
* The operations of a setting in ITA's order (docs/conventions.md, "Order of the operations"). A
|
|
342
|
-
* crystal class:
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
* that order, each with the time reversal it has in the group. A grey group: the operations of its
|
|
347
|
-
* class, then the same sequence combined with time reversal.
|
|
469
|
+
* crystal class: from the ITC class data (itcData.ts), built coset by coset from ITA's generators.
|
|
470
|
+
* A black-and-white group: the operations of its class in the setting its ITC symbol names, in
|
|
471
|
+
* that order, each with the time reversal its symbol gives (itcMagneticData.ts). A grey group: the
|
|
472
|
+
* operations of its class, then the same sequence combined with time reversal.
|
|
348
473
|
*/
|
|
349
|
-
function settingOperations(d: GroupData, index: number): readonly
|
|
474
|
+
function settingOperations(d: GroupData, index: number): readonly CartesianOperation[] {
|
|
350
475
|
const cacheKey = `${d.key}#${index}`;
|
|
351
476
|
let result = operationCache.get(cacheKey);
|
|
352
477
|
if (!result) {
|
|
353
|
-
|
|
354
|
-
let ordered: Operation[] | undefined;
|
|
478
|
+
let ordered: CartesianOperation[];
|
|
355
479
|
if (d.type === 'I') {
|
|
356
|
-
ordered =
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}
|
|
480
|
+
ordered = itcCartesianOperations(d.key as PointGroupKey, index).map((m) => operation(m));
|
|
481
|
+
} else if (d.type === 'II') {
|
|
482
|
+
const classOps = settingOperations(d.crystalClass, index);
|
|
483
|
+
ordered = [...classOps, ...classOps.map((op) => compose(TIME_REVERSAL, op))];
|
|
361
484
|
} else {
|
|
362
|
-
|
|
363
|
-
ordered =
|
|
364
|
-
d.type === 'II'
|
|
365
|
-
? [...classOps, ...classOps.map((op) => compose(TIME_REVERSAL, op))]
|
|
366
|
-
: classOps.map((op) => withMatrix(closed, op));
|
|
367
|
-
}
|
|
368
|
-
if (!sameSet(ordered, closed)) {
|
|
369
|
-
throw new Error(`Point group ${d.key}, setting ${index}: ordered operations differ from the closure`);
|
|
485
|
+
ordered = [...itcBlackWhiteOperations(d.key as BlackWhitePointGroupKey, index)];
|
|
370
486
|
}
|
|
371
487
|
result = Object.freeze(ordered.map(freezeOperation));
|
|
372
488
|
operationCache.set(cacheKey, result);
|
|
@@ -374,53 +490,61 @@ function settingOperations(d: GroupData, index: number): readonly Operation[] {
|
|
|
374
490
|
return result;
|
|
375
491
|
}
|
|
376
492
|
|
|
377
|
-
/** True if `a` is `b` in some order: equal length, no operation twice in `a`, every one of `a` in `b`. */
|
|
378
|
-
function sameSet(a: readonly Operation[], b: readonly Operation[]): boolean {
|
|
379
|
-
return (
|
|
380
|
-
a.length === b.length &&
|
|
381
|
-
a.every((op, i) => b.some((x) => operationsEqual(x, op)) && !a.slice(0, i).some((x) => operationsEqual(x, op)))
|
|
382
|
-
);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
493
|
const symbolCache = new Map<string, { readonly short: string; readonly full: string }>();
|
|
386
494
|
|
|
387
495
|
/**
|
|
388
|
-
* Short and full symbol of a setting
|
|
389
|
-
*
|
|
390
|
-
*
|
|
496
|
+
* Short and full symbol of a setting as symcrys gives them (#137 B2): those of `derivedSymbols`,
|
|
497
|
+
* except that the default setting of a grey or black-and-white group has its key as short symbol:
|
|
498
|
+
* that of ITC Vol. D Table 1.5.2.3 for a black-and-white group (`32'`, not `32'1`), the class key
|
|
499
|
+
* followed by `1'` for a grey group (`321'`, not `3211'`). A crystal class keeps
|
|
500
|
+
* ITA's symbol (`321`) in both entry points.
|
|
501
|
+
*/
|
|
502
|
+
function settingSymbols(d: GroupData, index: number): { readonly short: string; readonly full: string } {
|
|
503
|
+
const derived = derivedSymbols(d, index);
|
|
504
|
+
return d.type !== 'I' && index === d.itcDefault ? { short: d.key, full: derived.full } : derived;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Short and full symbol of a setting by the rule. A crystal class: from the ITC class data
|
|
509
|
+
* (itcData.ts). A grey group: the symbols of its class followed by `1'`. A black-and-white group:
|
|
510
|
+
* the symbols of its class in the same frame, with the primes of its operations
|
|
511
|
+
* (magneticSymbols.ts).
|
|
391
512
|
*/
|
|
392
|
-
function
|
|
393
|
-
if (d.
|
|
394
|
-
|
|
513
|
+
function derivedSymbols(d: GroupData, index: number): { readonly short: string; readonly full: string } {
|
|
514
|
+
if (d.type === 'I') {
|
|
515
|
+
const s = itcSetting(d.key as PointGroupKey, index);
|
|
516
|
+
return Object.freeze({ short: s.short, full: s.full });
|
|
517
|
+
}
|
|
518
|
+
const cacheKey = `${d.key}#${index}`;
|
|
395
519
|
let result = symbolCache.get(cacheKey);
|
|
396
520
|
if (!result) {
|
|
397
|
-
const classSymbols =
|
|
521
|
+
const classSymbols = derivedSymbols(d.crystalClass, classSetting(d, index));
|
|
398
522
|
result = Object.freeze(
|
|
399
523
|
d.type === 'II'
|
|
400
524
|
? { short: `${classSymbols.short}1'`, full: `${classSymbols.full} 1'` }
|
|
401
|
-
: primedSymbols(classSymbols, d.crystalSystem,
|
|
525
|
+
: primedSymbols(classSymbols, d.crystalSystem, settingOperations(d, index)),
|
|
402
526
|
);
|
|
403
527
|
symbolCache.set(cacheKey, result);
|
|
404
528
|
}
|
|
405
529
|
return result;
|
|
406
530
|
}
|
|
407
531
|
|
|
408
|
-
// --- properties fixed by the operations (setting 1
|
|
532
|
+
// --- properties fixed by the operations (setting 1; a class and its Laue class share its frame) ----
|
|
409
533
|
|
|
410
534
|
/** Contains the inversion, not combined with time reversal. */
|
|
411
|
-
function hasInversion(ops: readonly
|
|
412
|
-
return ops.some((op) => !op.timeReversal && matricesEqual(op.
|
|
535
|
+
function hasInversion(ops: readonly CartesianOperation[]): boolean {
|
|
536
|
+
return ops.some((op) => !op.timeReversal && matricesEqual(op.cartesian, INVERSION));
|
|
413
537
|
}
|
|
414
538
|
|
|
415
539
|
/**
|
|
416
540
|
* Some direction is left unchanged by every operation: the group average of the matrices, which
|
|
417
541
|
* projects onto the invariant vectors, is not zero.
|
|
418
542
|
*/
|
|
419
|
-
function hasFixedDirection(ops: readonly
|
|
543
|
+
function hasFixedDirection(ops: readonly CartesianOperation[]): boolean {
|
|
420
544
|
for (let i = 0; i < 3; i++) {
|
|
421
545
|
for (let j = 0; j < 3; j++) {
|
|
422
546
|
let sum = 0;
|
|
423
|
-
for (const op of ops) sum += op.
|
|
547
|
+
for (const op of ops) sum += op.cartesian[i][j];
|
|
424
548
|
if (Math.abs(sum / ops.length) > EPSILON) return true;
|
|
425
549
|
}
|
|
426
550
|
}
|
|
@@ -434,13 +558,13 @@ function laueClassOf(crystalClass: GroupData): PointGroupKey {
|
|
|
434
558
|
const cached = laueCache.get(crystalClass.key);
|
|
435
559
|
if (cached) return cached;
|
|
436
560
|
const ops = settingOperations(crystalClass, 1);
|
|
437
|
-
const inversion:
|
|
561
|
+
const inversion: CartesianOperation = { cartesian: INVERSION, timeReversal: false };
|
|
438
562
|
const withInversion = [...ops];
|
|
439
563
|
for (const op of ops) {
|
|
440
564
|
const product = compose(inversion, op);
|
|
441
565
|
if (!withInversion.some((x) => operationsEqual(x, product))) withInversion.push(product);
|
|
442
566
|
}
|
|
443
|
-
const sameSet = (other: readonly
|
|
567
|
+
const sameSet = (other: readonly CartesianOperation[]): boolean =>
|
|
444
568
|
other.length === withInversion.length && other.every((x) => withInversion.some((y) => operationsEqual(x, y)));
|
|
445
569
|
const laue = POINT_GROUP_KEYS.find((key) => sameSet(settingOperations(data(key), 1)));
|
|
446
570
|
if (!laue) throw new Error(`No centrosymmetric class matches ${crystalClass.key} with the inversion`);
|
|
@@ -467,7 +591,7 @@ export function pointGroup<K extends MagneticPointGroupKey>(key: K): PointGroup<
|
|
|
467
591
|
order: ops.length,
|
|
468
592
|
centrosymmetric: hasInversion(ops),
|
|
469
593
|
polar: hasFixedDirection(ops),
|
|
470
|
-
|
|
594
|
+
enantiomorphic: ops.every((op) => det(op.cartesian) > 0),
|
|
471
595
|
laueClass: laueClassOf(d.crystalClass),
|
|
472
596
|
});
|
|
473
597
|
groupCache.set(d.key, g);
|
|
@@ -477,7 +601,7 @@ export function pointGroup<K extends MagneticPointGroupKey>(key: K): PointGroup<
|
|
|
477
601
|
|
|
478
602
|
/** All 32 crystal classes, in the order of `POINT_GROUP_KEYS` (by crystal system, as in ITA). */
|
|
479
603
|
export function pointGroups(): readonly PointGroup[] {
|
|
480
|
-
return POINT_GROUP_KEYS.map((key) => pointGroup(key));
|
|
604
|
+
return deepFreeze(POINT_GROUP_KEYS.map((key) => pointGroup(key)));
|
|
481
605
|
}
|
|
482
606
|
|
|
483
607
|
/**
|
|
@@ -486,7 +610,7 @@ export function pointGroups(): readonly PointGroup[] {
|
|
|
486
610
|
* groups (type III) in the order of ITC Vol. D Table 1.5.2.3.
|
|
487
611
|
*/
|
|
488
612
|
export function magneticPointGroups(): readonly PointGroup<MagneticPointGroupKey>[] {
|
|
489
|
-
return MAGNETIC_POINT_GROUP_KEYS.map((key) => pointGroup(key));
|
|
613
|
+
return deepFreeze(MAGNETIC_POINT_GROUP_KEYS.map((key) => pointGroup(key)));
|
|
490
614
|
}
|
|
491
615
|
|
|
492
616
|
/**
|
|
@@ -498,60 +622,154 @@ export function crystalClassOf(key: MagneticPointGroupKey): PointGroupKey {
|
|
|
498
622
|
return data(key).crystalClass.key as PointGroupKey;
|
|
499
623
|
}
|
|
500
624
|
|
|
501
|
-
/**
|
|
502
|
-
|
|
625
|
+
/**
|
|
626
|
+
* The lattice systems of a point group: those whose lattices its crystal class can act on (ITA
|
|
627
|
+
* § 1.3.4.4.2 and Table 1.3.4.1, p. 39). One for every class but the trigonal ones, which belong to
|
|
628
|
+
* the hexagonal (hP) or the rhombohedral (hR) lattice system depending on the basis, so they give
|
|
629
|
+
* both, `['hexagonal', 'rhombohedral']`. The holohedry of each is `holohedry(latticeSystem)`. Throws a
|
|
630
|
+
* RangeError for an unknown key.
|
|
631
|
+
*/
|
|
632
|
+
export function latticeSystems(key: MagneticPointGroupKey): readonly LatticeSystem[] {
|
|
633
|
+
return latticeSystemsOfSystem(pointGroup(key).crystalSystem);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/** The settings of a point group, with their symbols and the ITC default. */
|
|
637
|
+
export function settings(key: MagneticPointGroupKey): readonly Setting[] {
|
|
638
|
+
rejectConventionArgument(arguments.length);
|
|
503
639
|
const d = data(key);
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
640
|
+
return deepFreeze(
|
|
641
|
+
Array.from({ length: d.settingCount }, (_, i) => {
|
|
642
|
+
const symbols = settingSymbols(d, i + 1);
|
|
643
|
+
const data =
|
|
644
|
+
d.type === 'III'
|
|
645
|
+
? itcBlackWhiteSetting(d.key as BlackWhitePointGroupKey, i + 1)
|
|
646
|
+
: itcSetting(d.crystalClass.key as PointGroupKey, i + 1);
|
|
647
|
+
return Object.freeze({
|
|
648
|
+
index: i + 1,
|
|
649
|
+
symbol: symbols.short,
|
|
650
|
+
fullSymbol: symbols.full,
|
|
651
|
+
...(data.uniqueAxis ? { uniqueAxis: data.uniqueAxis } : {}),
|
|
652
|
+
...(data.axes ? { axes: data.axes } : {}),
|
|
653
|
+
isDefault: i + 1 === d.itcDefault,
|
|
654
|
+
});
|
|
655
|
+
}),
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
const frozenMatrix = (m: Mat3 | IntMat3): Mat3 =>
|
|
660
|
+
Object.freeze(m.map((row) => Object.freeze(row.map((v) => v + 0)))) as unknown as Mat3;
|
|
661
|
+
|
|
662
|
+
/** An integer matrix from one that should be one; throws if it is not (a data error). Internal. */
|
|
663
|
+
export function integer(m: Mat3, what: string): Mat3 {
|
|
664
|
+
const r = m.map((row) => row.map((v) => Math.round(v) + 0)) as unknown as Mat3;
|
|
665
|
+
if (!m.every((row, i) => row.every((v, j) => Math.abs(v - r[i][j]) < 1e-9))) {
|
|
666
|
+
throw new Error(`${what} is not an integer matrix in the lattice basis: ${shown(m)}`);
|
|
667
|
+
}
|
|
668
|
+
return r;
|
|
516
669
|
}
|
|
517
670
|
|
|
518
671
|
/**
|
|
519
|
-
*
|
|
520
|
-
* setting
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
|
|
524
|
-
|
|
672
|
+
* The records of the API for Cartesian operations of a setting: each with its matrix W in the
|
|
673
|
+
* lattice basis of the setting. A crystal class takes W from the exact ITC class data (`exact`, in
|
|
674
|
+
* the same order); a magnetic group computes W = B⁻¹·R·B in the basis B of the setting of its class
|
|
675
|
+
* (itcData.ts, `itcBasis`), which is exact after rounding, since W is an integer matrix.
|
|
676
|
+
*/
|
|
677
|
+
function records(
|
|
678
|
+
d: GroupData,
|
|
679
|
+
index: number,
|
|
680
|
+
ops: readonly CartesianOperation[],
|
|
681
|
+
exact: readonly IntMat3[] | undefined,
|
|
682
|
+
): readonly Operation[] {
|
|
683
|
+
const classKey = d.crystalClass.key as PointGroupKey;
|
|
684
|
+
const b = itcBasis(classKey, classSetting(d, index));
|
|
685
|
+
const bInv = inverse(b);
|
|
686
|
+
return Object.freeze(
|
|
687
|
+
ops.map((op, i) =>
|
|
688
|
+
Object.freeze({
|
|
689
|
+
matrix: frozenMatrix(
|
|
690
|
+
exact ? exact[i] : integer(multiply(multiply(bInv, op.cartesian), b), `Operation ${i} of ${d.key}`),
|
|
691
|
+
),
|
|
692
|
+
cartesian: op.cartesian,
|
|
693
|
+
timeReversal: op.timeReversal,
|
|
694
|
+
}),
|
|
695
|
+
),
|
|
696
|
+
);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
const recordCache = new Map<string, readonly Operation[]>();
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* All operations of the point group in the requested setting (default: the ITC default setting),
|
|
703
|
+
* in ITA's order: identity first, then as ITA numbers the general position of the crystal class; an
|
|
704
|
+
* operation of a magnetic group has the number it has in the class, and a grey group lists the
|
|
705
|
+
* class first, then the same sequence with time reversal (docs/conventions.md, "Order of the
|
|
706
|
+
* operations"). Each operation is ITA's matrix W in the lattice basis of the setting (`matrix`) with
|
|
707
|
+
* the same operation as a Cartesian matrix (`cartesian`) and its time reversal (docs/conventions.md,
|
|
708
|
+
* "Operations").
|
|
525
709
|
*/
|
|
526
710
|
export function operations(key: MagneticPointGroupKey, options?: SettingOptions): readonly Operation[] {
|
|
711
|
+
checkOptions(options, SETTING_KEYS, 'operations');
|
|
527
712
|
const d = data(key);
|
|
528
713
|
const index = settingIndex(d, options);
|
|
529
|
-
|
|
714
|
+
const cacheKey = `${d.key}#${index}`;
|
|
715
|
+
let result = recordCache.get(cacheKey);
|
|
716
|
+
if (!result) {
|
|
717
|
+
const exact = d.type === 'I' ? itcLatticeOperations(d.key as PointGroupKey, index) : undefined;
|
|
718
|
+
result = records(d, index, settingOperations(d, index), exact);
|
|
719
|
+
recordCache.set(cacheKey, result);
|
|
720
|
+
}
|
|
721
|
+
return result;
|
|
530
722
|
}
|
|
531
723
|
|
|
532
724
|
/**
|
|
533
|
-
* Generators of the point group in the requested setting (docs/conventions.md, "Generators")
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
*
|
|
538
|
-
* birss-app's generators (for `1` the identity, as in birss-app).
|
|
725
|
+
* Generators of the point group in the requested setting (docs/conventions.md, "Generators"): ITA's
|
|
726
|
+
* selected generators in printed order, without the identity and ITA's lattice translations, so
|
|
727
|
+
* the list is empty for `1`; for the settings ITA does not print (`mm2` settings 2 and 3, monoclinic unique axis a), those of setting 1 carried
|
|
728
|
+
* into their frame; for a magnetic group, those of its class with the time reversal they
|
|
729
|
+
* have in the group, for a grey group followed by `1'`.
|
|
539
730
|
*/
|
|
540
731
|
export function generators(key: MagneticPointGroupKey, options?: SettingOptions): readonly Operation[] {
|
|
732
|
+
checkOptions(options, SETTING_KEYS, 'generators');
|
|
541
733
|
const d = data(key);
|
|
542
734
|
const index = settingIndex(d, options);
|
|
543
|
-
|
|
735
|
+
const cacheKey = `${d.key}#${index}#generators`;
|
|
736
|
+
let result = recordCache.get(cacheKey);
|
|
737
|
+
if (!result) {
|
|
738
|
+
const exact = d.type === 'I' ? itcLatticeGenerators(d.key as PointGroupKey, index) : undefined;
|
|
739
|
+
result = records(d, index, settingItaGenerators(d, index), exact);
|
|
740
|
+
recordCache.set(cacheKey, result);
|
|
741
|
+
}
|
|
742
|
+
return result;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* A Schoenflies symbol as ITC Vol. D writes it (#137 B3): `S6` for the class -3, where ITA writes
|
|
747
|
+
* `C3i` (Table 3.2.1.2), as the crystallographic API does, and so `S6R` for its grey group. The
|
|
748
|
+
* black-and-white groups store their symbols as Vol. D prints them (`S6(C3)`, `D3d(S6)`,
|
|
749
|
+
* `C6h(S6)`; itcMagneticData.ts).
|
|
750
|
+
*/
|
|
751
|
+
const volDSchoenflies = (s: string): string => s.replace(/C3i/g, 'S6');
|
|
752
|
+
|
|
753
|
+
/** The Schoenflies symbol of a crystal class as ITA writes it (`C3i`). Internal: for the crystallographic API. */
|
|
754
|
+
export function itaSchoenflies(key: PointGroupKey): string {
|
|
755
|
+
return data(key).schoenflies;
|
|
544
756
|
}
|
|
545
757
|
|
|
546
|
-
/**
|
|
758
|
+
/**
|
|
759
|
+
* A symbol of the point group in the requested setting. The default setting of a grey or
|
|
760
|
+
* black-and-white group has its key as short symbol (`32'`, as ITC Vol. D Table 1.5.2.3 prints it;
|
|
761
|
+
* `321'`), a crystal class ITA's symbol (`321`), and the Schoenflies symbols follow ITC Vol. D
|
|
762
|
+
* (`S6`, `D3d(S6)`; docs/conventions.md, "Symbols").
|
|
763
|
+
*/
|
|
547
764
|
export function symbol(key: MagneticPointGroupKey, options?: SymbolOptions): string {
|
|
765
|
+
checkOptions(options, [...SETTING_KEYS, 'form'], 'symbol');
|
|
548
766
|
const d = data(key);
|
|
549
767
|
const form = options?.form ?? 'short';
|
|
550
|
-
const s = settingSymbols(d, settingIndex(d, options)
|
|
551
|
-
if (form === 'schoenflies') return d.schoenflies;
|
|
768
|
+
const s = settingSymbols(d, settingIndex(d, options));
|
|
769
|
+
if (form === 'schoenflies') return volDSchoenflies(d.schoenflies);
|
|
552
770
|
if (form === 'short') return s.short;
|
|
553
771
|
if (form === 'full') return s.full;
|
|
554
|
-
throw new RangeError(`Unknown symbol form: ${
|
|
772
|
+
throw new RangeError(`Unknown symbol form: ${shown(form)}`);
|
|
555
773
|
}
|
|
556
774
|
|
|
557
775
|
/** A point group in a given setting. */
|
|
@@ -562,66 +780,91 @@ export interface PointGroupInSetting<K extends MagneticPointGroupKey = PointGrou
|
|
|
562
780
|
readonly setting: number;
|
|
563
781
|
}
|
|
564
782
|
|
|
565
|
-
|
|
783
|
+
/** A symbol in the spelling of this library without spaces (notation.ts). */
|
|
784
|
+
const compact = compactSymbol;
|
|
566
785
|
|
|
567
786
|
function find(
|
|
568
|
-
|
|
569
|
-
conventionName: Convention,
|
|
787
|
+
symbol: string,
|
|
570
788
|
classesOnly: boolean,
|
|
789
|
+
options: AxesOptions | undefined,
|
|
571
790
|
): PointGroupInSetting<MagneticPointGroupKey> | undefined {
|
|
572
|
-
|
|
573
|
-
if (typeof
|
|
574
|
-
|
|
791
|
+
// A symbol that names no group is not found; a value that is no symbol at all is wrong input.
|
|
792
|
+
if (typeof symbol !== 'string')
|
|
793
|
+
throw new RangeError(`findPointGroup takes a symbol (a string), not ${shown(symbol)}`);
|
|
794
|
+
const target = compact(symbol);
|
|
575
795
|
const candidates = [...BY_KEY.values()].filter((d) => !classesOnly || d.type === 'I');
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}
|
|
796
|
+
// The key, a short or full symbol of a setting (spaces ignored), Birss's cubic form; then a
|
|
797
|
+
// Schoenflies symbol, ITA's `C3i` or ITC Vol. D's `S6` alike, which names the group and not an
|
|
798
|
+
// orientation (Thomas, 2026-11-23, #96). A symbol of several groups is an error.
|
|
799
|
+
let found = candidates.map((d) => ({ d, named: settingsNamed(d, symbol) })).filter((m) => m.named.length > 0);
|
|
800
|
+
if (found.length === 0) {
|
|
801
|
+
const inVolD = volDSchoenflies(target);
|
|
802
|
+
found = candidates
|
|
803
|
+
.filter((d) => volDSchoenflies(d.schoenflies) === inVolD)
|
|
804
|
+
.map((d) => ({ d, named: allSettings(d) }));
|
|
805
|
+
}
|
|
806
|
+
if (found.length > 1) {
|
|
807
|
+
throw new RangeError(
|
|
808
|
+
`The symbol ${shown(symbol)} names several point groups: ${found.map((m) => m.d.key).join(', ')}`,
|
|
809
|
+
);
|
|
591
810
|
}
|
|
592
|
-
return undefined;
|
|
811
|
+
if (found.length === 0) return undefined;
|
|
812
|
+
const { d, named } = found[0]!;
|
|
813
|
+
// A name that several settings share gives the standard, unless axes or uniqueAxis chooses another.
|
|
814
|
+
return { key: d.key, setting: choose(d, named, criteriaOf(d, options), shown(symbol)) };
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* Birss prints the cubic groups without the overbar on the 3, which takes the prime of the mirror
|
|
819
|
+
* before it (Birss Tables 3 and 6: `m3m`, `m'3` for `m-3m`, `m'-3'`): the symbol with the overbar,
|
|
820
|
+
* which the caller looks up as a key (the cubic groups have one setting); undefined for any other
|
|
821
|
+
* symbol.
|
|
822
|
+
*/
|
|
823
|
+
function birssCubic(compactTarget: string): string | undefined {
|
|
824
|
+
const m = /^m('?)3(?!')(.*)$/.exec(compactTarget);
|
|
825
|
+
return m ? `m${m[1]}-3${m[1]}${m[2]}` : undefined;
|
|
593
826
|
}
|
|
594
827
|
|
|
595
828
|
/**
|
|
596
|
-
* Finds a crystal class by a
|
|
597
|
-
*
|
|
598
|
-
*
|
|
599
|
-
*
|
|
600
|
-
*
|
|
601
|
-
*
|
|
602
|
-
*
|
|
603
|
-
* `
|
|
829
|
+
* Finds a crystal class by a symbol, read tolerantly.
|
|
830
|
+
* It reads, spaces ignored (#96; docs/conventions.md, "Reading symbols"): the key; the short or
|
|
831
|
+
* full symbol of a setting (`312`, `1 1 2`); a Schoenflies symbol, ITA's or ITC Vol. D's (`D3`,
|
|
832
|
+
* `C3i`, `S6`); Birss's cubic symbols without the overbar on the 3 (`m3m`). A symbol that names
|
|
833
|
+
* several settings (the key `32`, which is also the symbol of the setting with rhombohedral axes;
|
|
834
|
+
* `2` for unique axis b, c and a; any Schoenflies symbol) gives the standard (ITC default) setting,
|
|
835
|
+
* unless the options `axes` or `uniqueAxis` choose another, as the headlines of ITA name the
|
|
836
|
+
* settings (the option `axes` set to `'rhombohedral'` for the key `32`).
|
|
837
|
+
*
|
|
838
|
+
* Spellings: the overbar as `-`, `−`, a combining overbar or `¯` after the digit (`m3̄m`), `bar3` (also with a backslash and braces, as in LaTeX);
|
|
839
|
+
* Schoenflies subscripts also as Unicode or LaTeX subscripts (`C₃ᵥ`, `C_{3v}`). Returns undefined if nothing matches,
|
|
840
|
+
* also for a value that is not a string and for the symbol of a magnetic group with time reversal
|
|
841
|
+
* (`findMagneticPointGroup`); a symbol that names several groups is a RangeError that lists them.
|
|
604
842
|
*/
|
|
605
|
-
export function findPointGroup(
|
|
606
|
-
|
|
843
|
+
export function findPointGroup(symbol: string, options?: AxesOptions): PointGroupInSetting | undefined {
|
|
844
|
+
if (arguments.length > 2) rejectConventionArgument(arguments.length);
|
|
845
|
+
return deepFreeze(find(symbol, true, criteriaArgument(options)) as PointGroupInSetting | undefined);
|
|
607
846
|
}
|
|
608
847
|
|
|
609
848
|
/**
|
|
610
|
-
* Finds one of the 122 magnetic point groups (the 32 crystal classes included) by a symbol
|
|
611
|
-
*
|
|
612
|
-
*
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
* the
|
|
616
|
-
*
|
|
617
|
-
*
|
|
618
|
-
*
|
|
619
|
-
*
|
|
620
|
-
*
|
|
849
|
+
* Finds one of the 122 magnetic point groups (the 32 crystal classes included) by a symbol, read
|
|
850
|
+
* tolerantly. A prime marks time reversal: `4'/mmm'`, `2221'`.
|
|
851
|
+
* It reads, spaces ignored (#96; docs/conventions.md, "Reading symbols"): the key; the short or
|
|
852
|
+
* full symbol of a setting (`312`, `1 1 2`); a Schoenflies symbol, ITA's or ITC Vol. D's (`D3`,
|
|
853
|
+
* `C3i`, `S6`); Birss's cubic symbols without the overbar on the 3 (`m3m`). A symbol that names
|
|
854
|
+
* several settings (the key `32`, which is also the symbol of the setting with rhombohedral axes;
|
|
855
|
+
* `2` for unique axis b, c and a; any Schoenflies symbol) gives the standard (ITC default) setting,
|
|
856
|
+
* unless the options `axes` or `uniqueAxis` choose another, as the headlines of ITA name the
|
|
857
|
+
* settings (the option `axes` set to `'rhombohedral'` for the key `32`).
|
|
858
|
+
*
|
|
859
|
+
* Spellings: the overbar as `-`, `−`, a combining overbar or `¯` after the digit (`m3̄m`), `bar3` (also with a backslash and braces, as in LaTeX);
|
|
860
|
+
* the prime as `'`, `′`, `ʹ` or `’`; Schoenflies subscripts also as Unicode or LaTeX subscripts (`D₃d(S₆)`, `D_{3d}`).
|
|
861
|
+
* Returns undefined if nothing matches, also for a value that is not a string; a symbol that names
|
|
862
|
+
* several groups is a RangeError that lists them.
|
|
621
863
|
*/
|
|
622
864
|
export function findMagneticPointGroup(
|
|
623
|
-
|
|
624
|
-
|
|
865
|
+
symbol: string,
|
|
866
|
+
options?: AxesOptions,
|
|
625
867
|
): PointGroupInSetting<MagneticPointGroupKey> | undefined {
|
|
626
|
-
|
|
868
|
+
if (arguments.length > 2) rejectConventionArgument(arguments.length);
|
|
869
|
+
return deepFreeze(find(symbol, false, criteriaArgument(options)));
|
|
627
870
|
}
|