symcrys 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +146 -118
  15. package/dist/crystalClasses.d.ts.map +1 -1
  16. package/dist/crystalClasses.js +163 -124
  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 +9 -17
  115. package/dist/siteSymmetry.d.ts.map +1 -1
  116. package/dist/siteSymmetry.js +62 -47
  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 +12 -4
  145. package/dist/tensors/rowEchelon.d.ts.map +1 -1
  146. package/dist/tensors/rowEchelon.js +24 -11
  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 +173 -68
  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 +234 -160
  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 -69
  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 +71 -64
  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 +29 -17
  199. package/src/tensors/rowEchelon.ts +28 -9
  200. package/src/tensors/tensorForm.ts +260 -89
  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,328 +0,0 @@
1
- /**
2
- * The 90 magnetic point groups with time reversal as data: the 32 grey groups (type II) and the 58
3
- * black-and-white groups (type III). With the 32 crystal classes (type I, data.ts) they are the 122
4
- * magnetic point groups.
5
- *
6
- * A grey group is its crystal class P together with all operations of P combined with time
7
- * reversal (ITC Vol. D, eq. (1.5.2.1)); its data follow from the class. A black-and-white group is
8
- * stored like a class: generators in the stored (Birss) frame, here those of birss-app, and the
9
- * frames of its settings. The symbols of a setting are not stored: they are the symbols of the
10
- * crystal class in that frame with the primes the operations carry (magneticSymbols.ts).
11
- * Print anchors and their tests: docs/conventions.md, "Sources".
12
- */
13
-
14
- import { IDENTITY, INVERSION, type Mat3 } from '../linalg.js';
15
- import { operation, type Operation } from '../operations.js';
16
- import {
17
- MIRROR_X,
18
- MIRROR_Y,
19
- MIRROR_Z,
20
- MONOCLINIC_B,
21
- ORTHO_SWAP,
22
- ORTHO_TO_A,
23
- ORTHO_TO_A_SWAP,
24
- ORTHO_TO_B,
25
- ORTHO_TO_B_SWAP,
26
- POINT_GROUP_DATA,
27
- POINT_GROUP_KEYS,
28
- ROT2_X,
29
- ROT2_Y,
30
- ROT2_Z,
31
- ROT30_Z,
32
- ROT3_111,
33
- ROT3_Z,
34
- ROT45_Z,
35
- ROT4_Z,
36
- ROT6_Z,
37
- ROTINV4_Z,
38
- ROTINV6_Z,
39
- SAME,
40
- type PointGroupKey,
41
- } from './data.js';
42
-
43
- /** Keys of the 32 grey groups: the key of the crystal class followed by `1'`. */
44
- export type GreyPointGroupKey = `${PointGroupKey}1'`;
45
-
46
- export const GREY_POINT_GROUP_KEYS: readonly GreyPointGroupKey[] = Object.freeze(
47
- POINT_GROUP_KEYS.map((key): GreyPointGroupKey => `${key}1'`),
48
- );
49
-
50
- /**
51
- * Keys of the 58 black-and-white groups: the short Hermann–Mauguin symbol of ITC Vol. D
52
- * Table 1.5.2.3, in the order of the table (docs/conventions.md, "Keys").
53
- */
54
- export const BLACK_WHITE_POINT_GROUP_KEYS = Object.freeze([
55
- "-1'",
56
- "2'",
57
- "m'",
58
- "2'/m'",
59
- "2/m'",
60
- "2'/m",
61
- "2'2'2",
62
- "m'm'2",
63
- "2'm'm",
64
- "mm'm'",
65
- "m'm'm'",
66
- "mmm'",
67
- "4'",
68
- "-4'",
69
- "4'/m",
70
- "4/m'",
71
- "4'/m'",
72
- "4'22'",
73
- "42'2'",
74
- "4'mm'",
75
- "4m'm'",
76
- "-4'2m'",
77
- "-4'm2'",
78
- "-42'm'",
79
- "4'/mmm'",
80
- "4/mm'm'",
81
- "4/m'm'm'",
82
- "4/m'mm",
83
- "4'/m'm'm",
84
- "-3'",
85
- "32'",
86
- "3m'",
87
- "-3m'",
88
- "-3'm'",
89
- "-3'm",
90
- "6'",
91
- "-6'",
92
- "6'/m'",
93
- "6/m'",
94
- "6'/m",
95
- "6'22'",
96
- "62'2'",
97
- "6'mm'",
98
- "6m'm'",
99
- "-6'2m'",
100
- "-6'm2'",
101
- "-6m'2'",
102
- "6'/m'mm'",
103
- "6/mm'm'",
104
- "6/m'm'm'",
105
- "6/m'mm",
106
- "6'/mmm'",
107
- "m'-3'",
108
- "4'32'",
109
- "-4'3m'",
110
- "m-3m'",
111
- "m'-3'm'",
112
- "m'-3'm",
113
- ] as const);
114
-
115
- /** The key of one of the 58 black-and-white magnetic point groups. */
116
- // `Extract<…, string>`: the same type, named by the documentation (see `PointGroupKey`).
117
- export type BlackWhitePointGroupKey = Extract<(typeof BLACK_WHITE_POINT_GROUP_KEYS)[number], string>;
118
-
119
- /** Keys of all 122 magnetic point groups: the 32 crystal classes, the 32 grey groups, the 58 black-and-white groups. */
120
- export type MagneticPointGroupKey = PointGroupKey | GreyPointGroupKey | BlackWhitePointGroupKey;
121
-
122
- /**
123
- * Keys of the 122 magnetic point groups: the 32 crystal classes (white groups), the 32 grey groups
124
- * and the 58 black-and-white groups, in this order (docs/conventions.md, "Keys").
125
- */
126
- export const MAGNETIC_POINT_GROUP_KEYS: readonly MagneticPointGroupKey[] = Object.freeze([
127
- ...POINT_GROUP_KEYS,
128
- ...GREY_POINT_GROUP_KEYS,
129
- ...BLACK_WHITE_POINT_GROUP_KEYS,
130
- ]);
131
-
132
- /** The frame of a setting of a black-and-white group. */
133
- export interface MagneticFrame {
134
- /** Orthogonal matrix s: the setting's operations are s·W·sᵀ for the stored operations W. */
135
- readonly frame: Mat3;
136
- /** Monoclinic: the unique axis; orthorhombic: the axis the stored z axis is carried to. */
137
- readonly uniqueAxis?: 'a' | 'b' | 'c';
138
- }
139
-
140
- export interface BlackWhiteData {
141
- readonly key: BlackWhitePointGroupKey;
142
- /** The crystal class the group becomes when every prime is dropped. */
143
- readonly crystalClass: PointGroupKey;
144
- readonly schoenflies: string;
145
- /** Generators in the stored (Birss) frame, which is setting 1. */
146
- readonly generators: readonly Operation[];
147
- /** Setting 1 first; its frame is the identity. */
148
- readonly settings: readonly MagneticFrame[];
149
- /** The ITC default setting (1-based). The Birss default is always setting 1. */
150
- readonly itcDefault: number;
151
- }
152
-
153
- /** Time reversal alone: the identity combined with time reversal (1'). */
154
- export const TIME_REVERSAL: Operation = Object.freeze({ matrix: IDENTITY, timeReversal: true });
155
-
156
- /** An operation combined with time reversal (a primed operation). */
157
- const primed = (matrix: Mat3): Operation => ({ matrix, timeReversal: true });
158
-
159
- function blackWhite(
160
- key: BlackWhitePointGroupKey,
161
- crystalClass: PointGroupKey,
162
- schoenflies: string,
163
- generators: Operation[],
164
- frames: Mat3[],
165
- itcDefault = 1,
166
- uniqueAxes?: ('a' | 'b' | 'c')[],
167
- ): BlackWhiteData {
168
- const settings = frames.map((frame, i): MagneticFrame =>
169
- uniqueAxes ? { frame, uniqueAxis: uniqueAxes[i] } : { frame },
170
- );
171
- return { key, crystalClass, schoenflies, generators, settings, itcDefault };
172
- }
173
-
174
- /**
175
- * The 58 black-and-white groups. The generators are birss-app's (CLAUDE.md, "birss-app is the
176
- * reference where print leaves a choice open"); the group they generate is checked against Birss's
177
- * Table 6 and against ITC Vol. D Table 1.5.2.3. Setting frames as for the classes (data.ts), with three more for `2'm'm`; the
178
- * ITC default is the frame in which the key, read along ITA's symmetry directions, describes the
179
- * group, which is the frame of the operators printed in Table 1.5.2.3.
180
- */
181
- export const BLACK_WHITE_DATA: readonly BlackWhiteData[] = [
182
- blackWhite("-1'", '-1', 'Ci(C1)', [primed(INVERSION)], [SAME]),
183
- blackWhite("2'", '2', 'C2(C1)', [primed(ROT2_Z)], [SAME, MONOCLINIC_B], 2, ['c', 'b']),
184
- blackWhite("m'", 'm', 'Cs(C1)', [primed(MIRROR_Z)], [SAME, MONOCLINIC_B], 2, ['c', 'b']),
185
- blackWhite("2'/m'", '2/m', 'C2h(Ci)', [primed(ROT2_Z), operation(INVERSION)], [SAME, MONOCLINIC_B], 2, ['c', 'b']),
186
- blackWhite("2/m'", '2/m', 'C2h(C2)', [operation(ROT2_Z), primed(INVERSION)], [SAME, MONOCLINIC_B], 2, ['c', 'b']),
187
- blackWhite("2'/m", '2/m', 'C2h(Cs)', [primed(ROT2_Z), primed(INVERSION)], [SAME, MONOCLINIC_B], 2, ['c', 'b']),
188
- blackWhite("2'2'2", '222', 'D2(C2)', [operation(ROT2_Z), primed(ROT2_X)], [SAME, ORTHO_TO_A, ORTHO_TO_B], 1, [
189
- 'c',
190
- 'a',
191
- 'b',
192
- ]),
193
- blackWhite("m'm'2", 'mm2', 'C2v(C2)', [operation(ROT2_Z), primed(MIRROR_X)], [SAME, ORTHO_TO_A, ORTHO_TO_B], 1, [
194
- 'c',
195
- 'a',
196
- 'b',
197
- ]),
198
- // Its three elements all differ, so exchanging two axes gives another orientation: six settings.
199
- // Settings 1 to 3 are birss-app's; 4 to 6 exchange the other two axes at the same unique axis.
200
- blackWhite(
201
- "2'm'm",
202
- 'mm2',
203
- 'C2v(Cs)',
204
- [operation(MIRROR_Z), primed(ROT2_X)],
205
- [SAME, ORTHO_TO_A, ORTHO_TO_B, ORTHO_SWAP, ORTHO_TO_A_SWAP, ORTHO_TO_B_SWAP],
206
- 1,
207
- ['c', 'a', 'b', 'c', 'a', 'b'],
208
- ),
209
- blackWhite(
210
- "mm'm'",
211
- 'mmm',
212
- 'D2h(C2h)',
213
- [operation(ROT2_Z), operation(INVERSION), primed(ROT2_X)],
214
- [SAME, ORTHO_TO_A, ORTHO_TO_B],
215
- 2,
216
- ['c', 'a', 'b'],
217
- ),
218
- blackWhite("m'm'm'", 'mmm', 'D2h(D2)', [operation(ROT2_Z), operation(ROT2_X), primed(INVERSION)], [SAME]),
219
- blackWhite(
220
- "mmm'",
221
- 'mmm',
222
- 'D2h(C2v)',
223
- [operation(ROT2_Z), operation(MIRROR_X), primed(INVERSION)],
224
- [SAME, ORTHO_TO_A, ORTHO_TO_B],
225
- 1,
226
- ['c', 'a', 'b'],
227
- ),
228
- blackWhite("4'", '4', 'C4(C2)', [primed(ROT4_Z)], [SAME]),
229
- blackWhite("-4'", '-4', 'S4(C2)', [primed(ROTINV4_Z)], [SAME]),
230
- blackWhite("4'/m", '4/m', 'C4h(C2h)', [primed(ROT4_Z), operation(INVERSION)], [SAME]),
231
- blackWhite("4/m'", '4/m', 'C4h(C4)', [operation(ROT4_Z), primed(INVERSION)], [SAME]),
232
- blackWhite("4'/m'", '4/m', 'C4h(S4)', [primed(ROT4_Z), primed(INVERSION)], [SAME]),
233
- blackWhite("4'22'", '422', 'D4(D2)', [primed(ROT4_Z), operation(ROT2_X)], [SAME, ROT45_Z]),
234
- blackWhite("42'2'", '422', 'D4(C4)', [operation(ROT4_Z), primed(ROT2_X)], [SAME]),
235
- blackWhite("4'mm'", '4mm', 'C4v(C2v)', [primed(ROT4_Z), operation(MIRROR_X)], [SAME, ROT45_Z]),
236
- blackWhite("4m'm'", '4mm', 'C4v(C4)', [operation(ROT4_Z), primed(MIRROR_X)], [SAME]),
237
- blackWhite("-4'2m'", '-42m', 'D2d(D2)', [primed(ROTINV4_Z), operation(ROT2_X)], [SAME, ROT45_Z]),
238
- blackWhite("-4'm2'", '-42m', 'D2d(C2v)', [primed(ROTINV4_Z), operation(MIRROR_Y)], [SAME, ROT45_Z]),
239
- blackWhite("-42'm'", '-42m', 'D2d(S4)', [operation(ROTINV4_Z), primed(ROT2_X)], [SAME, ROT45_Z]),
240
- blackWhite(
241
- "4'/mmm'",
242
- '4/mmm',
243
- 'D4h(D2h)',
244
- [primed(ROT4_Z), operation(ROT2_X), operation(INVERSION)],
245
- [SAME, ROT45_Z],
246
- ),
247
- blackWhite("4/mm'm'", '4/mmm', 'D4h(C4h)', [operation(ROT4_Z), operation(INVERSION), primed(ROT2_X)], [SAME]),
248
- blackWhite("4/m'm'm'", '4/mmm', 'D4h(D4)', [operation(ROT4_Z), operation(ROT2_X), primed(INVERSION)], [SAME]),
249
- blackWhite("4/m'mm", '4/mmm', 'D4h(C4v)', [operation(ROT4_Z), operation(MIRROR_X), primed(INVERSION)], [SAME]),
250
- blackWhite(
251
- "4'/m'm'm",
252
- '4/mmm',
253
- 'D4h(D2d)',
254
- [operation(ROTINV4_Z), operation(ROT2_Y), primed(INVERSION)],
255
- [SAME, ROT45_Z],
256
- ),
257
- blackWhite("-3'", '-3', 'C3i(C3)', [operation(ROT3_Z), primed(INVERSION)], [SAME]),
258
- blackWhite("32'", '32', 'D3(C3)', [operation(ROT3_Z), primed(ROT2_Y)], [SAME, ROT30_Z], 2),
259
- blackWhite("3m'", '3m', 'C3v(C3)', [operation(ROT3_Z), primed(MIRROR_Y)], [SAME, ROT30_Z], 2),
260
- blackWhite("-3m'", '-3m', 'D3d(C3i)', [operation(ROT3_Z), operation(INVERSION), primed(ROT2_Y)], [SAME, ROT30_Z], 2),
261
- blackWhite("-3'm'", '-3m', 'D3d(D3)', [operation(ROT3_Z), operation(ROT2_Y), primed(INVERSION)], [SAME, ROT30_Z], 2),
262
- blackWhite(
263
- "-3'm",
264
- '-3m',
265
- 'D3d(C3v)',
266
- [operation(ROT3_Z), operation(MIRROR_Y), primed(INVERSION)],
267
- [SAME, ROT30_Z],
268
- 2,
269
- ),
270
- blackWhite("6'", '6', 'C6(C3)', [primed(ROT6_Z)], [SAME]),
271
- blackWhite("-6'", '-6', 'C3h(C3)', [primed(ROTINV6_Z)], [SAME]),
272
- blackWhite("6'/m'", '6/m', 'C6h(C3i)', [primed(ROT6_Z), operation(INVERSION)], [SAME]),
273
- blackWhite("6/m'", '6/m', 'C6h(C6)', [operation(ROT6_Z), primed(INVERSION)], [SAME]),
274
- blackWhite("6'/m", '6/m', 'C6h(C3h)', [primed(ROT6_Z), primed(INVERSION)], [SAME]),
275
- blackWhite("6'22'", '622', 'D6(D3)', [primed(ROT6_Z), operation(ROT2_Y)], [SAME, ROT30_Z], 2),
276
- blackWhite("62'2'", '622', 'D6(C6)', [operation(ROT6_Z), primed(ROT2_Y)], [SAME]),
277
- blackWhite("6'mm'", '6mm', 'C6v(C3v)', [primed(ROT6_Z), operation(MIRROR_Y)], [SAME, ROT30_Z], 2),
278
- blackWhite("6m'm'", '6mm', 'C6v(C6)', [operation(ROT6_Z), primed(MIRROR_Y)], [SAME]),
279
- blackWhite("-6'2m'", '-6m2', 'D3h(D3)', [primed(ROTINV6_Z), operation(ROT2_Y)], [SAME, ROT30_Z], 2),
280
- blackWhite("-6'm2'", '-6m2', 'D3h(C3v)', [primed(ROTINV6_Z), operation(MIRROR_Y)], [SAME, ROT30_Z], 2),
281
- blackWhite("-6m'2'", '-6m2', 'D3h(C3h)', [operation(ROTINV6_Z), primed(MIRROR_Y)], [SAME, ROT30_Z], 2),
282
- blackWhite(
283
- "6'/m'mm'",
284
- '6/mmm',
285
- 'D6h(D3d)',
286
- [primed(ROT6_Z), operation(ROT2_Y), operation(INVERSION)],
287
- [SAME, ROT30_Z],
288
- 2,
289
- ),
290
- blackWhite("6/mm'm'", '6/mmm', 'D6h(C6h)', [operation(ROT6_Z), operation(INVERSION), primed(ROT2_Y)], [SAME]),
291
- blackWhite("6/m'm'm'", '6/mmm', 'D6h(D6)', [operation(ROT6_Z), operation(ROT2_Y), primed(INVERSION)], [SAME]),
292
- blackWhite("6/m'mm", '6/mmm', 'D6h(C6v)', [operation(ROT6_Z), operation(MIRROR_Y), primed(INVERSION)], [SAME]),
293
- blackWhite("6'/mmm'", '6/mmm', 'D6h(D3h)', [primed(ROT6_Z), operation(ROT2_Y), primed(INVERSION)], [SAME, ROT30_Z]),
294
- blackWhite(
295
- "m'-3'",
296
- 'm-3',
297
- 'Th(T)',
298
- [operation(ROT2_Z), operation(ROT2_X), operation(ROT3_111), primed(INVERSION)],
299
- [SAME],
300
- ),
301
- blackWhite(
302
- "4'32'",
303
- '432',
304
- 'O(T)',
305
- [operation(ROT2_Z), operation(ROT2_X), operation(ROT3_111), primed(ROT4_Z)],
306
- [SAME],
307
- ),
308
- blackWhite(
309
- "-4'3m'",
310
- '-43m',
311
- 'Td(T)',
312
- [operation(ROT2_Z), operation(ROT2_X), operation(ROT3_111), primed(ROTINV4_Z)],
313
- [SAME],
314
- ),
315
- blackWhite("m-3m'", 'm-3m', 'Oh(Th)', [operation(INVERSION), operation(ROT3_111), primed(ROT4_Z)], [SAME]),
316
- blackWhite("m'-3'm'", 'm-3m', 'Oh(O)', [operation(ROT4_Z), operation(ROT3_111), primed(INVERSION)], [SAME]),
317
- blackWhite("m'-3'm", 'm-3m', 'Oh(Td)', [operation(ROTINV4_Z), operation(ROT3_111), primed(INVERSION)], [SAME]),
318
- ];
319
-
320
- /** Schoenflies symbol of a grey group: that of its class with the subscript R (ITC Vol. D, Table 1.5.2.1). */
321
- export const greySchoenflies = (classSymbol: string): string => `${classSymbol}R`;
322
-
323
- /** The data of the crystal class with this key. */
324
- export function classData(key: PointGroupKey) {
325
- const d = POINT_GROUP_DATA.find((x) => x.key === key);
326
- if (!d) throw new RangeError(`Unknown crystal class: ${JSON.stringify(key)}`);
327
- return d;
328
- }
@@ -1,121 +0,0 @@
1
- /**
2
- * Snapping a point of the plane onto the nearest Wyckoff position of a plane group, by the distance
3
- * of the point to the position (#85; CLAUDE.md, "Snapping onto a Wyckoff position"). Unlike the site
4
- * symmetry (`positions.ts`), which asks whether the images of a point lie within a tolerance of it,
5
- * this asks whether the point lies within the tolerance of the point set of a position. Internal.
6
- */
7
-
8
- import { parseOperation, toPlain, type PlainOperation } from './affine.js';
9
- import { planeGroupEntry } from './planeGroups.js';
10
- import { EPSILON } from '../tolerances.js';
11
-
12
- /** The point set of one printed coordinate expression, x ↦ M·(x, y) + c, with the columns of M that are not zero. */
13
- interface Expression {
14
- readonly matrix: readonly (readonly number[])[];
15
- readonly translation: readonly number[];
16
- /** The number of free parameters: 0 for a point, 1 for a line, 2 for the general position. */
17
- readonly freedom: number;
18
- }
19
-
20
- const cache = new Map<string, readonly { row: number; expressions: Expression[] }[]>();
21
-
22
- function expression(op: PlainOperation, shift: readonly number[]): Expression {
23
- const m = op.matrix;
24
- const columns = [0, 1].filter((k) => m[0][k] !== 0 || m[1][k] !== 0);
25
- const det = m[0][0] * m[1][1] - m[0][1] * m[1][0];
26
- return {
27
- matrix: m,
28
- translation: [op.translation[0] + shift[0], op.translation[1] + shift[1]],
29
- freedom: columns.length === 2 && det === 0 ? 1 : columns.length,
30
- };
31
- }
32
-
33
- /** Per printed Wyckoff row (index into `wyckoff`), its coordinate expressions with every centring. */
34
- function positionsOf(symbol: string) {
35
- let rows = cache.get(symbol);
36
- if (!rows) {
37
- const entry = planeGroupEntry(symbol);
38
- const shifts = [[0, 0], ...entry.centring.map((t) => toPlain(parseOperation(t)).translation)];
39
- rows = entry.wyckoff.map(([, , , coordinates], row) => ({
40
- row,
41
- expressions: coordinates.flatMap((c) => shifts.map((s) => expression(toPlain(parseOperation(c)), s))),
42
- }));
43
- cache.set(symbol, rows);
44
- }
45
- return rows;
46
- }
47
-
48
- /**
49
- * The nearest point of the set of `e` to `p` modulo the lattice: the parameters by least squares in
50
- * the lattice coordinates, over the lattice translations that can reach it. Returns the point and
51
- * its distance, the larger of the two coordinate differences.
52
- */
53
- function nearest(e: Expression, p: readonly number[]): { point: number[]; distance: number } {
54
- if (e.freedom === 2) return { point: [...p], distance: 0 };
55
- const m = e.matrix;
56
- const c = e.translation;
57
- let best = { point: [0, 0], distance: Infinity };
58
- // c lies in [0, 2) (a printed coordinate in [0, 1) plus a centring), p in [0, 1).
59
- for (let i = -2; i <= 2; i++) {
60
- for (let j = -2; j <= 2; j++) {
61
- const v = [p[0] - c[0] - i, p[1] - c[1] - j];
62
- let r: number[];
63
- if (e.freedom === 0) {
64
- r = [0, 0];
65
- } else {
66
- const k = m[0][0] !== 0 || m[1][0] !== 0 ? 0 : 1;
67
- const col = [m[0][k], m[1][k]];
68
- const t = (col[0] * v[0] + col[1] * v[1]) / (col[0] * col[0] + col[1] * col[1]);
69
- r = [t * col[0], t * col[1]];
70
- }
71
- const distance = Math.max(Math.abs(r[0] - v[0]), Math.abs(r[1] - v[1]));
72
- if (distance < best.distance) best = { point: [r[0] + c[0] + i, r[1] + c[1] + j], distance };
73
- }
74
- }
75
- return best;
76
- }
77
-
78
- const mod1 = (v: number): number => {
79
- const r = v - Math.floor(v);
80
- return r >= 1 ? 0 : r + 0;
81
- };
82
-
83
- /** A point snapped onto a Wyckoff position: the index of the printed row and the point on it, in [0, 1). */
84
- export interface SnappedPoint {
85
- readonly row: number;
86
- readonly point: readonly number[];
87
- }
88
-
89
- /**
90
- * Snaps a point (lattice basis) onto the most special Wyckoff position of a plane group that lies
91
- * within `tolerance` of it (per coordinate, modulo the lattice): positions without a free parameter
92
- * first, then lines, then the general position, which always holds the point. Among positions with
93
- * the same number of free parameters the nearest wins. Throws a RangeError for a point that is not
94
- * two finite numbers or a tolerance outside (0, 1/2).
95
- */
96
- export function planeSnapToWyckoffPosition(
97
- key: string,
98
- point: readonly number[],
99
- tolerance: number = EPSILON,
100
- ): SnappedPoint {
101
- if (point.length !== 2 || !point.every(Number.isFinite)) {
102
- throw new RangeError(`A point of the plane has two finite coordinates, not ${JSON.stringify(point)}`);
103
- }
104
- if (!(typeof tolerance === 'number' && tolerance > 0 && tolerance < 0.5)) {
105
- throw new RangeError(`The tolerance must lie between 0 and 1/2, not ${String(tolerance)}`);
106
- }
107
- const p = point.map(mod1);
108
- const rows = positionsOf(planeGroupEntry(key).symbol);
109
- for (const freedom of [0, 1, 2]) {
110
- let best: { row: number; point: number[]; distance: number } | undefined;
111
- for (const { row, expressions } of rows) {
112
- for (const e of expressions) {
113
- if (e.freedom !== freedom) continue;
114
- const n = nearest(e, p);
115
- if (n.distance < tolerance && (!best || n.distance < best.distance)) best = { row, ...n };
116
- }
117
- }
118
- if (best) return { row: best.row, point: best.point.map(mod1) };
119
- }
120
- throw new Error(`The general position of ${key} does not hold ${JSON.stringify(point)}`);
121
- }