Beispiel #1
0
    def makeatoms(self, *args):
        self.update_element()
        self.update_gui()
        if self.legal_element is None or (self.struct.get_active() == 2 and
                                          self.legal_element2 is None):
            self.atoms = None
            self.pybut.python = None
            self.status.set_markup(_("Please specify a consistent set of atoms. "))
        else:
            n = int(self.n.value)
            m = int(self.m.value)
            CC = self.bondlength.value
            vacuum = self.vacuum.value
            orient = self.orient_text[self.orient.get_active()]
            elem = self.legal_element
            if self.struct.get_active() == 0:
                # Extended sheet
                self.atoms = graphene_nanoribbon(n, m, type=orient, C_C=CC,
                                                 vacc=vacuum, sheet=True,
                                                 main_element=elem)
            elif self.struct.get_active() == 1:
                # Unsaturated nanoribbon
                self.atoms = graphene_nanoribbon(n, m, type=orient, C_C=CC,
                                                 vacc=vacuum,
                                                 main_element=elem)
            elif self.struct.get_active() == 2:
                # Saturated nanoribbon
                elem2 = self.legal_element2
                self.atoms = graphene_nanoribbon(n, m, type=orient, C_C=CC,
                                                 C_H=self.bondlength2.value,
                                                 vacuum=vacuum,
                                                 saturated=True,
                                                 main_element=elem,
                                                 saturate_element=elem2)
            else:
                raise RuntimeError("Unknown structure in SetupGraphene!")

        # Now, rotate into the xy plane (ase.gui's default view plane)
        pos = self.atoms.get_positions()
        cell = self.atoms.get_cell()
        pbc = self.atoms.get_pbc()
        cell[1,1], cell[2,2] = cell[2,2], cell[1,1]
        x = pos[:,1].copy()
        z = pos[:,2].copy()
        pos[:,1] = z
        pos[:,2] = x
        self.atoms.set_cell(cell)
        self.atoms.set_positions(pos)
        self.atoms.set_pbc([pbc[0], pbc[2], pbc[1]])
        # Find the heights of the unit cell
        h = np.zeros(3)
        uc = self.atoms.get_cell()
        for i in range(3):
            norm = np.cross(uc[i-1], uc[i-2])
            norm /= np.sqrt(np.dot(norm, norm))
            h[i] = np.abs(np.dot(norm, uc[i]))
        label = label_template % {'natoms'  : self.atoms.get_number_of_atoms(),
                                  'symbols' : formula(self.atoms.get_atomic_numbers()),
                                  'volume'  : self.atoms.get_volume()}
        self.status.set_markup(label)                
Beispiel #2
0
 def makeatoms(self, *args):
     self.update_element()
     if self.legal_element is None or (self.struct.get_active() == 2
                                       and self.legal_element2 is None):
         self.atoms = None
         self.pybut.python = None
     else:
         n = int(self.n.value)
         m = int(self.m.value)
         CC = self.bondlength.value
         vacuum = self.vacuum.value
         orient = self.orient_text[self.orient.get_active()]
         elem = self.legal_element
         if self.struct.get_active() == 0:
             # Extended sheet
             self.atoms = graphene_nanoribbon(n,
                                              m,
                                              type=orient,
                                              C_C=CC,
                                              vacc=vacuum,
                                              sheet=True,
                                              main_element=elem)
         elif self.struct.get_active() == 1:
             # Unsaturated nanoribbon
             self.atoms = graphene_nanoribbon(n,
                                              m,
                                              type=orient,
                                              C_C=CC,
                                              vacc=vacuum,
                                              main_element=elem)
         elif self.struct.get_active() == 2:
             # Saturated nanoribbon
             elem2 = self.legal_element2
             self.atoms = graphene_nanoribbon(n,
                                              m,
                                              type=orient,
                                              C_C=CC,
                                              C_H=self.bondlength2.value,
                                              vacuum=vacuum,
                                              saturated=True,
                                              main_element=elem,
                                              saturate_element=elem2)
         else:
             raise RuntimeError("Unknown structure in SetupGraphene!")
     # Now, rotate into the xy plane (ase.gui's default view plane)
     pos = self.atoms.get_positions()
     cell = self.atoms.get_cell()
     pbc = self.atoms.get_pbc()
     cell[1, 1], cell[2, 2] = cell[2, 2], cell[1, 1]
     x = pos[:, 1].copy()
     z = pos[:, 2].copy()
     pos[:, 1] = z
     pos[:, 2] = x
     self.atoms.set_cell(cell)
     self.atoms.set_positions(pos)
     self.atoms.set_pbc([pbc[0], pbc[2], pbc[1]])
