symcrys 0.3.0 → 0.4.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 CHANGED
@@ -4,7 +4,8 @@ Crystallographic symmetry calculations in TypeScript: point groups, both crystal
4
4
  magnetic, with their settings, symbols and properties, and the property tensors they allow. A
5
5
  library without runtime dependencies that runs unbundled in browsers and in Node.
6
6
 
7
- > **Status: pre-release.** So far: the 32 crystallographic point groups with their symmetry elements.
7
+ > **Status: pre-release.** So far: the 32 crystallographic point groups with their symmetry elements,
8
+ > site symmetry and Wyckoff positions, and the forms of property tensors of rank 0 to 4.
8
9
  > The API will change without notice until 1.0.0.
9
10
 
10
11
  ## Scope
@@ -17,9 +18,10 @@ symcrys holds calculations, not presentation. Planned, in this order:
17
18
  2. Plane groups.
18
19
  3. Space groups.
19
20
 
20
- The tensor calculations of birss-app (tensor forms, projections) move here as well; their place in
21
- this order is not yet fixed. Rendering (LaTeX, SVG, view models) and translated
22
- display names stay in the applications that use symcrys.
21
+ Property tensors: the symmetry-reduced form of a tensor of rank 0 to 4 under a point group or any
22
+ set of operations, from birss-app; results are numbers (coefficient matrices). Rendering (LaTeX,
23
+ SVG, relation strings, view models) and translated display names stay in the applications that use
24
+ symcrys.
23
25
 
24
26
  **Conventions.** Point groups follow the _International Tables for Crystallography_ by default
25
27
  (Vol. A for the crystal classes, Vol. D Ch. 1.5 for the magnetic point groups). The convention of
@@ -43,10 +45,14 @@ Each release on GitHub also carries the package as `symcrys-X.Y.Z.tgz`.
43
45
  ```ts
44
46
  import {
45
47
  describeOperations,
48
+ isPiezoelectric,
46
49
  operations,
47
50
  settings,
51
+ siteSymmetry,
48
52
  symbol,
49
53
  symmetryDirections,
54
+ tensorForm,
55
+ tensorFormOf,
50
56
  wyckoffPositionOf,
51
57
  wyckoffPositions,
52
58
  } from 'symcrys';
@@ -59,8 +65,23 @@ describeOperations('4')[2]; // { kind: 'rotation', order: 4, sense: '+', axis: {
59
65
  symmetryDirections('4mm')[1]; // position 2: symbol 'm', directions [100] and [010], each with a mirror
60
66
  wyckoffPositions('4mm')[2]; // { letter: 'b', multiplicity: 4, siteSymmetry: '..m', millerIndices: 'h,h,l', … }
61
67
  wyckoffPositionOf('4mm', [0, 0, -1]).letter; // 'a'
68
+
69
+ const SHG = { rank: 3, parity: 'polar', timeParity: 'i', intrinsic: 'jk' } as const;
70
+ tensorForm('mm2', SHG).parameters; // [[0,0,2], [1,1,2], [2,0,0], [2,1,1], [2,2,2]]: xxz, yyz, zxx, zyy, zzz
71
+ tensorForm('3m', SHG, { convention: 'birss' }).parameters[0]; // [0, 0, 0]: xxx (ITC default 3m1: xxy)
72
+ isPiezoelectric('432'); // false
73
+ // SHG at the (111) surface of an m-3m crystal: the form under the site symmetry of the normal
74
+ const ops = operations('m-3m');
75
+ tensorFormOf(
76
+ siteSymmetry(ops, [1, 1, 1]).operations.map((i) => ops[i]),
77
+ SHG,
78
+ ).basis.length; // 4
62
79
  ```
63
80
 
81
+ A form gives the components by flat index (first index slowest: xyz of rank 3 is 5), the basis in
82
+ reduced row echelon form and the relations as coefficient rows; see
83
+ [`docs/conventions.md`](docs/conventions.md), "Tensors".
84
+
64
85
  Conventions, frames and symbols: [`docs/conventions.md`](docs/conventions.md).
65
86
 
66
87
  Without a build step, copy `dist/` (from the tarball, or built with `npm run build`) next to your
