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.
Files changed (248) 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/coordinates.d.ts +143 -0
  15. package/dist/coordinates.d.ts.map +1 -0
  16. package/dist/coordinates.js +198 -0
  17. package/dist/coordinates.js.map +1 -0
  18. package/dist/crystalClasses.d.ts +170 -117
  19. package/dist/crystalClasses.d.ts.map +1 -1
  20. package/dist/crystalClasses.js +190 -121
  21. package/dist/crystalClasses.js.map +1 -1
  22. package/dist/freeze.d.ts +7 -0
  23. package/dist/freeze.d.ts.map +1 -0
  24. package/dist/freeze.js +15 -0
  25. package/dist/freeze.js.map +1 -0
  26. package/dist/index.d.ts +13 -10
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +5 -3
  29. package/dist/index.js.map +1 -1
  30. package/dist/indices.d.ts +30 -20
  31. package/dist/indices.d.ts.map +1 -1
  32. package/dist/indices.js +101 -31
  33. package/dist/indices.js.map +1 -1
  34. package/dist/lattice.d.ts +15 -1
  35. package/dist/lattice.d.ts.map +1 -1
  36. package/dist/lattice.js +30 -1
  37. package/dist/lattice.js.map +1 -1
  38. package/dist/linalg.d.ts +2 -2
  39. package/dist/linalg.d.ts.map +1 -1
  40. package/dist/linalg.js +3 -3
  41. package/dist/linalg.js.map +1 -1
  42. package/dist/magnetic.d.ts +14 -10
  43. package/dist/magnetic.d.ts.map +1 -1
  44. package/dist/magnetic.js +10 -6
  45. package/dist/magnetic.js.map +1 -1
  46. package/dist/notation.d.ts +16 -0
  47. package/dist/notation.d.ts.map +1 -0
  48. package/dist/notation.js +66 -0
  49. package/dist/notation.js.map +1 -0
  50. package/dist/operations.d.ts +40 -26
  51. package/dist/operations.d.ts.map +1 -1
  52. package/dist/operations.js +48 -60
  53. package/dist/operations.js.map +1 -1
  54. package/dist/plane.d.ts +297 -80
  55. package/dist/plane.d.ts.map +1 -1
  56. package/dist/plane.js +289 -94
  57. package/dist/plane.js.map +1 -1
  58. package/dist/pointGroups/crystalForms.d.ts +6 -21
  59. package/dist/pointGroups/crystalForms.d.ts.map +1 -1
  60. package/dist/pointGroups/crystalForms.js +9 -16
  61. package/dist/pointGroups/crystalForms.js.map +1 -1
  62. package/dist/pointGroups/crystalFormsData.d.ts +4 -1
  63. package/dist/pointGroups/crystalFormsData.d.ts.map +1 -1
  64. package/dist/pointGroups/crystalFormsData.js +64 -1
  65. package/dist/pointGroups/crystalFormsData.js.map +1 -1
  66. package/dist/pointGroups/elements.d.ts +19 -17
  67. package/dist/pointGroups/elements.d.ts.map +1 -1
  68. package/dist/pointGroups/elements.js +65 -83
  69. package/dist/pointGroups/elements.js.map +1 -1
  70. package/dist/pointGroups/identify.d.ts +10 -18
  71. package/dist/pointGroups/identify.d.ts.map +1 -1
  72. package/dist/pointGroups/identify.js +27 -79
  73. package/dist/pointGroups/identify.js.map +1 -1
  74. package/dist/pointGroups/itaOrder.d.ts +15 -14
  75. package/dist/pointGroups/itaOrder.d.ts.map +1 -1
  76. package/dist/pointGroups/itaOrder.js +116 -94
  77. package/dist/pointGroups/itaOrder.js.map +1 -1
  78. package/dist/pointGroups/itcData.d.ts +96 -0
  79. package/dist/pointGroups/itcData.d.ts.map +1 -0
  80. package/dist/pointGroups/itcData.js +336 -0
  81. package/dist/pointGroups/itcData.js.map +1 -0
  82. package/dist/pointGroups/itcMagneticData.d.ts +55 -0
  83. package/dist/pointGroups/itcMagneticData.d.ts.map +1 -0
  84. package/dist/pointGroups/itcMagneticData.js +172 -0
  85. package/dist/pointGroups/itcMagneticData.js.map +1 -0
  86. package/dist/pointGroups/keys.d.ts +32 -0
  87. package/dist/pointGroups/keys.d.ts.map +1 -0
  88. package/dist/pointGroups/keys.js +120 -0
  89. package/dist/pointGroups/keys.js.map +1 -0
  90. package/dist/pointGroups/magneticSymbols.d.ts +6 -5
  91. package/dist/pointGroups/magneticSymbols.d.ts.map +1 -1
  92. package/dist/pointGroups/magneticSymbols.js +15 -12
  93. package/dist/pointGroups/magneticSymbols.js.map +1 -1
  94. package/dist/pointGroups/orbits.d.ts +23 -42
  95. package/dist/pointGroups/orbits.d.ts.map +1 -1
  96. package/dist/pointGroups/orbits.js +20 -62
  97. package/dist/pointGroups/orbits.js.map +1 -1
  98. package/dist/pointGroups/pointGroups.d.ts +145 -68
  99. package/dist/pointGroups/pointGroups.d.ts.map +1 -1
  100. package/dist/pointGroups/pointGroups.js +455 -243
  101. package/dist/pointGroups/pointGroups.js.map +1 -1
  102. package/dist/pointGroups/properties.d.ts +21 -22
  103. package/dist/pointGroups/properties.d.ts.map +1 -1
  104. package/dist/pointGroups/properties.js +40 -37
  105. package/dist/pointGroups/properties.js.map +1 -1
  106. package/dist/pointGroups/seitzData.d.ts +26 -0
  107. package/dist/pointGroups/seitzData.d.ts.map +1 -0
  108. package/dist/pointGroups/seitzData.js +130 -0
  109. package/dist/pointGroups/seitzData.js.map +1 -0
  110. package/dist/pointGroups/shubnikovData.d.ts +11 -0
  111. package/dist/pointGroups/shubnikovData.d.ts.map +1 -0
  112. package/dist/pointGroups/shubnikovData.js +101 -0
  113. package/dist/pointGroups/shubnikovData.js.map +1 -0
  114. package/dist/pointGroups/wyckoff.d.ts +70 -40
  115. package/dist/pointGroups/wyckoff.d.ts.map +1 -1
  116. package/dist/pointGroups/wyckoff.js +98 -91
  117. package/dist/pointGroups/wyckoff.js.map +1 -1
  118. package/dist/pointGroups/wyckoffData.d.ts +7 -4
  119. package/dist/pointGroups/wyckoffData.d.ts.map +1 -1
  120. package/dist/pointGroups/wyckoffData.js +789 -168
  121. package/dist/pointGroups/wyckoffData.js.map +1 -1
  122. package/dist/siteSymmetry.d.ts +8 -16
  123. package/dist/siteSymmetry.d.ts.map +1 -1
  124. package/dist/siteSymmetry.js +34 -24
  125. package/dist/siteSymmetry.js.map +1 -1
  126. package/dist/spaceGroups/affine.d.ts.map +1 -1
  127. package/dist/spaceGroups/affine.js +3 -2
  128. package/dist/spaceGroups/affine.js.map +1 -1
  129. package/dist/spaceGroups/cell.d.ts +43 -31
  130. package/dist/spaceGroups/cell.d.ts.map +1 -1
  131. package/dist/spaceGroups/cell.js +173 -85
  132. package/dist/spaceGroups/cell.js.map +1 -1
  133. package/dist/spaceGroups/describe.d.ts +13 -10
  134. package/dist/spaceGroups/describe.d.ts.map +1 -1
  135. package/dist/spaceGroups/describe.js +11 -10
  136. package/dist/spaceGroups/describe.js.map +1 -1
  137. package/dist/spaceGroups/planeGroupData.d.ts +3 -1
  138. package/dist/spaceGroups/planeGroupData.d.ts.map +1 -1
  139. package/dist/spaceGroups/planeGroupData.js +25 -8
  140. package/dist/spaceGroups/planeGroupData.js.map +1 -1
  141. package/dist/spaceGroups/planeGroups.d.ts.map +1 -1
  142. package/dist/spaceGroups/planeGroups.js +2 -1
  143. package/dist/spaceGroups/planeGroups.js.map +1 -1
  144. package/dist/spaceGroups/planeLattice.d.ts +78 -0
  145. package/dist/spaceGroups/planeLattice.d.ts.map +1 -0
  146. package/dist/spaceGroups/planeLattice.js +143 -0
  147. package/dist/spaceGroups/planeLattice.js.map +1 -0
  148. package/dist/spaceGroups/planePointGroups.d.ts +6 -2
  149. package/dist/spaceGroups/planePointGroups.d.ts.map +1 -1
  150. package/dist/spaceGroups/planePointGroups.js +14 -2
  151. package/dist/spaceGroups/planePointGroups.js.map +1 -1
  152. package/dist/spaceGroups/positions.d.ts +48 -19
  153. package/dist/spaceGroups/positions.d.ts.map +1 -1
  154. package/dist/spaceGroups/positions.js +166 -67
  155. package/dist/spaceGroups/positions.js.map +1 -1
  156. package/dist/spaceGroups/rational.d.ts +18 -0
  157. package/dist/spaceGroups/rational.d.ts.map +1 -1
  158. package/dist/spaceGroups/rational.js +58 -0
  159. package/dist/spaceGroups/rational.js.map +1 -1
  160. package/dist/tensors/propertyTable.d.ts +3 -1
  161. package/dist/tensors/propertyTable.d.ts.map +1 -1
  162. package/dist/tensors/propertyTable.js +17 -10
  163. package/dist/tensors/propertyTable.js.map +1 -1
  164. package/dist/tensors/rowEchelon.d.ts +3 -3
  165. package/dist/tensors/rowEchelon.d.ts.map +1 -1
  166. package/dist/tensors/rowEchelon.js +4 -4
  167. package/dist/tensors/rowEchelon.js.map +1 -1
  168. package/dist/tensors/tensorForm.d.ts +75 -34
  169. package/dist/tensors/tensorForm.d.ts.map +1 -1
  170. package/dist/tensors/tensorForm.js +171 -67
  171. package/dist/tensors/tensorForm.js.map +1 -1
  172. package/dist/tensors/tensorProperties.d.ts +10 -9
  173. package/dist/tensors/tensorProperties.d.ts.map +1 -1
  174. package/dist/tensors/tensorProperties.js +22 -12
  175. package/dist/tensors/tensorProperties.js.map +1 -1
  176. package/dist/tensors/voigt.d.ts +56 -0
  177. package/dist/tensors/voigt.d.ts.map +1 -0
  178. package/dist/tensors/voigt.js +188 -0
  179. package/dist/tensors/voigt.js.map +1 -0
  180. package/dist/tolerances.d.ts +56 -1
  181. package/dist/tolerances.d.ts.map +1 -1
  182. package/dist/tolerances.js +51 -1
  183. package/dist/tolerances.js.map +1 -1
  184. package/dist/version.d.ts +1 -1
  185. package/dist/version.js +1 -1
  186. package/package.json +1 -1
  187. package/src/cell.ts +78 -51
  188. package/src/checks.ts +84 -0
  189. package/src/closure.ts +214 -0
  190. package/src/coordinates.ts +370 -0
  191. package/src/crystalClasses.ts +271 -157
  192. package/src/freeze.ts +14 -0
  193. package/src/index.ts +33 -12
  194. package/src/indices.ts +102 -42
  195. package/src/lattice.ts +41 -1
  196. package/src/linalg.ts +3 -3
  197. package/src/magnetic.ts +24 -11
  198. package/src/notation.ts +73 -0
  199. package/src/operations.ts +78 -71
  200. package/src/plane.ts +531 -151
  201. package/src/pointGroups/crystalForms.ts +11 -44
  202. package/src/pointGroups/crystalFormsData.ts +66 -1
  203. package/src/pointGroups/elements.ts +82 -92
  204. package/src/pointGroups/identify.ts +38 -97
  205. package/src/pointGroups/itaOrder.ts +117 -101
  206. package/src/pointGroups/itcData.ts +404 -0
  207. package/src/pointGroups/itcMagneticData.ts +206 -0
  208. package/src/pointGroups/keys.ts +144 -0
  209. package/src/pointGroups/magneticSymbols.ts +18 -17
  210. package/src/pointGroups/orbits.ts +41 -89
  211. package/src/pointGroups/pointGroups.ts +593 -298
  212. package/src/pointGroups/properties.ts +44 -40
  213. package/src/pointGroups/seitzData.ts +147 -0
  214. package/src/pointGroups/shubnikovData.ts +103 -0
  215. package/src/pointGroups/wyckoff.ts +137 -112
  216. package/src/pointGroups/wyckoffData.ts +793 -170
  217. package/src/siteSymmetry.ts +43 -40
  218. package/src/spaceGroups/affine.ts +3 -2
  219. package/src/spaceGroups/cell.ts +227 -116
  220. package/src/spaceGroups/describe.ts +23 -19
  221. package/src/spaceGroups/planeGroupData.ts +28 -9
  222. package/src/spaceGroups/planeGroups.ts +2 -1
  223. package/src/spaceGroups/planeLattice.ts +208 -0
  224. package/src/spaceGroups/planePointGroups.ts +23 -3
  225. package/src/spaceGroups/positions.ts +202 -78
  226. package/src/spaceGroups/rational.ts +59 -0
  227. package/src/tensors/propertyTable.ts +26 -14
  228. package/src/tensors/rowEchelon.ts +4 -3
  229. package/src/tensors/tensorForm.ts +258 -88
  230. package/src/tensors/tensorProperties.ts +34 -14
  231. package/src/tensors/voigt.ts +268 -0
  232. package/src/tolerances.ts +66 -1
  233. package/src/version.ts +1 -1
  234. package/dist/pointGroups/data.d.ts +0 -75
  235. package/dist/pointGroups/data.d.ts.map +0 -1
  236. package/dist/pointGroups/data.js +0 -212
  237. package/dist/pointGroups/data.js.map +0 -1
  238. package/dist/pointGroups/magneticData.d.ts +0 -66
  239. package/dist/pointGroups/magneticData.d.ts.map +0 -1
  240. package/dist/pointGroups/magneticData.js +0 -184
  241. package/dist/pointGroups/magneticData.js.map +0 -1
  242. package/dist/spaceGroups/snap.d.ts +0 -20
  243. package/dist/spaceGroups/snap.d.ts.map +0 -1
  244. package/dist/spaceGroups/snap.js +0 -103
  245. package/dist/spaceGroups/snap.js.map +0 -1
  246. package/src/pointGroups/data.ts +0 -305
  247. package/src/pointGroups/magneticData.ts +0 -328
  248. package/src/spaceGroups/snap.ts +0 -121
