symcrys 0.4.0 → 0.6.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 +15 -132
- package/dist/crystalClasses.d.ts +211 -0
- package/dist/crystalClasses.d.ts.map +1 -0
- package/dist/crystalClasses.js +295 -0
- package/dist/crystalClasses.js.map +1 -0
- package/dist/index.d.ts +11 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -8
- package/dist/index.js.map +1 -1
- package/dist/magnetic.d.ts +35 -0
- package/dist/magnetic.d.ts.map +1 -0
- package/dist/magnetic.js +22 -0
- package/dist/magnetic.js.map +1 -0
- package/dist/operations.d.ts +8 -0
- package/dist/operations.d.ts.map +1 -1
- package/dist/operations.js +25 -0
- package/dist/operations.js.map +1 -1
- package/dist/pointGroups/data.d.ts +34 -0
- package/dist/pointGroups/data.d.ts.map +1 -1
- package/dist/pointGroups/data.js +29 -21
- package/dist/pointGroups/data.js.map +1 -1
- package/dist/pointGroups/elements.d.ts +12 -5
- package/dist/pointGroups/elements.d.ts.map +1 -1
- package/dist/pointGroups/elements.js +6 -1
- package/dist/pointGroups/elements.js.map +1 -1
- package/dist/pointGroups/magneticData.d.ts +61 -0
- package/dist/pointGroups/magneticData.d.ts.map +1 -0
- package/dist/pointGroups/magneticData.js +180 -0
- package/dist/pointGroups/magneticData.js.map +1 -0
- package/dist/pointGroups/magneticSymbols.d.ts +22 -0
- package/dist/pointGroups/magneticSymbols.d.ts.map +1 -0
- package/dist/pointGroups/magneticSymbols.js +103 -0
- package/dist/pointGroups/magneticSymbols.js.map +1 -0
- package/dist/pointGroups/pointGroups.d.ts +94 -24
- package/dist/pointGroups/pointGroups.d.ts.map +1 -1
- package/dist/pointGroups/pointGroups.js +293 -47
- package/dist/pointGroups/pointGroups.js.map +1 -1
- package/dist/pointGroups/properties.d.ts +25 -16
- package/dist/pointGroups/properties.d.ts.map +1 -1
- package/dist/pointGroups/properties.js +46 -56
- package/dist/pointGroups/properties.js.map +1 -1
- package/dist/pointGroups/wyckoff.d.ts +2 -1
- package/dist/pointGroups/wyckoff.d.ts.map +1 -1
- package/dist/pointGroups/wyckoff.js +6 -2
- package/dist/pointGroups/wyckoff.js.map +1 -1
- package/dist/tensors/propertyTable.d.ts +35 -0
- package/dist/tensors/propertyTable.d.ts.map +1 -0
- package/dist/tensors/propertyTable.js +32 -0
- package/dist/tensors/propertyTable.js.map +1 -0
- package/dist/tensors/tensorForm.d.ts +16 -10
- package/dist/tensors/tensorForm.d.ts.map +1 -1
- package/dist/tensors/tensorForm.js +23 -24
- package/dist/tensors/tensorForm.js.map +1 -1
- package/dist/tensors/tensorProperties.d.ts +30 -0
- package/dist/tensors/tensorProperties.d.ts.map +1 -0
- package/dist/tensors/tensorProperties.js +44 -0
- package/dist/tensors/tensorProperties.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +9 -26
- package/src/crystalClasses.ts +436 -0
- package/src/index.ts +32 -38
- package/src/magnetic.ts +87 -0
- package/src/operations.ts +29 -0
- package/src/pointGroups/data.ts +29 -21
- package/src/pointGroups/elements.ts +23 -7
- package/src/pointGroups/magneticData.ts +322 -0
- package/src/pointGroups/magneticSymbols.ts +110 -0
- package/src/pointGroups/pointGroups.ts +380 -65
- package/src/pointGroups/properties.ts +47 -56
- package/src/pointGroups/wyckoff.ts +15 -2
- package/src/tensors/propertyTable.ts +79 -0
- package/src/tensors/tensorForm.ts +34 -28
- package/src/tensors/tensorProperties.ts +50 -0
- package/src/version.ts +1 -1
|
@@ -1,73 +1,64 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Properties
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Properties that follow from operations, for a list of operations of a caller, and the holohedry
|
|
3
|
+
* of a crystal system. The properties of a point group given by its key are fields of
|
|
4
|
+
* `pointGroup(key)` (pointGroups.ts). Properties that are the question whether a tensor is allowed
|
|
5
|
+
* (polar, piezoelectric, ferroaxial, ferromagnetic, …) are named tensor properties
|
|
6
|
+
* (tensors/tensorProperties.ts).
|
|
5
7
|
*/
|
|
6
8
|
|
|
9
|
+
import type { CrystalSystem } from '../lattice.js';
|
|
7
10
|
import { INVERSION, det, matricesEqual } from '../linalg.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { POINT_GROUP_KEYS, type PointGroupKey } from './data.js';
|
|
11
|
-
import { operations } from './pointGroups.js';
|
|
12
|
-
import { tensorForm } from '../tensors/tensorForm.js';
|
|
13
|
-
|
|
14
|
-
/** Operations in setting 1, the frame all stored data share. */
|
|
15
|
-
const stored = (key: PointGroupKey): readonly Operation[] => operations(key, { setting: 1 });
|
|
16
|
-
|
|
17
|
-
/** Contains the inversion. */
|
|
18
|
-
export function isCentrosymmetric(key: PointGroupKey): boolean {
|
|
19
|
-
return stored(key).some((op) => !op.timeReversal && matricesEqual(op.matrix, INVERSION));
|
|
20
|
-
}
|
|
11
|
+
import { checkOrthogonal, checkTimeReversal, closeGroup, type Operation } from '../operations.js';
|
|
12
|
+
import type { PointGroupKey } from './data.js';
|
|
21
13
|
|
|
22
14
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
15
|
+
* What every function for a list of operations asks of the list: Cartesian (orthogonal) matrices,
|
|
16
|
+
* and of every operation whether it is combined with time reversal, as `tensorFormOf` does.
|
|
25
17
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
for (let j = 0; j < 3; j++) {
|
|
30
|
-
let sum = 0;
|
|
31
|
-
for (const op of ops) sum += op.matrix[i][j];
|
|
32
|
-
if (Math.abs(sum / ops.length) > EPSILON) return true;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return false;
|
|
18
|
+
function check(operations: readonly Operation[]): void {
|
|
19
|
+
operations.forEach((op, i) => checkOrthogonal(op.matrix, `Operation ${i}`));
|
|
20
|
+
checkTimeReversal(operations);
|
|
36
21
|
}
|
|
37
22
|
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
/**
|
|
24
|
+
* True if the group generated by `operations` contains the inversion, not combined with time
|
|
25
|
+
* reversal: e.g. for the operations of a distorted crystal. A list that is not closed is closed
|
|
26
|
+
* first. For a point group given by its key, read `pointGroup(key).centrosymmetric`.
|
|
27
|
+
*/
|
|
28
|
+
export function isCentrosymmetricOf(operations: readonly Operation[]): boolean {
|
|
29
|
+
check(operations);
|
|
30
|
+
return closeGroup(operations).some((op) => !op.timeReversal && matricesEqual(op.matrix, INVERSION));
|
|
41
31
|
}
|
|
42
32
|
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
/**
|
|
34
|
+
* True if the group generated by `operations` is chiral: proper rotations only, with or without
|
|
35
|
+
* time reversal (products of proper rotations are proper, so the list need not be closed). For a
|
|
36
|
+
* point group given by its key, read `pointGroup(key).chiral`.
|
|
37
|
+
*/
|
|
38
|
+
export function isChiralOf(operations: readonly Operation[]): boolean {
|
|
39
|
+
check(operations);
|
|
40
|
+
return operations.every((op) => det(op.matrix) > 0);
|
|
45
41
|
}
|
|
46
42
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const product = compose(operation(INVERSION), op);
|
|
57
|
-
if (!withInversion.some((x) => operationsEqual(x, product))) withInversion.push(product);
|
|
58
|
-
}
|
|
59
|
-
const laue = POINT_GROUP_KEYS.find((k) => isCentrosymmetric(k) && sameSet(withInversion, stored(k)));
|
|
60
|
-
if (!laue) throw new Error(`laueClass: no centrosymmetric class matches ${key}`);
|
|
61
|
-
laueCache.set(key, laue);
|
|
62
|
-
return laue;
|
|
63
|
-
}
|
|
43
|
+
const HOLOHEDRY: Readonly<Record<CrystalSystem, PointGroupKey>> = Object.freeze({
|
|
44
|
+
triclinic: '-1',
|
|
45
|
+
monoclinic: '2/m',
|
|
46
|
+
orthorhombic: 'mmm',
|
|
47
|
+
tetragonal: '4/mmm',
|
|
48
|
+
trigonal: '-3m',
|
|
49
|
+
hexagonal: '6/mmm',
|
|
50
|
+
cubic: 'm-3m',
|
|
51
|
+
});
|
|
64
52
|
|
|
65
53
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
54
|
+
* The holohedry of a crystal system: the crystal class that is the point symmetry of a lattice of
|
|
55
|
+
* the system (ITA Table 2.1.1.1, the Laue groups in full boxes). For the trigonal system it is
|
|
56
|
+
* `-3m`, the symmetry of the rhombohedral lattice. The trigonal classes also occur with the
|
|
57
|
+
* hexagonal lattice, whose symmetry is `6/mmm`: the holohedry of the crystal family is
|
|
58
|
+
* `holohedry(crystalFamily(system))`, which is what the lattice basis of this library
|
|
59
|
+
* (`latticeBasis`, hexagonal axes for both systems) has.
|
|
68
60
|
*/
|
|
69
|
-
export function
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
);
|
|
61
|
+
export function holohedry(system: CrystalSystem): PointGroupKey {
|
|
62
|
+
if (!Object.hasOwn(HOLOHEDRY, system)) throw new RangeError(`Unknown crystal system: ${JSON.stringify(system)}`);
|
|
63
|
+
return HOLOHEDRY[system];
|
|
73
64
|
}
|
|
@@ -7,7 +7,14 @@
|
|
|
7
7
|
import { apply, inverse, transpose, type Mat3, type Vec3 } from '../linalg.js';
|
|
8
8
|
import { crystalFamily, latticeBasis } from '../lattice.js';
|
|
9
9
|
import { POINT_GROUP_DATA } from './data.js';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
isMagneticPointGroupKey,
|
|
12
|
+
isPointGroupKey,
|
|
13
|
+
operations,
|
|
14
|
+
settings,
|
|
15
|
+
type PointGroupKey,
|
|
16
|
+
type SettingOptions,
|
|
17
|
+
} from './pointGroups.js';
|
|
11
18
|
import { siteSymmetry, siteTolerance, type SiteSymmetryOptions } from '../siteSymmetry.js';
|
|
12
19
|
import { ITA_WYCKOFF, type WyckoffRow } from './wyckoffData.js';
|
|
13
20
|
|
|
@@ -150,6 +157,11 @@ function printedRows(key: PointGroupKey, setting: number): readonly WyckoffRow[]
|
|
|
150
157
|
const cache = new Map<string, readonly WyckoffPosition[]>();
|
|
151
158
|
|
|
152
159
|
function itcSetting(key: PointGroupKey, options?: SettingOptions): number {
|
|
160
|
+
if (isMagneticPointGroupKey(key) && !isPointGroupKey(key)) {
|
|
161
|
+
throw new RangeError(
|
|
162
|
+
`Wyckoff positions are given for the 32 crystal classes only; ${JSON.stringify(key)} is a magnetic point group`,
|
|
163
|
+
);
|
|
164
|
+
}
|
|
153
165
|
if ((options?.convention ?? 'itc') !== 'itc') {
|
|
154
166
|
throw new RangeError("Wyckoff positions exist in the ITC convention only (convention 'itc')");
|
|
155
167
|
}
|
|
@@ -161,7 +173,8 @@ function itcSetting(key: PointGroupKey, options?: SettingOptions): number {
|
|
|
161
173
|
|
|
162
174
|
/**
|
|
163
175
|
* The Wyckoff positions of a point group for directions, in ITA's printed order (general position
|
|
164
|
-
* first), in the ITC convention only (throws a RangeError for
|
|
176
|
+
* first), for the 32 crystal classes and in the ITC convention only (throws a RangeError for a
|
|
177
|
+
* magnetic point group with time reversal and for `'birss'`). The point at the origin
|
|
165
178
|
* (letter o) is not a direction and is left out. For `mm2` settings 2 and 3 (`2mm`, `m2m`), which
|
|
166
179
|
* ITA does not print, the positions of setting 1 carried into their frame.
|
|
167
180
|
*/
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Named tensor properties: physical properties of a crystal that a point group allows if and only
|
|
3
|
+
* if it allows a non-zero tensor of a given kind. The table is data: a name, the kind of tensor
|
|
4
|
+
* (`TensorSpec`) and the print source of that definition. `allowsProperty` and `tensorForm` look a
|
|
5
|
+
* name up here (docs/conventions.md, "Named tensor properties").
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { TensorSpec } from './tensorForm.js';
|
|
9
|
+
|
|
10
|
+
export interface TensorProperty {
|
|
11
|
+
/** The kind of tensor whose non-zero form means that the property is allowed. */
|
|
12
|
+
readonly spec: TensorSpec;
|
|
13
|
+
/** The physical quantity the tensor relates. */
|
|
14
|
+
readonly description: string;
|
|
15
|
+
/** Print source of the definition, with printed page. */
|
|
16
|
+
readonly source: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const property = (spec: TensorSpec, description: string, source: string): TensorProperty =>
|
|
20
|
+
Object.freeze({ spec: Object.freeze(spec), description, source });
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The named tensor properties. Names are adjectives, one lower-case word each (maintainer,
|
|
24
|
+
* 2026-11-19, #41). `'gyrotropic'` is optical activity.
|
|
25
|
+
*/
|
|
26
|
+
export const TENSOR_PROPERTIES = Object.freeze({
|
|
27
|
+
pyroelectric: property(
|
|
28
|
+
{ rank: 1, parity: 'polar', timeParity: 'i', intrinsic: 'none' },
|
|
29
|
+
'Spontaneous electric polarization, which changes with temperature: a polar vector p_i.',
|
|
30
|
+
'ITC Vol. D (2013), § 1.1.4.4.2, p. 12; classes: ITA (2016) Table 3.2.2.1, p. 738',
|
|
31
|
+
),
|
|
32
|
+
ferroaxial: property(
|
|
33
|
+
{ rank: 1, parity: 'axial', timeParity: 'i', intrinsic: 'none' },
|
|
34
|
+
'Ferroaxial (ferro-rotational) order, e.g. a net rotation of structural units about an axis: an axial vector A_i.',
|
|
35
|
+
'Hlinka, Privratska, Ondrejkovic & Janovec, Phys. Rev. Lett. 116, 177602 (2016); classes: Birss (1966), Tables 4a and 4c, pp. 56–58',
|
|
36
|
+
),
|
|
37
|
+
piezoelectric: property(
|
|
38
|
+
{ rank: 3, parity: 'polar', timeParity: 'i', intrinsic: 'jk' },
|
|
39
|
+
'Electric polarization linear in stress, P_i = d_ijk T_jk: a polar tensor of rank 3, symmetric in j, k.',
|
|
40
|
+
'ITC Vol. D (2013), § 1.1.4.4.3, p. 12; classes: ITA (2016) Table 3.2.2.1, p. 738',
|
|
41
|
+
),
|
|
42
|
+
gyrotropic: property(
|
|
43
|
+
{ rank: 2, parity: 'axial', timeParity: 'i', intrinsic: 'ij' },
|
|
44
|
+
'Optical activity (optical rotation), G = g_ij α_i α_j: the symmetric part of the axial gyration tensor of rank 2.',
|
|
45
|
+
'ITC Vol. D (2013), § 1.1.4.10.7.2, p. 30; classes: ITA (2016) Table 3.2.2.1, p. 738',
|
|
46
|
+
),
|
|
47
|
+
ferromagnetic: property(
|
|
48
|
+
{ rank: 1, parity: 'axial', timeParity: 'c', intrinsic: 'none' },
|
|
49
|
+
'Spontaneous magnetization M_s (ferromagnets, ferrimagnets, weak ferromagnets): an axial vector that changes sign under time reversal.',
|
|
50
|
+
'ITC Vol. D (2013), § 1.5.2.1 with Table 1.5.2.4, p. 113',
|
|
51
|
+
),
|
|
52
|
+
magnetoelectric: property(
|
|
53
|
+
{ rank: 2, parity: 'axial', timeParity: 'c', intrinsic: 'none' },
|
|
54
|
+
'Linear magnetoelectric effect, P_i = α_ij H_j: an axial tensor of rank 2 that changes sign under time reversal.',
|
|
55
|
+
'ITC Vol. D (2013), § 1.5.8.1 with eqs. (1.5.8.2), (1.5.8.3) and Table 1.5.8.1, pp. 139–140',
|
|
56
|
+
),
|
|
57
|
+
piezomagnetic: property(
|
|
58
|
+
{ rank: 3, parity: 'axial', timeParity: 'c', intrinsic: 'jk' },
|
|
59
|
+
'Magnetization linear in stress, M_i = Λ_ijk T_jk: an axial tensor of rank 3, symmetric in j, k, that changes sign under time reversal.',
|
|
60
|
+
'ITC Vol. D (2013), § 1.5.7.1 with eq. (1.5.7.2) and Table 1.5.7.1, pp. 134–135',
|
|
61
|
+
),
|
|
62
|
+
} satisfies Record<string, TensorProperty>);
|
|
63
|
+
|
|
64
|
+
/** Name of a tensor property in `TENSOR_PROPERTIES`. */
|
|
65
|
+
export type TensorPropertyName = keyof typeof TENSOR_PROPERTIES;
|
|
66
|
+
|
|
67
|
+
/** The names of the tensor properties, in the order of `TENSOR_PROPERTIES`. */
|
|
68
|
+
export const TENSOR_PROPERTY_NAMES = Object.freeze(Object.keys(TENSOR_PROPERTIES)) as readonly TensorPropertyName[];
|
|
69
|
+
|
|
70
|
+
/** The specification behind a property name; a specification is returned as it is. */
|
|
71
|
+
export function specOf(specOrName: TensorSpec | TensorPropertyName): TensorSpec {
|
|
72
|
+
if (typeof specOrName !== 'string') return specOrName;
|
|
73
|
+
if (!Object.hasOwn(TENSOR_PROPERTIES, specOrName)) {
|
|
74
|
+
throw new RangeError(
|
|
75
|
+
`Unknown tensor property: ${JSON.stringify(specOrName)} (known: ${TENSOR_PROPERTY_NAMES.join(', ')})`,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
return TENSOR_PROPERTIES[specOrName].spec;
|
|
79
|
+
}
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { det, type Mat3 } from '../linalg.js';
|
|
14
|
-
import { closeGroup, type Operation } from '../operations.js';
|
|
15
|
-
import { operations, settings, type
|
|
14
|
+
import { checkOrthogonal, checkTimeReversal, closeGroup, type Operation } from '../operations.js';
|
|
15
|
+
import { operations, settings, type MagneticPointGroupKey, type SettingOptions } from '../pointGroups/pointGroups.js';
|
|
16
|
+
import { specOf, type TensorPropertyName } from './propertyTable.js';
|
|
16
17
|
import { EPSILON, SNAP_EPSILON } from '../tolerances.js';
|
|
17
18
|
import { reducedRowEchelon } from './rowEchelon.js';
|
|
18
19
|
|
|
@@ -101,18 +102,6 @@ function checkSpec(spec: TensorSpec): number[][] {
|
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
/** Throws unless `m` is orthogonal (mᵀm = 1 within `EPSILON`): the code assumes Cartesian matrices. */
|
|
105
|
-
function checkOrthogonal(m: Mat3, what: string): void {
|
|
106
|
-
for (let i = 0; i < 3; i++) {
|
|
107
|
-
for (let j = 0; j < 3; j++) {
|
|
108
|
-
const dot = m[0][i] * m[0][j] + m[1][i] * m[1][j] + m[2][i] * m[2][j];
|
|
109
|
-
if (Math.abs(dot - (i === j ? 1 : 0)) > EPSILON) {
|
|
110
|
-
throw new RangeError(`${what} is not an orthogonal (Cartesian) matrix: ${JSON.stringify(m)}`);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
105
|
/** The indices (x, y, z = 0, 1, 2) of every flat index at a rank, first index first. */
|
|
117
106
|
const digitTables = new Map<number, readonly (readonly number[])[]>();
|
|
118
107
|
function digits(rank: number): readonly (readonly number[])[] {
|
|
@@ -223,18 +212,25 @@ function specKey(spec: TensorSpec): string {
|
|
|
223
212
|
const formCache = new Map<string, TensorForm>();
|
|
224
213
|
|
|
225
214
|
/**
|
|
226
|
-
* The form of a tensor under a point group
|
|
227
|
-
* of the convention, `'itc'` unless given). The
|
|
228
|
-
*
|
|
215
|
+
* The form of a tensor under a point group, a crystal class or a magnetic point group, in the
|
|
216
|
+
* requested setting (default: the default setting of the convention, `'itc'` unless given). The
|
|
217
|
+
* tensor is given by its specification or by the name of a property in `TENSOR_PROPERTIES`
|
|
218
|
+
* (`'piezoelectric'`). The convention matters only through the setting: the same setting index
|
|
219
|
+
* gives the same form in both conventions (docs/conventions.md, "Tensors").
|
|
229
220
|
*/
|
|
230
|
-
export function tensorForm(
|
|
231
|
-
|
|
221
|
+
export function tensorForm(
|
|
222
|
+
key: MagneticPointGroupKey,
|
|
223
|
+
spec: TensorSpec | TensorPropertyName,
|
|
224
|
+
options?: SettingOptions,
|
|
225
|
+
): TensorForm {
|
|
226
|
+
const resolved = specOf(spec);
|
|
227
|
+
const perms = checkSpec(resolved);
|
|
232
228
|
const ops = operations(key, options); // checks key, convention and setting
|
|
233
229
|
const index = options?.setting ?? settings(key, options?.convention).find((s) => s.isDefault)!.index;
|
|
234
|
-
const cacheKey = `${key}#${index}#${specKey(
|
|
230
|
+
const cacheKey = `${key}#${index}#${specKey(resolved)}`;
|
|
235
231
|
let form = formCache.get(cacheKey);
|
|
236
232
|
if (!form) {
|
|
237
|
-
form = project(ops,
|
|
233
|
+
form = project(ops, resolved, perms);
|
|
238
234
|
formCache.set(cacheKey, form);
|
|
239
235
|
}
|
|
240
236
|
return form;
|
|
@@ -242,22 +238,32 @@ export function tensorForm(key: PointGroupKey, spec: TensorSpec, options?: Setti
|
|
|
242
238
|
|
|
243
239
|
/**
|
|
244
240
|
* The form of a tensor under the group generated by `operations`, e.g. the site symmetry of a
|
|
245
|
-
* surface normal (`siteSymmetry`) or the operations of a distorted crystal. The
|
|
246
|
-
*
|
|
241
|
+
* surface normal (`siteSymmetry`) or the operations of a distorted crystal. The tensor is given by
|
|
242
|
+
* its specification or by the name of a property in `TENSOR_PROPERTIES`. The operations are
|
|
243
|
+
* Cartesian and orthogonal, and each says whether it is combined with time reversal
|
|
244
|
+
* (`timeReversal`, true or false); a list that is not closed is closed first.
|
|
247
245
|
*/
|
|
248
|
-
export function tensorFormOf(operations: readonly Operation[], spec: TensorSpec): TensorForm {
|
|
249
|
-
const
|
|
246
|
+
export function tensorFormOf(operations: readonly Operation[], spec: TensorSpec | TensorPropertyName): TensorForm {
|
|
247
|
+
const resolved = specOf(spec);
|
|
248
|
+
const perms = checkSpec(resolved);
|
|
250
249
|
operations.forEach((op, i) => checkOrthogonal(op.matrix, `Operation ${i}`));
|
|
251
|
-
|
|
250
|
+
checkTimeReversal(operations);
|
|
251
|
+
return project(closeGroup(operations), resolved, perms);
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
/**
|
|
255
255
|
* The components of `tensor` (length 3^rank, flat index) in a frame rotated by the orthogonal
|
|
256
256
|
* matrix `rotation`: t′_{i…} = f·Σ R_{ia}…R_{…}·t_{a…}, with f = det(R) for an axial tensor and 1
|
|
257
257
|
* for a polar one. To express a tensor in the frame of a surface, pass the matrix whose rows are
|
|
258
|
-
* the new axes in the old frame. Time parity plays no part.
|
|
258
|
+
* the new axes in the old frame. Time parity plays no part. The kind of tensor is given by its
|
|
259
|
+
* specification or by the name of a property in `TENSOR_PROPERTIES`.
|
|
259
260
|
*/
|
|
260
|
-
export function rotateTensor(
|
|
261
|
+
export function rotateTensor(
|
|
262
|
+
tensor: readonly number[],
|
|
263
|
+
rotation: Mat3,
|
|
264
|
+
specOrName: TensorSpec | TensorPropertyName,
|
|
265
|
+
): number[] {
|
|
266
|
+
const spec = specOf(specOrName);
|
|
261
267
|
checkSpec(spec);
|
|
262
268
|
checkOrthogonal(rotation, 'The rotation');
|
|
263
269
|
const { rank } = spec;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which named tensor properties a point group allows: the property is allowed if the tensor that
|
|
3
|
+
* describes it (`TENSOR_PROPERTIES`) has a non-zero form under the group. Symmetry only allows a
|
|
4
|
+
* property; whether a crystal shows it is a question of the material.
|
|
5
|
+
*
|
|
6
|
+
* These functions serve the magnetic API (`magnetic.ts`), where a key of type `'I'` (`'432'`) is the
|
|
7
|
+
* white group: the symmetry of a magnetically ordered crystal in which time reversal does not occur
|
|
8
|
+
* at all (`'432'` is magnetoelectric). A crystal without magnetic order has the grey group of its
|
|
9
|
+
* class (`"4321'"`), which allows no time-odd property; for the time-even properties the two agree.
|
|
10
|
+
* The crystallographic API (`crystalClasses.ts`) knows the time-even properties only
|
|
11
|
+
* (docs/conventions.md, "Two entry points").
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { Operation } from '../operations.js';
|
|
15
|
+
import type { MagneticPointGroupKey } from '../pointGroups/pointGroups.js';
|
|
16
|
+
import { TENSOR_PROPERTY_NAMES, specOf, type TensorPropertyName } from './propertyTable.js';
|
|
17
|
+
import { tensorForm, tensorFormOf } from './tensorForm.js';
|
|
18
|
+
|
|
19
|
+
/** A name of the table; anything else, a specification included, is an error here. */
|
|
20
|
+
function named(name: TensorPropertyName): TensorPropertyName {
|
|
21
|
+
if (typeof name !== 'string') throw new RangeError(`Unknown tensor property: ${JSON.stringify(name)}`);
|
|
22
|
+
specOf(name);
|
|
23
|
+
return name;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* True if the point group allows the named property, e.g. `allowsProperty('-6m2', 'piezoelectric')`.
|
|
28
|
+
* It does not depend on setting or convention. Throws a RangeError for an unknown key or name.
|
|
29
|
+
*/
|
|
30
|
+
export function allowsProperty(key: MagneticPointGroupKey, name: TensorPropertyName): boolean {
|
|
31
|
+
return tensorForm(key, named(name), { setting: 1 }).basis.length > 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The named properties the point group allows, in the order of `TENSOR_PROPERTIES`. */
|
|
35
|
+
export function allowedProperties(key: MagneticPointGroupKey): TensorPropertyName[] {
|
|
36
|
+
return TENSOR_PROPERTY_NAMES.filter((name) => allowsProperty(key, name));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* True if the group generated by `operations` allows the named property, e.g. for the site
|
|
41
|
+
* symmetry of a surface normal or the operations of a distorted crystal.
|
|
42
|
+
*/
|
|
43
|
+
export function allowsPropertyOf(operations: readonly Operation[], name: TensorPropertyName): boolean {
|
|
44
|
+
return tensorFormOf(operations, named(name)).basis.length > 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The named properties the group generated by `operations` allows. */
|
|
48
|
+
export function allowedPropertiesOf(operations: readonly Operation[]): TensorPropertyName[] {
|
|
49
|
+
return TENSOR_PROPERTY_NAMES.filter((name) => allowsPropertyOf(operations, name));
|
|
50
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Version of symcrys. Kept equal to `version` in package.json (checked by version.test.ts). */
|
|
2
|
-
export const VERSION = '0.
|
|
2
|
+
export const VERSION = '0.6.0';
|