@@ -87,8 +108,8 @@ Audits under `audit/` compare the code bases symcrys draws on. They are run by h
87
108
  [birss-app](https://github.com/manganite/birss-app) and
88
109
  [stereography](https://github.com/manganite/stereography) checked out next to this repository:
89
110
  `npm run audit:point-groups` writes `audit/point-groups/report.md`, and `npm run audit:birss-app`
90
- captures the pins of the Birss convention (`src/pointGroups/birssApp.pins.fixtures.ts`, formatted
91
- with Prettier by the same script).
111
+ captures the pins of the Birss convention as JSON (`src/pointGroups/birssApp.pins.json` for the
112
+ operations, `src/tensors/birssApp.pins.json` for the tensor forms).
92
113
 
93
114
  CI runs these seven gates on every pull request, on Node 22 and 24. Tests sit next to their
94
115
  module (`foo.ts`, `foo.test.ts`). Working rules for contributors, human or agent: `CLAUDE.md`.
package/dist/index.d.ts CHANGED
@@ -7,9 +7,10 @@ export type { Mat3, Vec3 } from './linalg.js';
7
7
  export type { Operation } from './operations.js';
8
8
  export { crystalFamily, latticeBasis, type CrystalFamily, type CrystalSystem, type FixedAngleFamily, } from './lattice.js';
9
9
  export { POINT_GROUP_KEYS, findPointGroup, generators, isPointGroupKey, operations, pointGroup, pointGroups, settings, symbol, type Convention, type PointGroup, type PointGroupInSetting, type PointGroupKey, type PointGroupType, type Setting, type SettingOptions, type SymbolOptions, } from './pointGroups/pointGroups.js';
10
- export { isCentrosymmetric, isChiral, isPolar, laueClass } from './pointGroups/properties.js';
10
+ export { isCentrosymmetric, isChiral, isPiezoelectric, isPolar, laueClass } from './pointGroups/properties.js';
11
11
  export { LATTICE_SYMMETRY_DIRECTIONS, type Uvw } from './symmetryDirections.js';
12
12
  export { describeOperations, symmetryDirections, type Axis, type DirectionElements, type OperationDescription, type OperationKind, type SymmetryDirection, } from './pointGroups/elements.js';
13
13
  export { siteSymmetry, type SiteSymmetry, type SiteSymmetryOptions } from './siteSymmetry.js';
14
14
  export { wyckoffPositionOf, wyckoffPositions, type Hkl, type WyckoffOptions, type WyckoffPosition, } from './pointGroups/wyckoff.js';
15
+ export { rotateTensor, tensorForm, tensorFormOf, type IntrinsicSymmetry, type TensorForm, type TensorParity, type TensorRank, type TensorSpec, type TimeParity, } from './tensors/tensorForm.js';
15
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,E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EAClB,KAAK,gBAAgB,GACtB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,eAAe,EACf,UAAU,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,MAAM,EACN,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC/G,OAAO,EAAE,2BAA2B,EAAE,KAAK,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,IAAI,EACT,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,iBAAiB,GACvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC9F,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,eAAe,GACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,UAAU,GAChB,MAAM,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -5,9 +5,10 @@
5
5
  export { VERSION } from './version.js';
6
6
  export { crystalFamily, latticeBasis, } from './lattice.js';
7
7
  export { POINT_GROUP_KEYS, findPointGroup, generators, isPointGroupKey, operations, pointGroup, pointGroups, settings, symbol, } from './pointGroups/pointGroups.js';
8
- export { isCentrosymmetric, isChiral, isPolar, laueClass } from './pointGroups/properties.js';
8
+ export { isCentrosymmetric, isChiral, isPiezoelectric, isPolar, laueClass } from './pointGroups/properties.js';
9
9
  export { LATTICE_SYMMETRY_DIRECTIONS } from './symmetryDirections.js';
10
10
  export { describeOperations, symmetryDirections, } from './pointGroups/elements.js';
11
11
  export { siteSymmetry } from './siteSymmetry.js';
12
12
  export { wyckoffPositionOf, wyckoffPositions, } from './pointGroups/wyckoff.js';
13
+ export { rotateTensor, tensorForm, tensorFormOf, } from './tensors/tensorForm.js';
13
14
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIvC,OAAO,EACL,aAAa,EACb,YAAY,GAIb,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,eAAe,EACf,UAAU,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,MAAM,GASP,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC9F,OAAO,EAAE,2BAA2B,EAAY,MAAM,yBAAyB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GAMnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAA+C,MAAM,mBAAmB,CAAC;AAC9F,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GAIjB,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIvC,OAAO,EACL,aAAa,EACb,YAAY,GAIb,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,eAAe,EACf,UAAU,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,MAAM,GASP,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC/G,OAAO,EAAE,2BAA2B,EAAY,MAAM,yBAAyB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GAMnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAA+C,MAAM,mBAAmB,CAAC;AAC9F,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GAIjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,YAAY,EACZ,UAAU,EACV,YAAY,GAOb,MAAM,yBAAyB,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Properties of a point group that follow from its operations alone. They do not depend on the
3
- * setting or the convention. Properties that need tensors (piezoelectric, …) come with the tensor
4
- * module (CLAUDE.md, decision of 2026-11-08 on #13).
2
+ * Properties of a point group that follow from its operations, directly or through the form of a
3
+ * tensor (piezoelectric). They do not depend on the setting or the convention. Piezomagnetic,
4
+ * magnetoelectric and ferromagnetic follow with the magnetic point groups (#13).
5
5
  */
6
6
  import { type PointGroupKey } from './data.js';
7
7
  /** Contains the inversion. */
@@ -15,4 +15,9 @@ export declare function isPolar(key: PointGroupKey): boolean;
15
15
  export declare function isChiral(key: PointGroupKey): boolean;
16
16
  /** The Laue class: the centrosymmetric crystal class generated by the group and the inversion. */
17
17
  export declare function laueClass(key: PointGroupKey): PointGroupKey;
18
+ /**
19
+ * Piezoelectric: the polarization can depend linearly on stress, i.e. a polar time-even tensor of
20
+ * rank 3, symmetric in its last two indices, is allowed (ITA Table 3.2.2.1).
21
+ */
22
+ export declare function isPiezoelectric(key: PointGroupKey): boolean;
18
23
  //# sourceMappingURL=properties.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../../src/pointGroups/properties.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAMjE,8BAA8B;AAC9B,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAE7D;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAUnD;AAED,4DAA4D;AAC5D,wBAAgB,QAAQ,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAEpD;AAQD,kGAAkG;AAClG,wBAAgB,SAAS,CAAC,GAAG,EAAE,aAAa,GAAG,aAAa,CAa3D"}
1
+ {"version":3,"file":"properties.d.ts","sourceRoot":"","sources":["../../src/pointGroups/properties.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAOjE,8BAA8B;AAC9B,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAE7D;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAUnD;AAED,4DAA4D;AAC5D,wBAAgB,QAAQ,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAEpD;AAQD,kGAAkG;AAClG,wBAAgB,SAAS,CAAC,GAAG,EAAE,aAAa,GAAG,aAAa,CAa3D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAI3D"}
@@ -1,13 +1,14 @@
1
1
  /**
2
- * Properties of a point group that follow from its operations alone. They do not depend on the
3
- * setting or the convention. Properties that need tensors (piezoelectric, …) come with the tensor
4
- * module (CLAUDE.md, decision of 2026-11-08 on #13).
2
+ * Properties of a point group that follow from its operations, directly or through the form of a
3
+ * tensor (piezoelectric). They do not depend on the setting or the convention. Piezomagnetic,
4
+ * magnetoelectric and ferromagnetic follow with the magnetic point groups (#13).
5
5
  */
6
6
  import { INVERSION, det, matricesEqual } from '../linalg.js';
7
7
  import { EPSILON } from '../tolerances.js';
8
8
  import { compose, operation, operationsEqual } from '../operations.js';
9
9
  import { POINT_GROUP_KEYS } from './data.js';
10
10
  import { operations } from './pointGroups.js';
11
+ import { tensorForm } from '../tensors/tensorForm.js';
11
12
  /** Operations in setting 1, the frame all stored data share. */
12
13
  const stored = (key) => operations(key, { setting: 1 });
13
14
  /** Contains the inversion. */
@@ -57,4 +58,11 @@ export function laueClass(key) {
57
58
  laueCache.set(key, laue);
58
59
  return laue;
59
60
  }
61
+ /**
62
+ * Piezoelectric: the polarization can depend linearly on stress, i.e. a polar time-even tensor of
63
+ * rank 3, symmetric in its last two indices, is allowed (ITA Table 3.2.2.1).
64
+ */
65
+ export function isPiezoelectric(key) {
66
+ return (tensorForm(key, { rank: 3, parity: 'polar', timeParity: 'i', intrinsic: 'jk' }, { setting: 1 }).basis.length > 0);
67
+ }
60
68
  //# sourceMappingURL=properties.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"properties.js","sourceRoot":"","sources":["../../src/pointGroups/properties.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAkB,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAsB,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,gEAAgE;AAChE,MAAM,MAAM,GAAG,CAAC,GAAkB,EAAwB,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,OA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GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACrG,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,+CAA+C,GAAG,EAAE,CAAC,CAAC;IACjF,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACzB,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,GAAkB;IAChD,OAAO,CACL,UAAU,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CACjH,CAAC;AACJ,CAAC"}
@@ -14,7 +14,10 @@ export interface SiteSymmetryOptions {
14
14
  }
15
15
  /** The site symmetry of a direction. */
16
16
  export interface SiteSymmetry {
17
- /** Indices into the given operations of those that leave the direction fixed, ascending. */
17
+ /**
18
+ * Indices into the given operations of those that leave the direction fixed, ascending: for a group,
19
+ * a subgroup (the operations fixing within the tolerance, closed under products, see `siteSymmetry`).
20
+ */
18
21
  readonly operations: readonly number[];
19
22
  /**
20
23
  * The unit vector of the direction, set onto the fixed space of its site symmetry (the mean of
@@ -32,9 +35,12 @@ export declare function siteTolerance(options?: SiteSymmetryOptions): number;
32
35
  /**
33
36
  * The site symmetry of `direction` (any non-zero vector, Cartesian) under `operations`, which may
34
37
  * be any list of point operations (for instance those of a distorted crystal). Time reversal is
35
- * ignored: a direction or a face normal is not changed by it. `direction` and `multiplicity` are
36
- * meaningful when the operations form a group (then the fixing ones do too); for another list
37
- * `multiplicity` may not be an integer. Throws a RangeError for a zero vector.
38
+ * ignored: a direction or a face normal is not changed by it. The operations fixing the direction
39
+ * within the tolerance are closed under the products found in the list and the direction is set onto
40
+ * their fixed space, repeated until stable, so that for a group the result is a subgroup and the
41
+ * set direction lies exactly on its elements. For a list that is not a group, `multiplicity` may
42
+ * not be an integer. Throws a RangeError for a zero vector, and if the closed operations fix no
43
+ * common direction (a tolerance far too large, e.g. 0.5).
38
44
  */
39
45
  export declare function siteSymmetry(operations: readonly Operation[], direction: Vec3, options?: SiteSymmetryOptions): SiteSymmetry;
40
46
  //# sourceMappingURL=siteSymmetry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"siteSymmetry.d.ts","sourceRoot":"","sources":["../src/siteSymmetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAS,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,wCAAwC;AACxC,MAAM,WAAW,YAAY;IAC3B,4FAA4F;IAC5F,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,2GAA2G;IAC3G,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,kGAAkG;IAClG,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAiBD,6CAA6C;AAC7C,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAInE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,SAAS,SAAS,EAAE,EAChC,SAAS,EAAE,IAAI,EACf,OAAO,CAAC,EAAE,mBAAmB,GAC5B,YAAY,CAqBd"}
1
+ {"version":3,"file":"siteSymmetry.d.ts","sourceRoot":"","sources":["../src/siteSymmetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAkC,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,wCAAwC;AACxC,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,2GAA2G;IAC3G,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,kGAAkG;IAClG,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAuED,6CAA6C;AAC7C,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAInE;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,SAAS,SAAS,EAAE,EAChC,SAAS,EAAE,IAAI,EACf,OAAO,CAAC,EAAE,mBAAmB,GAC5B,YAAY,CAsCd"}
@@ -2,7 +2,7 @@
2
2
  * Site symmetry of a direction under any list of point operations: which operations leave it
3
3
  * fixed (docs/conventions.md, "Site symmetry and Wyckoff positions").
4
4
  */
5
- import { apply } from './linalg.js';
5
+ import { apply, matricesEqual, multiply } from './linalg.js';
6
6
  import { EPSILON } from './tolerances.js';
7
7
  function unit(v) {
8
8
  const n = Math.hypot(v[0], v[1], v[2]);
@@ -17,6 +17,55 @@ function fixes(op, v, tolerance) {
17
17
  function isIdentity(op) {
18
18
  return op.matrix.every((row, i) => row.every((v, j) => Math.abs(v - (i === j ? 1 : 0)) < EPSILON));
19
19
  }
20
+ /** Products already looked up, per list of operations: `i * n + j` → index of op[i]·op[j] in the list, or -1. */
21
+ const productTables = new WeakMap();
22
+ function productIndex(operations, i, j) {
23
+ let table = productTables.get(operations);
24
+ if (!table) {
25
+ table = new Map();
26
+ productTables.set(operations, table);
27
+ }
28
+ const key = i * operations.length + j;
29
+ let k = table.get(key);
30
+ if (k === undefined) {
31
+ const product = multiply(operations[i].matrix, operations[j].matrix);
32
+ k = operations.findIndex((op) => matricesEqual(op.matrix, product));
33
+ table.set(key, k);
34
+ }
35
+ return k;
36
+ }
37
+ /** The indices plus those of every product of two of them that is itself in the list, until closed. */
38
+ function closeWithin(operations, indices) {
39
+ const set = [...indices];
40
+ const inSet = new Set(set);
41
+ // Each element is multiplied with every element before it once, in both orders, as it is added.
42
+ for (let i = 0; i < set.length; i++) {
43
+ for (let j = 0; j <= i; j++) {
44
+ for (const k of [productIndex(operations, set[i], set[j]), productIndex(operations, set[j], set[i])]) {
45
+ if (k >= 0 && !inSet.has(k)) {
46
+ inSet.add(k);
47
+ set.push(k);
48
+ }
49
+ }
50
+ }
51
+ }
52
+ return set.sort((x, y) => x - y);
53
+ }
54
+ /** The normalised mean of the images of v under the operations at `indices`; undefined if it vanishes. */
55
+ function meanImage(operations, indices, v) {
56
+ if (indices.length === 0)
57
+ return v;
58
+ const sum = [0, 0, 0];
59
+ for (const i of indices) {
60
+ const w = apply(operations[i].matrix, v);
61
+ sum[0] += w[0];
62
+ sum[1] += w[1];
63
+ sum[2] += w[2];
64
+ }
65
+ const n = Math.hypot(sum[0], sum[1], sum[2]);
66
+ return n > 1e-9 * indices.length ? [sum[0] / n, sum[1] / n, sum[2] / n] : undefined;
67
+ }
68
+ const sameIndices = (a, b) => a.length === b.length && a.every((x, i) => x === b[i]);
20
69
  /** The tolerance of the options, checked. */
21
70
  export function siteTolerance(options) {
22
71
  const t = options?.tolerance ?? EPSILON;
@@ -27,26 +76,44 @@ export function siteTolerance(options) {
27
76
  /**
28
77
  * The site symmetry of `direction` (any non-zero vector, Cartesian) under `operations`, which may
29
78
  * be any list of point operations (for instance those of a distorted crystal). Time reversal is
30
- * ignored: a direction or a face normal is not changed by it. `direction` and `multiplicity` are
31
- * meaningful when the operations form a group (then the fixing ones do too); for another list
32
- * `multiplicity` may not be an integer. Throws a RangeError for a zero vector.
79
+ * ignored: a direction or a face normal is not changed by it. The operations fixing the direction
80
+ * within the tolerance are closed under the products found in the list and the direction is set onto
81
+ * their fixed space, repeated until stable, so that for a group the result is a subgroup and the
82
+ * set direction lies exactly on its elements. For a list that is not a group, `multiplicity` may
83
+ * not be an integer. Throws a RangeError for a zero vector, and if the closed operations fix no
84
+ * common direction (a tolerance far too large, e.g. 0.5).
33
85
  */
34
86
  export function siteSymmetry(operations, direction, options) {
35
87
  const tolerance = siteTolerance(options);
36
88
  const v = unit(direction);
37
- const indices = [];
38
- operations.forEach((op, i) => {
39
- if (fixes(op, v, tolerance))
40
- indices.push(i);
41
- });
42
- const sum = [0, 0, 0];
43
- for (const i of indices) {
44
- const w = apply(operations[i].matrix, v);
45
- sum[0] += w[0];
46
- sum[1] += w[1];
47
- sum[2] += w[2];
89
+ const fixing = (w) => {
90
+ const out = [];
91
+ operations.forEach((op, i) => {
92
+ if (fixes(op, w, tolerance))
93
+ out.push(i);
94
+ });
95
+ return out;
96
+ };
97
+ // Within the tolerance the operations fixing v need not form a group (near an axis a rotation can count
98
+ // as fixing while its square does not). Close them under products found in the list, set v onto the
99
+ // fixed space of the closure (the mean of its images, the projector for a group), and repeat on the
100
+ // projected direction until the set is stable.
101
+ let indices = fixing(v);
102
+ let projected = v;
103
+ let set = closeWithin(operations, indices);
104
+ for (let pass = 0; pass < 8; pass++) {
105
+ const mean = meanImage(operations, set, v);
106
+ if (mean === undefined) {
107
+ throw new RangeError(`No common fixed direction for the operations fixing ${JSON.stringify(direction)} within ${tolerance} (tolerance too large?)`);
108
+ }
109
+ const next = closeWithin(operations, fixing(mean));
110
+ if (sameIndices(next, set)) {
111
+ indices = set;
112
+ projected = mean;
113
+ break;
114
+ }
115
+ set = next;
48
116
  }
49
- const projected = indices.length > 0 ? unit(sum) : v;
50
117
  return Object.freeze({
51
118
  operations: Object.freeze(indices),
52
119
  direction: Object.freeze(projected),
@@ -1 +1 @@
1
- {"version":3,"file":"siteSymmetry.js","sourceRoot":"","sources":["../src/siteSymmetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAa,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AA2B1C,SAAS,IAAI,CAAC,CAAO;IACnB,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,oBAAoB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACnG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,KAAK,CAAC,EAAa,EAAE,CAAO,EAAE,SAAiB;IACtD,MAAM,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AACvE,CAAC;AAED,SAAS,UAAU,CAAC,EAA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,CAAC,CAAC,CAAC,CAAC;KACzD,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Row reduction of real vectors (any length): the reduced row echelon form of a spanning set, and
3
+ * the rank. The tolerances are those of birss-app's `linalg.ts`, where the tensor code comes from.
4
+ */
5
+ /** An entry below this (absolute) does not serve as a pivot: float noise is never a new direction. */
6
+ export declare const PIVOT_EPSILON = 1e-7;
7
+ /** An entry below this (absolute) is not eliminated, and is set to zero in the result. */
8
+ export declare const ELIMINATION_EPSILON = 1e-12;
9
+ /**
10
+ * The reduced row echelon form of the span of `vectors` (all of length `dim`): one row per
11
+ * independent direction, each with a 1 at its pivot and 0 at every other row's pivot, pivots
12
+ * ascending. The rows are unique for a given span, so the pivots name the free parameters
13
+ * unambiguously: each is the lowest-index component that is independent of the ones before it.
14
+ */
15
+ export declare function reducedRowEchelon(vectors: readonly (readonly number[])[], dim: number): number[][];
16
+ /** The number of independent vectors among `vectors` (all of length `dim`). */
17
+ export declare function rank(vectors: readonly (readonly number[])[], dim: number): number;
18
+ //# sourceMappingURL=rowEchelon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rowEchelon.d.ts","sourceRoot":"","sources":["../../src/tensors/rowEchelon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,sGAAsG;AACtG,eAAO,MAAM,aAAa,OAAO,CAAC;AAElC,0FAA0F;AAC1F,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,CAoBlG;AAED,+EAA+E;AAC/E,wBAAgB,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjF"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Row reduction of real vectors (any length): the reduced row echelon form of a spanning set, and
3
+ * the rank. The tolerances are those of birss-app's `linalg.ts`, where the tensor code comes from.
4
+ */
5
+ /** An entry below this (absolute) does not serve as a pivot: float noise is never a new direction. */
6
+ export const PIVOT_EPSILON = 1e-7;
7
+ /** An entry below this (absolute) is not eliminated, and is set to zero in the result. */
8
+ export const ELIMINATION_EPSILON = 1e-12;
9
+ /**
10
+ * The reduced row echelon form of the span of `vectors` (all of length `dim`): one row per
11
+ * independent direction, each with a 1 at its pivot and 0 at every other row's pivot, pivots
12
+ * ascending. The rows are unique for a given span, so the pivots name the free parameters
13
+ * unambiguously: each is the lowest-index component that is independent of the ones before it.
14
+ */
15
+ export function reducedRowEchelon(vectors, dim) {
16
+ const m = vectors.map((v) => Array.from(v));
17
+ let row = 0;
18
+ for (let c = 0; c < dim && row < m.length; c++) {
19
+ let pivot = row;
20
+ for (let r = row + 1; r < m.length; r++)
21
+ if (Math.abs(m[r][c]) > Math.abs(m[pivot][c]))
22
+ pivot = r;
23
+ if (Math.abs(m[pivot][c]) < PIVOT_EPSILON)
24
+ continue;
25
+ [m[row], m[pivot]] = [m[pivot], m[row]];
26
+ const p = m[row][c];
27
+ for (let j = 0; j < dim; j++)
28
+ m[row][j] /= p;
29
+ for (let r = 0; r < m.length; r++) {
30
+ if (r === row || Math.abs(m[r][c]) <= ELIMINATION_EPSILON)
31
+ continue;
32
+ const f = m[r][c];
33
+ for (let j = 0; j < dim; j++)
34
+ m[r][j] -= f * m[row][j];
35
+ }
36
+ row++;
37
+ }
38
+ const out = m.slice(0, row);
39
+ for (const r of out)
40
+ for (let j = 0; j < dim; j++)
41
+ if (Math.abs(r[j]) < ELIMINATION_EPSILON)
42
+ r[j] = 0;
43
+ return out;
44
+ }
45
+ /** The number of independent vectors among `vectors` (all of length `dim`). */
46
+ export function rank(vectors, dim) {
47
+ return reducedRowEchelon(vectors, dim).length;
48
+ }
49
+ //# sourceMappingURL=rowEchelon.js.map
@@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,0 +1,82 @@
1
+ /**
2
+ * Symmetry-reduced forms of property tensors: which Cartesian components of a tensor of rank 0 to 4
3
+ * a point group allows, and how they depend on each other. Results are plain numbers (coefficient
4
+ * matrices and index lists); formulas, LaTeX and diagrams stay in the applications (CLAUDE.md,
5
+ * "Tensors").
6
+ *
7
+ * Components are numbered by their flat index: for indices (i₁, …, iₙ) with x, y, z = 0, 1, 2 the
8
+ * flat index is i₁·3ⁿ⁻¹ + … + iₙ, so the first index varies slowest (row-major, the order of a
9
+ * NumPy array of shape (3,)*n in C order). Moved from birss-app (`tensorForms.ts`,
10
+ * `tensorProjection.ts`, `linalg.ts`, revision 2be5fe3).
11
+ */
12
+ import { type Mat3 } from '../linalg.js';
13
+ import { type Operation } from '../operations.js';
14
+ import { type PointGroupKey, type SettingOptions } from '../pointGroups/pointGroups.js';
15
+ /** Rank of a tensor: 0 (scalar) to 4. */
16
+ export type TensorRank = 0 | 1 | 2 | 3 | 4;
17
+ /** `'polar'`: transforms with R; `'axial'`: with det(R)·R (pseudotensor). */
18
+ export type TensorParity = 'polar' | 'axial';
19
+ /** `'i'`: time-even (invariant under time reversal); `'c'`: time-odd (changes sign). */
20
+ export type TimeParity = 'i' | 'c';
21
+ /**
22
+ * Symmetry of the tensor under permutation of its own indices, independent of the crystal:
23
+ * `'none'`; `'ij'`: the first two indices are interchangeable; `'jk'`: the last two (for rank 3 the
24
+ * index symmetry of second-harmonic generation and the piezoelectric effect); `'ij_kl'` (rank 4):
25
+ * each of the two pairs symmetric, the pairs not interchangeable (e.g. electric-quadrupole SHG,
26
+ * photoelasticity); `'voigt'` (rank 4): `'ij_kl'` and the pairs interchangeable (elastic
27
+ * stiffness). At rank 2, `'ij'` and `'jk'` both mean a symmetric tensor.
28
+ */
29
+ export type IntrinsicSymmetry = 'none' | 'ij' | 'jk' | 'ij_kl' | 'voigt';
30
+ /** The kind of tensor, as in birss-app. */
31
+ export interface TensorSpec {
32
+ readonly rank: TensorRank;
33
+ readonly parity: TensorParity;
34
+ readonly timeParity: TimeParity;
35
+ readonly intrinsic: IntrinsicSymmetry;
36
+ }
37
+ /**
38
+ * The form of a tensor under a point group: the subspace of tensors invariant under every
39
+ * operation and with the requested index symmetry. Every entry is a plain number; a vector of
40
+ * components has length 3^rank (flat index, see the module documentation).
41
+ */
42
+ export interface TensorForm {
43
+ readonly rank: TensorRank;
44
+ /**
45
+ * A basis of the allowed tensors in reduced row echelon form: one row per free parameter, with 1
46
+ * at the parameter's own component and 0 at every other parameter's component. Every allowed
47
+ * tensor is Σₖ pₖ·basis[k], where pₖ is the value of its component `parameters[k]`. Empty if the
48
+ * tensor vanishes.
49
+ */
50
+ readonly basis: readonly (readonly number[])[];
51
+ /**
52
+ * The free parameters, as the index lists of their components (e.g. `[0, 1, 1]` for xyy), one per
53
+ * basis row and in its order: each is the lowest component independent of those before it.
54
+ */
55
+ readonly parameters: readonly (readonly number[])[];
56
+ /**
57
+ * The constraints: one row r per component that is not a parameter, in ascending flat index,
58
+ * with r·t = 0 for every allowed tensor t. Row c reads t_c − Σₖ basis[k][c]·t_{parameters[k]} = 0;
59
+ * a row with a single 1 says that the component vanishes.
60
+ */
61
+ readonly relations: readonly (readonly number[])[];
62
+ }
63
+ /**
64
+ * The form of a tensor under a point group in the requested setting (default: the default setting
65
+ * of the convention, `'itc'` unless given). The convention matters only through the setting: the
66
+ * same setting index gives the same form in both conventions (docs/conventions.md, "Tensors").
67
+ */
68
+ export declare function tensorForm(key: PointGroupKey, spec: TensorSpec, options?: SettingOptions): TensorForm;
69
+ /**
70
+ * The form of a tensor under the group generated by `operations`, e.g. the site symmetry of a
71
+ * surface normal (`siteSymmetry`) or the operations of a distorted crystal. The operations are
72
+ * Cartesian and orthogonal; a list that is not closed is closed first.
73
+ */
74
+ export declare function tensorFormOf(operations: readonly Operation[], spec: TensorSpec): TensorForm;
75
+ /**
76
+ * The components of `tensor` (length 3^rank, flat index) in a frame rotated by the orthogonal
77
+ * matrix `rotation`: t′_{i…} = f·Σ R_{ia}…R_{…}·t_{a…}, with f = det(R) for an axial tensor and 1
78
+ * for a polar one. To express a tensor in the frame of a surface, pass the matrix whose rows are
79
+ * the new axes in the old frame. Time parity plays no part.
80
+ */
81
+ export declare function rotateTensor(tensor: readonly number[], rotation: Mat3, spec: TensorSpec): number[];
82
+ //# sourceMappingURL=tensorForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tensorForm.d.ts","sourceRoot":"","sources":["../../src/tensors/tensorForm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAO,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAwB,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAI9G,yCAAyC;AACzC,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE3C,6EAA6E;AAC7E,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,OAAO,CAAC;AAE7C,wFAAwF;AACxF,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,CAAC;AAEnC;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC;AAEzE,2CAA2C;AAC3C,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EA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