symcrys 0.10.1 → 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.
Files changed (218) hide show
  1. package/README.md +6 -6
  2. package/dist/cell.d.ts +19 -16
  3. package/dist/cell.d.ts.map +1 -1
  4. package/dist/cell.js +63 -35
  5. package/dist/cell.js.map +1 -1
  6. package/dist/checks.d.ts +29 -0
  7. package/dist/checks.d.ts.map +1 -0
  8. package/dist/checks.js +79 -0
  9. package/dist/checks.js.map +1 -0
  10. package/dist/closure.d.ts +43 -0
  11. package/dist/closure.d.ts.map +1 -0
  12. package/dist/closure.js +201 -0
  13. package/dist/closure.js.map +1 -0
  14. package/dist/crystalClasses.d.ts +145 -117
  15. package/dist/crystalClasses.d.ts.map +1 -1
  16. package/dist/crystalClasses.js +161 -121
  17. package/dist/crystalClasses.js.map +1 -1
  18. package/dist/freeze.d.ts +7 -0
  19. package/dist/freeze.d.ts.map +1 -0
  20. package/dist/freeze.js +15 -0
  21. package/dist/freeze.js.map +1 -0
  22. package/dist/index.d.ts +11 -10
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +4 -3
  25. package/dist/index.js.map +1 -1
  26. package/dist/indices.d.ts +31 -5
  27. package/dist/indices.d.ts.map +1 -1
  28. package/dist/indices.js +104 -13
  29. package/dist/indices.js.map +1 -1
  30. package/dist/lattice.d.ts +15 -1
  31. package/dist/lattice.d.ts.map +1 -1
  32. package/dist/lattice.js +30 -1
  33. package/dist/lattice.js.map +1 -1
  34. package/dist/linalg.d.ts +2 -2
  35. package/dist/linalg.d.ts.map +1 -1
  36. package/dist/linalg.js +3 -3
  37. package/dist/linalg.js.map +1 -1
  38. package/dist/magnetic.d.ts +12 -10
  39. package/dist/magnetic.d.ts.map +1 -1
  40. package/dist/magnetic.js +8 -6
  41. package/dist/magnetic.js.map +1 -1
  42. package/dist/notation.d.ts +16 -0
  43. package/dist/notation.d.ts.map +1 -0
  44. package/dist/notation.js +66 -0
  45. package/dist/notation.js.map +1 -0
  46. package/dist/operations.d.ts +40 -26
  47. package/dist/operations.d.ts.map +1 -1
  48. package/dist/operations.js +48 -60
  49. package/dist/operations.js.map +1 -1
  50. package/dist/plane.d.ts +141 -79
  51. package/dist/plane.d.ts.map +1 -1
  52. package/dist/plane.js +147 -77
  53. package/dist/plane.js.map +1 -1
  54. package/dist/pointGroups/crystalForms.d.ts +6 -21
  55. package/dist/pointGroups/crystalForms.d.ts.map +1 -1
  56. package/dist/pointGroups/crystalForms.js +9 -16
  57. package/dist/pointGroups/crystalForms.js.map +1 -1
  58. package/dist/pointGroups/crystalFormsData.d.ts +4 -1
  59. package/dist/pointGroups/crystalFormsData.d.ts.map +1 -1
  60. package/dist/pointGroups/crystalFormsData.js +64 -1
  61. package/dist/pointGroups/crystalFormsData.js.map +1 -1
  62. package/dist/pointGroups/elements.d.ts +19 -17
  63. package/dist/pointGroups/elements.d.ts.map +1 -1
  64. package/dist/pointGroups/elements.js +65 -83
  65. package/dist/pointGroups/elements.js.map +1 -1
  66. package/dist/pointGroups/identify.d.ts +10 -18
  67. package/dist/pointGroups/identify.d.ts.map +1 -1
  68. package/dist/pointGroups/identify.js +27 -79
  69. package/dist/pointGroups/identify.js.map +1 -1
  70. package/dist/pointGroups/itaOrder.d.ts +15 -14
  71. package/dist/pointGroups/itaOrder.d.ts.map +1 -1
  72. package/dist/pointGroups/itaOrder.js +116 -94
  73. package/dist/pointGroups/itaOrder.js.map +1 -1
  74. package/dist/pointGroups/itcData.d.ts +96 -0
  75. package/dist/pointGroups/itcData.d.ts.map +1 -0
  76. package/dist/pointGroups/itcData.js +336 -0
  77. package/dist/pointGroups/itcData.js.map +1 -0
  78. package/dist/pointGroups/itcMagneticData.d.ts +55 -0
  79. package/dist/pointGroups/itcMagneticData.d.ts.map +1 -0
  80. package/dist/pointGroups/itcMagneticData.js +172 -0
  81. package/dist/pointGroups/itcMagneticData.js.map +1 -0
  82. package/dist/pointGroups/keys.d.ts +32 -0
  83. package/dist/pointGroups/keys.d.ts.map +1 -0
  84. package/dist/pointGroups/keys.js +120 -0
  85. package/dist/pointGroups/keys.js.map +1 -0
  86. package/dist/pointGroups/magneticSymbols.d.ts +6 -5
  87. package/dist/pointGroups/magneticSymbols.d.ts.map +1 -1
  88. package/dist/pointGroups/magneticSymbols.js +15 -12
  89. package/dist/pointGroups/magneticSymbols.js.map +1 -1
  90. package/dist/pointGroups/orbits.d.ts +23 -42
  91. package/dist/pointGroups/orbits.d.ts.map +1 -1
  92. package/dist/pointGroups/orbits.js +20 -62
  93. package/dist/pointGroups/orbits.js.map +1 -1
  94. package/dist/pointGroups/pointGroups.d.ts +135 -67
  95. package/dist/pointGroups/pointGroups.d.ts.map +1 -1
  96. package/dist/pointGroups/pointGroups.js +409 -244
  97. package/dist/pointGroups/pointGroups.js.map +1 -1
  98. package/dist/pointGroups/properties.d.ts +21 -22
  99. package/dist/pointGroups/properties.d.ts.map +1 -1
  100. package/dist/pointGroups/properties.js +40 -37
  101. package/dist/pointGroups/properties.js.map +1 -1
  102. package/dist/pointGroups/seitzData.d.ts +26 -0
  103. package/dist/pointGroups/seitzData.d.ts.map +1 -0
  104. package/dist/pointGroups/seitzData.js +130 -0
  105. package/dist/pointGroups/seitzData.js.map +1 -0
  106. package/dist/pointGroups/wyckoff.d.ts +70 -40
  107. package/dist/pointGroups/wyckoff.d.ts.map +1 -1
  108. package/dist/pointGroups/wyckoff.js +98 -91
  109. package/dist/pointGroups/wyckoff.js.map +1 -1
  110. package/dist/pointGroups/wyckoffData.d.ts +7 -4
  111. package/dist/pointGroups/wyckoffData.d.ts.map +1 -1
  112. package/dist/pointGroups/wyckoffData.js +789 -168
  113. package/dist/pointGroups/wyckoffData.js.map +1 -1
  114. package/dist/siteSymmetry.d.ts +8 -16
  115. package/dist/siteSymmetry.d.ts.map +1 -1
  116. package/dist/siteSymmetry.js +34 -24
  117. package/dist/siteSymmetry.js.map +1 -1
  118. package/dist/spaceGroups/affine.d.ts.map +1 -1
  119. package/dist/spaceGroups/affine.js +3 -2
  120. package/dist/spaceGroups/affine.js.map +1 -1
  121. package/dist/spaceGroups/cell.d.ts +43 -31
  122. package/dist/spaceGroups/cell.d.ts.map +1 -1
  123. package/dist/spaceGroups/cell.js +173 -85
  124. package/dist/spaceGroups/cell.js.map +1 -1
  125. package/dist/spaceGroups/describe.d.ts +12 -10
  126. package/dist/spaceGroups/describe.d.ts.map +1 -1
  127. package/dist/spaceGroups/describe.js +11 -10
  128. package/dist/spaceGroups/describe.js.map +1 -1
  129. package/dist/spaceGroups/planeGroupData.d.ts +1 -1
  130. package/dist/spaceGroups/planeGroupData.d.ts.map +1 -1
  131. package/dist/spaceGroups/planeGroupData.js +8 -8
  132. package/dist/spaceGroups/planeGroupData.js.map +1 -1
  133. package/dist/spaceGroups/planeGroups.d.ts.map +1 -1
  134. package/dist/spaceGroups/planeGroups.js +2 -1
  135. package/dist/spaceGroups/planeGroups.js.map +1 -1
  136. package/dist/spaceGroups/positions.d.ts +48 -19
  137. package/dist/spaceGroups/positions.d.ts.map +1 -1
  138. package/dist/spaceGroups/positions.js +166 -67
  139. package/dist/spaceGroups/positions.js.map +1 -1
  140. package/dist/tensors/propertyTable.d.ts +3 -1
  141. package/dist/tensors/propertyTable.d.ts.map +1 -1
  142. package/dist/tensors/propertyTable.js +17 -10
  143. package/dist/tensors/propertyTable.js.map +1 -1
  144. package/dist/tensors/rowEchelon.d.ts +3 -3
  145. package/dist/tensors/rowEchelon.d.ts.map +1 -1
  146. package/dist/tensors/rowEchelon.js +4 -4
  147. package/dist/tensors/rowEchelon.js.map +1 -1
  148. package/dist/tensors/tensorForm.d.ts +75 -34
  149. package/dist/tensors/tensorForm.d.ts.map +1 -1
  150. package/dist/tensors/tensorForm.js +171 -67
  151. package/dist/tensors/tensorForm.js.map +1 -1
  152. package/dist/tensors/tensorProperties.d.ts +10 -9
  153. package/dist/tensors/tensorProperties.d.ts.map +1 -1
  154. package/dist/tensors/tensorProperties.js +22 -12
  155. package/dist/tensors/tensorProperties.js.map +1 -1
  156. package/dist/tolerances.d.ts +56 -1
  157. package/dist/tolerances.d.ts.map +1 -1
  158. package/dist/tolerances.js +51 -1
  159. package/dist/tolerances.js.map +1 -1
  160. package/dist/version.d.ts +1 -1
  161. package/dist/version.js +1 -1
  162. package/package.json +1 -1
  163. package/src/cell.ts +78 -51
  164. package/src/checks.ts +84 -0
  165. package/src/closure.ts +214 -0
  166. package/src/crystalClasses.ts +232 -157
  167. package/src/freeze.ts +14 -0
  168. package/src/index.ts +21 -10
  169. package/src/indices.ts +108 -18
  170. package/src/lattice.ts +41 -1
  171. package/src/linalg.ts +3 -3
  172. package/src/magnetic.ts +14 -9
  173. package/src/notation.ts +73 -0
  174. package/src/operations.ts +78 -71
  175. package/src/plane.ts +253 -127
  176. package/src/pointGroups/crystalForms.ts +11 -44
  177. package/src/pointGroups/crystalFormsData.ts +66 -1
  178. package/src/pointGroups/elements.ts +82 -92
  179. package/src/pointGroups/identify.ts +38 -97
  180. package/src/pointGroups/itaOrder.ts +117 -101
  181. package/src/pointGroups/itcData.ts +404 -0
  182. package/src/pointGroups/itcMagneticData.ts +206 -0
  183. package/src/pointGroups/keys.ts +144 -0
  184. package/src/pointGroups/magneticSymbols.ts +18 -17
  185. package/src/pointGroups/orbits.ts +41 -89
  186. package/src/pointGroups/pointGroups.ts +540 -297
  187. package/src/pointGroups/properties.ts +44 -40
  188. package/src/pointGroups/seitzData.ts +147 -0
  189. package/src/pointGroups/wyckoff.ts +137 -112
  190. package/src/pointGroups/wyckoffData.ts +793 -170
  191. package/src/siteSymmetry.ts +43 -40
  192. package/src/spaceGroups/affine.ts +3 -2
  193. package/src/spaceGroups/cell.ts +227 -116
  194. package/src/spaceGroups/describe.ts +22 -19
  195. package/src/spaceGroups/planeGroupData.ts +9 -9
  196. package/src/spaceGroups/planeGroups.ts +2 -1
  197. package/src/spaceGroups/positions.ts +202 -78
  198. package/src/tensors/propertyTable.ts +26 -14
  199. package/src/tensors/rowEchelon.ts +4 -3
  200. package/src/tensors/tensorForm.ts +258 -88
  201. package/src/tensors/tensorProperties.ts +34 -14
  202. package/src/tolerances.ts +66 -1
  203. package/src/version.ts +1 -1
  204. package/dist/pointGroups/data.d.ts +0 -75
  205. package/dist/pointGroups/data.d.ts.map +0 -1
  206. package/dist/pointGroups/data.js +0 -212
  207. package/dist/pointGroups/data.js.map +0 -1
  208. package/dist/pointGroups/magneticData.d.ts +0 -66
  209. package/dist/pointGroups/magneticData.d.ts.map +0 -1
  210. package/dist/pointGroups/magneticData.js +0 -184
  211. package/dist/pointGroups/magneticData.js.map +0 -1
  212. package/dist/spaceGroups/snap.d.ts +0 -20
  213. package/dist/spaceGroups/snap.d.ts.map +0 -1
  214. package/dist/spaceGroups/snap.js +0 -103
  215. package/dist/spaceGroups/snap.js.map +0 -1
  216. package/src/pointGroups/data.ts +0 -305
  217. package/src/pointGroups/magneticData.ts +0 -328
  218. package/src/spaceGroups/snap.ts +0 -121
