@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.
- 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/conventional_cell.js +2 -2
- package/dist/js/cell/primitive_cell.js +19 -21
- package/dist/js/lattice/lattice.js +42 -30
- package/dist/js/lattice/lattice_types.js +1 -1
- package/dist/js/lattice/reciprocal/lattice_reciprocal.js +16 -16
- package/dist/js/lattice/reciprocal/symmetry_points.js +1 -2
- package/dist/js/material.d.ts +15 -15
- package/dist/js/parsers/poscar.js +2 -4
- package/dist/js/parsers/xyz.js +2 -2
- package/dist/js/parsers/xyz_combinatorial_basis.d.ts +2 -1
- package/dist/js/parsers/xyz_combinatorial_basis.js +19 -9
- 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 +41 -40
- package/pyproject.toml +6 -7
- 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/src/py/mat3ra/made/cell/primitive_cell.py +156 -0
- 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/conftest.py +1 -1
- package/tests/py/unit/test_material.py +10 -0
- package/tests/py/unit/test_primitive_cell.py +118 -0
- /package/src/py/mat3ra/made/{cell.py → cell/__init__.py} +0 -0
|
@@ -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
|
});
|
package/tests/py/conftest.py
CHANGED
|
@@ -26,7 +26,7 @@ def custom_warn(message, category=None, *args, **kwargs):
|
|
|
26
26
|
# These warnings always appear to come from inside spglib itself.
|
|
27
27
|
# This patch intercepts `warnings.warn` to ignore only those specific messages.
|
|
28
28
|
|
|
29
|
-
if isinstance(message, str) and "SpglibDataset" in message and category
|
|
29
|
+
if isinstance(message, str) and "SpglibDataset" in message and category is DeprecationWarning:
|
|
30
30
|
return # suppress
|
|
31
31
|
return _orig_warn(message, category, *args, **kwargs)
|
|
32
32
|
|
|
@@ -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()
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import math
|
|
2
|
+
import pytest
|
|
3
|
+
|
|
4
|
+
from mat3ra.made.cell.primitive_cell import get_primitive_lattice_vectors_from_config
|
|
5
|
+
from mat3ra.made.lattice import Lattice, LatticeTypeEnum
|
|
6
|
+
from tests.py.unit.utils import assert_two_entities_deep_almost_equal
|
|
7
|
+
|
|
8
|
+
EXPECTED_PRIMITIVE_CELL_NA4CL4 = [
|
|
9
|
+
[5.691694, 0.0, 0.0],
|
|
10
|
+
[0.0, 5.691694, 0.0],
|
|
11
|
+
[0.0, 0.0, 5.691694],
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_primitive_lattice_vectors_na4cl4():
|
|
16
|
+
"""
|
|
17
|
+
Replicates the TypeScript test for Na4Cl4 (CUB cell).
|
|
18
|
+
Translates from: tests/js/cell/primitive_cell.ts
|
|
19
|
+
"""
|
|
20
|
+
lattice = Lattice(type=LatticeTypeEnum.CUB, a=5.691694)
|
|
21
|
+
actual_primitive_cell = get_primitive_lattice_vectors_from_config(lattice)
|
|
22
|
+
|
|
23
|
+
assert_two_entities_deep_almost_equal(EXPECTED_PRIMITIVE_CELL_NA4CL4, actual_primitive_cell)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@pytest.mark.parametrize(
|
|
27
|
+
"l_type, kwargs, expected",
|
|
28
|
+
[
|
|
29
|
+
(LatticeTypeEnum.CUB, {"a": 2.0}, [[2.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.0, 0.0, 2.0]]),
|
|
30
|
+
(LatticeTypeEnum.FCC, {"a": 2.0}, [[0.0, 1.0, 1.0], [1.0, 0.0, 1.0], [1.0, 1.0, 0.0]]),
|
|
31
|
+
(LatticeTypeEnum.BCC, {"a": 2.0}, [[-1.0, 1.0, 1.0], [1.0, -1.0, 1.0], [1.0, 1.0, -1.0]]),
|
|
32
|
+
(LatticeTypeEnum.TET, {"a": 2.0, "c": 3.0}, [[2.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.0, 0.0, 3.0]]),
|
|
33
|
+
(LatticeTypeEnum.BCT, {"a": 2.0, "c": 3.0}, [[-1.0, 1.0, 1.5], [1.0, -1.0, 1.5], [1.0, 1.0, -1.5]]),
|
|
34
|
+
(LatticeTypeEnum.ORC, {"a": 2.0, "b": 3.0, "c": 4.0}, [[2.0, 0.0, 0.0], [0.0, 3.0, 0.0], [0.0, 0.0, 4.0]]),
|
|
35
|
+
(
|
|
36
|
+
LatticeTypeEnum.ORCF,
|
|
37
|
+
{"a": 2.0, "b": 3.0, "c": 4.0},
|
|
38
|
+
[[0.0, 1.5, 2.0], [1.0, 0.0, 2.0], [1.0, 1.5, 0.0]],
|
|
39
|
+
),
|
|
40
|
+
(
|
|
41
|
+
LatticeTypeEnum.ORCI,
|
|
42
|
+
{"a": 2.0, "b": 3.0, "c": 4.0},
|
|
43
|
+
[[-1.0, 1.5, 2.0], [1.0, -1.5, 2.0], [1.0, 1.5, -2.0]],
|
|
44
|
+
),
|
|
45
|
+
(
|
|
46
|
+
LatticeTypeEnum.ORCC,
|
|
47
|
+
{"a": 2.0, "b": 3.0, "c": 4.0},
|
|
48
|
+
[[1.0, 1.5, 0.0], [-1.0, 1.5, 0.0], [0.0, 0.0, 4.0]],
|
|
49
|
+
),
|
|
50
|
+
(
|
|
51
|
+
LatticeTypeEnum.HEX,
|
|
52
|
+
{"a": 2.0, "c": 3.0},
|
|
53
|
+
[[1.0, -math.sqrt(3), 0.0], [1.0, math.sqrt(3), 0.0], [0.0, 0.0, 3.0]],
|
|
54
|
+
),
|
|
55
|
+
(
|
|
56
|
+
LatticeTypeEnum.RHL,
|
|
57
|
+
{"a": 2.0, "alpha": 60.0},
|
|
58
|
+
[[1.7320508, -1.0, 0.0], [1.7320508, 1.0, 0.0], [1.1547005, 0.0, 1.6329931]],
|
|
59
|
+
),
|
|
60
|
+
(
|
|
61
|
+
LatticeTypeEnum.MCL,
|
|
62
|
+
{"a": 2.0, "b": 3.0, "c": 4.0, "alpha": 60.0},
|
|
63
|
+
[[2.0, 0.0, 0.0], [0.0, 3.0, 0.0], [0.0, 2.0, 3.4641016]],
|
|
64
|
+
),
|
|
65
|
+
(
|
|
66
|
+
LatticeTypeEnum.MCLC,
|
|
67
|
+
{"a": 2.0, "b": 3.0, "c": 4.0, "alpha": 60.0},
|
|
68
|
+
[[1.0, 1.5, 0.0], [-1.0, 1.5, 0.0], [0.0, 2.0, 3.4641016]],
|
|
69
|
+
),
|
|
70
|
+
(
|
|
71
|
+
LatticeTypeEnum.TRI,
|
|
72
|
+
{"a": 2.0, "b": 3.0, "c": 4.0, "alpha": 90.0, "beta": 90.0, "gamma": 90.0},
|
|
73
|
+
[[2.0, 0.0, 0.0], [0.0, 3.0, 0.0], [0.0, 0.0, 4.0]],
|
|
74
|
+
),
|
|
75
|
+
],
|
|
76
|
+
)
|
|
77
|
+
def test_primitive_lattice_generators(l_type, kwargs, expected):
|
|
78
|
+
"""Validates the math generators for all 14 Bravais lattice scenarios."""
|
|
79
|
+
lattice = Lattice(type=l_type, **kwargs)
|
|
80
|
+
result = get_primitive_lattice_vectors_from_config(lattice)
|
|
81
|
+
assert_two_entities_deep_almost_equal(expected, result)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def test_fallback_to_tri_when_type_is_none():
|
|
85
|
+
"""Tests default fallback to 'TRI' when lattice_config.type is None."""
|
|
86
|
+
# Use a simple dummy class to bypass Pydantic's strict validation
|
|
87
|
+
# and simulate a malformed or incomplete Lattice config.
|
|
88
|
+
class MockLattice:
|
|
89
|
+
type = None
|
|
90
|
+
a, b, c = 2.0, 2.0, 2.0
|
|
91
|
+
alpha, beta, gamma = 90.0, 90.0, 90.0
|
|
92
|
+
|
|
93
|
+
lattice = MockLattice()
|
|
94
|
+
result = get_primitive_lattice_vectors_from_config(lattice)
|
|
95
|
+
expected = [[2.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.0, 0.0, 2.0]]
|
|
96
|
+
|
|
97
|
+
assert_two_entities_deep_almost_equal(expected, result)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def test_unsupported_lattice_type_raises_value_error():
|
|
101
|
+
"""Ensures a ValueError is raised for an unknown lattice type mapping."""
|
|
102
|
+
# Using a MagicMock specifically here to force an invalid type value
|
|
103
|
+
# since LatticeTypeEnum won't allow arbitrary strings
|
|
104
|
+
class MockType:
|
|
105
|
+
value = "INVALID_TYPE"
|
|
106
|
+
|
|
107
|
+
class MockLattice:
|
|
108
|
+
type = MockType()
|
|
109
|
+
# Provide dummy parameters just in case
|
|
110
|
+
a, b, c = 2.0, 2.0, 2.0
|
|
111
|
+
alpha, beta, gamma = 90.0, 90.0, 90.0
|
|
112
|
+
|
|
113
|
+
lattice = MockLattice()
|
|
114
|
+
|
|
115
|
+
with pytest.raises(ValueError) as exc_info:
|
|
116
|
+
get_primitive_lattice_vectors_from_config(lattice)
|
|
117
|
+
|
|
118
|
+
assert "Unsupported lattice type 'INVALID_TYPE'" in str(exc_info.value)
|
|
File without changes
|