@mat3ra/made 2026.6.29-0 → 2026.7.8-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.
Files changed (43) hide show
  1. package/dist/js/basis/basis.js +8 -8
  2. package/dist/js/basis/coordinates.js +2 -2
  3. package/dist/js/cell/cell.js +11 -10
  4. package/dist/js/cell/conventional_cell.js +2 -2
  5. package/dist/js/cell/primitive_cell.js +19 -21
  6. package/dist/js/lattice/lattice.js +42 -30
  7. package/dist/js/lattice/lattice_types.js +1 -1
  8. package/dist/js/lattice/reciprocal/lattice_reciprocal.js +16 -16
  9. package/dist/js/lattice/reciprocal/symmetry_points.js +1 -2
  10. package/dist/js/material.d.ts +15 -15
  11. package/dist/js/parsers/poscar.js +2 -4
  12. package/dist/js/parsers/xyz.js +2 -2
  13. package/dist/js/parsers/xyz_combinatorial_basis.d.ts +2 -1
  14. package/dist/js/parsers/xyz_combinatorial_basis.js +19 -9
  15. package/dist/js/tools/basis.js +3 -3
  16. package/dist/js/tools/cell.js +3 -3
  17. package/dist/js/tools/material.js +3 -3
  18. package/dist/js/tools/supercell.js +3 -3
  19. package/dist/js/tools/surface.js +14 -12
  20. package/package.json +41 -40
  21. package/pyproject.toml +6 -7
  22. package/src/js/basis/basis.ts +9 -8
  23. package/src/js/basis/coordinates.ts +3 -2
  24. package/src/js/cell/cell.ts +12 -10
  25. package/src/js/cell/primitive_cell.ts +23 -19
  26. package/src/js/lattice/lattice.ts +25 -23
  27. package/src/js/lattice/reciprocal/lattice_reciprocal.ts +19 -18
  28. package/src/js/parsers/poscar.ts +2 -2
  29. package/src/js/parsers/xyz_combinatorial_basis.ts +3 -2
  30. package/src/js/tools/basis.ts +4 -3
  31. package/src/js/tools/cell.ts +4 -3
  32. package/src/js/tools/material.ts +5 -4
  33. package/src/js/tools/supercell.ts +4 -3
  34. package/src/js/tools/surface.ts +18 -12
  35. package/src/py/mat3ra/made/cell/primitive_cell.py +156 -0
  36. package/tests/fixtures/hashes.json +3 -0
  37. package/tests/js/cell/cell.ts +1 -1
  38. package/tests/js/fixtures.ts +7 -1
  39. package/tests/js/material.test.ts +8 -1
  40. package/tests/py/conftest.py +1 -1
  41. package/tests/py/unit/test_material.py +10 -0
  42. package/tests/py/unit/test_primitive_cell.py +118 -0
  43. /package/src/py/mat3ra/made/{cell.py → cell/__init__.py} +0 -0
@@ -4,7 +4,7 @@ exports.Basis = void 0;
4
4
  // @ts-ignore
5
5
  const periodic_table_js_1 = require("@exabyte-io/periodic-table.js");
6
6
  const entity_1 = require("@mat3ra/code/dist/js/entity");
7
- const math_1 = require("@mat3ra/code/dist/js/math");
7
+ const utils_1 = require("@mat3ra/utils");
8
8
  const lodash_1 = require("lodash");
9
9
  const cell_1 = require("../cell/cell");
10
10
  const constants_1 = require("../constants");
@@ -163,7 +163,7 @@ class Basis extends entity_1.InMemoryEntity {
163
163
  }
164
164
  toStandardRepresentation() {
165
165
  this.toCrystal();
166
- this._coordinates.mapArrayInPlace((point) => point.map((x) => math_1.math.mod(x)));
166
+ this._coordinates.mapArrayInPlace((point) => point.map((x) => utils_1.Utils.math.mod(x)));
167
167
  }
168
168
  /** A representation where all coordinates are within 0 and 1 in crystal units */
