Пример #1
0
from ase.calculators.lammpsrun import LAMMPS
from ase.optimize import BFGS
from structure import create_stucture
from ase.visualize import view
from ase.structure import graphene_nanoribbon
from write_structure import saveAndPrint
from ase.io.trajectory import PickleTrajectory
from datetime import datetime
import matplotlib.pyplot as plt
import os

path = '/space/tohekorh/ShearSlide/files/KC_corrugation/twist4/'

edge = 'ac'

params0 = get_simulParams(edge)[-1]
bond = params0['bond']

if edge == 'ac':
    lat_vec1 = np.array([3. / 2 * bond, np.sqrt(3) / 2 * bond, 0.])
    lat_vec2 = np.array([3. / 2 * bond, -np.sqrt(3) / 2 * bond, 0.])
elif edge == 'zz':
    lat_vec1 = np.array([np.sqrt(3.) / 2 * bond, 3. / 2 * bond, 0.])
    lat_vec2 = np.array([np.sqrt(3.) * bond, 0., 0.])


def Rmat(theta):

    return np.array([[np.cos(theta), -np.sin(theta), 0.],
                     [np.sin(theta), np.cos(theta), 0.], [0., 0., 1.]])
Пример #2
0
from structure import create_stucture, get_posInds, get_constraints
from ase.calculators.lammpsrun import LAMMPS
from ase.visualize import view
from ase.io.trajectory import PickleTrajectory
from ase.md.langevin import Langevin
from ase.optimize import BFGS
from ase.md.velocitydistribution import MaxwellBoltzmannDistribution as mbd
from ase import units
import sys

#width, edge, rmin, rmax =  int(sys.argv[1]), sys.argv[2], int(sys.argv[3]), int(sys.argv[4])

taito = False
width, edge, rmin, rmax = 7, 'ac', 5, 6

T, dt, fric, thres_Z, v, bond, h = get_simulParams(edge)

#bond        =   1.39695
#h           =   3.3705
#ncores      =   2
#T           =   10 #K
#dt, fric    =   2, 0.002
#v           =   .001 #Angst/fs

tau = 10. / fric / 5
#thres_Z     =   4.


def shearDyn(width, ratio, edge, save=False, force_dir_update=True):

    atoms, L, W, length_int, b_idxs = create_stucture(ratio,
Пример #3
0
def corr_KC(width, edge):
    #width   =   5
    #edge    =   'ac'
    params0 = get_simulParams(edge)[-1]
    bond = params0['bond']

    atoms = create_stucture(1, width, edge, key='top', a=bond)[0]

    atoms.set_cell([40, 40, 20])
    atoms.center()
    atoms.positions[:, 2] = 3.4

    h_t = []
    for i in range(len(atoms)):
        if atoms[i].number == 1:
            h_t.append(i)

    del atoms[h_t]

    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)

    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)

    trans_vec = trans_atomsKC(atoms.positions[0], edge, bond)
    atoms.translate(trans_vec)

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

    thetas = np.linspace(np.pi / 2, np.pi, 91)
    L = 4 * bond
    ds = .05
    n = int(L / ds)

    for i, theta in enumerate(thetas):
        fname = path + 'corr_w=%02d_%s_theta=%.2f.data' % (width, edge, theta /
                                                           (2 * np.pi) * 360)
        if not os.path.isfile(fname):
            print 'Calculating w=%i, theta = %.2f' % (width, theta /
                                                      (2 * np.pi) * 360)

            atoms.positions = init_pos
            atoms.rotate([0, 0, 1], theta, center=middle)
            trans_vec = np.array([-np.sin(theta), np.cos(theta), 0])
            data = np.zeros((n, 3))

            for j in range(n):
                atoms.translate(ds * trans_vec)
                emin, hmin = get_optimal_h(atoms, len(atoms), dyn=False)
                data[j, :] = [j * ds, emin, hmin]
                #plot_posits(atoms, edge, bond)

            header = '%s runs along x-dir, angle measured from x-axis, natoms = %i. x (Angs), e (eV/atom), hmin' % (
                edge, len(atoms))
            np.savetxt(fname, data, header=header)
