Beispiel #1
0
    def get_system_atoms(self, system=None):
        """
        Returns a list of the atom kinds and number of atoms of the surface or solid system
        atom_kind : list
        atom_number : list
        """

        if system == 'surface':
            system_directory = self.sysdir_check()[0]
        if system == 'solid':
            system_directory = self.sysdir_check()[1]

        contcar = CONTCAR(os.path.join(system_directory, self.contcarfile))
 
        atom_kind = contcar.read_atomkinds()
        atom_number = contcar.read_atomnumbers()

        return atom_kind, atom_number 
Beispiel #2
0
    def get_system_atoms(self, system=None):
        """
        Returns a list of the atom kinds and number of atoms of the surface '
        'or solid system
        atom_kind : list
        atom_number : list
        """

        if system == 'surface':
            system_directory = self.sysdir_check()[0]
        if system == 'solid':
            system_directory = self.sysdir_check()[1]

        contcar = CONTCAR(os.path.join(system_directory, self.contcarfile))

        atom_kind = contcar.read_atomkinds()
        atom_number = contcar.read_atomnumbers()

        return atom_kind, atom_number
Beispiel #3
0
    def get_variables(self,
                      current_directory,
                      gasphase=False,
                      surface=False,
                      solid=False,
                      adsorbate=False,
                      ts=False,
                      species=None,
                      config=None,
                      system=None):
        '''Get the variables surface_name, composition, species_name, state,
        site_name, total_energy, frequencies, cell, positions, info
        from the VASP calculations
        '''

        system_name = self.rootdir.split('/')[-1]

        print('\nChecking --- ' + str(current_directory))

        # Check if outcarfile and contcarfile ie in the current_directory
        if (os.path.isfile(os.path.join(current_directory, self.outcarfile))
                and os.path.isfile(
                    os.path.join(current_directory, self.contcarfile))):
            outcar = OUTCAR(os.path.join(current_directory, self.outcarfile))
            contcar = CONTCAR(os.path.join(current_directory,
                                           self.contcarfile))

            # Checks if the OUTCAR file has completed -- will be
            # substituted with outcar.check_convergence
            finished = outcar.outcar_check()
            if finished is False:
                if surface:
                    print("   ERROR --- OUTCAR is not complete --- Exiting")
                    sys.exit()
                else:
                    print("    Warning --- OUTCAR file is not complete "
                          "--- This element is skipped")
                    variables = []
                return variables

        # if no contcar or outcar is in current_directory move to next
        else:
            print("    Warning --- No OUTCAR and/or CONTCAR file found "
                  "--- This element is skipped")
            variables = []
            return variables

        # Check if calculation has converged
        convergence = outcar.check_convergence()
        if convergence:
            print('    OUTCAR file - converged')
        #else:
        #print('WARNING --- Check convergency')

        # get chemical composition
        composition = contcar.read_composition(ordered=True)
        # get the total energy of the system
        total_energy = outcar.read_energy()

        # get the atomic super cell
        cell = contcar.read_cell()
        # get the atomic position of all elements
        positions = contcar.read_atoms_and_positions()
        # info is set as the given directory
        info = current_directory

        if gasphase:
            # check if atom/molecule is in defined molecules!!!! Add this

            # Set surface, site, species names and bulk_structure for
            # gasphase species
            surface_name = 'gasphase'
            species_name = contcar.read_composition(ordered=True, name=True)
            site_name = 'None'
            state = 'gasphase'

        if surface:
            # Set surface, site, species names and bulk_structure for
            # gasphase species
            surface_name = system_name
            site_name = 'None'
            species_name = contcar.read_composition(ordered=True)
            state = 'surface'

        if solid:
            # Set surface, site, species names and bulk_structure for
            # gasphase species
            surface_name = system_name
            site_name = 'None'
            species_name = contcar.read_composition(ordered=True)
            state = 'solid'

        if adsorbate:
            surface_name = system_name
            site_name = config
            surface_atoms = self.get_system_atoms(system=system)
            species_name = contcar.read_composition(adsorbed=True,
                                                    surface=surface_atoms,
                                                    name=True)
            state = species

        if ts:
            surface_name = system_name
            site_name = config
            surface_atoms = self.get_system_atoms(system=system)
            species_name = contcar.read_composition(adsorbed=True,
                                                    surface=surface_atoms,
                                                    name=True)

            state = species

            image = []
            for i in range(0, 40):
                if i < 10:
                    image.append(str(0) + str(i))
                else:
                    image.append(str(i))

            if 'dim' in current_directory.split('/'):
                print('    Dimer method - used')
            elif current_directory.split('/')[-1] in image:
                print('    (CI)-NEB method - used - image ' +
                      str(current_directory.split('/')[-1]) +
                      ' set as transition state '
                      '--- Check that this is the correct transition state')
            else:
                print('    Method for finding transition state not given')

        frequencies = self.get_frequencies(current_directory,
                                           gasphase=gasphase)

        # Check the number of imaginary frequencies
        j = 0
        for f in frequencies:
            if isinstance(f, complex):
                j = j + 1

        if j > 0 and ts is False:
            print("    WARNING --- " + str(j) + " imaginary frequencies found")

        elif j > 1 and ts is True:
            print("    WARNING --- " + str(j) +
                  " imaginary frequencies found - is this a true "
                  "transition state?")

        # make list containing information about surface species, species,
        # state, site, energy,
        # frequencies, cell, positions and info
        variables = [
            surface_name, composition, species_name, state, site_name,
            total_energy, frequencies, cell, positions, info
        ]

        print('    ' + str(variables[0:6]))

        return variables
