@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,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Lattice = exports.nonPeriodicLatticeScalingFactor = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const underscore_1 = __importDefault(require("underscore"));
|
|
9
|
+
const cell_1 = require("../cell/cell");
|
|
10
|
+
const primitive_cell_1 = require("../cell/primitive_cell");
|
|
11
|
+
const constants_1 = require("../constants");
|
|
12
|
+
const math_1 = __importDefault(require("../math"));
|
|
13
|
+
const lattice_bravais_1 = require("./lattice_bravais");
|
|
14
|
+
const lattice_vectors_1 = require("./lattice_vectors");
|
|
15
|
+
const types_1 = require("./types");
|
|
16
|
+
const unit_cell_1 = require("./unit_cell");
|
|
17
|
+
/**
|
|
18
|
+
* Scaling factor used to calculate the new lattice size for non-periodic systems.
|
|
19
|
+
* The scaling factor ensures that a non-periodic structure will have have a lattice greater than the structures size.
|
|
20
|
+
*/
|
|
21
|
+
exports.nonPeriodicLatticeScalingFactor = 2.0;
|
|
22
|
+
/*
|
|
23
|
+
* Container class for crystal lattice and associated methods.
|
|
24
|
+
* Follows Bravais convention for lattice types and contains lattice vectors within.
|
|
25
|
+
* Units for lattice vector coordinates are "angstroms", and "degrees" for the corresponding angles.
|
|
26
|
+
*/
|
|
27
|
+
class Lattice extends lattice_bravais_1.LatticeBravais {
|
|
28
|
+
/**
|
|
29
|
+
* Create a Lattice class from a config object.
|
|
30
|
+
* @param {Object} config - Config object. See LatticeVectors.fromBravais.
|
|
31
|
+
*/
|
|
32
|
+
constructor(config = {}) {
|
|
33
|
+
super(config);
|
|
34
|
+
this.vectors = lattice_vectors_1.LatticeVectors.fromBravais(config);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create a Lattice class from a list of vectors.
|
|
38
|
+
* @param {Object} config - Config object. See LatticeBravais.fromVectors.
|
|
39
|
+
*/
|
|
40
|
+
static fromVectors(config) {
|
|
41
|
+
return new Lattice(lattice_bravais_1.LatticeBravais.fromVectors(config).toJSON());
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Serialize class instance to JSON.
|
|
45
|
+
* @example As below:
|
|
46
|
+
{
|
|
47
|
+
"a" : 3.867,
|
|
48
|
+
"b" : 3.867,
|
|
49
|
+
"c" : 3.867,
|
|
50
|
+
"alpha" : 60,
|
|
51
|
+
"beta" : 60,
|
|
52
|
+
"gamma" : 60,
|
|
53
|
+
"units" : {
|
|
54
|
+
"length" : "angstrom",
|
|
55
|
+
"angle" : "degree"
|
|
56
|
+
},
|
|
57
|
+
"type" : "FCC",
|
|
58
|
+
"vectors" : {
|
|
59
|
+
"a" : [
|
|
60
|
+
3.34892,
|
|
61
|
+
0,
|
|
62
|
+
1.9335
|
|
63
|
+
],
|
|
64
|
+
"b" : [
|
|
65
|
+
1.116307,
|
|
66
|
+
3.157392,
|
|
67
|
+
1.9335
|
|
68
|
+
],
|
|
69
|
+
"c" : [
|
|
70
|
+
0,
|
|
71
|
+
0,
|
|
72
|
+
3.867
|
|
73
|
+
],
|
|
74
|
+
"alat" : 1,
|
|
75
|
+
"units" : "angstrom"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
*/
|
|
79
|
+
toJSON(skipRounding = false) {
|
|
80
|
+
const round = skipRounding ? (x) => x : Lattice._roundValue; // round values by default
|
|
81
|
+
return {
|
|
82
|
+
a: round(this.a),
|
|
83
|
+
b: round(this.b),
|
|
84
|
+
c: round(this.c),
|
|
85
|
+
alpha: round(this.alpha),
|
|
86
|
+
beta: round(this.beta),
|
|
87
|
+
gamma: round(this.gamma),
|
|
88
|
+
units: {
|
|
89
|
+
length: this.units.length,
|
|
90
|
+
angle: this.units.angle,
|
|
91
|
+
},
|
|
92
|
+
type: this.type,
|
|
93
|
+
vectors: this.vectors.toJSON(),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
clone(extraContext) {
|
|
97
|
+
return new this.constructor({ ...this.toJSON(), ...extraContext });
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get lattice vectors as a nested array
|
|
101
|
+
*/
|
|
102
|
+
get vectorArrays() {
|
|
103
|
+
return this.vectors.vectorArrays;
|
|
104
|
+
}
|
|
105
|
+
get Cell() {
|
|
106
|
+
return new cell_1.Cell(this.vectorArrays);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get a short label for the type of the lattice, eg. "MCLC".
|
|
110
|
+
*/
|
|
111
|
+
get typeLabel() {
|
|
112
|
+
return lodash_1.default.get(types_1.LATTICE_TYPE_CONFIGS.find((c) => c.code === this.type), "label", "Unknown");
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get a short label for the extended type of the lattice, eg. "MCLC-5".
|
|
116
|
+
*/
|
|
117
|
+
get typeExtended() {
|
|
118
|
+
const { a, b, c, alpha, beta, gamma, type } = this;
|
|
119
|
+
const cosAlpha = math_1.default.cos((alpha / 180) * math_1.default.PI);
|
|
120
|
+
switch (type) {
|
|
121
|
+
case "BCT":
|
|
122
|
+
return c < a ? "BCT-1" : "BCT-2";
|
|
123
|
+
case "ORCF":
|
|
124
|
+
if (1 / (a * a) >= 1 / (b * b) + 1 / (c * c)) {
|
|
125
|
+
return "ORCF-1";
|
|
126
|
+
}
|
|
127
|
+
return "ORCF-2";
|
|
128
|
+
case "RHL":
|
|
129
|
+
return cosAlpha > 0 ? "RHL-1" : "RHL-2";
|
|
130
|
+
case "MCLC":
|
|
131
|
+
if (gamma >= 90) {
|
|
132
|
+
// MCLC-1,2
|
|
133
|
+
return "MCLC-1";
|
|
134
|
+
}
|
|
135
|
+
if ((b / c) * cosAlpha + ((b * b) / (a * a)) * (1 - cosAlpha * cosAlpha) <= 1) {
|
|
136
|
+
// MCLC-3,4
|
|
137
|
+
return "MCLC-3";
|
|
138
|
+
}
|
|
139
|
+
return "MCLC-5";
|
|
140
|
+
case "TRI":
|
|
141
|
+
if (alpha > 90 && beta > 90 && gamma >= 90) {
|
|
142
|
+
// TRI-1a,2a
|
|
143
|
+
return "TRI_1a";
|
|
144
|
+
}
|
|
145
|
+
return "TRI_1b";
|
|
146
|
+
default:
|
|
147
|
+
return type;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Calculate the volume of the lattice cell.
|
|
152
|
+
*/
|
|
153
|
+
get volume() {
|
|
154
|
+
return math_1.default.abs(math_1.default.det(this.vectorArrays));
|
|
155
|
+
}
|
|
156
|
+
/*
|
|
157
|
+
* Returns a "default" primitive lattice by type, with lattice parameters scaled by the length of "a",
|
|
158
|
+
* @param latticeConfig {Object} LatticeBravais config (see constructor)
|
|
159
|
+
*/
|
|
160
|
+
static getDefaultPrimitiveLatticeConfigByType(latticeConfig) {
|
|
161
|
+
const f_ = Lattice._roundValue;
|
|
162
|
+
// construct new primitive cell using lattice parameters and skip rounding the vectors
|
|
163
|
+
const pCell = (0, primitive_cell_1.primitiveCell)(latticeConfig, true);
|
|
164
|
+
// create new lattice from primitive cell
|
|
165
|
+
const newLattice = { ...Lattice.fromVectorArrays(pCell, latticeConfig.type) };
|
|
166
|
+
// preserve the new type and scale back the lattice parameters
|
|
167
|
+
const k = latticeConfig.a / newLattice.a;
|
|
168
|
+
return Object.assign(newLattice, {
|
|
169
|
+
a: f_(newLattice.a * k),
|
|
170
|
+
b: f_(newLattice.b * k),
|
|
171
|
+
c: f_(newLattice.c * k),
|
|
172
|
+
alpha: f_(newLattice.alpha),
|
|
173
|
+
beta: f_(newLattice.beta),
|
|
174
|
+
gamma: f_(newLattice.gamma),
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
// TODO: remove
|
|
178
|
+
get unitCell() {
|
|
179
|
+
const vectors = [...underscore_1.default.flatten(this.vectorArrays), this.units.length];
|
|
180
|
+
return new unit_cell_1.UnitCell(vectors);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Returns a string further used for the calculation of an unique hash.
|
|
184
|
+
* @param isScaled - Whether to scale the vectors by the length of the first vector initially.
|
|
185
|
+
*/
|
|
186
|
+
getHashString(isScaled = false) {
|
|
187
|
+
// lattice vectors must be measured in angstroms
|
|
188
|
+
const scaleK = isScaled ? this.a : 1;
|
|
189
|
+
const scaledLattice = {
|
|
190
|
+
...this,
|
|
191
|
+
a: this.a / scaleK,
|
|
192
|
+
b: this.b / scaleK,
|
|
193
|
+
c: this.c / scaleK,
|
|
194
|
+
};
|
|
195
|
+
// form lattice string
|
|
196
|
+
return `${[
|
|
197
|
+
scaledLattice.a,
|
|
198
|
+
scaledLattice.b,
|
|
199
|
+
scaledLattice.c,
|
|
200
|
+
scaledLattice.alpha,
|
|
201
|
+
scaledLattice.beta,
|
|
202
|
+
scaledLattice.gamma,
|
|
203
|
+
]
|
|
204
|
+
.map((x) => math_1.default.round(x, constants_1.HASH_TOLERANCE))
|
|
205
|
+
.join(";")};`;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
exports.Lattice = Lattice;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { LatticeImplicitSchema, LatticeTypeSchema } from "@mat3ra/esse/lib/js/types";
|
|
2
|
+
import { Vector, VectorsAsArray } from "./types";
|
|
3
|
+
export type Units = Required<LatticeImplicitSchema>["units"];
|
|
4
|
+
export interface FromVectorsProps {
|
|
5
|
+
a: Vector;
|
|
6
|
+
b: Vector;
|
|
7
|
+
c: Vector;
|
|
8
|
+
alat?: number;
|
|
9
|
+
units?: Units["length"];
|
|
10
|
+
type?: LatticeTypeSchema;
|
|
11
|
+
skipRounding?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare class LatticeBravais implements LatticeImplicitSchema {
|
|
14
|
+
a: number;
|
|
15
|
+
b: number;
|
|
16
|
+
c: number;
|
|
17
|
+
alpha: number;
|
|
18
|
+
beta: number;
|
|
19
|
+
gamma: number;
|
|
20
|
+
units: Units;
|
|
21
|
+
type: LatticeImplicitSchema["type"];
|
|
22
|
+
/**
|
|
23
|
+
* Create a Bravais lattice.
|
|
24
|
+
*/
|
|
25
|
+
constructor(config: Partial<LatticeImplicitSchema>);
|
|
26
|
+
static _roundValue(x: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* Create a Bravais lattice from vectors.
|
|
29
|
+
*/
|
|
30
|
+
static fromVectors({ a, b, c, alat, units, type, skipRounding, }: FromVectorsProps): LatticeBravais;
|
|
31
|
+
/**
|
|
32
|
+
* See fromVectors above.
|
|
33
|
+
*/
|
|
34
|
+
static fromVectorArrays(array: VectorsAsArray, type: LatticeTypeSchema, skipRounding?: boolean): LatticeBravais;
|
|
35
|
+
/**
|
|
36
|
+
* Get the list of editable keys (eg. 'a', 'alpha') for the current lattice.
|
|
37
|
+
* @return {Object}
|
|
38
|
+
* @example {a: true, b: false, c: false, alpha: true, beta: false, gamma: false}
|
|
39
|
+
*/
|
|
40
|
+
get editables(): {};
|
|
41
|
+
/**
|
|
42
|
+
* Serialize class instance to JSON.
|
|
43
|
+
* @example As below:
|
|
44
|
+
{
|
|
45
|
+
"a" : 3.867,
|
|
46
|
+
"b" : 3.867,
|
|
47
|
+
"c" : 3.867,
|
|
48
|
+
"alpha" : 60,
|
|
49
|
+
"beta" : 60,
|
|
50
|
+
"gamma" : 60,
|
|
51
|
+
"units" : {
|
|
52
|
+
"length" : "angstrom",
|
|
53
|
+
"angle" : "degree"
|
|
54
|
+
},
|
|
55
|
+
"type" : "FCC"
|
|
56
|
+
}
|
|
57
|
+
*/
|
|
58
|
+
toJSON(): LatticeImplicitSchema;
|
|
59
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LatticeBravais = void 0;
|
|
7
|
+
const constants_1 = __importDefault(require("../constants"));
|
|
8
|
+
const math_1 = __importDefault(require("../math"));
|
|
9
|
+
const types_1 = require("./types");
|
|
10
|
+
/*
|
|
11
|
+
* @summary: class that holds parameters of a Bravais Lattice: a, b, c, alpha, beta, gamma + corresponding units.
|
|
12
|
+
* When stored as class variables units for lengths are always "angstrom"s, angle - "degree"s
|
|
13
|
+
*/
|
|
14
|
+
class LatticeBravais {
|
|
15
|
+
/**
|
|
16
|
+
* Create a Bravais lattice.
|
|
17
|
+
*/
|
|
18
|
+
constructor(config) {
|
|
19
|
+
const { a = 1, // default lattice is cubic with unity in edge sizes
|
|
20
|
+
b = a, c = a, alpha = 90, beta = alpha, gamma = alpha,
|
|
21
|
+
// if we do not know what lattice type this is => set to TRI
|
|
22
|
+
type = "TRI", units = {
|
|
23
|
+
length: "angstrom",
|
|
24
|
+
angle: "degree",
|
|
25
|
+
}, } = config;
|
|
26
|
+
const k = constants_1.default.units.bohr === units.length ? constants_1.default.coefficients.BOHR_TO_ANGSTROM : 1;
|
|
27
|
+
this.a = a * k;
|
|
28
|
+
this.b = b * k;
|
|
29
|
+
this.c = c * k;
|
|
30
|
+
this.alpha = alpha;
|
|
31
|
+
this.beta = beta;
|
|
32
|
+
this.gamma = gamma;
|
|
33
|
+
this.type = type;
|
|
34
|
+
this.units = units;
|
|
35
|
+
}
|
|
36
|
+
static _roundValue(x) {
|
|
37
|
+
return math_1.default.precise(math_1.default.roundToZero(x));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Create a Bravais lattice from vectors.
|
|
41
|
+
*/
|
|
42
|
+
static fromVectors({ a, b, c, alat = 1, units = "angstrom", type = "TRI", skipRounding = false, }) {
|
|
43
|
+
const roundValue = skipRounding ? (x) => x : this._roundValue;
|
|
44
|
+
return new this.prototype.constructor({
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
a: roundValue(math_1.default.vlen(a) * alat),
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
b: roundValue(math_1.default.vlen(b) * alat),
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
c: roundValue(math_1.default.vlen(c) * alat),
|
|
51
|
+
alpha: roundValue(math_1.default.angle(b, c, "deg")),
|
|
52
|
+
beta: roundValue(math_1.default.angle(a, c, "deg")),
|
|
53
|
+
gamma: roundValue(math_1.default.angle(a, b, "deg")),
|
|
54
|
+
// initially we do not know what lattice type this is => set to TRI
|
|
55
|
+
type,
|
|
56
|
+
units: {
|
|
57
|
+
length: units,
|
|
58
|
+
angle: "degree",
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* See fromVectors above.
|
|
64
|
+
*/
|
|
65
|
+
static fromVectorArrays(array, type, skipRounding = true) {
|
|
66
|
+
return this.fromVectors({
|
|
67
|
+
a: array[0],
|
|
68
|
+
b: array[1],
|
|
69
|
+
c: array[2],
|
|
70
|
+
type,
|
|
71
|
+
skipRounding, // do not round the values to avoid loosing precision by default
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get the list of editable keys (eg. 'a', 'alpha') for the current lattice.
|
|
76
|
+
* @return {Object}
|
|
77
|
+
* @example {a: true, b: false, c: false, alpha: true, beta: false, gamma: false}
|
|
78
|
+
*/
|
|
79
|
+
get editables() {
|
|
80
|
+
var _a;
|
|
81
|
+
const object = {};
|
|
82
|
+
const editablesList = (_a = types_1.LATTICE_TYPE_CONFIGS.find((entry) => entry.code === this.type)) === null || _a === void 0 ? void 0 : _a.editables;
|
|
83
|
+
// ["a", "gamma"] => {a: true, gamma: true}
|
|
84
|
+
if (editablesList) {
|
|
85
|
+
editablesList.forEach((element) => {
|
|
86
|
+
Object.assign(object, {
|
|
87
|
+
[element]: true,
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return object;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Serialize class instance to JSON.
|
|
95
|
+
* @example As below:
|
|
96
|
+
{
|
|
97
|
+
"a" : 3.867,
|
|
98
|
+
"b" : 3.867,
|
|
99
|
+
"c" : 3.867,
|
|
100
|
+
"alpha" : 60,
|
|
101
|
+
"beta" : 60,
|
|
102
|
+
"gamma" : 60,
|
|
103
|
+
"units" : {
|
|
104
|
+
"length" : "angstrom",
|
|
105
|
+
"angle" : "degree"
|
|
106
|
+
},
|
|
107
|
+
"type" : "FCC"
|
|
108
|
+
}
|
|
109
|
+
*/
|
|
110
|
+
toJSON() {
|
|
111
|
+
return {
|
|
112
|
+
...this,
|
|
113
|
+
units: {
|
|
114
|
+
length: this.units.length,
|
|
115
|
+
angle: this.units.angle,
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.LatticeBravais = LatticeBravais;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { LatticeExplicitUnit, LatticeImplicitSchema } from "@mat3ra/esse/lib/js/types";
|
|
2
|
+
import { Vector } from "./types";
|
|
3
|
+
type RequiredLatticeExplicitUnit = Required<LatticeExplicitUnit>;
|
|
4
|
+
export interface BravaisConfigProps extends Partial<LatticeImplicitSchema> {
|
|
5
|
+
isConventional?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class LatticeVectors implements RequiredLatticeExplicitUnit {
|
|
8
|
+
a: RequiredLatticeExplicitUnit["a"];
|
|
9
|
+
b: RequiredLatticeExplicitUnit["b"];
|
|
10
|
+
c: RequiredLatticeExplicitUnit["c"];
|
|
11
|
+
alat: RequiredLatticeExplicitUnit["alat"];
|
|
12
|
+
units: RequiredLatticeExplicitUnit["units"];
|
|
13
|
+
/**
|
|
14
|
+
* Create a Bravais lattice.
|
|
15
|
+
*/
|
|
16
|
+
constructor(config: LatticeExplicitUnit);
|
|
17
|
+
static _roundValue(arr: number[]): number[];
|
|
18
|
+
static fromBravais({ a, // default lattice is cubic with unity in edge sizes
|
|
19
|
+
b, c, alpha, beta, gamma, units, type, isConventional, }: BravaisConfigProps): LatticeVectors;
|
|
20
|
+
get vectorArrays(): [Vector, Vector, Vector];
|
|
21
|
+
/**
|
|
22
|
+
* Serialize class instance to JSON.
|
|
23
|
+
* @example As below:
|
|
24
|
+
{
|
|
25
|
+
"a" : [
|
|
26
|
+
3.34892,
|
|
27
|
+
0,
|
|
28
|
+
1.9335
|
|
29
|
+
],
|
|
30
|
+
"b" : [
|
|
31
|
+
1.116307,
|
|
32
|
+
3.157392,
|
|
33
|
+
1.9335
|
|
34
|
+
],
|
|
35
|
+
"c" : [
|
|
36
|
+
0,
|
|
37
|
+
0,
|
|
38
|
+
3.867
|
|
39
|
+
],
|
|
40
|
+
"alat" : 1,
|
|
41
|
+
"units" : "angstrom"
|
|
42
|
+
}
|
|
43
|
+
*/
|
|
44
|
+
toJSON(): RequiredLatticeExplicitUnit;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LatticeVectors = void 0;
|
|
7
|
+
const primitive_cell_1 = require("../cell/primitive_cell");
|
|
8
|
+
const constants_1 = __importDefault(require("../constants"));
|
|
9
|
+
const math_1 = __importDefault(require("../math"));
|
|
10
|
+
/*
|
|
11
|
+
* @summary: class that holds parameters of a Bravais Lattice: a, b, c, alpha, beta, gamma + corresponding units.
|
|
12
|
+
* When stored as class variables units for lengths are always "angstrom"s, angle - "degree"s
|
|
13
|
+
*/
|
|
14
|
+
class LatticeVectors {
|
|
15
|
+
/**
|
|
16
|
+
* Create a Bravais lattice.
|
|
17
|
+
*/
|
|
18
|
+
constructor(config) {
|
|
19
|
+
const { a, b, c, alat = 1, units = "angstrom" } = config;
|
|
20
|
+
const k = constants_1.default.units.bohr === units ? constants_1.default.coefficients.BOHR_TO_ANGSTROM : 1;
|
|
21
|
+
this.a = a.map((x) => x * k);
|
|
22
|
+
this.b = b.map((x) => x * k);
|
|
23
|
+
this.c = c.map((x) => x * k);
|
|
24
|
+
this.alat = alat;
|
|
25
|
+
this.units = "angstrom";
|
|
26
|
+
}
|
|
27
|
+
static _roundValue(arr) {
|
|
28
|
+
return arr.map((el) => math_1.default.precise(math_1.default.roundToZero(el)));
|
|
29
|
+
}
|
|
30
|
+
/*
|
|
31
|
+
* Constructs a Bravais lattice from lattice vectors
|
|
32
|
+
* Supports conventional lattice as parameters and primitive too.
|
|
33
|
+
* Algorithm from http://pymatgen.org/_modules/pymatgen/core/lattice.html (from_params)
|
|
34
|
+
* For parameters see `LatticeBravais.constructor`.
|
|
35
|
+
*/
|
|
36
|
+
static fromBravais({ a = 1, // default lattice is cubic with unity in edge sizes
|
|
37
|
+
b = a, c = a, alpha = 90, beta = 90, gamma = 90, units = {
|
|
38
|
+
length: "angstrom",
|
|
39
|
+
angle: "degree",
|
|
40
|
+
}, type = "TRI", isConventional = false, }) {
|
|
41
|
+
// use "direct" lattice constructor for primitive lattice
|
|
42
|
+
// eslint-disable-next-line no-param-reassign
|
|
43
|
+
if (!isConventional)
|
|
44
|
+
type = "TRI";
|
|
45
|
+
// set precision and remove JS floating point artifacts
|
|
46
|
+
const [vectorA, vectorB, vectorC] = (0, primitive_cell_1.primitiveCell)({
|
|
47
|
+
a,
|
|
48
|
+
b,
|
|
49
|
+
c,
|
|
50
|
+
alpha,
|
|
51
|
+
beta,
|
|
52
|
+
gamma,
|
|
53
|
+
units,
|
|
54
|
+
type,
|
|
55
|
+
});
|
|
56
|
+
return new LatticeVectors({
|
|
57
|
+
a: vectorA,
|
|
58
|
+
b: vectorB,
|
|
59
|
+
c: vectorC,
|
|
60
|
+
alat: 1,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
get vectorArrays() {
|
|
64
|
+
return [this.a, this.b, this.c];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Serialize class instance to JSON.
|
|
68
|
+
* @example As below:
|
|
69
|
+
{
|
|
70
|
+
"a" : [
|
|
71
|
+
3.34892,
|
|
72
|
+
0,
|
|
73
|
+
1.9335
|
|
74
|
+
],
|
|
75
|
+
"b" : [
|
|
76
|
+
1.116307,
|
|
77
|
+
3.157392,
|
|
78
|
+
1.9335
|
|
79
|
+
],
|
|
80
|
+
"c" : [
|
|
81
|
+
0,
|
|
82
|
+
0,
|
|
83
|
+
3.867
|
|
84
|
+
],
|
|
85
|
+
"alat" : 1,
|
|
86
|
+
"units" : "angstrom"
|
|
87
|
+
}
|
|
88
|
+
*/
|
|
89
|
+
toJSON() {
|
|
90
|
+
return {
|
|
91
|
+
...this,
|
|
92
|
+
a: LatticeVectors._roundValue(this.a),
|
|
93
|
+
b: LatticeVectors._roundValue(this.b),
|
|
94
|
+
c: LatticeVectors._roundValue(this.c),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.LatticeVectors = LatticeVectors;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export class ReciprocalLattice extends Lattice {
|
|
2
|
+
/**
|
|
3
|
+
* Get reciprocal vectors for the current Lattice in cartesian (2pi / a) units
|
|
4
|
+
* @return {Array[]}
|
|
5
|
+
*/
|
|
6
|
+
get reciprocalVectors(): any[][];
|
|
7
|
+
/**
|
|
8
|
+
* Norms of reciprocal vectors.
|
|
9
|
+
* @return {number[]}
|
|
10
|
+
*/
|
|
11
|
+
get reciprocalVectorNorms(): number[];
|
|
12
|
+
/**
|
|
13
|
+
* Ratio of reciprocal vector norms scaled by the inverse of the largest component.
|
|
14
|
+
* @return {number[]}
|
|
15
|
+
*/
|
|
16
|
+
get reciprocalVectorRatios(): number[];
|
|
17
|
+
/**
|
|
18
|
+
* Get point (in crystal coordinates) in cartesian coordinates.
|
|
19
|
+
* @param {Array} point - point in 3D space
|
|
20
|
+
* @return {Array}
|
|
21
|
+
*/
|
|
22
|
+
getCartesianCoordinates(point: any[]): any[];
|
|
23
|
+
/**
|
|
24
|
+
* Get the list of high-symmetry points for the current lattice.
|
|
25
|
+
* @return {Object[]}
|
|
26
|
+
*/
|
|
27
|
+
get symmetryPoints(): Object[];
|
|
28
|
+
/**
|
|
29
|
+
* Get the default path in reciprocal space for the current lattice.
|
|
30
|
+
* @return {Array[]}
|
|
31
|
+
*/
|
|
32
|
+
get defaultKpointPath(): any[][];
|
|
33
|
+
/**
|
|
34
|
+
* Find/mark the high symmetry points on a list with raw data and return the edited list.
|
|
35
|
+
* @param {Array} dataPoints - list of point coordinates
|
|
36
|
+
* @return {Object[]}
|
|
37
|
+
*/
|
|
38
|
+
extractKpointPath(dataPoints?: any[]): Object[];
|
|
39
|
+
/**
|
|
40
|
+
* Calculate grid dimension based on reciprocal lattice vectors.
|
|
41
|
+
* @param {number} nPoints - Total number of points
|
|
42
|
+
* @param {number} index - Index of reciprocal vector
|
|
43
|
+
* @return {number} - Grid dimension in direction of reciprocal vector
|
|
44
|
+
* @todo This could be moved to a separate KGrid class.
|
|
45
|
+
*/
|
|
46
|
+
calculateDimension(nPoints: number, index: number): number;
|
|
47
|
+
/**
|
|
48
|
+
* Calculate grid dimensions from total number of k-points.
|
|
49
|
+
* @param {number} nKpoints - Total number of k-points.
|
|
50
|
+
* @return {number[]} - Grid dimensions
|
|
51
|
+
*/
|
|
52
|
+
getDimensionsFromPointsCount(nKpoints: number): number[];
|
|
53
|
+
get conversionTable(): {
|
|
54
|
+
[x: string]: {
|
|
55
|
+
[x: string]: number;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Calculate grid dimensions from k-point spacing, i.e.
|
|
60
|
+
* the maximum distance between adjacent points along a reciprocal axis.
|
|
61
|
+
* Note: just as the lattice vectors spacing is in cartesian (2pi / a) units by default
|
|
62
|
+
* @param {number} spacing - maximum Spacing between k-points
|
|
63
|
+
* @param {string} units - units of spacing parameter (default: 2pi / a)
|
|
64
|
+
* @return {number[]}
|
|
65
|
+
*/
|
|
66
|
+
getDimensionsFromSpacing(spacing: number, units?: string): number[];
|
|
67
|
+
/**
|
|
68
|
+
* Calculate grid spacing as average of spacing along individual reciprocal axes.
|
|
69
|
+
* @param {number[]} dimensions - Array of dimensions
|
|
70
|
+
* @param {string} units - units of spacing parameter (default: 2pi / a)
|
|
71
|
+
* @return {number} - average grid spacing
|
|
72
|
+
*/
|
|
73
|
+
getSpacingFromDimensions(dimensions: number[], units?: string): number;
|
|
74
|
+
}
|
|
75
|
+
import { Lattice } from "../lattice";
|