@mat3ra/made 2025.4.14-0 → 2025.4.15-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.
@@ -82,7 +82,8 @@ function getMillerScalingMatrix(cell, millerIndices, tol = 1e-8) {
82
82
  // Here we specify rounding method to Bankers
83
83
  // For Python 3.11: round(-0.5) = 0
84
84
  const value = k1 / k2;
85
- const i = math_1.default.roundCustom(value, 0, math_1.default.RoundingMethod.Bankers);
85
+ const roundedValue = math_1.default.roundCustom(value, 0, math_1.default.RoundingMethod.Bankers);
86
+ const i = -roundedValue;
86
87
  [p, q] = [p + i * l, q - i * k];
87
88
  }
88
89
  const [a, b] = extGCD(p * k + q * l, h);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mat3ra/made",
3
- "version": "2025.4.14-0",
3
+ "version": "2025.4.15-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",
@@ -85,7 +85,8 @@ function getMillerScalingMatrix(cell, millerIndices, tol = 1e-8) {
85
85
  // Here we specify rounding method to Bankers
86
86
  // For Python 3.11: round(-0.5) = 0
87
87
  const value = k1 / k2;
88
- const i = math.roundCustom(value, 0, math.RoundingMethod.Bankers);
88
+ const roundedValue = math.roundCustom(value, 0, math.RoundingMethod.Bankers);
89
+ const i = -roundedValue;
89
90
  [p, q] = [p + i * l, q - i * k];
90
91
  }
91
92
 
@@ -0,0 +1,3 @@
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9f5905448537352e0af199e5d1b66a2d51585b6fc91ad2078809fda097a428ab
3
+ size 1894
@@ -2,34 +2,33 @@ import fs from "fs";
2
2
  import path from "path";
3
3
 
4
4
  // TODO: use @mat3ra/standata
5
-
6
- import Silicon from "../fixtures/si-standata.json";
7
- import FeO from "../fixtures/FeO.json";
8
- import Na4Cl4 from "../fixtures/Na4Cl4.json";
9
- import Na4Cl4Cartesian from "../fixtures/Na4Cl4-cartesian.json";
10
- import SiSupercell from "../fixtures/Si-supercell.json";
5
+ import AsGeBasis from "../fixtures/AsGe-basis.json";
6
+ import atomicConstraints from "../fixtures/atomic-constraints.json";
11
7
  import C2H4 from "../fixtures/C2H4.json";
12
8
  import C2H4Translated from "../fixtures/C2H4-translated.json";
13
- import Na from "../fixtures/Na.json";
14
- import OSiBasis from "../fixtures/OSi-basis.json";
15
- import Si2Basis from "../fixtures/Si2-basis.json";
16
- import Ge2Basis from "../fixtures/Ge2-basis.json";
17
- import AsGeBasis from "../fixtures/AsGe-basis.json";
18
9
  import FeLiSiBasis from "../fixtures/FeLiSi-basis.json";
19
- import LiFeSiBasis from "../fixtures/LiFeSi-basis.json";
20
- import atomicConstraints from "../fixtures/atomic-constraints.json";
21
- import Si2BasisRepeated from "../fixtures/Si2-basis-repeated.json";
22
- import H2HInitial from "../fixtures/H2+H-initial.json";
10
+ import FeO from "../fixtures/FeO.json";
11
+ import Ge2Basis from "../fixtures/Ge2-basis.json";
12
+ import Graphene from "../fixtures/Graphene.json";
23
13
  import H2HFinal from "../fixtures/H2+H-final.json";
24
14
  import H2HImage from "../fixtures/H2+H-image.json";
25
- import SiSlab from "../fixtures/Si-slab.json";
26
- import Zr1H23Zr1H1 from "../fixtures/Zr1H23Zr1H1.json";
27
- import Graphene from "../fixtures/Graphene.json";
15
+ import H2HInitial from "../fixtures/H2+H-initial.json";
16
+ import LiFeSiBasis from "../fixtures/LiFeSi-basis.json";
17
+ import Na from "../fixtures/Na.json";
18
+ import Na4Cl4 from "../fixtures/Na4Cl4.json";
19
+ import Na4Cl4Cartesian from "../fixtures/Na4Cl4-cartesian.json";
28
20
  import NiHex from "../fixtures/Ni-hex.json";
21
+ import OSiBasis from "../fixtures/OSi-basis.json";
22
+ import SiSlab from "../fixtures/Si-slab.json";
29
23
  import SiSlab100 from "../fixtures/si-slab-100.json";
24
+ import SiSlab111Gamma120 from "../fixtures/si-slab-111-0.5-vacuum-gamma-120.json";
30
25
  import SiSlab111 from "../fixtures/si-slab-111-0.5-vacuum-ratio.json";
31
26
  import SiSlab111NoVacuum from "../fixtures/si-slab-111-0-vacuum.json";
