def graphene(n1, n2, R, height=5.0): """ Construct graphene lattice, multiply the primitive cell n1 x n2 times in corresponding directions. .-----. / / / X / a2 / / X-----> a1 """ from hotbit import Atoms if not isinstance(R, float): R = R[0] a1 = vec([R * np.cos(pi / 6) * 2, 0., 0.]) a2 = 0.5 * a1 + vec([0., 1.5 * R, 0.]) #assert n2%2==0 r = [] for i1 in range(n1): for i2 in range(n2): corner = i1 * a1 + i2 * a2 r.append(corner) r.append(corner + a1 + vec([0.0, R, 0.0])) cell = [[n1 * a1[0], 0, 0], [n2 * a2[0], n2 * a2[1], 0], [0, 0, 10]] atoms = Atoms('C' * len(r), positions=r, cell=cell) atoms.center(vacuum=height / 2, axis=2) atoms.set_pbc((True, True, False)) return atoms
def graphene(n1,n2,R,height=5.0): """ Construct graphene lattice, multiply the primitive cell n1 x n2 times in corresponding directions. .-----. / / / X / a2 / / X-----> a1 """ from hotbit import Atoms if not isinstance(R,float): R=R[0] a1=vec([R*np.cos(pi/6)*2,0.,0.]) a2=0.5*a1 + vec([0.,1.5*R,0.]) #assert n2%2==0 r=[] for i1 in range(n1): for i2 in range(n2): corner = i1*a1+i2*a2 r.append(corner) r.append(corner+a1+vec([0.0,R,0.0])) cell=[[n1*a1[0], 0, 0],[n2*a2[0],n2*a2[1],0],[0,0,10]] atoms=Atoms('C'*len(r),positions=r,cell=cell) atoms.center(vacuum=height/2,axis=2) atoms.set_pbc((True,True,False)) return atoms
def nanotube(n, m, R=1.42, length=1, element='C'): ''' Create a nanotube around z-axis. parameters: ----------- n,m: chiral indices R: nearest neighbor distance length: number of unit cells element: element symbol ''' from hotbit import Atoms at = Atoms(pbc=(False, False, True)) sq3 = sqrt(3.0) a0 = R gcn = gcd(n, m) a1 = np.array([sq3 / 2, 0.5]) * a0 * sq3 a2 = np.array([sq3 / 2, -0.5]) * a0 * sq3 h = float(float(n) - float(m)) / float(3 * gcn) if h - int(h) == 0.0: RR = 3 else: RR = 1 c = n * a1 + m * a2 abs_c = sqrt(dot(c, c)) a = (-(2 * m + n) * a1 + (2 * n + m) * a2) / (gcn * RR) abs_a = sqrt(dot(a, a)) eps = 0.01 b = [[1. / 3 - eps, 1. / 3 - eps], [2. / 3 - eps, 2. / 3 - eps]] nxy = max(n, m) + 100 eps = 0.00001 for x in xrange(-nxy, nxy): for y in xrange(-nxy, nxy): for b1, b2 in b: p = (x + b1) * a1 + (y + b2) * a2 abs_p = sqrt(dot(p, p)) sa = dot(p, a) / (abs_a**2) sc = dot(p, c) / (abs_c**2) if sa >= 0 and sa < 1 - eps and sc >= 0 and sc < 1 - eps: r = (cos(2 * pi * sc) * abs_c / (2 * pi), sin(2 * pi * sc) * abs_c / (2 * pi), sa * abs_a) at += Atom(element, r) at.set_cell((2 * abs_c / (2 * pi), 2 * abs_c / (2 * pi), length * abs_a)) b = at.copy() for i in range(length - 1): b.translate((0.0, 0.0, abs_a)) for j in b: at += j at.center(axis=2) rcm = at.get_center_of_mass() at.translate((-rcm[0], -rcm[1], 0)) at.set_pbc((False, False, True)) at.data = nanotube_data(n, m) return at
def nanotube(n,m,R=1.42,length=1,element='C'): ''' Create a nanotube around z-axis. parameters: ----------- n,m: chiral indices R: nearest neighbor distance length: number of unit cells element: element symbol ''' from hotbit import Atoms at = Atoms( pbc = ( False, False, True ) ) sq3 = sqrt(3.0) a0 = R gcn = gcd(n, m) a1 = np.array( [ sq3/2, 0.5 ] ) * a0 * sq3 a2 = np.array( [ sq3/2, -0.5 ] ) * a0 * sq3 h = float(float(n)-float(m))/float(3*gcn) if h-int(h) == 0.0: RR = 3 else: RR = 1 c = n*a1 + m*a2 abs_c = sqrt(dot(c, c)) a = ( -(2*m+n)*a1 + (2*n+m)*a2 )/(gcn*RR) abs_a = sqrt(dot(a, a)) eps = 0.01 b = [ [ 1./3-eps, 1./3-eps ], [ 2./3-eps, 2./3-eps ] ] nxy = max(n, m)+100 eps = 0.00001 for x in xrange(-nxy, nxy): for y in xrange(-nxy, nxy): for b1, b2 in b: p = (x+b1)*a1 + (y+b2)*a2 abs_p = sqrt(dot(p, p)) sa = dot(p, a)/(abs_a**2) sc = dot(p, c)/(abs_c**2) if sa >= 0 and sa < 1-eps and sc >= 0 and sc < 1-eps: r = ( cos(2*pi*sc)*abs_c/(2*pi), sin(2*pi*sc)*abs_c/(2*pi), sa*abs_a ) at += Atom( element, r ) at.set_cell( ( 2*abs_c/(2*pi), 2*abs_c/(2*pi), length*abs_a ) ) b = at.copy() for i in range(length-1): b.translate( ( 0.0, 0.0, abs_a ) ) for j in b: at += j at.center(axis=2) rcm = at.get_center_of_mass() at.translate( (-rcm[0],-rcm[1],0) ) at.set_pbc((False,False,True)) at.data = nanotube_data(n,m) return at