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.
- package/README.md +6 -6
- package/dist/cell.d.ts +19 -16
- package/dist/cell.d.ts.map +1 -1
- package/dist/cell.js +63 -35
- package/dist/cell.js.map +1 -1
- package/dist/checks.d.ts +29 -0
- package/dist/checks.d.ts.map +1 -0
- package/dist/checks.js +79 -0
- package/dist/checks.js.map +1 -0
- package/dist/closure.d.ts +43 -0
- package/dist/closure.d.ts.map +1 -0
- package/dist/closure.js +201 -0
- package/dist/closure.js.map +1 -0
- package/dist/crystalClasses.d.ts +146 -118
- package/dist/crystalClasses.d.ts.map +1 -1
- package/dist/crystalClasses.js +163 -124
- package/dist/crystalClasses.js.map +1 -1
- package/dist/freeze.d.ts +7 -0
- package/dist/freeze.d.ts.map +1 -0
- package/dist/freeze.js +15 -0
- package/dist/freeze.js.map +1 -0
- package/dist/index.d.ts +11 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/indices.d.ts +31 -5
- package/dist/indices.d.ts.map +1 -1
- package/dist/indices.js +104 -13
- package/dist/indices.js.map +1 -1
- package/dist/lattice.d.ts +15 -1
- package/dist/lattice.d.ts.map +1 -1
- package/dist/lattice.js +30 -1
- package/dist/lattice.js.map +1 -1
- package/dist/linalg.d.ts +2 -2
- package/dist/linalg.d.ts.map +1 -1
- package/dist/linalg.js +3 -3
- package/dist/linalg.js.map +1 -1
- package/dist/magnetic.d.ts +12 -10
- package/dist/magnetic.d.ts.map +1 -1
- package/dist/magnetic.js +8 -6
- package/dist/magnetic.js.map +1 -1
- package/dist/notation.d.ts +16 -0
- package/dist/notation.d.ts.map +1 -0
- package/dist/notation.js +66 -0
- package/dist/notation.js.map +1 -0
- package/dist/operations.d.ts +40 -26
- package/dist/operations.d.ts.map +1 -1
- package/dist/operations.js +48 -60
- package/dist/operations.js.map +1 -1
- package/dist/plane.d.ts +141 -79
- package/dist/plane.d.ts.map +1 -1
- package/dist/plane.js +147 -77
- package/dist/plane.js.map +1 -1
- package/dist/pointGroups/crystalForms.d.ts +6 -21
- package/dist/pointGroups/crystalForms.d.ts.map +1 -1
- package/dist/pointGroups/crystalForms.js +9 -16
- package/dist/pointGroups/crystalForms.js.map +1 -1
- package/dist/pointGroups/crystalFormsData.d.ts +4 -1
- package/dist/pointGroups/crystalFormsData.d.ts.map +1 -1
- package/dist/pointGroups/crystalFormsData.js +64 -1
- package/dist/pointGroups/crystalFormsData.js.map +1 -1
- package/dist/pointGroups/elements.d.ts +19 -17
- package/dist/pointGroups/elements.d.ts.map +1 -1
- package/dist/pointGroups/elements.js +65 -83
- package/dist/pointGroups/elements.js.map +1 -1
- package/dist/pointGroups/identify.d.ts +10 -18
- package/dist/pointGroups/identify.d.ts.map +1 -1
- package/dist/pointGroups/identify.js +27 -79
- package/dist/pointGroups/identify.js.map +1 -1
- package/dist/pointGroups/itaOrder.d.ts +15 -14
- package/dist/pointGroups/itaOrder.d.ts.map +1 -1
- package/dist/pointGroups/itaOrder.js +116 -94
- package/dist/pointGroups/itaOrder.js.map +1 -1
- package/dist/pointGroups/itcData.d.ts +96 -0
- package/dist/pointGroups/itcData.d.ts.map +1 -0
- package/dist/pointGroups/itcData.js +336 -0
- package/dist/pointGroups/itcData.js.map +1 -0
- package/dist/pointGroups/itcMagneticData.d.ts +55 -0
- package/dist/pointGroups/itcMagneticData.d.ts.map +1 -0
- package/dist/pointGroups/itcMagneticData.js +172 -0
- package/dist/pointGroups/itcMagneticData.js.map +1 -0
- package/dist/pointGroups/keys.d.ts +32 -0
- package/dist/pointGroups/keys.d.ts.map +1 -0
- package/dist/pointGroups/keys.js +120 -0
- package/dist/pointGroups/keys.js.map +1 -0
- package/dist/pointGroups/magneticSymbols.d.ts +6 -5
- package/dist/pointGroups/magneticSymbols.d.ts.map +1 -1
- package/dist/pointGroups/magneticSymbols.js +15 -12
- package/dist/pointGroups/magneticSymbols.js.map +1 -1
- package/dist/pointGroups/orbits.d.ts +23 -42
- package/dist/pointGroups/orbits.d.ts.map +1 -1
- package/dist/pointGroups/orbits.js +20 -62
- package/dist/pointGroups/orbits.js.map +1 -1
- package/dist/pointGroups/pointGroups.d.ts +135 -67
- package/dist/pointGroups/pointGroups.d.ts.map +1 -1
- package/dist/pointGroups/pointGroups.js +409 -244
- package/dist/pointGroups/pointGroups.js.map +1 -1
- package/dist/pointGroups/properties.d.ts +21 -22
- package/dist/pointGroups/properties.d.ts.map +1 -1
- package/dist/pointGroups/properties.js +40 -37
- package/dist/pointGroups/properties.js.map +1 -1
- package/dist/pointGroups/seitzData.d.ts +26 -0
- package/dist/pointGroups/seitzData.d.ts.map +1 -0
- package/dist/pointGroups/seitzData.js +130 -0
- package/dist/pointGroups/seitzData.js.map +1 -0
- package/dist/pointGroups/wyckoff.d.ts +70 -40
- package/dist/pointGroups/wyckoff.d.ts.map +1 -1
- package/dist/pointGroups/wyckoff.js +98 -91
- package/dist/pointGroups/wyckoff.js.map +1 -1
- package/dist/pointGroups/wyckoffData.d.ts +7 -4
- package/dist/pointGroups/wyckoffData.d.ts.map +1 -1
- package/dist/pointGroups/wyckoffData.js +789 -168
- package/dist/pointGroups/wyckoffData.js.map +1 -1
- package/dist/siteSymmetry.d.ts +9 -17
- package/dist/siteSymmetry.d.ts.map +1 -1
- package/dist/siteSymmetry.js +62 -47
- package/dist/siteSymmetry.js.map +1 -1
- package/dist/spaceGroups/affine.d.ts.map +1 -1
- package/dist/spaceGroups/affine.js +3 -2
- package/dist/spaceGroups/affine.js.map +1 -1
- package/dist/spaceGroups/cell.d.ts +43 -31
- package/dist/spaceGroups/cell.d.ts.map +1 -1
- package/dist/spaceGroups/cell.js +173 -85
- package/dist/spaceGroups/cell.js.map +1 -1
- package/dist/spaceGroups/describe.d.ts +12 -10
- package/dist/spaceGroups/describe.d.ts.map +1 -1
- package/dist/spaceGroups/describe.js +11 -10
- package/dist/spaceGroups/describe.js.map +1 -1
- package/dist/spaceGroups/planeGroupData.d.ts +1 -1
- package/dist/spaceGroups/planeGroupData.d.ts.map +1 -1
- package/dist/spaceGroups/planeGroupData.js +8 -8
- package/dist/spaceGroups/planeGroupData.js.map +1 -1
- package/dist/spaceGroups/planeGroups.d.ts.map +1 -1
- package/dist/spaceGroups/planeGroups.js +2 -1
- package/dist/spaceGroups/planeGroups.js.map +1 -1
- package/dist/spaceGroups/positions.d.ts +48 -19
- package/dist/spaceGroups/positions.d.ts.map +1 -1
- package/dist/spaceGroups/positions.js +166 -67
- package/dist/spaceGroups/positions.js.map +1 -1
- package/dist/tensors/propertyTable.d.ts +3 -1
- package/dist/tensors/propertyTable.d.ts.map +1 -1
- package/dist/tensors/propertyTable.js +17 -10
- package/dist/tensors/propertyTable.js.map +1 -1
- package/dist/tensors/rowEchelon.d.ts +12 -4
- package/dist/tensors/rowEchelon.d.ts.map +1 -1
- package/dist/tensors/rowEchelon.js +24 -11
- package/dist/tensors/rowEchelon.js.map +1 -1
- package/dist/tensors/tensorForm.d.ts +75 -34
- package/dist/tensors/tensorForm.d.ts.map +1 -1
- package/dist/tensors/tensorForm.js +173 -68
- package/dist/tensors/tensorForm.js.map +1 -1
- package/dist/tensors/tensorProperties.d.ts +10 -9
- package/dist/tensors/tensorProperties.d.ts.map +1 -1
- package/dist/tensors/tensorProperties.js +22 -12
- package/dist/tensors/tensorProperties.js.map +1 -1
- package/dist/tolerances.d.ts +56 -1
- package/dist/tolerances.d.ts.map +1 -1
- package/dist/tolerances.js +51 -1
- package/dist/tolerances.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/cell.ts +78 -51
- package/src/checks.ts +84 -0
- package/src/closure.ts +214 -0
- package/src/crystalClasses.ts +234 -160
- package/src/freeze.ts +14 -0
- package/src/index.ts +21 -10
- package/src/indices.ts +108 -18
- package/src/lattice.ts +41 -1
- package/src/linalg.ts +3 -3
- package/src/magnetic.ts +14 -9
- package/src/notation.ts +73 -0
- package/src/operations.ts +78 -69
- package/src/plane.ts +253 -127
- package/src/pointGroups/crystalForms.ts +11 -44
- package/src/pointGroups/crystalFormsData.ts +66 -1
- package/src/pointGroups/elements.ts +82 -92
- package/src/pointGroups/identify.ts +38 -97
- package/src/pointGroups/itaOrder.ts +117 -101
- package/src/pointGroups/itcData.ts +404 -0
- package/src/pointGroups/itcMagneticData.ts +206 -0
- package/src/pointGroups/keys.ts +144 -0
- package/src/pointGroups/magneticSymbols.ts +18 -17
- package/src/pointGroups/orbits.ts +41 -89
- package/src/pointGroups/pointGroups.ts +540 -297
- package/src/pointGroups/properties.ts +44 -40
- package/src/pointGroups/seitzData.ts +147 -0
- package/src/pointGroups/wyckoff.ts +137 -112
- package/src/pointGroups/wyckoffData.ts +793 -170
- package/src/siteSymmetry.ts +71 -64
- package/src/spaceGroups/affine.ts +3 -2
- package/src/spaceGroups/cell.ts +227 -116
- package/src/spaceGroups/describe.ts +22 -19
- package/src/spaceGroups/planeGroupData.ts +9 -9
- package/src/spaceGroups/planeGroups.ts +2 -1
- package/src/spaceGroups/positions.ts +202 -78
- package/src/tensors/propertyTable.ts +29 -17
- package/src/tensors/rowEchelon.ts +28 -9
- package/src/tensors/tensorForm.ts +260 -89
- package/src/tensors/tensorProperties.ts +34 -14
- package/src/tolerances.ts +66 -1
- package/src/version.ts +1 -1
- package/dist/pointGroups/data.d.ts +0 -75
- package/dist/pointGroups/data.d.ts.map +0 -1
- package/dist/pointGroups/data.js +0 -212
- package/dist/pointGroups/data.js.map +0 -1
- package/dist/pointGroups/magneticData.d.ts +0 -66
- package/dist/pointGroups/magneticData.d.ts.map +0 -1
- package/dist/pointGroups/magneticData.js +0 -184
- package/dist/pointGroups/magneticData.js.map +0 -1
- package/dist/spaceGroups/snap.d.ts +0 -20
- package/dist/spaceGroups/snap.d.ts.map +0 -1
- package/dist/spaceGroups/snap.js +0 -103
- package/dist/spaceGroups/snap.js.map +0 -1
- package/src/pointGroups/data.ts +0 -305
- package/src/pointGroups/magneticData.ts +0 -328
- package/src/spaceGroups/snap.ts +0 -121
package/src/siteSymmetry.ts
CHANGED
|
@@ -3,25 +3,16 @@
|
|
|
3
3
|
* fixed (docs/conventions.md, "Site symmetry and Wyckoff positions").
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
/** Options of `siteSymmetry` and `wyckoffPositionOf`. */
|
|
11
|
-
export interface SiteSymmetryOptions {
|
|
12
|
-
/**
|
|
13
|
-
* A direction counts as fixed by an operation if the operation moves its unit vector by less
|
|
14
|
-
* than this (Euclidean distance). Default 10⁻⁶; a caller whose directions carry
|
|
15
|
-
* rounding errors (e.g. read from a rounded link) passes a larger value.
|
|
16
|
-
*/
|
|
17
|
-
readonly tolerance?: number;
|
|
18
|
-
}
|
|
6
|
+
import { checkNumbers, checkOptions, shown, TOLERANCE_KEYS } from './checks.js';
|
|
7
|
+
import { apply, multiply, type Vec3 } from './linalg.js';
|
|
8
|
+
import { checkCartesianOperations, type CartesianOperation } from './operations.js';
|
|
9
|
+
import { EPSILON, TOLERANCE_BOUND, toleranceOf, type ToleranceOptions } from './tolerances.js';
|
|
19
10
|
|
|
20
11
|
/** The site symmetry of a direction. */
|
|
21
12
|
export interface SiteSymmetry {
|
|
22
13
|
/**
|
|
23
14
|
* Indices into the given operations of those that leave the direction fixed, ascending: for a group,
|
|
24
|
-
* a subgroup (the operations fixing within the tolerance, closed under products, see `
|
|
15
|
+
* a subgroup (the operations fixing within the tolerance, closed under products, see `siteSymmetryOf`).
|
|
25
16
|
*/
|
|
26
17
|
readonly operations: readonly number[];
|
|
27
18
|
/**
|
|
@@ -37,47 +28,58 @@ export interface SiteSymmetry {
|
|
|
37
28
|
}
|
|
38
29
|
|
|
39
30
|
function unit(v: Vec3): Vec3 {
|
|
31
|
+
checkNumbers(v, 3, 'A direction');
|
|
40
32
|
const n = Math.hypot(v[0], v[1], v[2]);
|
|
41
|
-
if (!(n > 0) || !Number.isFinite(n)) throw new RangeError(`Not a direction: ${
|
|
33
|
+
if (!(n > 0) || !Number.isFinite(n)) throw new RangeError(`Not a direction: ${shown(v)}`);
|
|
42
34
|
return [v[0] / n, v[1] / n, v[2] / n];
|
|
43
35
|
}
|
|
44
36
|
|
|
45
|
-
function fixes(op:
|
|
46
|
-
const w = apply(op.
|
|
37
|
+
function fixes(op: CartesianOperation, v: Vec3, tolerance: number): boolean {
|
|
38
|
+
const w = apply(op.cartesian, v);
|
|
47
39
|
return Math.hypot(w[0] - v[0], w[1] - v[1], w[2] - v[2]) < tolerance;
|
|
48
40
|
}
|
|
49
41
|
|
|
50
|
-
function isIdentity(op:
|
|
51
|
-
return op.
|
|
42
|
+
function isIdentity(op: CartesianOperation): boolean {
|
|
43
|
+
return op.cartesian.every((row, i) => row.every((v, j) => Math.abs(v - (i === j ? 1 : 0)) < EPSILON));
|
|
52
44
|
}
|
|
53
45
|
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
table.
|
|
69
|
-
|
|
70
|
-
|
|
46
|
+
/**
|
|
47
|
+
* The products of a list of operations, looked up as needed: `i * n + j` → index of op[i]·op[j] in
|
|
48
|
+
* the list, or -1. The product is the whole operation, time reversal included, so that in a grey
|
|
49
|
+
* group, where every matrix occurs twice, it finds the copy with the right time reversal (#133).
|
|
50
|
+
* Matrices count as equal per entry within the tolerance, at least `EPSILON` and at most the bound
|
|
51
|
+
* for operations (a tolerance for directions may be larger). Made per call, not kept between
|
|
52
|
+
* calls: a caller may change its list in place (#90).
|
|
53
|
+
*/
|
|
54
|
+
function productLookup(operations: readonly CartesianOperation[], tolerance: number): (i: number, j: number) => number {
|
|
55
|
+
const table = new Map<number, number>();
|
|
56
|
+
const within = Math.min(Math.max(tolerance, EPSILON), TOLERANCE_BOUND.operations);
|
|
57
|
+
const reversed = (op: CartesianOperation): boolean => op.timeReversal === true;
|
|
58
|
+
return (i, j) => {
|
|
59
|
+
const key = i * operations.length + j;
|
|
60
|
+
let k = table.get(key);
|
|
61
|
+
if (k === undefined) {
|
|
62
|
+
const product = multiply(operations[i].cartesian, operations[j].cartesian);
|
|
63
|
+
const timeReversal = reversed(operations[i]) !== reversed(operations[j]);
|
|
64
|
+
k = operations.findIndex(
|
|
65
|
+
(op) =>
|
|
66
|
+
reversed(op) === timeReversal &&
|
|
67
|
+
op.cartesian.every((row, a) => row.every((v, b) => Math.abs(v - product[a][b]) < within)),
|
|
68
|
+
);
|
|
69
|
+
table.set(key, k);
|
|
70
|
+
}
|
|
71
|
+
return k;
|
|
72
|
+
};
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
/** The indices plus those of every product of two of them that is itself in the list, until closed. */
|
|
74
|
-
function closeWithin(
|
|
76
|
+
function closeWithin(product: (i: number, j: number) => number, indices: readonly number[]): number[] {
|
|
75
77
|
const set = [...indices];
|
|
76
78
|
const inSet = new Set(set);
|
|
77
79
|
// Each element is multiplied with every element before it once, in both orders, as it is added.
|
|
78
80
|
for (let i = 0; i < set.length; i++) {
|
|
79
81
|
for (let j = 0; j <= i; j++) {
|
|
80
|
-
for (const k of [
|
|
82
|
+
for (const k of [product(set[i], set[j]), product(set[j], set[i])]) {
|
|
81
83
|
if (k >= 0 && !inSet.has(k)) {
|
|
82
84
|
inSet.add(k);
|
|
83
85
|
set.push(k);
|
|
@@ -89,11 +91,11 @@ function closeWithin(operations: readonly Operation[], indices: readonly number[
|
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
/** The normalised mean of the images of v under the operations at `indices`; undefined if it vanishes. */
|
|
92
|
-
function meanImage(operations: readonly
|
|
94
|
+
function meanImage(operations: readonly CartesianOperation[], indices: readonly number[], v: Vec3): Vec3 | undefined {
|
|
93
95
|
if (indices.length === 0) return v;
|
|
94
96
|
const sum: [number, number, number] = [0, 0, 0];
|
|
95
97
|
for (const i of indices) {
|
|
96
|
-
const w = apply(operations[i].
|
|
98
|
+
const w = apply(operations[i].cartesian, v);
|
|
97
99
|
sum[0] += w[0];
|
|
98
100
|
sum[1] += w[1];
|
|
99
101
|
sum[2] += w[2];
|
|
@@ -105,11 +107,9 @@ function meanImage(operations: readonly Operation[], indices: readonly number[],
|
|
|
105
107
|
const sameIndices = (a: readonly number[], b: readonly number[]): boolean =>
|
|
106
108
|
a.length === b.length && a.every((x, i) => x === b[i]);
|
|
107
109
|
|
|
108
|
-
/** The tolerance of the options, checked. */
|
|
109
|
-
export function siteTolerance(options?:
|
|
110
|
-
|
|
111
|
-
if (!(typeof t === 'number' && t > 0 && t < 1)) throw new RangeError(`Invalid tolerance: ${String(t)}`);
|
|
112
|
-
return t;
|
|
110
|
+
/** The tolerance of the options for directions, checked. */
|
|
111
|
+
export function siteTolerance(options?: ToleranceOptions): number {
|
|
112
|
+
return toleranceOf(options, 'directions');
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
/**
|
|
@@ -119,18 +119,21 @@ export function siteTolerance(options?: SiteSymmetryOptions): number {
|
|
|
119
119
|
* within the tolerance are closed under the products found in the list and the direction is set onto
|
|
120
120
|
* their fixed space, repeated until stable, so that for a group the result is a subgroup and the
|
|
121
121
|
* set direction lies exactly on its elements. For a list that is not a group, `multiplicity` may
|
|
122
|
-
* not be an integer.
|
|
123
|
-
* `
|
|
122
|
+
* not be an integer. Each operation is read by its Cartesian matrix
|
|
123
|
+
* (`cartesian`). Throws a RangeError for an operation without an orthogonal Cartesian matrix (`cartesian`; within
|
|
124
124
|
* `tolerance`, at least `EPSILON`), for a zero vector, and if the closed operations fix no common
|
|
125
|
-
* direction (a tolerance far too large, e.g. 0.5).
|
|
125
|
+
* direction or do not settle into a group (a tolerance far too large, e.g. 0.5).
|
|
126
126
|
*/
|
|
127
|
-
export function
|
|
128
|
-
operations: readonly
|
|
127
|
+
export function siteSymmetryOf(
|
|
128
|
+
operations: readonly CartesianOperation[],
|
|
129
129
|
direction: Vec3,
|
|
130
|
-
options?:
|
|
130
|
+
options?: ToleranceOptions,
|
|
131
131
|
): SiteSymmetry {
|
|
132
|
+
checkOptions(options, TOLERANCE_KEYS, 'siteSymmetryOf');
|
|
132
133
|
const tolerance = siteTolerance(options);
|
|
133
|
-
|
|
134
|
+
// Operations are checked in their own metric, at most with the bound for operations.
|
|
135
|
+
checkCartesianOperations(operations, Math.min(tolerance, TOLERANCE_BOUND.operations));
|
|
136
|
+
if (operations.length === 0) throw new RangeError('siteSymmetryOf takes a list of at least one operation');
|
|
134
137
|
const v = unit(direction);
|
|
135
138
|
const fixing = (w: Vec3): number[] => {
|
|
136
139
|
const out: number[] = [];
|
|
@@ -143,24 +146,28 @@ export function siteSymmetry(
|
|
|
143
146
|
// as fixing while its square does not). Close them under products found in the list, set v onto the
|
|
144
147
|
// fixed space of the closure (the mean of its images, the projector for a group), and repeat on the
|
|
145
148
|
// projected direction until the set is stable.
|
|
146
|
-
|
|
147
|
-
let
|
|
148
|
-
let
|
|
149
|
-
for (let pass = 0; pass < 8; pass++) {
|
|
149
|
+
const product = productLookup(operations, tolerance);
|
|
150
|
+
let set = closeWithin(product, fixing(v));
|
|
151
|
+
let settled: { indices: number[]; projected: Vec3 } | undefined;
|
|
152
|
+
for (let pass = 0; pass < 8 && !settled; pass++) {
|
|
150
153
|
const mean = meanImage(operations, set, v);
|
|
151
154
|
if (mean === undefined) {
|
|
152
155
|
throw new RangeError(
|
|
153
|
-
`No common fixed direction for the operations fixing ${
|
|
156
|
+
`No common fixed direction for the operations fixing ${shown(direction)} within ${tolerance} (tolerance too large?)`,
|
|
154
157
|
);
|
|
155
158
|
}
|
|
156
|
-
const next = closeWithin(
|
|
157
|
-
if (sameIndices(next, set)) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
159
|
+
const next = closeWithin(product, fixing(mean));
|
|
160
|
+
if (sameIndices(next, set)) settled = { indices: set, projected: mean };
|
|
161
|
+
else set = next;
|
|
162
|
+
}
|
|
163
|
+
if (!settled) {
|
|
164
|
+
// Only for a tolerance far too large; the site symmetry would be neither closed nor its direction
|
|
165
|
+
// projected (#91).
|
|
166
|
+
throw new RangeError(
|
|
167
|
+
`The site symmetry of ${shown(direction)} does not settle within ${tolerance} (tolerance too large?)`,
|
|
168
|
+
);
|
|
163
169
|
}
|
|
170
|
+
const { indices, projected } = settled;
|
|
164
171
|
return Object.freeze({
|
|
165
172
|
operations: Object.freeze(indices),
|
|
166
173
|
direction: Object.freeze(projected) as Vec3,
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* space groups). CLAUDE.md, "Plane groups (and later space groups)".
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { shown } from '../checks.js';
|
|
8
9
|
import {
|
|
9
10
|
ZERO,
|
|
10
11
|
add,
|
|
@@ -63,7 +64,7 @@ function checkDimension(d: number): number {
|
|
|
63
64
|
export function dimensionOf(op: ExactOperation): number {
|
|
64
65
|
const d = op.matrix.length;
|
|
65
66
|
if (d < 1 || d > 3 || op.translation.length !== d || op.matrix.some((row) => row.length !== d)) {
|
|
66
|
-
throw new RangeError(`Not an operation of dimension 1 to 3: ${
|
|
67
|
+
throw new RangeError(`Not an operation of dimension 1 to 3: ${shown(op)}`);
|
|
67
68
|
}
|
|
68
69
|
for (const row of op.matrix) {
|
|
69
70
|
for (const v of row) {
|
|
@@ -118,7 +119,7 @@ export function checkUnimodular(op: ExactOperation): void {
|
|
|
118
119
|
dimensionOf(op);
|
|
119
120
|
const det = determinant(op.matrix);
|
|
120
121
|
if (det !== 1 && det !== -1) {
|
|
121
|
-
throw new RangeError(`Determinant ${det} is not ±1: ${
|
|
122
|
+
throw new RangeError(`Determinant ${det} is not ±1: ${shown(op.matrix)}`);
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
|