@@ -1122,6 +1122,54 @@ def next_g_size(cur_g_size):
1122
1122
1123
1123
return ng_vec , [ng_ * finer_g_scale for ng_ in ng_vec ]
1124
1124
1125
+ @staticmethod
1126
+ def from_directory (directory : str | Path , optional_files : dict = None ) -> VaspInput :
1127
+ """Load a set of VASP inputs from a directory.
1128
+
1129
+ Note that only the standard INCAR, POSCAR, POTCAR and KPOINTS files are read
1130
+ unless optional_filenames is specified.
1131
+
1132
+ Parameters
1133
+ ----------
1134
+ directory
1135
+ Directory to read VASP inputs from.
1136
+ optional_files
1137
+ Optional files to read in as well as a dict of {filename: Object class}.
1138
+ Object class must have a static/class method from_file.
1139
+ """
1140
+ directory = Path (directory )
1141
+ objs = {"INCAR" : Incar , "KPOINTS" : Kpoints , "POSCAR" : Poscar , "POTCAR" : Potcar }
1142
+
1143
+ inputs = {}
1144
+ for name , obj in objs .items ():
1145
+ if (directory / name ).exists ():
1146
+ inputs [name .upper ()] = obj .from_file (directory / name )
1147
+ else :
1148
+ # handle the case where there is no KPOINTS file
1149
+ inputs [name .upper ()] = None
1150
+
1151
+ optional_inputs = {}
1152
+ if optional_files is not None :
1153
+ for name , obj in optional_files .items ():
1154
+ optional_inputs [name ] = obj .from_file (directory / name )
1155
+
1156
+ return VaspInput (
1157
+ incar = inputs ["INCAR" ],
1158
+ kpoints = inputs ["KPOINTS" ],
1159
+ poscar = inputs ["POSCAR" ],
1160
+ potcar = inputs ["POTCAR" ],
1161
+ optional_files = optional_inputs ,
1162
+ )
1163
+
1164
+ def _get_nedos (self , dedos : float ) -> int :
1165
+ """Automatic setting of nedos using the energy range and the energy step."""
1166
+ if self .prev_vasprun is None :
1167
+ return 2000
1168
+
1169
+ emax = max (eigs .max () for eigs in self .prev_vasprun .eigenvalues .values ())
1170
+ emin = min (eigs .min () for eigs in self .prev_vasprun .eigenvalues .values ())
1171
+ return int ((emax - emin ) / dedos )
1172
+
1125
1173
1126
1174
# create VaspInputGenerator alias to follow atomate2 terminology
1127
1175
VaspInputGenerator = VaspInputSet
0 commit comments