Exemple #1
0
def main():
    args = parse_command_line_arguments()
    poscar = Poscar()
    poscar.read_from( args.poscar )
    theta = math.pi * args.degrees / 180.0
    poscar.cell.rotate( args.axis, theta )
    poscar.output()
Exemple #2
0
def main():
    args = parse_command_line_arguments()
    coordinate_types = { 'd' : 'Direct',
                         'direct' : 'Direct',
                         'c' : 'Cartesian',
                         'cartesian' : 'Cartesian' }
    coordinate_type = coordinate_types[ args.coordinate_type ]
    # initialise
    poscar = Poscar()
    # read POSCAR file
    poscar.read_from( args.poscar )
    if args.scale:
        poscar.cell.matrix *= poscar.scaling
        poscar.scaling = 1.0
    if args.supercell: # generate supercell
        if args.group:
            # check that if grouping is switched on, we are asking for a supercell that allows a "3D-chequerboard" pattern.
            for (i,axis) in zip( args.supercell, range(3) ):
                if i%2 == 1 and i > 1:
                    raise Exception( "odd supercell expansions != 1 are incompatible with automatic grouping" )
        poscar = poscar.replicate( *args.supercell, group=args.group )
    if args.bohr:
        poscar = poscar.in_bohr()
    # output to stdout
    output_opts = { 'label'    : args.label,
                    'numbered' : args.number_atoms,
                    'coordinates_only' : args.coordinates_only,
                    'selective': args.selective }
    poscar.output( coordinate_type=coordinate_type, opts=output_opts )
Exemple #3
0
def main():
    args = parse_command_line_arguments()
    poscar = Poscar()
    poscar.read_from(args.poscar)
    theta = math.pi * args.degrees / 180.0
    poscar.cell.rotate(args.axis, theta)
    poscar.output()
Exemple #4
0
def main():
    args = parse_command_line_arguments()
    coordinate_types = {
        'd': 'Direct',
        'direct': 'Direct',
        'c': 'Cartesian',
        'cartesian': 'Cartesian'
    }
    coordinate_type = coordinate_types[args.coordinate_type]
    # initialise
    poscar = Poscar()
    # read POSCAR file
    poscar.read_from(args.poscar)
    if args.scale:
        poscar.cell.matrix *= poscar.scaling
        poscar.scaling = 1.0
    if args.supercell:  # generate supercell
        if args.group:
            # check that if grouping is switched on, we are asking for a supercell that allows a "3D-chequerboard" pattern.
            for (i, axis) in zip(args.supercell, range(3)):
                if i % 2 == 1 and i > 1:
                    raise Exception(
                        "odd supercell expansions != 1 are incompatible with automatic grouping"
                    )
        poscar = poscar.replicate(*args.supercell, group=args.group)
    if args.bohr:
        poscar = poscar.in_bohr()
    # output to stdout
    output_opts = {
        'label': args.label,
        'numbered': args.number_atoms,
        'coordinates_only': args.coordinates_only,
        'selective': args.selective
    }
    poscar.output(coordinate_type=coordinate_type, opts=output_opts)
Exemple #5
0
def main():
    filename = 'testout.rst'
    restart_file = True
    args = parse_command_line_arguments()
    coordinates, velocities, dipoles, full_cell_matrix, cell_lengths = read_pimaim_restart( filename )
    assert( sum( args.atom_numbers ) == len( coordinates ) )
    poscar = Poscar()
    full_cell_matrix = full_cell_matrix.transpose()
    coordinates = get_cart_coords_from_pimaim_restart(coordinates, full_cell_matrix,cell_lengths)
    poscar.cell = Cell( full_cell_matrix)
    poscar.atoms = args.labels
    poscar.atom_numbers = args.atom_numbers
    poscar.coordinate_type = 'Cartesian'
    poscar.coordinates = coordinates
    poscar.output()
Exemple #6
0
def main():
    filename = 'testout.rst'
    restart_file = True
    args = parse_command_line_arguments()
    coordinates, velocities, dipoles, full_cell_matrix, cell_lengths = read_pimaim_restart( filename )
    assert( sum( args.atom_numbers ) == len( coordinates ) )
    poscar = Poscar()
    full_cell_matrix = full_cell_matrix.transpose()
    coordinates = get_cart_coords_from_pimaim_restart(coordinates, full_cell_matrix,cell_lengths)
    poscar.cell = Cell( full_cell_matrix)
    poscar.atoms = args.labels
    poscar.atom_numbers = args.atom_numbers
    poscar.coordinate_type = 'Cartesian'
    poscar.coordinates = coordinates
    poscar.output()
Exemple #7
0
def main():
    filename = 'testout.rst'
    restart_file = True

    args = parse_command_line_arguments()
    coordinates, velocities, dipoles, full_cell_matrix = read_pimaim_restart(
        filename)
    assert (sum(args.atom_numbers) == len(coordinates))
    poscar = Poscar()
    poscar.cell = Cell(
        full_cell_matrix)  # TODO: possibly this needs transposing?
    poscar.atoms = args.labels
    poscar.atom_numbers = args.atom_numbers
    poscar.coordinate_type = 'Cartesian'
    poscar.coordinates = coordinates
    poscar.output()
