react-cheminfo 0.134.0 → 0.135.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 +13 -0
- package/lib/crystal/core/bondGrid.d.ts +26 -0
- package/lib/crystal/core/bondGrid.d.ts.map +1 -0
- package/lib/crystal/core/bondGrid.js +76 -0
- package/lib/crystal/core/bondGrid.js.map +1 -0
- package/lib/crystal/core/cellBonds.d.ts +21 -0
- package/lib/crystal/core/cellBonds.d.ts.map +1 -0
- package/lib/crystal/core/cellBonds.js +100 -0
- package/lib/crystal/core/cellBonds.js.map +1 -0
- package/lib/crystal/core/cif/element.d.ts +9 -0
- package/lib/crystal/core/cif/element.d.ts.map +1 -0
- package/lib/crystal/core/cif/element.js +41 -0
- package/lib/crystal/core/cif/element.js.map +1 -0
- package/lib/crystal/core/cif/index.d.ts +4 -0
- package/lib/crystal/core/cif/index.d.ts.map +1 -0
- package/lib/crystal/core/cif/index.js +3 -0
- package/lib/crystal/core/cif/index.js.map +1 -0
- package/lib/crystal/core/cif/number.d.ts +27 -0
- package/lib/crystal/core/cif/number.d.ts.map +1 -0
- package/lib/crystal/core/cif/number.js +57 -0
- package/lib/crystal/core/cif/number.js.map +1 -0
- package/lib/crystal/core/cif/read.d.ts +12 -0
- package/lib/crystal/core/cif/read.d.ts.map +1 -0
- package/lib/crystal/core/cif/read.js +183 -0
- package/lib/crystal/core/cif/read.js.map +1 -0
- package/lib/crystal/core/cif/readGeometry.d.ts +17 -0
- package/lib/crystal/core/cif/readGeometry.d.ts.map +1 -0
- package/lib/crystal/core/cif/readGeometry.js +93 -0
- package/lib/crystal/core/cif/readGeometry.js.map +1 -0
- package/lib/crystal/core/cif/tags.d.ts +62 -0
- package/lib/crystal/core/cif/tags.d.ts.map +1 -0
- package/lib/crystal/core/cif/tags.js +115 -0
- package/lib/crystal/core/cif/tags.js.map +1 -0
- package/lib/crystal/core/cif/types.d.ts +158 -0
- package/lib/crystal/core/cif/types.d.ts.map +1 -0
- package/lib/crystal/core/cif/types.js +2 -0
- package/lib/crystal/core/cif/types.js.map +1 -0
- package/lib/crystal/core/components.d.ts +56 -0
- package/lib/crystal/core/components.d.ts.map +1 -0
- package/lib/crystal/core/components.js +132 -0
- package/lib/crystal/core/components.js.map +1 -0
- package/lib/crystal/core/covalentRadii.d.ts +24 -0
- package/lib/crystal/core/covalentRadii.d.ts.map +1 -0
- package/lib/crystal/core/covalentRadii.js +55 -0
- package/lib/crystal/core/covalentRadii.js.map +1 -0
- package/lib/crystal/core/disorder.d.ts +59 -0
- package/lib/crystal/core/disorder.d.ts.map +1 -0
- package/lib/crystal/core/disorder.js +168 -0
- package/lib/crystal/core/disorder.js.map +1 -0
- package/lib/crystal/core/expand.d.ts +62 -0
- package/lib/crystal/core/expand.d.ts.map +1 -0
- package/lib/crystal/core/expand.js +61 -0
- package/lib/crystal/core/expand.js.map +1 -0
- package/lib/crystal/core/index.d.ts +18 -0
- package/lib/crystal/core/index.d.ts.map +1 -0
- package/lib/crystal/core/index.js +12 -0
- package/lib/crystal/core/index.js.map +1 -0
- package/lib/crystal/core/moleculeOf.d.ts +31 -0
- package/lib/crystal/core/moleculeOf.d.ts.map +1 -0
- package/lib/crystal/core/moleculeOf.js +128 -0
- package/lib/crystal/core/moleculeOf.js.map +1 -0
- package/lib/crystal/core/moleculeTypes.d.ts +80 -0
- package/lib/crystal/core/moleculeTypes.d.ts.map +1 -0
- package/lib/crystal/core/moleculeTypes.js +2 -0
- package/lib/crystal/core/moleculeTypes.js.map +1 -0
- package/lib/crystal/core/molecules.d.ts +39 -0
- package/lib/crystal/core/molecules.d.ts.map +1 -0
- package/lib/crystal/core/molecules.js +140 -0
- package/lib/crystal/core/molecules.js.map +1 -0
- package/lib/crystal/core/operations.d.ts +19 -0
- package/lib/crystal/core/operations.d.ts.map +1 -0
- package/lib/crystal/core/operations.js +68 -0
- package/lib/crystal/core/operations.js.map +1 -0
- package/lib/crystal/core/packing.d.ts +43 -0
- package/lib/crystal/core/packing.d.ts.map +1 -0
- package/lib/crystal/core/packing.js +89 -0
- package/lib/crystal/core/packing.js.map +1 -0
- package/lib/crystal/core/periodicBonds.d.ts +57 -0
- package/lib/crystal/core/periodicBonds.d.ts.map +1 -0
- package/lib/crystal/core/periodicBonds.js +167 -0
- package/lib/crystal/core/periodicBonds.js.map +1 -0
- package/lib/crystal/core/resolve.d.ts +61 -0
- package/lib/crystal/core/resolve.d.ts.map +1 -0
- package/lib/crystal/core/resolve.js +149 -0
- package/lib/crystal/core/resolve.js.map +1 -0
- package/lib/crystal/core/spaceGroups/index.d.ts +5 -0
- package/lib/crystal/core/spaceGroups/index.d.ts.map +1 -0
- package/lib/crystal/core/spaceGroups/index.js +4 -0
- package/lib/crystal/core/spaceGroups/index.js.map +1 -0
- package/lib/crystal/core/spaceGroups/spaceGroupOperations.d.ts +14 -0
- package/lib/crystal/core/spaceGroups/spaceGroupOperations.d.ts.map +1 -0
- package/lib/crystal/core/spaceGroups/spaceGroupOperations.js +24 -0
- package/lib/crystal/core/spaceGroups/spaceGroupOperations.js.map +1 -0
- package/lib/crystal/core/spaceGroups/spaceGroupRows.d.ts +3 -0
- package/lib/crystal/core/spaceGroups/spaceGroupRows.d.ts.map +1 -0
- package/lib/crystal/core/spaceGroups/spaceGroupRows.js +536 -0
- package/lib/crystal/core/spaceGroups/spaceGroupRows.js.map +1 -0
- package/lib/crystal/core/spaceGroups/spaceGroupSymbols.d.ts +43 -0
- package/lib/crystal/core/spaceGroups/spaceGroupSymbols.d.ts.map +1 -0
- package/lib/crystal/core/spaceGroups/spaceGroupSymbols.js +169 -0
- package/lib/crystal/core/spaceGroups/spaceGroupSymbols.js.map +1 -0
- package/lib/crystal/core/spaceGroups/spaceGroups.d.ts +78 -0
- package/lib/crystal/core/spaceGroups/spaceGroups.d.ts.map +1 -0
- package/lib/crystal/core/spaceGroups/spaceGroups.js +83 -0
- package/lib/crystal/core/spaceGroups/spaceGroups.js.map +1 -0
- package/lib/crystal/core/symmetry/group.d.ts +15 -0
- package/lib/crystal/core/symmetry/group.d.ts.map +1 -0
- package/lib/crystal/core/symmetry/group.js +37 -0
- package/lib/crystal/core/symmetry/group.js.map +1 -0
- package/lib/crystal/core/symmetry/index.d.ts +8 -0
- package/lib/crystal/core/symmetry/index.d.ts.map +1 -0
- package/lib/crystal/core/symmetry/index.js +6 -0
- package/lib/crystal/core/symmetry/index.js.map +1 -0
- package/lib/crystal/core/symmetry/integerMatrix.d.ts +45 -0
- package/lib/crystal/core/symmetry/integerMatrix.d.ts.map +1 -0
- package/lib/crystal/core/symmetry/integerMatrix.js +139 -0
- package/lib/crystal/core/symmetry/integerMatrix.js.map +1 -0
- package/lib/crystal/core/symmetry/lattice.d.ts +64 -0
- package/lib/crystal/core/symmetry/lattice.d.ts.map +1 -0
- package/lib/crystal/core/symmetry/lattice.js +113 -0
- package/lib/crystal/core/symmetry/lattice.js.map +1 -0
- package/lib/crystal/core/symmetry/operation.d.ts +91 -0
- package/lib/crystal/core/symmetry/operation.d.ts.map +1 -0
- package/lib/crystal/core/symmetry/operation.js +184 -0
- package/lib/crystal/core/symmetry/operation.js.map +1 -0
- package/lib/crystal/core/symmetry/parseOperation.d.ts +18 -0
- package/lib/crystal/core/symmetry/parseOperation.d.ts.map +1 -0
- package/lib/crystal/core/symmetry/parseOperation.js +145 -0
- package/lib/crystal/core/symmetry/parseOperation.js.map +1 -0
- package/lib/crystal/core/symmetry/types.d.ts +29 -0
- package/lib/crystal/core/symmetry/types.d.ts.map +1 -0
- package/lib/crystal/core/symmetry/types.js +5 -0
- package/lib/crystal/core/symmetry/types.js.map +1 -0
- package/lib/crystal/core/symmetryClasses.d.ts +28 -0
- package/lib/crystal/core/symmetryClasses.d.ts.map +1 -0
- package/lib/crystal/core/symmetryClasses.js +93 -0
- package/lib/crystal/core/symmetryClasses.js.map +1 -0
- package/lib/crystal.d.ts +12 -0
- package/lib/crystal.d.ts.map +1 -0
- package/lib/crystal.js +12 -0
- package/lib/crystal.js.map +1 -0
- package/lib/server/spaSite.d.ts.map +1 -1
- package/lib/server/spaSite.js +9 -0
- package/lib/server/spaSite.js.map +1 -1
- package/package.json +3 -1
- package/src/crystal/core/bondGrid.ts +98 -0
- package/src/crystal/core/cellBonds.ts +121 -0
- package/src/crystal/core/cif/element.ts +40 -0
- package/src/crystal/core/cif/index.ts +12 -0
- package/src/crystal/core/cif/number.ts +62 -0
- package/src/crystal/core/cif/read.ts +218 -0
- package/src/crystal/core/cif/readGeometry.ts +104 -0
- package/src/crystal/core/cif/tags.ts +143 -0
- package/src/crystal/core/cif/types.ts +164 -0
- package/src/crystal/core/components.ts +183 -0
- package/src/crystal/core/covalentRadii.ts +56 -0
- package/src/crystal/core/disorder.ts +190 -0
- package/src/crystal/core/expand.ts +105 -0
- package/src/crystal/core/index.ts +44 -0
- package/src/crystal/core/moleculeOf.ts +169 -0
- package/src/crystal/core/moleculeTypes.ts +85 -0
- package/src/crystal/core/molecules.ts +165 -0
- package/src/crystal/core/operations.ts +79 -0
- package/src/crystal/core/packing.ts +116 -0
- package/src/crystal/core/periodicBonds.ts +234 -0
- package/src/crystal/core/resolve.ts +187 -0
- package/src/crystal/core/spaceGroups/index.ts +16 -0
- package/src/crystal/core/spaceGroups/spaceGroupOperations.ts +32 -0
- package/src/crystal/core/spaceGroups/spaceGroupRows.ts +536 -0
- package/src/crystal/core/spaceGroups/spaceGroupSymbols.ts +179 -0
- package/src/crystal/core/spaceGroups/spaceGroups.ts +154 -0
- package/src/crystal/core/symmetry/group.ts +42 -0
- package/src/crystal/core/symmetry/index.ts +23 -0
- package/src/crystal/core/symmetry/integerMatrix.ts +153 -0
- package/src/crystal/core/symmetry/lattice.ts +152 -0
- package/src/crystal/core/symmetry/operation.ts +223 -0
- package/src/crystal/core/symmetry/parseOperation.ts +180 -0
- package/src/crystal/core/symmetry/types.ts +32 -0
- package/src/crystal/core/symmetryClasses.ts +105 -0
- package/src/crystal.ts +12 -0
- package/src/server/spaSite.ts +9 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The product `a · b` of two square integer matrices of the same size.
|
|
3
|
+
* @param a - Left factor, row-major.
|
|
4
|
+
* @param b - Right factor, row-major.
|
|
5
|
+
* @returns The product, row-major.
|
|
6
|
+
*/
|
|
7
|
+
export function multiplyMatrices(a, b) {
|
|
8
|
+
const size = a.length;
|
|
9
|
+
const product = [];
|
|
10
|
+
for (let i = 0; i < size; i++) {
|
|
11
|
+
const values = new Array(size).fill(0);
|
|
12
|
+
for (let k = 0; k < size; k++) {
|
|
13
|
+
const factor = entry(a, i, k);
|
|
14
|
+
if (factor === 0)
|
|
15
|
+
continue;
|
|
16
|
+
for (let j = 0; j < size; j++) {
|
|
17
|
+
values[j] = (values[j] ?? 0) + factor * entry(b, k, j);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
product.push(values);
|
|
21
|
+
}
|
|
22
|
+
return product;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The product `matrix · vector`.
|
|
26
|
+
* @param matrix - The matrix, row-major.
|
|
27
|
+
* @param vector - The vector.
|
|
28
|
+
* @returns The image of the vector.
|
|
29
|
+
*/
|
|
30
|
+
export function multiplyMatrixVector(matrix, vector) {
|
|
31
|
+
const size = matrix.length;
|
|
32
|
+
const image = new Array(size).fill(0);
|
|
33
|
+
for (let i = 0; i < size; i++) {
|
|
34
|
+
let sum = 0;
|
|
35
|
+
for (let j = 0; j < vector.length; j++) {
|
|
36
|
+
sum += entry(matrix, i, j) * (vector[j] ?? 0);
|
|
37
|
+
}
|
|
38
|
+
image[i] = sum;
|
|
39
|
+
}
|
|
40
|
+
return image;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The `size × size` identity matrix.
|
|
44
|
+
* @param size - 2 or 3.
|
|
45
|
+
* @returns The identity matrix.
|
|
46
|
+
*/
|
|
47
|
+
export function identityMatrix(size) {
|
|
48
|
+
const identity = [];
|
|
49
|
+
for (let i = 0; i < size; i++) {
|
|
50
|
+
const values = new Array(size).fill(0);
|
|
51
|
+
values[i] = 1;
|
|
52
|
+
identity.push(values);
|
|
53
|
+
}
|
|
54
|
+
return identity;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The determinant of a 2×2 or 3×3 integer matrix.
|
|
58
|
+
* @param matrix - A 2×2 or 3×3 matrix.
|
|
59
|
+
* @throws {RangeError} When the matrix is not 2×2 or 3×3; no crystallographic operation is.
|
|
60
|
+
* @returns The determinant.
|
|
61
|
+
*/
|
|
62
|
+
export function matrixDeterminant(matrix) {
|
|
63
|
+
if (matrix.length === 2) {
|
|
64
|
+
return (entry(matrix, 0, 0) * entry(matrix, 1, 1) -
|
|
65
|
+
entry(matrix, 0, 1) * entry(matrix, 1, 0));
|
|
66
|
+
}
|
|
67
|
+
if (matrix.length !== 3) {
|
|
68
|
+
throw new RangeError(`expected a 2×2 or 3×3 matrix, received ${matrix.length}×${matrix.length}`);
|
|
69
|
+
}
|
|
70
|
+
// The cyclic cofactor expansion: the index rotation already carries the sign,
|
|
71
|
+
// so there is no alternating factor to apply on top of it.
|
|
72
|
+
let determinant = 0;
|
|
73
|
+
for (let j = 0; j < 3; j++) {
|
|
74
|
+
determinant +=
|
|
75
|
+
entry(matrix, 0, j) *
|
|
76
|
+
(entry(matrix, 1, (j + 1) % 3) * entry(matrix, 2, (j + 2) % 3) -
|
|
77
|
+
entry(matrix, 1, (j + 2) % 3) * entry(matrix, 2, (j + 1) % 3));
|
|
78
|
+
}
|
|
79
|
+
return determinant;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The adjugate: `adjugate(m) · m = det(m) · I`, exactly, in integers.
|
|
83
|
+
*
|
|
84
|
+
* It is how this core inverts an integer matrix without ever dividing, so an
|
|
85
|
+
* element's position stays an exact fraction.
|
|
86
|
+
* @param matrix - A 2×2 or 3×3 matrix.
|
|
87
|
+
* @returns The adjugate.
|
|
88
|
+
*/
|
|
89
|
+
export function matrixAdjugate(matrix) {
|
|
90
|
+
if (matrix.length === 2) {
|
|
91
|
+
return [
|
|
92
|
+
[entry(matrix, 1, 1), -entry(matrix, 0, 1)],
|
|
93
|
+
[-entry(matrix, 1, 0), entry(matrix, 0, 0)],
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
const adjugate = [];
|
|
97
|
+
for (let i = 0; i < 3; i++) {
|
|
98
|
+
const values = new Array(3).fill(0);
|
|
99
|
+
for (let j = 0; j < 3; j++) {
|
|
100
|
+
const rows = [(j + 1) % 3, (j + 2) % 3];
|
|
101
|
+
const columns = [(i + 1) % 3, (i + 2) % 3];
|
|
102
|
+
values[j] =
|
|
103
|
+
entry(matrix, rows[0] ?? 0, columns[0] ?? 0) *
|
|
104
|
+
entry(matrix, rows[1] ?? 0, columns[1] ?? 0) -
|
|
105
|
+
entry(matrix, rows[0] ?? 0, columns[1] ?? 0) *
|
|
106
|
+
entry(matrix, rows[1] ?? 0, columns[0] ?? 0);
|
|
107
|
+
}
|
|
108
|
+
adjugate.push(values);
|
|
109
|
+
}
|
|
110
|
+
return adjugate;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Whether two matrices hold the same integers.
|
|
114
|
+
* @param a - One matrix.
|
|
115
|
+
* @param b - The other.
|
|
116
|
+
* @returns Whether every entry is the same.
|
|
117
|
+
*/
|
|
118
|
+
export function matricesEqual(a, b) {
|
|
119
|
+
if (a.length !== b.length)
|
|
120
|
+
return false;
|
|
121
|
+
for (let i = 0; i < a.length; i++) {
|
|
122
|
+
for (let j = 0; j < a.length; j++) {
|
|
123
|
+
if (entry(a, i, j) !== entry(b, i, j))
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* One entry, or 0 outside the matrix, so `noUncheckedIndexedAccess` costs nothing here.
|
|
131
|
+
* @param matrix - The matrix.
|
|
132
|
+
* @param row - Row index.
|
|
133
|
+
* @param column - Column index.
|
|
134
|
+
* @returns The entry.
|
|
135
|
+
*/
|
|
136
|
+
function entry(matrix, row, column) {
|
|
137
|
+
return matrix[row]?.[column] ?? 0;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=integerMatrix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integerMatrix.js","sourceRoot":"","sources":["../../../../src/crystal/core/symmetry/integerMatrix.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,CAAgB,EAChB,CAAgB;IAEhB,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC;IACtB,MAAM,OAAO,GAAe,EAAE,CAAC;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,IAAI,KAAK,CAAS,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC/C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;YAC9B,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC9B,IAAI,MAAM,KAAK,CAAC;gBAAE,SAAS;YAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC9B,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAA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AC;QACnD,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,CAAgB,EAAE,CAAgB;IAC9D,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;QACtD,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;GAMG;AACH,SAAS,KAAK,CAAC,MAAqB,EAAE,GAAW,EAAE,MAAc;IAC/D,OAAO,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** The six parameters of a unit cell: three edges in Å, three angles in degrees. */
|
|
2
|
+
export interface UnitCell {
|
|
3
|
+
readonly a: number;
|
|
4
|
+
readonly b: number;
|
|
5
|
+
readonly c: number;
|
|
6
|
+
/** Angle between b and c, in degrees. */
|
|
7
|
+
readonly alpha: number;
|
|
8
|
+
/** Angle between c and a, in degrees. */
|
|
9
|
+
readonly beta: number;
|
|
10
|
+
/** Angle between a and b, in degrees. */
|
|
11
|
+
readonly gamma: number;
|
|
12
|
+
}
|
|
13
|
+
/** A cell with everything derived from it computed once. */
|
|
14
|
+
export interface Lattice {
|
|
15
|
+
readonly cell: UnitCell;
|
|
16
|
+
/** The cell volume in ų. */
|
|
17
|
+
readonly volume: number;
|
|
18
|
+
/** M, whose columns are the Cartesian components of a, b and c. */
|
|
19
|
+
readonly cartesian: number[][];
|
|
20
|
+
/** M⁻¹. */
|
|
21
|
+
readonly fractional: number[][];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Everything a cell implies, computed once.
|
|
25
|
+
*
|
|
26
|
+
* **The Cartesian convention is the PDB / CCP4 one**, which is what molstar and
|
|
27
|
+
* every CIF consumer assumes: **a** lies along **x**, **b** lies in the **xy**
|
|
28
|
+
* plane with a positive **y** component, and **c** completes a right-handed set.
|
|
29
|
+
* There are two other conventions in common use and they disagree with this one,
|
|
30
|
+
* so never mix Cartesian coordinates from another source without checking.
|
|
31
|
+
* @param cell - The six cell parameters.
|
|
32
|
+
* @returns The lattice.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createLattice(cell: UnitCell): Lattice;
|
|
35
|
+
/**
|
|
36
|
+
* The cell volume in ų, from the closed form; it equals `sqrt(det G)`.
|
|
37
|
+
* @param cell - The six cell parameters.
|
|
38
|
+
* @throws {RangeError} When the three angles describe no cell that exists. A CIF can carry
|
|
39
|
+
* such a triple, and without this the volume is `NaN` and every coordinate
|
|
40
|
+
* downstream of it silently becomes one too.
|
|
41
|
+
* @returns The volume, ų.
|
|
42
|
+
*/
|
|
43
|
+
export declare function cellVolume(cell: UnitCell): number;
|
|
44
|
+
/**
|
|
45
|
+
* M, whose columns are the Cartesian components of a, b and c. `G = Mᵀ M`.
|
|
46
|
+
* @param cell - The six cell parameters.
|
|
47
|
+
* @returns M, row-major.
|
|
48
|
+
*/
|
|
49
|
+
export declare function cartesianMatrix(cell: UnitCell): number[][];
|
|
50
|
+
/**
|
|
51
|
+
* The Cartesian coordinates, in Å, of a fractional point.
|
|
52
|
+
* @param lattice - The cell.
|
|
53
|
+
* @param point - Fractional coordinates.
|
|
54
|
+
* @returns The Cartesian coordinates, Å.
|
|
55
|
+
*/
|
|
56
|
+
export declare function fractionalToCartesian(lattice: Lattice, point: readonly number[]): number[];
|
|
57
|
+
/**
|
|
58
|
+
* The fractional coordinates of a Cartesian point given in Å.
|
|
59
|
+
* @param lattice - The cell.
|
|
60
|
+
* @param point - Cartesian coordinates, Å.
|
|
61
|
+
* @returns The fractional coordinates.
|
|
62
|
+
*/
|
|
63
|
+
export declare function cartesianToFractional(lattice: Lattice, point: readonly number[]): number[];
|
|
64
|
+
//# sourceMappingURL=lattice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lattice.d.ts","sourceRoot":"","sources":["../../../../src/crystal/core/symmetry/lattice.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,4DAA4D;AAC5D,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,6BAA6B;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,mEAAmE;IACnE,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;IAC/B,WAAW;IACX,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC;CACjC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAQrD;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAgBjD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,EAAE,EAAE,CAW1D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,MAAM,EAAE,CAEV;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,MAAM,EAAE,CAEV"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Everything a cell implies, computed once.
|
|
3
|
+
*
|
|
4
|
+
* **The Cartesian convention is the PDB / CCP4 one**, which is what molstar and
|
|
5
|
+
* every CIF consumer assumes: **a** lies along **x**, **b** lies in the **xy**
|
|
6
|
+
* plane with a positive **y** component, and **c** completes a right-handed set.
|
|
7
|
+
* There are two other conventions in common use and they disagree with this one,
|
|
8
|
+
* so never mix Cartesian coordinates from another source without checking.
|
|
9
|
+
* @param cell - The six cell parameters.
|
|
10
|
+
* @returns The lattice.
|
|
11
|
+
*/
|
|
12
|
+
export function createLattice(cell) {
|
|
13
|
+
const cartesian = cartesianMatrix(cell);
|
|
14
|
+
return {
|
|
15
|
+
cell,
|
|
16
|
+
volume: cellVolume(cell),
|
|
17
|
+
cartesian,
|
|
18
|
+
fractional: invertUpperTriangular(cartesian),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The cell volume in ų, from the closed form; it equals `sqrt(det G)`.
|
|
23
|
+
* @param cell - The six cell parameters.
|
|
24
|
+
* @throws {RangeError} When the three angles describe no cell that exists. A CIF can carry
|
|
25
|
+
* such a triple, and without this the volume is `NaN` and every coordinate
|
|
26
|
+
* downstream of it silently becomes one too.
|
|
27
|
+
* @returns The volume, ų.
|
|
28
|
+
*/
|
|
29
|
+
export function cellVolume(cell) {
|
|
30
|
+
const cosAlpha = Math.cos(toRadians(cell.alpha));
|
|
31
|
+
const cosBeta = Math.cos(toRadians(cell.beta));
|
|
32
|
+
const cosGamma = Math.cos(toRadians(cell.gamma));
|
|
33
|
+
const factor = 1 -
|
|
34
|
+
cosAlpha * cosAlpha -
|
|
35
|
+
cosBeta * cosBeta -
|
|
36
|
+
cosGamma * cosGamma +
|
|
37
|
+
2 * cosAlpha * cosBeta * cosGamma;
|
|
38
|
+
if (factor <= 0) {
|
|
39
|
+
throw new RangeError(`no cell has the angles ${cell.alpha}, ${cell.beta}, ${cell.gamma} degrees`);
|
|
40
|
+
}
|
|
41
|
+
return cell.a * cell.b * cell.c * Math.sqrt(factor);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* M, whose columns are the Cartesian components of a, b and c. `G = Mᵀ M`.
|
|
45
|
+
* @param cell - The six cell parameters.
|
|
46
|
+
* @returns M, row-major.
|
|
47
|
+
*/
|
|
48
|
+
export function cartesianMatrix(cell) {
|
|
49
|
+
const { a, b, c, alpha, beta, gamma } = cell;
|
|
50
|
+
const cosAlpha = Math.cos(toRadians(alpha));
|
|
51
|
+
const cosBeta = Math.cos(toRadians(beta));
|
|
52
|
+
const cosGamma = Math.cos(toRadians(gamma));
|
|
53
|
+
const sinGamma = Math.sin(toRadians(gamma));
|
|
54
|
+
return [
|
|
55
|
+
[a, b * cosGamma, c * cosBeta],
|
|
56
|
+
[0, b * sinGamma, (c * (cosAlpha - cosBeta * cosGamma)) / sinGamma],
|
|
57
|
+
[0, 0, cellVolume(cell) / (a * b * sinGamma)],
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The Cartesian coordinates, in Å, of a fractional point.
|
|
62
|
+
* @param lattice - The cell.
|
|
63
|
+
* @param point - Fractional coordinates.
|
|
64
|
+
* @returns The Cartesian coordinates, Å.
|
|
65
|
+
*/
|
|
66
|
+
export function fractionalToCartesian(lattice, point) {
|
|
67
|
+
return applyMatrix(lattice.cartesian, point);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The fractional coordinates of a Cartesian point given in Å.
|
|
71
|
+
* @param lattice - The cell.
|
|
72
|
+
* @param point - Cartesian coordinates, Å.
|
|
73
|
+
* @returns The fractional coordinates.
|
|
74
|
+
*/
|
|
75
|
+
export function cartesianToFractional(lattice, point) {
|
|
76
|
+
return applyMatrix(lattice.fractional, point);
|
|
77
|
+
}
|
|
78
|
+
function applyMatrix(matrix, point) {
|
|
79
|
+
const image = new Array(matrix.length).fill(0);
|
|
80
|
+
for (let i = 0; i < matrix.length; i++) {
|
|
81
|
+
const row = matrix[i];
|
|
82
|
+
let sum = 0;
|
|
83
|
+
for (let j = 0; j < matrix.length; j++) {
|
|
84
|
+
sum += (row?.[j] ?? 0) * (point[j] ?? 0);
|
|
85
|
+
}
|
|
86
|
+
image[i] = sum;
|
|
87
|
+
}
|
|
88
|
+
return image;
|
|
89
|
+
}
|
|
90
|
+
function toRadians(degrees) {
|
|
91
|
+
return (degrees * Math.PI) / 180;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* M⁻¹ in closed form: M has a along x and b in the xy plane, so it is upper
|
|
95
|
+
* triangular and its diagonal is never zero for a cell that exists.
|
|
96
|
+
* @param matrix - M.
|
|
97
|
+
* @returns M⁻¹.
|
|
98
|
+
*/
|
|
99
|
+
function invertUpperTriangular(matrix) {
|
|
100
|
+
const [row0 = [], row1 = [], row2 = []] = matrix;
|
|
101
|
+
const m00 = row0[0] ?? 1;
|
|
102
|
+
const m01 = row0[1] ?? 0;
|
|
103
|
+
const m02 = row0[2] ?? 0;
|
|
104
|
+
const m11 = row1[1] ?? 1;
|
|
105
|
+
const m12 = row1[2] ?? 0;
|
|
106
|
+
const m22 = row2[2] ?? 1;
|
|
107
|
+
return [
|
|
108
|
+
[1 / m00, -m01 / (m00 * m11), (m01 * m12 - m02 * m11) / (m00 * m11 * m22)],
|
|
109
|
+
[0, 1 / m11, -m12 / (m11 * m22)],
|
|
110
|
+
[0, 0, 1 / m22],
|
|
111
|
+
];
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=lattice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lattice.js","sourceRoot":"","sources":["../../../../src/crystal/core/symmetry/lattice.ts"],"names":[],"mappings":"AAwBA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAAC,IAAc;IAC1C,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACxC,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC;QACxB,SAAS;QACT,UAAU,EAAE,qBAAqB,CAAC,SAAS,CAAC;KAC7C,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,IAAc;IACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACjD,MAAM,MAAM,GACV,CAAC;QACD,QAAQ,GAAG,QAAQ;QACnB,OAAO,GAAG,OAAO;QACjB,QAAQ,GAAG,QAAQ;QACnB,CAAC,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;IACpC,IAAI,MAAM,IAAI,CAAC,EAAE,CAAC;QAChB,MAAM,IAAI,UAAU,CAClB,0BAA0B,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,UAAU,CAC5E,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAA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AAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACzB,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACzB,OAAO;QACL,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;QAC1E,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;QAChC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { CrystalOperation, Dimension } from './types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The composition `a ∘ b`: apply `b` first, then `a`, so
|
|
4
|
+
* `compose(a, b)(point)` is `apply(a, apply(b, point))`.
|
|
5
|
+
*
|
|
6
|
+
* The rotation part is `Wa · Wb` and the translation is `Wa · wb + wa`, reduced
|
|
7
|
+
* into the cell — exact integer arithmetic throughout.
|
|
8
|
+
* @param a - The operation applied second.
|
|
9
|
+
* @param b - The operation applied first.
|
|
10
|
+
* @returns The composed operation.
|
|
11
|
+
*/
|
|
12
|
+
export declare function compose<D extends Dimension>(a: CrystalOperation<D>, b: CrystalOperation<D>): CrystalOperation<D>;
|
|
13
|
+
/**
|
|
14
|
+
* The inverse operation: rotation `W⁻¹`, translation `−W⁻¹ · w`.
|
|
15
|
+
* @param operation - The operation.
|
|
16
|
+
* @returns The inverse operation.
|
|
17
|
+
*/
|
|
18
|
+
export declare function inverse<D extends Dimension>(operation: CrystalOperation<D>): CrystalOperation<D>;
|
|
19
|
+
/**
|
|
20
|
+
* The image `W · point + w` of a fractional point. The result is **not** wrapped
|
|
21
|
+
* into the cell: pass it through {@link wrapFractional} when the cell is what you
|
|
22
|
+
* want, and leave it alone when you are following a bond out of the cell.
|
|
23
|
+
* @param operation - The operation.
|
|
24
|
+
* @param point - A fractional point.
|
|
25
|
+
* @returns The image, not wrapped.
|
|
26
|
+
*/
|
|
27
|
+
export declare function apply(operation: CrystalOperation<Dimension>, point: readonly number[]): number[];
|
|
28
|
+
/**
|
|
29
|
+
* Each coordinate moved into [0, 1) by a whole number of cells.
|
|
30
|
+
* @param point - A fractional point.
|
|
31
|
+
* @returns The point, in [0, 1).
|
|
32
|
+
*/
|
|
33
|
+
export declare function wrapFractional(point: readonly number[]): number[];
|
|
34
|
+
/**
|
|
35
|
+
* The exact key of an operation modulo the lattice: two operations share a key
|
|
36
|
+
* when they are the same coset representative. Integers only, so the comparison
|
|
37
|
+
* is exact and a group expansion terminates.
|
|
38
|
+
* @param operation - The operation.
|
|
39
|
+
* @returns The key.
|
|
40
|
+
*/
|
|
41
|
+
export declare function operationKey(operation: CrystalOperation<Dimension>): string;
|
|
42
|
+
/**
|
|
43
|
+
* The identity operation of the given dimension.
|
|
44
|
+
* @param dimension - 2 or 3.
|
|
45
|
+
* @returns The identity.
|
|
46
|
+
*/
|
|
47
|
+
export declare function identityOperation<D extends Dimension>(dimension: D): CrystalOperation<D>;
|
|
48
|
+
/**
|
|
49
|
+
* Whether the operation is the identity, translation included.
|
|
50
|
+
* @param operation - The operation.
|
|
51
|
+
* @returns Whether it is the identity.
|
|
52
|
+
*/
|
|
53
|
+
export declare function isIdentity(operation: CrystalOperation<Dimension>): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* The orbit of one fractional position: every distinct image under the
|
|
56
|
+
* operations, wrapped into the cell.
|
|
57
|
+
*
|
|
58
|
+
* The returned `operationIndex` is what lets the page say *which* operation put
|
|
59
|
+
* an atom where it is, and hovering it highlight the element that generated it.
|
|
60
|
+
* Its length is the multiplicity of the position, which is exact.
|
|
61
|
+
* @param position - A fractional position; it need not be inside the cell.
|
|
62
|
+
* @param operations - The full coset list, centring translations included.
|
|
63
|
+
* @param tolerance - Fractional distance below which two images are one atom.
|
|
64
|
+
* @default 1e-4
|
|
65
|
+
* @returns One image per distinct position, with the index of the operation that made it.
|
|
66
|
+
*/
|
|
67
|
+
export declare function orbit(position: readonly number[], operations: ReadonlyArray<CrystalOperation<Dimension>>, tolerance?: number): Array<{
|
|
68
|
+
position: number[];
|
|
69
|
+
operationIndex: number;
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Whether two wrapped fractional positions are the same site, across the cell edge.
|
|
73
|
+
* @param a - One wrapped fractional position.
|
|
74
|
+
* @param b - The other.
|
|
75
|
+
* @param tolerance - Fractional distance below which they are one site.
|
|
76
|
+
* @returns Whether they are the same site.
|
|
77
|
+
*/
|
|
78
|
+
export declare function sameSite(a: readonly number[], b: readonly number[], tolerance?: number): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* A count of twelfths reduced into [0, 12).
|
|
81
|
+
* @param twelfths - A translation, in twelfths.
|
|
82
|
+
* @returns The count, in [0, 12).
|
|
83
|
+
*/
|
|
84
|
+
export declare function wrapTwelfths(twelfths: number): number;
|
|
85
|
+
/**
|
|
86
|
+
* The dimension an operation lives in, read off its rotation part.
|
|
87
|
+
* @param operation - The operation.
|
|
88
|
+
* @returns 2 or 3.
|
|
89
|
+
*/
|
|
90
|
+
export declare function dimensionOf(operation: CrystalOperation<Dimension>): Dimension;
|
|
91
|
+
//# sourceMappingURL=operation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../../src/crystal/core/symmetry/operation.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAM9D;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,SAAS,EACzC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,EACtB,CAAC,EAA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,EAAE,MAAM,GAAG,MAAM,CAIrD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,gBAAgB,CAAC,SAAS,CAAC,GAAG,SAAS,CAE7E"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { identityMatrix, matricesEqual, matrixAdjugate, matrixDeterminant, multiplyMatrices, multiplyMatrixVector, } from "./integerMatrix.js";
|
|
2
|
+
import { TWELFTHS_PER_CELL } from "./types.js";
|
|
3
|
+
/** How close two fractional coordinates must be to count as the same atom. */
|
|
4
|
+
const DEFAULT_TOLERANCE = 1e-4;
|
|
5
|
+
/**
|
|
6
|
+
* The composition `a ∘ b`: apply `b` first, then `a`, so
|
|
7
|
+
* `compose(a, b)(point)` is `apply(a, apply(b, point))`.
|
|
8
|
+
*
|
|
9
|
+
* The rotation part is `Wa · Wb` and the translation is `Wa · wb + wa`, reduced
|
|
10
|
+
* into the cell — exact integer arithmetic throughout.
|
|
11
|
+
* @param a - The operation applied second.
|
|
12
|
+
* @param b - The operation applied first.
|
|
13
|
+
* @returns The composed operation.
|
|
14
|
+
*/
|
|
15
|
+
export function compose(a, b) {
|
|
16
|
+
const rotation = multiplyMatrices(a.rotation, b.rotation);
|
|
17
|
+
const rotated = multiplyMatrixVector(a.rotation, b.translation);
|
|
18
|
+
const translation = new Array(rotated.length).fill(0);
|
|
19
|
+
for (let index = 0; index < rotated.length; index++) {
|
|
20
|
+
translation[index] = wrapTwelfths((rotated[index] ?? 0) + (a.translation[index] ?? 0));
|
|
21
|
+
}
|
|
22
|
+
return { dimension: a.dimension, rotation, translation };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The inverse operation: rotation `W⁻¹`, translation `−W⁻¹ · w`.
|
|
26
|
+
* @param operation - The operation.
|
|
27
|
+
* @returns The inverse operation.
|
|
28
|
+
*/
|
|
29
|
+
export function inverse(operation) {
|
|
30
|
+
const determinant = matrixDeterminant(operation.rotation);
|
|
31
|
+
const adjugate = matrixAdjugate(operation.rotation);
|
|
32
|
+
const rotation = [];
|
|
33
|
+
for (const row of adjugate) {
|
|
34
|
+
const values = new Array(adjugate.length).fill(0);
|
|
35
|
+
for (let j = 0; j < adjugate.length; j++) {
|
|
36
|
+
values[j] = (row[j] ?? 0) / determinant;
|
|
37
|
+
}
|
|
38
|
+
rotation.push(values);
|
|
39
|
+
}
|
|
40
|
+
const rotated = multiplyMatrixVector(rotation, operation.translation);
|
|
41
|
+
const translation = new Array(rotated.length).fill(0);
|
|
42
|
+
for (let index = 0; index < rotated.length; index++) {
|
|
43
|
+
translation[index] = wrapTwelfths(-(rotated[index] ?? 0));
|
|
44
|
+
}
|
|
45
|
+
return { dimension: operation.dimension, rotation, translation };
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The image `W · point + w` of a fractional point. The result is **not** wrapped
|
|
49
|
+
* into the cell: pass it through {@link wrapFractional} when the cell is what you
|
|
50
|
+
* want, and leave it alone when you are following a bond out of the cell.
|
|
51
|
+
* @param operation - The operation.
|
|
52
|
+
* @param point - A fractional point.
|
|
53
|
+
* @returns The image, not wrapped.
|
|
54
|
+
*/
|
|
55
|
+
export function apply(operation, point) {
|
|
56
|
+
const size = operation.rotation.length;
|
|
57
|
+
const image = new Array(size).fill(0);
|
|
58
|
+
for (let i = 0; i < size; i++) {
|
|
59
|
+
let sum = (operation.translation[i] ?? 0) / TWELFTHS_PER_CELL;
|
|
60
|
+
const row = operation.rotation[i];
|
|
61
|
+
for (let j = 0; j < size; j++)
|
|
62
|
+
sum += (row?.[j] ?? 0) * (point[j] ?? 0);
|
|
63
|
+
image[i] = sum;
|
|
64
|
+
}
|
|
65
|
+
return image;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Each coordinate moved into [0, 1) by a whole number of cells.
|
|
69
|
+
* @param point - A fractional point.
|
|
70
|
+
* @returns The point, in [0, 1).
|
|
71
|
+
*/
|
|
72
|
+
export function wrapFractional(point) {
|
|
73
|
+
const wrapped = new Array(point.length).fill(0);
|
|
74
|
+
for (let index = 0; index < point.length; index++) {
|
|
75
|
+
const value = point[index] ?? 0;
|
|
76
|
+
wrapped[index] = value - Math.floor(value);
|
|
77
|
+
}
|
|
78
|
+
return wrapped;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The exact key of an operation modulo the lattice: two operations share a key
|
|
82
|
+
* when they are the same coset representative. Integers only, so the comparison
|
|
83
|
+
* is exact and a group expansion terminates.
|
|
84
|
+
* @param operation - The operation.
|
|
85
|
+
* @returns The key.
|
|
86
|
+
*/
|
|
87
|
+
export function operationKey(operation) {
|
|
88
|
+
let key = '';
|
|
89
|
+
for (const row of operation.rotation) {
|
|
90
|
+
for (let j = 0; j < operation.rotation.length; j++) {
|
|
91
|
+
key += `${row[j] ?? 0},`;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
key += '|';
|
|
95
|
+
for (const twelfths of operation.translation) {
|
|
96
|
+
key += `${wrapTwelfths(twelfths)},`;
|
|
97
|
+
}
|
|
98
|
+
return key;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The identity operation of the given dimension.
|
|
102
|
+
* @param dimension - 2 or 3.
|
|
103
|
+
* @returns The identity.
|
|
104
|
+
*/
|
|
105
|
+
export function identityOperation(dimension) {
|
|
106
|
+
return {
|
|
107
|
+
dimension,
|
|
108
|
+
rotation: identityMatrix(dimension),
|
|
109
|
+
translation: new Array(dimension).fill(0),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Whether the operation is the identity, translation included.
|
|
114
|
+
* @param operation - The operation.
|
|
115
|
+
* @returns Whether it is the identity.
|
|
116
|
+
*/
|
|
117
|
+
export function isIdentity(operation) {
|
|
118
|
+
for (const twelfths of operation.translation) {
|
|
119
|
+
if (wrapTwelfths(twelfths) !== 0)
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
return matricesEqual(operation.rotation, identityMatrix(operation.rotation.length));
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The orbit of one fractional position: every distinct image under the
|
|
126
|
+
* operations, wrapped into the cell.
|
|
127
|
+
*
|
|
128
|
+
* The returned `operationIndex` is what lets the page say *which* operation put
|
|
129
|
+
* an atom where it is, and hovering it highlight the element that generated it.
|
|
130
|
+
* Its length is the multiplicity of the position, which is exact.
|
|
131
|
+
* @param position - A fractional position; it need not be inside the cell.
|
|
132
|
+
* @param operations - The full coset list, centring translations included.
|
|
133
|
+
* @param tolerance - Fractional distance below which two images are one atom.
|
|
134
|
+
* @default 1e-4
|
|
135
|
+
* @returns One image per distinct position, with the index of the operation that made it.
|
|
136
|
+
*/
|
|
137
|
+
export function orbit(position, operations, tolerance = DEFAULT_TOLERANCE) {
|
|
138
|
+
const images = [];
|
|
139
|
+
for (let index = 0; index < operations.length; index++) {
|
|
140
|
+
const operation = operations[index];
|
|
141
|
+
if (operation === undefined)
|
|
142
|
+
continue;
|
|
143
|
+
const image = wrapFractional(apply(operation, position));
|
|
144
|
+
let seen = false;
|
|
145
|
+
for (let other = 0; other < images.length && !seen; other++) {
|
|
146
|
+
seen = sameSite(image, images[other]?.position ?? [], tolerance);
|
|
147
|
+
}
|
|
148
|
+
if (!seen)
|
|
149
|
+
images.push({ position: image, operationIndex: index });
|
|
150
|
+
}
|
|
151
|
+
return images;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Whether two wrapped fractional positions are the same site, across the cell edge.
|
|
155
|
+
* @param a - One wrapped fractional position.
|
|
156
|
+
* @param b - The other.
|
|
157
|
+
* @param tolerance - Fractional distance below which they are one site.
|
|
158
|
+
* @returns Whether they are the same site.
|
|
159
|
+
*/
|
|
160
|
+
export function sameSite(a, b, tolerance = DEFAULT_TOLERANCE) {
|
|
161
|
+
for (let index = 0; index < a.length; index++) {
|
|
162
|
+
const difference = Math.abs((a[index] ?? 0) - (b[index] ?? 0));
|
|
163
|
+
if (Math.min(difference, 1 - difference) > tolerance)
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* A count of twelfths reduced into [0, 12).
|
|
170
|
+
* @param twelfths - A translation, in twelfths.
|
|
171
|
+
* @returns The count, in [0, 12).
|
|
172
|
+
*/
|
|
173
|
+
export function wrapTwelfths(twelfths) {
|
|
174
|
+
return (((twelfths % TWELFTHS_PER_CELL) + TWELFTHS_PER_CELL) % TWELFTHS_PER_CELL);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* The dimension an operation lives in, read off its rotation part.
|
|
178
|
+
* @param operation - The operation.
|
|
179
|
+
* @returns 2 or 3.
|
|
180
|
+
*/
|
|
181
|
+
export function dimensionOf(operation) {
|
|
182
|
+
return operation.rotation.length === 2 ? 2 : 3;
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../../src/crystal/core/symmetry/operation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,8EAA8E;AAC9E,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B;;;;;;;;;GASG;AACH,MAAM,UAAU,OAAO,CACrB,CAAsB,EACtB,CAAsB;IAEtB,MAAM,QAAQ,GAAG,gBAAgB,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC1D,MAAM,OAAO,GAAG,oBAAoB,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC;IAChE,MAAM,WAAW,GAAG,IAAI,KAAK,CAAS,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC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CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QAC9C,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC/D,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,GAAG,UAAU,CAAC,GAAG,SAAS;YAAE,OAAO,KAAK,CAAC;IACrE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,OAAO,CACL,CAAC,CAAC,QAAQ,GAAG,iBAAiB,CAAC,GAAG,iBAAiB,CAAC,GAAG,iBAAiB,CACzE,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,SAAsC;IAChE,OAAO,SAAS,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CrystalOperation, Dimension } from './types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Parse one coordinate triplet — `x,y,z`, `-x+1/2,-y,z+1/2`, `-x+y+2/3,-x+1/3,z+1/3`
|
|
4
|
+
* — into an exact operation.
|
|
5
|
+
*
|
|
6
|
+
* Accepts what the International Tables print and what a CIF may carry: any
|
|
7
|
+
* ordering of the terms (`1/2-x` as well as `-x+1/2`), a leading `+`, upper or
|
|
8
|
+
* lower case, decimal translations (`0.5+x`, `0.33333+y`), a translation of a
|
|
9
|
+
* whole cell, and whitespace anywhere. A two-dimensional operation is `x,y`.
|
|
10
|
+
* @param xyz - The triplet, with or without surrounding whitespace.
|
|
11
|
+
* @param dimension - 2 for a plane group, 3 for a space group.
|
|
12
|
+
* @throws {SyntaxError | RangeError} When the triplet has the wrong number of components, carries a
|
|
13
|
+
* variable coefficient outside {−1, 0, +1}, names an axis the dimension does
|
|
14
|
+
* not have, has a translation that is not a multiple of 1/12, or is singular.
|
|
15
|
+
* @returns The exact operation.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseOperation<D extends Dimension>(xyz: string, dimension: D): CrystalOperation<D>;
|
|
18
|
+
//# sourceMappingURL=parseOperation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseOperation.d.ts","sourceRoot":"","sources":["../../../../src/crystal/core/symmetry/parseOperation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAM9D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,SAAS,EAChD,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,CAAC,GACX,gBAAgB,CAAC,CAAC,CAAC,CAqBrB"}
|