@@ -1,68 +1,72 @@
1
1
  /**
2
2
  * Properties that follow from operations, for a list of operations of a caller, and the holohedry
3
- * of a crystal system. The properties of a point group given by its key are fields of
3
+ * of a lattice system. The properties of a point group given by its key are fields of
4
4
  * `pointGroup(key)` (pointGroups.ts). Properties that are the question whether a tensor is allowed
5
5
  * (polar, piezoelectric, ferroaxial, ferromagnetic, …) are named tensor properties
6
6
  * (tensors/tensorProperties.ts).
7
7
  */
8
8
 
9
- import type { CrystalSystem } from '../lattice.js';
10
- import { INVERSION, det, matricesEqual } from '../linalg.js';
11
- import { checkOrthogonal, checkTimeReversal, closeGroup, type Operation } from '../operations.js';
12
- import type { PointGroupKey } from './data.js';
13
-
14
- /**
15
- * What every function for a list of operations asks of the list: Cartesian (orthogonal) matrices,
16
- * and of every operation whether it is combined with time reversal, as `tensorFormOf` does.
17
- */
18
- function check(operations: readonly Operation[]): void {
19
- operations.forEach((op, i) => checkOrthogonal(op.matrix, `Operation ${i}`));
20
- checkTimeReversal(operations);
21
- }
9
+ import { checkOptions, shown, TOLERANCE_KEYS } from '../checks.js';
10
+ import type { LatticeSystem } from '../lattice.js';
11
+ import { INVERSION, det } from '../linalg.js';
12
+ import { checkCartesianOperations, checkTimeReversal, type CartesianOperation } from '../operations.js';
13
+ import { closedGroup, sameWithin } from '../closure.js';
14
+ import { toleranceOf, type ToleranceOptions } from '../tolerances.js';
15
+ import type { PointGroupKey } from './keys.js';
22
16
 
