Пример #1
0
    def parse_vasprun(self):
        """
        Read in `vasprun.xml` as a pymatgen Vasprun object.

        Args:
            None

        Returns:
            None

        None:
            If the vasprun.xml is not well formed this method will catch the ParseError
            and set self.vasprun = None.
        """
        self.vasprun_filename = match_filename('vasprun.xml')
        if not self.vasprun_filename:
            raise FileNotFoundError(
                'Could not find vasprun.xml or vasprun.xml.gz file')
        try:
            self.vasprun = Vasprun(self.vasprun_filename,
                                   parse_potcar_file=False,
                                   parse_dos=False)
        except ET.ParseError:
            self.vasprun = None
        except:
            raise
Пример #2
0
def read_data( verbose=True ):
    dir_list = find_vasp_calculations()
    if not dir_list:
        raise ValueError( 'Did not find any subdirectories containing vasprun.xml or vasprun.xml.gz files' )
    data = []
    for d in dir_list:
        converged = True
        try:
            with warnings.catch_warnings(record=True) as w:
                vasprun = read_vasprun( match_filename( d + 'vasprun.xml' ) )
                for warning in w:
                    if isinstance( warning.message, UnconvergedVASPWarning ):
                        converged = False
                    else:
                        print( warning.message )
        except:
            continue 
        poscar = Poscar.from_file( d + 'POSCAR' )
        data.append( [ poscar.scaling, 
                       vasprun.final_structure.volume, 
                       vasprun.final_energy,
                       converged ] )
    column_titles = [ 'scaling', 'volume', 'energy', 'converged' ]
    df = pd.DataFrame( data, columns=column_titles ).sort_values( by='scaling' )
    df = df.reset_index( drop=True )
    df['scaling_factor'] = df.volume / df.scaling**3
    scaling_factor_round = 4
    if verbose:
        print( df.to_string(index=False) )
    if len( set( df.scaling_factor.round( scaling_factor_round ) ) ) != 1:
        raise ValueError( "POSCAR scaling factors and volumes are inconsistent" )
    return df
Пример #3
0
 def print_file_tracking(self):
     if self.meta.track:
         print("file tracking:")
         for f, new_filename in self.meta.track.items():
             print("    {}:".format(f))
             if not new_filename:
                 new_filename = f
             print("        filename: {}".format(new_filename))
             filename = match_filename(self.directory + f)
             if filename:
                 md5 = file_md5(filename)
             else:
                 md5 = 'null'
             print("        md5: {}".format(md5))
Пример #4
0
 def print_file_tracking( self ):
     if self.meta.track:
         print( "file tracking:" )
         for f, new_filename in self.meta.track.items():
             print( "    {}:".format( f ) )
             if not new_filename:
                 new_filename = f
             print( "        filename: {}".format( new_filename ) )
             filename = match_filename( self.directory + f )
             if filename: 
                 md5 = file_md5( filename )
             else:
                 md5 = 'null'
             print( "        md5: {}".format( md5 ) )
Пример #5
0
    def parse_vasprun( self ):
        """
        Read in `vasprun.xml` as a pymatgen Vasprun object.

        Args:
            None

        Returns:
            None

        None:
            If the vasprun.xml is not well formed this method will catch the ParseError
            and set self.vasprun = None.
        """            
        self.vasprun_filename = match_filename( 'vasprun.xml' )
        if not self.vasprun_filename:
            raise FileNotFoundError( 'Could not find vasprun.xml or vasprun.xml.gz file' )
        try:
            self.vasprun = Vasprun( self.vasprun_filename, parse_potcar_file=False )
        except ET.ParseError:
            self.vasprun = None
        except:
            raise