@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.
- package/.mocharc.json +2 -2
- package/dist/js/Material.d.ts +219 -0
- package/dist/js/Material.js +457 -0
- package/dist/js/basis/basis.d.ts +14 -9
- package/dist/js/basis/basis.js +15 -13
- package/dist/js/basis/constrained_basis.d.ts +9 -7
- package/dist/js/basis/constrained_basis.js +4 -4
- package/dist/js/generated/MaterialSchemaMixin.d.ts +5 -0
- package/dist/js/generated/MaterialSchemaMixin.js +69 -0
- package/dist/js/lattice/lattice.d.ts +4 -3
- package/dist/js/lattice/lattice.js +1 -2
- package/dist/js/made.d.ts +12 -12
- package/dist/js/made.js +38 -5
- package/dist/js/parsers/espresso.d.ts +2 -3
- package/dist/js/parsers/espresso.js +0 -1
- package/dist/js/parsers/native_format_parsers.d.ts +9 -8
- package/dist/js/parsers/native_format_parsers.js +6 -6
- package/dist/js/parsers/parsers.d.ts +6 -6
- package/dist/js/parsers/poscar.d.ts +5 -4
- package/dist/js/parsers/poscar.js +3 -2
- package/dist/js/parsers/xyz.d.ts +3 -5
- package/dist/js/parsers/xyz.js +3 -4
- package/dist/js/parsers/xyz_combinatorial_basis.js +3 -1
- package/dist/js/tools/basis.d.ts +1 -1
- package/dist/js/tools/index.d.ts +7 -7
- package/dist/js/tools/material.d.ts +1 -1
- package/dist/js/tools/material.js +8 -7
- package/dist/js/tools/supercell.d.ts +4 -5
- package/dist/js/tools/supercell.js +2 -4
- package/dist/js/tools/surface.d.ts +4 -4
- package/dist/js/tools/surface.js +2 -7
- package/package.json +6 -6
- package/scripts/generate-mixins.ts +28 -0
- package/src/js/Material.ts +618 -0
- package/src/js/basis/basis.ts +38 -25
- package/src/js/basis/constrained_basis.ts +12 -11
- package/src/js/basis/coordinates.ts +0 -1
- package/src/js/cell/cell.ts +0 -1
- package/src/js/generated/MaterialSchemaMixin.ts +79 -0
- package/src/js/lattice/lattice.ts +6 -4
- package/src/js/lattice/reciprocal/lattice_reciprocal.ts +19 -6
- package/src/js/made.ts +1 -1
- package/src/js/parsers/espresso.ts +2 -3
- package/src/js/parsers/native_format_parsers.ts +9 -8
- package/src/js/parsers/poscar.ts +12 -6
- package/src/js/parsers/xyz.ts +9 -6
- package/src/js/parsers/xyz_combinatorial_basis.ts +5 -2
- package/src/js/tools/basis.ts +0 -1
- package/src/js/tools/cell.ts +0 -1
- package/src/js/tools/material.ts +13 -11
- package/src/js/tools/supercell.ts +8 -7
- package/src/js/tools/surface.ts +7 -17
- package/src/py/mat3ra/made/material.py +6 -5
- package/tests/fixtures/si-standata.json +2 -2
- package/tests/js/basis/basis.ts +8 -8
- package/tests/js/fixtures.ts +12 -9
- package/tests/js/material/material.ts +161 -0
- package/tests/js/parsers/espresso.ts +2 -5
- package/tests/js/parsers/poscar.ts +2 -2
- package/tests/js/register-esse-schemas.cjs +10 -0
- package/tests/js/tools/supercell.ts +2 -2
- package/tests/js/tools/surface.ts +6 -10
- package/dist/js/material.d.ts +0 -169
- package/dist/js/material.js +0 -362
- package/src/js/material.ts +0 -458
- package/tests/js/material.test.ts +0 -42
package/dist/js/parsers/xyz.js
CHANGED
|
@@ -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
|
-
*
|
|
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
|
-
|
|
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,
|
|
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
|
/**
|
package/dist/js/tools/basis.d.ts
CHANGED
|
@@ -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;
|
package/dist/js/tools/index.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
2
|
surface: {
|
|
3
|
-
generateConfig: (material: import("../
|
|
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("../
|
|
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").
|
|
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("../
|
|
15
|
-
scaleLatticeToMakeNonPeriodic: (material: import("../
|
|
16
|
-
translateAtomsToCenter: (material: import("../
|
|
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;
|
|
@@ -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.
|
|
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.
|
|
27
|
-
a: material.
|
|
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
|
|
37
|
+
const basis = material.getBasis();
|
|
38
|
+
const originalUnits = basis.units;
|
|
38
39
|
material.toCartesian();
|
|
39
|
-
const updatedBasis =
|
|
40
|
+
const updatedBasis = basis.toCartesian();
|
|
40
41
|
const centerOfCoordinates = updatedBasis.centerOfCoordinatesPoint;
|
|
41
|
-
const centerOfLattice = utils_1.Utils.math.multiply(0.5, material.
|
|
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 {
|
|
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
|
|
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").
|
|
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.
|
|
44
|
+
const cell = material.getLattice().vectors;
|
|
47
45
|
const supercell = cell.cloneAndScaleByMatrix(supercellMatrix);
|
|
48
|
-
const newBasis = generateNewBasisWithinSupercell(material.
|
|
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
|
|
2
|
-
import {
|
|
3
|
-
export type SlabConfigSchema =
|
|
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
|
|
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
|
};
|
package/dist/js/tools/surface.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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": "
|
|
38
|
-
"@mat3ra/esse": "
|
|
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
|
-
"
|
|
64
|
-
"
|
|
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();
|