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,25 +1,26 @@
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 is, as ITA names the operations (ITA 2016 Table 2.1.2.1, p. 145): `'reflection'`
14
+ * (in a line, as `'reflection'` of the point groups) and `'glide-reflection'`.
14
15
  */
15
- export type PlaneOperationKind = 'identity' | 'translation' | 'rotation' | 'mirror' | 'glide';
16
+ export type PlaneOperationKind = 'identity' | 'translation' | 'rotation' | 'reflection' | 'glide-reflection';
16
17
 
17
18
  /** One operation of a plane group described geometrically, in the lattice basis. */
18
19
  export interface PlaneOperationDescription {
19
20
  /** What the operation is. */
20
21
  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;
22
+ /** The n of its linear part (an n-fold rotation): 1 for identity and translation, 2 for a reflection or glide reflection. */
23
+ readonly n: number;
23
24
  /** For a rotation with n ≥ 3: `'+'` if it turns a towards b, `'-'` otherwise. */
24
25
  readonly sense?: '+' | '-';
25
26
  /** For a translation: the translation vector. */
@@ -33,12 +34,14 @@ export interface PlaneOperationDescription {
33
34
  /** For a mirror or glide: the direction of its line, the shortest integer vector, first non-zero component positive. */
34
35
  readonly direction?: readonly [number, number];
35
36
  /**
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
37
+ * For a reflection or glide reflection: its axis, the normal of its line in the lattice basis (as
38
+ * the `axis` of a reflection of the point groups is the normal of its plane, #137 C3), its symmetry
39
+ * direction with the sign of its Seitz symbol (ITA 2016 Tables 1.4.2.4, 1.4.2.5, p. 53: `m₁₀`, `m₁₂`,
40
+ * #107, #114): the shortest integer vector along the columns of W − I, first non-zero component
41
+ * positive, which is the Seitz direction for every plane group (tested). Without a metric it is not the perpendicular of `direction`: in a
39
42
  * hexagonal basis the normal of a line along [1,0] is [1,2].
40
43
  */
41
- readonly normal?: readonly [number, number];
44
+ readonly axis?: readonly [number, number];
42
45
  /**
43
46
  * For a glide: the glide vector (w + W·w)/2, not reduced modulo the lattice. An operation whose
44
47
  * glide vector is a non-zero lattice vector is a glide, as it is geometrically, although the
@@ -89,12 +92,12 @@ export function describePlaneOperation(op: ExactOperation): PlaneOperationDescri
89
92
  if (det === 1) {
90
93
  const n = ORDER_BY_TRACE[trace(w)];
91
94
  if (n === undefined || !isIdentity(power(w, n))) {
92
- throw new RangeError(`Not a crystallographic rotation: ${JSON.stringify(w)}`);
95
+ throw new RangeError(`Not a crystallographic rotation: ${shown(w)}`);
93
96
  }
94
97
  if (n === 1) {
95
98
  return t.every((v) => v[0] === 0)
96
- ? { kind: 'identity', order: 1 }
97
- : { kind: 'translation', order: 1, translation: [...t] };
99
+ ? { kind: 'identity', n: 1 }
100
+ : { kind: 'translation', n: 1, translation: [...t] };
98
101
  }
99
102
  // The centre p solves (I − W) p = w; det(I − W) = 2 − trace W ≠ 0 for a rotation.
100
103
  const a = [
@@ -107,12 +110,12 @@ export function describePlaneOperation(op: ExactOperation): PlaneOperationDescri
107
110
  multiply(add(scale(a[1][1], t[0]), scale(-a[0][1], t[1])), inv),
108
111
  multiply(add(scale(-a[1][0], t[0]), scale(a[0][0], t[1])), inv),
109
112
  ];
110
- const description: PlaneOperationDescription = { kind: 'rotation', order: n, location: Object.freeze(location) };
113
+ const description: PlaneOperationDescription = { kind: 'rotation', n, location: Object.freeze(location) };
111
114
  // The sense: the sign of a × W·a with a = (1, 0), the same in any right-handed basis.
112
115
  return Object.freeze(n === 2 ? description : { ...description, sense: w[1][0] > 0 ? '+' : '-' });
113
116
  }
114
117
  if (det !== -1 || trace(w) !== 0 || !isIdentity(power(w, 2))) {
115
- throw new RangeError(`Not a crystallographic reflection: ${JSON.stringify(w)}`);
118
+ throw new RangeError(`Not a crystallographic reflection: ${shown(w)}`);
116
119
  }
117
120
  // 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
121
  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 +139,14 @@ export function describePlaneOperation(op: ExactOperation): PlaneOperationDescri
136
139
  const location: Rational[] =
137
140
  a[i][0] !== 0 ? [multiply(s[i], rational(1, a[i][0])), ZERO] : [ZERO, multiply(s[i], rational(1, a[i][1]))];
138
141
  const line = {
139
- order: 2,
142
+ n: 2,
140
143
  location: Object.freeze(location),
141
144
  direction: Object.freeze(direction),
142
- normal: Object.freeze(normal),
145
+ axis: Object.freeze(normal),
143
146
  };
144
147
  return Object.freeze(
145
148
  glide.some((v) => v[0] !== 0)
146
- ? { kind: 'glide' as const, ...line, glide: Object.freeze(glide) }
147
- : { kind: 'mirror' as const, ...line },
149
+ ? { kind: 'glide-reflection' as const, ...line, glide: Object.freeze(glide) }
150
+ : { kind: 'reflection' as const, ...line },
148
151
  );
149
152
  }
@@ -27,7 +27,7 @@ export interface PlaneGroupEntry {
27
27
  readonly system: PlaneSystem;
28
28
  /** Printed page. */
29
29
  readonly page: number;
30
- /** The block "Origin" as printed, e.g. `at 21g`. */
30
+ /** The block "Origin" as printed, its positions spaced, e.g. `at 2 1 g`. */
31
31
  readonly origin: string;
32
32
  /** The block "Asymmetric unit" as printed. */
33
33
  readonly asymmetricUnit: string;
@@ -135,7 +135,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
135
135
  pointGroup: '2mm',
136
136
  system: 'rectangular',
137
137
  page: 181,
138
- origin: 'at 2mm',
138
+ origin: 'at 2 m m',
139
139
  asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1/2',
140
140
  centring: [],
141
141
  generalPosition: ['x,y', '-x,-y', '-x,y', 'x,-y'],
@@ -159,7 +159,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
159
159
  pointGroup: '2mm',
160
160
  system: 'rectangular',
161
161
  page: 182,
162
- origin: 'at 21g',
162
+ origin: 'at 2 1 g',
163
163
  asymmetricUnit: '0 <= x <= 1/4; 0 <= y <= 1',
164
164
  centring: [],
165
165
  generalPosition: ['x,y', '-x,-y', '-x+1/2,y', 'x+1/2,-y'],
@@ -196,7 +196,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
196
196
  pointGroup: '2mm',
197
197
  system: 'rectangular',
198
198
  page: 184,
199
- origin: 'at 2mm',
199
+ origin: 'at 2 m m',
200
200
  asymmetricUnit: '0 <= x <= 1/4; 0 <= y <= 1/2',
201
201
  centring: ['1/2,1/2'],
202
202
  generalPosition: ['x,y', '-x,-y', '-x,y', 'x,-y'],
@@ -236,7 +236,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
236
236
  pointGroup: '4mm',
237
237
  system: 'square',
238
238
  page: 186,
239
- origin: 'at 4mm',
239
+ origin: 'at 4 m m',
240
240
  asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1/2; x <= y',
241
241
  centring: [],
242
242
  generalPosition: ['x,y', '-x,-y', '-y,x', 'y,-x', '-x,y', 'x,-y', 'y,x', '-y,-x'],
@@ -258,7 +258,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
258
258
  pointGroup: '4mm',
259
259
  system: 'square',
260
260
  page: 187,
261
- origin: 'at 41g',
261
+ origin: 'at 4 1 g',
262
262
  asymmetricUnit: '0 <= x <= 1/2; 0 <= y <= 1/2; y <= 1/2 - x',
263
263
  centring: [],
264
264
  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'],
@@ -297,7 +297,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
297
297
  pointGroup: '3m',
298
298
  system: 'hexagonal',
299
299
  page: 189,
300
- origin: 'at 3m1',
300
+ origin: 'at 3 m 1',
301
301
  asymmetricUnit: '0 <= x <= 2/3; 0 <= y <= 2/3; x <= 2y; y <= min(1 - x, 2x)',
302
302
  vertices: ['0,0', '2/3,1/3', '1/3,2/3'],
303
303
  centring: [],
@@ -318,7 +318,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
318
318
  pointGroup: '3m',
319
319
  system: 'hexagonal',
320
320
  page: 190,
321
- origin: 'at 31m',
321
+ origin: 'at 3 1 m',
322
322
  asymmetricUnit: '0 <= x <= 2/3; 0 <= y <= 1/2; x <= (1 + y)/2; y <= min(1 - x, x)',
323
323
  vertices: ['0,0', '1/2,0', '2/3,1/3', '1/2,1/2'],
324
324
  centring: [],
@@ -358,7 +358,7 @@ export const PLANE_GROUP_DATA: readonly PlaneGroupEntry[] = [
358
358
  pointGroup: '6mm',
359
359
  system: 'hexagonal',
360
360
  page: 192,
361
- origin: 'at 6mm',
361
+ origin: 'at 6 m m',
362
362
  asymmetricUnit: '0 <= x <= 2/3; 0 <= y <= 1/3; x <= (1 + y)/2; y <= x/2',
363
363
  vertices: ['0,0', '1/2,0', '2/3,1/3'],
364
364
  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
  }
@@ -2,21 +2,13 @@
2
2
  * Points of a plane group: their orbit, site symmetry and Wyckoff position (CLAUDE.md, "Plane
3
3
  * groups (and later space groups)"). Points come from callers as floating-point coordinates in the
4
4
  * lattice basis; whether an operation fixes a point is decided within a tolerance, as for the
5
- * point groups (`siteSymmetry`). Internal for now.
5
+ * point groups (`siteSymmetryOf`). Internal for now.
6
6
  */
7
7
 
8
+ import { shown } from '../checks.js';
8
9
  import { compose, equalModLattice, parseOperation, toPlain, type PlainOperation } from './affine.js';
9
10
  import { planeGroupEntry, planeGroupOperations } from './planeGroups.js';
10
- import { EPSILON } from '../tolerances.js';
11
-
12
- /** Options of the functions that take a point. */
13
- export interface PointOptions {
14
- /**
15
- * Two points count as the same, modulo the lattice, if each coordinate differs by less than this
16
- * from an integer (coordinates in the lattice basis). Default 10⁻⁶.
17
- */
18
- readonly tolerance?: number;
19
- }
11
+ import { toleranceOf, type ToleranceOptions } from '../tolerances.js';
20
12
 
21
13
  /** The site symmetry of a point under a plane group. */
22
14
  export interface PlaneSiteSymmetry {
@@ -49,18 +41,14 @@ export interface PlaneWyckoffPosition {
49
41
  readonly siteSymmetry: string;
50
42
  }
51
43
 
52
- function tolerance(options?: PointOptions): number {
53
- const t = options?.tolerance ?? EPSILON;
44
+ function tolerance(options?: ToleranceOptions): number {
54
45
  // Modulo the lattice two coordinates differ by at most 1/2, so a tolerance of 1/2 or more says nothing.
55
- if (!(typeof t === 'number' && t > 0 && t < 0.5)) {
56
- throw new RangeError(`The tolerance must lie between 0 and 1/2, not ${String(t)}`);
57
- }
58
- return t;
46
+ return toleranceOf(options, 'points');
59
47
  }
60
48
 
61
49
  function checkPoint(point: readonly number[]): void {
62
- if (point.length !== 2 || !point.every(Number.isFinite)) {
63
- throw new RangeError(`A point of the plane has two finite coordinates, not ${JSON.stringify(point)}`);
50
+ if (!Array.isArray(point) || point.length !== 2 || !point.every((x) => typeof x === 'number' && Number.isFinite(x))) {
51
+ throw new RangeError(`A point of the plane has two finite coordinates, not ${shown(point)}`);
64
52
  }
65
53
  }
66
54
 
@@ -114,18 +102,28 @@ function groupData(key: string): GroupData {
114
102
  const plainOperations = (key: string): readonly PlainOperation[] => groupData(key).ops;
115
103
 
116
104
  /**
117
- * The orbit of a point under a plane group: its distinct images in the conventional cell, each in
118
- * [0, 1), in the order of the operations that first produce them. Coinciding images (within the
119
- * tolerance) are merged.
105
+ * The orbit of a point under a plane group: the images of the point set onto its Wyckoff position
106
+ * (`planeSiteOfPosition`), each in [0, 1), in the order of the operations that first produce them,
107
+ * with the operations that map the point there: one entry per coset of the site symmetry.
120
108
  */
121
- export function planeOrbit(key: string, point: readonly number[], options?: PointOptions): number[][] {
122
- checkPoint(point);
123
- const tol = tolerance(options);
124
- const out: number[][] = [];
125
- for (const op of plainOperations(key)) {
126
- const q = image(op, point).map(mod1);
127
- if (!out.some((r) => sameModLattice(r, q, tol))) out.push(q);
128
- }
109
+ export function planeOrbit(
110
+ key: string,
111
+ point: readonly number[],
112
+ options?: ToleranceOptions,
113
+ ): { point: number[]; operations: number[] }[] {
114
+ // The point is first set onto its Wyckoff position (#137 F1), and the entries are the left cosets
115
+ // g·H of its site symmetry H: merging images by a distance is not transitive and depends on a
116
+ // threshold (reviews of #153 and of step 10a).
117
+ const site = planeSiteOfPosition(key, point, options);
118
+ const { ops, table } = groupData(key);
119
+ const done = new Set<number>();
120
+ const out: { point: number[]; operations: number[] }[] = [];
121
+ ops.forEach((op, i) => {
122
+ if (done.has(i)) return;
123
+ const coset = [...new Set(site.operations.map((h) => table[i][h]))].sort((a, b) => a - b);
124
+ for (const j of coset) done.add(j);
125
+ out.push({ point: image(op, site.point).map(mod1), operations: coset });
126
+ });
129
127
  return out;
130
128
  }
131
129
 
@@ -160,11 +158,15 @@ function fixingOperations(ops: readonly PlainOperation[], indices: readonly numb
160
158
  /**
161
159
  * The site symmetry of a point under a plane group. The operations that fix the point modulo the
162
160
  * lattice within the tolerance are closed under products and the point is set onto the fixed space
163
- * of the closure (the mean of its images), repeated until stable, as `siteSymmetry` does for the point
161
+ * of the closure (the mean of its images), repeated until stable, as `siteSymmetryOf` does for the point
164
162
  * groups; so the result is always a subgroup and the set point lies exactly on its elements. Throws a
165
163
  * RangeError if that does not settle (a tolerance far too large).
166
164
  */
167
- export function planeSiteSymmetry(key: string, point: readonly number[], options?: PointOptions): PlaneSiteSymmetry {
165
+ export function planeSiteSymmetry(
166
+ key: string,
167
+ point: readonly number[],
168
+ options?: ToleranceOptions,
169
+ ): PlaneSiteSymmetry {
168
170
  checkPoint(point);
169
171
  const tol = tolerance(options);
170
172
  const ops = plainOperations(key);
@@ -190,7 +192,7 @@ export function planeSiteSymmetry(key: string, point: readonly number[], options
190
192
  set = next;
191
193
  }
192
194
  throw new RangeError(
193
- `No common fixed point for the operations fixing ${JSON.stringify(point)} within ${tol} (tolerance too large?)`,
195
+ `No common fixed point for the operations fixing ${shown(point)} within ${tol} (tolerance too large?)`,
194
196
  );
195
197
  }
196
198
 
@@ -205,63 +207,185 @@ function parsed(expression: string): PlainOperation {
205
207
  return op;
206
208
  }
207
209
 
210
+ /** The distance of a point to one printed Wyckoff position, and the nearest point of the position. */
211
+ export interface PositionDistance {
212
+ /** The index of the position in the printed order (`entry.wyckoff`). */
213
+ readonly row: number;
214
+ /** The nearest point of the position's point set, in [0, 1). */
215
+ readonly point: number[];
216
+ /** The distance: per lattice coordinate without a basis, Euclidean with one. */
217
+ readonly distance: number;
218
+ }
219
+
220
+ /** The free directions of a printed coordinate expression (the columns of W that are not zero, independent ones). */
221
+ function freeDirections(op: PlainOperation): number[][] {
222
+ const cols = [0, 1].map((k) => [op.matrix[0][k], op.matrix[1][k]]).filter((v) => v[0] !== 0 || v[1] !== 0);
223
+ if (cols.length === 2 && Math.abs(cols[0][0] * cols[1][1] - cols[0][1] * cols[1][0]) < 1e-12) return [cols[0]];
224
+ return cols;
225
+ }
226
+
208
227
  /**
209
- * True if some parameters x, y make the printed coordinate expression (e.g. `x,2x`, `-x+1/2,y`) give
210
- * the point modulo the lattice within `tol`: least squares over the nearby lattice translations.
228
+ * The smallest distance of r to a multiple of v, and the multiple: in the metric G (Euclidean with
229
+ * a basis, by projection) or per coordinate (the largest of the two components; the minimum over t
230
+ * of max(|r₁ − t v₁|, |r₂ − t v₂|) lies where a component vanishes or the two are equal).
211
231
  */
212
- function onExpression(expression: string, p: readonly number[], tol: number): boolean {
213
- const { matrix, translation } = parsed(expression);
214
- const c = translation;
215
- const ex = [matrix[0][0], matrix[1][0]];
216
- const ey = [matrix[0][1], matrix[1][1]];
217
- for (let i = -2; i <= 2; i++) {
218
- for (let j = -2; j <= 2; j++) {
219
- const r = [p[0] - c[0] - i, p[1] - c[1] - j];
220
- // Solve min |a·ex + b·ey − r| over the columns that are not zero.
221
- const cols = [ex, ey].filter((v) => v[0] !== 0 || v[1] !== 0);
222
- let fit = [0, 0];
223
- if (cols.length === 1) {
224
- const v = cols[0];
225
- const t = (v[0] * r[0] + v[1] * r[1]) / (v[0] * v[0] + v[1] * v[1]);
226
- fit = [t * v[0], t * v[1]];
227
- } else if (cols.length === 2) {
228
- const det = ex[0] * ey[1] - ex[1] * ey[0];
229
- if (Math.abs(det) < 1e-12) {
230
- const v = ex;
231
- const t = (v[0] * r[0] + v[1] * r[1]) / (v[0] * v[0] + v[1] * v[1]);
232
- fit = [t * v[0], t * v[1]];
233
- } else {
234
- fit = r;
232
+ function nearestOnLine(r: readonly number[], v: readonly number[], g: Mat2 | undefined): { t: number; d: number } {
233
+ if (g) {
234
+ const gv = [g[0][0] * v[0] + g[0][1] * v[1], g[1][0] * v[0] + g[1][1] * v[1]];
235
+ const t = (r[0] * gv[0] + r[1] * gv[1]) / (v[0] * gv[0] + v[1] * gv[1]);
236
+ return { t, d: norm([r[0] - t * v[0], r[1] - t * v[1]], g) };
237
+ }
238
+ const candidates: number[] = [];
239
+ if (v[0] !== 0) candidates.push(r[0] / v[0]);
240
+ if (v[1] !== 0) candidates.push(r[1] / v[1]);
241
+ if (v[0] !== v[1]) candidates.push((r[0] - r[1]) / (v[0] - v[1]));
242
+ if (v[0] !== -v[1]) candidates.push((r[0] + r[1]) / (v[0] + v[1]));
243
+ let best = { t: 0, d: Infinity };
244
+ for (const t of candidates) {
245
+ const d = norm([r[0] - t * v[0], r[1] - t * v[1]], undefined);
246
+ if (d < best.d) best = { t, d };
247
+ }
248
+ return best;
249
+ }
250
+
251
+ type Mat2 = readonly (readonly number[])[];
252
+
253
+ /** The length of a vector of lattice coordinates: per coordinate (the larger component) or in the metric G. */
254
+ function norm(r: readonly number[], g: Mat2 | undefined): number {
255
+ if (!g) return Math.max(Math.abs(r[0]), Math.abs(r[1]));
256
+ return Math.sqrt(Math.max(0, r[0] * (g[0][0] * r[0] + g[0][1] * r[1]) + r[1] * (g[1][0] * r[0] + g[1][1] * r[1])));
257
+ }
258
+
259
+ /** The metric tensor G = BᵀB of a basis (columns a, b), checked: two rows of two finite numbers, not singular. */
260
+ export function planeMetric(basis: unknown): Mat2 {
261
+ const ok =
262
+ Array.isArray(basis) &&
263
+ basis.length === 2 &&
264
+ basis.every(
265
+ (row) => Array.isArray(row) && row.length === 2 && row.every((x) => typeof x === 'number' && Number.isFinite(x)),
266
+ );
267
+ const b = basis as Mat2;
268
+ // Singular if V/(ab) is below 10⁻⁹, computed with the columns scaled to unit length so that no
269
+ // product overflows or underflows (review of step 10a).
270
+ const na = ok ? Math.hypot(b[0][0], b[1][0]) : 0;
271
+ const nb = ok ? Math.hypot(b[0][1], b[1][1]) : 0;
272
+ const ratio = na > 0 && nb > 0 ? (b[0][0] / na) * (b[1][1] / nb) - (b[0][1] / nb) * (b[1][0] / na) : 0;
273
+ if (!ok || !(Math.abs(ratio) > 1e-9)) {
274
+ throw new RangeError(
275
+ `The basis of a plane lattice is a non-singular 2 × 2 matrix (columns a, b), not ${shown(basis)}`,
276
+ );
277
+ }
278
+ const col = (k: number) => [b[0][k], b[1][k]];
279
+ const dot = (u: number[], w: number[]) => u[0] * w[0] + u[1] * w[1];
280
+ return [
281
+ [dot(col(0), col(0)), dot(col(0), col(1))],
282
+ [dot(col(1), col(0)), dot(col(1), col(1))],
283
+ ];
284
+ }
285
+
286
+ /**
287
+ * The distance of a point (lattice basis) to every printed Wyckoff position of a plane group, in
288
+ * printed order, with the nearest point of each: the point set of a position is the union of its
289
+ * printed coordinate expressions with every centring and lattice translation, a point, a line or
290
+ * the plane. Without a metric the distance is the larger of the two coordinate differences, with
291
+ * one (G = BᵀB) Euclidean.
292
+ */
293
+ export function planeWyckoffDistances(key: string, given: readonly number[], g?: Mat2): PositionDistance[] {
294
+ checkPoint(given);
295
+ // Modulo the lattice first, so that large coordinates keep their digits (review of step 10a).
296
+ const point = given.map(mod1);
297
+ const entry = planeGroupEntry(key);
298
+ const centrings = [[0, 0], ...entry.centring.map((t) => parsed(t).translation)];
299
+ return entry.wyckoff.map(([, , , coordinates], row) => {
300
+ let best = { point: [...point], distance: Infinity };
301
+ for (const expression of coordinates) {
302
+ const op = parsed(expression);
303
+ const free = freeDirections(op);
304
+ for (const shift of centrings) {
305
+ const c = [op.translation[0] + shift[0], op.translation[1] + shift[1]];
306
+ if (free.length === 2) {
307
+ best = { point: [...point], distance: 0 };
308
+ continue;
309
+ }
310
+ const base = [Math.round(point[0] - c[0]), Math.round(point[1] - c[1])];
311
+ for (let i = -2; i <= 2; i++) {
312
+ for (let j = -2; j <= 2; j++) {
313
+ const origin = [c[0] + base[0] + i, c[1] + base[1] + j];
314
+ const r = [point[0] - origin[0], point[1] - origin[1]];
315
+ const { t, d } = free.length === 1 ? nearestOnLine(r, free[0], g) : { t: 0, d: norm(r, g) };
316
+ if (d < best.distance) {
317
+ const v = free.length === 1 ? free[0] : [0, 0];
318
+ best = { point: [origin[0] + t * v[0], origin[1] + t * v[1]], distance: d };
319
+ }
320
+ }
235
321
  }
236
322
  }
237
- if (Math.abs(fit[0] - r[0]) < tol && Math.abs(fit[1] - r[1]) < tol) return true;
238
323
  }
324
+ return { row, point: best.point.map(mod1), distance: best.distance };
325
+ });
326
+ }
327
+
328
+ /**
329
+ * The Wyckoff position a point lies on within the tolerance (#137 F1): the most special printed
330
+ * position (the smallest multiplicity) whose point set lies within the tolerance of the point,
331
+ * measured per coordinate modulo the lattice, the nearest among positions of equal multiplicity;
332
+ * the general position always holds the point. Returns the row and the nearest point on it.
333
+ */
334
+ export function planePosition(key: string, point: readonly number[], options?: ToleranceOptions): PositionDistance {
335
+ const tol = tolerance(options);
336
+ const entry = planeGroupEntry(key);
337
+ const within = planeWyckoffDistances(key, point).filter((d) => d.distance < tol);
338
+ within.sort((a, b) => entry.wyckoff[a.row][0] - entry.wyckoff[b.row][0] || a.distance - b.distance);
339
+ return within[0];
340
+ }
341
+
342
+ /**
343
+ * The site symmetry of a point under a plane group, as one notion with its Wyckoff position
344
+ * (#137 F1): the point is set onto the position it lies on within the tolerance (`planePosition`),
345
+ * and the site symmetry is that of the point there.
346
+ */
347
+ export function planeSiteOfPosition(
348
+ key: string,
349
+ point: readonly number[],
350
+ options?: ToleranceOptions,
351
+ ): PlaneSiteSymmetry {
352
+ const { row, point: onPosition } = planePosition(key, point, options);
353
+ const multiplicity = planeGroupEntry(key).wyckoff[row][0];
354
+ // The site symmetry follows from the position, not from a second tolerance (review of step 10a):
355
+ // the point lies on it, so its |G|/multiplicity operations are those whose images of the point
356
+ // lie nearest to it (all of them at rounding distance).
357
+ const ops = plainOperations(key);
358
+ const order = ops.length / multiplicity;
359
+ const offset = (op: PlainOperation) =>
360
+ Math.max(
361
+ ...image(op, onPosition).map((v, k) => {
362
+ const d = v - onPosition[k];
363
+ return Math.abs(d - Math.round(d));
364
+ }),
365
+ );
366
+ const indices = ops
367
+ .map((op, i) => ({ i, d: offset(op) }))
368
+ .sort((a, b) => a.d - b.d || a.i - b.i)
369
+ .slice(0, order)
370
+ .map((e) => e.i)
371
+ .sort((a, b) => a - b);
372
+ const { table } = groupData(key);
373
+ if (!indices.every((a) => indices.every((b) => indices.includes(table[a][b])))) {
374
+ throw new Error(`${key}: the operations nearest to fixing ${shown(onPosition)} on position ${row} form no group`);
239
375
  }
240
- return false;
376
+ return { operations: indices, fixing: fixingOperations(ops, indices, onPosition), point: onPosition, multiplicity };
241
377
  }
242
378
 
243
379
  /**
244
- * The Wyckoff position of a point under a plane group, as ITA prints it: the point is first set
245
- * onto the fixed space of its site symmetry (`planeSiteSymmetry`), then found among the printed
246
- * coordinates of the positions with its multiplicity, the centring included.
380
+ * The Wyckoff position of a point under a plane group, as ITA prints it: the position it lies on
381
+ * within the tolerance (`planePosition`).
247
382
  */
248
383
  export function planeWyckoffPositionOf(
249
384
  key: string,
250
385
  point: readonly number[],
251
- options?: PointOptions,
386
+ options?: ToleranceOptions,
252
387
  ): PlaneWyckoffPosition {
253
- const tol = tolerance(options);
254
- const site = planeSiteSymmetry(key, point, options);
255
- const entry = planeGroupEntry(key);
256
- const centrings = [[0, 0], ...entry.centring.map((t) => parsed(t).translation)];
257
- for (const [multiplicity, letter, siteSymmetry, coordinates] of entry.wyckoff) {
258
- if (multiplicity !== site.multiplicity) continue;
259
- for (const t of centrings) {
260
- const shifted = [site.point[0] - t[0], site.point[1] - t[1]];
261
- if (coordinates.some((expression) => onExpression(expression, shifted, tol))) {
262
- return { letter, multiplicity, siteSymmetry };
263
- }
264
- }
265
- }
266
- throw new RangeError(`No Wyckoff position of ${entry.symbol} holds the point ${JSON.stringify(point)}`);
388
+ const { row } = planePosition(key, point, options);
389
+ const [multiplicity, letter, siteSymmetry] = planeGroupEntry(key).wyckoff[row];
390
+ return { letter, multiplicity, siteSymmetry };
267
391
  }
@@ -5,6 +5,7 @@
5
5
  * name up here (docs/conventions.md, "Named tensor properties").
6
6
  */
7
7
 
8
+ import { shown } from '../checks.js';
8
9
  import type { TensorSpec } from './tensorForm.js';
9
10
 
10
11
  /** A named property: the tensor that describes it, what it is and where it is defined. */
@@ -29,43 +30,49 @@ const property = (spec: TensorSpec, description: string, source: string): Tensor
29
30
  export const TENSOR_PROPERTIES = Object.freeze({
30
31
  /** Spontaneous polarization: a time-even polar vector. */
31
32
  pyroelectric: property(
32
- { rank: 1, parity: 'polar', timeParity: 'i', intrinsic: 'none' },
33
+ { rank: 1, kind: 'polar', timeParity: 'even', intrinsic: 'none' },
33
34
  'Spontaneous electric polarization, which changes with temperature: a polar vector p_i.',
34
35
  'ITC Vol. D (2013), § 1.1.4.4.2, p. 12; classes: ITA (2016) Table 3.2.2.1, p. 738',
35
36
  ),
36
- /** Ferroaxial order: a time-even axial vector. */
37
+ /** Ferroaxial order: a time-even axial vector (not a term of ITC). */
37
38
  ferroaxial: property(
38
- { rank: 1, parity: 'axial', timeParity: 'i', intrinsic: 'none' },
39
- 'Ferroaxial (ferro-rotational) order, e.g. a net rotation of structural units about an axis: an axial vector A_i.',
40
- 'Hlinka, Privratska, Ondrejkovic & Janovec, Phys. Rev. Lett. 116, 177602 (2016); classes: Birss (1966), Tables 4a and 4c, pp. 56–58',
39
+ { rank: 1, kind: 'axial', timeParity: 'even', intrinsic: 'none' },
40
+ 'Ferroaxial (ferro-rotational) order, e.g. a net rotation of structural units about an axis: an axial vector A_i, the axial toroidal moment (Jahn symbol eV).',
41
+ 'Not in ITC: Hlinka, Privratska, Ondrejkovic & Janovec, Phys. Rev. Lett. 116, 177602 (2016); Gallego et al., Acta Cryst. A75, 438 (2019), p. 440 (axial toroidal moment, type eV); classes: Birss (1966), Tables 4a and 4c, pp. 56–58',
41
42
  ),
42
43
  /** The piezoelectric effect (and second-harmonic generation, which has the same tensor): polar, rank 3, symmetric in j, k. */
43
44
  piezoelectric: property(
44
- { rank: 3, parity: 'polar', timeParity: 'i', intrinsic: 'jk' },
45
+ { rank: 3, kind: 'polar', timeParity: 'even', intrinsic: 'symmetric-last-pair' },
45
46
  'Electric polarization linear in stress, P_i = d_ijk T_jk: a polar tensor of rank 3, symmetric in j, k.',
46
47
  'ITC Vol. D (2013), § 1.1.4.4.3, p. 12, and § 1.1.4.10.1, eqs. (1.1.4.5), (1.1.4.7), p. 24; classes: ITA (2016) Table 3.2.2.1, p. 738',
47
48
  ),
48
49
  /** Optical activity: the symmetric axial tensor of rank 2. */
49
50
  gyrotropic: property(
50
- { rank: 2, parity: 'axial', timeParity: 'i', intrinsic: 'ij' },
51
+ { rank: 2, kind: 'axial', timeParity: 'even', intrinsic: 'symmetric-first-pair' },
51
52
  'Optical activity (optical rotation), G = g_ij α_i α_j: the symmetric part of the axial gyration tensor of rank 2.',
52
53
  'ITC Vol. D (2013), § 1.1.4.10.7.2, p. 30; classes: ITA (2016) Table 3.2.2.1, p. 738',
53
54
  ),
54
55
  /** Spontaneous magnetization: a time-odd axial vector (magnetic API only). */
55
56
  ferromagnetic: property(
56
- { rank: 1, parity: 'axial', timeParity: 'c', intrinsic: 'none' },
57
+ { rank: 1, kind: 'axial', timeParity: 'odd', intrinsic: 'none' },
57
58
  'Spontaneous magnetization M_s (ferromagnets, ferrimagnets, weak ferromagnets): an axial vector that changes sign under time reversal.',
58
59
  'ITC Vol. D (2013), § 1.5.2.1 with Table 1.5.2.4, p. 113',
59
60
  ),
61
+ /** A spontaneous toroidal moment: a time-odd polar vector (magnetic API only). */
62
+ ferrotoroidic: property(
63
+ { rank: 1, kind: 'polar', timeParity: 'odd', intrinsic: 'none' },
64
+ 'Spontaneous toroidal moment T_i (ferrotoroidic order): a polar vector that changes sign under time reversal (Jahn symbol aV); allowed exactly where the magnetoelectric tensor need not be symmetric.',
65
+ 'ITC Vol. D (2013), § 1.5.4.3, p. 128 (the term), and § 1.5.8.1, footnote 3, p. 140 (the 31 groups of Table 1.5.8.1 whose magnetoelectric tensor need not be symmetric); Gallego et al., Acta Cryst. A75, 438 (2019), p. 440 (polar toroidal moment, type aV)',
66
+ ),
60
67
  /** The linear magnetoelectric effect: a time-odd axial tensor of rank 2 (magnetic API only). */
61
68
  magnetoelectric: property(
62
- { rank: 2, parity: 'axial', timeParity: 'c', intrinsic: 'none' },
69
+ { rank: 2, kind: 'axial', timeParity: 'odd', intrinsic: 'none' },
63
70
  'Linear magnetoelectric effect, P_i = α_ij H_j: an axial tensor of rank 2 that changes sign under time reversal.',
64
71
  'ITC Vol. D (2013), § 1.5.8, eqs. (1.5.8.2), (1.5.8.3), p. 139, and § 1.5.8.1 with Table 1.5.8.1, pp. 139–140',
65
72
  ),
66
73
  /** The piezomagnetic effect: a time-odd axial tensor of rank 3, symmetric in j, k (magnetic API only). */
67
74
  piezomagnetic: property(
68
- { rank: 3, parity: 'axial', timeParity: 'c', intrinsic: 'jk' },
75
+ { rank: 3, kind: 'axial', timeParity: 'odd', intrinsic: 'symmetric-last-pair' },
69
76
  'Magnetization linear in stress, M_i = Λ_ijk T_jk: an axial tensor of rank 3, symmetric in j, k, that changes sign under time reversal.',
70
77
  'ITC Vol. D (2013), § 1.5.7, eq. (1.5.7.2), and § 1.5.7.1 with Table 1.5.7.1, pp. 134–135',
71
78
  ),
@@ -79,11 +86,16 @@ export const TENSOR_PROPERTY_NAMES = Object.freeze(Object.keys(TENSOR_PROPERTIES
79
86
 
80
87
  /** The specification behind a property name; a specification is returned as it is. */
81
88
  export function specOf(specOrName: TensorSpec | TensorPropertyName): TensorSpec {
82
- if (typeof specOrName !== 'string') return specOrName;
89
+ if (typeof specOrName !== 'string') {
90
+ if (typeof specOrName !== 'object' || specOrName === null || Array.isArray(specOrName)) {
91
+ throw new RangeError(
92
+ `A tensor is given by its specification { rank, kind, timeParity, intrinsic } or the name of a property, not ${shown(specOrName)}`,
93
+ );
94
+ }
95
+ return specOrName;
96
+ }
83
97
  if (!Object.hasOwn(TENSOR_PROPERTIES, specOrName)) {
84
- throw new RangeError(
85
- `Unknown tensor property: ${JSON.stringify(specOrName)} (known: ${TENSOR_PROPERTY_NAMES.join(', ')})`,
86
- );
98
+ throw new RangeError(`Unknown tensor property: ${shown(specOrName)} (known: ${TENSOR_PROPERTY_NAMES.join(', ')})`);
87
99
  }
88
100
  return TENSOR_PROPERTIES[specOrName].spec;
89
101
  }