@mat3ra/made 2026.7.4-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.
- package/dist/js/basis/basis.js +8 -8
- package/dist/js/basis/coordinates.js +2 -2
- package/dist/js/cell/cell.js +11 -10
- package/dist/js/cell/primitive_cell.js +18 -19
- package/dist/js/lattice/lattice.js +25 -23
- package/dist/js/lattice/reciprocal/lattice_reciprocal.js +16 -16
- package/dist/js/parsers/poscar.js +1 -2
- package/dist/js/parsers/xyz_combinatorial_basis.js +2 -2
- package/dist/js/tools/basis.js +3 -3
- package/dist/js/tools/cell.js +3 -3
- package/dist/js/tools/material.js +3 -3
- package/dist/js/tools/supercell.js +3 -3
- package/dist/js/tools/surface.js +14 -12
- package/package.json +3 -2
- package/src/js/basis/basis.ts +9 -8
- package/src/js/basis/coordinates.ts +3 -2
- package/src/js/cell/cell.ts +12 -10
- package/src/js/cell/primitive_cell.ts +23 -19
- package/src/js/lattice/lattice.ts +25 -23
- package/src/js/lattice/reciprocal/lattice_reciprocal.ts +19 -18
- package/src/js/parsers/poscar.ts +2 -2
- package/src/js/parsers/xyz_combinatorial_basis.ts +3 -2
- package/src/js/tools/basis.ts +4 -3
- package/src/js/tools/cell.ts +4 -3
- package/src/js/tools/material.ts +5 -4
- package/src/js/tools/supercell.ts +4 -3
- package/src/js/tools/surface.ts +18 -12
- package/tests/fixtures/hashes.json +3 -0
- package/tests/js/cell/cell.ts +1 -1
- package/tests/js/fixtures.ts +7 -1
- package/tests/js/material.test.ts +8 -1
- package/tests/py/unit/test_material.py +10 -0
package/src/js/tools/surface.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { math } from "@mat3ra/code/dist/js/math";
|
|
2
1
|
import {
|
|
3
2
|
Coordinate3DSchema,
|
|
4
3
|
MaterialSchema,
|
|
5
4
|
Matrix3X3Schema,
|
|
6
5
|
Vector3DSchema,
|
|
7
6
|
} from "@mat3ra/esse/dist/js/types";
|
|
7
|
+
import { Utils } from "@mat3ra/utils";
|
|
8
8
|
|
|
9
9
|
import { Cell } from "../cell/cell";
|
|
10
10
|
import { Lattice } from "../lattice/lattice";
|
|
11
11
|
import { Material } from "../material";
|
|
12
12
|
import SupercellTools from "./supercell";
|
|
13
13
|
|
|
14
|
-
const MULT = math.multiply;
|
|
15
|
-
const ADD = math.add;
|
|
16
|
-
const DOT = math.product;
|
|
14
|
+
const MULT = Utils.math.multiply;
|
|
15
|
+
const ADD = Utils.math.add;
|
|
16
|
+
const DOT = Utils.math.product;
|
|
17
17
|
const getMatrixInLeftHandedRepresentation = (matrix: Matrix3X3Schema) => {
|
|
18
|
-
return math.det(matrix) < 0 ? MULT(matrix, -1) : matrix;
|
|
18
|
+
return Utils.math.det(matrix) < 0 ? MULT(matrix, -1) : matrix;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -27,10 +27,10 @@ const getMatrixInLeftHandedRepresentation = (matrix: Matrix3X3Schema) => {
|
|
|
27
27
|
*/
|
|
28
28
|
function extGCD(a: number, b: number): [number, number] {
|
|
29
29
|
if (b === 0) return [1, 0];
|
|
30
|
-
if (math.mod(a, b) === 0) return [0, 1];
|
|
30
|
+
if (Utils.math.mod(a, b) === 0) return [0, 1];
|
|
31
31
|
|
|
32
|
-
const [x, y] = extGCD(b, math.mod(a, b));
|
|
33
|
-
return [y, x - y * math.floor(a / b)];
|
|
32
|
+
const [x, y] = extGCD(b, Utils.math.mod(a, b));
|
|
33
|
+
return [y, x - y * Utils.math.floor(a / b)];
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -46,7 +46,7 @@ function getMillerScalingMatrix(
|
|
|
46
46
|
millerIndices: Coordinate3DSchema,
|
|
47
47
|
tol = 1e-8,
|
|
48
48
|
): Matrix3X3Schema {
|
|
49
|
-
if (!millerIndices.reduce((a, b) => math.abs(a) + math.abs(b)))
|
|
49
|
+
if (!millerIndices.reduce((a, b) => Utils.math.abs(a) + Utils.math.abs(b)))
|
|
50
50
|
throw new Error("Miller indices are zeros.");
|
|
51
51
|
|
|
52
52
|
let scalingMatrix;
|
|
@@ -94,20 +94,26 @@ function getMillerScalingMatrix(
|
|
|
94
94
|
// @ts-ignore
|
|
95
95
|
const k2 = DOT(ADD(MULT(l, z1), -MULT(k, z2)), z3);
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
// @ts-ignore
|
|
98
|
+
if (Utils.math.abs(k2) > tol) {
|
|
98
99
|
// For mathjs version 3.20: round(-0.5) = -0
|
|
99
100
|
// For mathjs version 5.10: round(-0.5) = -1
|
|
100
101
|
// Here we specify rounding method to Bankers
|
|
101
102
|
// For Python 3.11: round(-0.5) = 0
|
|
103
|
+
// @ts-ignore - mathjs v12 dot return type
|
|
102
104
|
const value = k1 / k2;
|
|
103
|
-
const roundedValue = math.roundCustom(
|
|
105
|
+
const roundedValue = Utils.math.roundCustom(
|
|
106
|
+
value,
|
|
107
|
+
0,
|
|
108
|
+
Utils.math.RoundingMethod.Bankers,
|
|
109
|
+
);
|
|
104
110
|
const i = -roundedValue;
|
|
105
111
|
[p, q] = [p + i * l, q - i * k];
|
|
106
112
|
}
|
|
107
113
|
|
|
108
114
|
const [a, b] = extGCD(p * k + q * l, h);
|
|
109
115
|
const c1 = [p * k + q * l, -p * h, -q * h];
|
|
110
|
-
const c2 = [0, l, -k].map((c) => math.trunc(c / math.gcd(l, k))); // floor division
|
|
116
|
+
const c2 = [0, l, -k].map((c) => Utils.math.trunc(c / Utils.math.gcd(l, k))); // floor division
|
|
111
117
|
const c3 = [b, a * p, a * q];
|
|
112
118
|
|
|
113
119
|
scalingMatrix = [c1, c2, c3];
|
package/tests/js/cell/cell.ts
CHANGED
|
@@ -41,7 +41,7 @@ const VECTORS_EQUAL_UP_TO_PRECISION_4: Matrix3X3Schema = [
|
|
|
41
41
|
[0.0, 0.0, 3.00001],
|
|
42
42
|
];
|
|
43
43
|
|
|
44
|
-
const VECTORS_EQUAL_UP_TO_PRECISION_4_VOLUME = 6.
|
|
44
|
+
const VECTORS_EQUAL_UP_TO_PRECISION_4_VOLUME = 6.000110000600001;
|
|
45
45
|
const VECTORS_EQUAL_UP_TO_PRECISION_4_VOLUME_ROUNDED_TO_PRECISION_4 = 6.0001;
|
|
46
46
|
const VECTORS_EQUAL_UP_TO_PRECISION_4_VOLUME_ROUNDED_TO_PRECISION_5 = 6.00011;
|
|
47
47
|
|
package/tests/js/fixtures.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { AtomicConstraintsSchema, BasisSchema, MaterialSchema } from "@mat3ra/esse/dist/js/types";
|
|
2
|
+
import { MaterialStandata } from "@mat3ra/standata";
|
|
2
3
|
import fs from "fs";
|
|
3
4
|
import path from "path";
|
|
4
5
|
|
|
5
|
-
// TODO: use @mat3ra/standata
|
|
6
6
|
import AsGeBasis_JSON from "../fixtures/AsGe-basis.json";
|
|
7
7
|
import atomicConstraints_JSON from "../fixtures/atomic-constraints.json";
|
|
8
8
|
import C2H4_JSON from "../fixtures/C2H4.json";
|
|
9
9
|
import C2H4Translated_JSON from "../fixtures/C2H4-translated.json";
|
|
10
10
|
import FeLiSiBasis_JSON from "../fixtures/FeLiSi-basis.json";
|
|
11
11
|
import FeO_JSON from "../fixtures/FeO.json";
|
|
12
|
+
|
|
12
13
|
import Ge2Basis_JSON from "../fixtures/Ge2-basis.json";
|
|
13
14
|
import Graphene_JSON from "../fixtures/Graphene.json";
|
|
14
15
|
import H2HFinal_JSON from "../fixtures/H2+H-final.json";
|
|
@@ -27,6 +28,7 @@ import SiSlab111Gamma120_JSON from "../fixtures/si-slab-111-0.5-vacuum-gamma-120
|
|
|
27
28
|
import SiSlab111_JSON from "../fixtures/si-slab-111-0.5-vacuum-ratio.json";
|
|
28
29
|
import SiSlab111NoVacuum_JSON from "../fixtures/si-slab-111-0-vacuum.json";
|
|
29
30
|
import Silicon_JSON from "../fixtures/si-standata.json";
|
|
31
|
+
|
|
30
32
|
import SiSupercell_JSON from "../fixtures/Si-supercell.json";
|
|
31
33
|
import Si2Basis_JSON from "../fixtures/Si2-basis.json";
|
|
32
34
|
import Si2BasisRepeated_JSON from "../fixtures/Si2-basis-repeated.json";
|
|
@@ -41,6 +43,9 @@ const SiSlab111 = SiSlab111_JSON as unknown as MaterialSchema;
|
|
|
41
43
|
const SiSlab111Gamma120 = SiSlab111Gamma120_JSON as unknown as MaterialSchema;
|
|
42
44
|
const SiSlab111NoVacuum = SiSlab111NoVacuum_JSON as unknown as MaterialSchema;
|
|
43
45
|
const FeO = FeO_JSON as unknown as MaterialSchema;
|
|
46
|
+
const FeOStandata = MaterialStandata.getRuntimeDataConfigs().find(
|
|
47
|
+
(m: any) => m.name?.includes("FeO"),
|
|
48
|
+
) as MaterialSchema;
|
|
44
49
|
const Na4Cl4 = Na4Cl4_JSON as unknown as MaterialSchema;
|
|
45
50
|
const Na4Cl4Cartesian = Na4Cl4Cartesian_JSON as unknown as MaterialSchema;
|
|
46
51
|
const C2H4 = C2H4_JSON as unknown as MaterialSchema;
|
|
@@ -79,6 +84,7 @@ export {
|
|
|
79
84
|
Si2BasisRepeated,
|
|
80
85
|
// Other
|
|
81
86
|
FeO,
|
|
87
|
+
FeOStandata,
|
|
82
88
|
Na4Cl4,
|
|
83
89
|
Na4Cl4Cartesian,
|
|
84
90
|
C2H4,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { expect } from "chai";
|
|
2
2
|
|
|
3
3
|
import { Material } from "../../src/js/material";
|
|
4
|
-
import { Graphene, Na4Cl4, Silicon } from "./fixtures";
|
|
4
|
+
import { FeOStandata, Graphene, Na4Cl4, Silicon } from "./fixtures";
|
|
5
5
|
|
|
6
6
|
const newBasisXYZ = `Si 0.000000 0.000000 0.000000
|
|
7
7
|
Ge 0.250000 0.250000 0.250000
|
|
@@ -31,5 +31,12 @@ describe("Material", () => {
|
|
|
31
31
|
expect(material.scaledHash).to.equal((fixture as any).scaledHash);
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
|
+
|
|
35
|
+
it("should match expected hash for FeO (standata)", () => {
|
|
36
|
+
const expectedHashes = require("../../fixtures/hashes.json");
|
|
37
|
+
const material = new Material(FeOStandata);
|
|
38
|
+
expect(material.calculateHash()).to.equal(expectedHashes.FeO.hash);
|
|
39
|
+
expect(material.scaledHash).to.equal(expectedHashes.FeO.scaledHash);
|
|
40
|
+
});
|
|
34
41
|
});
|
|
35
42
|
});
|
|
@@ -140,6 +140,16 @@ def test_calculate_hash(fixture_file):
|
|
|
140
140
|
assert material.scaled_hash == fixture["scaledHash"]
|
|
141
141
|
|
|
142
142
|
|
|
143
|
+
def test_calculate_hash_feo_standata():
|
|
144
|
+
from mat3ra.standata.materials import Materials
|
|
145
|
+
|
|
146
|
+
expected_hashes = load_fixture("hashes.json")["FeO"]
|
|
147
|
+
data = Materials.get_by_name_first_match("FeO")
|
|
148
|
+
material = Material.create(data)
|
|
149
|
+
assert material.hash == expected_hashes["hash"]
|
|
150
|
+
assert material.scaled_hash == expected_hashes["scaledHash"]
|
|
151
|
+
|
|
152
|
+
|
|
143
153
|
def test_model_dump_includes_hashes():
|
|
144
154
|
material = Material.create_default()
|
|
145
155
|
serialized_material = material.model_dump()
|