Пример #4
0
def corr_KC(width, edge):

    params0 = get_simulParams(edge)[-1]
    bond = params0['bond']
    '''
    atoms   =   graphene_nanoribbon(1, 1, type= 'armchair', C_C=bond, saturated = False)
    atoms.rotate([1,0,0], np.pi/2, rotate_cell = True)
    atoms.rotate([0,0,1], -np.pi/2, rotate_cell = True)
    atoms.set_cell([20, 20, 10])
    atoms.center()
    del atoms[[2,3]]
    '''
    atoms = create_stucture(2, width, edge, key='top', a=bond)[0]

    atoms.set_cell([70, 70, 20])
    atoms.center()
    atoms.positions[:, 2] = 3.4

    h_t = []
    for i in range(len(atoms)):
        if atoms[i].number == 1:
            h_t.append(i)

    del atoms[h_t]

    #view(atoms)
    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
    params['no_edge_neigh'] = True
    add_KC = KC_potential_p(params)

    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[0], edge, bond)
    atoms.translate(trans_vec)

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

    thetas = np.linspace(0, np.pi / 3, 61)
    n = 15

    lat_vec1 = np.array([3. / 2 * bond, np.sqrt(3) / 2 * bond, 0.])
    lat_vec2 = np.array([3. / 2 * bond, -np.sqrt(3) / 2 * bond, 0.])

    for i, theta in enumerate(thetas):
        fname = path + 'corr_%s_theta=%.2f.data' % (edge, theta /
                                                    (2 * np.pi) * 360)
        #if not os.path.isfile(fname):
        print 'Calculating theta = %.2f' % (theta / (2 * np.pi) * 360)
        atoms.positions = init_pos
        atoms.rotate([0, 0, 1], theta, center=r_around)

        R = np.array([[np.cos(theta), -np.sin(theta), 0.],
                      [np.sin(theta), np.cos(theta), 0.], [0., 0., 1.]])

        lat_vec_theta1 = np.dot(R, lat_vec1.copy())
        lat_vec_theta2 = np.dot(R, lat_vec2.copy())

        #trans_vec1      =   lat_vec_theta1.copy()/n
        trans_vec2 = lat_vec_theta2.copy() / n

        data = np.zeros((n, n))
        #plot_posits(atoms, edge, bond, vecs =  [lat_vec_theta1, lat_vec_theta2])

        for k in range(n):
            atoms.positions = init_pos
            atoms.translate(lat_vec_theta1 * float(k) / n)
            #plot_posits(atoms, edge, bond, vecs =  [lat_vec_theta1, lat_vec_theta2])
            #print trans_vec1*float(k)/n, k, n, float(k)/n

            for l in range(n):
                atoms.translate(trans_vec2)
                emin, hmin = get_optimal_h(atoms, len(atoms), dyn=False)
                #data[k,l,:]  =   [emin, hmin]
                data[k, l] = emin  #atoms.get_potential_energy()/len(atoms)

        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)
Пример #5
0
'''
Created on 31.8.2015

@author: tohekorh
'''

from twist_topByRod import shearDyn
from misc.lammps_help import get_simulParams
import sys

#width, edge, ratio  =  int(sys.argv[1]), sys.argv[2], int(sys.argv[3])

width, edge, ratio =   8, 'zz', 4
vs      =   [0.0001, 0.0002, 0.0003, 0.0004, 0.0005]   
taito   =   False


params_dic          =   get_simulParams(edge)[-1]
params_dic['taito'] =   taito
params_dic['ratio'] =   ratio
params_dic['width'] =   width
params_dic['vMAX']  =   .0008    
pot_key             =   'LJ'

for _ in range(0, 5):
    for v in vs:
        params_dic['vmax']  =   v
        folder  =   shearDyn(params_dic, pot_key, True)