Beispiel #3
0
def make_neighSet(cutoff, edge, bond):
   
    atoms   =   graphene_nanoribbon(50, 50, type='zigzag', C_C = bond)
    atoms.rotate([1,0,0], np.pi/2, rotate_cell = True)
    
    if edge == 'zz':
        atoms.rotate([0,0,1], np.pi/2, rotate_cell = True)
        if cutoff != 15:
            print 'not implemented'
            raise
    if edge == 'ac':
        if cutoff != 15:
            print 'not implemented... cannot be sure of the alingmen for other cutoffs.'
            raise
    
        
    atoms.center()
        
    middle  =   [np.average(atoms.positions[:,0]), \
                 np.average(atoms.positions[:,1]), \
                 np.average(atoms.positions[:,2])]
    
    rem     =   []
    midMin  =   100
    for i, atom in enumerate(atoms):
        if cutoff < np.linalg.norm(atom.position - middle): rem.append(i)
             
    del atoms[rem]
    
    for i, pos in enumerate(atoms.positions):
        if np.linalg.norm(pos - middle) < midMin:
            midMin  =   np.linalg.norm(pos - middle)
            iCentre =   i

    return atoms.positions - atoms.positions[iCentre]
Beispiel #4
0
def make_neighSet(cutoff, edge, bond):

    atoms = graphene_nanoribbon(50, 50, type='zigzag', C_C=bond)
    atoms.rotate([1, 0, 0], np.pi / 2, rotate_cell=True)

    if edge == 'zz':
        atoms.rotate([0, 0, 1], np.pi / 2, rotate_cell=True)
        if cutoff != 15:
            print 'not implemented'
            raise
    if edge == 'ac':
        if cutoff != 15:
            print 'not implemented... cannot be sure of the alingmen for other cutoffs.'
            raise

    atoms.center()

    middle  =   [np.average(atoms.positions[:,0]), \
                 np.average(atoms.positions[:,1]), \
                 np.average(atoms.positions[:,2])]

    rem = []
    midMin = 100
    for i, atom in enumerate(atoms):
        if cutoff < np.linalg.norm(atom.position - middle): rem.append(i)

    del atoms[rem]

    for i, pos in enumerate(atoms.positions):
        if np.linalg.norm(pos - middle) < midMin:
            midMin = np.linalg.norm(pos - middle)
            iCentre = i

    return atoms.positions - atoms.positions[iCentre]
Beispiel #5
0
 def makeatoms(self, *args):
     self.update_element()
     if self.legal_element is None or (self.struct.get_active() == 2 and
                                       self.legal_element2 is None):
         self.atoms = None
         self.pybut.python = None
     else:
         n = int(self.n.value)
         m = int(self.m.value)
         CC = self.bondlength.value
         vacuum = self.vacuum.value
         orient = self.orient_text[self.orient.get_active()]
         elem = self.legal_element
         if self.struct.get_active() == 0:
             # Extended sheet
             self.atoms = graphene_nanoribbon(n, m, type=orient, C_C=CC,
                                              vacc=vacuum, sheet=True,
                                              main_element=elem)
         elif self.struct.get_active() == 1:
             # Unsaturated nanoribbon
             self.atoms = graphene_nanoribbon(n, m, type=orient, C_C=CC,
                                              vacc=vacuum,
                                              main_element=elem)
         elif self.struct.get_active() == 2:
             # Saturated nanoribbon
             elem2 = self.legal_element2
             self.atoms = graphene_nanoribbon(n, m, type=orient, C_C=CC,
                                              C_H=self.bondlength2.value,
                                              vacuum=vacuum,
                                              saturated=True,
                                              main_element=elem,
                                              saturate_element=elem2)
         else:
             raise RuntimeError("Unknown structure in SetupGraphene!")
     # Now, rotate into the xy plane (ase.gui's default view plane)
     pos = self.atoms.get_positions()
     cell = self.atoms.get_cell()
     pbc = self.atoms.get_pbc()
     cell[1,1], cell[2,2] = cell[2,2], cell[1,1]
     x = pos[:,1].copy()
     z = pos[:,2].copy()
     pos[:,1] = z
     pos[:,2] = x
     self.atoms.set_cell(cell)
     self.atoms.set_positions(pos)
     self.atoms.set_pbc([pbc[0], pbc[2], pbc[1]])