Beispiel #4
0
    def get_variables(self, current_directory, gasphase=False, surface=False,
                      solid=False, adsorbate=False, ts=False, species=None,
                      config=None, system=None):
        '''Get the variables surface_name, composition, species_name, state,
        site_name, total_energy, frequencies, cell, positions, info
        from the VASP calculations
        '''

        system_name = self.rootdir.split('/')[-1]

        print('\nChecking --- ' + str(current_directory))



        # Check if outcarfile and contcarfile ie in the current_directory
        if (os.path.isfile(os.path.join(
                current_directory, self.outcarfile)) and
            os.path.isfile(os.path.join(
                current_directory, self.contcarfile))):
            outcar = OUTCAR(os.path.join(current_directory, self.outcarfile))
            contcar = CONTCAR(os.path.join(current_directory, self.contcarfile))

            # Checks if the OUTCAR file has completed -- will be
            # substituted with outcar.check_convergence
            finished = outcar.outcar_check()
            if finished is False:
                if surface:
                    print("   ERROR --- OUTCAR is not complete --- Exiting")
                    sys.exit()
                else:
                    print("    Warning --- OUTCAR file is not complete "
                          "--- This element is skipped")
                    variables = []
                return variables

        # if no contcar or outcar is in current_directory move to next
        else:
            print("    Warning --- No OUTCAR and/or CONTCAR file found "
                  "--- This element is skipped")
            variables = []
            return variables


        # Check if calculation has converged
        convergence = outcar.check_convergence()
        if convergence:
            print('    OUTCAR file - converged')
        #else:
            #print('WARNING --- Check convergency')


        # get chemical composition
        composition = contcar.read_composition(ordered=True)
        # get the total energy of the system
        total_energy = outcar.read_energy()

        # get the atomic super cell
        cell = contcar.read_cell()
        # get the atomic position of all elements
        positions = contcar.read_atoms_and_positions()
        # info is set as the given directory
        info = current_directory

        if gasphase:
            # check if atom/molecule is in defined molecules!!!! Add this

            # Set surface, site, species names and bulk_structure for
            # gasphase species
            surface_name = 'gasphase'
            species_name = contcar.read_composition(ordered=True, name=True)
            site_name = 'None'
            state = 'gasphase'

        if surface:
            # Set surface, site, species names and bulk_structure for
            # gasphase species
            surface_name = system_name
            site_name = 'None'
            species_name = contcar.read_composition(ordered=True)
            state = 'surface'

        if solid:
            # Set surface, site, species names and bulk_structure for
            # gasphase species
            surface_name = system_name
            site_name = 'None'
            species_name = contcar.read_composition(ordered=True)
            state = 'solid'

        if adsorbate:
            surface_name = system_name
            site_name = config
            surface_atoms = self.get_system_atoms(system=system)
            species_name = contcar.read_composition(
                adsorbed=True, surface=surface_atoms, name=True)
            state = species

        if ts:
            surface_name = system_name
            site_name = config
            surface_atoms = self.get_system_atoms(system=system)
            species_name = contcar.read_composition(
                adsorbed=True, surface=surface_atoms, name=True)

            state = species


            image = []
            for i in range(0,40):
                if i < 10:
                    image.append(str(0)+str(i))
                else:
                    image.append(str(i))

            if 'dim' in current_directory.split('/'):
                print('    Dimer method - used')
            elif current_directory.split('/')[-1] in image:
                print('    (CI)-NEB method - used - image ' +
                      str(current_directory.split('/')[-1]) +
                      ' set as transition state '
                      '--- Check that this is the correct transition state')
            else:
                print('    Method for finding transition state not given')


        frequencies = self.get_frequencies(
            current_directory, gasphase = gasphase)

        # Check the number of imaginary frequencies
        j = 0
        for f in frequencies:
            if isinstance(f, complex):
                j = j + 1

        if j > 0 and ts is False:
            print("    WARNING --- " + str(j) + " imaginary frequencies found")

        elif j > 1 and ts is True:
            print("    WARNING --- " + str(j) +
                  " imaginary frequencies found - is this a true "
                  "transition state?")

        # make list containing information about surface species, species,
        # state, site, energy,
        # frequencies, cell, positions and info
        variables = [surface_name, composition, species_name, state, site_name,
                         total_energy, frequencies,
                         cell, positions, info]

        print('    ' + str(variables[0:6]))

        return variables