@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
package/dist/material.js
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
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.Material = exports.MaterialMixin = exports.defaultMaterialConfig = void 0;
|
|
7
|
+
const entity_1 = require("@exabyte-io/code.js/dist/entity");
|
|
8
|
+
const material_json_1 = __importDefault(require("@mat3ra/esse/lib/js/schema/material.json"));
|
|
9
|
+
const crypto_js_1 = __importDefault(require("crypto-js"));
|
|
10
|
+
const constrained_basis_1 = require("./basis/constrained_basis");
|
|
11
|
+
const conventional_cell_1 = require("./cell/conventional_cell");
|
|
12
|
+
const constants_1 = require("./constants");
|
|
13
|
+
const lattice_1 = require("./lattice/lattice");
|
|
14
|
+
const parsers_1 = __importDefault(require("./parsers/parsers"));
|
|
15
|
+
// TODO: fix dependency cycle below
|
|
16
|
+
// eslint-disable-next-line import/no-cycle
|
|
17
|
+
const supercell_1 = __importDefault(require("./tools/supercell"));
|
|
18
|
+
exports.defaultMaterialConfig = {
|
|
19
|
+
name: "Silicon FCC",
|
|
20
|
+
basis: {
|
|
21
|
+
elements: [
|
|
22
|
+
{
|
|
23
|
+
id: 1,
|
|
24
|
+
value: "Si",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 2,
|
|
28
|
+
value: "Si",
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
coordinates: [
|
|
32
|
+
{
|
|
33
|
+
id: 1,
|
|
34
|
+
value: [0.0, 0.0, 0.0],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 2,
|
|
38
|
+
value: [0.25, 0.25, 0.25],
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
units: constants_1.ATOMIC_COORD_UNITS.crystal,
|
|
42
|
+
},
|
|
43
|
+
lattice: {
|
|
44
|
+
// Primitive cell for Diamond FCC Silicon at ambient conditions
|
|
45
|
+
type: "FCC",
|
|
46
|
+
a: 3.867,
|
|
47
|
+
b: 3.867,
|
|
48
|
+
c: 3.867,
|
|
49
|
+
alpha: 60,
|
|
50
|
+
beta: 60,
|
|
51
|
+
gamma: 60,
|
|
52
|
+
units: {
|
|
53
|
+
length: constants_1.units.angstrom,
|
|
54
|
+
angle: constants_1.units.degree,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
function MaterialMixin(superclass) {
|
|
59
|
+
class MadeMaterial extends superclass {
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
+
constructor(...config) {
|
|
62
|
+
super(...config);
|
|
63
|
+
this.name = super.name || this.formula;
|
|
64
|
+
}
|
|
65
|
+
toJSON() {
|
|
66
|
+
return {
|
|
67
|
+
...super.toJSON(),
|
|
68
|
+
lattice: this.Lattice.toJSON(),
|
|
69
|
+
basis: this.Basis.toJSON(),
|
|
70
|
+
name: this.name,
|
|
71
|
+
isNonPeriodic: this.isNonPeriodic,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
static get defaultConfig() {
|
|
75
|
+
return exports.defaultMaterialConfig;
|
|
76
|
+
}
|
|
77
|
+
get src() {
|
|
78
|
+
return this.prop("src");
|
|
79
|
+
}
|
|
80
|
+
set src(src) {
|
|
81
|
+
this.setProp("src", src);
|
|
82
|
+
}
|
|
83
|
+
updateFormula() {
|
|
84
|
+
this.setProp("formula", this.Basis.formula);
|
|
85
|
+
this.setProp("unitCellFormula", this.Basis.unitCellFormula);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Gets Bolean value for whether or not a material is non-periodic vs periodic.
|
|
89
|
+
* False = periodic, True = non-periodic
|
|
90
|
+
*/
|
|
91
|
+
get isNonPeriodic() {
|
|
92
|
+
return this.prop("isNonPeriodic", false);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @summary Sets the value of isNonPeriodic based on Boolean value passed as an argument.
|
|
96
|
+
*/
|
|
97
|
+
set isNonPeriodic(bool) {
|
|
98
|
+
this.setProp("isNonPeriodic", bool);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* @summary Returns the specific derived property (as specified by name) for a material.
|
|
102
|
+
*/
|
|
103
|
+
getDerivedPropertyByName(name) {
|
|
104
|
+
return this.getDerivedProperties().find((x) => x.name === name);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* @summary Returns the derived properties array for a material.
|
|
108
|
+
*/
|
|
109
|
+
getDerivedProperties() {
|
|
110
|
+
return this.prop("derivedProperties", []);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Gets material's formula
|
|
114
|
+
*/
|
|
115
|
+
get formula() {
|
|
116
|
+
return this.prop("formula") || this.Basis.formula;
|
|
117
|
+
}
|
|
118
|
+
get unitCellFormula() {
|
|
119
|
+
return this.prop("unitCellFormula") || this.Basis.unitCellFormula;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* @param textOrObject Basis text or JSON object.
|
|
123
|
+
* @param format Format (xyz, etc.)
|
|
124
|
+
* @param unitz crystal/cartesian
|
|
125
|
+
*/
|
|
126
|
+
setBasis(textOrObject, format, unitz) {
|
|
127
|
+
let basis;
|
|
128
|
+
switch (format) {
|
|
129
|
+
case "xyz":
|
|
130
|
+
basis = parsers_1.default.xyz.toBasisConfig(textOrObject, unitz);
|
|
131
|
+
break;
|
|
132
|
+
default:
|
|
133
|
+
basis = textOrObject;
|
|
134
|
+
}
|
|
135
|
+
this.setProp("basis", basis);
|
|
136
|
+
this.updateFormula();
|
|
137
|
+
}
|
|
138
|
+
setBasisConstraints(constraints) {
|
|
139
|
+
this.setBasis({ ...this.basis, constraints });
|
|
140
|
+
}
|
|
141
|
+
get basis() {
|
|
142
|
+
return this.prop("basis");
|
|
143
|
+
}
|
|
144
|
+
// returns the instance of {ConstrainedBasis} class
|
|
145
|
+
get Basis() {
|
|
146
|
+
return new constrained_basis_1.ConstrainedBasis({
|
|
147
|
+
...this.basis,
|
|
148
|
+
cell: this.Lattice.vectorArrays,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* High-level access to unique elements from material instead of basis.
|
|
153
|
+
*/
|
|
154
|
+
get uniqueElements() {
|
|
155
|
+
return this.Basis.uniqueElements;
|
|
156
|
+
}
|
|
157
|
+
get lattice() {
|
|
158
|
+
return this.prop("lattice", undefined);
|
|
159
|
+
}
|
|
160
|
+
set lattice(config) {
|
|
161
|
+
this.setProp("lattice", config);
|
|
162
|
+
}
|
|
163
|
+
get Lattice() {
|
|
164
|
+
return new lattice_1.Lattice(this.lattice);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Returns the inchi string from the derivedProperties for a non-periodic material, or throws an error if the
|
|
168
|
+
* inchi cannot be found.
|
|
169
|
+
* @returns {String}
|
|
170
|
+
*/
|
|
171
|
+
getInchiStringForHash() {
|
|
172
|
+
const inchi = this.getDerivedPropertyByName("inchi");
|
|
173
|
+
if (inchi) {
|
|
174
|
+
return inchi.value;
|
|
175
|
+
}
|
|
176
|
+
throw new Error("Hash cannot be created. Missing InChI string in derivedProperties");
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Calculates hash from basis and lattice. Algorithm expects the following:
|
|
180
|
+
* - asserts lattice units to be angstrom
|
|
181
|
+
* - asserts basis units to be crystal
|
|
182
|
+
* - asserts basis coordinates and lattice measurements are rounded to hash precision
|
|
183
|
+
* - forms strings for lattice and basis
|
|
184
|
+
* - creates MD5 hash from basisStr + latticeStr + salt
|
|
185
|
+
* @param salt Salt for hashing, empty string by default.
|
|
186
|
+
* @param isScaled Whether to scale the lattice parameter 'a' to 1.
|
|
187
|
+
*/
|
|
188
|
+
calculateHash(salt = "", isScaled = false, bypassNonPeriodicCheck = false) {
|
|
189
|
+
let message;
|
|
190
|
+
if (!this.isNonPeriodic || bypassNonPeriodicCheck) {
|
|
191
|
+
message =
|
|
192
|
+
this.Basis.hashString + "#" + this.Lattice.getHashString(isScaled) + "#" + salt;
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
message = this.getInchiStringForHash();
|
|
196
|
+
}
|
|
197
|
+
return crypto_js_1.default.MD5(message).toString();
|
|
198
|
+
}
|
|
199
|
+
set hash(hash) {
|
|
200
|
+
this.setProp("hash", hash);
|
|
201
|
+
}
|
|
202
|
+
get hash() {
|
|
203
|
+
return this.prop("hash");
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Calculates hash from basis and lattice as above + scales lattice properties to make lattice.a = 1
|
|
207
|
+
*/
|
|
208
|
+
get scaledHash() {
|
|
209
|
+
return this.calculateHash("", true);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Converts basis to crystal/fractional coordinates.
|
|
213
|
+
*/
|
|
214
|
+
toCrystal() {
|
|
215
|
+
const basis = this.Basis;
|
|
216
|
+
basis.toCrystal();
|
|
217
|
+
this.setProp("basis", basis.toJSON());
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Converts current material's basis coordinates to cartesian.
|
|
221
|
+
* No changes if coordinates already cartesian.
|
|
222
|
+
*/
|
|
223
|
+
toCartesian() {
|
|
224
|
+
const basis = this.Basis;
|
|
225
|
+
basis.toCartesian();
|
|
226
|
+
this.setProp("basis", basis.toJSON());
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Returns material's basis in XYZ format.
|
|
230
|
+
*/
|
|
231
|
+
getBasisAsXyz(fractional = false) {
|
|
232
|
+
return parsers_1.default.xyz.fromMaterial(this.toJSON(), fractional);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Returns material in Quantum Espresso output format:
|
|
236
|
+
* ```
|
|
237
|
+
* CELL_PARAMETERS (angstroms)
|
|
238
|
+
* -0.543131284 -0.000000000 0.543131284
|
|
239
|
+
* -0.000000000 0.543131284 0.543131284
|
|
240
|
+
* -0.543131284 0.543131284 0.000000000
|
|
241
|
+
*
|
|
242
|
+
* ATOMIC_POSITIONS (crystal)
|
|
243
|
+
* Si 0.000000000 0.000000000 -0.000000000
|
|
244
|
+
* Si 0.250000000 0.250000000 0.250000000
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
getAsQEFormat() {
|
|
248
|
+
return parsers_1.default.espresso.toEspressoFormat(this.toJSON());
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Returns material in POSCAR format. Pass `true` to ignore original poscar source and re-serialize.
|
|
252
|
+
*/
|
|
253
|
+
getAsPOSCAR(ignoreOriginal = false, omitConstraints = false) {
|
|
254
|
+
const { src } = this;
|
|
255
|
+
// By default return original source if exists
|
|
256
|
+
if (src && src.extension === "poscar" && !ignoreOriginal) {
|
|
257
|
+
return this.src.text;
|
|
258
|
+
}
|
|
259
|
+
return parsers_1.default.poscar.toPoscar(this.toJSON(), omitConstraints);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Returns a copy of the material with conventional cell constructed instead of primitive.
|
|
263
|
+
*/
|
|
264
|
+
getACopyWithConventionalCell() {
|
|
265
|
+
const material = this.clone();
|
|
266
|
+
// if conventional and primitive cells are the same => return a copy.
|
|
267
|
+
if ((0, conventional_cell_1.isConventionalCellSameAsPrimitiveForLatticeType)(this.Lattice.type))
|
|
268
|
+
return material;
|
|
269
|
+
const conventionalSupercellMatrix = conventional_cell_1.PRIMITIVE_TO_CONVENTIONAL_CELL_MULTIPLIERS[this.Lattice.type];
|
|
270
|
+
const conventionalLatticeType = conventional_cell_1.PRIMITIVE_TO_CONVENTIONAL_CELL_LATTICE_TYPES[this.Lattice.type];
|
|
271
|
+
const config = supercell_1.default.generateConfig(material, conventionalSupercellMatrix);
|
|
272
|
+
config.lattice.type = conventionalLatticeType;
|
|
273
|
+
config.name = `${material.name} - conventional cell`;
|
|
274
|
+
// @ts-ignore
|
|
275
|
+
return new this.constructor(config);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* @summary a series of checks for the material and returns an array of results in ConsistencyChecks format.
|
|
279
|
+
* @returns Array of checks results
|
|
280
|
+
*/
|
|
281
|
+
getConsistencyChecks() {
|
|
282
|
+
const basisChecks = this.getBasisConsistencyChecks();
|
|
283
|
+
// any other Material checks can be added here
|
|
284
|
+
return basisChecks;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* @summary a series of checks for the material's basis and returns an array of results in ConsistencyChecks format.
|
|
288
|
+
* @returns Array of checks results
|
|
289
|
+
*/
|
|
290
|
+
getBasisConsistencyChecks() {
|
|
291
|
+
const checks = [];
|
|
292
|
+
const limit = 1000;
|
|
293
|
+
const basis = this.Basis;
|
|
294
|
+
if (this.Basis.elements.length < limit) {
|
|
295
|
+
const overlappingAtomsGroups = basis.getOverlappingAtoms();
|
|
296
|
+
overlappingAtomsGroups.forEach(({ id1, id2, element1, element2 }) => {
|
|
297
|
+
checks.push({
|
|
298
|
+
key: `basis.coordinates.${id1}`,
|
|
299
|
+
name: "atomsOverlap",
|
|
300
|
+
severity: "warning",
|
|
301
|
+
message: `Atom ${element1} is too close to ${element2} at position ${id2 + 1}`,
|
|
302
|
+
}, {
|
|
303
|
+
key: `basis.coordinates.${id2}`,
|
|
304
|
+
name: "atomsOverlap",
|
|
305
|
+
severity: "warning",
|
|
306
|
+
message: `Atom ${element2} is too close to ${element1} at position ${id1 + 1}`,
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
return checks;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
MadeMaterial.jsonSchema = material_json_1.default;
|
|
314
|
+
return MadeMaterial;
|
|
315
|
+
}
|
|
316
|
+
exports.MaterialMixin = MaterialMixin;
|
|
317
|
+
exports.Material = MaterialMixin(entity_1.HasConsistencyChecksHasMetadataNamedDefaultableInMemoryEntity);
|