Beispiel #6
0
def plot_fig1():

    mdfile = '/space/tohekorh/ShearSlide/files/LJ_10/ac_twistTaito/w=7/md_L=24_v=0.20_00.traj'
    #mdfile  =   '/space/tohekorh/ShearSlide/files/KC_10/ac_stickTaito/w=7/r=20/md_L=145_stL=27_00.traj'

    traj = PickleTrajectory(mdfile)

    z_init = np.average(traj[0].positions[:, 2])
    xrange = [np.min(traj[0].positions[:, 0]), np.max(traj[0].positions[:, 0])]
    yrange = [np.min(traj[0].positions[:, 1]), np.max(traj[0].positions[:, 1])]

    from ase.structure import graphene_nanoribbon
    from ase.visualize import view
    from ase import Atoms
    base = graphene_nanoribbon(70,
                               50,
                               type='armchair',
                               saturated=False,
                               C_C=bond,
                               main_element='N')

    base.rotate([1, 0, 0], np.pi / 2)
    base.positions[:, 2] = z_init - 3.8
    atoms_v = Atoms()
    n = int(len(traj) / 1.3)
    #n       =

    nsnap = 3

    atoms_use = [traj[i] for i in np.array(range(nsnap)) * n / nsnap]

    for i, atoms in enumerate(atoms_use):

        atoms.positions[:, 1] = -atoms.positions[:, 1] - i * 20
        #atoms.positions[:,0] = -atoms.positions[:,0]

        atoms_v += atoms

    cent_atoms = np.array([
        np.average(atoms_v.positions[:, 0]),
        np.average(atoms_v.positions[:, 1]), 0
    ])
    cent_base = np.array([
        np.average(base.positions[:, 0]),
        np.average(base.positions[:, 1]), 0
    ])
    base.translate(cent_atoms - cent_base)

    #atoms_v +=  base
    view(atoms_v, viewer='vmd')
Beispiel #7
0
def plot_fig1():
    
    mdfile  =   '/space/tohekorh/ShearSlide/files/LJ_10/ac_twistTaito/w=7/md_L=24_v=0.20_00.traj'
    #mdfile  =   '/space/tohekorh/ShearSlide/files/KC_10/ac_stickTaito/w=7/r=20/md_L=145_stL=27_00.traj'
    
    traj    =   PickleTrajectory(mdfile)
    
    z_init  =   np.average(traj[0].positions[:,2])
    xrange  =   [np.min(traj[0].positions[:,0]), np.max(traj[0].positions[:,0])]
    yrange  =   [np.min(traj[0].positions[:,1]), np.max(traj[0].positions[:,1])]
    
    from ase.structure import graphene_nanoribbon
    from ase.visualize import view
    from ase import Atoms
    base    =   graphene_nanoribbon(70, 50, type='armchair', saturated=False,
                                    C_C=bond, main_element='N')
    
    base.rotate([1,0,0], np.pi/2)
    base.positions[:,2]     =   z_init - 3.8 
    atoms_v =   Atoms()
    n       =   int(len(traj)/1.3)
    #n       =   
    
    nsnap   =   3
    
    atoms_use   =   [traj[i] for i in np.array(range(nsnap))*n/nsnap]
    
    for i, atoms in enumerate(atoms_use):
        
        atoms.positions[:,1] = -atoms.positions[:,1] - i*20 
        #atoms.positions[:,0] = -atoms.positions[:,0] 
        
        atoms_v +=  atoms
    
    cent_atoms  =   np.array([np.average(atoms_v.positions[:,0]), np.average(atoms_v.positions[:,1]), 0])
    cent_base   =   np.array([np.average(base.positions[:,0]), np.average(base.positions[:,1]), 0])
    base.translate(cent_atoms - cent_base)
        
    #atoms_v +=  base
    view(atoms_v, viewer = 'vmd')
