示例#1
0
def chiral_nanotube(n, m, R=1.42, element='C'):
    """
    Construct a nanotube with a chiral container.
    
    parameters:
    ===========
    n,m:     chiral indices
    R:       bond length
    element: element type 
    """
    from hotbit import Atoms
    a = np.sqrt(3) * R
    a1 = np.array([a, 0, 0])
    a2 = np.array([0.5 * a, -1.5 * R, 0])

    rl = []
    shift = (a / 2, -0.5 * R, 0)
    for i in range(n):
        origin = i * a1
        rl.append(origin)
        rl.append(origin + shift)

    for j in range(m):
        origin = (n - 1) * a1 + (j + 1) * a1
        rl.append(origin)
        rl.append(origin + shift)

    atoms = Atoms()
    C = n * a1 + m * a2
    Cn = np.linalg.norm(C)
    T = np.array([C[1], -C[0], 0])
    t = T / np.linalg.norm(T)
    radius = Cn / (2 * pi)

    atoms = Atoms()
    for r in rl:
        phi = np.dot(r, C) / Cn**2 * 2 * pi
        atoms += Atom(
            element,
            (radius * np.cos(phi), radius * np.sin(phi), np.dot(r, t)))

    atoms = Atoms(atoms, container='Chiral')
    height = np.abs(np.dot(a1 - a2, t))
    angle = -np.dot(a1 - a2, C) / Cn**2 * 2 * pi
    atoms.set_container(angle=angle, height=height)

    data = nanotube_data(n, m, R)
    T, Ntot = data['T'], 2 * data['hexagons_per_cell']
    data['height'] = height
    data['twist'] = angle
    atoms.data = data
    return atoms
示例#2
0
def chiral_nanotube(n,m,R=1.42,element='C'):
    """
    Construct a nanotube with a chiral container.
    
    parameters:
    ===========
    n,m:     chiral indices
    R:       bond length
    element: element type 
    """
    from hotbit import Atoms
    a = np.sqrt(3)*R
    a1 = np.array([a,0,0])
    a2 = np.array([0.5*a,-1.5*R,0])
    
    rl = []
    shift = (a/2,-0.5*R,0)
    for i in range(n):
        origin = i*a1
        rl.append( origin )
        rl.append( origin+shift )
          
    for j in range(m):
        origin = (n-1)*a1 + (j+1)*a1
        rl.append( origin )
        rl.append( origin + shift )
        
    atoms = Atoms()
    C = n*a1 + m*a2
    Cn = np.linalg.norm(C)
    T = np.array([C[1],-C[0],0])
    t = T/np.linalg.norm(T)
    radius = Cn/(2*pi)
    
    atoms = Atoms()
    for r in rl:
        phi = np.dot(r,C)/Cn**2 * 2*pi
        atoms += Atom( element,(radius*np.cos(phi),radius*np.sin(phi),np.dot(r,t)) )
    
    atoms = Atoms(atoms,container='Chiral')
    height = np.abs( np.dot(a1-a2,t) )
    angle = -np.dot(a1-a2,C)/Cn**2 * 2*pi
    atoms.set_container(angle=angle,height=height) 
    
    data = nanotube_data(n,m,R)
    T, Ntot = data['T'],2*data['hexagons_per_cell']
    data['height']=height
    data['twist']=angle
    atoms.data = data
    return atoms
示例#3
0
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
示例#4
0
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