@mat3ra/made 2024.3.22-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/.babelrc +10 -0
- package/.eslintrc.json +11 -0
- package/.mocharc.json +5 -0
- package/.prettierignore +1 -0
- package/.prettierrc +6 -0
- package/LICENSE.md +15 -0
- package/README.md +167 -0
- package/dist/abstract/array_with_ids.d.ts +43 -0
- package/dist/abstract/array_with_ids.js +88 -0
- package/dist/abstract/scalar_with_id.d.ts +25 -0
- package/dist/abstract/scalar_with_id.js +44 -0
- package/dist/basis/basis.d.ts +269 -0
- package/dist/basis/basis.js +499 -0
- package/dist/basis/constrained_basis.d.ts +56 -0
- package/dist/basis/constrained_basis.js +90 -0
- package/dist/basis/types.d.ts +1 -0
- package/dist/basis/types.js +2 -0
- package/dist/cell/cell.d.ts +45 -0
- package/dist/cell/cell.js +88 -0
- package/dist/cell/conventional_cell.d.ts +22 -0
- package/dist/cell/conventional_cell.js +83 -0
- package/dist/cell/primitive_cell.d.ts +9 -0
- package/dist/cell/primitive_cell.js +166 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +25 -0
- package/dist/constraints/constraints.d.ts +45 -0
- package/dist/constraints/constraints.js +49 -0
- package/dist/lattice/lattice.d.ts +104 -0
- package/dist/lattice/lattice.js +208 -0
- package/dist/lattice/lattice_bravais.d.ts +59 -0
- package/dist/lattice/lattice_bravais.js +120 -0
- package/dist/lattice/lattice_vectors.d.ts +46 -0
- package/dist/lattice/lattice_vectors.js +98 -0
- package/dist/lattice/reciprocal/lattice_reciprocal.d.ts +75 -0
- package/dist/lattice/reciprocal/lattice_reciprocal.js +148 -0
- package/dist/lattice/reciprocal/paths.d.ts +24 -0
- package/dist/lattice/reciprocal/paths.js +136 -0
- package/dist/lattice/reciprocal/symmetry_points.d.ts +8 -0
- package/dist/lattice/reciprocal/symmetry_points.js +866 -0
- package/dist/lattice/types.d.ts +49 -0
- package/dist/lattice/types.js +127 -0
- package/dist/lattice/unit_cell.d.ts +30 -0
- package/dist/lattice/unit_cell.js +31 -0
- package/dist/made.d.ts +40 -0
- package/dist/made.js +39 -0
- package/dist/material.d.ts +1562 -0
- package/dist/material.js +317 -0
- package/dist/math.d.ts +395 -0
- package/dist/math.js +7 -0
- package/dist/parsers/cif.d.ts +10 -0
- package/dist/parsers/cif.js +21 -0
- package/dist/parsers/errors.d.ts +5 -0
- package/dist/parsers/errors.js +11 -0
- package/dist/parsers/espresso.d.ts +10 -0
- package/dist/parsers/espresso.js +24 -0
- package/dist/parsers/native_format_parsers.d.ts +26 -0
- package/dist/parsers/native_format_parsers.js +52 -0
- package/dist/parsers/parsers.d.ts +13 -0
- package/dist/parsers/parsers.js +17 -0
- package/dist/parsers/poscar.d.ts +31 -0
- package/dist/parsers/poscar.js +180 -0
- package/dist/parsers/xyz.d.ts +62 -0
- package/dist/parsers/xyz.js +167 -0
- package/dist/parsers/xyz_combinatorial_basis.d.ts +64 -0
- package/dist/parsers/xyz_combinatorial_basis.js +241 -0
- package/dist/tools/basis.d.ts +22 -0
- package/dist/tools/basis.js +100 -0
- package/dist/tools/cell.d.ts +9 -0
- package/dist/tools/cell.js +39 -0
- package/dist/tools/index.d.ts +11 -0
- package/dist/tools/index.js +15 -0
- package/dist/tools/material.d.ts +25 -0
- package/dist/tools/material.js +54 -0
- package/dist/tools/supercell.d.ts +22 -0
- package/dist/tools/supercell.js +62 -0
- package/dist/tools/surface.d.ts +10 -0
- package/dist/tools/surface.js +147 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.js +2 -0
- package/package.json +89 -0
- package/pyproject.toml +77 -0
- package/src/js/abstract/array_with_ids.ts +100 -0
- package/src/js/abstract/scalar_with_id.ts +53 -0
- package/src/js/basis/basis.ts +607 -0
- package/src/js/basis/constrained_basis.ts +107 -0
- package/src/js/basis/types.ts +1 -0
- package/src/js/cell/cell.ts +109 -0
- package/src/js/cell/conventional_cell.ts +89 -0
- package/src/js/cell/primitive_cell.ts +189 -0
- package/src/js/constants.js +4 -0
- package/src/js/constraints/constraints.ts +63 -0
- package/src/js/lattice/lattice.ts +229 -0
- package/src/js/lattice/lattice_bravais.ts +170 -0
- package/src/js/lattice/lattice_vectors.ts +126 -0
- package/src/js/lattice/reciprocal/lattice_reciprocal.js +155 -0
- package/src/js/lattice/reciprocal/paths.js +134 -0
- package/src/js/lattice/reciprocal/symmetry_points.ts +886 -0
- package/src/js/lattice/types.ts +142 -0
- package/src/js/lattice/unit_cell.ts +66 -0
- package/src/js/made.js +36 -0
- package/src/js/material.ts +398 -0
- package/src/js/math.js +6 -0
- package/src/js/parsers/cif.js +22 -0
- package/src/js/parsers/errors.js +7 -0
- package/src/js/parsers/espresso.ts +30 -0
- package/src/js/parsers/native_format_parsers.js +51 -0
- package/src/js/parsers/parsers.js +13 -0
- package/src/js/parsers/poscar.ts +201 -0
- package/src/js/parsers/xyz.ts +216 -0
- package/src/js/parsers/xyz_combinatorial_basis.js +243 -0
- package/src/js/tools/basis.js +116 -0
- package/src/js/tools/cell.js +36 -0
- package/src/js/tools/index.js +11 -0
- package/src/js/tools/material.js +60 -0
- package/src/js/tools/supercell.ts +80 -0
- package/src/js/tools/surface.js +176 -0
- package/src/js/types.ts +4 -0
- package/src/py/__init__.py +0 -0
- package/src/py/mat3ra/__init__.py +0 -0
- package/src/py/mat3ra/made/__init__.py +5 -0
- package/tests/.gitattributes +1 -0
- package/tests/fixtures/AsGe-basis.json +3 -0
- package/tests/fixtures/C2H4-translated.json +3 -0
- package/tests/fixtures/C2H4.json +3 -0
- package/tests/fixtures/FeLiSi-basis.json +3 -0
- package/tests/fixtures/FeO.json +3 -0
- package/tests/fixtures/Ge2-basis.json +3 -0
- package/tests/fixtures/Graphene.json +3 -0
- package/tests/fixtures/Graphene.poscar +3 -0
- package/tests/fixtures/H2+H-final.json +3 -0
- package/tests/fixtures/H2+H-image.json +3 -0
- package/tests/fixtures/H2+H-initial.json +3 -0
- package/tests/fixtures/H2O.poscar +3 -0
- package/tests/fixtures/LiFeSi-basis.json +3 -0
- package/tests/fixtures/Na.json +3 -0
- package/tests/fixtures/Na4Cl4-cartesian.json +3 -0
- package/tests/fixtures/Na4Cl4.json +3 -0
- package/tests/fixtures/Na4Cl4.poscar +3 -0
- package/tests/fixtures/Ni-hex.json +3 -0
- package/tests/fixtures/Ni-hex.poscar +3 -0
- package/tests/fixtures/OSi-basis.json +3 -0
- package/tests/fixtures/Si-hex.json +3 -0
- package/tests/fixtures/Si-hex.poscar +3 -0
- package/tests/fixtures/Si-pwscf.in +3 -0
- package/tests/fixtures/Si-slab.json +3 -0
- package/tests/fixtures/Si-supercell.json +3 -0
- package/tests/fixtures/Si.json +3 -0
- package/tests/fixtures/Si2-basis-repeated.json +3 -0
- package/tests/fixtures/Si2-basis.json +3 -0
- package/tests/fixtures/Zr1H23Zr1H1.json +3 -0
- package/tests/fixtures/Zr1H23Zr1H1.poscar +3 -0
- package/tests/fixtures/atomic-constraints.json +3 -0
- package/tests/js/basis/basis.js +221 -0
- package/tests/js/cell/cell.js +21 -0
- package/tests/js/cell/primitive_cell.js +17 -0
- package/tests/js/constraints/constraints.js +27 -0
- package/tests/js/enums.js +40 -0
- package/tests/js/lattice/lattice.js +31 -0
- package/tests/js/lattice/lattice_bravais.js +17 -0
- package/tests/js/lattice/lattice_reciprocal.js +99 -0
- package/tests/js/lattice/lattice_vectors.js +10 -0
- package/tests/js/material.test.js +11 -0
- package/tests/js/parsers/espresso.js +12 -0
- package/tests/js/parsers/native_formats.js +30 -0
- package/tests/js/parsers/poscar.js +21 -0
- package/tests/js/parsers/xyz.js +25 -0
- package/tests/js/parsers/xyz_combinatorial_basis.js +153 -0
- package/tests/js/setup.js +6 -0
- package/tests/js/tools/basis.js +18 -0
- package/tests/js/tools/supercell.js +23 -0
- package/tests/js/tools/surface.js +12 -0
- package/tests/js/utils.js +17 -0
- package/tests/py/__init__.py +0 -0
- package/tests/py/unit/__init__.py +0 -0
- package/tests/py/unit/test_sample.py +10 -0
- package/tsconfig.json +3 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
|
|
3
|
+
import { readFile, readJSONFile } from "./utils";
|
|
4
|
+
|
|
5
|
+
export const TOLERANCE = 1e-3;
|
|
6
|
+
|
|
7
|
+
export const FIXTURES_DIR = path.resolve(__dirname, "../fixtures");
|
|
8
|
+
export const Si = readJSONFile(path.join(FIXTURES_DIR, "Si.json"));
|
|
9
|
+
export const FeO = readJSONFile(path.join(FIXTURES_DIR, "FeO.json"));
|
|
10
|
+
export const Na4Cl4 = readJSONFile(path.join(FIXTURES_DIR, "Na4Cl4.json"));
|
|
11
|
+
export const Na4Cl4Cartesian = readJSONFile(path.join(FIXTURES_DIR, "Na4Cl4-cartesian.json"));
|
|
12
|
+
export const Na4Cl4Poscar = readFile(path.join(FIXTURES_DIR, "Na4Cl4.poscar"));
|
|
13
|
+
export const SiSupercell = readJSONFile(path.join(FIXTURES_DIR, "Si-supercell.json"));
|
|
14
|
+
export const C2H4 = readJSONFile(path.join(FIXTURES_DIR, "C2H4.json"));
|
|
15
|
+
export const C2H4Translated = readJSONFile(path.join(FIXTURES_DIR, "C2H4-translated.json"));
|
|
16
|
+
export const Na = readJSONFile(path.join(FIXTURES_DIR, "Na.json"));
|
|
17
|
+
|
|
18
|
+
export const OSiBasis = readJSONFile(path.join(FIXTURES_DIR, "OSi-basis.json"));
|
|
19
|
+
export const Si2Basis = readJSONFile(path.join(FIXTURES_DIR, "Si2-basis.json"));
|
|
20
|
+
export const Ge2Basis = readJSONFile(path.join(FIXTURES_DIR, "Ge2-basis.json"));
|
|
21
|
+
export const AsGeBasis = readJSONFile(path.join(FIXTURES_DIR, "AsGe-basis.json"));
|
|
22
|
+
export const FeLiSiBasis = readJSONFile(path.join(FIXTURES_DIR, "FeLiSi-basis.json"));
|
|
23
|
+
export const LiFeSiBasis = readJSONFile(path.join(FIXTURES_DIR, "LiFeSi-basis.json"));
|
|
24
|
+
export const atomicConstraints = readJSONFile(path.join(FIXTURES_DIR, "atomic-constraints.json"));
|
|
25
|
+
export const Si2BasisRepeated = readJSONFile(path.join(FIXTURES_DIR, "Si2-basis-repeated.json"));
|
|
26
|
+
export const H2HInitial = readJSONFile(path.join(FIXTURES_DIR, "H2+H-initial.json"));
|
|
27
|
+
export const H2HFinal = readJSONFile(path.join(FIXTURES_DIR, "H2+H-final.json"));
|
|
28
|
+
export const H2HImage = readJSONFile(path.join(FIXTURES_DIR, "H2+H-image.json"));
|
|
29
|
+
export const SiSlab = readJSONFile(path.join(FIXTURES_DIR, "Si-slab.json"));
|
|
30
|
+
export const SiPWSCFInput = readFile(path.join(FIXTURES_DIR, "Si-pwscf.in"));
|
|
31
|
+
|
|
32
|
+
export const Zr1H23Zr1H1 = readJSONFile(path.join(FIXTURES_DIR, "Zr1H23Zr1H1.json"));
|
|
33
|
+
export const Zr1H23Zr1H1Poscar = readFile(path.join(FIXTURES_DIR, "Zr1H23Zr1H1.poscar"));
|
|
34
|
+
export const H2O = readFile(path.join(FIXTURES_DIR, "H2O.poscar"));
|
|
35
|
+
|
|
36
|
+
export const Graphene = readJSONFile(path.join(FIXTURES_DIR, "Graphene.json"));
|
|
37
|
+
export const GraphenePoscar = readFile(path.join(FIXTURES_DIR, "Graphene.poscar"));
|
|
38
|
+
export const NiHex = readJSONFile(path.join(FIXTURES_DIR, "Ni-hex.json"));
|
|
39
|
+
export const NiHexPoscar = readFile(path.join(FIXTURES_DIR, "Ni-hex.poscar"));
|
|
40
|
+
export const SiHex = readJSONFile(path.join(FIXTURES_DIR, "Si-hex.json"));
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
|
|
3
|
+
import { Lattice } from "../../../src/js/lattice/lattice";
|
|
4
|
+
import { Na4Cl4, Si } from "../enums";
|
|
5
|
+
import { assertDeepAlmostEqual } from "../utils";
|
|
6
|
+
|
|
7
|
+
describe("Lattice", () => {
|
|
8
|
+
it("should return lattice cell volume", () => {
|
|
9
|
+
const lattice = new Lattice(Si.lattice);
|
|
10
|
+
expect(lattice.volume).to.be.almost.equal(125);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("should return lattice from vectors", () => {
|
|
14
|
+
const lattice = Lattice.fromVectors(Na4Cl4.lattice.vectors);
|
|
15
|
+
assertDeepAlmostEqual(lattice.toJSON(), Na4Cl4.lattice, ["type"]);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("should return lattice type", () => {
|
|
19
|
+
const lattice = new Lattice(Si.lattice);
|
|
20
|
+
expect(lattice.typeExtended).to.be.equal("TRI_1b");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* hash
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
it("should return lattice hash string", () => {
|
|
28
|
+
const lattice = new Lattice(Na4Cl4.lattice);
|
|
29
|
+
expect(lattice.getHashString()).to.be.equal("5.692;5.692;5.692;90;90;90;");
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
|
|
3
|
+
import { LatticeBravais } from "../../../src/js/lattice/lattice_bravais";
|
|
4
|
+
import { Na4Cl4 } from "../enums";
|
|
5
|
+
import { assertDeepAlmostEqual } from "../utils";
|
|
6
|
+
|
|
7
|
+
describe("Lattice Bravais", () => {
|
|
8
|
+
it("should return lattice bravais from vectors", () => {
|
|
9
|
+
const lattice = LatticeBravais.fromVectors(Na4Cl4.lattice.vectors);
|
|
10
|
+
assertDeepAlmostEqual(lattice.toJSON(), Na4Cl4.lattice, ["type", "vectors"]);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("should return a list of editable keys", () => {
|
|
14
|
+
const lattice = new LatticeBravais(Na4Cl4.lattice);
|
|
15
|
+
expect(lattice.editables).to.be.deep.equal({ a: true });
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
|
|
3
|
+
import { ReciprocalLattice } from "../../../src/js/lattice/reciprocal/lattice_reciprocal";
|
|
4
|
+
import { Na4Cl4, Si, SiSlab } from "../enums";
|
|
5
|
+
import { assertDeepAlmostEqual } from "../utils";
|
|
6
|
+
|
|
7
|
+
describe("Lattice Reciprocal", () => {
|
|
8
|
+
it("should extract kpoint path", () => {
|
|
9
|
+
const lattice = new ReciprocalLattice(Na4Cl4.lattice);
|
|
10
|
+
const expectedPath = [
|
|
11
|
+
{
|
|
12
|
+
point: "Г",
|
|
13
|
+
steps: 0,
|
|
14
|
+
coordinates: [0, 0, 0],
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
point: "R",
|
|
18
|
+
steps: 1,
|
|
19
|
+
coordinates: [0.5, 0.5, 0.5],
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
const actualPath = lattice.extractKpointPath([
|
|
23
|
+
[0, 0, 0],
|
|
24
|
+
[0.5, 0.5, 0.5],
|
|
25
|
+
]);
|
|
26
|
+
assertDeepAlmostEqual(expectedPath, actualPath);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("should return cartesian coordinates of a point", () => {
|
|
30
|
+
const lattice = new ReciprocalLattice(Na4Cl4.lattice);
|
|
31
|
+
const expectedCoordinates = [0.5, 0.5, 0.5];
|
|
32
|
+
const actualCoordinates = lattice.getCartesianCoordinates([0.5, 0.5, 0.5]);
|
|
33
|
+
assertDeepAlmostEqual(actualCoordinates, expectedCoordinates);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("should return reciprocal vectors", () => {
|
|
37
|
+
const lattice = new ReciprocalLattice(Si.lattice);
|
|
38
|
+
const actualVectors = lattice.reciprocalVectors;
|
|
39
|
+
const expectedVectors = [
|
|
40
|
+
[1, 0, 0],
|
|
41
|
+
[0, 1, 0],
|
|
42
|
+
[0, 0, 1],
|
|
43
|
+
];
|
|
44
|
+
assertDeepAlmostEqual(actualVectors, expectedVectors);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("should extract symmetry points", () => {
|
|
48
|
+
const lattice = new ReciprocalLattice(Na4Cl4.lattice);
|
|
49
|
+
const actualPoints = lattice.symmetryPoints;
|
|
50
|
+
const expectedPoints = [
|
|
51
|
+
{
|
|
52
|
+
point: "Г",
|
|
53
|
+
coordinates: [0, 0, 0],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
point: "R",
|
|
57
|
+
coordinates: [0.5, 0.5, 0.5],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
point: "X",
|
|
61
|
+
coordinates: [0, 0.5, 0],
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
point: "M",
|
|
65
|
+
coordinates: [0.5, 0.5, 0],
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
assertDeepAlmostEqual(actualPoints, expectedPoints);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("should calculate k-grid dimensions based on number of points", () => {
|
|
72
|
+
const lattice = new ReciprocalLattice(SiSlab.lattice);
|
|
73
|
+
const dimensions = lattice.getDimensionsFromPointsCount(500);
|
|
74
|
+
const expectedDimensions = [12, 12, 4];
|
|
75
|
+
assertDeepAlmostEqual(dimensions, expectedDimensions);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("should calculate k-grid dimensions based on spacing in cartesian units", () => {
|
|
79
|
+
const lattice = new ReciprocalLattice(SiSlab.lattice);
|
|
80
|
+
const dimensions = lattice.getDimensionsFromSpacing(0.09);
|
|
81
|
+
const expectedDimensions = [12, 12, 4];
|
|
82
|
+
assertDeepAlmostEqual(dimensions, expectedDimensions);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("should calculate k-grid dimensions based on spacing in 1/angstrom", () => {
|
|
86
|
+
const lattice = new ReciprocalLattice(SiSlab.lattice);
|
|
87
|
+
const dimensions = lattice.getDimensionsFromSpacing(0.11, "angstrom");
|
|
88
|
+
const expectedDimensions = [12, 12, 4];
|
|
89
|
+
assertDeepAlmostEqual(dimensions, expectedDimensions);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("should calculate average spacing in 1/angstrom based on k-grid dimensions", () => {
|
|
93
|
+
const lattice = new ReciprocalLattice(SiSlab.lattice);
|
|
94
|
+
const dimensions = [12, 12, 4];
|
|
95
|
+
const expectedSpacing = 0.1047;
|
|
96
|
+
const spacing = lattice.getSpacingFromDimensions(dimensions, "angstrom");
|
|
97
|
+
expect(spacing).to.be.almost(expectedSpacing, 1e-4);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LatticeVectors } from "../../../src/js/lattice/lattice_vectors";
|
|
2
|
+
import { Na4Cl4 } from "../enums";
|
|
3
|
+
import { assertDeepAlmostEqual } from "../utils";
|
|
4
|
+
|
|
5
|
+
describe("Lattice Vectors", () => {
|
|
6
|
+
it("should return lattice from bravais", () => {
|
|
7
|
+
const lattice = LatticeVectors.fromBravais(Na4Cl4.lattice);
|
|
8
|
+
assertDeepAlmostEqual(lattice.toJSON(), Na4Cl4.lattice.vectors, ["type", "vectors"]);
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
|
|
3
|
+
import { Material } from "../../src/js/material";
|
|
4
|
+
import { Na4Cl4 } from "./enums";
|
|
5
|
+
|
|
6
|
+
describe("Material", () => {
|
|
7
|
+
it("should return unique elements", () => {
|
|
8
|
+
const material = new Material(Na4Cl4);
|
|
9
|
+
expect(material.uniqueElements).to.have.same.members(["Na", "Cl"]);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
|
|
3
|
+
import { Material } from "../../../src/js/material";
|
|
4
|
+
import parsers from "../../../src/js/parsers/parsers";
|
|
5
|
+
import { Si, SiPWSCFInput } from "../enums";
|
|
6
|
+
|
|
7
|
+
describe("Parsers:Espresso", () => {
|
|
8
|
+
it("should return textual representation of a material according to QE pw.x input format", () => {
|
|
9
|
+
const material = new Material(Si);
|
|
10
|
+
expect(parsers.espresso.toEspressoFormat(material)).to.be.equal(SiPWSCFInput);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
|
|
3
|
+
import nativeFormatParsers from "../../../src/js/parsers/native_format_parsers";
|
|
4
|
+
import { Graphene, GraphenePoscar, NiHex, NiHexPoscar } from "../enums";
|
|
5
|
+
import { assertDeepAlmostEqual } from "../utils";
|
|
6
|
+
|
|
7
|
+
describe("Parsers.NativeFormat", () => {
|
|
8
|
+
it("should return a material config for graphene from a json", () => {
|
|
9
|
+
const json = JSON.stringify(Graphene);
|
|
10
|
+
expect(nativeFormatParsers.convertFromNativeFormat(json)).to.deep.equal(Graphene);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("should return a material config for graphene from a poscar", () => {
|
|
14
|
+
const poscar = GraphenePoscar;
|
|
15
|
+
const config = nativeFormatParsers.convertFromNativeFormat(poscar);
|
|
16
|
+
expect(config).to.be.deep.almost.equal(Graphene);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("should return a material config for Ni hex from a poscar", () => {
|
|
20
|
+
const poscar = NiHexPoscar;
|
|
21
|
+
const config = nativeFormatParsers.convertFromNativeFormat(poscar);
|
|
22
|
+
assertDeepAlmostEqual(config, NiHex, ["lattice"]);
|
|
23
|
+
assertDeepAlmostEqual(config.lattice, NiHex.lattice, ["type"]); // to omit "lattice.type" property
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("should throw an error for unknown format", () => {
|
|
27
|
+
const text = "A\n snippet from an unknown format";
|
|
28
|
+
expect(() => nativeFormatParsers.convertFromNativeFormat(text)).to.throw("Unknown format");
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
|
|
3
|
+
import { Material } from "../../../src/js/material";
|
|
4
|
+
import { atomsCount } from "../../../src/js/parsers/poscar";
|
|
5
|
+
import { H2O, Na4Cl4, Na4Cl4Poscar, Zr1H23Zr1H1, Zr1H23Zr1H1Poscar } from "../enums";
|
|
6
|
+
|
|
7
|
+
describe("Parsers.POSCAR", () => {
|
|
8
|
+
it("should return a valid poscar", () => {
|
|
9
|
+
const material = new Material(Na4Cl4);
|
|
10
|
+
expect(`${material.getAsPOSCAR()}\n`).to.be.equal(Na4Cl4Poscar);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("should return poscar elements line according to id in basis, duplicate entries separate", () => {
|
|
14
|
+
const material = new Material(Zr1H23Zr1H1);
|
|
15
|
+
expect(`${material.getAsPOSCAR()}\n`).to.be.equal(Zr1H23Zr1H1Poscar);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("should return the number of atoms for a molecule in a poscar file", () => {
|
|
19
|
+
expect(atomsCount(H2O)).to.be.equal(3);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import parsers from "../../../src/js/parsers/parsers";
|
|
2
|
+
import { FeO, Si } from "../enums";
|
|
3
|
+
import { assertDeepAlmostEqual } from "../utils";
|
|
4
|
+
|
|
5
|
+
describe("Parsers:XYZ", () => {
|
|
6
|
+
it("should extract basis from XYZ text", () => {
|
|
7
|
+
const text = "Si 0 0 0 \n Si 0.25 0.25 0.25";
|
|
8
|
+
assertDeepAlmostEqual(parsers.xyz.toBasisConfig(text), Si.basis, [
|
|
9
|
+
"constraints",
|
|
10
|
+
"cell",
|
|
11
|
+
"units",
|
|
12
|
+
]);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
describe("Parsers:XYZ", () => {
|
|
17
|
+
it("should extract basis from XYZ text with atomic labels", () => {
|
|
18
|
+
const text =
|
|
19
|
+
"Fe1 0.00 0.00 0.00 1 1 1\n" +
|
|
20
|
+
"Fe2 0.50 0.50 0.50 1 1 1\n" +
|
|
21
|
+
"O 0.25 0.25 0.25 1 1 1\n" +
|
|
22
|
+
"O 0.75 0.75 0.75 1 1 1";
|
|
23
|
+
assertDeepAlmostEqual(parsers.xyz.toBasisConfig(text), FeO.basis, ["cell", "units"]);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
|
|
3
|
+
import { Basis } from "../../../src/js/basis/basis";
|
|
4
|
+
import { CombinatorialBasis } from "../../../src/js/parsers/xyz_combinatorial_basis";
|
|
5
|
+
import { AsGeBasis, FeLiSiBasis, Ge2Basis, OSiBasis, Si2Basis } from "../enums";
|
|
6
|
+
|
|
7
|
+
describe("Parsers:CombinatorialBasis", () => {
|
|
8
|
+
it("toBasisConfig", () => {
|
|
9
|
+
// eslint-disable-next-line new-cap
|
|
10
|
+
const basisConfig2 = CombinatorialBasis.toBasisConfig([
|
|
11
|
+
{
|
|
12
|
+
element: "Si",
|
|
13
|
+
coordinates: [0, 0, 0],
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
element: "Li",
|
|
17
|
+
coordinates: [0.3, 0.3, 0.3],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
element: "Fe",
|
|
21
|
+
coordinates: [0.5, 0.5, 0.5],
|
|
22
|
+
},
|
|
23
|
+
]);
|
|
24
|
+
const [basis1, basis2] = [new Basis(FeLiSiBasis), new Basis(basisConfig2)];
|
|
25
|
+
|
|
26
|
+
expect(basis1.isEqualTo(basis2)).to.equal(true);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("Regular XYZ", () => {
|
|
30
|
+
const xyz = `
|
|
31
|
+
Si 0.0 0.0 0.0
|
|
32
|
+
O 0.5 0.5 0.5
|
|
33
|
+
`;
|
|
34
|
+
const basis = new CombinatorialBasis(xyz);
|
|
35
|
+
expect(basis.uniqueElements).deep.equal(["O", "Si"]);
|
|
36
|
+
const basis1 = new Basis(basis.allBasisConfigs[0]);
|
|
37
|
+
const basis2 = new Basis(OSiBasis);
|
|
38
|
+
expect(basis1.isEqualTo(basis2)).to.equal(true);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("Permutation XYZ", () => {
|
|
42
|
+
const permutation = `
|
|
43
|
+
Si/Ge/As 0.0 0.0 0.0
|
|
44
|
+
Si/Ge 0.5 0.5 0.5
|
|
45
|
+
`;
|
|
46
|
+
const basis = new CombinatorialBasis(permutation);
|
|
47
|
+
expect(basis.uniqueElements).deep.equal(["As", "Ge", "Si"]);
|
|
48
|
+
const basisList1 = basis.allBasisConfigs.map((c) => new Basis(c));
|
|
49
|
+
const basisList2 = [Si2Basis, Ge2Basis, AsGeBasis].map((c) => new Basis(c));
|
|
50
|
+
|
|
51
|
+
basisList1.forEach((basis1) => {
|
|
52
|
+
const condition = basisList2
|
|
53
|
+
.map((basis2) => basis2.isEqualTo(basis1))
|
|
54
|
+
.reduce((a, b) => a || b);
|
|
55
|
+
expect(condition).to.equal(true);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("Combination XYZ", () => {
|
|
60
|
+
const combination = `
|
|
61
|
+
Si,Ge,As 0.0 0.0 0.0
|
|
62
|
+
Si,Ge 0.5 0.5 0.5
|
|
63
|
+
`;
|
|
64
|
+
const basis = new CombinatorialBasis(combination);
|
|
65
|
+
expect(basis.uniqueElements).deep.equal(["As", "Ge", "Si"]);
|
|
66
|
+
|
|
67
|
+
const basisList1 = basis.allBasisConfigs.map((c) => new Basis(c));
|
|
68
|
+
expect(basisList1.length).to.equal(6);
|
|
69
|
+
|
|
70
|
+
const basisList2 = [
|
|
71
|
+
CombinatorialBasis.toBasisConfig([
|
|
72
|
+
{
|
|
73
|
+
element: "Si",
|
|
74
|
+
coordinates: [0, 0, 0],
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
element: "Si",
|
|
78
|
+
coordinates: [0.5, 0.5, 0.5],
|
|
79
|
+
},
|
|
80
|
+
]),
|
|
81
|
+
CombinatorialBasis.toBasisConfig([
|
|
82
|
+
{
|
|
83
|
+
element: "Si",
|
|
84
|
+
coordinates: [0, 0, 0],
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
element: "Ge",
|
|
88
|
+
coordinates: [0.5, 0.5, 0.5],
|
|
89
|
+
},
|
|
90
|
+
]),
|
|
91
|
+
CombinatorialBasis.toBasisConfig([
|
|
92
|
+
{
|
|
93
|
+
element: "Ge",
|
|
94
|
+
coordinates: [0, 0, 0],
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
element: "Si",
|
|
98
|
+
coordinates: [0.5, 0.5, 0.5],
|
|
99
|
+
},
|
|
100
|
+
]),
|
|
101
|
+
CombinatorialBasis.toBasisConfig([
|
|
102
|
+
{
|
|
103
|
+
element: "Ge",
|
|
104
|
+
coordinates: [0, 0, 0],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
element: "Ge",
|
|
108
|
+
coordinates: [0.5, 0.5, 0.5],
|
|
109
|
+
},
|
|
110
|
+
]),
|
|
111
|
+
CombinatorialBasis.toBasisConfig([
|
|
112
|
+
{
|
|
113
|
+
element: "As",
|
|
114
|
+
coordinates: [0, 0, 0],
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
element: "Si",
|
|
118
|
+
coordinates: [0.5, 0.5, 0.5],
|
|
119
|
+
},
|
|
120
|
+
]),
|
|
121
|
+
CombinatorialBasis.toBasisConfig([
|
|
122
|
+
{
|
|
123
|
+
element: "As",
|
|
124
|
+
coordinates: [0, 0, 0],
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
element: "Ge",
|
|
128
|
+
coordinates: [0.5, 0.5, 0.5],
|
|
129
|
+
},
|
|
130
|
+
]),
|
|
131
|
+
].map((c) => new Basis(c));
|
|
132
|
+
|
|
133
|
+
basisList1.forEach((basis1) => {
|
|
134
|
+
const condition = basisList2
|
|
135
|
+
.map((basis2) => basis2.isEqualTo(basis1))
|
|
136
|
+
.reduce((a, b) => a || b);
|
|
137
|
+
expect(condition).to.equal(true);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("Mixing combination and permutation should fail", () => {
|
|
142
|
+
const mixedInMultipleLines = `
|
|
143
|
+
Si/Ge/As 0.0 0.0 0.0\n
|
|
144
|
+
Si,Ge 0.5 0.5 0.5
|
|
145
|
+
`;
|
|
146
|
+
const mixedInOneLine = `
|
|
147
|
+
Si/Ge,As 0.0 0.0 0.0
|
|
148
|
+
`;
|
|
149
|
+
// Wrapping into function as recommended in: http://chaijs.com/api/bdd/
|
|
150
|
+
expect(() => new CombinatorialBasis(mixedInMultipleLines)).to.throw();
|
|
151
|
+
expect(() => new CombinatorialBasis(mixedInOneLine)).to.throw();
|
|
152
|
+
});
|
|
153
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Basis } from "../../../src/js/basis/basis";
|
|
2
|
+
import tools from "../../../src/js/tools";
|
|
3
|
+
import { H2HFinal, H2HImage, H2HInitial, Si2Basis, Si2BasisRepeated } from "../enums";
|
|
4
|
+
import { assertDeepAlmostEqual } from "../utils";
|
|
5
|
+
|
|
6
|
+
describe("Tools:Basis", () => {
|
|
7
|
+
it("should return a repeated basis", () => {
|
|
8
|
+
const b = new Basis(Si2Basis);
|
|
9
|
+
assertDeepAlmostEqual(Si2BasisRepeated, tools.basis.repeat(b, [2, 1, 1]).toJSON());
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("should return interpolated basises", () => {
|
|
13
|
+
const finalBasis = new Basis(H2HFinal.basis);
|
|
14
|
+
const initialBasis = new Basis(H2HInitial.basis);
|
|
15
|
+
const images = tools.basis.interpolate(initialBasis, finalBasis, 1);
|
|
16
|
+
assertDeepAlmostEqual(H2HImage.basis, images[0].toJSON());
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
|
|
3
|
+
import { Basis } from "../../../src/js/basis/basis";
|
|
4
|
+
import { Made } from "../../../src/js/made";
|
|
5
|
+
import { Material } from "../../../src/js/material";
|
|
6
|
+
import { Si, SiSupercell } from "../enums";
|
|
7
|
+
|
|
8
|
+
describe("Tools:Supercell", () => {
|
|
9
|
+
it("should generate supercell", () => {
|
|
10
|
+
const material = new Material(Si);
|
|
11
|
+
const supercell = Made.tools.supercell.generateConfig(material, [
|
|
12
|
+
[2, 0, 0],
|
|
13
|
+
[0, 2, 0],
|
|
14
|
+
[0, 0, 2],
|
|
15
|
+
]);
|
|
16
|
+
expect(supercell.lattice).deep.equal(SiSupercell.lattice, "lattices are not equal");
|
|
17
|
+
|
|
18
|
+
const basis1 = new Basis(SiSupercell.basis);
|
|
19
|
+
const basis2 = new Basis(supercell.basis);
|
|
20
|
+
|
|
21
|
+
expect(basis1.isEqualTo(basis2)).to.be.equal(true);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Material } from "../../../src/js/material";
|
|
2
|
+
import tools from "../../../src/js/tools";
|
|
3
|
+
import { Si, SiSlab } from "../enums";
|
|
4
|
+
import { assertDeepAlmostEqual } from "../utils";
|
|
5
|
+
|
|
6
|
+
describe("Tools:Surface", () => {
|
|
7
|
+
it("should return slab", () => {
|
|
8
|
+
const material = new Material(Si);
|
|
9
|
+
const slab = tools.surface.generateConfig(material, [1, 0, 0], 3, 1, 1);
|
|
10
|
+
assertDeepAlmostEqual(SiSlab, slab);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import _ from "underscore";
|
|
4
|
+
|
|
5
|
+
export function readFile(filePath, coding = "utf8") {
|
|
6
|
+
return fs.readFileSync(filePath, coding);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function readJSONFile(filePath) {
|
|
10
|
+
return JSON.parse(readFile(filePath));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function assertDeepAlmostEqual(leftHandOperand, rightHandOperand, excludedKeys = []) {
|
|
14
|
+
expect(_.omit(leftHandOperand, excludedKeys)).to.be.deep.almost.equal(
|
|
15
|
+
_.omit(rightHandOperand, excludedKeys),
|
|
16
|
+
);
|
|
17
|
+
}
|
|
File without changes
|
|
File without changes
|
package/tsconfig.json
ADDED