@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,269 @@
|
|
|
1
|
+
import _ from "underscore";
|
|
2
|
+
import { ArrayWithIds } from "../abstract/array_with_ids";
|
|
3
|
+
import { ObjectWithIdAndValue, ValueOrObjectArray } from "../abstract/scalar_with_id";
|
|
4
|
+
import { ATOMIC_COORD_UNITS } from "../constants";
|
|
5
|
+
import { Vector } from "../lattice/types";
|
|
6
|
+
import { Coordinate } from "./types";
|
|
7
|
+
export interface BasisProps {
|
|
8
|
+
elements: ValueOrObjectArray<string>;
|
|
9
|
+
coordinates: ValueOrObjectArray<Coordinate>;
|
|
10
|
+
labels?: {
|
|
11
|
+
id: number;
|
|
12
|
+
value: number;
|
|
13
|
+
}[];
|
|
14
|
+
units: string;
|
|
15
|
+
cell: Vector[];
|
|
16
|
+
isEmpty?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface Atom {
|
|
19
|
+
id?: number;
|
|
20
|
+
element: string;
|
|
21
|
+
coordinate: Coordinate;
|
|
22
|
+
}
|
|
23
|
+
export interface ElementCount {
|
|
24
|
+
count: number;
|
|
25
|
+
value: string;
|
|
26
|
+
}
|
|
27
|
+
export interface BasisSchema {
|
|
28
|
+
elements: ObjectWithIdAndValue<string>[];
|
|
29
|
+
labels?: {
|
|
30
|
+
id: number;
|
|
31
|
+
value: number;
|
|
32
|
+
}[];
|
|
33
|
+
coordinates: ObjectWithIdAndValue<Coordinate>[];
|
|
34
|
+
units: string;
|
|
35
|
+
cell: Vector[];
|
|
36
|
+
}
|
|
37
|
+
interface Overlap {
|
|
38
|
+
id1: number;
|
|
39
|
+
id2: number;
|
|
40
|
+
element1: string;
|
|
41
|
+
element2: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A class representing a crystal basis.
|
|
45
|
+
*/
|
|
46
|
+
export declare class Basis {
|
|
47
|
+
_elements: ArrayWithIds<string>;
|
|
48
|
+
_coordinates: ArrayWithIds<Coordinate>;
|
|
49
|
+
labels?: {
|
|
50
|
+
id: number;
|
|
51
|
+
value: number;
|
|
52
|
+
}[];
|
|
53
|
+
units: string;
|
|
54
|
+
cell: Vector[];
|
|
55
|
+
constructor({ elements, coordinates, units, cell, // by default, assume a cubic unary cell
|
|
56
|
+
isEmpty, // whether to generate an empty Basis
|
|
57
|
+
labels, }: BasisProps);
|
|
58
|
+
static get unitsOptionsConfig(): typeof ATOMIC_COORD_UNITS;
|
|
59
|
+
static get unitsOptionsDefaultValue(): string;
|
|
60
|
+
static get defaultCell(): [import("@mat3ra/esse/lib/js/types").ArrayOf3NumberElementsSchema, import("@mat3ra/esse/lib/js/types").ArrayOf3NumberElementsSchema, import("@mat3ra/esse/lib/js/types").ArrayOf3NumberElementsSchema];
|
|
61
|
+
/**
|
|
62
|
+
* Serialize class instance to JSON.
|
|
63
|
+
* @example As below:
|
|
64
|
+
{
|
|
65
|
+
"elements" : [
|
|
66
|
+
{
|
|
67
|
+
"id" : 0,
|
|
68
|
+
"value" : "Si"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"id" : 1,
|
|
72
|
+
"value" : "Si"
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
"coordinates" : [
|
|
76
|
+
{
|
|
77
|
+
"id" : 0,
|
|
78
|
+
"value" : [
|
|
79
|
+
0,
|
|
80
|
+
0,
|
|
81
|
+
0
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"id" : 1,
|
|
86
|
+
"value" : [
|
|
87
|
+
0.25,
|
|
88
|
+
0.25,
|
|
89
|
+
0.25
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"units" : "crystal",
|
|
94
|
+
"cell" : [
|
|
95
|
+
[
|
|
96
|
+
1,
|
|
97
|
+
0,
|
|
98
|
+
6.12323399573677e-17
|
|
99
|
+
],
|
|
100
|
+
[
|
|
101
|
+
1.60812264967664e-16,
|
|
102
|
+
1,
|
|
103
|
+
6.12323399573677e-17
|
|
104
|
+
],
|
|
105
|
+
[
|
|
106
|
+
0,
|
|
107
|
+
0,
|
|
108
|
+
1
|
|
109
|
+
]
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
*/
|
|
113
|
+
toJSON(): BasisSchema;
|
|
114
|
+
/**
|
|
115
|
+
* Create an identical copy of the class instance.
|
|
116
|
+
* @param extraContext - Extra context to be passed to the new class instance on creation.
|
|
117
|
+
*/
|
|
118
|
+
clone(extraContext?: Partial<BasisProps>): Basis;
|
|
119
|
+
getElementByIndex(idx: number): string;
|
|
120
|
+
getCoordinateByIndex(idx: number): Coordinate;
|
|
121
|
+
get elementsArray(): string[];
|
|
122
|
+
get elements(): ObjectWithIdAndValue<string>[];
|
|
123
|
+
/**
|
|
124
|
+
* Set basis elements to passed array.
|
|
125
|
+
* @param elementsArray - New elements array.
|
|
126
|
+
*/
|
|
127
|
+
set elements(elementsArray: string[] | ObjectWithIdAndValue<string>[]);
|
|
128
|
+
getElementsAsObject(): ObjectWithIdAndValue<string>[];
|
|
129
|
+
get coordinates(): ObjectWithIdAndValue<Coordinate>[];
|
|
130
|
+
/**
|
|
131
|
+
* Set basis elements to passed array.
|
|
132
|
+
* @param {Array|ArrayWithIds} coordinatesNestedArray - New coordinates array.
|
|
133
|
+
*/
|
|
134
|
+
set coordinates(coordinatesNestedArray: Coordinate[] | ObjectWithIdAndValue<Coordinate>[]);
|
|
135
|
+
get coordinatesAsArray(): Coordinate[];
|
|
136
|
+
get isInCrystalUnits(): boolean;
|
|
137
|
+
get isInCartesianUnits(): boolean;
|
|
138
|
+
toCartesian(): void;
|
|
139
|
+
toCrystal(): void;
|
|
140
|
+
/**
|
|
141
|
+
* Asserts that all coordinates are in standardRepresentation (as explained below).
|
|
142
|
+
*/
|
|
143
|
+
toStandardRepresentation(): void;
|
|
144
|
+
/** A representation where all coordinates are within 0 and 1 in crystal units */
|
|
145
|
+
get standardRepresentation(): BasisSchema;
|
|
146
|
+
/**
|
|
147
|
+
* Add atom with a chemical element at coordinate.
|
|
148
|
+
*/
|
|
149
|
+
addAtom({ element, coordinate }: Atom): void;
|
|
150
|
+
/**
|
|
151
|
+
* Remove atom with a chemical element at coordinate either by passing the (element AND coordinate) OR id.
|
|
152
|
+
*/
|
|
153
|
+
removeAtom({ element, coordinate, id }: Atom): void;
|
|
154
|
+
/**
|
|
155
|
+
* Unique names (symbols) of the chemical elements basis. E.g. `['Si', 'Li']`
|
|
156
|
+
*/
|
|
157
|
+
get uniqueElements(): string[];
|
|
158
|
+
/**
|
|
159
|
+
* Returns unique chemical elements with their count sorted by electronegativity.
|
|
160
|
+
* `{ "Fe": 4.0, "O": 8.0, "Li": 2.0}`.
|
|
161
|
+
*/
|
|
162
|
+
get uniqueElementCountsSortedByElectronegativity(): _.Dictionary<number>;
|
|
163
|
+
/**
|
|
164
|
+
* Returns chemical elements with their count wrt their original order in the basis.
|
|
165
|
+
* Note: entries for the same element separated by another element are considered separately.
|
|
166
|
+
* [{"count":1, "value":"Zr"}, {"count":23, "value":"H"}, {"count":11, "value":"Zr"}, {"count":1, "value":"H"}]
|
|
167
|
+
*/
|
|
168
|
+
get elementCounts(): ElementCount[];
|
|
169
|
+
/**
|
|
170
|
+
* Reduced formula in IUPAC format. E.g., Na2SO4
|
|
171
|
+
*/
|
|
172
|
+
get formula(): string;
|
|
173
|
+
/**
|
|
174
|
+
* Returns the unit cell formula as object `{ "Fe": 4.0, "O": 8.0, "Li": 2.0}`
|
|
175
|
+
*/
|
|
176
|
+
get unitCellFormula(): string;
|
|
177
|
+
/**
|
|
178
|
+
* Returns a nested array with elements and their corresponding coordinates
|
|
179
|
+
* @example Output: [ ["Si", [0,0,0]], ["Si", [0.5,0.5,0.5]] ]
|
|
180
|
+
*/
|
|
181
|
+
get elementsAndCoordinatesArray(): [string, Coordinate, string][];
|
|
182
|
+
/**
|
|
183
|
+
* @summary Concatenates elements and sorts them in alphanumeric order.
|
|
184
|
+
* E.g.,
|
|
185
|
+
* ```
|
|
186
|
+
* elements: [{id: 0, value: 'Si'}, {id: 1, value: 'Si'}]
|
|
187
|
+
* coordinates: [{id: 0, value: [1,0,0]}, {id: 1, value: [0, 1, 0]}]
|
|
188
|
+
*
|
|
189
|
+
* result: "Si 0,1,0;Si 1,0,0"
|
|
190
|
+
* ```
|
|
191
|
+
* This guarantees the independence from the order in the elements array.
|
|
192
|
+
*/
|
|
193
|
+
getAsSortedString(): string;
|
|
194
|
+
/**
|
|
195
|
+
* Returns a string for hash calculation (in crystal units)
|
|
196
|
+
*/
|
|
197
|
+
get hashString(): string;
|
|
198
|
+
get atomicLabelsArray(): string[];
|
|
199
|
+
get elementsWithLabelsArray(): string[];
|
|
200
|
+
/**
|
|
201
|
+
* Returns an array of strings with chemical elements and their atomic positions.
|
|
202
|
+
* E.g., ``` ['Si 0 0 0', 'Li 0.5 0.5 0.5']```
|
|
203
|
+
*/
|
|
204
|
+
get atomicPositions(): string[];
|
|
205
|
+
/**
|
|
206
|
+
* @summary Returns number of atoms in material
|
|
207
|
+
*/
|
|
208
|
+
get nAtoms(): number;
|
|
209
|
+
/**
|
|
210
|
+
* @summary Returns true if bases are equal, otherwise - false.
|
|
211
|
+
* @param anotherBasisClsInstance {Basis} Another Basis.
|
|
212
|
+
*/
|
|
213
|
+
isEqualTo(anotherBasisClsInstance: Basis): boolean;
|
|
214
|
+
/**
|
|
215
|
+
* @summary Returns true if basis cells are equal, otherwise - false.
|
|
216
|
+
* @param anotherBasisClsInstance {Basis} Another Basis.
|
|
217
|
+
*/
|
|
218
|
+
hasEquivalentCellTo(anotherBasisClsInstance: Basis): boolean;
|
|
219
|
+
/**
|
|
220
|
+
* @summary function returns the minimum basis lattice size for a structure.
|
|
221
|
+
* The lattice size is based on the atomic radius of an element if the basis contains a single atom.
|
|
222
|
+
* The lattice size is based on the maximum pairwise distance across a structure if the basis contains > 2 atoms.
|
|
223
|
+
*/
|
|
224
|
+
getMinimumLatticeSize(latticeScalingFactor?: number): number;
|
|
225
|
+
/**
|
|
226
|
+
* @summary function returns an array of overlapping atoms within specified tolerance.
|
|
227
|
+
*/
|
|
228
|
+
getOverlappingAtoms(): Overlap[];
|
|
229
|
+
/**
|
|
230
|
+
* @summary function returns the max distance between pairs of basis coordinates by
|
|
231
|
+
* calculating the distance between pairs of basis coordinates.
|
|
232
|
+
* basis coordinates = [[x1, y1, z1], [x2, y2, z2], ... [xn, yn, zn]]
|
|
233
|
+
* n = last set of coordinates
|
|
234
|
+
* n-1 = second to last set of coordinates
|
|
235
|
+
*
|
|
236
|
+
* Iterate through pairs without redundancy.
|
|
237
|
+
* pair 0,1 pair 0,2 pair 0,3 ... pair 0,n
|
|
238
|
+
* - pair 1,2 pair 1,3 ... pair 1,n
|
|
239
|
+
* - - - pair 2,3 ... pair 2,n
|
|
240
|
+
* - - - ... ...
|
|
241
|
+
* - - - ... ... pair n-1, n
|
|
242
|
+
*
|
|
243
|
+
*/
|
|
244
|
+
get maxPairwiseDistance(): number;
|
|
245
|
+
/**
|
|
246
|
+
* @summary Function takes basis coordinates and transposes them so that the values for each dimension of the
|
|
247
|
+
* the basis are in their own nested array.
|
|
248
|
+
* Then the center point for each dimension of the coordinates is calculated.
|
|
249
|
+
*
|
|
250
|
+
* initial basisCoordinates
|
|
251
|
+
* [[x1, y1, z1],
|
|
252
|
+
* [x2, y2, z2],
|
|
253
|
+
* [.., .., ..],
|
|
254
|
+
* [xn, yn, zn]]
|
|
255
|
+
*
|
|
256
|
+
* transposed basisCoordinates
|
|
257
|
+
* [[x1, x2, ...xn],
|
|
258
|
+
* [y1, y2, ...yn],
|
|
259
|
+
* [z1, z2, ...zn]]
|
|
260
|
+
*
|
|
261
|
+
* Returns an array = [xCenter, yCenter, zCenter]
|
|
262
|
+
*/
|
|
263
|
+
get centerOfCoordinatesPoint(): number[];
|
|
264
|
+
/**
|
|
265
|
+
* @summary Function translates coordinates by the vector passed as an argument.
|
|
266
|
+
*/
|
|
267
|
+
translateByVector(translationVector: number[]): void;
|
|
268
|
+
}
|
|
269
|
+
export {};
|