169
169
  get standardRepresentation() {
@@ -237,7 +237,7 @@ class Basis extends entity_1.InMemoryEntity {
237
237
  get formula() {
238
238
  const counts = this.uniqueElementCountsSortedByElectronegativity;
239
239
  const countsValues = (0, lodash_1.values)(counts);
240
- const gcd = countsValues.length > 1 ? math_1.math.gcd(...countsValues) : countsValues[0];
240
+ const gcd = countsValues.length > 1 ? utils_1.Utils.math.gcd(...countsValues) : countsValues[0];
241
241
  return (0, lodash_1.toPairs)(counts)
242
242
  .map(([element, count]) => element + (count / gcd === 1 ? "" : count / gcd))
243
243
  .reduce((acc, part) => acc + part, "");
@@ -290,7 +290,7 @@ class Basis extends entity_1.InMemoryEntity {
290
290
  const element = entry[0];
291
291
  const coordinate = entry[1];
292
292
  const atomicLabel = entry[2];
293
- const toleratedCoordinate = coordinate.map((x) => math_1.math.round(x, constants_1.HASH_TOLERANCE));
293
+ const toleratedCoordinate = coordinate.map((x) => utils_1.Utils.math.roundCustom(x, constants_1.HASH_TOLERANCE));
294
294
  return `${element}${atomicLabel} ${toleratedCoordinate.join()}`;
295
295
  });
296
296
  return `${standardRep.sort().join(";")};`;
@@ -361,7 +361,7 @@ class Basis extends entity_1.InMemoryEntity {
361
361
  hasEquivalentCellTo(anotherBasisClsInstance) {
362
362
  return !this.cell.vectorArrays
363
363
  .map((vector, idx) => {
364
- return math_1.math.vEqualWithTolerance(vector, anotherBasisClsInstance.cell.vectorArrays[idx]);
364
+ return utils_1.Utils.math.vEqualWithTolerance(vector, anotherBasisClsInstance.cell.vectorArrays[idx]);
365
365
  })
366
366
  .some((x) => !x);
367
367
  }
@@ -380,7 +380,7 @@ class Basis extends entity_1.InMemoryEntity {
380
380
  const maxDistance = this.maxPairwiseDistance;
381
381
  const minDistance = this.minPairwiseDistance;
382
382
  const widthRatio = maxDistance > 0 ? minDistance / maxDistance : 1;
383
- const latticeScalingFactor = math_1.math.almostEqual(widthRatio, 1)
383
+ const latticeScalingFactor = utils_1.Utils.math.almostEqual(widthRatio, 1)
384
384
  ? lattice_1.diatomicLatticePaddingFactor
385
385
  : lattice_1.molecularLatticePaddingFactor;
386
386
  const moleculeLatticeSize = maxDistance * latticeScalingFactor;
@@ -404,7 +404,7 @@ class Basis extends entity_1.InMemoryEntity {
404
404
  const tolerance = overlapCoefficient *
405
405
  ((0, periodic_table_js_1.getElementAtomicRadius)(el1) + (0, periodic_table_js_1.getElementAtomicRadius)(el2)); // in angstroms
406
406
  // @ts-ignore
407
- const distance = math_1.math.vDist(entry1.value, entry2.value);
407
+ const distance = utils_1.Utils.math.vDist(entry1.value, entry2.value);
408
408
  if (distance < tolerance) {
409
409
  overlaps.push({
410
410
  id1: i,
@@ -446,7 +446,7 @@ class Basis extends entity_1.InMemoryEntity {
446
446
  if (this._elements.values.length >= 2) {
447
447
  for (let i = 0; i < this._elements.values.length; i++) {
448
448
  for (let j = i + 1; j < this._elements.values.length; j++) {
449
- const distance = math_1.math.vDist(this._coordinates.getElementValueByIndex(i), this._coordinates.getElementValueByIndex(j));
449
+ const distance = utils_1.Utils.math.vDist(this._coordinates.getElementValueByIndex(i), this._coordinates.getElementValueByIndex(j));
450
450
  if (!distance)
451
451
  continue;
452
452
  if (extremum === "max" && distance > resultDistance) {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Coordinates = exports.Coordinate = void 0;
4
4
  const code_1 = require("@mat3ra/code");
5
- const math_1 = require("@mat3ra/code/dist/js/math");
5
+ const utils_1 = require("@mat3ra/utils");
6
6
  const underscore_string_1 = require("underscore.string");
7
7
  class Coordinate extends code_1.RoundedValueWithId {
8
8
  constructor({ value, id }) {
@@ -58,7 +58,7 @@ class Coordinates extends code_1.RoundedArrayWithIds {
58
58
  });
59
59
  }
60
60
  getCenterPoint() {
61
- const transposed = math_1.math.transpose(this.values);
61
+ const transposed = utils_1.Utils.math.transpose(this.values);
62
62
  const center = [0, 0, 0];
63
63
  for (let i = 0; i < 3; i++) {
64
64
  const axisCoords = transposed[i];
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Cell = void 0;
7
7
  const code_1 = require("@mat3ra/code");
8
- const math_1 = require("@mat3ra/code/dist/js/math");
8
+ const utils_1 = require("@mat3ra/utils");
9
9
  const constants_1 = __importDefault(require("../constants"));
10
- const MATRIX = math_1.math.matrix;
11
- const MULT = math_1.math.multiply;
12
- const INV = math_1.math.inv;
10
+ const MATRIX = utils_1.Utils.math.matrix;
11
+ const MULT = utils_1.Utils.math.multiply;
12
+ const INV = utils_1.Utils.math.inv;
13
13
  // @ts-ignore
14
14
  const MATRIX_MULT = (...args) => MULT(...args.map((x) => MATRIX(x))).toArray();
15
15
  class Cell {
@@ -44,10 +44,10 @@ class Cell {
44
44
  return [this._a.valueRounded, this._b.valueRounded, this._c.valueRounded];
45
45
  }
46
46
  get volume() {
47
- return math_1.math.det(this.vectorArrays);
47
+ return utils_1.Utils.math.det(this.vectorArrays);
48
48
  }
49
49
  get volumeRounded() {
50
- return math_1.math.roundArrayOrNumber(this.volume, Cell.roundPrecision);
50
+ return utils_1.Utils.math.roundArrayOrNumber(this.volume, Cell.roundPrecision);
51
51
  }
52
52
  clone() {
53
53
  return new Cell({ a: this.a, b: this.b, c: this.c });
@@ -66,7 +66,7 @@ class Cell {
66
66
  isPointInsideCellCartesian(point) {
67
67
  const { tolerance } = this.constructor;
68
68
  return (this.convertPointToCrystal(point)
69
- .map((c) => math_1.math.isBetweenZeroInclusiveAndOne(c, tolerance))
69
+ .map((c) => utils_1.Utils.math.isBetweenZeroInclusiveAndOne(c, tolerance))
70
70
  // @ts-ignore
71
71
  .reduce((a, b) => a && b));
72
72
  }
@@ -74,7 +74,7 @@ class Cell {
74
74
  isPointInsideCellCrystal(point) {
75
75
  const { tolerance } = this.constructor;
76
76
  return (point
77
- .map((c) => math_1.math.isBetweenZeroInclusiveAndOne(c, tolerance))
77
+ .map((c) => utils_1.Utils.math.isBetweenZeroInclusiveAndOne(c, tolerance))
78
78
  // @ts-ignore
79
79
  .reduce((a, b) => a && b));
80
80
  }
@@ -85,10 +85,11 @@ class Cell {
85
85
  return this.isPointInsideCellCartesian(point);
86
86
  }
87
87
  getMostCollinearVectorIndex(testVector) {
88
- const angles = this.vectorArrays.map((v) => math_1.math.angleUpTo90(v, testVector, "deg"));
89
- return angles.findIndex((el) => el === math_1.math.min(angles));
88
+ const angles = this.vectorArrays.map((v) => utils_1.Utils.math.angleUpTo90(v, testVector, "deg"));
89
+ return angles.findIndex((el) => el === utils_1.Utils.math.min(angles));
90
90
  }
91
91
  scaleByMatrix(matrix) {
92
+ // @ts-ignore - mathjs v12 multiply return type is broader than runtime
92
93
  [this.a, this.b, this.c] = MATRIX_MULT(matrix, this.vectorArrays);
93
94
  }
94
95
  toJSON() {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isConventionalCellSameAsPrimitiveForLatticeType = exports.PRIMITIVE_TO_CONVENTIONAL_CELL_LATTICE_TYPES = exports.PRIMITIVE_TO_CONVENTIONAL_CELL_MULTIPLIERS = void 0;
3
+ exports.PRIMITIVE_TO_CONVENTIONAL_CELL_LATTICE_TYPES = exports.PRIMITIVE_TO_CONVENTIONAL_CELL_MULTIPLIERS = void 0;
4
+ exports.isConventionalCellSameAsPrimitiveForLatticeType = isConventionalCellSameAsPrimitiveForLatticeType;
4
5
  /**
5
6
  * Routines for calculating conventional cell vectors from primitive cell Bravais parameters.
6
7
  * Following Setyawan, W., & Curtarolo, S. (2010). doi:10.1016/j.commatsci.2010.05.010
@@ -77,4 +78,3 @@ function isConventionalCellSameAsPrimitiveForLatticeType(latticeType) {
77
78
  const multiplier = exports.PRIMITIVE_TO_CONVENTIONAL_CELL_MULTIPLIERS[latticeType || "TRI"];
78
79
  return multiplier === unitMatrix;
79
80
  }
80
- exports.isConventionalCellSameAsPrimitiveForLatticeType = isConventionalCellSameAsPrimitiveForLatticeType;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPrimitiveLatticeVectorsFromConfig = void 0;
4
- const math_1 = require("@mat3ra/code/dist/js/math");
3
+ exports.getPrimitiveLatticeVectorsFromConfig = getPrimitiveLatticeVectorsFromConfig;
4
+ const utils_1 = require("@mat3ra/utils");
5
5
  /**
6
6
  * Routines for calculating primitive cell vectors from conventional cell Bravais parameters.
7
7
  * Following Setyawan, W., & Curtarolo, S. (2010). doi:10.1016/j.commatsci.2010.05.010
@@ -72,50 +72,49 @@ const PRIMITIVE_CELLS = {
72
72
  },
73
73
  HEX: ({ a, c }) => {
74
74
  return [
75
- [a / 2, (-a * math_1.math.sqrt(3)) / 2, 0],
76
- [a / 2, (a * math_1.math.sqrt(3)) / 2, 0],
75
+ [a / 2, (-a * Number(utils_1.Utils.math.sqrt(3))) / 2, 0],
76
+ [a / 2, (a * Number(utils_1.Utils.math.sqrt(3))) / 2, 0],
77
77
  [0, 0, c],
78
78
  ];
79
79
  },
80
80
  RHL: ({ a, alpha }) => {
81
- const cosAlpha = math_1.math.cos((alpha / 180) * math_1.math.PI);
82
- const cosHalfAlpha = math_1.math.sqrt((1 / 2) * (1 + cosAlpha));
83
- const sinHalfAlpha = math_1.math.sqrt((1 / 2) * (1 - cosAlpha));
81
+ const cosAlpha = Number(utils_1.Utils.math.cos((alpha / 180) * Number(utils_1.Utils.math.PI)));
82
+ const cosHalfAlpha = Number(utils_1.Utils.math.sqrt((1 / 2) * (1 + cosAlpha)));
83
+ const sinHalfAlpha = Number(utils_1.Utils.math.sqrt((1 / 2) * (1 - cosAlpha)));
84
84
  return [
85
85
  [a * cosHalfAlpha, -a * sinHalfAlpha, 0.0],
86
86
  [a * cosHalfAlpha, a * sinHalfAlpha, 0.0],
87
87
  [
88
88
  (a * cosAlpha) / cosHalfAlpha,
89
89
  0.0,
90
- a * math_1.math.sqrt(1 - (cosAlpha * cosAlpha) / (cosHalfAlpha * cosHalfAlpha)),
90
+ a *
91
+ Number(utils_1.Utils.math.sqrt(1 - (cosAlpha * cosAlpha) / (cosHalfAlpha * cosHalfAlpha))),
91
92
  ],
92
93
  ];
93
94
  },
94
95
  MCL: ({ a, b, c, alpha }) => {
95
- const cosAlpha = math_1.math.cos((alpha / 180) * math_1.math.PI);
96
+ const cosAlpha = Number(utils_1.Utils.math.cos((alpha / 180) * Number(utils_1.Utils.math.PI)));
96
97
  return [
97
98
  [a, 0, 0],
98
99
  [0, b, 0],
99
- [0, c * cosAlpha, c * math_1.math.sqrt(1 - cosAlpha * cosAlpha)],
100
+ [0, c * cosAlpha, c * Number(utils_1.Utils.math.sqrt(1 - cosAlpha * cosAlpha))],
100
101
  ];
101
102
  },
102
103
  MCLC: ({ a, b, c, alpha }) => {
103
- const cosAlpha = math_1.math.cos((alpha / 180) * math_1.math.PI);
104
+ const cosAlpha = Number(utils_1.Utils.math.cos((alpha / 180) * Number(utils_1.Utils.math.PI)));
104
105
  return [
105
106
  [a / 2, b / 2, 0],
106
107
  [-a / 2, b / 2, 0],
107
- [0, c * cosAlpha, c * math_1.math.sqrt(1 - cosAlpha * cosAlpha)],
108
+ [0, c * cosAlpha, c * Number(utils_1.Utils.math.sqrt(1 - cosAlpha * cosAlpha))],
108
109
  ];
109
110
  },
110
111
  // Algorithm from http://pymatgen.org/_modules/pymatgen/core/lattice.html (from_params)
111
112
  TRI: ({ a, b, c, alpha, beta, gamma }) => {
112
113
  // convert angles to Radians
113
114
  // eslint-disable-next-line no-param-reassign
114
- [alpha, beta, gamma] = [alpha, beta, gamma].map(
115
- // @ts-ignore
116
- (x) => math_1.math.unit(x, "degree").to("rad").value);
117
- const [cosAlpha, cosBeta, cosGamma] = [alpha, beta, gamma].map((x) => math_1.math.cos(x));
118
- const [sinAlpha, sinBeta] = [alpha, beta].map((x) => math_1.math.sin(x));
115
+ [alpha, beta, gamma] = [alpha, beta, gamma].map((x) => Number(utils_1.Utils.math.unit(x, "degree").to("rad").value));
116
+ const [cosAlpha, cosBeta, cosGamma] = [alpha, beta, gamma].map((x) => Number(utils_1.Utils.math.cos(x)));
117
+ const [sinAlpha, sinBeta] = [alpha, beta].map((x) => Number(utils_1.Utils.math.sin(x)));
119
118
  let acosArg = (cosAlpha * cosBeta - cosGamma) / (sinAlpha * sinBeta);
120
119
  if (acosArg < -1) {
121
120
  acosArg = -1;
@@ -123,9 +122,9 @@ const PRIMITIVE_CELLS = {
123
122
  else if (acosArg > 1) {
124
123
  acosArg = 1;
125
124
  }
126
- const gammaStar = math_1.math.acos(acosArg);
127
- const cosGammaStar = math_1.math.cos(gammaStar);
128
- const sinGammaStar = math_1.math.sin(gammaStar);
125
+ const gammaStar = Number(utils_1.Utils.math.acos(acosArg));
126
+ const cosGammaStar = Number(utils_1.Utils.math.cos(gammaStar));
127
+ const sinGammaStar = Number(utils_1.Utils.math.sin(gammaStar));
129
128
  return [
130
129
  [a * sinBeta, 0.0, a * cosBeta],
131
130
  [-b * sinAlpha * cosGammaStar, b * sinAlpha * sinGammaStar, b * cosAlpha],
@@ -143,4 +142,3 @@ function getPrimitiveLatticeVectorsFromConfig(latticeConfig) {
143
142
  const [vectorA, vectorB, vectorC] = primitiveCellGenerator(latticeConfig);
144
143
  return [vectorA, vectorB, vectorC];
145
144
  }
146
- exports.getPrimitiveLatticeVectorsFromConfig = getPrimitiveLatticeVectorsFromConfig;
@@ -15,23 +15,33 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.Lattice = exports.LatticeVectors = exports.molecularLatticePaddingFactor = exports.diatomicLatticePaddingFactor = exports.defaultNonPeriodicMinimumLatticeSize = void 0;
27
- const constants_1 = require("@mat3ra/code/dist/js/constants");
28
37
  const entity_1 = require("@mat3ra/code/dist/js/entity");
29
- const math_1 = require("@mat3ra/code/dist/js/math");
38
+ const utils_1 = require("@mat3ra/utils");
30
39
  const lodash = __importStar(require("lodash"));
31
40
  const cell_1 = require("../cell/cell");
32
41
  const primitive_cell_1 = require("../cell/primitive_cell");
33
42
  const lattice_types_1 = require("./lattice_types");
34
43
  const unit_cell_1 = require("./unit_cell");
44
+ const { HASH_TOLERANCE } = utils_1.Utils.constants;
35
45
  /**
36
46
  * Scaling factor used to calculate the new lattice size for non-periodic systems.
37
47
  * The scaling factor ensures that a non-periodic structure will have have a lattice greater than the structures size.
@@ -69,17 +79,19 @@ class Lattice extends entity_1.InMemoryEntity {
69
79
  const { a } = this;
70
80
  const { b } = this;
71
81
  const { c } = this;
72
- const alphaRad = math_1.math.unit(this.alpha, "deg").toNumber("rad");
73
- const betaRad = math_1.math.unit(this.beta, "deg").toNumber("rad");
74
- const gammaRad = math_1.math.unit(this.gamma, "deg").toNumber("rad");
75
- const cosAlpha = math_1.math.cos(alphaRad);
76
- const cosBeta = math_1.math.cos(betaRad);
77
- const cosGamma = math_1.math.cos(gammaRad);
78
- const sinAlpha = math_1.math.sin(alphaRad);
79
- const sinBeta = math_1.math.sin(betaRad);
80
- const gammaStar = math_1.math.acos((cosAlpha * cosBeta - cosGamma) / (sinAlpha * sinBeta));
81
- const cosGammaStar = math_1.math.cos(gammaStar);
82
- const sinGammaStar = math_1.math.sin(gammaStar);
82
+ const alphaRad = utils_1.Utils.math.unit(this.alpha, "deg").toNumber("rad");
83
+ const betaRad = utils_1.Utils.math.unit(this.beta, "deg").toNumber("rad");
84
+ const gammaRad = utils_1.Utils.math.unit(this.gamma, "deg").toNumber("rad");
85
+ const cosAlpha = utils_1.Utils.math.cos(alphaRad);
86
+ const cosBeta = utils_1.Utils.math.cos(betaRad);
87
+ const cosGamma = utils_1.Utils.math.cos(gammaRad);
88
+ const sinAlpha = utils_1.Utils.math.sin(alphaRad);
89
+ const sinBeta = utils_1.Utils.math.sin(betaRad);
90
+ const gammaStar = utils_1.Utils.math.acos((cosAlpha * cosBeta - cosGamma) / (sinAlpha * sinBeta));
91
+ // @ts-ignore - mathjs v12 acos return type includes Complex, but inputs are always real
92
+ const cosGammaStar = utils_1.Utils.math.cos(gammaStar);
93
+ // @ts-ignore
94
+ const sinGammaStar = utils_1.Utils.math.sin(gammaStar);
83
95
  const vectorA = [a * sinBeta, 0.0, a * cosBeta];
84
96
  const vectorB = [
85
97
  -b * sinAlpha * cosGammaStar,
@@ -94,12 +106,12 @@ class Lattice extends entity_1.InMemoryEntity {
94
106
  }
95
107
  static fromVectorsArray(vectors, units = Lattice.defaultConfig.units, type = "TRI") {
96
108
  const [aVec, bVec, cVec] = vectors;
97
- const a = math_1.math.vlen(aVec);
98
- const b = math_1.math.vlen(bVec);
99
- const c = math_1.math.vlen(cVec);
100
- const alpha = math_1.math.angle(bVec, cVec, "deg");
101
- const beta = math_1.math.angle(aVec, cVec, "deg");
102
- const gamma = math_1.math.angle(aVec, bVec, "deg");
109
+ const a = utils_1.Utils.math.vlen(aVec);
110
+ const b = utils_1.Utils.math.vlen(bVec);
111
+ const c = utils_1.Utils.math.vlen(cVec);
112
+ const alpha = utils_1.Utils.math.angle(bVec, cVec, "deg");
113
+ const beta = utils_1.Utils.math.angle(aVec, cVec, "deg");
114
+ const gamma = utils_1.Utils.math.angle(aVec, bVec, "deg");
103
115
  return new Lattice({
104
116
  a,
105
117
  b,
@@ -144,7 +156,7 @@ class Lattice extends entity_1.InMemoryEntity {
144
156
  */
145
157
  get typeExtended() {
146
158
  const { a, b, c, alpha, beta, gamma, type } = this;
147
- const cosAlpha = math_1.math.cos((alpha / 180) * math_1.math.PI);
159
+ const cosAlpha = utils_1.Utils.math.cos((alpha / 180) * utils_1.Utils.math.PI);
148
160
  switch (type) {
149
161
  case "BCT":
150
162
  return c < a ? "BCT-1" : "BCT-2";
@@ -179,14 +191,14 @@ class Lattice extends entity_1.InMemoryEntity {
179
191
  * Calculate the volume of the lattice cell.
180
192
  */
181
193
  get volume() {
182
- return math_1.math.abs(math_1.math.det(this.vectorArrays));
194
+ return utils_1.Utils.math.abs(utils_1.Utils.math.det(this.vectorArrays));
183
195
  }
184
196
  /*
185
197
  * Returns a "default" primitive lattice by type, with lattice parameters scaled by the length of "a",
186
198
  * @param latticeConfig {Object} LatticeBravais config (see constructor)
187
199
  */
188
200
  static getDefaultPrimitiveLatticeConfigByType(latticeConfig) {
189
- const f_ = math_1.math.roundArrayOrNumber;
201
+ const f_ = utils_1.Utils.math.roundArrayOrNumber;
190
202
  // construct new primitive cell using lattice parameters and skip rounding the vectors
191
203
  const vectors = (0, primitive_cell_1.getPrimitiveLatticeVectorsFromConfig)(latticeConfig);
192
204
  // create new lattice from primitive cell
@@ -224,7 +236,7 @@ class Lattice extends entity_1.InMemoryEntity {
224
236
  scaledLattice.beta,
225
237
  scaledLattice.gamma,
226
238
  ]
227
- .map((x) => math_1.math.round(x, constants_1.HASH_TOLERANCE))
239
+ .map((x) => utils_1.Utils.math.roundCustom(x, HASH_TOLERANCE))
228
240
  .join(";")};`;
229
241
  }
230
242
  /**
@@ -27,7 +27,7 @@ var LatticeTypeExtended;
27
27
  LatticeTypeExtended["TRI_1a"] = "TRI_1a";
28
28
  LatticeTypeExtended["TRI_2a"] = "TRI_2a";
29
29
  LatticeTypeExtended["TRI_1b"] = "TRI_1b";
30
- })(LatticeTypeExtended = exports.LatticeTypeExtended || (exports.LatticeTypeExtended = {}));
30
+ })(LatticeTypeExtended || (exports.LatticeTypeExtended = LatticeTypeExtended = {}));
31
31
  exports.DEFAULT_LATTICE_UNITS = {
32
32
  // by default lattice vectors shall be measured in angstrom, angles - in degrees
33
33
  length: {
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ReciprocalLattice = void 0;
7
7
  const constants_1 = require("@mat3ra/code/dist/js/constants");
8
- const math_1 = require("@mat3ra/code/dist/js/math");
8
+ const utils_1 = require("@mat3ra/utils");
9
9
  const lodash_1 = __importDefault(require("lodash"));
10
10
  const lattice_1 = require("../lattice");
11
11
  const paths_1 = require("./paths");
@@ -17,26 +17,26 @@ class ReciprocalLattice extends lattice_1.Lattice {
17
17
  */
18
18
  get reciprocalVectors() {
19
19
  const vectors_ = this.vectors.vectorArrays;
20
- const a = math_1.math.vlen(vectors_[0]);
21
- const divider = math_1.math.multiply(vectors_[0], math_1.math.cross(vectors_[1], vectors_[2])) / a;
20
+ const a = utils_1.Utils.math.vlen(vectors_[0]);
21
+ const divider = utils_1.Utils.math.multiply(vectors_[0], utils_1.Utils.math.cross(vectors_[1], vectors_[2])) / a;
22
22
  return [
23
- math_1.math.multiply(math_1.math.cross(vectors_[1], vectors_[2]), 1 / divider),
24
- math_1.math.multiply(math_1.math.cross(vectors_[2], vectors_[0]), 1 / divider),
25
- math_1.math.multiply(math_1.math.cross(vectors_[0], vectors_[1]), 1 / divider),
23
+ utils_1.Utils.math.multiply(utils_1.Utils.math.cross(vectors_[1], vectors_[2]), 1 / divider),
24
+ utils_1.Utils.math.multiply(utils_1.Utils.math.cross(vectors_[2], vectors_[0]), 1 / divider),
25
+ utils_1.Utils.math.multiply(utils_1.Utils.math.cross(vectors_[0], vectors_[1]), 1 / divider),
26
26
  ];
27
27
  }
28
28
  /**
29
29
  * Norms of reciprocal vectors.
30
30
  */
31
31
  get reciprocalVectorNorms() {
32
- return this.reciprocalVectors.map((vec) => math_1.math.norm(vec));
32
+ return this.reciprocalVectors.map((vec) => utils_1.Utils.math.norm(vec));
33
33
  }
34
34
  /**
35
35
  * Ratio of reciprocal vector norms scaled by the inverse of the largest component.
36
36
  */
37
37
  get reciprocalVectorRatios() {
38
38
  const norms = this.reciprocalVectorNorms;
39
- const maxNorm = math_1.math.max(...norms);
39
+ const maxNorm = utils_1.Utils.math.max(...norms);
40
40
  return norms.map((n) => n / maxNorm);
41
41
  }
42
42
  /**
@@ -45,7 +45,7 @@ class ReciprocalLattice extends lattice_1.Lattice {
45
45
  * @return {KPointCoordinates}
46
46
  */
47
47
  getCartesianCoordinates(point) {
48
- return math_1.math.multiply(point, this.reciprocalVectors);
48
+ return utils_1.Utils.math.multiply(point, this.reciprocalVectors);
49
49
  }
50
50
  /**
51
51
  * Get the list of high-symmetry points for the current lattice.
@@ -72,7 +72,7 @@ class ReciprocalLattice extends lattice_1.Lattice {
72
72
  const symmPoints = this.symmetryPoints;
73
73
  dataPoints.forEach((point, index) => {
74
74
  const symmPoint = symmPoints.find((x) => {
75
- return math_1.math.vEqualWithTolerance(x.coordinates, point, 1e-4);
75
+ return utils_1.Utils.math.vEqualWithTolerance(x.coordinates, point, 1e-4);
76
76
  });
77
77
  if (symmPoint) {
78
78
  kpointPath.push({
@@ -94,8 +94,8 @@ class ReciprocalLattice extends lattice_1.Lattice {
94
94
  calculateDimension(nPoints, index) {
95
95
  const norms = this.reciprocalVectorNorms;
96
96
  const [j, k] = [0, 1, 2].filter((i) => i !== index); // get indices of other two dimensions
97
- const N = math_1.math.cbrt((nPoints * norms[index] ** 2) / (norms[j] * norms[k]));
98
- return math_1.math.max(1, math_1.math.ceil(N));
97
+ const N = utils_1.Utils.math.cbrt((nPoints * norms[index] ** 2) / (norms[j] * norms[k]));
98
+ return utils_1.Utils.math.max(1, utils_1.Utils.math.ceil(N));
99
99
  }
100
100
  /**
101
101
  * Calculate grid dimensions from total number of k-points.
@@ -110,10 +110,10 @@ class ReciprocalLattice extends lattice_1.Lattice {
110
110
  const { a } = this;
111
111
  return {
112
112
  [constants_1.ATOMIC_COORD_UNITS.cartesian]: {
113
- [constants_1.units.angstrom]: (2 * math_1.math.PI) / a,
113
+ [constants_1.units.angstrom]: (2 * utils_1.Utils.math.PI) / a,
114
114
  },
115
115
  [constants_1.units.angstrom]: {
116
- [constants_1.ATOMIC_COORD_UNITS.cartesian]: a / (2 * math_1.math.PI),
116
+ [constants_1.ATOMIC_COORD_UNITS.cartesian]: a / (2 * utils_1.Utils.math.PI),
117
117
  },
118
118
  };
119
119
  }
@@ -127,7 +127,7 @@ class ReciprocalLattice extends lattice_1.Lattice {
127
127
  getDimensionsFromSpacing(spacing, units = constants_1.ATOMIC_COORD_UNITS.cartesian) {
128
128
  const factor = this.conversionTable[units][constants_1.ATOMIC_COORD_UNITS.cartesian] || 1;
129
129
  return this.reciprocalVectorNorms.map((norm) => {
130
- return math_1.math.max(1, math_1.math.ceil(lodash_1.default.round(norm / (spacing * factor), 4)));
130
+ return utils_1.Utils.math.max(1, utils_1.Utils.math.ceil(lodash_1.default.round(norm / (spacing * factor), 4)));
131
131
  });
132
132
  }
133
133
  /**
@@ -140,7 +140,7 @@ class ReciprocalLattice extends lattice_1.Lattice {
140
140
  const factor = this.conversionTable[constants_1.ATOMIC_COORD_UNITS.cartesian][units] || 1;
141
141
  const norms = this.reciprocalVectorNorms;
142
142
  return (factor *
143
- math_1.math.mean(dimensions.map((dim, i) => norms[i] / math_1.math.max(1, dim))));
143
+ utils_1.Utils.math.mean(dimensions.map((dim, i) => norms[i] / utils_1.Utils.math.max(1, dim))));
144
144
  }
145
145
  }
146
146
  exports.ReciprocalLattice = ReciprocalLattice;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.symmetryPoints = void 0;
3
+ exports.symmetryPoints = symmetryPoints;
4
4
  const POINTS = {
5
5
  CUB: () => {
6
6
  return [
@@ -863,4 +863,3 @@ function symmetryPoints(lattice) {
863
863
  },
864
864
  ].concat(POINTS[lattice.type](lattice) || []);
865
865
  }
866
- exports.symmetryPoints = symmetryPoints;
@@ -37,34 +37,34 @@ declare class Material extends InMemoryEntity implements Schema {
37
37
  * @summary Returns the specific derived property (as specified by name) for a material.
38
38
  */
39
39
  getDerivedPropertyByName(name: string): {
40
- name?: "volume" | undefined;
41
- units?: "angstrom^3" | undefined;
40
+ name?: "volume";
41
+ units?: "angstrom^3";
42
42
  value: number;
43
43
  } | {
44
- name?: "density" | undefined;
45
- units?: "g/cm^3" | undefined;
44
+ name?: "density";
45
+ units?: "g/cm^3";
46
46
  value: number;
47
47
  } | {
48
- pointGroupSymbol?: string | undefined;
49
- spaceGroupSymbol?: string | undefined;
48
+ pointGroupSymbol?: string;
49
+ spaceGroupSymbol?: string;
50
50
  tolerance?: {
51
- units?: "angstrom" | undefined;
51
+ units?: "angstrom";
52
52
  value: number;
53
- } | undefined;
54
- name?: "symmetry" | undefined;
53
+ };
54
+ name?: "symmetry";
55
55
  } | {
56
- name?: "elemental_ratio" | undefined;
56
+ name?: "elemental_ratio";
57
57
  value: number;
58
- element?: string | undefined;
58
+ element?: string;
59
59
  } | {
60
- name?: "p-norm" | undefined;
61
- degree?: number | undefined;
60
+ name?: "p-norm";
61
+ degree?: number;
62
62
  value: number;
63
63
  } | {
64
- name?: "inchi" | undefined;
64
+ name?: "inchi";
65
65
  value: string;
66
66
  } | {
67
- name?: "inchi_key" | undefined;
67
+ name?: "inchi_key";
68
68
  value: string;
69
69
  } | undefined;
70
70
  /**
@@ -3,15 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.atomsCount = void 0;
7
- const math_1 = require("@mat3ra/code/dist/js/math");
6
+ exports.atomsCount = atomsCount;
8
7
  const utils_1 = require("@mat3ra/utils");
9
8
  const underscore_string_1 = __importDefault(require("underscore.string"));
10
9
  const constrained_basis_1 = require("../basis/constrained_basis");
11
10
  const cell_1 = require("../cell/cell");
12
11
  const constants_1 = require("../constants");
13
12
  const lattice_1 = require("../lattice/lattice");
14
- const _print = (x, printFormat = "%14.9f") => underscore_string_1.default.sprintf(printFormat, math_1.math.precise(x));
13
+ const _print = (x, printFormat = "%14.9f") => underscore_string_1.default.sprintf(printFormat, utils_1.Utils.math.precise(x));
15
14
  const _latticeVectorsToString = (vectors) => vectors.map((v) => v.map((c) => _print(c)).join("\t")).join("\n");
16
15
  const atomicConstraintsCharFromBool = (bool) => (bool ? "T" : "F");
17
16
  /**
@@ -63,7 +62,6 @@ function atomsCount(poscarFileContent) {
63
62
  const atomsLine = lines[6].split(/\s+/);
64
63
  return atomsLine.map((x) => parseInt(x, 10)).reduce((a, b) => a + b);
65
64
  }
66
- exports.atomsCount = atomsCount;
67
65
  /**
68
66
  * Parses POSCAR file into a Material config object.
69
67
  * @param fileContent - POSCAR file content.
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validate = exports.XYZ_COORDINATE_PRECISION = void 0;
6
+ exports.XYZ_COORDINATE_PRECISION = void 0;
7
+ exports.validate = validate;
7
8
  const lodash_1 = require("lodash");
8
9
  const underscore_string_1 = __importDefault(require("underscore.string"));
9
10
  const constrained_basis_1 = require("../basis/constrained_basis");
@@ -43,7 +44,6 @@ function validate(xyzTxt) {
43
44
  .filter((x) => x.trim() !== "")
44
45
  .forEach(validateLine);
45
46
  }
46
- exports.validate = validate;
47
47
  /**
48
48
  * Parses XYZ line and returns an object.
49
49
  * @param line - line of text
@@ -1,3 +1,4 @@
1
+ import { BasisSchema } from "@mat3ra/esse/dist/js/types";
1
2
  import { ElementsAndCoordinatesConfig } from "../basis/basis";
2
3
  import { AtomicCoordinateValue } from "../basis/coordinates";
3
4
  import { AtomicElementValue } from "../basis/elements";
@@ -37,7 +38,7 @@ export declare class CombinatorialBasis {
37
38
  * @return {String[]}
38
39
  */
39
40
  get uniqueElements(): any[];
40
- static toBasisConfigForElementsAndCoordinates(array: ElementWithCoordinate[], units?: "crystal" | "cartesian" | undefined, cell?: Cell): ElementsAndCoordinatesConfig;
41
+ static toBasisConfigForElementsAndCoordinates(array: ElementWithCoordinate[], units?: BasisSchema["units"], cell?: Cell): ElementsAndCoordinatesConfig;
41
42
  /**
42
43
  * Returns array of regular bases extracted from current combinatorial basis.
43
44
  * @return {Basis[]|Object[]}