Beispiel #8
0
'''
Created on 12.10.2015

@author: tohekorh
'''

from ase.structure import graphene_nanoribbon
from ase.visualize import view
import numpy as np
from scipy.optimize import fmin
from ase.calculators.lammpsrun import LAMMPS
from scipy.optimize import minimize

bond = 1.4
#atoms   =   graphene_nanoribbon(1, 1, C_C=bond, sheet=True)
atoms = graphene_nanoribbon(1, 1, type='armchair', C_C=bond, sheet=True)
atoms.rotate([1, 0, 0], -np.pi / 2, rotate_cell=True)
atoms.rotate([0, 0, 1], -np.pi / 2, rotate_cell=True)

del atoms[[0, 3]]

atoms.set_cell([[3. / 2 * bond, np.sqrt(3) / 2 * bond, 0],
                [3. / 2 * bond, -np.sqrt(3) / 2 * bond, 0], [0, 0, 9]])
atoms.center()
atoms.set_pbc = [True, True, False]


def setCell(bond):

    cell = np.array([[3. / 2 * bond, np.sqrt(3) / 2. * bond, 0],
                     [3. / 2 * bond, -np.sqrt(3) / 2. * bond, 0], [0, 0, 9.]])
Beispiel #9
0
          run_povray=True)

cnt1 = nanotube(6, 0, length=4)
cnt1.rotate('x', 'z', rotate_cell=True)
cnt2 = nanotube(3, 3, length=6, bond=1.4, symbol='Si')
cnt2.rotate('x', 'z', rotate_cell=True)

for i, a in enumerate([cnt1, cnt2]):
    write('cnt%d.pov' % (i + 1),
          a,
          show_unit_cell=2,
          display=False,
          run_povray=True)

ind = [2, 0, 1]
gnr1 = graphene_nanoribbon(3, 4, type='armchair')
gnr1.set_cell(np.diag(gnr1.cell)[ind])
gnr1.positions = gnr1.positions[:, ind]
gnr2 = graphene_nanoribbon(2,
                           6,
                           type='zigzag',
                           saturated=True,
                           C_H=1.1,
                           C_C=1.4,
                           vacuum=3.0,
                           magnetic=True,
                           initial_mag=1.12)
gnr2.set_cell(np.diag(gnr2.cell)[ind])
gnr2.positions = gnr2.positions[:, ind]

