@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
@@ -15,16 +15,26 @@ 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.CombinatorialBasis = exports.WrongBasisFormat = void 0;
27
- const math_1 = require("@mat3ra/code/dist/js/math");
37
+ const utils_1 = require("@mat3ra/utils");
28
38
  const lodash_1 = require("lodash");
29
39
  const s = __importStar(require("underscore.string"));
30
40
  const cell_1 = require("../cell/cell");
@@ -199,7 +209,7 @@ class CombinatorialBasis {
199
209
  dimensions.push(itemsSet);
200
210
  });
201
211
  // @ts-ignore // We're multiplying objects with math, not numbers. No type casting will help.
202
- const basisSet = math_1.math.cartesianProduct.apply(null, dimensions);
212
+ const basisSet = utils_1.Utils.math.cartesianProduct.apply(null, dimensions);
203
213
  return basisSet.map((basis) => basis.filter((entry) => entry.element !== VACANCY_CHARACTER));
204
214
  }
205
215
  /**
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const math_1 = require("@mat3ra/code/dist/js/math");
3
+ const utils_1 = require("@mat3ra/utils");
4
4
  const lodash_1 = require("lodash");
5
5
  const coordinates_1 = require("../basis/coordinates");
6
- const ADD = math_1.math.add;
7
- const MULT = math_1.math.multiply;
6
+ const ADD = utils_1.Utils.math.add;
7
+ const MULT = utils_1.Utils.math.multiply;
8
8
  /**
9
9
  * Returns a repeated basis of a crystal.
10
10
  * @param basis {Basis} Original basis.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const math_1 = require("@mat3ra/code/dist/js/math");
3
+ const utils_1 = require("@mat3ra/utils");
4
4
  const cell_1 = require("../cell/cell");
5
5
  /**
6
6
  * Returns the list of points on the original lattice contained in the supercell in fractional coordinates.
@@ -19,8 +19,8 @@ function latticePointsInSupercell(supercellMatrix) {
19
19
  [1, 1, 1],
20
20
  ];
21
21
  const d_points = diagonals.map((point) => supercell.convertPointToCartesian(point));
22
- const mins = [0, 1, 2].map((i) => math_1.math.min(...d_points.map((p) => p[i])));
23
- const maxes = [0, 1, 2].map((i) => math_1.math.max(...d_points.map((p) => p[i])) + 1);
22
+ const mins = [0, 1, 2].map((i) => utils_1.Utils.math.min(...d_points.map((p) => p[i])));
23
+ const maxes = [0, 1, 2].map((i) => utils_1.Utils.math.max(...d_points.map((p) => p[i])) + 1);
24
24
  const points = [];
25
25
  for (let i = mins[0]; i <= maxes[0]; i++) {
26
26
  for (let j = mins[1]; j <= maxes[1]; j++) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const math_1 = require("@mat3ra/code/dist/js/math");
3
+ const utils_1 = require("@mat3ra/utils");
4
4
  const constants_1 = require("../constants");
5
5
  const lattice_1 = require("../lattice/lattice");
6
6
  /**
@@ -38,8 +38,8 @@ function translateAtomsToCenter(material) {
38
38
  material.toCartesian();
39
39
  const updatedBasis = material.Basis;
40
40
  const centerOfCoordinates = updatedBasis.centerOfCoordinatesPoint;
41
- const centerOfLattice = math_1.math.multiply(0.5, material.Lattice.vectorArrays.reduce((a, b) => math_1.math.add(a, b)));
42
- const translationVector = math_1.math.subtract(centerOfLattice, centerOfCoordinates);
41
+ const centerOfLattice = utils_1.Utils.math.multiply(0.5, material.Lattice.vectorArrays.reduce((a, b) => utils_1.Utils.math.add(a, b)));
42
+ const translationVector = utils_1.Utils.math.subtract(centerOfLattice, centerOfCoordinates);
43
43
  updatedBasis.translateByVector(translationVector);
44
44
  material.setBasis(updatedBasis.toJSON());
45
45
  if (originalUnits !== constants_1.ATOMIC_COORD_UNITS.cartesian)
@@ -3,10 +3,10 @@ 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
- const math_1 = require("@mat3ra/code/dist/js/math");
6
+ const utils_1 = require("@mat3ra/utils");
7
7
  const lattice_1 = require("../lattice/lattice");
8
8
  const cell_1 = __importDefault(require("./cell"));
9
- const ADD = math_1.math.add;
9
+ const ADD = utils_1.Utils.math.add;
10
10
  /**
11
11
  * @summary Generates new basis for a supercell. For each site from basis generates shifts that are within supercell.
12
12
  */
