symcrys 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/coordinates.d.ts +143 -0
- package/dist/coordinates.d.ts.map +1 -0
- package/dist/coordinates.js +198 -0
- package/dist/coordinates.js.map +1 -0
- package/dist/crystalClasses.d.ts +28 -3
- package/dist/crystalClasses.d.ts.map +1 -1
- package/dist/crystalClasses.js +32 -3
- package/dist/crystalClasses.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/indices.d.ts +3 -19
- package/dist/indices.d.ts.map +1 -1
- package/dist/indices.js +3 -24
- package/dist/indices.js.map +1 -1
- package/dist/magnetic.d.ts +3 -1
- package/dist/magnetic.d.ts.map +1 -1
- package/dist/magnetic.js +3 -1
- package/dist/magnetic.js.map +1 -1
- package/dist/plane.d.ts +158 -3
- package/dist/plane.d.ts.map +1 -1
- package/dist/plane.js +166 -41
- package/dist/plane.js.map +1 -1
- package/dist/pointGroups/pointGroups.d.ts +15 -6
- package/dist/pointGroups/pointGroups.d.ts.map +1 -1
- package/dist/pointGroups/pointGroups.js +52 -5
- package/dist/pointGroups/pointGroups.js.map +1 -1
- package/dist/pointGroups/shubnikovData.d.ts +11 -0
- package/dist/pointGroups/shubnikovData.d.ts.map +1 -0
- package/dist/pointGroups/shubnikovData.js +101 -0
- package/dist/pointGroups/shubnikovData.js.map +1 -0
- package/dist/spaceGroups/describe.d.ts +3 -2
- package/dist/spaceGroups/describe.d.ts.map +1 -1
- package/dist/spaceGroups/describe.js.map +1 -1
- package/dist/spaceGroups/planeGroupData.d.ts +2 -0
- package/dist/spaceGroups/planeGroupData.d.ts.map +1 -1
- package/dist/spaceGroups/planeGroupData.js +17 -0
- package/dist/spaceGroups/planeGroupData.js.map +1 -1
- package/dist/spaceGroups/planeLattice.d.ts +78 -0
- package/dist/spaceGroups/planeLattice.d.ts.map +1 -0
- package/dist/spaceGroups/planeLattice.js +143 -0
- package/dist/spaceGroups/planeLattice.js.map +1 -0
- package/dist/spaceGroups/planePointGroups.d.ts +6 -2
- package/dist/spaceGroups/planePointGroups.d.ts.map +1 -1
- package/dist/spaceGroups/planePointGroups.js +14 -2
- package/dist/spaceGroups/planePointGroups.js.map +1 -1
- package/dist/spaceGroups/rational.d.ts +18 -0
- package/dist/spaceGroups/rational.d.ts.map +1 -1
- package/dist/spaceGroups/rational.js +58 -0
- package/dist/spaceGroups/rational.js.map +1 -1
- package/dist/tensors/voigt.d.ts +56 -0
- package/dist/tensors/voigt.d.ts.map +1 -0
- package/dist/tensors/voigt.js +188 -0
- package/dist/tensors/voigt.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/coordinates.ts +370 -0
- package/src/crystalClasses.ts +42 -3
- package/src/index.ts +12 -2
- package/src/indices.ts +3 -33
- package/src/magnetic.ts +10 -2
- package/src/plane.ts +302 -48
- package/src/pointGroups/pointGroups.ts +58 -6
- package/src/pointGroups/shubnikovData.ts +103 -0
- package/src/spaceGroups/describe.ts +3 -2
- package/src/spaceGroups/planeGroupData.ts +19 -0
- package/src/spaceGroups/planeLattice.ts +208 -0
- package/src/spaceGroups/planePointGroups.ts +23 -3
- package/src/spaceGroups/rational.ts +59 -0
- package/src/tensors/voigt.ts +268 -0
- package/src/version.ts +1 -1
package/src/plane.ts
CHANGED
|
@@ -11,10 +11,25 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { TOLERANCE_KEYS, checkOptions, shown } from './checks.js';
|
|
14
|
-
import { describePlaneOperation } from './spaceGroups/describe.js';
|
|
14
|
+
import { describePlaneOperation, type PlaneOperationKind } from './spaceGroups/describe.js';
|
|
15
15
|
import { planeAsymmetricUnit, planeElements, planeElementsInBox } from './spaceGroups/cell.js';
|
|
16
16
|
import { toPlain, type ExactOperation } from './spaceGroups/affine.js';
|
|
17
17
|
import { type PlaneSystem } from './spaceGroups/planeGroupData.js';
|
|
18
|
+
import {
|
|
19
|
+
PLANE_FAMILIES,
|
|
20
|
+
planeBravaisLattice,
|
|
21
|
+
planeLatticeFromParameters,
|
|
22
|
+
planeLatticeParameters,
|
|
23
|
+
planeLaueClass,
|
|
24
|
+
planeMetricTensor,
|
|
25
|
+
planeReciprocalBasis,
|
|
26
|
+
type CellRestrictions,
|
|
27
|
+
type LatticeParameters,
|
|
28
|
+
type Mat2,
|
|
29
|
+
type PlaneBravaisLattice,
|
|
30
|
+
} from './spaceGroups/planeLattice.js';
|
|
31
|
+
import { deepFreeze } from './freeze.js';
|
|
32
|
+
import { changeCoordinates } from './coordinates.js';
|
|
18
33
|
import {
|
|
19
34
|
PLANE_GROUP_KEYS as GROUP_KEYS,
|
|
20
35
|
planeGroupEntry,
|
|
@@ -39,12 +54,22 @@ import {
|
|
|
39
54
|
planeWyckoffDistances,
|
|
40
55
|
planeWyckoffPositionOf,
|
|
41
56
|
} from './spaceGroups/positions.js';
|
|
42
|
-
import {
|
|
57
|
+
import { nearestFraction, parseRational, toNumber, type Rational } from './spaceGroups/rational.js';
|
|
43
58
|
|
|
44
59
|
export { VERSION } from './version.js';
|
|
45
60
|
export { EPSILON, type ToleranceOptions } from './tolerances.js';
|
|
46
61
|
import { toleranceOf, type ToleranceOptions } from './tolerances.js';
|
|
62
|
+
import { compactSymbol } from './notation.js';
|
|
47
63
|
export type { PlaneSystem } from './spaceGroups/planeGroupData.js';
|
|
64
|
+
export type {
|
|
65
|
+
CellRestrictions,
|
|
66
|
+
LatticeParameters,
|
|
67
|
+
Mat2,
|
|
68
|
+
PlaneBravaisLattice,
|
|
69
|
+
PlaneCellParameter,
|
|
70
|
+
PlaneFixedAngles,
|
|
71
|
+
} from './spaceGroups/planeLattice.js';
|
|
72
|
+
export type { PlaneOperationKind } from './spaceGroups/describe.js';
|
|
48
73
|
|
|
49
74
|
/** The short symbol of a plane group, e.g. `'p2mg'`. */
|
|
50
75
|
export type PlaneGroupKey =
|
|
@@ -77,8 +102,12 @@ export const POINT_GROUP_KEYS: readonly PointGroupKey[] = Object.freeze([...PLAN
|
|
|
77
102
|
|
|
78
103
|
/** Options that choose the setting of a plane point group. */
|
|
79
104
|
export interface SettingOptions {
|
|
80
|
-
/**
|
|
81
|
-
|
|
105
|
+
/**
|
|
106
|
+
* The setting, by its 1-based index or its symbol (spaces ignored): for the point group `3m` 1 or
|
|
107
|
+
* `'3m1'` (default) and 2 or `'31m'`, and the key `'3m'` names the default; the other point groups
|
|
108
|
+
* have one, and a plane group takes only 1 or its own symbol (short or full).
|
|
109
|
+
*/
|
|
110
|
+
readonly setting?: number | string;
|
|
82
111
|
}
|
|
83
112
|
|
|
84
113
|
/** Options of `symbol`: the setting, and the form of a plane group's symbol. */
|
|
@@ -107,6 +136,13 @@ export interface PlaneGroup {
|
|
|
107
136
|
readonly pointGroupSetting: number;
|
|
108
137
|
/** The crystal system. */
|
|
109
138
|
readonly crystalSystem: PlaneSystem;
|
|
139
|
+
/** The Bravais lattice (ITA 2016 Table 2.1.1.1, p. 143): `'mp'`, `'op'`, `'oc'`, `'tp'` or `'hp'`. */
|
|
140
|
+
readonly bravaisLattice: PlaneBravaisLattice;
|
|
141
|
+
/**
|
|
142
|
+
* The Patterson symmetry as ITA prints it in the headline of the group (Chapter 2.2), a plane group:
|
|
143
|
+
* the lattice of the group with its Laue class, e.g. `'p2mm'` for `p2mg`, `'c2mm'` for `cm`.
|
|
144
|
+
*/
|
|
145
|
+
readonly pattersonSymmetry: PlaneGroupKey;
|
|
110
146
|
/** The centring translations besides (0, 0): `[[0.5, 0.5]]` for `cm` and `c2mm`, otherwise none. */
|
|
111
147
|
readonly centring: readonly (readonly number[])[];
|
|
112
148
|
/** The block "Origin" as ITA prints it, its positions spaced as printed, e.g. `'at 2 m m'`, `'at 2 1 g'`. */
|
|
@@ -121,6 +157,25 @@ export interface PointGroup {
|
|
|
121
157
|
readonly crystalSystem: PlaneSystem;
|
|
122
158
|
/** The order of the group. */
|
|
123
159
|
readonly order: number;
|
|
160
|
+
/**
|
|
161
|
+
* The Laue class: the point group with the symmetry centre of the plane, the twofold rotation,
|
|
162
|
+
* added (ITA 2016 § 3.2.1.1, p. 720); one of `'2'`, `'2mm'`, `'4'`, `'4mm'`, `'6'`, `'6mm'`.
|
|
163
|
+
*/
|
|
164
|
+
readonly laueClass: PointGroupKey;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** A plane group found by `findPlaneGroup`. */
|
|
168
|
+
export interface PlaneGroupFound {
|
|
169
|
+
/** The key of the plane group. */
|
|
170
|
+
readonly key: PlaneGroupKey;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** A plane point group in a setting, as `findPointGroup` finds it. */
|
|
174
|
+
export interface PointGroupInSetting {
|
|
175
|
+
/** The key of the plane point group. */
|
|
176
|
+
readonly key: PointGroupKey;
|
|
177
|
+
/** The 1-based index of the setting. */
|
|
178
|
+
readonly setting: number;
|
|
124
179
|
}
|
|
125
180
|
|
|
126
181
|
/** A setting of a plane point group. */
|
|
@@ -139,7 +194,7 @@ export interface OperationDescription {
|
|
|
139
194
|
* `'identity'`, `'translation'`, `'rotation'`, `'reflection'` (in a line) or `'glide-reflection'`,
|
|
140
195
|
* as ITA names the operations (ITA 2016 Table 2.1.2.1, p. 145).
|
|
141
196
|
*/
|
|
142
|
-
readonly kind:
|
|
197
|
+
readonly kind: PlaneOperationKind;
|
|
143
198
|
/** The n of the linear part (an n-fold rotation): 1 for the identity and a translation, 2 for a reflection or glide reflection. */
|
|
144
199
|
readonly n: number;
|
|
145
200
|
/** For a rotation of order 3 or more: `'+'` if it turns a towards b, `'-'` otherwise. */
|
|
@@ -270,7 +325,7 @@ export interface SymmetryElementsOptions {
|
|
|
270
325
|
|
|
271
326
|
const numbers = (v: readonly Rational[]): number[] => v.map(toNumber);
|
|
272
327
|
|
|
273
|
-
function
|
|
328
|
+
function isGroupKey(key: unknown): key is PlaneGroupKey {
|
|
274
329
|
return typeof key === 'string' && (GROUP_KEYS as readonly string[]).includes(key);
|
|
275
330
|
}
|
|
276
331
|
|
|
@@ -280,7 +335,7 @@ function unknownKey(key: unknown, what = 'plane group or plane point group'): ne
|
|
|
280
335
|
|
|
281
336
|
/** The plane group of a key; throws for a point group or an unknown key. */
|
|
282
337
|
function groupKey(key: unknown, what: string): PlaneGroupKey {
|
|
283
|
-
if (
|
|
338
|
+
if (isGroupKey(key)) return key;
|
|
284
339
|
if (isPlanePointGroupKey(key)) {
|
|
285
340
|
throw new RangeError(`${what} takes the key of a plane group, not of the point group ${key}`);
|
|
286
341
|
}
|
|
@@ -290,26 +345,47 @@ function groupKey(key: unknown, what: string): PlaneGroupKey {
|
|
|
290
345
|
/** The key of a plane point group; throws for a plane group or an unknown key. */
|
|
291
346
|
function pointKey(key: unknown, what: string): PointGroupKey {
|
|
292
347
|
if (isPlanePointGroupKey(key)) return key;
|
|
293
|
-
if (
|
|
348
|
+
if (isGroupKey(key)) {
|
|
294
349
|
throw new RangeError(`${what} takes the key of a plane point group; ${key} is a plane group (planeGroup)`);
|
|
295
350
|
}
|
|
296
351
|
return unknownKey(key, 'plane point group');
|
|
297
352
|
}
|
|
298
353
|
|
|
299
|
-
|
|
300
|
-
|
|
354
|
+
/**
|
|
355
|
+
* The index of the setting that `options` names for a key, or undefined if it names none: an index
|
|
356
|
+
* is passed on (and checked where it is used), a symbol is looked up among the settings of the key.
|
|
357
|
+
*/
|
|
358
|
+
function settingOf(key: PlaneGroupKey | PointGroupKey, options: SettingOptions | undefined): number | undefined {
|
|
359
|
+
const setting = options?.setting;
|
|
360
|
+
if (typeof setting !== 'string') return setting;
|
|
361
|
+
const wanted = compactSymbol(setting);
|
|
362
|
+
if (isGroupKey(key)) {
|
|
363
|
+
if (wanted === key || wanted === planeGroupEntry(key).fullSymbol) return 1;
|
|
364
|
+
throw new RangeError(
|
|
365
|
+
`The plane group ${key} has no setting ${shown(setting)} (its symbols: ${key}, ${planeGroupEntry(key).fullSymbol})`,
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
const symbols = Array.from({ length: planePointGroupSettingCount(key) }, (_, i) => planePointGroupSymbol(key, i + 1));
|
|
369
|
+
const index = symbols.findIndex((s) => s === wanted);
|
|
370
|
+
if (index >= 0) return index + 1;
|
|
371
|
+
// The key of a point group with several settings is the symbol of none; it names the default.
|
|
372
|
+
if (wanted === key) return 1;
|
|
373
|
+
throw new RangeError(
|
|
374
|
+
`The plane point group ${key} has no setting ${shown(setting)} (settings: ${symbols.join(', ')})`,
|
|
375
|
+
);
|
|
301
376
|
}
|
|
302
377
|
|
|
303
378
|
/** The exact operations for a key: a plane group (setting 1 only) or a point group in a setting. */
|
|
304
379
|
function exact(key: unknown, options: SettingOptions | undefined, generatorsOnly: boolean): ExactOperation[] {
|
|
305
|
-
|
|
306
|
-
|
|
380
|
+
if (isGroupKey(key)) {
|
|
381
|
+
const setting = settingOf(key, options);
|
|
307
382
|
if (setting !== undefined && setting !== 1) {
|
|
308
383
|
throw new RangeError(`The plane group ${key} has no setting ${String(setting)}`);
|
|
309
384
|
}
|
|
310
385
|
return generatorsOnly ? planeGroupGenerators(key) : planeGroupOperations(key);
|
|
311
386
|
}
|
|
312
387
|
if (isPlanePointGroupKey(key)) {
|
|
388
|
+
const setting = settingOf(key, options);
|
|
313
389
|
return generatorsOnly ? planePointGroupGenerators(key, setting) : planePointGroupOperations(key, setting);
|
|
314
390
|
}
|
|
315
391
|
return unknownKey(key);
|
|
@@ -338,37 +414,6 @@ function describe(op: ExactOperation): OperationDescription {
|
|
|
338
414
|
});
|
|
339
415
|
}
|
|
340
416
|
|
|
341
|
-
/** Tolerance for reading an integer or a fraction from a double. */
|
|
342
|
-
/** The largest denominator of a translation that `describeOperationsOf` reads. */
|
|
343
|
-
const MAX_DENOMINATOR = 12;
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* The fraction with a denominator of at most `MAX_DENOMINATOR` within `tolerance` of the value.
|
|
347
|
-
* Two such fractions can lie as close as 1/132 (1/11 and 1/12): a value within the tolerance of two
|
|
348
|
-
* different ones is refused, not read as either.
|
|
349
|
-
*/
|
|
350
|
-
function fractionOf(value: unknown, tolerance: number): Rational {
|
|
351
|
-
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
352
|
-
const found: Rational[] = [];
|
|
353
|
-
for (let d = 1; d <= MAX_DENOMINATOR; d++) {
|
|
354
|
-
for (const n of [Math.floor(value * d), Math.ceil(value * d)]) {
|
|
355
|
-
if (Math.abs(value - n / d) >= tolerance) continue;
|
|
356
|
-
const r = rational(n, d);
|
|
357
|
-
if (!found.some((f) => f[0] === r[0] && f[1] === r[1])) found.push(r);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
if (found.length === 1) return found[0];
|
|
361
|
-
if (found.length > 1) {
|
|
362
|
-
throw new RangeError(
|
|
363
|
-
`The translation ${shown(value)} lies within ${tolerance} of ${found.map((f) => `${f[0]}/${f[1]}`).join(' and ')}: pass a smaller tolerance`,
|
|
364
|
-
);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
throw new RangeError(
|
|
368
|
-
`Not within ${tolerance} of a translation with a denominator of at most ${MAX_DENOMINATOR}: ${shown(value)}`,
|
|
369
|
-
);
|
|
370
|
-
}
|
|
371
|
-
|
|
372
417
|
/** An operation from a caller as an exact operation; throws a RangeError unless it has the shape of a plane operation. */
|
|
373
418
|
function exactOf(op: unknown, tolerance: number): ExactOperation {
|
|
374
419
|
const o = op as Partial<PlaneOperation> | null;
|
|
@@ -386,7 +431,58 @@ function exactOf(op: unknown, tolerance: number): ExactOperation {
|
|
|
386
431
|
return Math.round(v) + 0;
|
|
387
432
|
}),
|
|
388
433
|
);
|
|
389
|
-
return { matrix, translation: t.map((v) =>
|
|
434
|
+
return { matrix, translation: t.map((v) => nearestFraction(v, tolerance, 'translation')) };
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/** True if `key` is the key of one of the 17 plane groups (its short symbol, as ITA prints it). */
|
|
438
|
+
export function isPlaneGroupKey(key: string): key is PlaneGroupKey {
|
|
439
|
+
return isGroupKey(key);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/** True if `key` is the key of one of the 10 plane point groups. */
|
|
443
|
+
export function isPointGroupKey(key: string): key is PointGroupKey {
|
|
444
|
+
return isPlanePointGroupKey(key);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/** The 17 plane groups, in ITA's order (plane group n at index n − 1). */
|
|
448
|
+
export function planeGroups(): readonly PlaneGroup[] {
|
|
449
|
+
return Object.freeze(PLANE_GROUP_KEYS.map((key) => planeGroup(key)));
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/** The 10 plane point groups, in the order of ITA Table 3.2.1.1. */
|
|
453
|
+
export function pointGroups(): readonly PointGroup[] {
|
|
454
|
+
return Object.freeze(POINT_GROUP_KEYS.map((key) => pointGroup(key)));
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Finds a plane group by a symbol: the key (the short symbol, `'pm'`) or the full symbol (`'p1m1'`,
|
|
459
|
+
* `'p 1 m 1'`), spaces ignored (docs/conventions.md, "Reading symbols"). The lattice letter is
|
|
460
|
+
* lower case, as ITA prints it. Gives `undefined` if the symbol names no plane group; throws a
|
|
461
|
+
* RangeError for a value that is not a string.
|
|
462
|
+
*/
|
|
463
|
+
export function findPlaneGroup(symbol: string): PlaneGroupFound | undefined {
|
|
464
|
+
if (typeof symbol !== 'string') throw new RangeError(`A symbol is a string, not ${shown(symbol)}`);
|
|
465
|
+
const wanted = compactSymbol(symbol);
|
|
466
|
+
const key = PLANE_GROUP_KEYS.find((k) => k === wanted || planeGroupEntry(k).fullSymbol === wanted);
|
|
467
|
+
return key === undefined ? undefined : Object.freeze({ key });
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Finds a plane point group by a symbol: the key, or the symbol of a setting (`'3m1'`, `'31m'`),
|
|
472
|
+
* spaces ignored; the key `'3m'` gives the default setting 1. Gives `undefined` if the symbol names
|
|
473
|
+
* no plane point group, also for the symbol of a plane group (that is `findPlaneGroup`); throws a
|
|
474
|
+
* RangeError for a value that is not a string.
|
|
475
|
+
*/
|
|
476
|
+
export function findPointGroup(symbol: string): PointGroupInSetting | undefined {
|
|
477
|
+
if (typeof symbol !== 'string') throw new RangeError(`A symbol is a string, not ${shown(symbol)}`);
|
|
478
|
+
const wanted = compactSymbol(symbol);
|
|
479
|
+
for (const key of POINT_GROUP_KEYS) {
|
|
480
|
+
for (let i = 1; i <= planePointGroupSettingCount(key); i++) {
|
|
481
|
+
if (planePointGroupSymbol(key, i) === wanted) return Object.freeze({ key, setting: i });
|
|
482
|
+
}
|
|
483
|
+
if (key === wanted) return Object.freeze({ key, setting: 1 });
|
|
484
|
+
}
|
|
485
|
+
return undefined;
|
|
390
486
|
}
|
|
391
487
|
|
|
392
488
|
/** The plane group with this key (short symbol). Throws a RangeError for an unknown key. */
|
|
@@ -399,6 +495,8 @@ export function planeGroup(key: PlaneGroupKey): PlaneGroup {
|
|
|
399
495
|
pointGroup: point.key,
|
|
400
496
|
pointGroupSetting: point.setting,
|
|
401
497
|
crystalSystem: entry.system,
|
|
498
|
+
bravaisLattice: planeBravaisLattice(entry.system, entry.symbol),
|
|
499
|
+
pattersonSymmetry: entry.pattersonSymmetry as PlaneGroupKey,
|
|
402
500
|
centring: Object.freeze(
|
|
403
501
|
entry.centring.map((t) => Object.freeze(t.split(',').map((c) => toNumber(parseRational(c))))),
|
|
404
502
|
),
|
|
@@ -409,7 +507,12 @@ export function planeGroup(key: PlaneGroupKey): PlaneGroup {
|
|
|
409
507
|
/** The plane point group with this key. Throws a RangeError for an unknown key. */
|
|
410
508
|
export function pointGroup(key: PointGroupKey): PointGroup {
|
|
411
509
|
const k = pointKey(key, 'pointGroup');
|
|
412
|
-
return Object.freeze({
|
|
510
|
+
return Object.freeze({
|
|
511
|
+
key: k,
|
|
512
|
+
crystalSystem: planePointGroupSystem(k),
|
|
513
|
+
order: planePointGroupOperations(k).length,
|
|
514
|
+
laueClass: planeLaueClass(k),
|
|
515
|
+
});
|
|
413
516
|
}
|
|
414
517
|
|
|
415
518
|
/**
|
|
@@ -442,15 +545,15 @@ export function symbol(key: PlaneGroupKey | PointGroupKey, options?: SymbolOptio
|
|
|
442
545
|
}
|
|
443
546
|
// Every position of a plane symbol is one character, the lattice letter included.
|
|
444
547
|
const spaced = (text: string) => (form === 'full' ? [...text].join(' ') : text);
|
|
445
|
-
if (
|
|
446
|
-
const setting = settingOf(options);
|
|
548
|
+
if (isGroupKey(key)) {
|
|
549
|
+
const setting = settingOf(key, options);
|
|
447
550
|
if (setting !== undefined && setting !== 1) {
|
|
448
551
|
throw new RangeError(`The plane group ${key} has no setting ${shown(setting)}`);
|
|
449
552
|
}
|
|
450
553
|
return spaced(form === 'full' ? planeGroupEntry(key).fullSymbol : key);
|
|
451
554
|
}
|
|
452
555
|
if (!isPlanePointGroupKey(key)) return unknownKey(key);
|
|
453
|
-
return spaced(planePointGroupSymbol(key, settingOf(options)));
|
|
556
|
+
return spaced(planePointGroupSymbol(key, settingOf(key, options)));
|
|
454
557
|
}
|
|
455
558
|
|
|
456
559
|
/**
|
|
@@ -686,3 +789,154 @@ export function symmetryElements(key: PlaneGroupKey, options?: SymmetryElementsO
|
|
|
686
789
|
),
|
|
687
790
|
});
|
|
688
791
|
}
|
|
792
|
+
|
|
793
|
+
// --- lattices and cells (#119, #137 G5) ---------------------------------------------------------------
|
|
794
|
+
|
|
795
|
+
const PLANE_SYSTEMS = Object.keys(PLANE_FAMILIES) as PlaneSystem[];
|
|
796
|
+
|
|
797
|
+
const copy = (m: Mat2): Mat2 => [
|
|
798
|
+
[m[0][0], m[0][1]],
|
|
799
|
+
[m[1][0], m[1][1]],
|
|
800
|
+
];
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* The restrictions on the cell parameters of a crystal system of the plane, as ITA 2016 Table
|
|
804
|
+
* 2.1.1.1 (p. 143) gives them for the conventional cell: the parameters to be determined, the pairs
|
|
805
|
+
* of equal parameters, the fixed angles, and the angles conventionally taken non-acute. Throws a
|
|
806
|
+
* RangeError for anything that is not one of the four crystal systems of the plane.
|
|
807
|
+
*/
|
|
808
|
+
export function cellRestrictions(system: PlaneSystem): CellRestrictions {
|
|
809
|
+
if (!(PLANE_SYSTEMS as readonly unknown[]).includes(system)) {
|
|
810
|
+
throw new RangeError(`Unknown crystal system of the plane: ${shown(system)} (${PLANE_SYSTEMS.join(', ')})`);
|
|
811
|
+
}
|
|
812
|
+
const r = PLANE_FAMILIES[system].restrictions;
|
|
813
|
+
return deepFreeze({
|
|
814
|
+
parameters: [...r.parameters],
|
|
815
|
+
equal: r.equal.map((pair) => [...pair]),
|
|
816
|
+
angles: { ...r.angles },
|
|
817
|
+
nonAcute: [...r.nonAcute],
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* The Cartesian basis of a plane cell as the columns of a 2 × 2 matrix: a along x, b at γ from a
|
|
823
|
+
* towards +y (right-handed), in the unit of the edge lengths. Throws a RangeError for an edge that is
|
|
824
|
+
* not a positive number and for γ outside (0°, 180°).
|
|
825
|
+
*/
|
|
826
|
+
export function latticeFromParameters(parameters: LatticeParameters): Mat2 {
|
|
827
|
+
return deepFreeze(copy(planeLatticeFromParameters(parameters, 'latticeFromParameters')));
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* The parameters a, b, γ of a basis given as the columns of a 2 × 2 Cartesian matrix, independent of
|
|
832
|
+
* its orientation and handedness. Throws a RangeError for a basis that is not a non-singular 2 × 2
|
|
833
|
+
* matrix.
|
|
834
|
+
*/
|
|
835
|
+
export function latticeParameters(basis: Mat2): LatticeParameters {
|
|
836
|
+
return Object.freeze(planeLatticeParameters(basis, 'latticeParameters'));
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/** The metric tensor G = AᵀA of a basis A (columns a, b): g_ij = a_i · a_j. Throws a RangeError for a basis that is not a non-singular 2 × 2 matrix. */
|
|
840
|
+
export function metricTensor(basis: Mat2): Mat2 {
|
|
841
|
+
return deepFreeze(copy(planeMetricTensor(basis, 'metricTensor')));
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* The reciprocal basis B = A⁻ᵀ of a basis A (columns a, b) as the columns a*, b*, with
|
|
846
|
+
* a_i · a*_j = δ_ij (no factor 2π). Throws a RangeError for a basis that is not a non-singular 2 × 2
|
|
847
|
+
* matrix.
|
|
848
|
+
*/
|
|
849
|
+
export function reciprocalBasis(basis: Mat2): Mat2 {
|
|
850
|
+
return deepFreeze(copy(planeReciprocalBasis(basis, 'reciprocalBasis')));
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
// --- change of the coordinate system (#120, #137 G2) ---------------------------------------------------
|
|
854
|
+
|
|
855
|
+
/** A change of the coordinate system (P, p) of the plane (ITA 2016 § 1.5.1.3, p. 83): (a′, b′) = (a, b)·P, origin O′ = O + p. */
|
|
856
|
+
export interface CoordinateTransformation {
|
|
857
|
+
/** P, the linear part: its columns are the new basis vectors a′, b′ in the old basis; det P ≠ 0, also negative. */
|
|
858
|
+
readonly linearPart: Mat2;
|
|
859
|
+
/** p, the origin shift: the coordinates of the new origin in the old coordinate system; default zero. */
|
|
860
|
+
readonly originShift?: readonly number[];
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
/** An operation (W, w) in the lattice basis, x ↦ W·x + w; a record of `operations` passes as it is. */
|
|
864
|
+
export interface AffineOperation {
|
|
865
|
+
/** The linear part W, a 2 × 2 matrix with integer entries. */
|
|
866
|
+
readonly matrix: readonly (readonly number[])[];
|
|
867
|
+
/** The translation part w; default zero, as for the operations of a point group. */
|
|
868
|
+
readonly translation?: readonly number[];
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
/** An operation (W′, w′) in the new coordinate system. */
|
|
872
|
+
export interface TransformedOperation {
|
|
873
|
+
/** W′ = P⁻¹WP, integer entries. */
|
|
874
|
+
readonly matrix: Mat2;
|
|
875
|
+
/** w′ = P⁻¹(w + (W − I)p), not reduced modulo the lattice. */
|
|
876
|
+
readonly translation: readonly number[];
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/** The quantities that `changeOfCoordinates` transforms; each is optional. */
|
|
880
|
+
export interface CoordinateQuantities {
|
|
881
|
+
/** Point coordinates x: x′ = P⁻¹(x − p) (eq. (1.5.1.7)). */
|
|
882
|
+
readonly points?: readonly (readonly number[])[];
|
|
883
|
+
/** Coefficients [uv] of vectors, e.g. directions: [uv]′ = P⁻¹[uv] (eq. (1.5.2.3)); not changed by the origin shift. */
|
|
884
|
+
readonly directions?: readonly (readonly number[])[];
|
|
885
|
+
/** Miller indices (hk) of lines: (hk)′ = (hk)P (eq. (1.5.2.2)); not changed by the origin shift. */
|
|
886
|
+
readonly planes?: readonly (readonly number[])[];
|
|
887
|
+
/** The metric tensor G: G′ = PᵀGP (eq. (1.5.2.4)). */
|
|
888
|
+
readonly metric?: Mat2;
|
|
889
|
+
/** Operations (W, w): W′ = P⁻¹WP, w′ = P⁻¹(w + (W − I)p) (eqs. (1.5.2.12), (1.5.2.13)). */
|
|
890
|
+
readonly operations?: readonly AffineOperation[];
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/** The inverse change of the coordinate system (Q, q) = (P, p)⁻¹. */
|
|
894
|
+
export interface InverseTransformation {
|
|
895
|
+
/** Q = P⁻¹. */
|
|
896
|
+
readonly linearPart: Mat2;
|
|
897
|
+
/** q = −P⁻¹p. */
|
|
898
|
+
readonly originShift: readonly number[];
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/** The result of `changeOfCoordinates`: the inverse pair and each given quantity in the new coordinate system. */
|
|
902
|
+
export interface CoordinateChange {
|
|
903
|
+
/** (Q, q) = (P⁻¹, −P⁻¹p), which takes the new coordinates back to the old (eq. (1.5.1.7)). */
|
|
904
|
+
readonly inverse: InverseTransformation;
|
|
905
|
+
/** The points, as given, in the new coordinates. */
|
|
906
|
+
readonly points?: readonly (readonly number[])[];
|
|
907
|
+
/** The vector coefficients, as given, in the new basis. */
|
|
908
|
+
readonly directions?: readonly (readonly number[])[];
|
|
909
|
+
/** The Miller indices, as given, in the new basis. */
|
|
910
|
+
readonly planes?: readonly (readonly number[])[];
|
|
911
|
+
/** The metric tensor in the new basis. */
|
|
912
|
+
readonly metric?: Mat2;
|
|
913
|
+
/** The operations, as given, in the new coordinate system. */
|
|
914
|
+
readonly operations?: readonly TransformedOperation[];
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* Changes the coordinate system of the plane by the pair (P, p) of ITA (6th ed., 2016) § 1.5.1.3
|
|
919
|
+
* (p. 83), with 2 × 2 matrices: the new basis is (a′, b′) = (a, b)·P and the new origin lies at p.
|
|
920
|
+
* Transforms the given quantities by ITA's equations (§ 1.5.2, pp. 83–85): point coordinates
|
|
921
|
+
* x′ = P⁻¹(x − p), vector coefficients [uv]′ = P⁻¹[uv], Miller indices (hk)′ = (hk)P, the metric
|
|
922
|
+
* tensor G′ = PᵀGP, and operations W′ = P⁻¹WP, w′ = P⁻¹(w + (W − I)p); and gives the inverse pair
|
|
923
|
+
* (Q, q) = (P⁻¹, −P⁻¹p). det P may be negative.
|
|
924
|
+
*
|
|
925
|
+
* P, p and the operations are read each number as the simplest fraction within the tolerance
|
|
926
|
+
* (default `EPSILON`; 0.3333333 is 1/3) and transformed exactly, so that every result, the inverse
|
|
927
|
+
* pair included, can be passed back; the other quantities are floating point. P is rational in a
|
|
928
|
+
* change between lattice bases, as in ITA; an irrational P (a rotation by 30°) is read as the
|
|
929
|
+
* nearby fractions, about as exact as the tolerance, and a much smaller tolerance can make the exact
|
|
930
|
+
* products leave the safe integers, a RangeError.
|
|
931
|
+
* A transformed operation is `{ matrix, translation }`. Throws a RangeError for a singular P, a quantity of the
|
|
932
|
+
* wrong shape, an unknown quantity, an operation with det W ≠ ±1, and one whose W′ is not integral.
|
|
933
|
+
*/
|
|
934
|
+
export function changeOfCoordinates(
|
|
935
|
+
transformation: CoordinateTransformation,
|
|
936
|
+
quantities: CoordinateQuantities,
|
|
937
|
+
options?: ToleranceOptions,
|
|
938
|
+
): CoordinateChange {
|
|
939
|
+
return deepFreeze(
|
|
940
|
+
changeCoordinates(2, transformation, quantities, options, 'changeOfCoordinates') as unknown as CoordinateChange,
|
|
941
|
+
);
|
|
942
|
+
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* operations, generators and symbols, as ITC gives them (CLAUDE.md, "Pure ITC").
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { SHUBNIKOV } from './shubnikovData.js';
|
|
7
8
|
import { checkOptions, SETTING_KEYS, shown } from '../checks.js';
|
|
8
9
|
import { INVERSION, det, inverse, matricesEqual, multiply, type Mat3 } from '../linalg.js';
|
|
9
10
|
import { EPSILON } from '../tolerances.js';
|
|
@@ -160,8 +161,16 @@ export interface SymbolOptions extends SettingOptions {
|
|
|
160
161
|
* `'schoenflies'`: Schoenflies symbol, subscripts written inline (`C3v`, `D2d`, `Oh`); `C3i` for
|
|
161
162
|
* the class -3 in the crystallographic API (ITA), `S6` in the magnetic API (ITC Vol. D: `S6(C3)`,
|
|
162
163
|
* `D3d(S6)`).
|
|
164
|
+
* `'shubnikov'`: Shubnikov symbol as ITC Vol. D Table 1.5.2.3 prints it, with the combining
|
|
165
|
+
* overbar (U+0305) and the combining low line (U+0332, an element combined with time reversal)
|
|
166
|
+
* after their character and `·` for the centred dot: `2̲:m̲` for `2'/m'`, `6̅` for `-3` (Shubnikov's
|
|
167
|
+
* overbar is a rotoreflection). A grey group, which ITC does not print, has the symbol of its class,
|
|
168
|
+
* a centred dot and an underlined 1, as Shubnikov & Belov (1964, pp. 113–114) write it (`3:2·1̲` for
|
|
169
|
+
* `321'`). The same in every setting, since it names no
|
|
170
|
+
* orientation; `findPointGroup` does not read it, since it clashes with Hermann–Mauguin (`2̅` is
|
|
171
|
+
* −1, `6̅` is −3).
|
|
163
172
|
*/
|
|
164
|
-
readonly form?: 'short' | 'full' | 'schoenflies';
|
|
173
|
+
readonly form?: 'short' | 'full' | 'schoenflies' | 'shubnikov';
|
|
165
174
|
}
|
|
166
175
|
|
|
167
176
|
/**
|
|
@@ -767,11 +776,45 @@ export function symbol(key: MagneticPointGroupKey, options?: SymbolOptions): str
|
|
|
767
776
|
const form = options?.form ?? 'short';
|
|
768
777
|
const s = settingSymbols(d, settingIndex(d, options));
|
|
769
778
|
if (form === 'schoenflies') return volDSchoenflies(d.schoenflies);
|
|
779
|
+
if (form === 'shubnikov') return shubnikov(d);
|
|
770
780
|
if (form === 'short') return s.short;
|
|
771
781
|
if (form === 'full') return s.full;
|
|
772
782
|
throw new RangeError(`Unknown symbol form: ${shown(form)}`);
|
|
773
783
|
}
|
|
774
784
|
|
|
785
|
+
/** The underline of Shubnikov's notation (time reversal) and the overbar, as combining characters. */
|
|
786
|
+
const LOW_LINE = '\u0332';
|
|
787
|
+
const OVERBAR = '\u0305';
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* The Shubnikov symbol of a group: the printed one of ITC Vol. D Table 1.5.2.3 (types I and III),
|
|
791
|
+
* written with combining characters; for a grey group, which ITC does not print, the symbol of its
|
|
792
|
+
* class, a centred dot and an underlined 1, as Shubnikov & Belov (1964, pp. 113–114) write it
|
|
793
|
+
* (`m·1̲`, `4·1̲`).
|
|
794
|
+
*/
|
|
795
|
+
function shubnikov(d: GroupData): string {
|
|
796
|
+
if (d.type === 'II') return `${shubnikov(d.crystalClass)}·1${LOW_LINE}`;
|
|
797
|
+
const printed = SHUBNIKOV[d.key];
|
|
798
|
+
if (printed === undefined) throw new Error(`No Shubnikov symbol for ${d.key}`);
|
|
799
|
+
let out = '';
|
|
800
|
+
let underline = false;
|
|
801
|
+
let overbar = false;
|
|
802
|
+
for (const c of printed) {
|
|
803
|
+
if (c === '_') underline = true;
|
|
804
|
+
else if (c === '-') overbar = true;
|
|
805
|
+
else if (c === '.') out += '·';
|
|
806
|
+
else if (c === ':' || c === '/') out += c;
|
|
807
|
+
else {
|
|
808
|
+
// The low line before the overbar: Unicode's canonical order (combining classes 220, 230), so
|
|
809
|
+
// that the symbol is its own NFC and NFD form.
|
|
810
|
+
out += c + (underline ? LOW_LINE : '') + (overbar ? OVERBAR : '');
|
|
811
|
+
underline = false;
|
|
812
|
+
overbar = false;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
return out;
|
|
816
|
+
}
|
|
817
|
+
|
|
775
818
|
/** A point group in a given setting. */
|
|
776
819
|
export interface PointGroupInSetting<K extends MagneticPointGroupKey = PointGroupKey> {
|
|
777
820
|
/** The key of the point group. */
|
|
@@ -791,6 +834,14 @@ function find(
|
|
|
791
834
|
// A symbol that names no group is not found; a value that is no symbol at all is wrong input.
|
|
792
835
|
if (typeof symbol !== 'string')
|
|
793
836
|
throw new RangeError(`findPointGroup takes a symbol (a string), not ${shown(symbol)}`);
|
|
837
|
+
// Shubnikov's notation is written (symbol, form 'shubnikov') but not read: its overbar is a
|
|
838
|
+
// rotoreflection, so 6̅ is −3 there and C3h in Hermann–Mauguin (Thomas, 2026-11-25). A symbol with
|
|
839
|
+
// a character that only it writes is refused rather than read as something else.
|
|
840
|
+
if (/[\u0332:·\u22C5\u2219]/.test(symbol)) {
|
|
841
|
+
throw new RangeError(
|
|
842
|
+
`findPointGroup does not read Shubnikov symbols (${shown(symbol)}): give the Hermann–Mauguin or Schoenflies symbol`,
|
|
843
|
+
);
|
|
844
|
+
}
|
|
794
845
|
const target = compact(symbol);
|
|
795
846
|
const candidates = [...BY_KEY.values()].filter((d) => !classesOnly || d.type === 'I');
|
|
796
847
|
// The key, a short or full symbol of a setting (spaces ignored), Birss's cubic form; then a
|
|
@@ -836,9 +887,10 @@ function birssCubic(compactTarget: string): string | undefined {
|
|
|
836
887
|
* settings (the option `axes` set to `'rhombohedral'` for the key `32`).
|
|
837
888
|
*
|
|
838
889
|
* Spellings: the overbar as `-`, `−`, a combining overbar or `¯` after the digit (`m3̄m`), `bar3` (also with a backslash and braces, as in LaTeX);
|
|
839
|
-
* Schoenflies subscripts also as Unicode or LaTeX subscripts (`C₃ᵥ`, `C_{3v}`). Returns undefined if nothing matches,
|
|
840
|
-
* also for
|
|
841
|
-
*
|
|
890
|
+
* Schoenflies subscripts also as Unicode or LaTeX subscripts (`C₃ᵥ`, `C_{3v}`). Returns `undefined` if nothing matches,
|
|
891
|
+
* also for the symbol of a magnetic group with time reversal (`findMagneticPointGroup`); a value
|
|
892
|
+
* that is not a string, and a symbol that names several groups, are a RangeError (the latter lists
|
|
893
|
+
* the groups).
|
|
842
894
|
*/
|
|
843
895
|
export function findPointGroup(symbol: string, options?: AxesOptions): PointGroupInSetting | undefined {
|
|
844
896
|
if (arguments.length > 2) rejectConventionArgument(arguments.length);
|
|
@@ -858,8 +910,8 @@ export function findPointGroup(symbol: string, options?: AxesOptions): PointGrou
|
|
|
858
910
|
*
|
|
859
911
|
* Spellings: the overbar as `-`, `−`, a combining overbar or `¯` after the digit (`m3̄m`), `bar3` (also with a backslash and braces, as in LaTeX);
|
|
860
912
|
* the prime as `'`, `′`, `ʹ` or `’`; Schoenflies subscripts also as Unicode or LaTeX subscripts (`D₃d(S₆)`, `D_{3d}`).
|
|
861
|
-
* Returns undefined if nothing matches
|
|
862
|
-
* several groups
|
|
913
|
+
* Returns `undefined` if nothing matches; a value that is not a string, and a symbol that names
|
|
914
|
+
* several groups, are a RangeError (the latter lists the groups).
|
|
863
915
|
*/
|
|
864
916
|
export function findMagneticPointGroup(
|
|
865
917
|
symbol: string,
|