Пример #1
0
def quench(atoms,name=None,fmax=0.05,method='QN'):
    """ Quench given Atoms object with given attached calculator. """
    if name==None:
        try:
            name=atoms.get_chemical_formula(mode="hill")
        except:
            raise ValueError('name not specified')
    traj=ase.PickleTrajectory(name+'_quenching.trj','w',atoms)
    
    if method=='QN':
        qn=ase.QuasiNewton(atoms)
    elif method=='FIRE':
        qn=ase.FIRE(atoms)        
    qn.attach(traj.write)   
    qn.run(fmax=fmax)
    e=atoms.get_potential_energy()
    ase.write(name+'_quenched.xyz',atoms)
    return e
Пример #2
0
def quench(atoms, name=None, fmax=0.05, method='QN'):
    """ Quench given Atoms object with given attached calculator. """
    if name == None:
        try:
            name = atoms.get_chemical_formula(mode="hill")
        except:
            raise ValueError('name not specified')
    traj = ase.Trajectory(name + '_quenching.trj', 'w', atoms)

    if method == 'QN':
        qn = ase.QuasiNewton(atoms)
    elif method == 'FIRE':
        qn = ase.FIRE(atoms)
    qn.attach(traj.write)
    qn.run(fmax=fmax)
    e = atoms.get_potential_energy()
    ase.write(name + '_quenched.xyz', atoms)
    return e
Пример #3
0
    def __init__(self, atoms):
        '''
 
        '''
        self.atoms = atoms

        #get density and write cube file
        calc = atoms.get_calculator()
        ncfile = calc.get_nc()
        base, ext = os.path.splitext(ncfile)

        x, y, z, density = calc.get_charge_density()
        cubefile = base + '_charge_density.cube'
        self.densityfile = cubefile

        if not os.path.exists(cubefile):
            write(cubefile, atoms, data=density * Bohr**3)

        #cmd to run for bader analysis. check if output exists so we
        #don't run this too often.
        acf_file = base + '_ACF.dat'
        if not os.path.exists(acf_file):
            #mk tempdir
            tempdir = tempfile.mkdtemp()

            cwd = os.getcwd()
            os.chdir(tempdir)

            cmd = 'bader %s' % abscubefile
            status, output = commands.getstatusoutput(cmd)

            if status != 0:
                print output

            shutil.copy2('ACF.dat', os.path.join(cwd, acf_file))

            os.chdir(cwd)
            shutil.rmtree(tempdir)

        self.charges = []
        self.volumes = []

        #now parse the output
        f = open(acf_file, 'r')
        #skip 2 lines
        f.readline()
        f.readline()

        for i, atom in enumerate(self.atoms):
            line = f.readline()
            fields = line.split()
            n = int(fields[0])
            x = float(fields[1])
            y = float(fields[2])
            z = float(fields[3])
            chg = float(fields[4])
            mindist = float(fields[5])
            vol = float(fields[6])

            self.charges.append(chg)
            self.volumes.append(vol)

        f.close()
Пример #4
0
c = Hotbit(elements={
    'H': dir2 + 'H-H.skf',
    'C': dir2 + 'C-C.skf'
},
           tables={
               'HH': dir2 + 'H-H.skf',
               'CH': dir2 + 'C-H.skf',
               'CC': dir2 + 'C-C.skf'
           },
           SCC=False)
a.set_calculator(c)

ase.FIRE(a).run(fmax=0.01)

ase.write('C6H6.cfg', a)

###

for i in c.el.get_present():
    el = c.el.get_element(i)
    sym = el.get_symbol()
    orbs = el.get_valence_orbitals()
    for orb in orbs:
        print sym, orb, el.get_epsilon(orb), el.get_epsilon(orb) * Hartree

x = np.linspace(1.0, 12.0, 1000)

y, dy = c.ia.h['CC'](x)
d = np.transpose(np.append(x.reshape(1, -1), y, axis=0))
np.savetxt('CC_H.out', d)
Пример #5
0
    elements = {
        'H': dir2 + 'H-H.skf',
        'C': dir2 + 'C-C.skf'
        },
    tables   = {
        'HH': dir2 + 'H-H.skf',
        'CH': dir2 + 'C-H.skf',
        'CC': dir2 + 'C-C.skf'
        },
    SCC      = False
    )
a.set_calculator(c)

ase.FIRE(a).run(fmax=0.01)

ase.write('C6H6.cfg', a)

###

for i in c.el.get_present():
    el = c.el.get_element(i)
    sym = el.get_symbol()
    orbs = el.get_valence_orbitals()
    for orb in orbs:
        print sym, orb, el.get_epsilon(orb), el.get_epsilon(orb)*Hartree

x = np.linspace(1.0, 12.0, 1000)

y, dy = c.ia.h['CC'](x)
d = np.transpose(np.append(x.reshape(1, -1), y, axis=0))
np.savetxt('CC_H.out', d)
Пример #6
0
    def __init__(self, atoms):
        """
 
        """
        self.atoms = atoms

        # get density and write cube file
        calc = atoms.get_calculator()
        ncfile = calc.get_nc()
        base, ext = os.path.splitext(ncfile)

        x, y, z, density = calc.get_charge_density()
        cubefile = base + "_charge_density.cube"
        self.densityfile = cubefile

        if not os.path.exists(cubefile):
            write(cubefile, atoms, data=density * Bohr ** 3)

        # cmd to run for bader analysis. check if output exists so we
        # don't run this too often.
        acf_file = base + "_ACF.dat"
        if not os.path.exists(acf_file):
            # mk tempdir
            tempdir = tempfile.mkdtemp()

            cwd = os.getcwd()
            os.chdir(tempdir)

            cmd = "bader %s" % abscubefile
            status, output = commands.getstatusoutput(cmd)

            if status != 0:
                print output

            shutil.copy2("ACF.dat", os.path.join(cwd, acf_file))

            os.chdir(cwd)
            shutil.rmtree(tempdir)

        self.charges = []
        self.volumes = []

        # now parse the output
        f = open(acf_file, "r")
        # skip 2 lines
        f.readline()
        f.readline()

        for i, atom in enumerate(self.atoms):
            line = f.readline()
            fields = line.split()
            n = int(fields[0])
            x = float(fields[1])
            y = float(fields[2])
            z = float(fields[3])
            chg = float(fields[4])
            mindist = float(fields[5])
            vol = float(fields[6])

            self.charges.append(chg)
            self.volumes.append(vol)

        f.close()