@@ -1,25 +1,27 @@
1
1
  /**
2
2
  * The geometric description of an operation of a plane group, as ITA gives it under "Symmetry
3
- * operations" (ITA 2016, § 2.1.3.9, pp. 160–161): what it is, its order and sense, where its
3
+ * operations" (ITA 2016, § 2.1.3.9, pp. 160–161): what it is, its n and sense, where its
4
4
  * symmetry element lies and its glide part. Structured data; the symbols such as `g(1/2,1/2) x,x`
5
5
  * stay with the applications (CLAUDE.md, "Symmetry elements as structured data").
6
6
  */
7
7
 
8
+ import { shown } from '../checks.js';
8
9
  import { determinant, dimensionOf, trace, type ExactOperation, type IntMatrix } from './affine.js';
9
10
  import { ZERO, add, multiply, rational, scale, type Rational } from './rational.js';
10
11
 
11
12
  /**
12
- * What an operation of a plane group is: `'mirror'` (a reflection in a line, as `'mirror'` of the
13
- * point groups) and `'glide'` (a glide reflection).
13
+ * What an operation of a plane group or plane point group is, as ITA names the operations (ITA 2016
14
+ * Table 2.1.2.1, p. 145): `'reflection'` (in a line, as `'reflection'` of the point groups) and
15
+ * `'glide-reflection'`.
14
16
  */