32
-
27
+ import Silicon from "../fixtures/si-standata.json";
28
+ import SiSupercell from "../fixtures/Si-supercell.json";
29
+ import Si2Basis from "../fixtures/Si2-basis.json";
30
+ import Si2BasisRepeated from "../fixtures/Si2-basis-repeated.json";
31
+ import Zr1H23Zr1H1 from "../fixtures/Zr1H23Zr1H1.json";
33
32
 
34
33
  export {
35
34
  // Silicon
@@ -38,6 +37,7 @@ export {
38
37
  SiSlab,
39
38
  SiSlab100,
40
39
  SiSlab111,
40
+ SiSlab111Gamma120,
41
41
  SiSlab111NoVacuum,
42
42
  Si2Basis,
43
43
  Si2BasisRepeated,
@@ -2,10 +2,23 @@ import { Utils } from "@mat3ra/utils";
2
2
 
3
3
  import { Material } from "../../../src/js/material";
4
4
  import tools from "../../../src/js/tools";
5
- import { Silicon, SiSlab100, SiSlab111, SiSlab111NoVacuum } from "../fixtures";
5
+ import { Silicon, SiSlab100, SiSlab111, SiSlab111Gamma120, SiSlab111NoVacuum } from "../fixtures";
6
6
 
7
7
  const { assertDeepAlmostEqual } = Utils.assertion;
8
8
 
9
+ const generateSlabWithVacuum = (slabConfig, vacuumRatio) => {
10
+ const slabMaterial = new Material(slabConfig);
11
+ const { outOfPlaneAxisIndex } = slabConfig;
12
+
13
+ tools.material.scaleOneLatticeVector(
14
+ slabMaterial,
15
+ ["a", "b", "c"][outOfPlaneAxisIndex],
16
+ 1 / (1 - vacuumRatio),
17
+ );
18
+
19
+ return slabMaterial;
20
+ };
21
+
9
22
  describe("Tools:Surface", () => {
10
23
  it("should return slab (100)", () => {
11
24
  const material = new Material(Silicon);
@@ -23,15 +36,47 @@ describe("Tools:Surface", () => {
23
36
  const material = new Material(Silicon);
24
37
  const slabConfig = tools.surface.generateConfig(material, [1, 1, 1], 3, 1, 1);
25
38
  const vacuumRatio = 0.5;
26
- const slabMaterial = new Material(slabConfig);
27
- const { outOfPlaneAxisIndex } = slabConfig;
28
- // Add 0.5 vacuum ratio, which is used in MD
29
- tools.material.scaleOneLatticeVector(
30
- slabMaterial,
31
- ["a", "b", "c"][outOfPlaneAxisIndex],
32
- 1 / (1 - vacuumRatio),
33
- );
39
+ const slabMaterial = generateSlabWithVacuum(slabConfig, vacuumRatio);
40
+ const expectedSlabMaterial = new Material(SiSlab111);
41
+ const expectedMaterialJSON = expectedSlabMaterial.toJSON();
42
+ const slabMaterialJSON = slabMaterial.toJSON();
43
+ assertDeepAlmostEqual(expectedMaterialJSON, slabMaterialJSON);
44
+ });
45
+
46
+ it("should return slab (111) with vacuum (gamma~=120) for gamma = 59.999", () => {
47
+ const adjustedSilicon = {
48
+ ...Silicon,
49
+ lattice: {
50
+ ...Silicon.lattice,
51
+ gamma: 59.999,
52
+ },
53
+ };
54
+ const material = new Material(adjustedSilicon);
55
+ const slabConfig = tools.surface.generateConfig(material, [1, 1, 1], 3, 1, 1);
56
+ const vacuumRatio = 0.5;
57
+ const slabMaterial = generateSlabWithVacuum(slabConfig, vacuumRatio);
58
+ // With original gamma being below 60, the surface generated differently, with a different gamma
59
+ const expectedSlabMaterial = new Material(SiSlab111Gamma120);
60
+ const expectedMaterialJSON = expectedSlabMaterial.toJSON();
61
+ const slabMaterialJSON = slabMaterial.toJSON();
62
+ assertDeepAlmostEqual(expectedMaterialJSON, slabMaterialJSON);
63
+ });
64
+
65
+ it("should return slab (111) with vacuum for gamma = 60.001", () => {
66
+ const adjustedSilicon = {
67
+ ...Silicon,
68
+ lattice: {
69
+ ...Silicon.lattice,
70
+ gamma: 60.001,
71
+ },
72
+ };
73
+ const material = new Material(adjustedSilicon);
74
+ const slabConfig = tools.surface.generateConfig(material, [1, 1, 1], 3, 1, 1);
75
+ const vacuumRatio = 0.5;
76
+ const slabMaterial = generateSlabWithVacuum(slabConfig, vacuumRatio);
34
77
  const expectedSlabMaterial = new Material(SiSlab111);
35
- assertDeepAlmostEqual(expectedSlabMaterial.toJSON(), slabMaterial.toJSON());
78
+ const expectedMaterialJSON = expectedSlabMaterial.toJSON();
79
+ const slabMaterialJSON = slabMaterial.toJSON();
80
+ assertDeepAlmostEqual(expectedMaterialJSON, slabMaterialJSON);
36
81
  });
37
82
  });