Skip to content

Commit a9bf80e

Browse files
Merge pull request #13 from Exabyte-io/epic/SOF-6265
Epic/sof 6265
2 parents c1615d9 + f478de0 commit a9bf80e

File tree

6 files changed

+248
-246
lines changed

6 files changed

+248
-246
lines changed

package-lock.json

Lines changed: 104 additions & 165 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"@babel/preset-react": "7.16.7",
3737
"@babel/register": "^7.16.0",
3838
"@babel/runtime-corejs3": "7.16.8",
39-
"@exabyte-io/application-flavors.js": "2022.7.24-0",
39+
"@exabyte-io/application-flavors.js": "2022.11.10-0",
4040
"@exabyte-io/periodic-table.js": "2022.6.8-0",
4141
"lodash": "^4.17.21",
4242
"mixwith": "^0.1.1",
@@ -45,7 +45,7 @@
4545
"underscore.string": "^3.3.4"
4646
},
4747
"devDependencies": {
48-
"@exabyte-io/code.js": "2022.9.2-0",
48+
"@exabyte-io/code.js": "2022.11.11-0",
4949
"@exabyte-io/made.js": "2022.6.15-0",
5050
"chai": "^4.3.4",
5151
"eslint": "7.32.0",

src/context/providers/espresso/providers.js

Lines changed: 63 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,62 @@ import { Made } from "@exabyte-io/made.js";
1010
import { PERIODIC_TABLE } from "@exabyte-io/periodic-table.js";
1111
import lodash from "lodash";
1212
import { mix } from "mixwith";
13-
import _ from "underscore";
1413
import s from "underscore.string";
1514

1615
import { ExecutableContextProvider } from "../../providers";
1716

1817
export class QEPWXContextProvider extends mix(ExecutableContextProvider).with(
1918
MaterialContextMixin,
19+
MaterialsContextMixin,
2020
MethodDataContextMixin,
2121
WorkflowContextMixin,
2222
JobContextMixin,
2323
) {
2424
static Material = Made.Material;
2525

26-
get atomSymbols() {
27-
return this.material.Basis.uniqueElements;
26+
static atomSymbols(material) {
27+
return material.Basis.uniqueElements;
28+
}
29+
30+
/** Returns the input text block for atomic positions WITH constraints.
31+
*/
32+
static atomicPositionsWithConstraints(material) {
33+
return material.Basis.atomicPositionsWithConstraints.join("\n");
34+
}
35+
36+
/** Returns the input text block for atomic positions
37+
* Note: does NOT include constraints
38+
*/
39+
static atomicPositions(material) {
40+
return material.Basis.atomicPositions.join("\n");
41+
}
42+
43+
static NAT(material) {
44+
return material.Basis.atomicPositions.length;
45+
}
46+
47+
static NTYP(material) {
48+
return material.Basis.uniqueElements.length;
2849
}
2950

30-
get atomicPositionsWithoutConstraints() {
31-
return this.material.Basis.atomicPositions;
51+
buildQEPWXContext(material) {
52+
const IBRAV = 0; // use CELL_PARAMETERS to define Bravais lattice
53+
54+
return {
55+
IBRAV,
56+
RESTART_MODE: this.RESTART_MODE,
57+
ATOMIC_SPECIES: this.ATOMIC_SPECIES(material),
58+
NAT: QEPWXContextProvider.NAT(material),
59+
NTYP: QEPWXContextProvider.NTYP(material),
60+
ATOMIC_POSITIONS: QEPWXContextProvider.atomicPositionsWithConstraints(material),
61+
ATOMIC_POSITIONS_WITHOUT_CONSTRAINTS: QEPWXContextProvider.atomicPositions(material),
62+
CELL_PARAMETERS: QEPWXContextProvider.CELL_PARAMETERS(material),
63+
};
3264
}
3365

34-
get atomicPositions() {
35-
return this.material.Basis.atomicPositionsWithConstraints;
66+
getDataPerMaterial() {
67+
if (!this.materials || this.materials.length <= 1) return {};
68+
return { perMaterial: this.materials.map((material) => this.buildQEPWXContext(material)) };
3669
}
3770

3871
/*
@@ -44,17 +77,9 @@ export class QEPWXContextProvider extends mix(ExecutableContextProvider).with(
4477
// ECUTWFC = 40;
4578
// ECUTRHO = 200;
4679

47-
const IBRAV = 0;
48-
4980
return {
50-
IBRAV,
51-
RESTART_MODE: this.RESTART_MODE,
52-
NAT: this.atomicPositions.length,
53-
NTYP: this.atomSymbols.length,
54-
ATOMIC_POSITIONS: this.atomicPositions.join("\n"),
55-
ATOMIC_POSITIONS_WITHOUT_CONSTRAINTS: this.atomicPositionsWithoutConstraints.join("\n"),
56-
CELL_PARAMETERS: this.CELL_PARAMETERS,
57-
ATOMIC_SPECIES: this.ATOMIC_SPECIES,
81+
...this.buildQEPWXContext(this.material),
82+
...this.getDataPerMaterial(),
5883
};
5984
}
6085

@@ -66,16 +91,25 @@ export class QEPWXContextProvider extends mix(ExecutableContextProvider).with(
6691
return (this.methodData.pseudo || []).find((p) => p.element === symbol);
6792
}
6893

69-
get ATOMIC_SPECIES() {
70-
// atomic species with pseudopotentials
71-
return _.map(this.atomSymbols, (symbol) => {
72-
const pseudo = this.getPseudoBySymbol(symbol);
73-
return QEPWXContextProvider.symbolToAtomicSpecie(symbol, pseudo);
74-
}).join("\n");
94+
/** Builds ATOMIC SPECIES block of pw.x input in the format
95+
* X Mass_X PseudoPot_X
96+
* where X is the atom label
97+
* Mass_X is the mass of element X [amu]
98+
* PseudoPot_X is the pseudopotential filename associated with element X
99+
*
100+
* Note: assumes this.methodData is defined
101+
*/
102+
ATOMIC_SPECIES(material) {
103+
return QEPWXContextProvider.atomSymbols(material)
104+
.map((symbol) => {
105+
const pseudo = this.getPseudoBySymbol(symbol);
106+
return QEPWXContextProvider.symbolToAtomicSpecie(symbol, pseudo);
107+
})
108+
.join("\n");
75109
}
76110

77-
get CELL_PARAMETERS() {
78-
return this.material.Lattice.vectorArrays
111+
static CELL_PARAMETERS(material) {
112+
return material.Lattice.vectorArrays
79113
.map((x) => {
80114
return x
81115
.map((y) => {
@@ -114,7 +148,10 @@ export class QENEBContextProvider extends mix(ExecutableContextProvider).with(
114148
});
115149

116150
return {
117-
..._.omit(PWXContexts[0], ["ATOMIC_POSITIONS", "ATOMIC_POSITIONS_WITHOUT_CONSTRAINTS"]),
151+
...lodash.omit(PWXContexts[0], [
152+
"ATOMIC_POSITIONS",
153+
"ATOMIC_POSITIONS_WITHOUT_CONSTRAINTS",
154+
]),
118155
FIRST_IMAGE: PWXContexts[0].ATOMIC_POSITIONS,
119156
LAST_IMAGE: PWXContexts[PWXContexts.length - 1].ATOMIC_POSITIONS,
120157
INTERMEDIATE_IMAGES: PWXContexts.slice(1, PWXContexts.length - 1).map(

src/context/providers/vasp/providers.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,27 @@ import { ExecutableContextProvider } from "../../providers";
1313

1414
export class VASPContextProvider extends mix(ExecutableContextProvider).with(
1515
MaterialContextMixin,
16+
MaterialsContextMixin,
1617
MethodDataContextMixin,
1718
WorkflowContextMixin,
1819
JobContextMixin,
1920
) {
2021
static Material = Made.Material;
2122

23+
// eslint-disable-next-line class-methods-use-this
24+
buildVASPContext(material) {
25+
return {
26+
// TODO: figure out whether we need two separate POSCARS, maybe one is enough
27+
POSCAR: material.getAsPOSCAR(true, true),
28+
POSCAR_WITH_CONSTRAINTS: material.getAsPOSCAR(true),
29+
};
30+
}
31+
32+
getDataPerMaterial() {
33+
if (!this.materials || this.materials.length <= 1) return {};
34+
return { perMaterial: this.materials.map((material) => this.buildVASPContext(material)) };
35+
}
36+
2237
/*
2338
* @NOTE: Overriding getData makes this provider "stateless", ie. delivering data from scratch each time and not
2439
* considering the content of `this.data`, and `this.isEdited` field(s).
@@ -29,9 +44,8 @@ export class VASPContextProvider extends mix(ExecutableContextProvider).with(
2944
// ECUTRHO;
3045

3146
return {
32-
// TODO: figure out whether we need two separate POSCARS, maybe one is enough
33-
POSCAR: this.material.getAsPOSCAR(true, true),
34-
POSCAR_WITH_CONSTRAINTS: this.material.getAsPOSCAR(true),
47+
...this.buildVASPContext(this.material),
48+
...this.getDataPerMaterial(),
3549
};
3650
}
3751
}

src/executable.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
import { mix } from "mixwith";
21
import { NamedDefaultableInMemoryEntity, RuntimeItemsMixin } from "@exabyte-io/code.js/dist/entity";
2+
import { mix } from "mixwith";
3+
34
import { Flavor } from "./flavor";
45

56
export class Executable extends mix(NamedDefaultableInMemoryEntity).with(RuntimeItemsMixin) {
67
static Flavor = Flavor;
78

8-
constructor(config) {
9-
super(config);
10-
}
11-
129
toJSON(exclude) {
1310
return super.toJSON(["flavors"].concat(exclude));
1411
}
@@ -18,18 +15,18 @@ export class Executable extends mix(NamedDefaultableInMemoryEntity).with(Runtime
1815
}
1916

2017
get flavors() {
21-
return Object.keys(this.flavorsTree).map(key => {
22-
return this.constructor.Flavor.create(
23-
Object.assign({}, this.flavorsTree[key], {name: key, executable: this})
24-
);
18+
return Object.keys(this.flavorsTree).map((key) => {
19+
return this.constructor.Flavor.create({
20+
...this.flavorsTree[key],
21+
name: key,
22+
executable: this,
23+
});
2524
});
2625
}
2726

2827
get flavorsFromTree() {
29-
return Object.keys(this.flavorsTree).map(key => {
30-
return new this.constructor.Flavor(
31-
Object.assign({}, this.flavorsTree[key], {name: key})
32-
);
28+
return Object.keys(this.flavorsTree).map((key) => {
29+
return new this.constructor.Flavor({ ...this.flavorsTree[key], name: key });
3330
});
3431
}
3532

@@ -44,5 +41,4 @@ export class Executable extends mix(NamedDefaultableInMemoryEntity).with(Runtime
4441
getFlavorByConfig(config) {
4542
return config ? this.getFlavorByName(config.name) : this.defaultFlavor;
4643
}
47-
4844
}

0 commit comments

Comments
 (0)