@mat3ra/made 2026.8.7-0 → 2026.8.13-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 (66) hide show
  1. package/.mocharc.json +2 -2
  2. package/dist/js/Material.d.ts +219 -0
  3. package/dist/js/Material.js +457 -0
  4. package/dist/js/basis/basis.d.ts +14 -9
  5. package/dist/js/basis/basis.js +15 -13
  6. package/dist/js/basis/constrained_basis.d.ts +9 -7
  7. package/dist/js/basis/constrained_basis.js +4 -4
  8. package/dist/js/generated/MaterialSchemaMixin.d.ts +5 -0
  9. package/dist/js/generated/MaterialSchemaMixin.js +69 -0
  10. package/dist/js/lattice/lattice.d.ts +4 -3
  11. package/dist/js/lattice/lattice.js +1 -2
  12. package/dist/js/made.d.ts +12 -12
  13. package/dist/js/made.js +38 -5
  14. package/dist/js/parsers/espresso.d.ts +2 -3
  15. package/dist/js/parsers/espresso.js +0 -1
  16. package/dist/js/parsers/native_format_parsers.d.ts +9 -8
  17. package/dist/js/parsers/native_format_parsers.js +6 -6
  18. package/dist/js/parsers/parsers.d.ts +6 -6
  19. package/dist/js/parsers/poscar.d.ts +5 -4
  20. package/dist/js/parsers/poscar.js +3 -2
  21. package/dist/js/parsers/xyz.d.ts +3 -5
  22. package/dist/js/parsers/xyz.js +3 -4
  23. package/dist/js/parsers/xyz_combinatorial_basis.js +3 -1
  24. package/dist/js/tools/basis.d.ts +1 -1
  25. package/dist/js/tools/index.d.ts +7 -7
  26. package/dist/js/tools/material.d.ts +1 -1
  27. package/dist/js/tools/material.js +8 -7
  28. package/dist/js/tools/supercell.d.ts +4 -5
  29. package/dist/js/tools/supercell.js +2 -4
  30. package/dist/js/tools/surface.d.ts +4 -4
  31. package/dist/js/tools/surface.js +2 -7
  32. package/package.json +6 -6
  33. package/scripts/generate-mixins.ts +28 -0
  34. package/src/js/Material.ts +618 -0
  35. package/src/js/basis/basis.ts +38 -25
  36. package/src/js/basis/constrained_basis.ts +12 -11
  37. package/src/js/basis/coordinates.ts +0 -1
  38. package/src/js/cell/cell.ts +0 -1
  39. package/src/js/generated/MaterialSchemaMixin.ts +79 -0
  40. package/src/js/lattice/lattice.ts +6 -4
  41. package/src/js/lattice/reciprocal/lattice_reciprocal.ts +19 -6
  42. package/src/js/made.ts +1 -1
  43. package/src/js/parsers/espresso.ts +2 -3
  44. package/src/js/parsers/native_format_parsers.ts +9 -8
  45. package/src/js/parsers/poscar.ts +12 -6
  46. package/src/js/parsers/xyz.ts +9 -6
  47. package/src/js/parsers/xyz_combinatorial_basis.ts +5 -2
  48. package/src/js/tools/basis.ts +0 -1
  49. package/src/js/tools/cell.ts +0 -1
  50. package/src/js/tools/material.ts +13 -11
  51. package/src/js/tools/supercell.ts +8 -7
  52. package/src/js/tools/surface.ts +7 -17
  53. package/src/py/mat3ra/made/material.py +6 -5
  54. package/tests/fixtures/si-standata.json +2 -2
  55. package/tests/js/basis/basis.ts +8 -8
  56. package/tests/js/fixtures.ts +12 -9
  57. package/tests/js/material/material.ts +161 -0
  58. package/tests/js/parsers/espresso.ts +2 -5
  59. package/tests/js/parsers/poscar.ts +2 -2
  60. package/tests/js/register-esse-schemas.cjs +10 -0
  61. package/tests/js/tools/supercell.ts +2 -2
  62. package/tests/js/tools/surface.ts +6 -10
  63. package/dist/js/material.d.ts +0 -169
  64. package/dist/js/material.js +0 -362
  65. package/src/js/material.ts +0 -458
  66. package/tests/js/material.test.ts +0 -42
@@ -132,16 +132,15 @@ function fromBasis(basisClsInstance, coordinatePrintFormat) {
132
132
  }
