1
- import _ from "underscore" ;
2
- import lodash from "lodash" ;
3
- import { mix } from "mixwith" ;
4
- import s from "underscore.string" ;
5
-
6
- import { Made } from "@exabyte-io/made.js" ;
7
- import { PERIODIC_TABLE } from "@exabyte-io/periodic-table.js" ;
8
-
9
1
import {
10
- MaterialContextMixinBuilder ,
11
- MaterialsContextMixinBuilder ,
2
+ JobContextMixin ,
3
+ MaterialContextMixin ,
4
+ MaterialsContextMixin ,
12
5
MaterialsSetContextMixin ,
13
6
MethodDataContextMixin ,
14
7
WorkflowContextMixin ,
15
- JobContextMixin
16
8
} from "@exabyte-io/code.js/dist/context" ;
9
+ import { Made } from "@exabyte-io/made.js" ;
10
+ import { PERIODIC_TABLE } from "@exabyte-io/periodic-table.js" ;
11
+ import lodash from "lodash" ;
12
+ import { mix } from "mixwith" ;
13
+ import _ from "underscore" ;
14
+ import s from "underscore.string" ;
15
+
17
16
import { ExecutableContextProvider } from "../../providers" ;
18
17
19
18
export class QEPWXContextProvider extends mix ( ExecutableContextProvider ) . with (
20
- MaterialContextMixinBuilder ( Made . Material ) ,
19
+ MaterialContextMixin ,
21
20
MethodDataContextMixin ,
22
21
WorkflowContextMixin ,
23
22
JobContextMixin ,
24
23
) {
24
+ static materialCls = Made . Material ;
25
25
26
- get atomSymbols ( ) { return this . material . Basis . uniqueElements }
26
+ get atomSymbols ( ) {
27
+ return this . material . Basis . uniqueElements ;
28
+ }
27
29
28
- get atomicPositionsWithoutConstraints ( ) { return this . material . Basis . atomicPositions }
30
+ get atomicPositionsWithoutConstraints ( ) {
31
+ return this . material . Basis . atomicPositions ;
32
+ }
29
33
30
- get atomicPositions ( ) { return this . material . Basis . atomicPositionsWithConstraints } ;
34
+ get atomicPositions ( ) {
35
+ return this . material . Basis . atomicPositionsWithConstraints ;
36
+ }
31
37
32
38
/*
33
39
* @NOTE : Overriding getData makes this provider "stateless", ie. delivering data from scratch each time and not
34
40
* considering the content of `this.data`, and `this.isEdited` field(s).
35
41
*/
36
42
getData ( ) {
37
-
38
43
// the below values are read from PlanewaveDataManager instead
39
44
// ECUTWFC = 40;
40
45
// ECUTRHO = 200;
@@ -46,67 +51,75 @@ export class QEPWXContextProvider extends mix(ExecutableContextProvider).with(
46
51
RESTART_MODE : this . RESTART_MODE ,
47
52
NAT : this . atomicPositions . length ,
48
53
NTYP : this . atomSymbols . length ,
49
- ATOMIC_POSITIONS : this . atomicPositions . join ( '\n' ) ,
50
- ATOMIC_POSITIONS_WITHOUT_CONSTRAINTS : this . atomicPositionsWithoutConstraints . join ( '\n' ) ,
54
+ ATOMIC_POSITIONS : this . atomicPositions . join ( "\n" ) ,
55
+ ATOMIC_POSITIONS_WITHOUT_CONSTRAINTS : this . atomicPositionsWithoutConstraints . join ( "\n" ) ,
51
56
CELL_PARAMETERS : this . CELL_PARAMETERS ,
52
57
ATOMIC_SPECIES : this . ATOMIC_SPECIES ,
53
- }
58
+ } ;
54
59
}
55
60
56
61
get RESTART_MODE ( ) {
57
- return ( this . job . parentJob || this . workflow . hasRelaxation ) ? ' restart' : ' from_scratch' ;
62
+ return this . job . parentJob || this . workflow . hasRelaxation ? " restart" : " from_scratch" ;
58
63
}
59
64
60
65
getPseudoBySymbol ( symbol ) {
61
- return ( this . methodData . pseudo || [ ] ) . find ( p => p . element === symbol ) ;
66
+ return ( this . methodData . pseudo || [ ] ) . find ( ( p ) => p . element === symbol ) ;
62
67
}
63
68
64
69
get ATOMIC_SPECIES ( ) {
65
70
// atomic species with pseudopotentials
66
71
return _ . map ( this . atomSymbols , ( symbol ) => {
67
72
const pseudo = this . getPseudoBySymbol ( symbol ) ;
68
73
return QEPWXContextProvider . symbolToAtomicSpecie ( symbol , pseudo ) ;
69
- } ) . join ( '\n' ) ;
74
+ } ) . join ( "\n" ) ;
70
75
}
71
76
72
77
get CELL_PARAMETERS ( ) {
73
- return this . material . Lattice . vectorArrays . map ( x => {
74
- return x . map ( y => {
75
- return s . sprintf ( '%14.9f' , y ) . trim ( ) ;
76
- } ) . join ( ' ' ) ;
77
- } ) . join ( '\n' ) ;
78
-
78
+ return this . material . Lattice . vectorArrays
79
+ . map ( ( x ) => {
80
+ return x
81
+ . map ( ( y ) => {
82
+ return s . sprintf ( "%14.9f" , y ) . trim ( ) ;
83
+ } )
84
+ . join ( " " ) ;
85
+ } )
86
+ . join ( "\n" ) ;
79
87
}
80
88
81
89
static symbolToAtomicSpecie ( symbol , pseudo ) {
82
90
const el = PERIODIC_TABLE [ symbol ] ;
83
- const filename = pseudo ? lodash . get ( pseudo , 'filename' , s . strRightBack ( pseudo . path , '/' ) ) : '' ;
84
- return el ? s . sprintf ( '%s %f %s' , symbol , el . atomic_mass , filename ) : undefined ;
91
+ const filename = pseudo
92
+ ? lodash . get ( pseudo , "filename" , s . strRightBack ( pseudo . path , "/" ) )
93
+ : "" ;
94
+ return el ? s . sprintf ( "%s %f %s" , symbol , el . atomic_mass , filename ) : undefined ;
85
95
}
86
96
}
87
97
88
98
export class QENEBContextProvider extends mix ( ExecutableContextProvider ) . with (
89
- MaterialContextMixinBuilder ( Made . Material ) ,
90
- MaterialsContextMixinBuilder ( Made . Material ) ,
99
+ MaterialContextMixin ,
100
+ MaterialsContextMixin ,
91
101
MaterialsSetContextMixin ,
92
102
MethodDataContextMixin ,
93
103
WorkflowContextMixin ,
94
104
JobContextMixin ,
95
105
) {
106
+ static materialCls = Made . Material ;
96
107
97
108
getData ( ) {
98
109
const sortedMaterials = this . sortMaterialsByIndexInSet ( this . materials ) ;
99
- const PWXContexts = sortedMaterials . map ( material => {
100
- const context = Object . assign ( { } , this . config . context , { material : material } ) ;
101
- const config = Object . assign ( { } , this . config , { context} ) ;
110
+ const PWXContexts = sortedMaterials . map ( ( material ) => {
111
+ const context = { ... this . config . context , material } ;
112
+ const config = { ... this . config , context } ;
102
113
return new QEPWXContextProvider ( config ) . getData ( ) ;
103
114
} ) ;
104
115
105
116
return {
106
117
..._ . omit ( PWXContexts [ 0 ] , [ "ATOMIC_POSITIONS" , "ATOMIC_POSITIONS_WITHOUT_CONSTRAINTS" ] ) ,
107
118
FIRST_IMAGE : PWXContexts [ 0 ] . ATOMIC_POSITIONS ,
108
119
LAST_IMAGE : PWXContexts [ PWXContexts . length - 1 ] . ATOMIC_POSITIONS ,
109
- INTERMEDIATE_IMAGES : PWXContexts . slice ( 1 , PWXContexts . length - 1 ) . map ( data => data . ATOMIC_POSITIONS ) ,
110
- }
120
+ INTERMEDIATE_IMAGES : PWXContexts . slice ( 1 , PWXContexts . length - 1 ) . map (
121
+ ( data ) => data . ATOMIC_POSITIONS ,
122
+ ) ,
123
+ } ;
111
124
}
112
125
}
0 commit comments