Exemple #8
0
    parser.add_argument( '-b', '--bohr', action='store_true', help='assumes the input file is in Angstrom, and converts everything to bohr')
    parser.add_argument( '-n', '--number-atoms', action='store_true', help='label coordinates with atom number' )
    args = parser.parse_args()
    return( args )

if __name__ == "__main__":
    args = parse_command_line_arguments()
    coordinate_types = { 'd' : 'Direct',
                         'direct' : 'Direct',
                         'c' : 'Cartesian',
                         'cartesian' : 'Cartesian' }
    coordinate_type = coordinate_types[ args.coordinate_type ]
    # initialise
    poscar = Poscar()
    # read POSCAR file
    poscar.read_from( args.poscar )
    if args.supercell: # generate supercell
        if args.group:
            # check that if grouping is switched on, we are asking for a supercell that allows a "3D-chequerboard" pattern.
            for (i,axis) in zip( args.supercell, range(3) ):
                if i%2 == 1 and i > 1:
                    raise Exception( "odd supercell expansions != 1 are incompatible with automatic grouping" )
        poscar = poscar.replicate( *args.supercell, group=args.group )
    if args.bohr:
        poscar = poscar.in_bohr()
    # output to stdout
    output_opts = { 'label'    : args.label,
                    'numbered' : args.number_atoms,
                    'coordinates_only' : args.coordinates_only }
    poscar.output( coordinate_type = coordinate_type, opts = output_opts )
    number_of_atomic_data_lines = next( index for index, d in enumerate( data_per_line[4:] ) if d == 1 )
    number_of_atomic_data_types = sum( [ cr_dump_log, vel_dump_log, chg_dump_log ] )
    number_of_atoms = int( number_of_atomic_data_lines / number_of_atomic_data_types )
    # this assumes coordinates, velocities, and dipoles are all present.
    # not sure what happens if atoms have qudrupoles, etc.
    coordinates = lines_to_numpy_array( file_data[ 4 : 4 + number_of_atoms ] ) 
    velocities  = lines_to_numpy_array( file_data[ 4 + number_of_atoms : 4 + number_of_atoms * 2 ] ) 
    dipoles     = lines_to_numpy_array( file_data[ 4 + number_of_atoms * 2 : 4 + number_of_atoms * 3 ] ) 
    cell_matrix = lines_to_numpy_array( file_data[ -6: -3 ] )
    cell_lengths = lines_to_numpy_array( file_data[ -3: ] )
    full_cell_matrix = cell_matrix * cell_lengths
    # TODO! need to check this with a non-orthorhombic cell
    return( coordinates, velocities, dipoles, full_cell_matrix )

if __name__ == '__main__':
    filename = 'testout.rst'
    restart_file = True

    args = parse_command_line_arguments()
    coordinates, velocities, dipoles, full_cell_matrix = read_pimaim_restart( filename )
    assert( sum( args.atom_numbers ) == len( coordinates ) )
    poscar = Poscar()
    poscar.cell = Cell( full_cell_matrix ) # TODO: possibly this needs transposing?
    poscar.atoms = args.labels
    poscar.atom_numbers = args.atom_numbers
    poscar.coordinate_type = 'Cartesian'
    poscar.coordinates = coordinates

    poscar.output()
Exemple #10
0
    return( args )

if __name__ == "__main__":
    args = parse_command_line_arguments()
    coordinate_types = { 'd' : 'Direct',
                         'direct' : 'Direct',
                         'c' : 'Cartesian',
                         'cartesian' : 'Cartesian' }
    coordinate_type = coordinate_types[ args.coordinate_type ]
    # initialise
    poscar = Poscar()
    # read POSCAR file
    poscar.read_from( args.poscar )
    if args.scale:
        poscar.cell.matrix *= poscar.scaling
        poscar.scaling = 1.0
    if args.supercell: # generate supercell
        if args.group:
            # check that if grouping is switched on, we are asking for a supercell that allows a "3D-chequerboard" pattern.
            for (i,axis) in zip( args.supercell, range(3) ):
                if i%2 == 1 and i > 1:
                    raise Exception( "odd supercell expansions != 1 are incompatible with automatic grouping" )
        poscar = poscar.replicate( *args.supercell, group=args.group )
    if args.bohr:
        poscar = poscar.in_bohr()
    # output to stdout
    output_opts = { 'label'    : args.label,
                    'numbered' : args.number_atoms,
                    'coordinates_only' : args.coordinates_only }
    poscar.output( coordinate_type = coordinate_type, opts = output_opts )
Exemple #11
0
#! /usr/bin/env python3

from vasppy.poscar import Poscar
import math
import argparse

def parse_command_line_arguments():
    parser = argparse.ArgumentParser( description='Rotates the cell lattice in VASP POSCAR files' )
    parser.add_argument( 'poscar', help="filename of the VASP POSCAR to be processed" )
    parser.add_argument( '-a', '--axis', nargs=3, type=float, help="vector for rotation axis", required=True )
    parser.add_argument( '-d', '--degrees', type=int, help="rotation angle in degrees", required=True )
    args = parser.parse_args()
    return( args )

if __name__ == "__main__":
    args = parse_command_line_arguments()
    poscar = Poscar()
    poscar.read_from( args.poscar )
    theta = math.pi * args.degrees / 180.0
    poscar.cell.rotate( args.axis, theta )
    poscar.output()