예제 #1
0
    def cineb_lowacc(self, initial_atoms, final_atoms, n_images):
        """
		Run CI-NEB low accuracy calculation
		Returns:
			mof (ASE Atoms object): updated ASE Atoms object
		"""
        spin_level = self.spin_level
        kpts_lo = self.kpts_dict['kpts_lo']
        calcs = self.calcs
        nprocs = self.nprocs
        pwd = os.getcwd()
        partial_path = self.results_partial_paths[self.run_i]
        data_path = os.path.join(partial_path, 'neb.tar.gz')
        partial_error_path = self.error_partial_paths[self.run_i]
        error_data_path = os.path.join(partial_error_path, 'neb.tar.gz')
        neb_conv = False
        if nprocs % n_images != 0:
            raise ValueError(
                str(nprocs) + ' procs not divisible by ' + str(n_images))
        if not os.path.isfile(data_path) and not os.path.isfile(
                error_data_path):
            if initial_atoms.get_chemical_formula(
            ) != final_atoms.get_chemical_formula():
                raise ValueError('POSCAR1 and POSCAR2 must have same atoms')
            nebmake(initial_atoms, final_atoms, n_images)
            initial_atoms = set_initial_magmoms(initial_atoms, spin_level)
            pprint('Running CI-NEB (pre-dimer)')
            initial_atoms, self.calc_swaps = mof_run(self,
                                                     initial_atoms,
                                                     calcs('cineb_lowacc'),
                                                     kpts_lo,
                                                     images=n_images)
            ediffg = calcs('cineb_lowacc').exp_params['ediffg']
            neb_conv = nebef(ediffg)
            os.chdir(pwd)
            if neb_conv:
                write_success(self, neb=True)
            else:
                write_errors(self, initial_atoms, neb=True)
            vtst_cleanup()
        elif os.path.isfile(data_path):
            pprint('COMPLETED: CI-NEB (pre-dimer)')
            neb_conv = True
        self.run_i += 1
        if not neb_conv:
            pprint('Skipping rest because of errors')
            return False

        return neb_conv
예제 #2
0
    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