Example #1
0
    def write_input(self,
                    atoms,
                    properties=None,
                    system_changes=None,
                    ghosts=None,
                    geo_constrain=None,
                    scaled=False,
                    velocities=None):
        FileIOCalculator.write_input(self, atoms, properties, system_changes)

        if geo_constrain is None:
            geo_constrain = "relax_geometry" in self.parameters

        if scaled is None:
            scaled = np.all(atoms.get_pbc())
        if velocities is None:
            velocities = atoms.has('momenta')

        have_lattice_vectors = atoms.pbc.any()
        have_k_grid = ('k_grid' in self.parameters
                       or 'kpts' in self.parameters)
        if have_lattice_vectors and not have_k_grid:
            raise RuntimeError('Found lattice vectors but no k-grid!')
        if not have_lattice_vectors and have_k_grid:
            raise RuntimeError('Found k-grid but no lattice vectors!')
        write_aims(os.path.join(self.directory, 'geometry.in'),
                   atoms,
                   scaled,
                   geo_constrain,
                   velocities=velocities,
                   ghosts=ghosts)
        self.write_control(atoms, os.path.join(self.directory, 'control.in'))
        self.write_species(atoms, os.path.join(self.directory, 'control.in'))
        self.parameters.write(os.path.join(self.directory, 'parameters.ase'))
Example #2
0
File: aims.py Project: lqcata/ase
    def calculate(self, atoms):
        """Generate necessary files in the working directory.
        
        If the directory does not exist it will be created.

        """
        positions = atoms.get_positions()
        have_lattice_vectors = atoms.get_pbc().any()        
        have_k_grid = self.list_params['k_grid']
        if have_lattice_vectors and not have_k_grid:
            raise RuntimeError("Found lattice vectors but no k-grid!")
        if not have_lattice_vectors and have_k_grid:
            raise RuntimeError("Found k-grid but no lattice vectors!")
        from ase.io.aims import write_aims
        write_aims('geometry.in', atoms) 
        self.write_control()
        self.write_species()
        self.run()
        self.converged = self.read_convergence()
        if not self.converged:
            os.system("tail -20 "+self.out)
            raise RuntimeError("FHI-aims did not converge!\n"+
                               "The last lines of output are printed above "+
                               "and should give an indication why.")

        self.set_results(atoms)
Example #3
0
    def write_input(self, atoms, properties=None, system_changes=None, ghosts=None):
        FileIOCalculator.write_input(self, atoms, properties, system_changes)

        have_lattice_vectors = atoms.pbc.any()
        have_k_grid = ('k_grid' in self.parameters or
                       'kpts' in self.parameters)
        if have_lattice_vectors and not have_k_grid:
            raise RuntimeError('Found lattice vectors but no k-grid!')
        if not have_lattice_vectors and have_k_grid:
            raise RuntimeError('Found k-grid but no lattice vectors!')
        write_aims(os.path.join(self.directory, 'geometry.in'), atoms, ghosts)
        self.write_control(atoms, os.path.join(self.directory, 'control.in'))
        self.write_species(atoms, os.path.join(self.directory, 'control.in'))
        self.parameters.write(os.path.join(self.directory, 'parameters.ase'))
Example #4
0
                ra = options.rotate_around
                if (ra > 0 and ra <= natoms):
                    positions = step.arrays['positions']
                    origin = positions[ra - 1]
                # rotate selected atoms
                asekk.rotate_atoms(step,
                                   alpha,
                                   fromto=[a_from, a_to],
                                   axis=options.axis,
                                   origin=origin)

            # --- Repetytion  ----
            if (do_we_repeat):
                # multiply by periods
                step = step * p

            # ----- Write -----
            if (options.format == 'xyz'):
                write_xyz(sys.stdout, step, comment=comm)
            elif (options.format == 'aims'):
                write_aims("geometry.in", step)
            elif (options.format == 'poscar'):
                #                print step.get_cell()
                step.center()
                write_vasp(sys.stdout,
                           step,
                           label="POSCAR generated by asm.xyz.py",
                           direct=False,
                           sort=False,
                           vasp5=True)
Example #5
0
parser = OptionParser()
parser.add_option("-a", "--lattice", action="store", type="float", default=1.0)
parser.add_option("-p",
                  "--periods",
                  action="store",
                  type="int",
                  default=[1, 1, 1],
                  help="repetition of the unit cell",
                  nargs=3)
parser.add_option("-e",
                  "--element",
                  action="store",
                  type="string",
                  default='H')
(options, args) = parser.parse_args()

a = options.lattice
p = options.periods
e = options.element

#print a

atoms = FaceCenteredCubic(latticeconstant=a,
                          directions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
                          size=p,
                          symbol=e,
                          pbc=(1, 1, 1))

write_aims("geometry.in", atoms)
Example #6
0
            for i in range(3):
                l = ls[i].split()
                cell[i] = [float(l[0]), float(l[1]), float(l[2])]
            atoms.set_cell(cell)
            atoms.set_pbc([True, True, True])

    elif (iformat == "cube"):
        cube = read_cube(sys.argv[num - 1], read_data=True)
        atoms = cube[1]
        field = cube[0]
        print atoms.get_cell()
        print len(field), len(field[0]), len(field[0][0])

    if (oformat == "geometry.in"):
        tmpname = "geometry.in.tmp"
        write_aims(tmpname, atoms)
        f = open(tmpname, 'r')
        print f.read()
        f.close()
        os.remove(tmpname)
#        write_aims("geometry.in", atoms)
#    elif(oformat == "cube"):
#        write_cube(`,xsf[1],xsf[0])
#    elif(oformat == "xsf"):
#        write_xsf(sys.stdout,xsf[1],xsf[0])

    elif (oformat == "POSCAR"):
        write_vasp(ostream,
                   atoms,
                   label=options.comment,
                   direct=False,