133
133
  /**
134
134
  * Create XYZ from Material class instance (or its JSON config).
135
- * @param materialOrConfig Material.
136
- * @param fractional Coordinate units as fractional.
137
- * @return Class Instance
135
+ * Prefer fromBasis when you already have a ConstrainedBasis instance.
138
136
  */
139
137
  function fromMaterial(materialOrConfig, fractional = false) {
140
138
  const lattice = new lattice_1.Lattice(materialOrConfig.lattice);
141
- // @ts-ignore
139
+ const constraints = "constraints" in materialOrConfig.basis ? materialOrConfig.basis.constraints : [];
142
140
  const basis = new constrained_basis_1.ConstrainedBasis({
143
141
  ...materialOrConfig.basis,
144
142
  cell: cell_1.Cell.fromVectorsArray(lattice.vectorArrays),
143
+ constraints,
145
144
  });
146
145
  if (fractional) {
147
146
  basis.toCrystal();
@@ -209,7 +209,9 @@ class CombinatorialBasis {
209
209
  dimensions.push(itemsSet);
210
210
  });
211
211
  // @ts-ignore // We're multiplying objects with math, not numbers. No type casting will help.
212
- const basisSet = utils_1.Utils.math.cartesianProduct.apply(null, dimensions);
212
+ const basisSet = utils_1.Utils.math.cartesianProduct.apply(null,
213
+ // @ts-ignore
214
+ dimensions);
213
215
  return basisSet.map((basis) => basis.filter((entry) => entry.element !== VACANCY_CHARACTER));
214
216
  }
215
217
  /**
@@ -14,7 +14,7 @@ declare function repeat(basis: Basis, repetitions: number[]): Basis;
14
14
  * @param numberOfSteps{Number} Number of intermediate steps.
15
15
  * @return {Basis[]} List of all bases.
16
16
  */
