@@ -50,7 +50,7 @@ class MatPesStaticFlowMaker(Maker):
50
50
),
51
51
)
52
52
)
53
- static2 : Maker = field (
53
+ static2 : Maker | None = field (
54
54
default_factory = lambda : MatPesMetaGGAStaticMaker (
55
55
# start from pre-conditioned WAVECAR from static1 to speed up convergence
56
56
# could copy CHGCAR too but is redundant since VASP can reconstruct it from
@@ -69,6 +69,11 @@ class MatPesStaticFlowMaker(Maker):
69
69
)
70
70
)
71
71
72
+ def __post_init__ (self ) -> None :
73
+ """Validate flow."""
74
+ if (self .static1 , self .static2 , self .static3 ) == (None , None , None ):
75
+ raise ValueError ("Must provide at least one StaticMaker" )
76
+
72
77
def make (self , structure : Structure , prev_dir : str | Path | None = None ) -> Flow :
73
78
"""Create a flow with MatPES statics.
74
79
@@ -89,10 +94,20 @@ def make(self, structure: Structure, prev_dir: str | Path | None = None) -> Flow
89
94
Flow
90
95
A flow containing 2 or 3 statics.
91
96
"""
92
- static1 = self .static1 .make (structure , prev_dir = prev_dir )
93
- static2 = self .static2 .make (structure , prev_dir = static1 .output .dir_name )
94
- output = {"static1" : static1 .output , "static2" : static2 .output }
95
- jobs = [static1 , static2 ]
97
+ jobs = []
98
+ output = {}
99
+
100
+ if self .static1 is not None :
101
+ static1 = self .static1 .make (structure , prev_dir = prev_dir )
102
+ jobs += [static1 ]
103
+ output ["static1" ] = static1 .output
104
+
105
+ prev_dir = static1 .output .dir_name if self .static1 is not None else prev_dir
106
+
107
+ if self .static2 is not None :
108
+ static2 = self .static2 .make (structure , prev_dir = prev_dir )
109
+ jobs += [static2 ]
110
+ output ["static2" ] = static2 .output
96
111
97
112
# only run 3rd static if set generator not None and structure contains at least
98
113
# one element with Hubbard +U corrections
@@ -104,7 +119,7 @@ def make(self, structure: Structure, prev_dir: str | Path | None = None) -> Flow
104
119
anion in elems and elems & {* cations }
105
120
for anion , cations in u_corrections .items ()
106
121
):
107
- static3 = self .static3 .make (structure , prev_dir = static1 . output . dir_name )
122
+ static3 = self .static3 .make (structure , prev_dir = prev_dir )
108
123
output ["static3" ] = static3 .output
109
124
jobs += [static3 ]
110
125
0 commit comments