@@ -39,7 +39,7 @@ function generateNewBasisWithinSupercell(basis, cell, supercell, supercellMatrix
39
39
  * @param supercellMatrix {Number[][]}
40
40
  */
41
41
  function generateConfig(material, supercellMatrix) {
42
- const det = math_1.math.det(supercellMatrix);
42
+ const det = utils_1.Utils.math.det(supercellMatrix);
43
43
  if (det === 0) {
44
44
  throw new Error("Scaling matrix is degenerate.");
45
45
  }
@@ -3,14 +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
- const math_1 = require("@mat3ra/code/dist/js/math");
6
+ const utils_1 = require("@mat3ra/utils");
7
7
  const lattice_1 = require("../lattice/lattice");
8
8
  const supercell_1 = __importDefault(require("./supercell"));
9
- const MULT = math_1.math.multiply;
10
- const ADD = math_1.math.add;
11
- const DOT = math_1.math.product;
9
+ const MULT = utils_1.Utils.math.multiply;
10
+ const ADD = utils_1.Utils.math.add;
11
+ const DOT = utils_1.Utils.math.product;
12
12
  const getMatrixInLeftHandedRepresentation = (matrix) => {
13
- return math_1.math.det(matrix) < 0 ? MULT(matrix, -1) : matrix;
13
+ return utils_1.Utils.math.det(matrix) < 0 ? MULT(matrix, -1) : matrix;
14
14
  };
15
15
  /**
16
16
  * Helper function for extended GCD.
@@ -22,10 +22,10 @@ const getMatrixInLeftHandedRepresentation = (matrix) => {
22
22
  function extGCD(a, b) {
23
23
  if (b === 0)
24
24
  return [1, 0];
25
- if (math_1.math.mod(a, b) === 0)
25
+ if (utils_1.Utils.math.mod(a, b) === 0)
26
26
  return [0, 1];
27
- const [x, y] = extGCD(b, math_1.math.mod(a, b));
28
- return [y, x - y * math_1.math.floor(a / b)];
27
+ const [x, y] = extGCD(b, utils_1.Utils.math.mod(a, b));
28
+ return [y, x - y * utils_1.Utils.math.floor(a / b)];
29
29
  }
30
30
  /**
31
31
  * Generates a slab scaling matrix for the specified cell based on miller indices.
@@ -36,7 +36,7 @@ function extGCD(a, b) {
36
36
  * @return {Number[][]}
37
37
  */
38
38
  function getMillerScalingMatrix(cell, millerIndices, tol = 1e-8) {
39
- if (!millerIndices.reduce((a, b) => math_1.math.abs(a) + math_1.math.abs(b)))
39
+ if (!millerIndices.reduce((a, b) => utils_1.Utils.math.abs(a) + utils_1.Utils.math.abs(b)))
40
40
  throw new Error("Miller indices are zeros.");
41
41
  let scalingMatrix;
42
42
  const [h, k, l] = millerIndices;
@@ -78,19 +78,21 @@ function getMillerScalingMatrix(cell, millerIndices, tol = 1e-8) {
78
78
  const k1 = DOT(ADD(MULT(p, z1), MULT(q, z2)), z3);
79
79
  // @ts-ignore
80
80
  const k2 = DOT(ADD(MULT(l, z1), -MULT(k, z2)), z3);
81
- if (math_1.math.abs(k2) > tol) {
81
+ // @ts-ignore
82
+ if (utils_1.Utils.math.abs(k2) > tol) {
82
83
  // For mathjs version 3.20: round(-0.5) = -0
83
84
  // For mathjs version 5.10: round(-0.5) = -1
84
85
  // Here we specify rounding method to Bankers
85
86
  // For Python 3.11: round(-0.5) = 0
87
+ // @ts-ignore - mathjs v12 dot return type
86
88
  const value = k1 / k2;
87
- const roundedValue = math_1.math.roundCustom(value, 0, math_1.math.RoundingMethod.Bankers);
89
+ const roundedValue = utils_1.Utils.math.roundCustom(value, 0, utils_1.Utils.math.RoundingMethod.Bankers);
88
90
  const i = -roundedValue;
89
91
  [p, q] = [p + i * l, q - i * k];
90
92
  }
91
93
  const [a, b] = extGCD(p * k + q * l, h);
92
94
  const c1 = [p * k + q * l, -p * h, -q * h];
93
- const c2 = [0, l, -k].map((c) => math_1.math.trunc(c / math_1.math.gcd(l, k))); // floor division
95
+ const c2 = [0, l, -k].map((c) => utils_1.Utils.math.trunc(c / utils_1.Utils.math.gcd(l, k))); // floor division
94
96
  const c3 = [b, a * p, a * q];
95
97
  scalingMatrix = [c1, c2, c3];
96
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mat3ra/made",
3
- "version": "2026.6.29-0",
3
+ "version": "2026.7.8-0",
4
4
  "description": "MAterials DEsign library",
5
5
  "scripts": {
6
6
  "lint": "eslint --cache src/js tests/js && prettier --write src/js tests/js",
@@ -14,68 +14,69 @@
14
14
  },
15
15
  "repository": {
16
16
  "type": "git",
17
- "url": "https://github.com/Exabyte-io/made.git"
17
+ "url": "https://github.com/mat3ra/made.git"
18
18
  },
19
19
  "main": "dist/js/made.js",
20
20
  "author": "Exabyte Inc.",
21
21
  "bugs": {
22
- "url": "https://github.com/Exabyte-io/made/issues"
22
+ "url": "https://github.com/mat3ra/made/issues"
23
23
  },
24
24
  "license": "Apache-2.0",
25
- "homepage": "https://github.com/Exabyte-io/made",
25
+ "homepage": "https://github.com/mat3ra/made",
26
26
  "engines": {
27
27
  "node": ">=0.14"
28
28
  },
29
29
  "devDependencies": {
30
- "@babel/eslint-parser": "^7.16.3",
31
- "@babel/plugin-proposal-class-properties": "^7.16.0",
32
- "@babel/preset-env": "^7.16.4",
33
- "@babel/preset-react": "^7.16.7",
34
- "@babel/register": "^7.22.15",
35
- "@babel/runtime-corejs3": "^7.16.8",
36
- "@exabyte-io/eslint-config": "2025.5.13-0",
37
- "@mat3ra/code": "2026.5.27-0",
38
- "@mat3ra/esse": "2026.5.27-0",
39
- "@mat3ra/tsconfig": "2024.6.3-0",
40
- "@mat3ra/utils": "^2026.6.11-0",
30
+ "@babel/eslint-parser": "^7.29.7",
31
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
32
+ "@babel/preset-env": "^7.29.7",
33
+ "@babel/preset-react": "^7.29.7",
34
+ "@babel/register": "^7.29.7",
35
+ "@babel/runtime-corejs3": "^7.29.7",
36
+ "@exabyte-io/eslint-config": "^2026.7.3-0",
37
+ "@mat3ra/code": "^2026.5.27-0",
38
+ "@mat3ra/esse": "^2026.6.30-0",
39
+ "@mat3ra/tsconfig": "^2024.6.3-0",
40
+ "@mat3ra/utils": "^2026.7.8-0",
41
+ "@mat3ra/standata": "2026.6.30-0",
41
42
  "@types/crypto-js": "^4.2.2",
42
- "@typescript-eslint/eslint-plugin": "^5.9.1",
43
- "@typescript-eslint/parser": "^5.9.1",
44
- "chai": "^4.3.4",
43
+ "@typescript-eslint/eslint-plugin": "^5.62.0",
44
+ "@typescript-eslint/parser": "^5.62.0",
45
+ "chai": "^4.5.0",
45
46
  "chai-almost": "^1.0.1",
46
47
  "eslint": "^7.32.0",
47
- "eslint-config-airbnb": "^19.0.2",
48
- "eslint-config-prettier": "^8.5.0",
48
+ "eslint-config-airbnb": "^19.0.4",
49
+ "eslint-config-prettier": "^8.10.2",
49
50
  "eslint-import-resolver-exports": "^1.0.0-beta.5",
50
51
  "eslint-import-resolver-meteor": "^0.4.0",
51
- "eslint-import-resolver-node": "^0.3.9",
52
- "eslint-plugin-import": "^2.25.3",
53
- "eslint-plugin-jsdoc": "^37.1.0",
54
- "eslint-plugin-jsx-a11y": "^6.5.1",
52
+ "eslint-import-resolver-node": "^0.3.10",
53
+ "eslint-plugin-import": "^2.32.0",
54
+ "eslint-plugin-jsdoc": "^37.9.7",
55
+ "eslint-plugin-jsx-a11y": "^6.10.2",
55
56
  "eslint-plugin-mui-path-imports": "0.0.15",
56
- "eslint-plugin-prettier": "^4.2.1",
57
- "eslint-plugin-react": "^7.30.0",
57
+ "eslint-plugin-prettier": "^4.2.5",
58
+ "eslint-plugin-react": "^7.37.5",
58
59
  "eslint-plugin-simple-import-sort": "^7.0.0",
59
60
  "husky": "^7.0.4",
60
- "lint-staged": "^12.1.2",
61
- "mocha": "10.3.0",
62
- "prettier": "^2.5.1",
61
+ "lint-staged": "^12.5.0",
62
+ "mocha": "10.8.2",
63
+ "prettier": "^2.8.8",
63
64
  "nyc": "^15.1.0"
64
65
  },
65
66
  "dependencies": {
66
- "@babel/core": "7.24.1",
67
- "@exabyte-io/periodic-table.js": "2022.5.28-0",
68
- "@types/chai": "^4.3.5",
67
+ "@babel/core": "^7.29.7",
68
+ "@exabyte-io/periodic-table.js": "^2023.12.23-3",
69
+ "@types/chai": "^4.3.20",
69
70
  "@types/chai-almost": "^1.0.3",
70
- "@types/mocha": "^10.0.1",
71
- "@types/node": "^20.4.2",
72
- "@types/underscore.string": "^0.0.40",
71
+ "@types/mocha": "^10.0.10",
72
+ "@types/node": "^20.19.43",
73
+ "@types/underscore.string": "^0.0.42",
73
74
  "array-almost-equal": "^1.0.0",
74
- "crypto-js": "4.2.0",
75
- "lodash": "^4.17.*",
76
- "ts-node": "^10.9.1",
77
- "typescript": "^4.5.5",
78
- "underscore.string": "^3.3.4"
75
+ "crypto-js": "^4.2.0",
76
+ "lodash": "^4.18.*",
77
+ "ts-node": "^10.9.2",
78
+ "typescript": "^5.9.3",
79
+ "underscore.string": "^3.3.6"
79
80
  },
80
81
  "peerDependencies": {
81
82
  "@mat3ra/code": "*",
package/pyproject.toml CHANGED
@@ -3,7 +3,7 @@ name = "mat3ra-made"
3
3
  dynamic = ["version"]
4
4
  description = "MAterials DEfinitions and/or MAterials DEsign library."
5
5
  readme = "README.md"
6
- requires-python = ">=3.8"
6
+ requires-python = ">=3.10"
7
7
  license = {file = "LICENSE.md"}
8
8
  authors = [
9
9
  { name = "Exabyte Inc.", email = "info@mat3ra.com" }
@@ -15,12 +15,11 @@ classifiers = [
15
15
  "Topic :: Software Development",
16
16
  ]
17
17
  dependencies = [
18
- # add requirements here
18
+ "mat3ra-code",
19
+ "mat3ra-esse>=2026.6.30.post0",
20
+ "mat3ra-utils>=2026.7.3.post0",
19
21
  # new verison of numpy==2.0.0 is not handled by pymatgen yet
20
22
  "numpy<=1.26.4",
21
- "mat3ra-utils",
22
- "mat3ra-esse",
23
- "mat3ra-code"
24
23
  ]
25
24
 
26
25
  [project.optional-dependencies]
@@ -81,7 +80,7 @@ where = ["src/py"]
81
80
 
82
81
  [tool.black]
83
82
  line-length = 120
84
- target-version = ['py38']
83
+ target-version = ['py310']
85
84
  # 'extend-exclude' excludes files or directories in addition to the defaults
86
85
  extend-exclude = '''
87
86
  (
@@ -99,7 +98,7 @@ extend-exclude = [
99
98
  "tests/py/unit/fixtures"
100
99
  ]
101
100
  line-length = 120
102
- target-version = "py38"
101
+ target-version = "py310"
103
102
 
104
103
  [tool.ruff.per-file-ignores]
105
104
  "__init__.py" = ["F401"]
@@ -1,12 +1,13 @@
1
1
  // @ts-ignore
2
2
  import { getElectronegativity, getElementAtomicRadius } from "@exabyte-io/periodic-table.js";
3
3
  import { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
4
- import { math } from "@mat3ra/code/dist/js/math";
5
4
  import { BasisSchema, Coordinate3DSchema, Vector3DSchema } from "@mat3ra/esse/dist/js/types";
5
+ import { Utils } from "@mat3ra/utils";
6
6
  import { chain, toPairs, uniq, values } from "lodash";
7
7
 
8
8
  import { Cell } from "../cell/cell";
9
9
  import { ATOMIC_COORD_UNITS, HASH_TOLERANCE } from "../constants";
10
+
10
11
  import {
11
12
  defaultNonPeriodicMinimumLatticeSize,
12
13
  diatomicLatticePaddingFactor,
@@ -247,7 +248,7 @@ export class Basis extends InMemoryEntity implements BasisSchema {
247
248
  toStandardRepresentation() {
248
249
  this.toCrystal();
249
250
  this._coordinates.mapArrayInPlace(
250
- (point) => point.map((x) => math.mod(x)) as Coordinate3DSchema,
251
+ (point) => point.map((x) => Utils.math.mod(x)) as Coordinate3DSchema,
251
252
  );
252
253
  }
253
254
 
@@ -330,7 +331,7 @@ export class Basis extends InMemoryEntity implements BasisSchema {
330
331
  get formula(): string {
331
332
  const counts = this.uniqueElementCountsSortedByElectronegativity;
332
333
  const countsValues = values(counts);
333
- const gcd = countsValues.length > 1 ? math.gcd(...countsValues) : countsValues[0];
334
+ const gcd = countsValues.length > 1 ? Utils.math.gcd(...countsValues) : countsValues[0];
334
335
 
335
336
  return toPairs(counts)
336
337
  .map(([element, count]) => element + (count / gcd === 1 ? "" : count / gcd))
@@ -392,7 +393,7 @@ export class Basis extends InMemoryEntity implements BasisSchema {
392
393
  const element = entry[0];
393
394
  const coordinate = entry[1];
394
395
  const atomicLabel = entry[2];
395
- const toleratedCoordinate = coordinate.map((x) => math.round(x, HASH_TOLERANCE));
396
+ const toleratedCoordinate = coordinate.map((x) => Utils.math.roundCustom(x, HASH_TOLERANCE));
396
397
  return `${element}${atomicLabel} ${toleratedCoordinate.join()}`;
397
398
  });
398
399
  return `${standardRep.sort().join(";")};`;
@@ -471,7 +472,7 @@ export class Basis extends InMemoryEntity implements BasisSchema {
471
472
  hasEquivalentCellTo(anotherBasisClsInstance: Basis): boolean {
472
473
  return !this.cell.vectorArrays
473
474
  .map((vector, idx) => {
474
- return math.vEqualWithTolerance(
475
+ return Utils.math.vEqualWithTolerance(
475
476
  vector,
476
477
  anotherBasisClsInstance.cell.vectorArrays[idx],
477
478
  );
@@ -496,7 +497,7 @@ export class Basis extends InMemoryEntity implements BasisSchema {
496
497
  const maxDistance = this.maxPairwiseDistance;
497
498
  const minDistance = this.minPairwiseDistance;
498
499
  const widthRatio = maxDistance > 0 ? minDistance / maxDistance : 1;
499
- const latticeScalingFactor = math.almostEqual(widthRatio, 1)
500
+ const latticeScalingFactor = Utils.math.almostEqual(widthRatio, 1)
500
501
  ? diatomicLatticePaddingFactor
501
502
  : molecularLatticePaddingFactor;
502
503
  const moleculeLatticeSize = maxDistance * latticeScalingFactor;
@@ -525,7 +526,7 @@ export class Basis extends InMemoryEntity implements BasisSchema {
525
526
  (getElementAtomicRadius(el1) + getElementAtomicRadius(el2)); // in angstroms
526
527
 
527
528
  // @ts-ignore
528
- const distance = math.vDist(entry1.value, entry2.value) as number;
529
+ const distance = Utils.math.vDist(entry1.value, entry2.value) as number;
529
530
  if (distance < tolerance) {
530
531
  overlaps.push({
531
532
  id1: i,
@@ -571,7 +572,7 @@ export class Basis extends InMemoryEntity implements BasisSchema {
571
572
  if (this._elements.values.length >= 2) {
572
573
  for (let i = 0; i < this._elements.values.length; i++) {
573
574
  for (let j = i + 1; j < this._elements.values.length; j++) {
574
- const distance = math.vDist(
575
+ const distance = Utils.math.vDist(
575
576
  this._coordinates.getElementValueByIndex(i) as Coordinate3DSchema,
576
577
  this._coordinates.getElementValueByIndex(j) as Coordinate3DSchema,
577
578
  );
@@ -1,13 +1,14 @@
1
1
  import { RoundedArrayWithIds, RoundedValueWithId, RoundedVector3D, Vector3D } from "@mat3ra/code";
2
- import { math } from "@mat3ra/code/dist/js/math";
3
2
  import {
4
3
  AtomicCoordinateSchema,
5
4
  Coordinate3DSchema,
6
5
  Matrix3X3Schema,
7
6
  Vector3DSchema,
8
7
  } from "@mat3ra/esse/dist/js/types";
8
+ import { Utils } from "@mat3ra/utils";
9
9
  import { sprintf } from "underscore.string";
10
10
 
11
+
11
12
  export type AtomicCoordinateValue = AtomicCoordinateSchema["value"];
12
13
 
13
14
  type AxisType = "x" | "y" | "z";
@@ -78,7 +79,7 @@ export class Coordinates extends RoundedArrayWithIds<Coordinate3DSchema> {
78
79
  }
79
80
 
80
81
  getCenterPoint(): Vector3DSchema {
81
- const transposed = math.transpose(this.values) as Matrix3X3Schema;
82
+ const transposed = Utils.math.transpose(this.values) as Matrix3X3Schema;
82
83
  const center: Vector3DSchema = [0, 0, 0];
83
84
 
84
85
  for (let i = 0; i < 3; i++) {
@@ -1,17 +1,18 @@
1
1
  import { RoundedVector3D } from "@mat3ra/code";
2
- import { math } from "@mat3ra/code/dist/js/math";
3
2
  import {
4
3
  Coordinate3DSchema,
5
4
  LatticeVectorsSchema as CellSchema,
6
5
  Matrix3X3Schema,
7
6
  Vector3DSchema,
8
7
  } from "@mat3ra/esse/dist/js/types";
8
+ import { Utils } from "@mat3ra/utils";
9
9
 
10
10
  import constants from "../constants";
11
11
 
12
- const MATRIX = math.matrix;
13
- const MULT = math.multiply;
14
- const INV = math.inv;
12
+
13
+ const MATRIX = Utils.math.matrix;
14
+ const MULT = Utils.math.multiply;
15
+ const INV = Utils.math.inv;
15
16
  // @ts-ignore
16
17
  const MATRIX_MULT = (...args) => MULT(...args.map((x) => MATRIX(x))).toArray();
17
18
 
@@ -74,11 +75,11 @@ export class Cell implements CellSchema {
74
75
  }
75
76
 
76
77
  get volume(): number {
77
- return math.det(this.vectorArrays);
78
+ return Utils.math.det(this.vectorArrays);
78
79
  }
79
80
 
80
81
  get volumeRounded(): number {
81
- return math.roundArrayOrNumber(this.volume, Cell.roundPrecision) as number;
82
+ return Utils.math.roundArrayOrNumber(this.volume, Cell.roundPrecision) as number;
82
83
  }
83
84
 
84
85
  clone(): Cell {
@@ -103,7 +104,7 @@ export class Cell implements CellSchema {
103
104
  const { tolerance } = this.constructor as typeof Cell;
104
105
  return (
105
106
  this.convertPointToCrystal(point)
106
- .map((c: number) => math.isBetweenZeroInclusiveAndOne(c, tolerance))
107
+ .map((c: number) => Utils.math.isBetweenZeroInclusiveAndOne(c, tolerance))
107
108
  // @ts-ignore
108
109
  .reduce((a: boolean, b: boolean): boolean => a && b)
109
110
  );
@@ -114,7 +115,7 @@ export class Cell implements CellSchema {
114
115
  const { tolerance } = this.constructor as typeof Cell;
115
116
  return (
116
117
  point
117
- .map((c: number) => math.isBetweenZeroInclusiveAndOne(c, tolerance))
118
+ .map((c: number) => Utils.math.isBetweenZeroInclusiveAndOne(c, tolerance))
118
119
  // @ts-ignore
119
120
  .reduce((a: boolean, b: boolean): boolean => a && b)
120
121
  );
@@ -128,11 +129,12 @@ export class Cell implements CellSchema {
128
129
  }
129
130
 
130
131
  getMostCollinearVectorIndex(testVector: Vector3DSchema): number {
131
- const angles = this.vectorArrays.map((v) => math.angleUpTo90(v, testVector, "deg"));
132
- return angles.findIndex((el: number) => el === math.min(angles));
132
+ const angles = this.vectorArrays.map((v) => Utils.math.angleUpTo90(v, testVector, "deg"));
133
+ return angles.findIndex((el: number) => el === Utils.math.min(angles));
133
134
  }
134
135
 
135
136
  scaleByMatrix(matrix: number[][]) {
137
+ // @ts-ignore - mathjs v12 multiply return type is broader than runtime
136
138
  [this.a, this.b, this.c] = MATRIX_MULT(matrix, this.vectorArrays);
137
139
  }
138
140
 
@@ -1,5 +1,5 @@
1
- import { math } from "@mat3ra/code/dist/js/math";
2
1
  import { LatticeSchema, Matrix3X3Schema } from "@mat3ra/esse/dist/js/types";
2
+ import { Utils } from "@mat3ra/utils";
3
3
 
4
4
  /**
5
5
  * Routines for calculating primitive cell vectors from conventional cell Bravais parameters.
@@ -80,42 +80,45 @@ const PRIMITIVE_CELLS = {
80
80
 
81
81
  HEX: ({ a, c }: LatticeSchema): Matrix3X3Schema => {
82
82
  return [
83
- [a / 2, (-a * math.sqrt(3)) / 2, 0],
84
- [a / 2, (a * math.sqrt(3)) / 2, 0],
83
+ [a / 2, (-a * Number(Utils.math.sqrt(3))) / 2, 0],
84
+ [a / 2, (a * Number(Utils.math.sqrt(3))) / 2, 0],
85
85
  [0, 0, c],
86
86
  ];
87
87
  },
88
88
 
89
89
  RHL: ({ a, alpha }: LatticeSchema): Matrix3X3Schema => {
90
- const cosAlpha = math.cos((alpha / 180) * math.PI);
91
- const cosHalfAlpha = math.sqrt((1 / 2) * (1 + cosAlpha));
92
- const sinHalfAlpha = math.sqrt((1 / 2) * (1 - cosAlpha));
90
+ const cosAlpha = Number(Utils.math.cos((alpha / 180) * Number(Utils.math.PI)));
91
+ const cosHalfAlpha = Number(Utils.math.sqrt((1 / 2) * (1 + cosAlpha)));
92
+ const sinHalfAlpha = Number(Utils.math.sqrt((1 / 2) * (1 - cosAlpha)));
93
93
  return [
94
94
  [a * cosHalfAlpha, -a * sinHalfAlpha, 0.0],
95
95
  [a * cosHalfAlpha, a * sinHalfAlpha, 0.0],
96
96
  [
97
97
  (a * cosAlpha) / cosHalfAlpha,
98
98
  0.0,
99
- a * math.sqrt(1 - (cosAlpha * cosAlpha) / (cosHalfAlpha * cosHalfAlpha)),
99
+ a *
100
+ Number(
101
+ Utils.math.sqrt(1 - (cosAlpha * cosAlpha) / (cosHalfAlpha * cosHalfAlpha)),
102
+ ),
100
103
  ],
101
104
  ];
102
105
  },
103
106
 
104
107
  MCL: ({ a, b, c, alpha }: LatticeSchema): Matrix3X3Schema => {
105
- const cosAlpha = math.cos((alpha / 180) * math.PI);
108
+ const cosAlpha = Number(Utils.math.cos((alpha / 180) * Number(Utils.math.PI)));
106
109
  return [
107
110
  [a, 0, 0],
108
111
  [0, b, 0],
109
- [0, c * cosAlpha, c * math.sqrt(1 - cosAlpha * cosAlpha)],
112
+ [0, c * cosAlpha, c * Number(Utils.math.sqrt(1 - cosAlpha * cosAlpha))],
110
113
  ];
111
114
  },
112
115
 
113
116
  MCLC: ({ a, b, c, alpha }: LatticeSchema): Matrix3X3Schema => {
114
- const cosAlpha = math.cos((alpha / 180) * math.PI);
117
+ const cosAlpha = Number(Utils.math.cos((alpha / 180) * Number(Utils.math.PI)));
115
118
  return [
116
119
  [a / 2, b / 2, 0],
117
120
  [-a / 2, b / 2, 0],
118
- [0, c * cosAlpha, c * math.sqrt(1 - cosAlpha * cosAlpha)],
121
+ [0, c * cosAlpha, c * Number(Utils.math.sqrt(1 - cosAlpha * cosAlpha))],
119
122
  ];
120
123
  },
121
124
 
@@ -123,22 +126,23 @@ const PRIMITIVE_CELLS = {
123
126
  TRI: ({ a, b, c, alpha, beta, gamma }: LatticeSchema): Matrix3X3Schema => {
124
127
  // convert angles to Radians
125
128
  // eslint-disable-next-line no-param-reassign
126
- [alpha, beta, gamma] = [alpha, beta, gamma].map(
127
- // @ts-ignore
128
- (x) => math.unit(x, "degree").to("rad").value,
129
+ [alpha, beta, gamma] = [alpha, beta, gamma].map((x) =>
130
+ Number(Utils.math.unit(x, "degree").to("rad").value),
129
131
  );
130
132
 
131
- const [cosAlpha, cosBeta, cosGamma] = [alpha, beta, gamma].map((x) => math.cos(x));
132
- const [sinAlpha, sinBeta] = [alpha, beta].map((x) => math.sin(x));
133
+ const [cosAlpha, cosBeta, cosGamma] = [alpha, beta, gamma].map((x) =>
134
+ Number(Utils.math.cos(x)),
135
+ );
136
+ const [sinAlpha, sinBeta] = [alpha, beta].map((x) => Number(Utils.math.sin(x)));
133
137
  let acosArg = (cosAlpha * cosBeta - cosGamma) / (sinAlpha * sinBeta);
134
138
  if (acosArg < -1) {
135
139
  acosArg = -1;
136
140
  } else if (acosArg > 1) {
137
141
  acosArg = 1;
138
142
  }
139
- const gammaStar = math.acos(acosArg);
140
- const cosGammaStar = math.cos(gammaStar);
141
- const sinGammaStar = math.sin(gammaStar);
143
+ const gammaStar = Number(Utils.math.acos(acosArg));
144
+ const cosGammaStar = Number(Utils.math.cos(gammaStar));
145
+ const sinGammaStar = Number(Utils.math.sin(gammaStar));
142
146
 
143
147
  return [
144
148
  [a * sinBeta, 0.0, a * cosBeta],