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