symcrys 0.5.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 +12 -1
- 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 +5 -1
- 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
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "symcrys",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Crystallographic symmetry calculations: point groups (crystallographic and magnetic), their settings, symbols and properties, and property tensors. TypeScript library without dependencies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"crystallography",
|
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
25
|
"default": "./dist/index.js"
|
|
26
26
|
},
|
|
27
|
+
"./magnetic": {
|
|
28
|
+
"types": "./dist/magnetic.d.ts",
|
|
29
|
+
"default": "./dist/magnetic.js"
|
|
30
|
+
},
|
|
27
31
|
"./package.json": "./package.json"
|
|
28
32
|
},
|
|
29
33
|
"main": "./dist/index.js",
|
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The crystallographic API: the 32 crystal classes, without time reversal. It is what `index.ts`
|
|
3
|
+
* exports. Nothing here mentions time reversal: an operation is its matrix, a tensor has no time
|
|
4
|
+
* parity, and the named properties are those of time-even tensors. A question that involves time
|
|
5
|
+
* reversal (a magnetic point group, a time-odd tensor or property, an operation combined with time
|
|
6
|
+
* reversal) is a RangeError that names the magnetic API (`magnetic.ts`, `symcrys/magnetic`), where
|
|
7
|
+
* the key `'32'` is the white group and a crystal without magnetic order has the grey group of its
|
|
8
|
+
* class (`"321'"`; docs/conventions.md, "Two entry points").
|
|
9
|
+
*
|
|
10
|
+
* Everything is computed by the modules that serve both entry points; this module checks what
|
|
11
|
+
* comes in and leaves time reversal out of what goes back.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { CrystalSystem } from './lattice.js';
|
|
15
|
+
import type { Mat3, Vec3 } from './linalg.js';
|
|
16
|
+
import type { Operation as MagneticOperation } from './operations.js';
|
|
17
|
+
import * as elements from './pointGroups/elements.js';
|
|
18
|
+
import * as groups from './pointGroups/pointGroups.js';
|
|
19
|
+
import type { Convention, PointGroupKey, Setting, SettingOptions, SymbolOptions } from './pointGroups/pointGroups.js';
|
|
20
|
+
import * as properties from './pointGroups/properties.js';
|
|
21
|
+
import * as wyckoff from './pointGroups/wyckoff.js';
|
|
22
|
+
import * as site from './siteSymmetry.js';
|
|
23
|
+
import { TENSOR_PROPERTIES as ALL_TENSOR_PROPERTIES } from './tensors/propertyTable.js';
|
|
24
|
+
import type { TensorPropertyName as MagneticTensorPropertyName } from './tensors/propertyTable.js';
|
|
25
|
+
import * as tensors from './tensors/tensorForm.js';
|
|
26
|
+
import type { IntrinsicSymmetry, TensorForm, TensorParity, TensorRank } from './tensors/tensorForm.js';
|
|
27
|
+
|
|
28
|
+
const USE_MAGNETIC =
|
|
29
|
+
"the crystallographic API has no time reversal; use the magnetic API ('symcrys/magnetic', in Python symcrys.magnetic)";
|
|
30
|
+
|
|
31
|
+
/** A point operation: an orthogonal Cartesian matrix (rotation, rotoinversion, mirror, inversion). */
|
|
32
|
+
export interface Operation {
|
|
33
|
+
readonly matrix: Mat3;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A crystal class with the properties that are fixed by its operations. None of them depends on
|
|
38
|
+
* the setting or the convention (docs/conventions.md, "Properties").
|
|
39
|
+
*/
|
|
40
|
+
export interface PointGroup {
|
|
41
|
+
readonly key: PointGroupKey;
|
|
42
|
+
readonly crystalSystem: CrystalSystem;
|
|
43
|
+
/** Number of operations. */
|
|
44
|
+
readonly order: number;
|
|
45
|
+
/** Contains the inversion. */
|
|
46
|
+
readonly centrosymmetric: boolean;
|
|
47
|
+
/** Polar (pyroelectric class): some direction is left unchanged by every operation. */
|
|
48
|
+
readonly polar: boolean;
|
|
49
|
+
/** Chiral (enantiomorphic class): proper rotations only. */
|
|
50
|
+
readonly chiral: boolean;
|
|
51
|
+
/** The Laue class: the centrosymmetric crystal class generated by the class and the inversion. */
|
|
52
|
+
readonly laueClass: PointGroupKey;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** A crystal class in a given setting. */
|
|
56
|
+
export interface PointGroupInSetting {
|
|
57
|
+
readonly key: PointGroupKey;
|
|
58
|
+
readonly setting: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** One point operation described geometrically. */
|
|
62
|
+
export type OperationDescription = Omit<elements.OperationDescription, 'timeReversal'>;
|
|
63
|
+
|
|
64
|
+
/** The kind of tensor. */
|
|
65
|
+
export interface TensorSpec {
|
|
66
|
+
readonly rank: TensorRank;
|
|
67
|
+
readonly parity: TensorParity;
|
|
68
|
+
readonly intrinsic: IntrinsicSymmetry;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* An operation as a caller may pass it: its matrix. `timeReversal: false` is accepted, so that an
|
|
73
|
+
* operation of the magnetic API without time reversal can be handed on from plain JavaScript; with
|
|
74
|
+
* `timeReversal: true` it is refused, at compile time and at run time.
|
|
75
|
+
*/
|
|
76
|
+
type OperationArgument = Operation & { readonly timeReversal?: false };
|
|
77
|
+
|
|
78
|
+
/** A tensor specification as a caller may pass it; `timeParity: 'i'` is accepted, `'c'` refused. */
|
|
79
|
+
type TensorSpecArgument = TensorSpec & { readonly timeParity?: 'i' };
|
|
80
|
+
|
|
81
|
+
export interface TensorProperty {
|
|
82
|
+
/** The kind of tensor whose non-zero form means that the property is allowed. */
|
|
83
|
+
readonly spec: TensorSpec;
|
|
84
|
+
/** The physical quantity the tensor relates. */
|
|
85
|
+
readonly description: string;
|
|
86
|
+
/** Print source of the definition, with printed page. */
|
|
87
|
+
readonly source: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Name of a tensor property in `TENSOR_PROPERTIES`. */
|
|
91
|
+
export type TensorPropertyName = Extract<
|
|
92
|
+
MagneticTensorPropertyName,
|
|
93
|
+
'pyroelectric' | 'ferroaxial' | 'piezoelectric' | 'gyrotropic'
|
|
94
|
+
>;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The named tensor properties of the crystal classes: those of time-even tensors. `'gyrotropic'`
|
|
98
|
+
* is optical activity. The properties of time-odd tensors (`'ferromagnetic'`, …) are in the
|
|
99
|
+
* magnetic API.
|
|
100
|
+
*/
|
|
101
|
+
export const TENSOR_PROPERTIES = Object.freeze(
|
|
102
|
+
Object.fromEntries(
|
|
103
|
+
Object.entries(ALL_TENSOR_PROPERTIES)
|
|
104
|
+
.filter(([, p]) => p.spec.timeParity === 'i')
|
|
105
|
+
.map(([name, { spec, description, source }]) => [
|
|
106
|
+
name,
|
|
107
|
+
Object.freeze({
|
|
108
|
+
spec: Object.freeze({ rank: spec.rank, parity: spec.parity, intrinsic: spec.intrinsic }),
|
|
109
|
+
description,
|
|
110
|
+
source,
|
|
111
|
+
}),
|
|
112
|
+
]),
|
|
113
|
+
),
|
|
114
|
+
) as Readonly<Record<TensorPropertyName, TensorProperty>>;
|
|
115
|
+
|
|
116
|
+
const TENSOR_PROPERTY_NAMES = Object.freeze(Object.keys(TENSOR_PROPERTIES)) as readonly TensorPropertyName[];
|
|
117
|
+
|
|
118
|
+
// --- what comes in ---------------------------------------------------------------------------------
|
|
119
|
+
|
|
120
|
+
/** The key of a crystal class, checked. */
|
|
121
|
+
function classKey(key: PointGroupKey): PointGroupKey {
|
|
122
|
+
if (groups.isPointGroupKey(key)) return key;
|
|
123
|
+
if (groups.isMagneticPointGroupKey(key)) {
|
|
124
|
+
throw new RangeError(`${JSON.stringify(key)} is a magnetic point group, not a crystal class: ${USE_MAGNETIC}`);
|
|
125
|
+
}
|
|
126
|
+
throw new RangeError(`Unknown point group key: ${JSON.stringify(key)}`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** A name of the table of this API, checked. */
|
|
130
|
+
function propertyName(name: TensorPropertyName): TensorPropertyName {
|
|
131
|
+
if (typeof name === 'string') {
|
|
132
|
+
if (Object.hasOwn(TENSOR_PROPERTIES, name)) return name;
|
|
133
|
+
if (Object.hasOwn(ALL_TENSOR_PROPERTIES, name)) {
|
|
134
|
+
throw new RangeError(`${JSON.stringify(name)} is the property of a time-odd tensor: ${USE_MAGNETIC}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
throw new RangeError(`Unknown tensor property: ${JSON.stringify(name)} (known: ${TENSOR_PROPERTY_NAMES.join(', ')})`);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** The time-even tensor of a specification or of a property name, as the shared modules take it. */
|
|
141
|
+
function timeEven(specOrName: TensorSpecArgument | TensorPropertyName): tensors.TensorSpec | TensorPropertyName {
|
|
142
|
+
if (typeof specOrName === 'string') return propertyName(specOrName);
|
|
143
|
+
if (typeof specOrName !== 'object' || specOrName === null) {
|
|
144
|
+
throw new RangeError(`Not a tensor specification: ${JSON.stringify(specOrName)}`);
|
|
145
|
+
}
|
|
146
|
+
const timeParity = (specOrName as { readonly timeParity?: unknown }).timeParity;
|
|
147
|
+
if (timeParity === 'c') throw new RangeError(`A time-odd tensor (timeParity 'c'): ${USE_MAGNETIC}`);
|
|
148
|
+
if (timeParity !== undefined && timeParity !== 'i') {
|
|
149
|
+
throw new RangeError(`Unknown time parity: ${JSON.stringify(timeParity)}`);
|
|
150
|
+
}
|
|
151
|
+
return { rank: specOrName.rank, parity: specOrName.parity, timeParity: 'i', intrinsic: specOrName.intrinsic };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Checks a list of operations of a caller: an operation with time reversal is an error. */
|
|
155
|
+
function checkUnitary(operations: readonly OperationArgument[]): void {
|
|
156
|
+
operations.forEach((op, i) => {
|
|
157
|
+
const timeReversal = (op as { readonly timeReversal?: unknown }).timeReversal;
|
|
158
|
+
if (timeReversal === true) {
|
|
159
|
+
throw new RangeError(`Operation ${i} is combined with time reversal: ${USE_MAGNETIC}`);
|
|
160
|
+
}
|
|
161
|
+
if (timeReversal !== undefined && timeReversal !== false) {
|
|
162
|
+
throw new RangeError(`Operation ${i}: timeReversal must be false or absent, not ${JSON.stringify(timeReversal)}`);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** A list of operations as the shared modules take it. */
|
|
168
|
+
function unitary(operations: readonly OperationArgument[]): MagneticOperation[] {
|
|
169
|
+
checkUnitary(operations);
|
|
170
|
+
return operations.map((op) => ({ matrix: op.matrix, timeReversal: false }));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// --- what goes back --------------------------------------------------------------------------------
|
|
174
|
+
|
|
175
|
+
const withoutTimeCache = new WeakMap<readonly MagneticOperation[], readonly Operation[]>();
|
|
176
|
+
|
|
177
|
+
/** The operations as their matrices; the shared modules return the same frozen list for the same call. */
|
|
178
|
+
function matricesOnly(ops: readonly MagneticOperation[]): readonly Operation[] {
|
|
179
|
+
let result = withoutTimeCache.get(ops);
|
|
180
|
+
if (!result) {
|
|
181
|
+
result = Object.freeze(ops.map((op) => Object.freeze({ matrix: op.matrix })));
|
|
182
|
+
withoutTimeCache.set(ops, result);
|
|
183
|
+
}
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const descriptionCache = new WeakMap<readonly elements.OperationDescription[], readonly OperationDescription[]>();
|
|
188
|
+
|
|
189
|
+
// --- point groups ----------------------------------------------------------------------------------
|
|
190
|
+
|
|
191
|
+
export { POINT_GROUP_KEYS } from './pointGroups/pointGroups.js';
|
|
192
|
+
|
|
193
|
+
/** True if `key` is the key of one of the 32 crystal classes. */
|
|
194
|
+
export function isPointGroupKey(key: string): key is PointGroupKey {
|
|
195
|
+
return groups.isPointGroupKey(key);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const groupCache = new Map<PointGroupKey, PointGroup>();
|
|
199
|
+
|
|
200
|
+
/** The crystal class with this key. Throws a RangeError for an unknown key. */
|
|
201
|
+
export function pointGroup(key: PointGroupKey): PointGroup {
|
|
202
|
+
let g = groupCache.get(classKey(key));
|
|
203
|
+
if (!g) {
|
|
204
|
+
const { crystalSystem, order, centrosymmetric, polar, chiral, laueClass } = groups.pointGroup(key);
|
|
205
|
+
g = Object.freeze({ key, crystalSystem, order, centrosymmetric, polar, chiral, laueClass });
|
|
206
|
+
groupCache.set(key, g);
|
|
207
|
+
}
|
|
208
|
+
return g;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** All 32 crystal classes, in the order of `POINT_GROUP_KEYS` (by crystal system, as in ITA). */
|
|
212
|
+
export function pointGroups(): readonly PointGroup[] {
|
|
213
|
+
return groups.POINT_GROUP_KEYS.map((key) => pointGroup(key));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Finds a crystal class by a Hermann–Mauguin symbol in the given convention (default `'itc'`): the
|
|
218
|
+
* short symbol of a setting, a full symbol, or the key (spaces are ignored). A symbol that names
|
|
219
|
+
* one setting gives that setting; the key, and a short symbol that several settings share (the
|
|
220
|
+
* monoclinic ones: `2` for unique axis b and c), give the default setting of the convention.
|
|
221
|
+
* Returns undefined if nothing matches, also for a value that is not a string and for the
|
|
222
|
+
* symbol of a magnetic group with time reversal. Symbols are written as in this library: `-` for
|
|
223
|
+
* the overbar, also in the Birss convention (`m-3m`, where Birss prints `m3m`; docs/conventions.md,
|
|
224
|
+
* "Where ITC and Birss differ").
|
|
225
|
+
*/
|
|
226
|
+
export function findPointGroup(hm: string, conventionName: Convention = 'itc'): PointGroupInSetting | undefined {
|
|
227
|
+
return groups.findPointGroup(hm, conventionName);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** The settings of a crystal class, with symbols and the default of the given convention (default `'itc'`). */
|
|
231
|
+
export function settings(key: PointGroupKey, conventionName: Convention = 'itc'): readonly Setting[] {
|
|
232
|
+
return groups.settings(classKey(key), conventionName);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* All operations of the crystal class in the requested setting (default: the convention's default
|
|
237
|
+
* setting). ITC convention: in ITA's order, identity first, then as ITA numbers the general
|
|
238
|
+
* position. Birss convention: in birss-app's order (docs/conventions.md, "Order of the
|
|
239
|
+
* operations"). The matrices are Cartesian (docs/conventions.md, "Cartesian frame").
|
|
240
|
+
*/
|
|
241
|
+
export function operations(key: PointGroupKey, options?: SettingOptions): readonly Operation[] {
|
|
242
|
+
return matricesOnly(groups.operations(classKey(key), options));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Generators of the crystal class in the requested setting (docs/conventions.md, "Generators"). ITC
|
|
247
|
+
* convention: ITA's selected generators in printed order, without the identity and ITA's lattice
|
|
248
|
+
* translations, so the list is empty for `1`; for `mm2` settings 2 and 3, which ITA does not list,
|
|
249
|
+
* those of setting 1 carried into their frame. Birss convention: birss-app's generators (for `1`
|
|
250
|
+
* the identity, as in birss-app).
|
|
251
|
+
*/
|
|
252
|
+
export function generators(key: PointGroupKey, options?: SettingOptions): readonly Operation[] {
|
|
253
|
+
return matricesOnly(groups.generators(classKey(key), options));
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** A symbol of the crystal class in the requested convention and setting. */
|
|
257
|
+
export function symbol(key: PointGroupKey, options?: SymbolOptions): string {
|
|
258
|
+
return groups.symbol(classKey(key), options);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// --- properties that follow from operations ---------------------------------------------------------
|
|
262
|
+
|
|
263
|
+
export { holohedry } from './pointGroups/properties.js';
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* True if the group generated by `operations` contains the inversion, e.g. for the operations of a
|
|
267
|
+
* distorted crystal. A list that is not closed is closed first. For a crystal class, read
|
|
268
|
+
* `pointGroup(key).centrosymmetric`.
|
|
269
|
+
*/
|
|
270
|
+
export function isCentrosymmetricOf(operations: readonly OperationArgument[]): boolean {
|
|
271
|
+
return properties.isCentrosymmetricOf(unitary(operations));
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* True if the group generated by `operations` is chiral: proper rotations only. For a crystal
|
|
276
|
+
* class, read `pointGroup(key).chiral`. Polar is the named property `'pyroelectric'`:
|
|
277
|
+
* `allowsPropertyOf(operations, 'pyroelectric')`.
|
|
278
|
+
*/
|
|
279
|
+
export function isChiralOf(operations: readonly OperationArgument[]): boolean {
|
|
280
|
+
return properties.isChiralOf(unitary(operations));
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// --- symmetry elements -----------------------------------------------------------------------------
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Each operation of the crystal class described geometrically, in the order of `operations` for
|
|
287
|
+
* the same key and options. Axes are named by the symmetry direction they lie along: in the ITC
|
|
288
|
+
* convention with the sign of ITA Table 2.1.3.1, in the Birss convention signed as birss-app signs
|
|
289
|
+
* them (first non-zero Cartesian component positive); the sign fixes what the sense refers to.
|
|
290
|
+
*/
|
|
291
|
+
export function describeOperations(key: PointGroupKey, options?: SettingOptions): readonly OperationDescription[] {
|
|
292
|
+
const described = elements.describeOperations(classKey(key), options);
|
|
293
|
+
let result = descriptionCache.get(described);
|
|
294
|
+
if (!result) {
|
|
295
|
+
result = Object.freeze(
|
|
296
|
+
described.map(({ kind, order, axis, sense }) =>
|
|
297
|
+
Object.freeze({ kind, order, ...(axis ? { axis } : {}), ...(sense ? { sense } : {}) }),
|
|
298
|
+
),
|
|
299
|
+
);
|
|
300
|
+
descriptionCache.set(described, result);
|
|
301
|
+
}
|
|
302
|
+
return result;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* The positions of the full Hermann–Mauguin symbol in the requested convention and setting, each
|
|
307
|
+
* with its symmetry directions (ITA Table 2.1.3.1) and the symmetry elements along them. All
|
|
308
|
+
* positions of the crystal family are listed, also those the symbol of the class leaves out (then
|
|
309
|
+
* without `symbol`); the triclinic family has none. The directions keep the sign of Table 2.1.3.1
|
|
310
|
+
* in both conventions; in the Birss convention an axis of `describeOperations` may be reversed, so
|
|
311
|
+
* match it to a direction by |dot| = 1, not by identity.
|
|
312
|
+
*/
|
|
313
|
+
export function symmetryDirections(
|
|
314
|
+
key: PointGroupKey,
|
|
315
|
+
options?: SettingOptions,
|
|
316
|
+
): readonly elements.SymmetryDirection[] {
|
|
317
|
+
return elements.symmetryDirections(classKey(key), options);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// --- site symmetry and Wyckoff positions -----------------------------------------------------------
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* The site symmetry of `direction` (any non-zero vector, Cartesian) under `operations`, which may
|
|
324
|
+
* be any list of point operations (for instance those of a distorted crystal). The operations
|
|
325
|
+
* fixing the direction within the tolerance are closed under the products found in the list and
|
|
326
|
+
* the direction is set onto their fixed space, repeated until stable, so that for a group the
|
|
327
|
+
* result is a subgroup and the set direction lies exactly on its elements. For a list that is not a
|
|
328
|
+
* group, `multiplicity` may not be an integer. Throws a RangeError for a zero vector, and if the
|
|
329
|
+
* closed operations fix no common direction (a tolerance far too large, e.g. 0.5).
|
|
330
|
+
*/
|
|
331
|
+
export function siteSymmetry(
|
|
332
|
+
operations: readonly OperationArgument[],
|
|
333
|
+
direction: Vec3,
|
|
334
|
+
options?: site.SiteSymmetryOptions,
|
|
335
|
+
): site.SiteSymmetry {
|
|
336
|
+
checkUnitary(operations);
|
|
337
|
+
// The shared function reads the matrices only, and it keeps the products of a list by the identity
|
|
338
|
+
// of the list, so the list of the caller is passed on as it is.
|
|
339
|
+
return site.siteSymmetry(operations as readonly MagneticOperation[], direction, options);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* The Wyckoff positions of a crystal class for directions, as ITA tabulates them (general position
|
|
344
|
+
* first), in the ITC convention only (docs/conventions.md, "Site symmetry and Wyckoff positions").
|
|
345
|
+
*/
|
|
346
|
+
export function wyckoffPositions(key: PointGroupKey, options?: SettingOptions): readonly wyckoff.WyckoffPosition[] {
|
|
347
|
+
return wyckoff.wyckoffPositions(classKey(key), options);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* The Wyckoff position of a direction (Cartesian) in a crystal class: the position whose site
|
|
352
|
+
* symmetry is conjugate to that of the direction (ITA's definition). `tolerance` as for
|
|
353
|
+
* `siteSymmetry`.
|
|
354
|
+
*/
|
|
355
|
+
export function wyckoffPositionOf(
|
|
356
|
+
key: PointGroupKey,
|
|
357
|
+
direction: Vec3,
|
|
358
|
+
options?: wyckoff.WyckoffOptions,
|
|
359
|
+
): wyckoff.WyckoffPosition {
|
|
360
|
+
return wyckoff.wyckoffPositionOf(classKey(key), direction, options);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// --- tensors ---------------------------------------------------------------------------------------
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* The form of a tensor under a crystal class in the requested setting (default: the default
|
|
367
|
+
* setting of the convention, `'itc'` unless given). The tensor is given by its specification or by
|
|
368
|
+
* the name of a property in `TENSOR_PROPERTIES` (`'piezoelectric'`). The convention matters only
|
|
369
|
+
* through the setting: the same setting index gives the same form in both conventions
|
|
370
|
+
* (docs/conventions.md, "Tensors").
|
|
371
|
+
*/
|
|
372
|
+
export function tensorForm(
|
|
373
|
+
key: PointGroupKey,
|
|
374
|
+
spec: TensorSpecArgument | TensorPropertyName,
|
|
375
|
+
options?: SettingOptions,
|
|
376
|
+
): TensorForm {
|
|
377
|
+
return tensors.tensorForm(classKey(key), timeEven(spec), options);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* The form of a tensor under the group generated by `operations`, e.g. the site symmetry of a
|
|
382
|
+
* surface normal (`siteSymmetry`) or the operations of a distorted crystal. The tensor is given by
|
|
383
|
+
* its specification or by the name of a property in `TENSOR_PROPERTIES`. The operations are
|
|
384
|
+
* Cartesian and orthogonal; a list that is not closed is closed first.
|
|
385
|
+
*/
|
|
386
|
+
export function tensorFormOf(
|
|
387
|
+
operations: readonly OperationArgument[],
|
|
388
|
+
spec: TensorSpecArgument | TensorPropertyName,
|
|
389
|
+
): TensorForm {
|
|
390
|
+
return tensors.tensorFormOf(unitary(operations), timeEven(spec));
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* The components of `tensor` (length 3^rank, flat index) in a frame rotated by the orthogonal
|
|
395
|
+
* matrix `rotation`: t′_{i…} = f·Σ R_{ia}…R_{…}·t_{a…}, with f = det(R) for an axial tensor and 1
|
|
396
|
+
* for a polar one. To express a tensor in the frame of a surface, pass the matrix whose rows are
|
|
397
|
+
* the new axes in the old frame. The kind of tensor is given by its specification or by the name
|
|
398
|
+
* of a property in `TENSOR_PROPERTIES`.
|
|
399
|
+
*/
|
|
400
|
+
export function rotateTensor(
|
|
401
|
+
tensor: readonly number[],
|
|
402
|
+
rotation: Mat3,
|
|
403
|
+
specOrName: TensorSpecArgument | TensorPropertyName,
|
|
404
|
+
): number[] {
|
|
405
|
+
return tensors.rotateTensor(tensor, rotation, timeEven(specOrName));
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* True if the crystal class allows the named property, e.g. `allowsProperty('-6m2',
|
|
410
|
+
* 'piezoelectric')`: the tensor that describes it (`TENSOR_PROPERTIES`) has a non-zero form under
|
|
411
|
+
* the class. Symmetry only allows a property; whether a crystal shows it is a question of the
|
|
412
|
+
* material. It does not depend on setting or convention. Throws a RangeError for an unknown key or
|
|
413
|
+
* name.
|
|
414
|
+
*/
|
|
415
|
+
export function allowsProperty(key: PointGroupKey, name: TensorPropertyName): boolean {
|
|
416
|
+
return tensors.tensorForm(classKey(key), propertyName(name), { setting: 1 }).basis.length > 0;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/** The named properties the crystal class allows, in the order of `TENSOR_PROPERTIES`. */
|
|
420
|
+
export function allowedProperties(key: PointGroupKey): TensorPropertyName[] {
|
|
421
|
+
return TENSOR_PROPERTY_NAMES.filter((name) => allowsProperty(key, name));
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* True if the group generated by `operations` allows the named property, e.g. for the site
|
|
426
|
+
* symmetry of a surface normal or the operations of a distorted crystal.
|
|
427
|
+
*/
|
|
428
|
+
export function allowsPropertyOf(operations: readonly OperationArgument[], name: TensorPropertyName): boolean {
|
|
429
|
+
return tensors.tensorFormOf(unitary(operations), propertyName(name)).basis.length > 0;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/** The named properties the group generated by `operations` allows. */
|
|
433
|
+
export function allowedPropertiesOf(operations: readonly OperationArgument[]): TensorPropertyName[] {
|
|
434
|
+
const ops = unitary(operations);
|
|
435
|
+
return TENSOR_PROPERTY_NAMES.filter((name) => tensors.tensorFormOf(ops, name).basis.length > 0);
|
|
436
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Public API of symcrys
|
|
3
|
-
*
|
|
2
|
+
* Public API of symcrys: the crystallographic API, for the 32 crystal classes and without time
|
|
3
|
+
* reversal. The magnetic point groups, time-odd tensors and operations with time reversal are in
|
|
4
|
+
* the magnetic API, `symcrys/magnetic` (`magnetic.ts`), under the same function names
|
|
5
|
+
* (docs/conventions.md, "Two entry points"). Everything exported here and there is covered by
|
|
6
|
+
* SemVer (see CLAUDE.md); everything else is internal.
|
|
4
7
|
*/
|
|
5
8
|
export { VERSION } from './version.js';
|
|
6
9
|
|
|
7
10
|
export type { Mat3, Vec3 } from './linalg.js';
|
|
8
|
-
export type { Operation } from './operations.js';
|
|
9
11
|
export {
|
|
10
12
|
crystalFamily,
|
|
11
13
|
latticeBasis,
|
|
@@ -14,52 +16,44 @@ export {
|
|
|
14
16
|
type FixedAngleFamily,
|
|
15
17
|
} from './lattice.js';
|
|
16
18
|
|
|
19
|
+
export type { Convention, PointGroupKey, Setting, SettingOptions, SymbolOptions } from './pointGroups/pointGroups.js';
|
|
20
|
+
export { LATTICE_SYMMETRY_DIRECTIONS, type Uvw } from './symmetryDirections.js';
|
|
21
|
+
export type { Axis, DirectionElements, OperationKind, SymmetryDirection } from './pointGroups/elements.js';
|
|
22
|
+
export type { SiteSymmetry, SiteSymmetryOptions } from './siteSymmetry.js';
|
|
23
|
+
export type { Hkl, WyckoffOptions, WyckoffPosition } from './pointGroups/wyckoff.js';
|
|
24
|
+
export type { IntrinsicSymmetry, TensorForm, TensorParity, TensorRank } from './tensors/tensorForm.js';
|
|
25
|
+
|
|
17
26
|
export {
|
|
18
27
|
POINT_GROUP_KEYS,
|
|
28
|
+
TENSOR_PROPERTIES,
|
|
29
|
+
allowedProperties,
|
|
30
|
+
allowedPropertiesOf,
|
|
31
|
+
allowsProperty,
|
|
32
|
+
allowsPropertyOf,
|
|
33
|
+
describeOperations,
|
|
19
34
|
findPointGroup,
|
|
20
35
|
generators,
|
|
36
|
+
holohedry,
|
|
37
|
+
isCentrosymmetricOf,
|
|
38
|
+
isChiralOf,
|
|
21
39
|
isPointGroupKey,
|
|
22
40
|
operations,
|
|
23
41
|
pointGroup,
|
|
24
42
|
pointGroups,
|
|
43
|
+
rotateTensor,
|
|
25
44
|
settings,
|
|
45
|
+
siteSymmetry,
|
|
26
46
|
symbol,
|
|
27
|
-
type Convention,
|
|
28
|
-
type PointGroup,
|
|
29
|
-
type PointGroupInSetting,
|
|
30
|
-
type PointGroupKey,
|
|
31
|
-
type PointGroupType,
|
|
32
|
-
type Setting,
|
|
33
|
-
type SettingOptions,
|
|
34
|
-
type SymbolOptions,
|
|
35
|
-
} from './pointGroups/pointGroups.js';
|
|
36
|
-
export { isCentrosymmetric, isChiral, isPiezoelectric, isPolar, laueClass } from './pointGroups/properties.js';
|
|
37
|
-
export { LATTICE_SYMMETRY_DIRECTIONS, type Uvw } from './symmetryDirections.js';
|
|
38
|
-
export {
|
|
39
|
-
describeOperations,
|
|
40
47
|
symmetryDirections,
|
|
41
|
-
type Axis,
|
|
42
|
-
type DirectionElements,
|
|
43
|
-
type OperationDescription,
|
|
44
|
-
type OperationKind,
|
|
45
|
-
type SymmetryDirection,
|
|
46
|
-
} from './pointGroups/elements.js';
|
|
47
|
-
export { siteSymmetry, type SiteSymmetry, type SiteSymmetryOptions } from './siteSymmetry.js';
|
|
48
|
-
export {
|
|
49
|
-
wyckoffPositionOf,
|
|
50
|
-
wyckoffPositions,
|
|
51
|
-
type Hkl,
|
|
52
|
-
type WyckoffOptions,
|
|
53
|
-
type WyckoffPosition,
|
|
54
|
-
} from './pointGroups/wyckoff.js';
|
|
55
|
-
export {
|
|
56
|
-
rotateTensor,
|
|
57
48
|
tensorForm,
|
|
58
49
|
tensorFormOf,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
type
|
|
62
|
-
type
|
|
50
|
+
wyckoffPositionOf,
|
|
51
|
+
wyckoffPositions,
|
|
52
|
+
type Operation,
|
|
53
|
+
type OperationDescription,
|
|
54
|
+
type PointGroup,
|
|
55
|
+
type PointGroupInSetting,
|
|
56
|
+
type TensorProperty,
|
|
57
|
+
type TensorPropertyName,
|
|
63
58
|
type TensorSpec,
|
|
64
|
-
|
|
65
|
-
} from './tensors/tensorForm.js';
|
|
59
|
+
} from './crystalClasses.js';
|
package/src/magnetic.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The magnetic API of symcrys (`symcrys/magnetic`): the 122 magnetic point groups, with time
|
|
3
|
+
* reversal. Everything exported here is covered by SemVer (see CLAUDE.md), like the exports of
|
|
4
|
+
* `index.ts`.
|
|
5
|
+
*
|
|
6
|
+
* The functions have the names they have in the crystallographic API (`index.ts`); the import
|
|
7
|
+
* decides which reading a key has. Here a key of type `'I'` (`'32'`) is a white (colourless)
|
|
8
|
+
* group: the symmetry of a magnetically ordered crystal in which time reversal does not occur at
|
|
9
|
+
* all. A crystal without magnetic order has the grey group of its class (quartz: `"321'"`), which
|
|
10
|
+
* allows no time-odd property (docs/conventions.md, "Two entry points").
|
|
11
|
+
*/
|
|
12
|
+
export { VERSION } from './version.js';
|
|
13
|
+
|
|
14
|
+
export type { Mat3, Vec3 } from './linalg.js';
|
|
15
|
+
export type { Operation } from './operations.js';
|
|
16
|
+
export {
|
|
17
|
+
crystalFamily,
|
|
18
|
+
latticeBasis,
|
|
19
|
+
type CrystalFamily,
|
|
20
|
+
type CrystalSystem,
|
|
21
|
+
type FixedAngleFamily,
|
|
22
|
+
} from './lattice.js';
|
|
23
|
+
|
|
24
|
+
import type {
|
|
25
|
+
PointGroupKey as ClassKey,
|
|
26
|
+
MagneticPointGroupKey,
|
|
27
|
+
PointGroup as PointGroupOf,
|
|
28
|
+
PointGroupInSetting as PointGroupInSettingOf,
|
|
29
|
+
} from './pointGroups/pointGroups.js';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The key of a crystal class, one of the 32: the type of `crystalClass` and `laueClass` of a point
|
|
33
|
+
* group and of `holohedry()`. In the crystallographic API this is `PointGroupKey`.
|
|
34
|
+
*/
|
|
35
|
+
export type CrystalClassKey = ClassKey;
|
|
36
|
+
/** The key of a magnetic point group: a crystal class (white group), a grey or a black-and-white group. */
|
|
37
|
+
export type PointGroupKey = MagneticPointGroupKey;
|
|
38
|
+
export type PointGroup<K extends PointGroupKey = PointGroupKey> = PointGroupOf<K>;
|
|
39
|
+
/** A point group in a given setting. */
|
|
40
|
+
export type PointGroupInSetting = PointGroupInSettingOf<PointGroupKey>;
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
MAGNETIC_POINT_GROUP_KEYS as POINT_GROUP_KEYS,
|
|
44
|
+
findMagneticPointGroup as findPointGroup,
|
|
45
|
+
generators,
|
|
46
|
+
isMagneticPointGroupKey as isPointGroupKey,
|
|
47
|
+
magneticPointGroups as pointGroups,
|
|
48
|
+
operations,
|
|
49
|
+
pointGroup,
|
|
50
|
+
settings,
|
|
51
|
+
symbol,
|
|
52
|
+
type Convention,
|
|
53
|
+
type PointGroupType,
|
|
54
|
+
type Setting,
|
|
55
|
+
type SettingOptions,
|
|
56
|
+
type SymbolOptions,
|
|
57
|
+
} from './pointGroups/pointGroups.js';
|
|
58
|
+
export { holohedry, isCentrosymmetricOf, isChiralOf } from './pointGroups/properties.js';
|
|
59
|
+
export { LATTICE_SYMMETRY_DIRECTIONS, type Uvw } from './symmetryDirections.js';
|
|
60
|
+
export {
|
|
61
|
+
describeOperations,
|
|
62
|
+
symmetryDirections,
|
|
63
|
+
type Axis,
|
|
64
|
+
type DirectionElements,
|
|
65
|
+
type OperationDescription,
|
|
66
|
+
type OperationKind,
|
|
67
|
+
type SymmetryDirection,
|
|
68
|
+
} from './pointGroups/elements.js';
|
|
69
|
+
export { siteSymmetry, type SiteSymmetry, type SiteSymmetryOptions } from './siteSymmetry.js';
|
|
70
|
+
export {
|
|
71
|
+
rotateTensor,
|
|
72
|
+
tensorForm,
|
|
73
|
+
tensorFormOf,
|
|
74
|
+
type IntrinsicSymmetry,
|
|
75
|
+
type TensorForm,
|
|
76
|
+
type TensorParity,
|
|
77
|
+
type TensorRank,
|
|
78
|
+
type TensorSpec,
|
|
79
|
+
type TimeParity,
|
|
80
|
+
} from './tensors/tensorForm.js';
|
|
81
|
+
export { TENSOR_PROPERTIES, type TensorProperty, type TensorPropertyName } from './tensors/propertyTable.js';
|
|
82
|
+
export {
|
|
83
|
+
allowedProperties,
|
|
84
|
+
allowedPropertiesOf,
|
|
85
|
+
allowsProperty,
|
|
86
|
+
allowsPropertyOf,
|
|
87
|
+
} from './tensors/tensorProperties.js';
|