23
17
  /**
24
18
  * True if the group generated by `operations` contains the inversion, not combined with time
25
- * reversal: e.g. for the operations of a distorted crystal. A list that is not closed is closed
26
- * first. For a point group given by its key, read `pointGroup(key).centrosymmetric`. Throws a
27
- * RangeError for a matrix that is not orthogonal and for an operation that does not say whether it
28
- * is combined with time reversal.
19
+ * reversal: e.g. for the operations of a distorted crystal. The list is closed into a group within
20
+ * the tolerance first, as `tensorFormOf` closes it, and the inversion is sought within the
21
+ * tolerance. For a point group given by its key, read `pointGroup(key).centrosymmetric`. Throws a
22
+ * RangeError as `tensorFormOf`.
29
23
  */
30
- export function isCentrosymmetricOf(operations: readonly Operation[]): boolean {
31
- check(operations);
32
- return closeGroup(operations).some((op) => !op.timeReversal && matricesEqual(op.matrix, INVERSION));
24
+ export function isCentrosymmetricOf(operations: readonly CartesianOperation[], options?: ToleranceOptions): boolean {
25
+ checkOptions(options, TOLERANCE_KEYS, 'isCentrosymmetricOf');
26
+ const tolerance = toleranceOf(options, 'operations');
27
+ checkCartesianOperations(operations, tolerance);
28
+ checkTimeReversal(operations);
29
+ const inversion: CartesianOperation = { cartesian: INVERSION, timeReversal: false };
30
+ return closedGroup(operations, tolerance).some((op) => sameWithin(op, inversion, tolerance));
33
31
  }
34
32
 
35
33
  /**
36
- * True if the group generated by `operations` is chiral: proper rotations only, with or without
37
- * time reversal (products of proper rotations are proper, so the list need not be closed). For a
38
- * point group given by its key, read `pointGroup(key).chiral`. Throws a RangeError for a matrix that
39
- * is not orthogonal and for an operation that does not say whether it is combined with time
40
- * reversal.
34
+ * True if the group generated by `operations` is enantiomorphic: proper rotations only, with or
35
+ * without time reversal (ITA § 3.2.2.1.3; products of proper rotations are proper, so the list need
36
+ * not be closed). For a point group given by its key, read `pointGroup(key).enantiomorphic`. Throws
37
+ * a RangeError for an operation without an orthogonal Cartesian matrix (`cartesian`; within the
38
+ * tolerance) and for an operation that does not say whether it is combined with time reversal.
41
39
  */
42
- export function isChiralOf(operations: readonly Operation[]): boolean {
43
- check(operations);
44
- return operations.every((op) => det(op.matrix) > 0);
40
+ export function isEnantiomorphicOf(operations: readonly CartesianOperation[], options?: ToleranceOptions): boolean {
41
+ checkOptions(options, TOLERANCE_KEYS, 'isEnantiomorphicOf');
42
+ checkCartesianOperations(operations, toleranceOf(options, 'operations'));
43
+ checkTimeReversal(operations);
44
+ return operations.every((op) => det(op.cartesian) > 0);
45
45
  }
46
46
 
47
- const HOLOHEDRY: Readonly<Record<CrystalSystem, PointGroupKey>> = Object.freeze({
47
+ const HOLOHEDRY: Readonly<Record<LatticeSystem, PointGroupKey>> = Object.freeze({
48
48
  triclinic: '-1',
49
49
  monoclinic: '2/m',
50
50
  orthorhombic: 'mmm',
51
51
  tetragonal: '4/mmm',
52
- trigonal: '-3m',
53
52
  hexagonal: '6/mmm',
53
+ rhombohedral: '-3m',
54
54
  cubic: 'm-3m',
55
55
  });
56
56
 
57
57
  /**
58
- * The holohedry of a crystal system: the crystal class that is the point symmetry of a lattice of
59
- * the system (ITA Table 2.1.1.1, the Laue groups in full boxes). For the trigonal system it is
60
- * `-3m`, the symmetry of the rhombohedral lattice. The trigonal classes also occur with the
61
- * hexagonal lattice, whose symmetry is `6/mmm`: the holohedry of the crystal family is
62
- * `holohedry(crystalFamily(system))`, which is what the lattice basis of this library
63
- * (`latticeBasis`, hexagonal axes for both systems) has.
58
+ * The holohedry of a lattice system, the point symmetry of its lattices (ITA Table 1.3.4.1, p. 39),
59
+ * e.g. `6/mmm` for the hexagonal and `-3m` for the rhombohedral lattice system. A trigonal crystal belongs to
60
+ * either lattice system, so `latticeSystems(key)` gives two for a trigonal class. Throws a RangeError
61
+ * for anything that is not one of the seven lattice systems, a crystal system `'trigonal'` included.
64
62
  */
65
- export function holohedry(system: CrystalSystem): PointGroupKey {
66
- if (!Object.hasOwn(HOLOHEDRY, system)) throw new RangeError(`Unknown crystal system: ${JSON.stringify(system)}`);
67
- return HOLOHEDRY[system];
63
+ export function holohedry(latticeSystem: LatticeSystem): PointGroupKey {
64
+ if (!Object.hasOwn(HOLOHEDRY, latticeSystem)) {
65
+ const hint =
66
+ latticeSystem === ('trigonal' as unknown)
67
+ ? "; a trigonal crystal has the lattice system 'hexagonal' or 'rhombohedral' (latticeSystems)"
68
+ : '';
69
+ throw new RangeError(`Unknown lattice system: ${shown(latticeSystem)}${hint}`);
70
+ }
71
+ return HOLOHEDRY[latticeSystem];
68
72
  }
@@ -0,0 +1,147 @@
1
+ /**
2
+ * The linear parts of ITA's Seitz symbols for the point operations (ITA 6th ed. 2016, § 1.4.2.2,
3
+ * Tables 1.4.2.1–1.4.2.3, p. 52; transcribed in references/itc/vol-a-2016-tables-1.4.2-seitz.md):
4
+ * for each matrix W, as its coordinate triplet, the characteristic direction of its Seitz symbol
5
+ * (the axis of a rotation or rotoinversion, the normal of a reflection) and the sense of a rotation
6
+ * of order 3 or more. The axis of an operation in `describeOperations` takes this direction, with
7
+ * its sign ("Pure ITC", #114; docs/conventions.md, "Symmetry directions and elements"). Table
8
+ * 1.4.2.1 serves the cubic, tetragonal, orthorhombic, monoclinic and triclinic systems, 1.4.2.2 the
9
+ * hexagonal family in hexagonal axes, 1.4.2.3 rhombohedral axes.
10
+ */
11
+
12
+ import { parseOperation } from '../spaceGroups/affine.js';
13
+ import type { IntMat3 } from './itaOrder.js';
14
+
15
+ /** A coordinate triplet, the direction [uvw] of its Seitz symbol (none for 1 and -1), its sense (n ≥ 3). */
16
+ type SeitzRow = readonly [string, readonly [number, number, number] | null, '+' | '-' | null];
17
+
18
+ /** ITA Table 1.4.2.1. No. 32 read with the overbar the type gives it (erratum in the transcription). */
19
+ const SEITZ_TABLE_1_4_2_1: readonly SeitzRow[] = [
20
+ ['x,y,z', null, null], // 1: 1
21
+ ['-x,-y,z', [0, 0, 1], null], // 2: 2_{001}
22
+ ['-x,y,-z', [0, 1, 0], null], // 3: 2_{010}
23
+ ['x,-y,-z', [1, 0, 0], null], // 4: 2_{100}
24
+ ['z,x,y', [1, 1, 1], '+'], // 5: 3^+_{111}
25
+ ['z,-x,-y', [-1, 1, -1], '+'], // 6: 3^+_{-11-1}
26
+ ['-z,-x,y', [1, -1, -1], '+'], // 7: 3^+_{1-1-1}
27
+ ['-z,x,-y', [-1, -1, 1], '+'], // 8: 3^+_{-1-11}
28
+ ['y,z,x', [1, 1, 1], '-'], // 9: 3^-_{111}
29
+ ['-y,z,-x', [1, -1, -1], '-'], // 10: 3^-_{1-1-1}
30
+ ['y,-z,-x', [-1, -1, 1], '-'], // 11: 3^-_{-1-11}
31
+ ['-y,-z,x', [-1, 1, -1], '-'], // 12: 3^-_{-11-1}
32
+ ['y,x,-z', [1, 1, 0], null], // 13: 2_{110}
33
+ ['-y,-x,-z', [1, -1, 0], null], // 14: 2_{1-10}
34
+ ['y,-x,z', [0, 0, 1], '-'], // 15: 4^-_{001}
35
+ ['-y,x,z', [0, 0, 1], '+'], // 16: 4^+_{001}
36
+ ['x,z,-y', [1, 0, 0], '-'], // 17: 4^-_{100}
37
+ ['-x,z,y', [0, 1, 1], null], // 18: 2_{011}
38
+ ['-x,-z,-y', [0, 1, -1], null], // 19: 2_{01-1}
39
+ ['x,-z,y', [1, 0, 0], '+'], // 20: 4^+_{100}
40
+ ['z,y,-x', [0, 1, 0], '+'], // 21: 4^+_{010}
41
+ ['z,-y,x', [1, 0, 1], null], // 22: 2_{101}
42
+ ['-z,y,x', [0, 1, 0], '-'], // 23: 4^-_{010}
43
+ ['-z,-y,-x', [-1, 0, 1], null], // 24: 2_{-101}
44
+ ['-x,-y,-z', null, null], // 25: -1
45
+ ['x,y,-z', [0, 0, 1], null], // 26: m_{001}
46
+ ['x,-y,z', [0, 1, 0], null], // 27: m_{010}
47
+ ['-x,y,z', [1, 0, 0], null], // 28: m_{100}
48
+ ['-z,-x,-y', [1, 1, 1], '+'], // 29: -3^+_{111}
49
+ ['-z,x,y', [-1, 1, -1], '+'], // 30: -3^+_{-11-1}
50
+ ['z,x,-y', [1, -1, -1], '+'], // 31: -3^+_{1-1-1}
51
+ ['z,-x,y', [-1, -1, 1], '+'], // 32: -3^+_{-1-11}
52
+ ['-y,-z,-x', [1, 1, 1], '-'], // 33: -3^-_{111}
53
+ ['y,-z,x', [1, -1, -1], '-'], // 34: -3^-_{1-1-1}
54
+ ['-y,z,x', [-1, -1, 1], '-'], // 35: -3^-_{-1-11}
55
+ ['y,z,-x', [-1, 1, -1], '-'], // 36: -3^-_{-11-1}
56
+ ['-y,-x,z', [1, 1, 0], null], // 37: m_{110}
57
+ ['y,x,z', [1, -1, 0], null], // 38: m_{1-10}
58
+ ['-y,x,-z', [0, 0, 1], '-'], // 39: -4^-_{001}
59
+ ['y,-x,-z', [0, 0, 1], '+'], // 40: -4^+_{001}
60
+ ['-x,-z,y', [1, 0, 0], '-'], // 41: -4^-_{100}
61
+ ['x,-z,-y', [0, 1, 1], null], // 42: m_{011}
62
+ ['x,z,y', [0, 1, -1], null], // 43: m_{01-1}
63
+ ['-x,z,-y', [1, 0, 0], '+'], // 44: -4^+_{100}
64
+ ['-z,-y,x', [0, 1, 0], '+'], // 45: -4^+_{010}
65
+ ['-z,y,-x', [1, 0, 1], null], // 46: m_{101}
66
+ ['z,-y,-x', [0, 1, 0], '-'], // 47: -4^-_{010}
67
+ ['z,y,x', [-1, 0, 1], null], // 48: m_{-101}
68
+ ];
69
+
70
+ /** ITA Table 1.4.2.2. */
71
+ const SEITZ_TABLE_1_4_2_2: readonly SeitzRow[] = [
72
+ ['x,y,z', null, null], // 1: 1
73
+ ['-y,x-y,z', [0, 0, 1], '+'], // 2: 3^+_{001}
74
+ ['-x+y,-x,z', [0, 0, 1], '-'], // 3: 3^-_{001}
75
+ ['-x,-y,z', [0, 0, 1], null], // 4: 2_{001}
76
+ ['y,-x+y,z', [0, 0, 1], '-'], // 5: 6^-_{001}
77
+ ['x-y,x,z', [0, 0, 1], '+'], // 6: 6^+_{001}
78
+ ['y,x,-z', [1, 1, 0], null], // 7: 2_{110}
79
+ ['x-y,-y,-z', [1, 0, 0], null], // 8: 2_{100}
80
+ ['-x,-x+y,-z', [0, 1, 0], null], // 9: 2_{010}
81
+ ['-y,-x,-z', [1, -1, 0], null], // 10: 2_{1-10}
82
+ ['-x+y,y,-z', [1, 2, 0], null], // 11: 2_{120}
83
+ ['x,x-y,-z', [2, 1, 0], null], // 12: 2_{210}
84
+ ['-x,-y,-z', null, null], // 13: -1
85
+ ['y,-x+y,-z', [0, 0, 1], '+'], // 14: -3^+_{001}
86
+ ['x-y,x,-z', [0, 0, 1], '-'], // 15: -3^-_{001}
87
+ ['x,y,-z', [0, 0, 1], null], // 16: m_{001}
88
+ ['-y,x-y,-z', [0, 0, 1], '-'], // 17: -6^-_{001}
89
+ ['-x+y,-x,-z', [0, 0, 1], '+'], // 18: -6^+_{001}
90
+ ['-y,-x,z', [1, 1, 0], null], // 19: m_{110}
91
+ ['-x+y,y,z', [1, 0, 0], null], // 20: m_{100}
92
+ ['x,x-y,z', [0, 1, 0], null], // 21: m_{010}
93
+ ['y,x,z', [1, -1, 0], null], // 22: m_{1-10}
94
+ ['x-y,-y,z', [1, 2, 0], null], // 23: m_{120}
95
+ ['-x,-x+y,z', [2, 1, 0], null], // 24: m_{210}
96
+ ];
97
+
98
+ /** ITA Table 1.4.2.3. */
99
+ const SEITZ_TABLE_1_4_2_3: readonly SeitzRow[] = [
100
+ ['x,y,z', null, null], // 1: 1
101
+ ['z,x,y', [1, 1, 1], '+'], // 2: 3^+_{111}
102
+ ['y,z,x', [1, 1, 1], '-'], // 3: 3^-_{111}
103
+ ['-z,-y,-x', [-1, 0, 1], null], // 4: 2_{-101}
104
+ ['-y,-x,-z', [1, -1, 0], null], // 5: 2_{1-10}
105
+ ['-x,-z,-y', [0, 1, -1], null], // 6: 2_{01-1}
106
+ ['-x,-y,-z', null, null], // 7: -1
107
+ ['-z,-x,-y', [1, 1, 1], '+'], // 8: -3^+_{111}
108
+ ['-y,-z,-x', [1, 1, 1], '-'], // 9: -3^-_{111}
109
+ ['z,y,x', [-1, 0, 1], null], // 10: m_{-101}
110
+ ['y,x,z', [1, -1, 0], null], // 11: m_{1-10}
111
+ ['x,z,y', [0, 1, -1], null], // 12: m_{01-1}
112
+ ];
113
+
114
+ /** The tables by the axes of the setting. */
115
+ export type SeitzTable = 'cubic' | 'hexagonal' | 'rhombohedral';
116
+
117
+ const TABLES: Readonly<Record<SeitzTable, readonly SeitzRow[]>> = {
118
+ cubic: SEITZ_TABLE_1_4_2_1,
119
+ hexagonal: SEITZ_TABLE_1_4_2_2,
120
+ rhombohedral: SEITZ_TABLE_1_4_2_3,
121
+ };
122
+
123
+ const parsed = new Map<SeitzTable, readonly { w: IntMat3; axis: SeitzRow[1]; sense: SeitzRow[2] }[]>();
124
+
125
+ /**
126
+ * The Seitz direction and sense of the matrix W in a table, or undefined if the table has no such W.
127
+ */
128
+ export function seitzOf(
129
+ table: SeitzTable,
130
+ w: IntMat3,
131
+ ): { readonly axis: SeitzRow[1]; readonly sense: SeitzRow[2] } | undefined {
132
+ let rows = parsed.get(table);
133
+ if (!rows) {
134
+ rows = TABLES[table].map(([t, axis, sense]) => ({
135
+ w: parseOperation(t).matrix as unknown as IntMat3,
136
+ axis,
137
+ sense,
138
+ }));
139
+ parsed.set(table, rows);
140
+ }
141
+ return rows.find((r) => r.w.every((row, i) => row.every((v, j) => v === w[i][j])));
142
+ }
143
+
144
+ /** The rows of a table, for the tests. */
145
+ export function seitzRows(table: SeitzTable): readonly SeitzRow[] {
146
+ return TABLES[table];
147
+ }
@@ -1,21 +1,26 @@
1
1
  /**
2
- * Wyckoff positions of the crystal classes for directions (face normals), in the ITC convention:
3
- * ITA's letters, multiplicities and oriented site-symmetry symbols, a representative face, and the
2
+ * Wyckoff positions of the crystal classes for directions (face normals), as ITA gives them:
3
+ * ITA's letters, multiplicities, oriented site-symmetry symbols, coordinates and faces as printed, and the
4
4
  * Wyckoff position of any direction (docs/conventions.md, "Site symmetry and Wyckoff positions").
5
5
  */
6
6
 
7
+ import { checkOptions, pick, SETTING_KEYS, shown, TOLERANCE_KEYS } from '../checks.js';
7
8
  import { apply, inverse, transpose, type Mat3, type Vec3 } from '../linalg.js';
8
- import { crystalFamily, latticeBasis } from '../lattice.js';
9
- import { POINT_GROUP_DATA } from './data.js';
9
+ import { crystalFamily } from '../lattice.js';
10
+ import { substituteMillerIndices } from '../indices.js';
11
+ import { itcBasis, itcClass, itcSetting as itcClassSetting } from './itcData.js';
10
12
  import {
13
+ settingIndexOf,
11
14
  isMagneticPointGroupKey,
12
15
  isPointGroupKey,
13
16
  operations,
14
17
  settings,
18
+ type MagneticPointGroupKey,
15
19
  type PointGroupKey,
16
20
  type SettingOptions,
17
21
  } from './pointGroups.js';
18
- import { siteSymmetry, siteTolerance, type SiteSymmetryOptions } from '../siteSymmetry.js';
22
+ import { siteSymmetryOf, siteTolerance, type SiteSymmetry } from '../siteSymmetry.js';
23
+ import type { ToleranceOptions } from '../tolerances.js';
19
24
  import { ITA_WYCKOFF, type WyckoffRow } from './wyckoffData.js';
20
25
 
21
26
  /** A face (hkl): three Miller indices in the conventional basis (for hexagonal axes without i = −(h + k)). */
@@ -29,50 +34,45 @@ export interface WyckoffPosition {
29
34
  readonly multiplicity: number;
30
35
  /** Oriented site-symmetry symbol as ITA prints it, e.g. `..m`, `4m.m`, `1`. */
31
36
  readonly siteSymmetry: string;
32
- /** ITA's representative point as printed, e.g. `x,x,z` (a leading `-` is an overbar). */
33
- readonly coordinates: string;
37
+ /**
38
+ * ITA's coordinate triplets of the position as printed, in printed order, the first being the
39
+ * representative point, e.g. `['x,x,z', '-x,-x,z', …]` (a leading `-` is an overbar); one per
40
+ * equivalent direction, as in `symcrys/plane`.
41
+ */
42
+ readonly coordinates: readonly string[];
34
43
  /**
35
44
  * ITA's representative face as printed, components separated by commas, e.g. `h,h,l`, or
36
- * `h,h,-2h,l` (Bravais–Miller indices) for hexagonal axes.
45
+ * `h,h,-2h,l` (Bravais–Miller indices) for hexagonal axes. `millerIndices(printed, { h, k, l })` gives
46
+ * a face with numbers, `faceNormal(basis, hkl)` its normal in a cell.
37
47
  */
38
48
  readonly millerIndices: string;
39
- /** A representative face with numbers: `millerIndices` with h = 3, k = 2, l = 1. */
40
- readonly representative: {
41
- /** The Miller indices (hkl) of the face. */
42
- readonly hkl: Hkl;
43
- /**
44
- * Its face normal, a Cartesian unit vector. Monoclinic and triclinic: the normal for a, b, c along
45
- * x, y, z (no cell angles), exact for the unique axis only, but with the correct site symmetry.
46
- */
47
- readonly cartesian: Vec3;
48
- };
49
- /** Indices into `operations` (same setting, ITC convention) of the site symmetry of the representative. */
49
+ /**
50
+ * Indices into `operations` (same setting) of the site symmetry of the position: of the operations
51
+ * that fix its first printed face for values of h, k, l that keep the face in the position.
52
+ */
50
53
  readonly siteSymmetryOperations: readonly number[];
51
54
  }
52
55
 
53
- /** Convention and setting (`SettingOptions`) and the tolerance of `siteSymmetry` (`SiteSymmetryOptions`). */
54
- export type WyckoffOptions = SettingOptions & SiteSymmetryOptions;
55
-
56
56
  /** The values substituted into ITA's Miller indices for the numeric representative. */
57
57
  export const REPRESENTATIVE_VALUES: Readonly<Record<'h' | 'k' | 'l', number>> = { h: 3, k: 2, l: 1 };
58
58
 
59
- /** One printed index (`h`, `-2h`, `0`, `1`) as a number. */
60
- function index(component: string, values: Readonly<Record<'h' | 'k' | 'l', number>>): number {
61
- const m = /^(-?)(\d*)([hkil]?)$/.exec(component);
62
- if (!m || (m[2] === '' && m[3] === '')) throw new Error(`Unreadable Miller index: ${component}`);
63
- const sign = m[1] ? -1 : 1;
64
- const factor = m[2] === '' ? 1 : Number(m[2]);
65
- if (m[3] === '') return sign * factor;
66
- if (m[3] === 'i') return sign * factor * -(values.h + values.k);
67
- return sign * factor * values[m[3] as 'h' | 'k' | 'l'];
59
+ /**
60
+ * The values for rhombohedral axes: h = 5, k = 2, l = 1. With 3, 2, 1 the face (h,k,l) would lie on
61
+ * the limiting form (h,k,2k-h) that ITA prints there (Table 3.2.3.2, 32, 3m and -3m with rhombohedral
62
+ * axes, pp. 755–759): (321) is (116) in hexagonal axes. (521), (318) in hexagonal axes, lies on no
63
+ * printed limiting form, and every printed face with these values is in lowest terms ((5,2,-7),
64
+ * (5,2,-1), (5,5,1)); h = 4 would give (4,2,-6) and (4,2,0).
65
+ */
66
+ export const RHOMBOHEDRAL_VALUES: Readonly<Record<'h' | 'k' | 'l', number>> = { h: 5, k: 2, l: 1 };
67
+
68
+ /** The values of h, k, l for the representative faces of a setting. */
69
+ export function representativeValues(key: PointGroupKey, setting: number): Readonly<Record<'h' | 'k' | 'l', number>> {
70
+ return itcClassSetting(key, setting).axes === 'rhombohedral' ? RHOMBOHEDRAL_VALUES : REPRESENTATIVE_VALUES;
68
71
  }
69
72
 
70
73
  /** Printed Miller indices (three, or four for hexagonal axes) as three numbers, with the given values of h, k, l. */
71
74
  export function numericHkl(miller: string, values = REPRESENTATIVE_VALUES): Hkl {
72
- const parts = miller.split(',').map((c) => index(c, values));
73
- if (parts.length === 3) return [parts[0], parts[1], parts[2]];
74
- if (parts.length === 4 && parts[2] === -(parts[0] + parts[1])) return [parts[0], parts[1], parts[3]];
75
- throw new Error(`Unreadable Miller indices: ${miller}`);
75
+ return substituteMillerIndices(miller, values, (m) => new Error(m));
76
76
  }
77
77
 
78
78
  export const IDENTITY: Mat3 = [
@@ -121,45 +121,44 @@ function permuteSymbol(symbolText: string, r: Mat3): string {
121
121
  return [0, 1, 2].map((i) => symbolText[[0, 1, 2].find((k) => Math.abs(r[i][k]) === 1) ?? -1]).join('');
122
122
  }
123
123
 
124
- function isSignedPermutation(r: Mat3): boolean {
125
- return r.every(
126
- (row) => row.filter((v) => Math.abs(v) > 1e-9).length === 1 && row.some((v) => Math.abs(Math.abs(v) - 1) < 1e-9),
127
- );
128
- }
129
-
130
124
  /**
131
- * The signed permutation r that carries setting 1 of a class into `setting` (new axis i = r[i][j] ×
132
- * old axis j), for the settings ITA does not print (`mm2` settings 2 and 3). Throws if the frame of
133
- * the setting is not a permutation of that of setting 1.
125
+ * The permutation r that carries setting 1 of a class into `setting` (new axis i = r[i][j] × old
126
+ * axis j), for the settings ITA does not print (`mm2` settings 2 and 3, monoclinic unique axis a):
127
+ * the transpose of the change
128
+ * of basis P of the ITC class data ((a′, b′, c′) = (a, b, c)·P, itcData.ts). Coordinates (P⁻¹·x)
129
+ * and Miller indices (h·P) are carried by the same r only because P is a signed permutation
130
+ * (P⁻¹ = Pᵀ); throws for a setting that is not carried from setting 1 by one.
134
131
  */
135
132
  export function permutationFromSetting1(key: PointGroupKey, setting: number): Mat3 {
136
- const d = POINT_GROUP_DATA.find((x) => x.key === key);
137
- if (!d) throw new RangeError(`Unknown point group key: ${JSON.stringify(key)}`);
138
- const f1 = d.settings[0].frame;
139
- const fk = d.settings[setting - 1].frame;
140
- const raw = fk.map((row) => [0, 1, 2].map((j) => row[0] * f1[j][0] + row[1] * f1[j][1] + row[2] * f1[j][2]));
141
- const r = raw.map((row) => row.map((v) => Math.round(v))) as unknown as Mat3;
142
- if (
143
- !isSignedPermutation(raw as unknown as Mat3) ||
144
- !raw.every((row, i) => row.every((v, j) => Math.abs(v - r[i][j]) < 1e-9))
145
- ) {
146
- throw new Error(`Point group ${key}, setting ${setting}: frame is not a permutation of setting 1`);
147
- }
148
- return r;
133
+ const from = itcClassSetting(key, setting).from;
134
+ if (from?.index !== 1) throw new Error(`Point group ${key}, setting ${setting}: not carried from setting 1`);
135
+ const p = from.basis;
136
+ const signedPermutation = [0, 1, 2].every(
137
+ (i) =>
138
+ p[i].filter((v) => v !== 0).length === 1 &&
139
+ p[i].every((v) => v === 0 || Math.abs(v) === 1) &&
140
+ p.filter((row) => row[i] !== 0).length === 1,
141
+ );
142
+ if (!signedPermutation)
143
+ throw new Error(`Point group ${key}, setting ${setting}: not a signed permutation of setting 1`);
144
+ return [0, 1, 2].map((i) => [0, 1, 2].map((j) => p[j][i])) as unknown as Mat3;
149
145
  }
150
146
 
151
147
  /**
152
148
  * The entry of a table printed per setting (Wyckoff positions, face forms) for a setting of a class:
153
- * the one with the ITC short symbol (and unique axis) of the setting, or undefined if ITA does not
149
+ * the one with the ITC short symbol (and unique axis or axes) of the setting, or undefined if ITA does not
154
150
  * print the setting.
155
151
  */
156
- export function printedEntry<E extends { readonly symbol: string; readonly uniqueAxis?: 'b' | 'c' }>(
157
- table: readonly E[],
158
- key: PointGroupKey,
159
- setting: number,
160
- ): E | undefined {
161
- const s = settings(key, 'itc')[setting - 1];
162
- return table.find((e) => e.symbol === s.symbol && (e.uniqueAxis === undefined || e.uniqueAxis === s.uniqueAxis));
152
+ export function printedEntry<
153
+ E extends { readonly symbol: string; readonly uniqueAxis?: 'b' | 'c'; readonly axes?: 'rhombohedral' },
154
+ >(table: readonly E[], key: PointGroupKey, setting: number): E | undefined {
155
+ const s = settings(key)[setting - 1];
156
+ return table.find(
157
+ (e) =>
158
+ e.symbol === s.symbol &&
159
+ (e.uniqueAxis === undefined || e.uniqueAxis === s.uniqueAxis) &&
160
+ (e.axes === 'rhombohedral') === (s.axes === 'rhombohedral'),
161
+ );
163
162
  }
164
163
 
165
164
  /** The printed rows of a setting; for a setting ITA does not print, those of setting 1 carried into its frame. */
@@ -168,69 +167,80 @@ function printedRows(key: PointGroupKey, setting: number): readonly WyckoffRow[]
168
167
  if (entry) return entry.rows;
169
168
  if (setting === 1) throw new Error(`Point group ${key}: no printed Wyckoff positions for setting 1`);
170
169
  const r = permutationFromSetting1(key, setting);
170
+ // A monoclinic site symmetry (`2`, `m`, `2/m`) names the element on the unique axis, not a position.
171
+ const oriented = crystalFamily(itcClass(key).crystalSystem) !== 'monoclinic';
171
172
  return printedRows(key, 1).map(([letter, mult, site, coords, miller]) => [
172
173
  letter,
173
174
  mult,
174
- permuteSymbol(site, r),
175
- permutePattern(coords, r, XYZ),
175
+ oriented ? permuteSymbol(site, r) : site,
176
+ coords.map((c) => permutePattern(c, r, XYZ)),
176
177
  miller === '' ? '' : permutePattern(miller, r, HKL),
177
178
  ]);
178
179
  }
179
180
 
180
181
  /**
181
- * The lattice basis in which the Cartesian normals of the representatives are computed; monoclinic
182
- * and triclinic: a, b, c along x, y, z (docs/conventions.md, "Site symmetry and Wyckoff positions").
182
+ * The lattice basis in which the Cartesian normals of the representatives are computed, that of the
183
+ * setting (itcData.ts, `itcBasis`): monoclinic and triclinic a, b, c along x, y, z; rhombohedral
184
+ * axes in the hexagonal cell of `latticeBasis` (docs/conventions.md, "Site symmetry and Wyckoff
185
+ * positions").
186
+ */
187
+ export function faceBasis(key: PointGroupKey, setting: number): Mat3 {
188
+ return itcBasis(key, setting);
189
+ }
190
+
191
+ /** h, k, l of a representative face under the printed condition |h| < |l| (cubic forms (hhl)). */
192
+ export const SMALL_H: Readonly<Record<'h' | 'k' | 'l', number>> = Object.freeze({ h: 1, k: 2, l: 3 });
193
+
194
+ /**
195
+ * A face of a position or form with numbers, internal (#137 G3: the API gives the printed indices
196
+ * only): h, k, l = 3, 2, 1 (rhombohedral axes: 5, 2, 1; 1, 2, 3 under the condition |h| < |l|), and
197
+ * its normal in the basis of the setting (`faceBasis`; monoclinic and triclinic a, b, c along x, y,
198
+ * z, which gives the correct site symmetry but not the pole of a real cell, #137 G4).
183
199
  */
184
- export function faceBasis(key: PointGroupKey): Mat3 {
185
- const d = POINT_GROUP_DATA.find((x) => x.key === key);
186
- if (!d) throw new RangeError(`Unknown point group key: ${JSON.stringify(key)}`);
187
- const family = crystalFamily(d.crystalSystem);
188
- return family === 'monoclinic' || family === 'triclinic' ? IDENTITY : latticeBasis(family);
200
+ export function representativeFace(
201
+ key: PointGroupKey,
202
+ setting: number,
203
+ miller: string,
204
+ condition?: string,
205
+ ): { readonly hkl: Hkl; readonly cartesian: Vec3 } {
206
+ const hkl = numericHkl(miller, condition === '|h|<|l|' ? SMALL_H : representativeValues(key, setting));
207
+ return { hkl, cartesian: normal(faceBasis(key, setting), hkl) };
189
208
  }
190
209
 
191
210
  const cache = new Map<string, readonly WyckoffPosition[]>();
192
211
 
193
212
  /**
194
- * The setting index for a table that exists for the crystal classes in the ITC convention only
195
- * (`what`: 'Wyckoff positions', 'Crystal forms'); throws a RangeError for a magnetic point group
196
- * with time reversal and for another convention.
213
+ * The setting index for a table that exists for the crystal classes only (`what`: 'Wyckoff
214
+ * positions', 'Crystal forms'); throws a RangeError for a magnetic point group with time reversal.
197
215
  */
198
- export function itcSetting(key: PointGroupKey, options?: SettingOptions, what = 'Wyckoff positions'): number {
216
+ export function tableSetting(key: PointGroupKey, options?: SettingOptions, what = 'Wyckoff positions'): number {
199
217
  if (isMagneticPointGroupKey(key) && !isPointGroupKey(key)) {
200
- throw new RangeError(
201
- `${what} are given for the 32 crystal classes only; ${JSON.stringify(key)} is a magnetic point group`,
202
- );
203
- }
204
- if ((options?.convention ?? 'itc') !== 'itc') {
205
- throw new RangeError(`${what} exist in the ITC convention only (convention 'itc')`);
218
+ throw new RangeError(`${what} are given for the 32 crystal classes only; ${shown(key)} is a magnetic point group`);
206
219
  }
207
- const list = settings(key, 'itc');
208
- const index = options?.setting ?? list.find((s) => s.isDefault)?.index ?? 1;
209
- operations(key, { convention: 'itc', setting: index }); // validates the setting index
220
+ const index = settingIndexOf(key, options);
221
+ operations(key, pick(options, SETTING_KEYS)); // validates the setting index
210
222
  return index;
211
223
  }
212
224
 
213
225
  /**
214
226
  * The Wyckoff positions of a point group for directions, in ITA's printed order (general position
215
- * first), for the 32 crystal classes and in the ITC convention only (throws a RangeError for a
216
- * magnetic point group with time reversal and for `'birss'`). The point at the origin
217
- * (letter o) is not a direction and is left out. For `mm2` settings 2 and 3 (`2mm`, `m2m`), which
218
- * ITA does not print, the positions of setting 1 carried into their frame.
227
+ * first), for the 32 crystal classes only (throws a RangeError for a magnetic point group with
228
+ * time reversal). The point at the origin
229
+ * (letter o) is not a direction and is left out. For the settings ITA does not print (`mm2` settings 2 and 3, monoclinic unique axis a), the positions
230
+ * of setting 1 carried into their frame.
219
231
  */
220
232
  export function wyckoffPositions(key: PointGroupKey, options?: SettingOptions): readonly WyckoffPosition[] {
221
- const setting = itcSetting(key, options);
233
+ checkOptions(options, SETTING_KEYS, 'wyckoffPositions');
234
+ const setting = tableSetting(key, options);
222
235
  const cacheKey = `${key}#${setting}`;
223
236
  let result = cache.get(cacheKey);
224
237
  if (!result) {
225
- const ops = operations(key, { convention: 'itc', setting });
226
- const basis = faceBasis(key);
238
+ const ops = operations(key, { setting });
227
239
  result = Object.freeze(
228
240
  printedRows(key, setting)
229
241
  .filter(([letter]) => letter !== 'o')
230
242
  .map(([letter, multiplicity, site, coordinates, millerIndices]) => {
231
- const hkl = numericHkl(millerIndices);
232
- const cartesian = normal(basis, hkl);
233
- const stab = siteSymmetry(ops, cartesian);
243
+ const stab = siteSymmetryOf(ops, representativeFace(key, setting, millerIndices).cartesian);
234
244
  if (stab.multiplicity !== multiplicity) {
235
245
  throw new Error(
236
246
  `Point group ${key}, setting ${setting}, position ${letter}: multiplicity differs from print`,
@@ -240,12 +250,8 @@ export function wyckoffPositions(key: PointGroupKey, options?: SettingOptions):
240
250
  letter,
241
251
  multiplicity,
242
252
  siteSymmetry: site,
243
- coordinates,
253
+ coordinates: Object.freeze([...coordinates]),
244
254
  millerIndices,
245
- representative: Object.freeze({
246
- hkl: Object.freeze(hkl) as Hkl,
247
- cartesian: Object.freeze(cartesian) as Vec3,
248
- }),
249
255
  siteSymmetryOperations: stab.operations,
250
256
  });
251
257
  }),
@@ -255,27 +261,46 @@ export function wyckoffPositions(key: PointGroupKey, options?: SettingOptions):
255
261
  return result;
256
262
  }
257
263
 
264
+ /**
265
+ * The site symmetry of a direction (any non-zero Cartesian vector) under a point group in a
266
+ * setting: `siteSymmetryOf` applied to `operations(key, options)`, so the indices refer to those
267
+ * operations (#137 C1). Time reversal is ignored. Throws a RangeError as `siteSymmetryOf` does.
268
+ */
269
+ export function siteSymmetry(
270
+ key: MagneticPointGroupKey,
271
+ direction: Vec3,
272
+ options?: SettingOptions & ToleranceOptions,
273
+ ): SiteSymmetry {
274
+ checkOptions(options, [...SETTING_KEYS, ...TOLERANCE_KEYS], 'siteSymmetry');
275
+ return siteSymmetryOf(operations(key, pick(options, SETTING_KEYS)), direction, pick(options, TOLERANCE_KEYS));
276
+ }
277
+
258
278
  const sortedKey = (list: readonly number[]): string => [...list].sort((a, b) => a - b).join(',');
259
279
 
260
280
  /**
261
- * The Wyckoff position of a direction (any non-zero Cartesian vector) in a point group, ITC
262
- * convention only: the position whose representative has a site symmetry conjugate to that of the
263
- * direction (ITA's definition). `tolerance` as for `siteSymmetry`; throws a RangeError if the
281
+ * The Wyckoff position of a direction (any non-zero Cartesian vector) in a crystal class: the
282
+ * position whose printed face has a site symmetry conjugate to that of the
283
+ * direction (ITA's definition). `tolerance` as for `siteSymmetryOf`; throws a RangeError if the
264
284
  * operations found within it do not match any position (a tolerance too large).
265
285
  */
266
- export function wyckoffPositionOf(key: PointGroupKey, direction: Vec3, options?: WyckoffOptions): WyckoffPosition {
286
+ export function wyckoffPosition(
287
+ key: PointGroupKey,
288
+ direction: Vec3,
289
+ options?: SettingOptions & ToleranceOptions,
290
+ ): WyckoffPosition {
291
+ checkOptions(options, [...SETTING_KEYS, ...TOLERANCE_KEYS], 'wyckoffPosition');
267
292
  const tolerance = siteTolerance(options);
268
- const setting = itcSetting(key, options);
269
- const ops = operations(key, { convention: 'itc', setting });
270
- const rows = wyckoffPositions(key, { convention: 'itc', setting });
271
- const site = siteSymmetry(ops, direction, { tolerance });
293
+ const setting = tableSetting(key, options);
294
+ const ops = operations(key, { setting });
295
+ const rows = wyckoffPositions(key, { setting });
296
+ const site = siteSymmetryOf(ops, direction, { tolerance });
272
297
  const candidates = rows.filter((r) => r.siteSymmetryOperations.length === site.operations.length);
273
298
  for (const g of ops) {
274
- const k = sortedKey(siteSymmetry(ops, apply(g.matrix, site.direction), { tolerance }).operations);
299
+ const k = sortedKey(siteSymmetryOf(ops, apply(g.cartesian, site.direction), { tolerance }).operations);
275
300
  const row = candidates.find((r) => sortedKey(r.siteSymmetryOperations) === k);
276
301
  if (row) return row;
277
302
  }
278
303
  throw new RangeError(
279
- `Point group ${key}, setting ${setting}: no Wyckoff position for ${JSON.stringify(direction)} (tolerance too large?)`,
304
+ `Point group ${key}, setting ${setting}: no Wyckoff position for ${shown(direction)} (tolerance too large?)`,
280
305
  );
281
306
  }