# Path: vasppy/xdatcar.py
# class Xdatcar:
# 
#     lines_offset = 9
# 
#     def __init__( self ):
#         """
#         Initialise a Xdatcar object.
# 
#         Args:
#             None
# 
#         Returns:
#             None
#         """
#         self.poscar = []
#         self.poscar.append( Poscar() )
#   
#     def read_from( self, filename ):
#         self.poscar[ 0 ].read_from( filename )
#         with open( filename ) as f:
#             lines = f.read()
#         frame_header = re.compile( '\nDirect configuration=\s+\d+\n' )
#         frame_coordinates = [ frame.split("\n") for frame in frame_header.split( lines )[2:] ]
#         for f, frame in enumerate( frame_coordinates ):
#             self.poscar.append( copy.deepcopy( self.poscar[ 0 ] ) ) 
#             self.poscar[-1].coordinates = np.array( [ [ float( e ) for e in frame.pop(0).split()[0:3] ] for i in range( sum( self.poscar[0].atom_numbers ) ) ] )


from vasppy.xdatcar import Xdatcar
import argparse
import copy
#! /usr/bin/env python3


def parse_command_line_arguments():
    # command line arguments
    parser = argparse.ArgumentParser()
    parser.add_argument( 'xdatcar' )
    args = parser.parse_args()
    return( args )

def main():
    args = parse_command_line_arguments()
    xdatcar = Xdatcar()
    xdatcar.read_from( args.xdatcar )
    poscar1 = copy.deepcopy( xdatcar.poscar[0] )
    for p in xdatcar.poscar[1:]:
        poscar2 = p
        for i, c in enumerate( poscar1.coordinates ):
            print( ' '.join( [ str(e) for e in ( poscar1.cell.minimum_image( poscar1.coordinates[i], poscar2.coordinates[i] ).dot( poscar1.cell.matrix ) ) ] ) )
        poscar1 = copy.deepcopy( p )


# Path: vasppy/xdatcar.py
# class Xdatcar:
# 
#     lines_offset = 9
# 
#     def __init__( self ):
#         """
#         Initialise a Xdatcar object.
# 
#         Args:
#             None
# 
#         Returns:
#             None
#         """
#         self.poscar = []
#         self.poscar.append( Poscar() )
#   
#     def read_from( self, filename ):
#         self.poscar[ 0 ].read_from( filename )
#         with open( filename ) as f:
#             lines = f.read()
#         frame_header = re.compile( '\nDirect configuration=\s+\d+\n' )
#         frame_coordinates = [ frame.split("\n") for frame in frame_header.split( lines )[2:] ]
#         for f, frame in enumerate( frame_coordinates ):
#             self.poscar.append( copy.deepcopy( self.poscar[ 0 ] ) ) 
#             self.poscar[-1].coordinates = np.array( [ [ float( e ) for e in frame.pop(0).split()[0:3] ] for i in range( sum( self.poscar[0].atom_numbers ) ) ] )


# Path: vasppy/scripts/xdatcar_to_disp.py
from vasppy.xdatcar import Xdatcar
import argparse
import copy

#! /usr/bin/env python3


def parse_command_line_arguments():
    # command line arguments
    parser = argparse.ArgumentParser()
    parser.add_argument( 'xdatcar' )
    args = parser.parse_args()
    return( args )

def main():
    args = parse_command_line_arguments()
    xdatcar = Xdatcar()
    xdatcar.read_from( args.xdatcar )
    poscar1 = copy.deepcopy( xdatcar.poscar[0] )
    for p in xdatcar.poscar[1:]:
        poscar2 = p
        for i, c in enumerate( poscar1.coordinates ):
            print( ' '.join( [ str(e) for e in ( poscar1.cell.minimum_image( poscar1.coordinates[i], poscar2.coordinates[i] ).dot( poscar1.cell.matrix ) ) ] ) )
        poscar1 = copy.deepcopy( p )


if __name__ == "__main__":