17
- declare function interpolate(initialBasis: Basis, finalBasis: Basis, numberOfSteps?: number): Basis[];
17
+ declare function interpolate(initialBasis: Basis, finalBasis: Basis, numberOfSteps?: number): Basis<import("../basis/basis").BasisConfig>[];
18
18
  declare const _default: {
19
19
  repeat: typeof repeat;
20
20
  interpolate: typeof interpolate;
@@ -1,23 +1,23 @@
1
1
  declare const _default: {
2
2
  surface: {
3
- generateConfig: (material: import("../material").Material, millerIndices: import("@mat3ra/esse/dist/js/types").Coordinate3DSchema, numberOfLayers?: number, vx?: number, vy?: number) => import("./surface").SlabConfigSchema;
3
+ generateConfig: <Schemas extends import("../Material").MaterialSchemaMap = import("../Material").MaterialSchemaMap>(material: import("../Material").default<Schemas>, millerIndices: import("@mat3ra/esse/dist/js/types").Coordinate3DSchema, numberOfLayers?: number, vx?: number, vy?: number) => import("./surface").SlabConfigSchema;
4
4
  };
5
5
  supercell: {
6
- generateConfig: (material: import("../material").Material, supercellMatrix: import("@mat3ra/esse/dist/js/types").Matrix3X3Schema) => {
6
+ generateConfig: <Schemas extends import("../Material").MaterialSchemaMap = import("../Material").MaterialSchemaMap>(material: import("../Material").default<Schemas>, supercellMatrix: import("@mat3ra/esse/dist/js/types").Matrix3X3Schema) => {
7
7
  name: string;
8
- basis: import("@mat3ra/esse/dist/js/types").BasisSchema;
8
+ basis: import("../basis/basis").BasisConfig & import("@mat3ra/esse/dist/js/types").BaseInMemoryEntitySchema;
9
9
  lattice: import("@mat3ra/esse/dist/js/types").LatticeSchema;
10
10
  };
11
11
  generateNewBasisWithinSupercell: (basis: import("../made").Basis | import("../basis/constrained_basis").ConstrainedBasis, cell: import("../made").Cell, supercell: import("../made").Cell, supercellMatrix: import("@mat3ra/esse/dist/js/types").Matrix3X3Schema) => import("../made").Basis;
12
12
  };
13
13
  material: {
14
- scaleOneLatticeVector: (material: import("../material").Material, key?: "a" | "b" | "c", factor?: number) => void;
15
- scaleLatticeToMakeNonPeriodic: (material: import("../material").Material) => void;
16
- translateAtomsToCenter: (material: import("../material").Material) => void;
14
+ scaleOneLatticeVector: (material: import("../Material").default, key?: "a" | "b" | "c", factor?: number) => void;
15
+ scaleLatticeToMakeNonPeriodic: (material: import("../Material").default) => void;
16
+ translateAtomsToCenter: (material: import("../Material").default) => void;
17
17
  };
18
18
  basis: {
19
19
  repeat: (basis: import("../made").Basis, repetitions: number[]) => import("../made").Basis;
20
- interpolate: (initialBasis: import("../made").Basis, finalBasis: import("../made").Basis, numberOfSteps?: number) => import("../made").Basis[];
20
+ interpolate: (initialBasis: import("../made").Basis, finalBasis: import("../made").Basis, numberOfSteps?: number) => import("../made").Basis<import("../basis/basis").BasisConfig>[];
21
21
  };
22
22
  };
23
23
  export default _default;
@@ -1,4 +1,4 @@
1
- import { Material } from "../material";
1
+ import Material from "../Material";
2
2
  /**
3
3
  * Scales one lattice vector for the given material
4
4
  * @param material {Material} The material acted upon.
@@ -15,7 +15,7 @@ function scaleOneLatticeVector(material, key = "a", factor = 1.0) {
15
15
  throw new Error("Lattice vectors are undefined");
16
16
  }
17
17
  lattice.vectors[key] = lattice.vectors[key].map((v) => v * factor);
18
- material.lattice = lattice_1.Lattice.fromVectors(lattice.vectors).toJSON();
18
+ material.setLattice(lattice_1.Lattice.fromVectors(lattice.vectors).toJSON());
19
19
  }
20
20
  /**
21
21
  * Updates the size of a materials lattice using the minimumLatticeSize function.
@@ -23,10 +23,10 @@ function scaleOneLatticeVector(material, key = "a", factor = 1.0) {
23
23
  * @param material {Material}
24
24
  */
25
25
  function scaleLatticeToMakeNonPeriodic(material) {
26
- material.lattice = lattice_1.Lattice.fromConfigPartial({
27
- a: material.Basis.getMinimumLatticeSize(),
26
+ material.setLattice(lattice_1.Lattice.fromConfigPartial({
27
+ a: material.getBasis().getMinimumLatticeSize(),
28
28
  type: "CUB",
29
- }).toJSON();
29
+ }).toJSON());
30
30
  }
31
31
  /**
32
32
  * Updates the basis of a material by translating the coordinates
@@ -34,11 +34,12 @@ function scaleLatticeToMakeNonPeriodic(material) {
34
34
  * @param material {Material}
35
35
  * */
36
36
  function translateAtomsToCenter(material) {
37
- const originalUnits = material.Basis.units;
37
+ const basis = material.getBasis();
38
+ const originalUnits = basis.units;
38
39
  material.toCartesian();
39
- const updatedBasis = material.Basis;
40
+ const updatedBasis = basis.toCartesian();
40
41
  const centerOfCoordinates = updatedBasis.centerOfCoordinatesPoint;
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 centerOfLattice = utils_1.Utils.math.multiply(0.5, material.getLattice().vectorArrays.reduce((a, b) => utils_1.Utils.math.add(a, b)));
42
43
  const translationVector = utils_1.Utils.math.subtract(centerOfLattice, centerOfCoordinates);
43
44
  updatedBasis.translateByVector(translationVector);
44
45
  material.setBasis(updatedBasis.toJSON());
@@ -2,19 +2,18 @@ import { Matrix3X3Schema } from "@mat3ra/esse/dist/js/types";
2
2
  import { Basis } from "../basis/basis";
3
3
  import { ConstrainedBasis } from "../basis/constrained_basis";
4
4
  import { Cell } from "../cell/cell";
5
- import type { Material } from "../material";
5
+ import type { MaterialSchemaMap } from "../Material";
6
+ import type Material from "../Material";
6
7
  /**
7
8
  * @summary Generates new basis for a supercell. For each site from basis generates shifts that are within supercell.
8
9
  */
9
10
  declare function generateNewBasisWithinSupercell(basis: Basis | ConstrainedBasis, cell: Cell, supercell: Cell, supercellMatrix: Matrix3X3Schema): Basis;
10
11
  /**
11
12
  * @summary Generates supercell config for the specified material.
12
- * @param material
13
- * @param supercellMatrix {Number[][]}
14
13
  */
15
- declare function generateConfig(material: Material, supercellMatrix: Matrix3X3Schema): {
14
+ declare function generateConfig<Schemas extends MaterialSchemaMap = MaterialSchemaMap>(material: Material<Schemas>, supercellMatrix: Matrix3X3Schema): {
16
15
  name: string;
17
- basis: import("@mat3ra/esse/dist/js/types").BasisSchema;
16
+ basis: import("../basis/basis").BasisConfig & import("@mat3ra/esse/dist/js/types").BaseInMemoryEntitySchema;
18
17
  lattice: import("@mat3ra/esse/dist/js/types").LatticeSchema;
19
18
  };
20
19
  declare const _default: {
@@ -35,17 +35,15 @@ function generateNewBasisWithinSupercell(basis, cell, supercell, supercellMatrix
35
35
  }
36
36
  /**
37
37
  * @summary Generates supercell config for the specified material.
38
- * @param material
39
- * @param supercellMatrix {Number[][]}
40
38
  */
41
39
  function generateConfig(material, supercellMatrix) {
42
40
  const det = utils_1.Utils.math.det(supercellMatrix);
43
41
  if (det === 0) {
44
42
  throw new Error("Scaling matrix is degenerate.");
45
43
  }
46
- const cell = material.Lattice.vectors;
44
+ const cell = material.getLattice().vectors;
47
45
  const supercell = cell.cloneAndScaleByMatrix(supercellMatrix);
48
- const newBasis = generateNewBasisWithinSupercell(material.Basis, cell, supercell, supercellMatrix);
46
+ const newBasis = generateNewBasisWithinSupercell(material.getBasis(), cell, supercell, supercellMatrix);
49
47
  const newLattice = lattice_1.Lattice.fromVectors({
50
48
  a: supercell.a,
51
49
  b: supercell.b,
@@ -1,9 +1,9 @@
1
- import { Coordinate3DSchema, MaterialSchema } from "@mat3ra/esse/dist/js/types";
2
- import { Material } from "../material";
3
- export type SlabConfigSchema = MaterialSchema & {
1
+ import { Coordinate3DSchema } from "@mat3ra/esse/dist/js/types";
2
+ import Material, { type MaterialConfig, type MaterialSchemaMap } from "../Material";
3
+ export type SlabConfigSchema = MaterialConfig & {
4
4
  outOfPlaneAxisIndex: number;
5
5
  };
6
- declare function generateConfig(material: Material, millerIndices: Coordinate3DSchema, numberOfLayers?: number, vx?: number, vy?: number): SlabConfigSchema;
6
+ declare function generateConfig<Schemas extends MaterialSchemaMap = MaterialSchemaMap>(material: Material<Schemas>, millerIndices: Coordinate3DSchema, numberOfLayers?: number, vx?: number, vy?: number): SlabConfigSchema;
7
7
  declare const _default: {
8
8
  generateConfig: typeof generateConfig;
9
9
  };
@@ -30,10 +30,6 @@ function extGCD(a, b) {
30
30
  /**
31
31
  * Generates a slab scaling matrix for the specified cell based on miller indices.
32
32
  * Inspired by from https://gitlab.com/ase/ase/blob/master/ase/build/general_surface.py.
33
- * @param cell {Cell}
34
- * @param millerIndices {Number[]}
35
- * @param tol {Number} Zero-value tolerance
36
- * @return {Number[][]}
37
33
  */
38
34
  function getMillerScalingMatrix(cell, millerIndices, tol = 1e-8) {
39
35
  if (!millerIndices.reduce((a, b) => utils_1.Utils.math.abs(a) + utils_1.Utils.math.abs(b)))
@@ -108,7 +104,6 @@ function getMillerScalingMatrix(cell, millerIndices, tol = 1e-8) {
108
104
  * @param thickness {Number} Surface (Slab) thickness in layers (Positive Integer).
109
105
  * @param vx {Number} Size of lateral supercell along the direction of the first (x) cell vector (Positive Integer).
110
106
  * @param vy {Number} Size of lateral supercell along the direction of the second (y) cell vector (Positive Integer).
111
- * @return {Number[][]}
112
107
  */
113
108
  function getDimensionsScalingMatrix(outOfPlaneAxisIndex, thickness, vx, vy) {
114
109
  const transformationMatrix = [
@@ -135,7 +130,7 @@ function getDimensionsScalingMatrix(outOfPlaneAxisIndex, thickness, vx, vy) {
135
130
  function generateConfig(material, millerIndices, numberOfLayers = 1, vx = 1, vy = 1) {
136
131
  if (numberOfLayers < 1)
137
132
  throw new Error("Made.tools.surface.generateConfig: number of layers < 1.");
138
- const cell = material.Lattice.vectors;
133
+ const cell = material.getLattice().vectors;
139
134
  const millerScalingMatrix = getMillerScalingMatrix(cell, millerIndices);
140
135
  const millerSupercell = cell.cloneAndScaleByMatrix(millerScalingMatrix);
141
136
  const millerPlanePseudoNormal = cell.convertPointToCartesian(millerIndices);
@@ -143,7 +138,7 @@ function generateConfig(material, millerIndices, numberOfLayers = 1, vx = 1, vy
143
138
  const dimensionsScalingMatrix = getDimensionsScalingMatrix(outOfPlaneAxisIndex, numberOfLayers, vx, vy);
144
139
  const supercellMatrix = MULT(dimensionsScalingMatrix, millerScalingMatrix);
145
140
  const supercell = millerSupercell.cloneAndScaleByMatrix(dimensionsScalingMatrix);
146
- const tempBasis = material.Basis.clone();
141
+ const tempBasis = material.getBasis().clone();
147
142
  const newBasis = supercell_1.default.generateNewBasisWithinSupercell(tempBasis, cell, supercell, supercellMatrix);
148
143
  const newLattice = lattice_1.Lattice.fromVectors({
149
144
  a: supercell.vectorArrays[0],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mat3ra/made",
3
- "version": "2026.8.7-0",
3
+ "version": "2026.8.13-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",
@@ -34,11 +34,11 @@
34
34
  "@babel/register": "^7.29.7",
35
35
  "@babel/runtime-corejs3": "^7.29.7",
36
36
  "@exabyte-io/eslint-config": "^2026.7.3-0",
37
- "@mat3ra/code": "^2026.5.27-0",
38
- "@mat3ra/esse": "^2026.6.30-0",
37
+ "@mat3ra/code": "2026.8.13-0",
38
+ "@mat3ra/esse": "2026.8.13-0",
39
+ "@mat3ra/standata": "2026.6.30-0",
39
40
  "@mat3ra/tsconfig": "^2024.6.3-0",
40
41
  "@mat3ra/utils": "^2026.7.8-0",
41
- "@mat3ra/standata": "2026.6.30-0",
42
42
  "@types/crypto-js": "^4.2.2",
43
43
  "@typescript-eslint/eslint-plugin": "^5.62.0",
44
44
  "@typescript-eslint/parser": "^5.62.0",
@@ -60,8 +60,8 @@
60
60
  "husky": "^7.0.4",
61
61
  "lint-staged": "^12.5.0",
62
62
  "mocha": "10.8.2",
63
- "prettier": "^2.8.8",
64
- "nyc": "^15.1.0"
63
+ "nyc": "^15.1.0",
64
+ "prettier": "^2.8.8"
65
65
  },
66
66
  "dependencies": {
67
67
  "@babel/core": "^7.29.7",
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Script to generate mixin properties from JSON schema.
5
+ *
6
+ * Usage:
7
+ * npm run generate-mixins
8
+ */
9
+
10
+ import generateSchemaMixin from "@mat3ra/code/dist/js/generateSchemaMixin";
11
+ import allSchemas from "@mat3ra/esse/dist/js/schemas.json";
12
+ import type { JSONSchema7 } from "json-schema";
13
+
14
+ const SKIP_FIELDS: string[] = [];
15
+
16
+ const OUTPUT_PATHS = {
17
+ "material/material-properties": "src/js/generated/MaterialSchemaMixin.ts",
18
+ };
19
+
20
+ function main() {
21
+ const result = generateSchemaMixin(allSchemas as JSONSchema7[], OUTPUT_PATHS, SKIP_FIELDS);
22
+
23
+ if (result.errorCount > 0) {
24
+ process.exit(1);
25
+ }
26
+ }
27
+
28
+ main();