def isif3_lowacc(self): """ Run low accuracy ISIF3 Returns: mof (ASE Atoms object): updated ASE Atoms object """ acc_levels = self.acc_levels outcar_paths = self.outcar_paths error_outcar_paths = self.error_outcar_paths spin_label = self.spin_label kpts_lo = self.kpts_dict['kpts_lo'] acc_level = acc_levels[self.run_i] calcs = self.calcs prior_results_path = os.path.join( self.results_partial_paths[self.run_i - 1], spin_label) if os.path.isfile(outcar_paths[self.run_i - 1]) and not os.path.isfile( outcar_paths[self.run_i]) and not os.path.isfile( error_outcar_paths[self.run_i]): mof = prep_new_run(self) converged = False loop_i = 0 n_runs = 15 manage_restart_files(prior_results_path) while not converged and loop_i < n_runs: if loop_i == 10 and 'fire' not in self.calc_swaps and 'zbrent' not in self.calc_swaps: self.calc_swaps.append('fire') pprint('Running ' + spin_label + ', ' + acc_level + ': iteration ' + str(loop_i) + '/' + str(n_runs - 1)) mof, self.calc_swaps = mof_run(self, mof, calcs('isif3_lowacc'), kpts_lo) if mof is None: break converged = mof.calc.converged mof = read('OUTCAR') mof = continue_magmoms(mof, 'INCAR') loop_i += 1 if 'fire' in self.calc_swaps: self.calc_swaps.remove('fire') if mof is not None and converged: write_success(self) else: write_errors(self, mof) elif os.path.isfile(outcar_paths[self.run_i]): pprint('COMPLETED: ' + spin_label + ', ' + acc_level) mof = prep_next_run(self) if mof is None: pprint('Skipping rest because of errors') return None return mof
def isif2_highacc(self): """ Run high accuracy ISIF2 Returns: mof (ASE Atoms object): updated ASE Atoms object """ acc_levels = self.acc_levels outcar_paths = self.outcar_paths error_outcar_paths = self.error_outcar_paths spin_label = self.spin_label kpts_hi = self.kpts_dict['kpts_hi'] acc_level = acc_levels[self.run_i] calcs = self.calcs prior_results_path = os.path.join( self.results_partial_paths[self.run_i - 1], spin_label) if os.path.isfile(outcar_paths[self.run_i - 1]) and not os.path.isfile( outcar_paths[self.run_i]) and not os.path.isfile( error_outcar_paths[self.run_i]): mof = prep_new_run(self) manage_restart_files(prior_results_path) pprint('Running ' + spin_label + ', ' + acc_level) mof, self.calc_swaps = mof_run(self, mof, calcs('isif2_highacc'), kpts_hi) if mof is not None and mof.calc.scf_converged and mof.calc.converged: if 'large_supercell' in self.calc_swaps: self.calc_swaps.remove('large_supercell') mof = read('OUTCAR') mof = continue_magmoms(mof, 'INCAR') mof, self.calc_swaps = mof_run(self, mof, calcs('isif2_highacc'), kpts_hi) if mof is not None and mof.calc.scf_converged and mof.calc.converged: write_success(self) else: write_errors(self, mof) else: write_success(self) else: write_errors(self, mof) elif os.path.isfile(outcar_paths[self.run_i]): pprint('COMPLETED: ' + spin_label + ', ' + acc_level) mof = prep_next_run(self) if mof is None: pprint('Skipping rest because of errors') return None return mof
def prep_new_run(workflow): acc_levels = workflow.acc_levels acc_level = acc_levels[workflow.run_i - 1] refcode = workflow.refcode spin_label = workflow.spin_label basepath = workflow.basepath success_path = os.path.join(basepath, 'results', refcode, acc_level, spin_label) outcarpath = os.path.join(success_path, 'OUTCAR') incarpath = os.path.join(success_path, 'INCAR') mof = read(outcarpath) mof_initialized = deepcopy(mof) mof_initialized = continue_magmoms(mof_initialized, incarpath) return mof_initialized
def isif3_highacc(self): """ Run high accuracy ISIF3 Returns: mof (ASE Atoms object): updated ASE Atoms object """ acc_levels = self.acc_levels outcar_paths = self.outcar_paths error_outcar_paths = self.error_outcar_paths spin_label = self.spin_label kpts_lo = self.kpts_dict['kpts_lo'] kpts_hi = self.kpts_dict['kpts_hi'] acc_level = acc_levels[self.run_i] calcs = self.calcs prior_results_path = os.path.join( self.results_partial_paths[self.run_i - 1], spin_label) if os.path.isfile(outcar_paths[self.run_i - 1]) and not os.path.isfile( outcar_paths[self.run_i]) and not os.path.isfile( error_outcar_paths[self.run_i]): mof = prep_new_run(self) converged = False loop_i = 0 n_runs = 15 V_diff = np.inf V_cut = 0.01 V0 = mof.get_volume() if sum(kpts_lo) == 3 and sum(kpts_hi) > 3: clean_files(['CHGCAR', 'WAVECAR']) else: manage_restart_files(prior_results_path) while (not converged or V_diff > V_cut) and loop_i < n_runs: if loop_i == 10 and 'fire' not in self.calc_swaps and 'zbrent' not in self.calc_swaps: self.calc_swaps.append('fire') pprint('Running ' + spin_label + ', ' + acc_level + ': iteration ' + str(loop_i) + '/' + str(n_runs - 1)) mof, self.calc_swaps = mof_run(self, mof, calcs('isif3_highacc'), kpts_hi) if mof is None: break if loop_i > 0: converged = mof.calc.converged mof = read('OUTCAR') V = mof.get_volume() mof = continue_magmoms(mof, 'INCAR') if loop_i > 0: V_diff = np.abs((V - V0)) / V0 V0 = V loop_i += 1 if mof is not None and converged and V_diff <= V_cut and 'large_supercell' in self.calc_swaps: self.calc_swaps.append('nsw=100') self.calc_swaps.remove('large_supercell') pprint('Running ' + spin_label + ', ' + acc_level + ' (LREAL=False)') mof, self.calc_swaps = mof_run(self, mof, calcs('isif3_highacc'), kpts_hi) self.calc_swaps.remove('nsw=100') if mof is not None and mof.calc.converged: write_success(self) else: write_errors(self, mof) else: write_errors(self, mof) if mof is not None and V_diff > V_cut: pprint('^ Change in V of ' + str(V_diff) + ' percent') if 'fire' in self.calc_swaps: self.calc_swaps.remove('fire') elif os.path.isfile(outcar_paths[self.run_i]): pprint('COMPLETED: ' + spin_label + ', ' + acc_level) mof = prep_next_run(self) if mof is None: pprint('Skipping rest because of errors') return None return mof
def isif2_lowacc(self): """ Run low accuracy ISIF2 Returns: mof (ASE Atoms object): updated ASE Atoms object """ acc_levels = self.acc_levels outcar_paths = self.outcar_paths error_outcar_paths = self.error_outcar_paths spin_level = self.spin_level spin_label = self.spin_label cif_file = self.cif_file mofpath = self.mofpath prior_spin = self.prior_spin spin1_final_mof_path = self.spin1_final_mof_path kpts_lo = self.kpts_dict['kpts_lo'] acc_level = acc_levels[self.run_i] niggli = self.niggli calcs = self.calcs prior_results_path = os.path.join( self.results_partial_paths[self.run_i - 1], spin_label) if os.path.isfile(outcar_paths[self.run_i - 1]) and not os.path.isfile( outcar_paths[self.run_i]) and not os.path.isfile( error_outcar_paths[self.run_i]): if prior_spin is None: mof = cif_to_mof(os.path.join(mofpath, cif_file), niggli) else: mof = read(spin1_final_mof_path) manage_restart_files(prior_results_path) mof = set_initial_magmoms(mof, spin_level) fmax = 5.0 pprint('Running ' + spin_label + ', ' + acc_level) mof, dyn, self.calc_swaps = mof_bfgs_run(self, mof, calcs('ase_bfgs'), kpts_lo, fmax=fmax) if mof is not None and dyn: loop_i = 0 converged = False clean_files(['opt.traj']) while mof is not None and loop_i < 4 and not converged and mof.calc.scf_converged: if loop_i == 2 and 'fire' not in self.calc_swaps and 'zbrent' not in self.calc_swaps: self.calc_swaps.append('fire') mof = read('OUTCAR') mof = continue_magmoms(mof, 'INCAR') mof, self.calc_swaps = mof_run(self, mof, calcs('isif2_lowacc'), kpts_lo) if mof is None: break converged = mof.calc.converged loop_i += 1 if 'fire' in self.calc_swaps: self.calc_swaps.remove('fire') if mof is not None and mof.calc.scf_converged and mof.calc.converged: write_success(self) else: write_errors(self, mof) elif os.path.isfile(outcar_paths[self.run_i]): pprint('COMPLETED: ' + spin_label + ', ' + acc_level) mof = prep_next_run(self) if mof is None: pprint('Skipping rest because of errors') return None return mof