15
- export type PlaneOperationKind = 'identity' | 'translation' | 'rotation' | 'mirror' | 'glide';
17
+ export type PlaneOperationKind = 'identity' | 'translation' | 'rotation' | 'reflection' | 'glide-reflection';
16
18
 
17
19
  /** One operation of a plane group described geometrically, in the lattice basis. */
18
20
  export interface PlaneOperationDescription {
19
21
  /** What the operation is. */
20
22
  readonly kind: PlaneOperationKind;
21
- /** The order n of its linear part: 1 for identity and translation, 2 for a mirror or glide. */
22
- readonly order: number;
23
+ /** The n of its linear part (an n-fold rotation): 1 for identity and translation, 2 for a reflection or glide reflection. */
24
+ readonly n: number;
23
25
  /** For a rotation with n ≥ 3: `'+'` if it turns a towards b, `'-'` otherwise. */
24
26
  readonly sense?: '+' | '-';
25
27
  /** For a translation: the translation vector. */
@@ -33,12 +35,14 @@ export interface PlaneOperationDescription {
33
35
  /** For a mirror or glide: the direction of its line, the shortest integer vector, first non-zero component positive. */
34
36
  readonly direction?: readonly [number, number];
35
37
  /**
36
- * For a mirror or glide: the normal of its line in the lattice basis, its symmetry direction in
37
- * the sense of ITA Table 2.1.3.1: the shortest integer vector along the columns of W − I, first
38
- * non-zero component positive. Without a metric it is not the perpendicular of `direction`: in a
38
+ * For a reflection or glide reflection: its axis, the normal of its line in the lattice basis (as
39
+ * the `axis` of a reflection of the point groups is the normal of its plane, #137 C3), its symmetry
40
+ * direction with the sign of its Seitz symbol (ITA 2016 Tables 1.4.2.4, 1.4.2.5, p. 53: `m₁₀`, `m₁₂`,
41
+ * #107, #114): the shortest integer vector along the columns of W − I, first non-zero component
42
+ * positive, which is the Seitz direction for every plane group (tested). Without a metric it is not the perpendicular of `direction`: in a
39
43
  * hexagonal basis the normal of a line along [1,0] is [1,2].
40
44
  */
41
- readonly normal?: readonly [number, number];
45
+ readonly axis?: readonly [number, number];
42
46
  /**
43
47
  * For a glide: the glide vector (w + W·w)/2, not reduced modulo the lattice. An operation whose
44
48
  * glide vector is a non-zero lattice vector is a glide, as it is geometrically, although the
@@ -89,12 +93,12 @@ export function describePlaneOperation(op: ExactOperation): PlaneOperationDescri
89
93
  if (det === 1) {
90
94
  const n = ORDER_BY_TRACE[trace(w)];
91
95
  if (n === undefined || !isIdentity(power(w, n))) {
92
- throw new RangeError(`Not a crystallographic rotation: ${JSON.stringify(w)}`);
96
+ throw new RangeError(`Not a crystallographic rotation: ${shown(w)}`);
93
97
  }
94
98
  if (n === 1) {
95
99
  return t.every((v) => v[0] === 0)
96
- ? { kind: 'identity', order: 1 }
97
- : { kind: 'translation', order: 1, translation: [...t] };
100
+ ? { kind: 'identity', n: 1 }
101
+ : { kind: 'translation', n: 1, translation: [...t] };
98
102
  }
99
103
  // The centre p solves (I − W) p = w; det(I − W) = 2 − trace W ≠ 0 for a rotation.
100
104
  const a = [
@@ -107,12 +111,12 @@ export function describePlaneOperation(op: ExactOperation): PlaneOperationDescri
107
111
  multiply(add(scale(a[1][1], t[0]), scale(-a[0][1], t[1])), inv),
108
112
  multiply(add(scale(-a[1][0], t[0]), scale(a[0][0], t[1])), inv),
109
113
  ];
110
- const description: PlaneOperationDescription = { kind: 'rotation', order: n, location: Object.freeze(location) };
114
+ const description: PlaneOperationDescription = { kind: 'rotation', n, location: Object.freeze(location) };
111
115
  // The sense: the sign of a × W·a with a = (1, 0), the same in any right-handed basis.
112
116
  return Object.freeze(n === 2 ? description : { ...description, sense: w[1][0] > 0 ? '+' : '-' });
113
117
  }
114
118
  if (det !== -1 || trace(w) !== 0 || !isIdentity(power(w, 2))) {
115
- throw new RangeError(`Not a crystallographic reflection: ${JSON.stringify(w)}`);
119
+ throw new RangeError(`Not a crystallographic reflection: ${shown(w)}`);
116
120
  }
117
121
  // A mirror or glide: W² = I. Glide vector g = (w + W·w)/2, along the line; the line is the set of p with (I − W) p = w − g.
118
122
  const wt = [add(scale(w[0][0], t[0]), scale(w[0][1], t[1])), add(scale(w[1][0], t[0]), scale(w[1][1], t[1]))];
@@ -136,14 +140,14 @@ export function describePlaneOperation(op: ExactOperation): PlaneOperationDescri
136
140
  const location: Rational[] =
137
141
  a[i][0] !== 0 ? [multiply(s[i], rational(1, a[i][0])), ZERO] : [ZERO, multiply(s[i], rational(1, a[i][1]))];
138
142
  const line = {
139
- order: 2,
143
+ n: 2,
140
144
  location: Object.freeze(location),
141
145
  direction: Object.freeze(direction),
142
- normal: Object.freeze(normal),
146
+ axis: Object.freeze(normal),
143
147
  };
144
148
  return Object.freeze(
145
149
  glide.some((v) => v[0] !== 0)
146
- ? { kind: 'glide' as const, ...line, glide: Object.freeze(glide) }
147
- : { kind: 'mirror' as const, ...line },
150
+ ? { kind: 'glide-reflection' as const, ...line, glide: Object.freeze(glide) }
151
+ : { kind: 'reflection' as const, ...line },
148
152
  );
149
153
  }
@@ -25,9 +25,11 @@ export interface PlaneGroupEntry {
25
25
  readonly pointGroup: string;
26
26
  /** The crystal system. */
27
27
  readonly system: PlaneSystem;
28
+ /** The Patterson symmetry as printed in the headline, the symbol of a plane group, e.g. `p2mm`. */
29
+ readonly pattersonSymmetry: string;
28
30
  /** Printed page. */
29
31
  readonly page: number;
30
- /** The block "Origin" as printed, e.g. `at 21g`. */
32
+ /** The block "Origin" as printed, its positions spaced, e.g. `at 2 1 g`. */
31
33
  readonly origin: string;
32
34
  /** The block "Asymmetric unit" as printed. */
33
35
  readonly asymmetricUnit: string;
@@ -51,6 +53,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
51
53
  fullSymbol: 'p1',
52
54
  pointGroup: '1',
53
55
  system: 'oblique',
56
+ pattersonSymmetry: 'p2',
54
57
  page: 176,
55
58
  origin: 'arbitrary',
56
59
  asymmetricUnit: '0 <= x <= 1; 0 <= y <= 1',
@@ -65,6 +68,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
65
68
  fullSymbol: 'p2',
66
69
  pointGroup: '2',
67
70
  system: 'oblique',
71
+ pattersonSymmetry: 'p2',
68
72
  page: 177,
69
73
  origin: 'at 2',
70
74
  asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1',
@@ -85,6 +89,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
85
89
  fullSymbol: 'p1m1',
86
90
  pointGroup: 'm',
87
91
  system: 'rectangular',
92
+ pattersonSymmetry: 'p2mm',
88
93
  page: 178,
89
94
  origin: 'on m',
90
95
  asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1',
@@ -103,6 +108,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
103
108
  fullSymbol: 'p1g1',
104
109
  pointGroup: 'm',
105
110
  system: 'rectangular',
111
+ pattersonSymmetry: 'p2mm',
106
112
  page: 179,
107
113
  origin: 'on g',
108
114
  asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1',
@@ -117,6 +123,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
117
123
  fullSymbol: 'c1m1',
118
124
  pointGroup: 'm',
119
125
  system: 'rectangular',
126
+ pattersonSymmetry: 'c2mm',
120
127
  page: 180,
121
128
  origin: 'on m',
122
129
  asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1/2',
@@ -134,8 +141,9 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
134
141
  fullSymbol: 'p2mm',
135
142
  pointGroup: '2mm',
136
143
  system: 'rectangular',
144
+ pattersonSymmetry: 'p2mm',
137
145
  page: 181,
138
- origin: 'at 2mm',
146
+ origin: 'at 2 m m',
139
147
  asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1/2',
140
148
  centring: [],
141
149
  generalPosition: ['x,y', '-x,-y', '-x,y', 'x,-y'],
@@ -158,8 +166,9 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
158
166
  fullSymbol: 'p2mg',
159
167
  pointGroup: '2mm',
160
168
  system: 'rectangular',
169
+ pattersonSymmetry: 'p2mm',
161
170
  page: 182,
162
- origin: 'at 21g',
171
+ origin: 'at 2 1 g',
163
172
  asymmetricUnit: '0 <= x <= 1/4; 0 <= y <= 1',
164
173
  centring: [],
165
174
  generalPosition: ['x,y', '-x,-y', '-x+1/2,y', 'x+1/2,-y'],
@@ -177,6 +186,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
177
186
  fullSymbol: 'p2gg',
178
187
  pointGroup: '2mm',
179
188
  system: 'rectangular',
189
+ pattersonSymmetry: 'p2mm',
180
190
  page: 183,
181
191
  origin: 'at 2',
182
192
  asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1/2',
@@ -195,8 +205,9 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
195
205
  fullSymbol: 'c2mm',
196
206
  pointGroup: '2mm',
197
207
  system: 'rectangular',
208
+ pattersonSymmetry: 'c2mm',
198
209
  page: 184,
199
- origin: 'at 2mm',
210
+ origin: 'at 2 m m',
200
211
  asymmetricUnit: '0 <= x <= 1/4; 0 <= y <= 1/2',
201
212
  centring: ['1/2,1/2'],
202
213
  generalPosition: ['x,y', '-x,-y', '-x,y', 'x,-y'],
@@ -216,6 +227,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
216
227
  fullSymbol: 'p4',
217
228
  pointGroup: '4',
218
229
  system: 'square',
230
+ pattersonSymmetry: 'p4',
219
231
  page: 185,
220
232
  origin: 'at 4',
221
233
  asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1/2',
@@ -235,8 +247,9 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
235
247
  fullSymbol: 'p4mm',
236
248
  pointGroup: '4mm',
237
249
  system: 'square',
250
+ pattersonSymmetry: 'p4mm',
238
251
  page: 186,
239
- origin: 'at 4mm',
252
+ origin: 'at 4 m m',
240
253
  asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1/2; x <= y',
241
254
  centring: [],
242
255
  generalPosition: ['x,y', '-x,-y', '-y,x', 'y,-x', '-x,y', 'x,-y', 'y,x', '-y,-x'],
@@ -257,8 +270,9 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
257
270
  fullSymbol: 'p4gm',
258
271
  pointGroup: '4mm',
259
272
  system: 'square',
273
+ pattersonSymmetry: 'p4mm',
260
274
  page: 187,
261
- origin: 'at 41g',
275
+ origin: 'at 4 1 g',
262
276
  asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1/2; y <= 1/2 - x',
263
277
  centring: [],
264
278
  generalPosition: ['x,y', '-x,-y', '-y,x', 'y,-x', '-x+1/2,y+1/2', 'x+1/2,-y+1/2', 'y+1/2,x+1/2', '-y+1/2,-x+1/2'],
@@ -276,6 +290,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
276
290
  fullSymbol: 'p3',
277
291
  pointGroup: '3',
278
292
  system: 'hexagonal',
293
+ pattersonSymmetry: 'p6',
279
294
  page: 188,
280
295
  origin: 'at 3',
281
296
  asymmetricUnit: '0 <= x <= 2/3; 0 <= y <= 2/3; x <= (1 + y)/2; y <= min(1 - x, (1 + x)/2)',
@@ -296,8 +311,9 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
296
311
  fullSymbol: 'p3m1',
297
312
  pointGroup: '3m',
298
313
  system: 'hexagonal',
314
+ pattersonSymmetry: 'p6mm',
299
315
  page: 189,
300
- origin: 'at 3m1',
316
+ origin: 'at 3 m 1',
301
317
  asymmetricUnit: '0 <= x <= 2/3; 0 <= y <= 2/3; x <= 2y; y <= min(1 - x, 2x)',
302
318
  vertices: ['0,0', '2/3,1/3', '1/3,2/3'],
303
319
  centring: [],
@@ -317,8 +333,9 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
317
333
  fullSymbol: 'p31m',
318
334
  pointGroup: '3m',
319
335
  system: 'hexagonal',
336
+ pattersonSymmetry: 'p6mm',
320
337
  page: 190,
321
- origin: 'at 31m',
338
+ origin: 'at 3 1 m',
322
339
  asymmetricUnit: '0 <= x <= 2/3; 0 <= y <= 1/2; x <= (1 + y)/2; y <= min(1 - x, x)',
323
340
  vertices: ['0,0', '1/2,0', '2/3,1/3', '1/2,1/2'],
324
341
  centring: [],
@@ -337,6 +354,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
337
354
  fullSymbol: 'p6',
338
355
  pointGroup: '6',
339
356
  system: 'hexagonal',
357
+ pattersonSymmetry: 'p6',
340
358
  page: 191,
341
359
  origin: 'at 6',
342
360
  asymmetricUnit: '0 <= x <= 2/3; 0 <= y <= 1/2; x <= (1 + y)/2; y <= min(1 - x, x)',
@@ -357,8 +375,9 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
357
375
  fullSymbol: 'p6mm',
358
376
  pointGroup: '6mm',
359
377
  system: 'hexagonal',
378
+ pattersonSymmetry: 'p6mm',
360
379
  page: 192,
361
- origin: 'at 6mm',
380
+ origin: 'at 6 m m',
362
381
  asymmetricUnit: '0 <= x <= 2/3; 0 <= y <= 1/3; x <= (1 + y)/2; y <= x/2',
363
382
  vertices: ['0,0', '1/2,0', '2/3,1/3'],
364
383
  centring: [],
@@ -4,6 +4,7 @@
4
4
  * Internal for now; the entry point `symcrys/plane` comes later.
5
5
  */
6
6
 
7
+ import { shown } from '../checks.js';
7
8
  import {
8
9
  closure,
9
10
  compose,
@@ -23,7 +24,7 @@ export const PLANE_GROUP_KEYS = PLANE_GROUP_DATA.map((g) => g.symbol);
23
24
  export function planeGroupEntry(key: string | number): PlaneGroupEntry {
24
25
  const entry = PLANE_GROUP_DATA.find((g) => g.symbol === key || g.number === key);
25
26
  if (!entry) {
26
- throw new RangeError(`Unknown plane group: ${JSON.stringify(key)}`);
27
+ throw new RangeError(`Unknown plane group: ${shown(key)}`);
27
28
  }
28
29
  return entry;
29
30
  }
@@ -0,0 +1,208 @@
1
+ /**
2
+ * The lattices of the plane: the crystal families with their Bravais lattices and cell restrictions
3
+ * (ITA 2016 Table 2.1.1.1, p. 143, block "Two dimensions"), the Laue class of a plane point group
4
+ * (ITA 2016 § 3.2.1.1, p. 720), and the cell functions for d = 2 (#119, #137 G5). Internal; the
5
+ * entry point is `symcrys/plane`.
6
+ */
7
+
8
+ import { checkObject, shown } from '../checks.js';
9
+ import type { PlaneSystem } from './planeGroupData.js';
10
+ import {
11
+ PLANE_POINT_GROUP_KEYS,
12
+ planePointGroupOperations,
13
+ planePointGroupSettingCount,
14
+ type PlanePointGroupKey,
15
+ } from './planePointGroups.js';
16
+
17
+ /** A Bravais lattice of the plane, by its symbol in ITA Table 2.1.1.1: family symbol and centring. */
18
+ export type PlaneBravaisLattice = 'mp' | 'op' | 'oc' | 'tp' | 'hp';
19
+
20
+ /** A parameter of a plane cell: the edge lengths a, b and the angle γ between them. */
21
+ export type PlaneCellParameter = 'a' | 'b' | 'gamma';
22
+
23
+ /** The angles of a plane cell fixed by its crystal system, in degrees. */
24
+ export interface PlaneFixedAngles {
25
+ /** The angle γ between a and b, where the system fixes it. */
26
+ readonly gamma?: number;
27
+ }
28
+
29
+ /** The restrictions on the cell parameters of a crystal system of the plane (ITA Table 2.1.1.1). */
30
+ export interface CellRestrictions {
31
+ /** The parameters to be determined (column "Parameters to be determined"), e.g. `['a']` for square. */
32
+ readonly parameters: readonly PlaneCellParameter[];
33
+ /** Pairs of parameters that are equal: `[['a', 'b']]` for square and hexagonal. */
34
+ readonly equal: readonly (readonly PlaneCellParameter[])[];
35
+ /** The angles fixed to a value, in degrees: gamma 90 for rectangular and square, 120 for hexagonal; none for oblique. */
36
+ readonly angles: PlaneFixedAngles;
37
+ /** The angles conventionally taken non-acute (≥ 90°), the footnote § of the table: `['gamma']` for oblique. */
38
+ readonly nonAcute: readonly PlaneCellParameter[];
39
+ }
40
+
41
+ /** One crystal family of the plane as Table 2.1.1.1 prints it; each has one crystal system. */
42
+ interface PlaneFamily {
43
+ /** The family symbol (column "Symbol"). */
44
+ readonly symbol: 'm' | 'o' | 't' | 'h';
45
+ /** The Bravais lattices. */
46
+ readonly bravaisLattices: readonly PlaneBravaisLattice[];
47
+ readonly restrictions: CellRestrictions;
48
+ }
49
+
50
+ /** ITA 2016 Table 2.1.1.1, p. 143, block "Two dimensions" (references/itc/vol-a-table-2.1.1.1.md). */
51
+ export const PLANE_FAMILIES: Readonly<Record<PlaneSystem, PlaneFamily>> = {
52
+ oblique: {
53
+ symbol: 'm',
54
+ bravaisLattices: ['mp'],
55
+ restrictions: { parameters: ['a', 'b', 'gamma'], equal: [], angles: {}, nonAcute: ['gamma'] },
56
+ },
57
+ rectangular: {
58
+ symbol: 'o',
59
+ bravaisLattices: ['op', 'oc'],
60
+ restrictions: { parameters: ['a', 'b'], equal: [], angles: { gamma: 90 }, nonAcute: [] },
61
+ },
62
+ square: {
63
+ symbol: 't',
64
+ bravaisLattices: ['tp'],
65
+ restrictions: { parameters: ['a'], equal: [['a', 'b']], angles: { gamma: 90 }, nonAcute: [] },
66
+ },
67
+ hexagonal: {
68
+ symbol: 'h',
69
+ bravaisLattices: ['hp'],
70
+ restrictions: { parameters: ['a'], equal: [['a', 'b']], angles: { gamma: 120 }, nonAcute: [] },
71
+ },
72
+ };
73
+
74
+ /** The Bravais lattice of a plane group: the family symbol of its system and its lattice letter. */
75
+ export function planeBravaisLattice(system: PlaneSystem, groupSymbol: string): PlaneBravaisLattice {
76
+ const family = PLANE_FAMILIES[system];
77
+ const lattice = `${family.symbol}${groupSymbol[0]}` as PlaneBravaisLattice;
78
+ if (!family.bravaisLattices.includes(lattice)) {
79
+ throw new Error(`The plane group ${groupSymbol} has the lattice ${lattice}, not one of its family`);
80
+ }
81
+ return lattice;
82
+ }
83
+
84
+ const matrixKey = (m: readonly (readonly number[])[]): string => m.map((r) => r.join(',')).join(';');
85
+
86
+ /**
87
+ * The Laue class of a plane point group: the point group with the twofold rotation added, which is
88
+ * the symmetry centre of the plane ("its Laue class is obtained if a symmetry centre is added to its
89
+ * point group", ITA 2016 § 3.2.1.1, p. 720). One of the six Laue classes 2, 2mm, 4, 4mm, 6, 6mm.
90
+ */
91
+ export function planeLaueClass(key: PlanePointGroupKey): PlanePointGroupKey {
92
+ const ops = planePointGroupOperations(key).map((op) => op.matrix);
93
+ const wanted = new Set([...ops, ...ops.map((m) => m.map((r) => r.map((x) => -x + 0)))].map(matrixKey));
94
+ for (const k of PLANE_POINT_GROUP_KEYS) {
95
+ for (let s = 1; s <= planePointGroupSettingCount(k); s++) {
96
+ const have = new Set(planePointGroupOperations(k, s).map((op) => matrixKey(op.matrix)));
97
+ if (have.size === wanted.size && [...wanted].every((m) => have.has(m))) return k;
98
+ }
99
+ }
100
+ throw new Error(`No Laue class for the plane point group ${key}`);
101
+ }
102
+
103
+ // --- cells ------------------------------------------------------------------------------------------
104
+
105
+ /** A 2 × 2 matrix, as two rows: a basis has the columns a and b. */
106
+ export type Mat2 = readonly [readonly [number, number], readonly [number, number]];
107
+
108
+ /** The parameters of a plane cell: the edge lengths a, b and the angle γ between them in degrees. */
109
+ export interface LatticeParameters {
110
+ /** Edge length a. */
111
+ readonly a: number;
112
+ /** Edge length b. */
113
+ readonly b: number;
114
+ /** Angle γ between a and b, in degrees. */
115
+ readonly gamma: number;
116
+ }
117
+
118
+ const DEG = Math.PI / 180;
119
+
120
+ /** cos of an angle in degrees, exact at the angles of the plane lattices (60°, 90°, 120°, …). */
121
+ function cosDeg(x: number): number {
122
+ const exact: Record<number, number> = { 0: 1, 60: 0.5, 90: 0, 120: -0.5, 180: -1 };
123
+ return x in exact ? exact[x] : Math.cos(x * DEG);
124
+ }
125
+
126
+ /**
127
+ * The Cartesian basis of a plane cell as the columns of a 2 × 2 matrix: a along x, b at γ from a
128
+ * towards +y, so the basis is right-handed. Throws a RangeError for an edge that is not a positive
129
+ * finite number, for γ outside (0°, 180°), and for a cell that is flat within rounding (sin γ, the
130
+ * ratio V/(ab), at most 10⁻⁶, as the cells of the point groups).
131
+ */
132
+ export function planeLatticeFromParameters(p: LatticeParameters, who: string): Mat2 {
133
+ checkObject(p, `${who} takes the parameters { a, b, gamma }`);
134
+ for (const name of ['a', 'b'] as const) {
135
+ const x = p[name];
136
+ if (!(typeof x === 'number' && Number.isFinite(x) && x > 0)) {
137
+ throw new RangeError(`${who}: edge ${name} must be a positive number, not ${shown(x)}`);
138
+ }
139
+ }
140
+ const g = p.gamma;
141
+ if (!(typeof g === 'number' && Number.isFinite(g) && g > 0 && g < 180)) {
142
+ throw new RangeError(`${who}: gamma must be an angle in degrees between 0 and 180, not ${shown(g)}`);
143
+ }
144
+ const c = cosDeg(g);
145
+ const s = Math.sqrt(1 - c * c);
146
+ if (!(s > 1e-6)) throw new RangeError(`${who}: gamma ${g}° gives no cell (a and b parallel within rounding)`);
147
+ const basis: Mat2 = [
148
+ [p.a + 0, p.b * c + 0],
149
+ [0, p.b * s + 0],
150
+ ];
151
+ // Edges so large or small that the cell cannot be computed with are refused as by the basis check.
152
+ planeBasisColumns(basis, who);
153
+ return basis;
154
+ }
155
+
156
+ /**
157
+ * The columns a, b of a basis, checked: two rows of two finite numbers, and regular by the criterion
158
+ * of the point groups (`isSingular`): the product of the column lengths finite and not zero, the
159
+ * determinant above 10⁻⁹ of it, so that no later product overflows or vanishes.
160
+ */
161
+ export function planeBasisColumns(basis: unknown, who: string): [readonly number[], readonly number[]] {
162
+ const ok =
163
+ Array.isArray(basis) &&
164
+ basis.length === 2 &&
165
+ basis.every(
166
+ (row) => Array.isArray(row) && row.length === 2 && row.every((x) => typeof x === 'number' && Number.isFinite(x)),
167
+ );
168
+ if (!ok) throw new RangeError(`${who}: the basis must be a 2 × 2 matrix of finite numbers, not ${shown(basis)}`);
169
+ const b = basis as unknown as Mat2;
170
+ const bound = Math.hypot(b[0][0], b[1][0]) * Math.hypot(b[0][1], b[1][1]);
171
+ const det = b[0][0] * b[1][1] - b[0][1] * b[1][0];
172
+ if (!(Number.isFinite(bound) && bound > 0 && Math.abs(det) > 1e-9 * bound)) {
173
+ throw new RangeError(`${who}: singular basis ${shown(basis)}`);
174
+ }
175
+ return [
176
+ [b[0][0], b[1][0]],
177
+ [b[0][1], b[1][1]],
178
+ ];
179
+ }
180
+
181
+ /** The parameters a, b, γ of a basis (columns a, b), independent of its orientation and handedness. */
182
+ export function planeLatticeParameters(basis: unknown, who: string): LatticeParameters {
183
+ const [a, b] = planeBasisColumns(basis, who);
184
+ const cross = a[0] * b[1] - a[1] * b[0];
185
+ const dot = a[0] * b[0] + a[1] * b[1];
186
+ return { a: Math.hypot(a[0], a[1]), b: Math.hypot(b[0], b[1]), gamma: Math.atan2(Math.abs(cross), dot) / DEG + 0 };
187
+ }
188
+
189
+ /** The metric tensor G = AᵀA of a basis A (columns a, b). */
190
+ export function planeMetricTensor(basis: unknown, who: string): Mat2 {
191
+ const [a, b] = planeBasisColumns(basis, who);
192
+ const dot = (u: readonly number[], v: readonly number[]) => u[0] * v[0] + u[1] * v[1] + 0;
193
+ return [
194
+ [dot(a, a), dot(a, b)],
195
+ [dot(b, a), dot(b, b)],
196
+ ];
197
+ }
198
+
199
+ /** The reciprocal basis A⁻ᵀ of a basis A (columns a, b) as the columns a*, b*, with a_i · a*_j = δ_ij. */
200
+ export function planeReciprocalBasis(basis: unknown, who: string): Mat2 {
201
+ const [a, b] = planeBasisColumns(basis, who);
202
+ const det = a[0] * b[1] - a[1] * b[0];
203
+ // A = [[a0, b0], [a1, b1]]; A⁻¹ = [[b1, -b0], [-a1, a0]] / det; A⁻ᵀ = [[b1, -a1], [-b0, a0]] / det.
204
+ return [
205
+ [b[1] / det + 0, -a[1] / det + 0],
206
+ [-b[0] / det + 0, a[0] / det + 0],
207
+ ];
208
+ }
@@ -12,10 +12,30 @@ import { planeGroupEntry, planeGroupGenerators, planeGroupOperations } from './p
12
12
  import { ZERO } from './rational.js';
13
13
 
14
14
  /** The keys of the ten plane point groups, in the order of ITA Table 3.2.1.1. */
15
- export const PLANE_POINT_GROUP_KEYS = ['1', '2', 'm', '2mm', '4', '4mm', '3', '3m', '6', '6mm'] as const;
15
+ /**
16
+ * The key of a plane point group. Written out rather than derived from the list below, so that the
17
+ * declarations keep its name (a derived type is expanded there), by which the Python generator
18
+ * reads it as a key (`str`).
19
+ */
20
+ export type PlanePointGroupKey = '1' | '2' | 'm' | '2mm' | '4' | '4mm' | '3' | '3m' | '6' | '6mm';
21
+
22
+ export const PLANE_POINT_GROUP_KEYS = [
23
+ '1',
24
+ '2',
25
+ 'm',
26
+ '2mm',
27
+ '4',
28
+ '4mm',
29
+ '3',
30
+ '3m',
31
+ '6',
32
+ '6mm',
33
+ ] as const satisfies readonly PlanePointGroupKey[];
16
34
 
17
- /** The key of a plane point group. */
18
- export type PlanePointGroupKey = (typeof PLANE_POINT_GROUP_KEYS)[number];
35
+ // Every key is in the list (the list holds no other value by `satisfies`).
36
+ type MissingKey = Exclude<PlanePointGroupKey, (typeof PLANE_POINT_GROUP_KEYS)[number]>;
37
+ const everyKeyListed: [MissingKey] extends [never] ? true : never = true;
38
+ void everyKeyListed;
19
39
 
20
40
  /** The symmorphic plane group of each point group and setting, whose linear parts it is. */
21
41
  const SOURCE: Record<PlanePointGroupKey, readonly string[]> = {