for i, a in enumerate([gnr1, gnr2]):
@author: tohekorh
'''



from ase.structure import graphene_nanoribbon
from ase.visualize import view
import numpy as np
from scipy.optimize import fmin
from ase.calculators.lammpsrun import LAMMPS
from scipy.optimize import minimize

bond    =   1.4
#atoms   =   graphene_nanoribbon(1, 1, C_C=bond, sheet=True)
atoms   =   graphene_nanoribbon(1,1, type = 'armchair', C_C=bond, sheet = True)
atoms.rotate([1,0,0], -np.pi/2, rotate_cell=True)
atoms.rotate([0,0,1], -np.pi/2, rotate_cell=True)

del atoms[[0,3]]

atoms.set_cell([[3./2*bond, np.sqrt(3)/2*bond, 0],
                [3./2*bond, -np.sqrt(3)/2*bond, 0],
                [0,0,9]])
atoms.center()
atoms.set_pbc   =   [True, True, False]




def setCell(bond):
Beispiel #11
0
def get_atoms(wi):
    if wi % 2 == 0:
        if edge == 'ac':
            atoms = graphene_nanoribbon(wi / 2,
                                        1,
                                        type='armchair',
                                        C_C=bond,
                                        saturated=True)
        elif edge == 'zz':
            atoms = graphene_nanoribbon(wi,
                                        1,
                                        type='zigzag',
                                        C_C=bond,
                                        saturated=True)

        atoms.rotate([1, 0, 0], -np.pi / 2, rotate_cell=True)
        atoms.rotate([0, 0, 1], -np.pi / 2, rotate_cell=True)

    else:
        if edge == 'ac':
            atoms = graphene_nanoribbon(wi / 2 + 1,
                                        1,
                                        type='armchair',
                                        C_C=bond,
                                        saturated=True)
        elif edge == 'zz':
            atoms = graphene_nanoribbon(wi + 1,
                                        1,
                                        type='zigzag',
                                        C_C=bond,
                                        saturated=True)

        atoms.rotate([1, 0, 0], -np.pi / 2, rotate_cell=True)
        atoms.rotate([0, 0, 1], -np.pi / 2, rotate_cell=True)
        ymax = np.max(atoms.positions[:, 1])
        delis, hs = [], []
        for i in range(len(atoms)):
            if ymax - 2 < atoms.positions[i, 1]: delis.append(i)
            else:
                if atoms[i].number == 1:
                    hs.append(i)

        atoms_add = Atoms()
        for h in hs:
            if edge == 'ac':
                add_h_vec = [0, (wi - 1) * np.sqrt(3) / 2 * bond + 2 * .943, 0]
            elif edge == 'zz':
                add_h_vec = [
                    -np.sqrt(3) / 2 * bond,
                    (wi * 3. / 2 - 1) * bond + 2 * 1.09, 0
                ]

            atoms_add += Atom('H', position=atoms[h].position + add_h_vec)

        del atoms[delis]

        atoms += atoms_add

    if edge == 'ac':
        atoms.set_cell([3 * bond, np.sqrt(3) / 2 * (wi + 8) * bond, 8])
    elif edge == 'zz':
        atoms.set_cell([np.sqrt(3) * bond, 3 * bond * (wi * 2), 8])

    ymax = np.max(atoms.positions[:, 1])
    yav = np.average(atoms.positions[:, 1])

    miny = 100
    minyidx = 0
    for i, a in enumerate(atoms):
        if np.abs(a.position[1] - yav) < miny:
            miny = np.abs(a.position[1] - yav)
            minyidx = i

    fixId = [np.where(atoms.positions == ymax)[0][0], minyidx]

    atoms.set_pbc([True, False, False])
    atoms.center()
    #view(atoms)
    return atoms, fixId
def corr_KC():
    
    atoms   =   graphene_nanoribbon(1, 1, type= 'armchair', C_C=bond, saturated = False)
    atoms.rotate([1,0,0], np.pi/2, rotate_cell = True)
    
    if edge == 'ac':    
        atoms.rotate([0,0,1], -np.pi/2, rotate_cell = True)
        del atoms[[0,3]]
        trans_idx   =   1
    elif edge == 'zz':
        del atoms[[1,0]]
        trans_idx   =   0
    
    atoms.set_cell([20, 20, 10])
    atoms.center()
    
    params  =   {}
    params['positions']         =   atoms.positions
    params['chemical_symbols']  =   atoms.get_chemical_symbols()   
    params['ia_dist']           =   10
    params['edge']              =   edge
    params['bond']              =   bond    
    params['ncores']            =   2
    add_KC                      =   KC_potential_p(params, True)
    
    
    constraints =   []
    for i in range(len(atoms)):
        fix_l   =   FixedLine(i, [0., 0., 1.])
        constraints.append(fix_l)
    
    constraints.append(add_KC)
    
    lamp_parameters =   get_lammps_params(H=False)
    calc            =   LAMMPS(parameters = lamp_parameters) #, files=['lammps.data'])
    atoms.set_calculator(calc)
    atoms.set_constraint(constraints)
    
    #dyn     =   BFGS(atoms, trajectory = 'test.traj')
    #dyn.run(fmax=0.05)
    
    #plot_posits(atoms, edge, bond)
    trans_vec   =   trans_atomsKC(atoms.positions[trans_idx], edge, bond)
    atoms.translate(trans_vec)
    
    #plot_posits(atoms, edge, bond)
    init_pos    =   atoms.positions.copy()
    r_around    =   init_pos[trans_idx]
    
    #thetas      =   np.linspace(0, np.pi/3, 7) #, endpoint = False)
    #thetas_deg  =   np.array([1,3,5,7,9,11,12,13,15,17,43,45,47,48,49,51,57,55,57,59])
    thetas_deg  =   np.array([.5,1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,11.5,12.5,13.5,14.5,15.5,16.5,17.5,18.5,19.5])
    
    traj        =   PickleTrajectory(path + '%s_corr_twist_thetas_(%.1f-%.1f).traj' \
                                     %(edge, np.min(thetas_deg), 
                                       np.max(thetas_deg)), 'w', atoms)

    n           =   100
    
    for i, theta_deg in enumerate(thetas_deg):
        fname   =   path + 'corr_%s_theta=%.2f.data' %(edge, theta_deg)
        print 'Calculating theta = %.2f' %(theta_deg)
        theta   =   theta_deg/360*np.pi*2
        print 'time ' + str(datetime.now().time())
        atoms.positions =   init_pos
        atoms.rotate([0,0,1], theta, center = r_around)
        rot_init_pos    =   atoms.positions.copy()
        
        lat_vec_theta1  =   lat_vec1.copy()
        lat_vec_theta2  =   lat_vec2.copy()

                
        trans_vec2      =   lat_vec_theta2.copy()/n
        
        data            =   np.zeros((n,n))
        
        for k in range(n):
            atoms.positions =   rot_init_pos
            atoms.translate(lat_vec_theta1*float(k)/n)
            #plot_posits(atoms, edge, bond, vecs =  [lat_vec_theta1, lat_vec_theta2])
            print '%.1f percent done' %(100*float(k)/n)
            for l in range(n):
                atoms.translate(trans_vec2)
                emin        =   get_optimal_h(atoms, len(atoms), dyn = False)[0]
                data[k,l]   =   emin #atoms.get_potential_energy()/len(atoms) #emin #
                saveAndPrint(atoms, traj, False)
                
                
        header  =   '%s runs along x-dir, angle measured from x-axis, natoms = %i. x (Angs), e (eV/atom), hmin \n\
the lattice vectors are l1 = [%.5f, %.5f, %.5f] and l2 = [%.5f, %.5f, %.5f], they are divided in %i parts. data[i,j,:] \n\
-> atoms pos += l1/n*i + l2/n*j, initial position is such that atom1 is in middle if hexagon.' \
    %(edge, len(atoms), lat_vec_theta1[0], lat_vec_theta1[1], lat_vec_theta1[2], \
      lat_vec_theta2[0], lat_vec_theta2[1], lat_vec_theta2[2], n)
        np.savetxt(fname, data, header = header)
Beispiel #13
0
from ase.optimize import QuasiNewton
from ase.structure import graphene_nanoribbon
from gpaw import GPAW

GNR = graphene_nanoribbon(12, 1, type='zigzag', vacc=6)
GNR.set_pbc((0, 0, 1))
kpts = (1, 1, 10)
calc = GPAW(kpts=kpts, spinpol=True)
GNR.set_calculator(calc)
dyn = QuasiNewton(GNR, trajectory='ZGNR12.traj')
dyn.run(fmax=0.05)
Beispiel #14
0
from ase.optimize import QuasiNewton
from ase.structure import graphene_nanoribbon
from gpaw import GPAW

GNR = graphene_nanoribbon(12,1,type='zigzag', vacc=6)
GNR.set_pbc((0,0,1))
kpts = (1,1,10)
calc = GPAW(kpts=kpts,spinpol=True)
GNR.set_calculator(calc)
dyn = QuasiNewton(GNR, trajectory='ZGNR12.traj')
dyn.run(fmax=0.05)
Beispiel #15
0
for i, a in enumerate([
    bulk('Cu', 'fcc', a=3.6),
    bulk('Cu', 'fcc', a=3.6, orthorhombic=True),
    bulk('Cu', 'fcc', a=3.6, cubic=True)]):
    write('a%d.pov' % (i + 1), a,
          show_unit_cell=2, display=False, run_povray=True)

cnt1 = nanotube(6, 0, length=4)
cnt1.rotate('x', 'z', rotate_cell=True)
cnt2 = nanotube(3, 3, length=6, bond=1.4, symbol='Si')
cnt2.rotate('x', 'z', rotate_cell=True)

for i, a in enumerate([cnt1, cnt2]):
    write('cnt%d.pov' % (i + 1), a,
          show_unit_cell=2, display=False, run_povray=True)

ind = [2, 0, 1]
gnr1 = graphene_nanoribbon(3, 4, type='armchair', saturated=True)
gnr1.set_cell(np.diag(gnr1.cell)[ind])
gnr1.positions = gnr1.positions[:, ind]
gnr2 = graphene_nanoribbon(2, 6, type='zigzag', saturated=True,
                           C_H=1.1, C_C=1.4, vacuum=3.0, 
                           magnetic=True, initial_mag=1.12)
gnr2.set_cell(np.diag(gnr2.cell)[ind])
gnr2.positions = gnr2.positions[:, ind]

for i, a in enumerate([gnr1, gnr2]):
    write('gnr%d.pov' % (i + 1), a,
          show_unit_cell=2, display=False, run_povray=True)
Beispiel #16
0
def get_atoms(wi):
    if wi % 2 == 0:
        if edge == 'ac':
            atoms   =   graphene_nanoribbon(wi/2,1, type = 'armchair', C_C=bond, saturated = True)
        elif edge == 'zz':
            atoms   =   graphene_nanoribbon(wi,1, type = 'zigzag', C_C=bond, saturated = True)

        atoms.rotate([1,0,0], -np.pi/2, rotate_cell=True)
        atoms.rotate([0,0,1], -np.pi/2, rotate_cell=True)
        
    else:
        if edge == 'ac':
            atoms   =   graphene_nanoribbon(wi/2 + 1, 1, type = 'armchair',  C_C=bond, saturated = True)
        elif edge == 'zz':
            atoms   =   graphene_nanoribbon(wi + 1, 1, type = 'zigzag',  C_C=bond, saturated = True)

        atoms.rotate([1,0,0], -np.pi/2, rotate_cell=True)
        atoms.rotate([0,0,1], -np.pi/2, rotate_cell=True)
        ymax        =   np.max(atoms.positions[:,1])
        delis, hs   =   [], []
        for i in range(len(atoms)):
            if ymax - 2 < atoms.positions[i,1]: delis.append(i) 
            else:
                if atoms[i].number == 1:
                    hs.append(i)
        
        
        atoms_add   =   Atoms()
        for h in hs:
            if edge == 'ac':   add_h_vec    =   [0, (wi-1)*np.sqrt(3)/2*bond + 2*.943, 0]
            elif edge == 'zz': add_h_vec    =   [-np.sqrt(3)/2*bond, (wi*3./2 - 1)*bond + 2*1.09, 0]
            
            atoms_add   +=  Atom('H', position=atoms[h].position + add_h_vec)
        
        del atoms[delis]
    
        atoms   +=  atoms_add
            
    
    
    if edge == 'ac':
        atoms.set_cell([3*bond, np.sqrt(3)/2*(wi + 8)*bond, 8])
    elif edge == 'zz':
        atoms.set_cell([np.sqrt(3)*bond, 3*bond * (wi*2),  8])
    
    ymax    =   np.max(atoms.positions[:,1])
    yav     =   np.average(atoms.positions[:,1])
    
    miny    =   100
    minyidx =   0
    for i, a in enumerate(atoms):
        if np.abs(a.position[1] - yav) < miny:  
            miny    =   np.abs(a.position[1] - yav)
            minyidx =   i
    
    fixId   =   [np.where(atoms.positions == ymax)[0][0], minyidx]
        
    atoms.set_pbc([True, False, False])
    atoms.center() 
    #view(atoms)
    return atoms, fixId
Beispiel #17
0
def corr_KC():

    atoms = graphene_nanoribbon(1,
                                1,
                                type='armchair',
                                C_C=bond,
                                saturated=False)
    atoms.rotate([1, 0, 0], np.pi / 2, rotate_cell=True)

    if edge == 'ac':
        atoms.rotate([0, 0, 1], -np.pi / 2, rotate_cell=True)
        del atoms[[0, 3]]
        trans_idx = 1
    elif edge == 'zz':
        del atoms[[1, 0]]
        trans_idx = 0

    atoms.set_cell([20, 20, 10])
    atoms.center()

    params = {}
    params['positions'] = atoms.positions
    params['chemical_symbols'] = atoms.get_chemical_symbols()
    params['ia_dist'] = 10
    params['edge'] = edge
    params['bond'] = bond
    params['ncores'] = 2
    add_KC = KC_potential_p(params, True)

    constraints = []
    for i in range(len(atoms)):
        fix_l = FixedLine(i, [0., 0., 1.])
        constraints.append(fix_l)

    constraints.append(add_KC)

    lamp_parameters = get_lammps_params(H=False)
    calc = LAMMPS(parameters=lamp_parameters)  #, files=['lammps.data'])
    atoms.set_calculator(calc)
    atoms.set_constraint(constraints)

    #dyn     =   BFGS(atoms, trajectory = 'test.traj')
    #dyn.run(fmax=0.05)

    #plot_posits(atoms, edge, bond)
    trans_vec = trans_atomsKC(atoms.positions[trans_idx], edge, bond)
    atoms.translate(trans_vec)

    #plot_posits(atoms, edge, bond)
    init_pos = atoms.positions.copy()
    r_around = init_pos[trans_idx]

    #thetas      =   np.linspace(0, np.pi/3, 7) #, endpoint = False)
    #thetas_deg  =   np.array([1,3,5,7,9,11,12,13,15,17,43,45,47,48,49,51,57,55,57,59])
    thetas_deg = np.array([
        .5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5,
        13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5
    ])

    traj        =   PickleTrajectory(path + '%s_corr_twist_thetas_(%.1f-%.1f).traj' \
                                     %(edge, np.min(thetas_deg),
                                       np.max(thetas_deg)), 'w', atoms)

    n = 100

    for i, theta_deg in enumerate(thetas_deg):
        fname = path + 'corr_%s_theta=%.2f.data' % (edge, theta_deg)
        print 'Calculating theta = %.2f' % (theta_deg)
        theta = theta_deg / 360 * np.pi * 2
        print 'time ' + str(datetime.now().time())
        atoms.positions = init_pos
        atoms.rotate([0, 0, 1], theta, center=r_around)
        rot_init_pos = atoms.positions.copy()

        lat_vec_theta1 = lat_vec1.copy()
        lat_vec_theta2 = lat_vec2.copy()

        trans_vec2 = lat_vec_theta2.copy() / n

        data = np.zeros((n, n))

        for k in range(n):
            atoms.positions = rot_init_pos
            atoms.translate(lat_vec_theta1 * float(k) / n)
            #plot_posits(atoms, edge, bond, vecs =  [lat_vec_theta1, lat_vec_theta2])
            print '%.1f percent done' % (100 * float(k) / n)
            for l in range(n):
                atoms.translate(trans_vec2)
                emin = get_optimal_h(atoms, len(atoms), dyn=False)[0]
                data[
                    k,
                    l] = emin  #atoms.get_potential_energy()/len(atoms) #emin #
                saveAndPrint(atoms, traj, False)


        header  =   '%s runs along x-dir, angle measured from x-axis, natoms = %i. x (Angs), e (eV/atom), hmin \n\
the lattice vectors are l1 = [%.5f, %.5f, %.5f] and l2 = [%.5f, %.5f, %.5f], they are divided in %i parts. data[i,j,:] \n\
-> atoms pos += l1/n*i + l2/n*j, initial position is such that atom1 is in middle if hexagon.' \
    %(edge, len(atoms), lat_vec_theta1[0], lat_vec_theta1[1], lat_vec_theta1[2], \
      lat_vec_theta2[0], lat_vec_theta2[1], lat_vec_theta2[2], n)
        np.savetxt(fname, data, header=header)
Beispiel #18
0
if __name__ == '__main__':
    from ase import Atoms
    from ase.cluster.cubic import FaceCenteredCubic
    from ase.structure import graphene_nanoribbon
    from ase.visualize import view

    surfaces = [(1,0,0), (1,1,0)]
    layers = [3,2]
    nano = Atoms(FaceCenteredCubic('Pt', surfaces, layers, 4.0))
    symbols = nano.get_chemical_symbols()
    symbols[0] = 'Cu'
    symbols[12] = 'Cu'
    nano.set_chemical_symbols(symbols)
    nano.pop(6)
    support = graphene_nanoribbon(8, 6, type='armchair', saturated=False)
    support.translate([-8,-2,-8])
    nano.extend(support)
    support.translate([0,-3.0,0])
    nano.extend(support)
    nano.center(vacuum=10)
    #~ view(nano)
    calc = Hybrid()
    nano.set_calculator(calc)
    # check subsystems selection
    from ase.io import write
    write('nanoparticle.pdb', calc.np_atoms)
    write('support.pdb', calc.sp_atoms)
    print ("Energy %f eV"% nano.get_potential_energy())