Esempio n. 1
0
    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
Esempio n. 2
0
    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
Esempio n. 3
0
    def isif2_medacc(self):
        """
		Run medium 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_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)
            if sum(kpts_lo) == 3 and sum(kpts_hi) > 3:
                clean_files(['CHGCAR', 'WAVECAR'])
            else:
                manage_restart_files(prior_results_path)
            pprint('Running ' + spin_label + ', ' + acc_level)
            mof, self.calc_swaps = mof_run(self, mof, calcs('isif2_medacc'),
                                           kpts_hi)
            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
Esempio n. 4
0
    def final_spe(self):
        """
		Run final single point
		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
        self.calc_swaps = []
        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('final_spe'),
                                           kpts_hi)
            if mof is not None and mof.calc.scf_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
Esempio n. 5
0
    def dimer(self):
        """
		Run dimer
		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
        prior_spin = self.prior_spin
        acc_level = acc_levels[self.run_i]
        prior_acc_level = acc_levels[self.run_i - 1]
        results_partial_paths = self.results_partial_paths
        pwd = os.getcwd()
        if 'lowacc' in acc_level:
            kpts = self.kpts_dict['kpts_lo']
        else:
            kpts_lo = self.kpts_dict['kpts_lo']
            kpts = self.kpts_dict['kpts_hi']
        calcs = self.calcs
        if 'neb' in prior_acc_level and prior_spin is None:
            prior_results_path = os.path.join(
                results_partial_paths[self.run_i - 1])
            prior_results_file = os.path.join(prior_results_path, 'neb.tar.gz')
        elif 'lowacc' in acc_level and prior_spin is not None:
            prior_results_path = os.path.join(results_partial_paths[-1],
                                              prior_spin)
            prior_results_file = os.path.join(prior_results_path, 'OUTCAR')
        else:
            prior_results_file = outcar_paths[self.run_i - 1]
            prior_results_path = os.path.join(
                results_partial_paths[self.run_i - 1], spin_label)
        if os.path.isfile(prior_results_file) and not os.path.isfile(
                outcar_paths[self.run_i]) and not os.path.isfile(
                    error_outcar_paths[self.run_i]):
            if 'scf_test' in prior_acc_level:
                mof = prep_new_run(self)
                manage_restart_files(prior_results_path, dimer=False)
            elif 'neb' in prior_acc_level and prior_spin is None:
                manage_restart_files(prior_results_path, neb=True)
                mof = neb2dim()
                mof = set_initial_magmoms(mof, spin_level)
            elif 'lowacc' in acc_level and prior_spin is not None:
                mof = read(prior_results_file)
                mof = set_initial_magmoms(mof, spin_level)
                manage_restart_files(prior_results_path,
                                     dimer=True,
                                     wavechg=False)
            else:
                mof = prep_new_run(self)
                manage_restart_files(prior_results_path, dimer=True)
                if 'medacc' in acc_level and sum(
                        kpts_lo) == 3 and sum(kpts) > 3:
                    clean_files(['CHGCAR', 'WAVECAR'])
            if 'highacc' in acc_level and 'large_supercell' in self.calc_swaps:
                self.calc_swaps.remove('large_supercell')
            pprint('Running ' + spin_label + ', ' + acc_level)
            mof, self.calc_swaps = mof_run(self, mof, calcs(acc_level), kpts)
            if mof is not None and mof.calc.scf_converged and mof.calc.converged:
                write_success(self)
            else:
                write_errors(self, mof)
            vtst_cleanup()
        elif os.path.isfile(outcar_paths[self.run_i]):
            pprint('COMPLETED: ' + spin_label + ', ' + acc_level)
        mof = prep_next_run(self)
        os.chdir(pwd)
        if mof is None:
            pprint('Skipping rest because of errors')
            return None

        return mof
Esempio n. 6
0
    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