@mat3ra/made 2026.8.7-0 → 2026.8.13-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/.mocharc.json +2 -2
- package/dist/js/Material.d.ts +219 -0
- package/dist/js/Material.js +457 -0
- package/dist/js/basis/basis.d.ts +14 -9
- package/dist/js/basis/basis.js +15 -13
- package/dist/js/basis/constrained_basis.d.ts +9 -7
- package/dist/js/basis/constrained_basis.js +4 -4
- package/dist/js/generated/MaterialSchemaMixin.d.ts +5 -0
- package/dist/js/generated/MaterialSchemaMixin.js +69 -0
- package/dist/js/lattice/lattice.d.ts +4 -3
- package/dist/js/lattice/lattice.js +1 -2
- package/dist/js/made.d.ts +12 -12
- package/dist/js/made.js +38 -5
- package/dist/js/parsers/espresso.d.ts +2 -3
- package/dist/js/parsers/espresso.js +0 -1
- package/dist/js/parsers/native_format_parsers.d.ts +9 -8
- package/dist/js/parsers/native_format_parsers.js +6 -6
- package/dist/js/parsers/parsers.d.ts +6 -6
- package/dist/js/parsers/poscar.d.ts +5 -4
- package/dist/js/parsers/poscar.js +3 -2
- package/dist/js/parsers/xyz.d.ts +3 -5
- package/dist/js/parsers/xyz.js +3 -4
- package/dist/js/parsers/xyz_combinatorial_basis.js +3 -1
- package/dist/js/tools/basis.d.ts +1 -1
- package/dist/js/tools/index.d.ts +7 -7
- package/dist/js/tools/material.d.ts +1 -1
- package/dist/js/tools/material.js +8 -7
- package/dist/js/tools/supercell.d.ts +4 -5
- package/dist/js/tools/supercell.js +2 -4
- package/dist/js/tools/surface.d.ts +4 -4
- package/dist/js/tools/surface.js +2 -7
- package/package.json +6 -6
- package/scripts/generate-mixins.ts +28 -0
- package/src/js/Material.ts +618 -0
- package/src/js/basis/basis.ts +38 -25
- package/src/js/basis/constrained_basis.ts +12 -11
- package/src/js/basis/coordinates.ts +0 -1
- package/src/js/cell/cell.ts +0 -1
- package/src/js/generated/MaterialSchemaMixin.ts +79 -0
- package/src/js/lattice/lattice.ts +6 -4
- package/src/js/lattice/reciprocal/lattice_reciprocal.ts +19 -6
- package/src/js/made.ts +1 -1
- package/src/js/parsers/espresso.ts +2 -3
- package/src/js/parsers/native_format_parsers.ts +9 -8
- package/src/js/parsers/poscar.ts +12 -6
- package/src/js/parsers/xyz.ts +9 -6
- package/src/js/parsers/xyz_combinatorial_basis.ts +5 -2
- package/src/js/tools/basis.ts +0 -1
- package/src/js/tools/cell.ts +0 -1
- package/src/js/tools/material.ts +13 -11
- package/src/js/tools/supercell.ts +8 -7
- package/src/js/tools/surface.ts +7 -17
- package/src/py/mat3ra/made/material.py +6 -5
- package/tests/fixtures/si-standata.json +2 -2
- package/tests/js/basis/basis.ts +8 -8
- package/tests/js/fixtures.ts +12 -9
- package/tests/js/material/material.ts +161 -0
- package/tests/js/parsers/espresso.ts +2 -5
- package/tests/js/parsers/poscar.ts +2 -2
- package/tests/js/register-esse-schemas.cjs +10 -0
- package/tests/js/tools/supercell.ts +2 -2
- package/tests/js/tools/surface.ts +6 -10
- package/dist/js/material.d.ts +0 -169
- package/dist/js/material.js +0 -362
- package/src/js/material.ts +0 -458
- package/tests/js/material.test.ts +0 -42
package/dist/js/material.d.ts
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { type DefaultableInMemoryEntity, InMemoryEntity } from "@mat3ra/code/dist/js/entity";
|
|
2
|
-
import { type HasConsistencyChecks } from "@mat3ra/code/dist/js/entity/mixins/HasConsistencyChecksMixin";
|
|
3
|
-
import { type HasMetadata } from "@mat3ra/code/dist/js/entity/mixins/HasMetadataMixin";
|
|
4
|
-
import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
|
|
5
|
-
import type { AtomicConstraintsSchema, ConsistencyCheck, DerivedPropertiesSchema, FileSourceSchema, LatticeSchema, MaterialSchema } from "@mat3ra/esse/dist/js/types";
|
|
6
|
-
import type { BasisConfig } from "./basis/basis";
|
|
7
|
-
import { type ConstrainedBasisConfig, ConstrainedBasis } from "./basis/constrained_basis";
|
|
8
|
-
import { Constraint } from "./constraints/constraints";
|
|
9
|
-
import { Lattice } from "./lattice/lattice";
|
|
10
|
-
interface Material extends HasConsistencyChecks, DefaultableInMemoryEntity, Required<HasMetadata<MaterialSchema["metadata"]>> {
|
|
11
|
-
}
|
|
12
|
-
type MaterialSchemaWithConsistencyChecksAsString = Omit<MaterialSchema, "consistencyChecks"> & {
|
|
13
|
-
consistencyChecks?: ConsistencyCheck[];
|
|
14
|
-
};
|
|
15
|
-
type OptionallyConstrainedBasisConfig = BasisConfig & Partial<Pick<ConstrainedBasisConfig, "constraints">>;
|
|
16
|
-
type Schema = MaterialSchemaWithConsistencyChecksAsString;
|
|
17
|
-
export declare const defaultMaterialConfig: MaterialSchema;
|
|
18
|
-
declare class Material extends InMemoryEntity implements Schema {
|
|
19
|
-
static createDefault: () => Material;
|
|
20
|
-
static get defaultConfig(): MaterialSchema;
|
|
21
|
-
static constructMaterialFileSource(fileName: string, fileContent: string, fileExtension: string): FileSourceSchema;
|
|
22
|
-
get name(): string;
|
|
23
|
-
set name(name: string);
|
|
24
|
-
get src(): FileSourceSchema | undefined;
|
|
25
|
-
set src(src: FileSourceSchema | undefined);
|
|
26
|
-
updateFormula(): void;
|
|
27
|
-
/**
|
|
28
|
-
* Gets Bolean value for whether or not a material is non-periodic vs periodic.
|
|
29
|
-
* False = periodic, True = non-periodic
|
|
30
|
-
*/
|
|
31
|
-
get isNonPeriodic(): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* @summary Sets the value of isNonPeriodic based on Boolean value passed as an argument.
|
|
34
|
-
*/
|
|
35
|
-
set isNonPeriodic(bool: boolean);
|
|
36
|
-
/**
|
|
37
|
-
* @summary Returns the specific derived property (as specified by name) for a material.
|
|
38
|
-
*/
|
|
39
|
-
getDerivedPropertyByName(name: string): {
|
|
40
|
-
name?: "volume";
|
|
41
|
-
units?: "angstrom^3";
|
|
42
|
-
value: number;
|
|
43
|
-
} | {
|
|
44
|
-
name?: "density";
|
|
45
|
-
units?: "g/cm^3";
|
|
46
|
-
value: number;
|
|
47
|
-
} | {
|
|
48
|
-
pointGroupSymbol?: string;
|
|
49
|
-
spaceGroupSymbol?: string;
|
|
50
|
-
tolerance?: {
|
|
51
|
-
units?: "angstrom";
|
|
52
|
-
value: number;
|
|
53
|
-
};
|
|
54
|
-
name?: "symmetry";
|
|
55
|
-
} | {
|
|
56
|
-
name?: "elemental_ratio";
|
|
57
|
-
value: number;
|
|
58
|
-
element?: string;
|
|
59
|
-
} | {
|
|
60
|
-
name?: "p-norm";
|
|
61
|
-
degree?: number;
|
|
62
|
-
value: number;
|
|
63
|
-
} | {
|
|
64
|
-
name?: "inchi";
|
|
65
|
-
value: string;
|
|
66
|
-
} | {
|
|
67
|
-
name?: "inchi_key";
|
|
68
|
-
value: string;
|
|
69
|
-
} | undefined;
|
|
70
|
-
/**
|
|
71
|
-
* @summary Returns the derived properties array for a material.
|
|
72
|
-
*/
|
|
73
|
-
getDerivedProperties(): DerivedPropertiesSchema;
|
|
74
|
-
/**
|
|
75
|
-
* Gets material's formula
|
|
76
|
-
*/
|
|
77
|
-
get formula(): string;
|
|
78
|
-
get unitCellFormula(): string;
|
|
79
|
-
unsetFileProps(): void;
|
|
80
|
-
/**
|
|
81
|
-
* @param textOrObject Basis text or JSON object.
|
|
82
|
-
* @param format Format (xyz, etc.)
|
|
83
|
-
* @param unitz crystal/cartesian
|
|
84
|
-
*/
|
|
85
|
-
setBasis(textOrObject: string | BasisConfig, format?: string, unitz?: string): void;
|
|
86
|
-
setBasisConstraints(constraints: Constraint[]): void;
|
|
87
|
-
setBasisConstraintsFromArrayOfObjects(constraints: AtomicConstraintsSchema): void;
|
|
88
|
-
get basis(): OptionallyConstrainedBasisConfig;
|
|
89
|
-
get Basis(): ConstrainedBasis;
|
|
90
|
-
/**
|
|
91
|
-
* High-level access to unique elements from material instead of basis.
|
|
92
|
-
*/
|
|
93
|
-
get uniqueElements(): ("H" | "He" | "Li" | "Be" | "B" | "C" | "N" | "O" | "F" | "Ne" | "Na" | "Mg" | "Al" | "Si" | "P" | "S" | "Cl" | "Ar" | "K" | "Ca" | "Sc" | "Ti" | "V" | "Cr" | "Mn" | "Fe" | "Co" | "Ni" | "Cu" | "Zn" | "Ga" | "Ge" | "As" | "Se" | "Br" | "Kr" | "Rb" | "Sr" | "Y" | "Zr" | "Nb" | "Mo" | "Tc" | "Ru" | "Rh" | "Pd" | "Ag" | "Cd" | "In" | "Sn" | "Sb" | "Te" | "I" | "Xe" | "Cs" | "Ba" | "La" | "Ce" | "Pr" | "Nd" | "Pm" | "Sm" | "Eu" | "Gd" | "Tb" | "Dy" | "Ho" | "Er" | "Tm" | "Yb" | "Lu" | "Hf" | "Ta" | "W" | "Re" | "Os" | "Ir" | "Pt" | "Au" | "Hg" | "Tl" | "Pb" | "Bi" | "Po" | "At" | "Rn" | "Fr" | "Ra" | "Ac" | "Th" | "Pa" | "U" | "Np" | "Pu" | "Am" | "Cm" | "Bk" | "Cf" | "Es" | "Fm" | "Md" | "No" | "Lr" | "Rf" | "Db" | "Sg" | "Bh" | "Hs" | "Mt" | "Ds" | "Rg" | "Cn" | "Nh" | "Fl" | "Mc" | "Lv" | "Ts" | "Og" | "X" | "Vac")[];
|
|
94
|
-
get lattice(): LatticeSchema;
|
|
95
|
-
set lattice(config: LatticeSchema);
|
|
96
|
-
get Lattice(): Lattice;
|
|
97
|
-
/**
|
|
98
|
-
* Returns the inchi string from the derivedProperties for a non-periodic material, or throws an error if the
|
|
99
|
-
* inchi cannot be found.
|
|
100
|
-
* @returns {String}
|
|
101
|
-
*/
|
|
102
|
-
getInchiStringForHash(): string;
|
|
103
|
-
/**
|
|
104
|
-
* Calculates hash from basis and lattice. Algorithm expects the following:
|
|
105
|
-
* - asserts lattice units to be angstrom
|
|
106
|
-
* - asserts basis units to be crystal
|
|
107
|
-
* - asserts basis coordinates and lattice measurements are rounded to hash precision
|
|
108
|
-
* - forms strings for lattice and basis
|
|
109
|
-
* - creates MD5 hash from basisStr + latticeStr + salt
|
|
110
|
-
* @param salt Salt for hashing, empty string by default.
|
|
111
|
-
* @param isScaled Whether to scale the lattice parameter 'a' to 1.
|
|
112
|
-
*/
|
|
113
|
-
calculateHash(salt?: string, isScaled?: boolean, bypassNonPeriodicCheck?: boolean): string;
|
|
114
|
-
set hash(hash: string);
|
|
115
|
-
get hash(): string;
|
|
116
|
-
/**
|
|
117
|
-
* Calculates hash from basis and lattice as above + scales lattice properties to make lattice.a = 1
|
|
118
|
-
*/
|
|
119
|
-
get scaledHash(): string;
|
|
120
|
-
get external(): MaterialSchema["external"];
|
|
121
|
-
set external(external: MaterialSchema["external"]);
|
|
122
|
-
/**
|
|
123
|
-
* Converts basis to crystal/fractional coordinates.
|
|
124
|
-
*/
|
|
125
|
-
toCrystal(): void;
|
|
126
|
-
/**
|
|
127
|
-
* Converts current material's basis coordinates to cartesian.
|
|
128
|
-
* No changes if coordinates already cartesian.
|
|
129
|
-
*/
|
|
130
|
-
toCartesian(): void;
|
|
131
|
-
/**
|
|
132
|
-
* Returns material's basis in XYZ format.
|
|
133
|
-
*/
|
|
134
|
-
getBasisAsXyz(fractional?: boolean): string;
|
|
135
|
-
/**
|
|
136
|
-
* Returns material in Quantum Espresso output format:
|
|
137
|
-
* ```
|
|
138
|
-
* CELL_PARAMETERS (angstroms)
|
|
139
|
-
* -0.543131284 -0.000000000 0.543131284
|
|
140
|
-
* -0.000000000 0.543131284 0.543131284
|
|
141
|
-
* -0.543131284 0.543131284 0.000000000
|
|
142
|
-
*
|
|
143
|
-
* ATOMIC_POSITIONS (crystal)
|
|
144
|
-
* Si 0.000000000 0.000000000 -0.000000000
|
|
145
|
-
* Si 0.250000000 0.250000000 0.250000000
|
|
146
|
-
* ```
|
|
147
|
-
*/
|
|
148
|
-
getAsQEFormat(): string;
|
|
149
|
-
/**
|
|
150
|
-
* Returns material in POSCAR format. Pass `true` to ignore original poscar source and re-serialize.
|
|
151
|
-
*/
|
|
152
|
-
getAsPOSCAR(ignoreOriginal?: boolean, omitConstraints?: boolean): string;
|
|
153
|
-
/**
|
|
154
|
-
* Returns a copy of the material with conventional cell constructed instead of primitive.
|
|
155
|
-
*/
|
|
156
|
-
getACopyWithConventionalCell(): this;
|
|
157
|
-
/**
|
|
158
|
-
* @summary a series of checks for the material and returns an array of results in ConsistencyChecks format.
|
|
159
|
-
* @returns Array of checks results
|
|
160
|
-
*/
|
|
161
|
-
getConsistencyChecks(): ConsistencyCheck[];
|
|
162
|
-
/**
|
|
163
|
-
* @summary a series of checks for the material's basis and returns an array of results in ConsistencyChecks format.
|
|
164
|
-
* @returns Array of checks results
|
|
165
|
-
*/
|
|
166
|
-
getBasisConsistencyChecks(): ConsistencyCheck[];
|
|
167
|
-
toJSON(): MaterialSchema & AnyObject;
|
|
168
|
-
}
|
|
169
|
-
export { Material };
|
package/dist/js/material.js
DELETED
|
@@ -1,362 +0,0 @@
|
|
|
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.defaultMaterialConfig = void 0;
|
|
7
|
-
const entity_1 = require("@mat3ra/code/dist/js/entity");
|
|
8
|
-
const DefaultableMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/DefaultableMixin");
|
|
9
|
-
const HasConsistencyChecksMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/HasConsistencyChecksMixin");
|
|
10
|
-
const HasMetadataMixin_1 = require("@mat3ra/code/dist/js/entity/mixins/HasMetadataMixin");
|
|
11
|
-
const crypto_js_1 = __importDefault(require("crypto-js"));
|
|
12
|
-
const constrained_basis_1 = require("./basis/constrained_basis");
|
|
13
|
-
const conventional_cell_1 = require("./cell/conventional_cell");
|
|
14
|
-
const constraints_1 = require("./constraints/constraints");
|
|
15
|
-
const lattice_1 = require("./lattice/lattice");
|
|
16
|
-
const parsers_1 = __importDefault(require("./parsers/parsers"));
|
|
17
|
-
const supercell_1 = __importDefault(require("./tools/supercell"));
|
|
18
|
-
exports.defaultMaterialConfig = {
|
|
19
|
-
name: "Silicon FCC",
|
|
20
|
-
basis: {
|
|
21
|
-
elements: [
|
|
22
|
-
{
|
|
23
|
-
id: 0,
|
|
24
|
-
value: "Si",
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
id: 1,
|
|
28
|
-
value: "Si",
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
coordinates: [
|
|
32
|
-
{
|
|
33
|
-
id: 0,
|
|
34
|
-
value: [0.0, 0.0, 0.0],
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
id: 1,
|
|
38
|
-
value: [0.25, 0.25, 0.25],
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
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: "angstrom",
|
|
54
|
-
angle: "degree",
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
metadata: {},
|
|
58
|
-
};
|
|
59
|
-
class Material extends entity_1.InMemoryEntity {
|
|
60
|
-
static get defaultConfig() {
|
|
61
|
-
return exports.defaultMaterialConfig;
|
|
62
|
-
}
|
|
63
|
-
static constructMaterialFileSource(fileName, fileContent, fileExtension) {
|
|
64
|
-
return {
|
|
65
|
-
extension: fileExtension,
|
|
66
|
-
filename: fileName,
|
|
67
|
-
text: fileContent,
|
|
68
|
-
hash: crypto_js_1.default.MD5(fileContent).toString(),
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
get name() {
|
|
72
|
-
var _a;
|
|
73
|
-
return (_a = this.prop("name")) !== null && _a !== void 0 ? _a : this.formula; // if name is not set, use formula, but keep empty string
|
|
74
|
-
}
|
|
75
|
-
set name(name) {
|
|
76
|
-
this.setProp("name", name);
|
|
77
|
-
}
|
|
78
|
-
get src() {
|
|
79
|
-
return this.prop("src");
|
|
80
|
-
}
|
|
81
|
-
set src(src) {
|
|
82
|
-
this.setProp("src", src);
|
|
83
|
-
}
|
|
84
|
-
updateFormula() {
|
|
85
|
-
this.setProp("formula", this.Basis.formula);
|
|
86
|
-
this.setProp("unitCellFormula", this.Basis.unitCellFormula);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Gets Bolean value for whether or not a material is non-periodic vs periodic.
|
|
90
|
-
* False = periodic, True = non-periodic
|
|
91
|
-
*/
|
|
92
|
-
get isNonPeriodic() {
|
|
93
|
-
return this.prop("isNonPeriodic", false);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* @summary Sets the value of isNonPeriodic based on Boolean value passed as an argument.
|
|
97
|
-
*/
|
|
98
|
-
set isNonPeriodic(bool) {
|
|
99
|
-
this.setProp("isNonPeriodic", bool);
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* @summary Returns the specific derived property (as specified by name) for a material.
|
|
103
|
-
*/
|
|
104
|
-
getDerivedPropertyByName(name) {
|
|
105
|
-
return this.getDerivedProperties().find((x) => x.name === name);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* @summary Returns the derived properties array for a material.
|
|
109
|
-
*/
|
|
110
|
-
getDerivedProperties() {
|
|
111
|
-
return this.prop("derivedProperties", []);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Gets material's formula
|
|
115
|
-
*/
|
|
116
|
-
get formula() {
|
|
117
|
-
return this.prop("formula") || this.Basis.formula;
|
|
118
|
-
}
|
|
119
|
-
get unitCellFormula() {
|
|
120
|
-
return this.prop("unitCellFormula") || this.Basis.unitCellFormula;
|
|
121
|
-
}
|
|
122
|
-
unsetFileProps() {
|
|
123
|
-
this.unsetProp("src");
|
|
124
|
-
this.unsetProp("icsdId");
|
|
125
|
-
this.unsetProp("external");
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* @param textOrObject Basis text or JSON object.
|
|
129
|
-
* @param format Format (xyz, etc.)
|
|
130
|
-
* @param unitz crystal/cartesian
|
|
131
|
-
*/
|
|
132
|
-
setBasis(textOrObject, format, unitz) {
|
|
133
|
-
let basis;
|
|
134
|
-
if (typeof textOrObject === "string" && format === "xyz") {
|
|
135
|
-
basis = parsers_1.default.xyz.toBasisConfig(textOrObject, unitz);
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
basis = textOrObject;
|
|
139
|
-
}
|
|
140
|
-
this.setProp("basis", basis);
|
|
141
|
-
this.unsetFileProps();
|
|
142
|
-
this.updateFormula();
|
|
143
|
-
}
|
|
144
|
-
setBasisConstraints(constraints) {
|
|
145
|
-
const basisWithConstraints = {
|
|
146
|
-
...this.basis,
|
|
147
|
-
constraints: constraints.map((c) => c.toJSON()),
|
|
148
|
-
};
|
|
149
|
-
this.setBasis(basisWithConstraints);
|
|
150
|
-
}
|
|
151
|
-
setBasisConstraintsFromArrayOfObjects(constraints) {
|
|
152
|
-
const constraintsInstances = constraints.map((c) => {
|
|
153
|
-
return constraints_1.Constraint.fromValueAndId(c.value, c.id);
|
|
154
|
-
});
|
|
155
|
-
this.setBasisConstraints(constraintsInstances);
|
|
156
|
-
}
|
|
157
|
-
get basis() {
|
|
158
|
-
return this.requiredProp("basis");
|
|
159
|
-
}
|
|
160
|
-
// returns the instance of {ConstrainedBasis} class
|
|
161
|
-
get Basis() {
|
|
162
|
-
const basisData = this.basis;
|
|
163
|
-
return new constrained_basis_1.ConstrainedBasis({
|
|
164
|
-
...basisData,
|
|
165
|
-
cell: this.Lattice.vectors,
|
|
166
|
-
constraints: basisData.constraints || [],
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* High-level access to unique elements from material instead of basis.
|
|
171
|
-
*/
|
|
172
|
-
get uniqueElements() {
|
|
173
|
-
return this.Basis.uniqueElements;
|
|
174
|
-
}
|
|
175
|
-
get lattice() {
|
|
176
|
-
return this.prop("lattice");
|
|
177
|
-
}
|
|
178
|
-
set lattice(config) {
|
|
179
|
-
const originalIsInCrystalUnits = this.Basis.isInCrystalUnits;
|
|
180
|
-
const basis = this.Basis;
|
|
181
|
-
basis.toCartesian();
|
|
182
|
-
const newLattice = new lattice_1.Lattice(config);
|
|
183
|
-
basis.cell = newLattice.vectors;
|
|
184
|
-
if (originalIsInCrystalUnits)
|
|
185
|
-
basis.toCrystal();
|
|
186
|
-
// Preserve all properties from the original basis to ensure constraints are included
|
|
187
|
-
const newBasisConfig = basis.toJSON();
|
|
188
|
-
this.setProp("basis", newBasisConfig);
|
|
189
|
-
this.setProp("lattice", config);
|
|
190
|
-
this.unsetFileProps();
|
|
191
|
-
}
|
|
192
|
-
get Lattice() {
|
|
193
|
-
return new lattice_1.Lattice(this.lattice);
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Returns the inchi string from the derivedProperties for a non-periodic material, or throws an error if the
|
|
197
|
-
* inchi cannot be found.
|
|
198
|
-
* @returns {String}
|
|
199
|
-
*/
|
|
200
|
-
getInchiStringForHash() {
|
|
201
|
-
const inchi = this.getDerivedPropertyByName("inchi");
|
|
202
|
-
if (inchi) {
|
|
203
|
-
return inchi.value;
|
|
204
|
-
}
|
|
205
|
-
throw new Error("Hash cannot be created. Missing InChI string in derivedProperties");
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Calculates hash from basis and lattice. Algorithm expects the following:
|
|
209
|
-
* - asserts lattice units to be angstrom
|
|
210
|
-
* - asserts basis units to be crystal
|
|
211
|
-
* - asserts basis coordinates and lattice measurements are rounded to hash precision
|
|
212
|
-
* - forms strings for lattice and basis
|
|
213
|
-
* - creates MD5 hash from basisStr + latticeStr + salt
|
|
214
|
-
* @param salt Salt for hashing, empty string by default.
|
|
215
|
-
* @param isScaled Whether to scale the lattice parameter 'a' to 1.
|
|
216
|
-
*/
|
|
217
|
-
calculateHash(salt = "", isScaled = false, bypassNonPeriodicCheck = false) {
|
|
218
|
-
let message;
|
|
219
|
-
if (!this.isNonPeriodic || bypassNonPeriodicCheck) {
|
|
220
|
-
message =
|
|
221
|
-
this.Basis.hashString + "#" + this.Lattice.getHashString(isScaled) + "#" + salt;
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
message = this.getInchiStringForHash();
|
|
225
|
-
}
|
|
226
|
-
return crypto_js_1.default.MD5(message).toString();
|
|
227
|
-
}
|
|
228
|
-
set hash(hash) {
|
|
229
|
-
this.setProp("hash", hash);
|
|
230
|
-
}
|
|
231
|
-
get hash() {
|
|
232
|
-
return this.prop("hash");
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Calculates hash from basis and lattice as above + scales lattice properties to make lattice.a = 1
|
|
236
|
-
*/
|
|
237
|
-
get scaledHash() {
|
|
238
|
-
return this.calculateHash("", true);
|
|
239
|
-
}
|
|
240
|
-
get external() {
|
|
241
|
-
return this.prop("external");
|
|
242
|
-
}
|
|
243
|
-
set external(external) {
|
|
244
|
-
this.setProp("external", external);
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Converts basis to crystal/fractional coordinates.
|
|
248
|
-
*/
|
|
249
|
-
toCrystal() {
|
|
250
|
-
const basis = this.Basis;
|
|
251
|
-
basis.toCrystal();
|
|
252
|
-
this.setProp("basis", basis.toJSON());
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Converts current material's basis coordinates to cartesian.
|
|
256
|
-
* No changes if coordinates already cartesian.
|
|
257
|
-
*/
|
|
258
|
-
toCartesian() {
|
|
259
|
-
const basis = this.Basis;
|
|
260
|
-
basis.toCartesian();
|
|
261
|
-
this.setProp("basis", basis.toJSON());
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Returns material's basis in XYZ format.
|
|
265
|
-
*/
|
|
266
|
-
getBasisAsXyz(fractional = false) {
|
|
267
|
-
return parsers_1.default.xyz.fromMaterial(this.toJSON(), fractional);
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Returns material in Quantum Espresso output format:
|
|
271
|
-
* ```
|
|
272
|
-
* CELL_PARAMETERS (angstroms)
|
|
273
|
-
* -0.543131284 -0.000000000 0.543131284
|
|
274
|
-
* -0.000000000 0.543131284 0.543131284
|
|
275
|
-
* -0.543131284 0.543131284 0.000000000
|
|
276
|
-
*
|
|
277
|
-
* ATOMIC_POSITIONS (crystal)
|
|
278
|
-
* Si 0.000000000 0.000000000 -0.000000000
|
|
279
|
-
* Si 0.250000000 0.250000000 0.250000000
|
|
280
|
-
* ```
|
|
281
|
-
*/
|
|
282
|
-
getAsQEFormat() {
|
|
283
|
-
return parsers_1.default.espresso.toEspressoFormat(this.toJSON());
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Returns material in POSCAR format. Pass `true` to ignore original poscar source and re-serialize.
|
|
287
|
-
*/
|
|
288
|
-
getAsPOSCAR(ignoreOriginal = false, omitConstraints = false) {
|
|
289
|
-
var _a;
|
|
290
|
-
// By default return original source if exists
|
|
291
|
-
if (((_a = this.src) === null || _a === void 0 ? void 0 : _a.extension) === "poscar" && !ignoreOriginal) {
|
|
292
|
-
return this.src.text;
|
|
293
|
-
}
|
|
294
|
-
return parsers_1.default.poscar.toPoscar(this.toJSON(), omitConstraints);
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Returns a copy of the material with conventional cell constructed instead of primitive.
|
|
298
|
-
*/
|
|
299
|
-
getACopyWithConventionalCell() {
|
|
300
|
-
const material = this.clone();
|
|
301
|
-
// if conventional and primitive cells are the same => return a copy.
|
|
302
|
-
if ((0, conventional_cell_1.isConventionalCellSameAsPrimitiveForLatticeType)(this.Lattice.type)) {
|
|
303
|
-
return material;
|
|
304
|
-
}
|
|
305
|
-
const conventionalSupercellMatrix = conventional_cell_1.PRIMITIVE_TO_CONVENTIONAL_CELL_MULTIPLIERS[this.Lattice.type];
|
|
306
|
-
const conventionalLatticeType = conventional_cell_1.PRIMITIVE_TO_CONVENTIONAL_CELL_LATTICE_TYPES[this.Lattice.type];
|
|
307
|
-
const config = supercell_1.default.generateConfig(this, conventionalSupercellMatrix);
|
|
308
|
-
config.lattice.type = conventionalLatticeType;
|
|
309
|
-
config.name = `${this.name} - conventional cell`;
|
|
310
|
-
// @ts-expect-error
|
|
311
|
-
return new this.constructor(config);
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* @summary a series of checks for the material and returns an array of results in ConsistencyChecks format.
|
|
315
|
-
* @returns Array of checks results
|
|
316
|
-
*/
|
|
317
|
-
getConsistencyChecks() {
|
|
318
|
-
const basisChecks = this.getBasisConsistencyChecks();
|
|
319
|
-
// any other Material checks can be added here
|
|
320
|
-
return basisChecks;
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* @summary a series of checks for the material's basis and returns an array of results in ConsistencyChecks format.
|
|
324
|
-
* @returns Array of checks results
|
|
325
|
-
*/
|
|
326
|
-
getBasisConsistencyChecks() {
|
|
327
|
-
const checks = [];
|
|
328
|
-
const limit = 1000;
|
|
329
|
-
const basis = this.Basis;
|
|
330
|
-
if (this.Basis.elements.length < limit) {
|
|
331
|
-
const overlappingAtomsGroups = basis.getOverlappingAtoms();
|
|
332
|
-
overlappingAtomsGroups.forEach(({ id1, id2, element1, element2 }) => {
|
|
333
|
-
checks.push({
|
|
334
|
-
key: `basis.coordinates.${id1}`,
|
|
335
|
-
name: "atomsOverlap",
|
|
336
|
-
severity: "warning",
|
|
337
|
-
message: `Atom ${element1} is too close to ${element2} at position ${id2 + 1}`,
|
|
338
|
-
}, {
|
|
339
|
-
key: `basis.coordinates.${id2}`,
|
|
340
|
-
name: "atomsOverlap",
|
|
341
|
-
severity: "warning",
|
|
342
|
-
message: `Atom ${element2} is too close to ${element1} at position ${id1 + 1}`,
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
return checks;
|
|
347
|
-
}
|
|
348
|
-
toJSON() {
|
|
349
|
-
// validation intoJSON() method will fail if name is not set in _json
|
|
350
|
-
this.name = this.name || this.formula;
|
|
351
|
-
return {
|
|
352
|
-
...super.toJSON(),
|
|
353
|
-
lattice: this.Lattice.toJSON(),
|
|
354
|
-
basis: this.Basis.toJSON(),
|
|
355
|
-
isNonPeriodic: this.isNonPeriodic,
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
exports.Material = Material;
|
|
360
|
-
(0, DefaultableMixin_1.defaultableEntityMixin)(Material);
|
|
361
|
-
(0, HasConsistencyChecksMixin_1.hasConsistencyChecksMixin)(Material.prototype);
|
|
362
|
-
(0, HasMetadataMixin_1.hasMetadataMixin)(Material.prototype);
|