Пример #6
0
def plot_corr_surf(edge):

    params0 = get_simulParams(edge)[-1]
    bond = params0['bond']

    lat_vec1 = np.array([3. / 2 * bond, np.sqrt(3) / 2 * bond, 0.])
    lat_vec2 = np.array([3. / 2 * bond, -np.sqrt(3) / 2 * bond, 0.])

    print lat_vec1

    for filen in os.listdir(path):
        if filen[:7] == 'corr_%s' % (edge):
            print filen.split('theta=')[-1].split('.data')[0]
            theta = float(
                filen.split('theta=')[-1].split('.data')[0]) / 360 * 2 * np.pi
            data = np.loadtxt(path + filen)
            data -= np.min(data)
            emax = np.max(data)
            n, m = data.shape

            R = np.array([[np.cos(theta), -np.sin(theta), 0.],
                          [np.sin(theta), np.cos(theta), 0.], [0., 0., 1.]])

            lat_vec_theta1 = np.dot(R, lat_vec1.copy())
            lat_vec_theta2 = np.dot(R, lat_vec2.copy())
            X = np.zeros((n, m))
            Y = np.zeros((n, m))
            Z = np.zeros((n, m))

            for i in range(n):
                for j in range(m):
                    x, y, _ = i * lat_vec_theta1 / n + j * lat_vec_theta2 / n
                    X[i, j] = x
                    Y[i, j] = y
                    Z[i, j] = data[i, j] * 1000  #t get meV

            origin = 'lower'

            xmin, xmax, Dx = np.min(X), np.max(X), np.max(X) - np.min(X)
            ymin, ymax, Dy = np.min(Y), np.max(Y), np.max(Y) - np.min(Y)
            plt.figure(figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k')

            plt.arrow(xmin, ymin, 1, .0)
            plt.arrow(xmin, ymin, 1 * np.cos(theta), 1 * np.sin(theta))

            plt.text(xmin - .05 * Dx * np.sin(theta),
                     ymin + Dy * (.05 + .05 * np.cos(theta)),
                     'ac-edge of top',
                     rotation=theta / (2 * np.pi) * 360)
            plt.text(xmin, ymin - .05 * Dy, 'ac-edge of bottom')
            CS = plt.contourf(
                X,
                Y,
                Z,
                100,  # [-1, -0.1, 0, 0.1],
                #alpha=0.5,
                cmap=plt.cm.cool,
                origin=origin)

            print theta
            plt.axis('off')
            plt.axis('equal')
            plt.title('Theta = %.1f deg' % (theta / (2 * np.pi) * 360))
            cbar = plt.colorbar(CS)
            cbar.ax.set_ylabel('corrugation meV/atom')
            plt.show()
    '''
Пример #7
0
from ase.calculators.lammpsrun import LAMMPS
from ase.optimize import BFGS
from structure import create_stucture
from ase.visualize import view
from ase.structure import graphene_nanoribbon
from write_structure import saveAndPrint
from ase.io.trajectory import PickleTrajectory
from datetime import datetime
import matplotlib.pyplot as plt 
import os

path    =   '/space/tohekorh/ShearSlide/files/KC_corrugation/twist4/'

edge    =   'ac'

params0 =   get_simulParams(edge)[-1]
bond    =   params0['bond']
    
if edge == 'ac':
    lat_vec1    =   np.array([3./2*bond,  np.sqrt(3)/2*bond, 0.])   
    lat_vec2    =   np.array([3./2*bond, -np.sqrt(3)/2*bond, 0.])
elif edge == 'zz':
    lat_vec1    =   np.array([np.sqrt(3.)/2*bond, 3./2*bond, 0.])   
    lat_vec2    =   np.array([np.sqrt(3.)*bond, 0., 0.])

    
def Rmat(theta):
    
    return  np.array([[np.cos(theta), -np.sin(theta), 0.],
                      [np.sin(theta),  np.cos(theta), 0.],
                      [0., 0., 1.]])
def corr_KC(width, edge):
    #width   =   5
    #edge    =   'ac'
    params0 =   get_simulParams(edge)[-1]
    bond    =   params0['bond']
    
    
    atoms   =   create_stucture(1, width, edge, key = 'top', a = bond)[0]
    
    atoms.set_cell([40, 40, 20])
    atoms.center()
    atoms.positions[:,2]    =   3.4
     
    h_t =   []
    for i in range(len(atoms)):
        if atoms[i].number == 1:
            h_t.append(i)
    
    del atoms[h_t]
    
    
    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)
    
    
    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)
    
    trans_vec   =   trans_atomsKC(atoms.positions[0], edge, bond)
    atoms.translate(trans_vec)
    
    init_pos    =   atoms.positions.copy()
    middle      =   [np.average(init_pos[:,0]), 
                     np.average(init_pos[:,1]), 
                     np.average(init_pos[:,2])]
     
    
    thetas      =   np.linspace(np.pi/2, np.pi, 91)
    L           =   4*bond
    ds          =   .05
    n           =   int(L/ds)
    
    for i, theta in enumerate(thetas):
        fname   =   path + 'corr_w=%02d_%s_theta=%.2f.data' %(width, edge, theta/(2*np.pi)*360)
        if not os.path.isfile(fname): 
            print 'Calculating w=%i, theta = %.2f' %(width, theta/(2*np.pi)*360)
            
            atoms.positions =   init_pos
            atoms.rotate([0,0,1], theta, center = middle)
            trans_vec       =   np.array([-np.sin(theta), np.cos(theta), 0])
            data            =   np.zeros((n, 3))
            
            for j in range(n):
                atoms.translate(ds*trans_vec)
                emin, hmin  =   get_optimal_h(atoms, len(atoms), dyn = False)
                data[j, :]  =   [j*ds, emin, hmin]   
                #plot_posits(atoms, edge, bond)
            
            header  =   '%s runs along x-dir, angle measured from x-axis, natoms = %i. x (Angs), e (eV/atom), hmin' %(edge, len(atoms))
            np.savetxt(fname, data, header = header)
Пример #9
0
def corr_KC(width, edge):
    
    params0 =   get_simulParams(edge)[-1]
    bond    =   params0['bond']
    
    '''
    atoms   =   graphene_nanoribbon(1, 1, type= 'armchair', C_C=bond, saturated = False)
    atoms.rotate([1,0,0], np.pi/2, rotate_cell = True)
    atoms.rotate([0,0,1], -np.pi/2, rotate_cell = True)
    atoms.set_cell([20, 20, 10])
    atoms.center()
    del atoms[[2,3]]
    '''
    atoms   =   create_stucture(2, width, edge, key = 'top', a = bond)[0]
    
    atoms.set_cell([70, 70, 20])
    atoms.center()
    atoms.positions[:,2]    =   3.4
     
    h_t =   []
    for i in range(len(atoms)):
        if atoms[i].number == 1:
            h_t.append(i)
    
    del atoms[h_t]
    
    #view(atoms)
    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
    params['no_edge_neigh']     =   True
    add_KC                      =   KC_potential_p(params)
    
    
    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[0], edge, bond)
    atoms.translate(trans_vec)
    
    #plot_posits(atoms, edge, bond)
    #exit()
    init_pos    =   atoms.positions.copy()
    r_around    =   init_pos[1]
    
    thetas      =   np.linspace(0, np.pi/3, 61)
    n           =   15
    
    lat_vec1    =   np.array([3./2*bond,  np.sqrt(3)/2*bond, 0.])   
    lat_vec2    =   np.array([3./2*bond, -np.sqrt(3)/2*bond, 0.])
    
    for i, theta in enumerate(thetas):
        fname   =   path + 'corr_%s_theta=%.2f.data' %(edge, theta/(2*np.pi)*360)
        #if not os.path.isfile(fname): 
        print 'Calculating theta = %.2f' %(theta/(2*np.pi)*360)
        atoms.positions =   init_pos
        atoms.rotate([0,0,1], theta, center = r_around)
        
        R               =   np.array([[np.cos(theta), -np.sin(theta), 0.],
                                      [np.sin(theta),  np.cos(theta), 0.],
                                      [0., 0., 1.]])
        
        lat_vec_theta1  =   np.dot(R, lat_vec1.copy())
        lat_vec_theta2  =   np.dot(R, lat_vec2.copy())
                
        #trans_vec1      =   lat_vec_theta1.copy()/n
        trans_vec2      =   lat_vec_theta2.copy()/n
        
        data            =   np.zeros((n,n))
        #plot_posits(atoms, edge, bond, vecs =  [lat_vec_theta1, lat_vec_theta2])
        
        for k in range(n):
            atoms.positions =   init_pos
            atoms.translate(lat_vec_theta1*float(k)/n)
            #plot_posits(atoms, edge, bond, vecs =  [lat_vec_theta1, lat_vec_theta2])
            #print trans_vec1*float(k)/n, k, n, float(k)/n 
            
            for l in range(n):
                atoms.translate(trans_vec2)
                emin, hmin   =   get_optimal_h(atoms, len(atoms), dyn = False)
                #data[k,l,:]  =   [emin, hmin]   
                data[k,l]  =  emin #atoms.get_potential_energy()/len(atoms)
                
        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)
Пример #10
0
def plot_corr_surf(edge):
    
    params0 =   get_simulParams(edge)[-1]
    bond    =   params0['bond']
    
    lat_vec1    =   np.array([3./2*bond,  np.sqrt(3)/2*bond, 0.])   
    lat_vec2    =   np.array([3./2*bond, -np.sqrt(3)/2*bond, 0.])
    
    print lat_vec1
    
    for filen in os.listdir(path):
        if filen[:7] == 'corr_%s' %(edge):
            print filen.split('theta=')[-1].split('.data')[0]
            theta   =   float(filen.split('theta=')[-1].split('.data')[0])/360*2*np.pi
            data    =   np.loadtxt(path + filen)
            data   -=   np.min(data)
            emax    =   np.max(data)
            n,m     =   data.shape
            
            R       =   np.array([[np.cos(theta), -np.sin(theta), 0.],
                                  [np.sin(theta),  np.cos(theta), 0.],
                                  [0., 0., 1.]])
        
            lat_vec_theta1  =   np.dot(R, lat_vec1.copy())
            lat_vec_theta2  =   np.dot(R, lat_vec2.copy())
            X   =   np.zeros((n,m))
            Y   =   np.zeros((n,m))
            Z   =   np.zeros((n,m))
            
            for i in range(n):
                for j in range(m):
                    x,y,_   =   i*lat_vec_theta1/n + j*lat_vec_theta2/n
                    X[i,j]  =   x
                    Y[i,j]  =   y
                    Z[i,j]  =   data[i,j]*1000 #t get meV
    
            origin = 'lower'
            
            xmin, xmax, Dx  =   np.min(X), np.max(X), np.max(X) - np.min(X)
            ymin, ymax, Dy  =   np.min(Y), np.max(Y), np.max(Y) - np.min(Y)
            plt.figure(figsize=(8,6), dpi=80, facecolor='w', edgecolor='k')
            
            plt.arrow(xmin, ymin, 1, .0)
            plt.arrow(xmin, ymin, 1*np.cos(theta), 1*np.sin(theta))
            
            plt.text(xmin - .05*Dx*np.sin(theta), ymin + Dy*(.05 + .05*np.cos(theta)), 'ac-edge of top', rotation=theta/(2*np.pi)*360)
            plt.text(xmin, ymin - .05*Dy, 'ac-edge of bottom')
            CS = plt.contourf(X, Y, Z, 100, # [-1, -0.1, 0, 0.1],
                #alpha=0.5,
                cmap=plt.cm.cool,
                origin=origin)
            
            print theta
            plt.axis('off')
            plt.axis('equal')
            plt.title('Theta = %.1f deg' %(theta/(2*np.pi)*360))
            cbar = plt.colorbar(CS)
            cbar.ax.set_ylabel('corrugation meV/atom')
            plt.show()
            
    '''