Exemplo n.º 1
0
user_input = raw_input('Enter the number of random Q-points you have\n')
try:
    nbQ = int(user_input)
except ValueError:
    raise Exception('The value you enter is not an integer!')

# Get the path of the DDB files from user
user_input = raw_input(
    'Enter the name of the %s DDB files separated by a space\n' % nbQ)
if len(user_input.split()) != nbQ:
    raise Exception("You sould provide %s DDB files" % nbQ)
else:
    DDB_files = user_input.split()

# Test if the first file is at the Gamma point
DDBtmp = system(directory='.', filename=DDB_files[0])
if N.allclose(DDBtmp.iqpt, [0.0, 0.0, 0.0]) == False:
    raise Exception('The first Q-point is not Gamma!')

# Choose a k-point in the list below:
print 'Choose a k-point number in the list below for A_nk(omega,T)\n'
for ii in N.arange(DDBtmp.nkpt):
    print '%s) %s' % (ii, DDBtmp.kpt[ii, :])
user_input = raw_input('Enter the number of the k-point you want to analyse\n')
try:
    kpt = N.int(user_input)
except ValueError:
    raise Exception('The value you enter is not an integer!')

# Take the EIG at Gamma
user_input = raw_input(
Exemplo n.º 2
0
  _____  _       _          ______ _____        ____   _____ 
 |  __ \| |     | |        |  ____|  __ \      |  _ \ / ____|
 | |__) | | ___ | |_ ______| |__  | |__) |_____| |_) | (___  
 |  ___/| |/ _ \| __|______|  __| |  ___/______|  _ < \___ \ 
 | |    | | (_) | |_       | |____| |          | |_) |____) |
 |_|    |_|\___/ \__|      |______|_|          |____/|_____/
"""
print """ 
This script allows you to plot an electronic bandstructure from en _EP.nc 
file. If you computed the file including lifetime you can also plot 
"fat-band".
"""
# Read the input file
user_input = raw_input('Enter name of the _EP.nc file\n')
EP_file = user_input.strip()
EP = system(directory='.', filename=EP_file)

gprimd = inv(EP.rprimd)
full_kpt = N.matrix(EP.kpt) * gprimd
#print full_kpt

special = find_special_kpt(EP.kpt)

print "The special k-points are:"
for ikpt in N.arange(len(special.special_kpoints)):
    print str(special.special_kpoints[ikpt])
user_input = raw_input('Enter the name of the ' +
                       str(len(special.special_kpoints)) +
                       ' special k-points \n')

special_name = user_input.split()
Exemplo n.º 3
0
def FanDDW(arguments):
  wtq,eigq_files,DDB_files,EIGR2D_files,FAN_files = arguments
  DDB = system()
  FANterm = system()
  EIGR2D = system()
  eigq = system()
  DDB.__init__(directory='.',filename=DDB_files)
  tot_corr = N.zeros((len(freq)),dtype=complex)
  self_energy = N.zeros((len(freq)),dtype=complex)
  spectral = N.zeros((len(freq)))


# Calcul of gprimd from rprimd
  rprimd = DDB.rprim*DDB.acell
  gprimd = N.linalg.inv(N.matrix(rprimd))

# Transform from 2nd-order matrix (non-cartesian coordinates, 
# masses not included, asr not included ) from DDB to
# dynamical matrix, in cartesian coordinates, asr not imposed.
  IFC_cart = N.zeros((3,DDB.natom,3,DDB.natom),dtype=complex)
  for ii in N.arange(DDB.natom):
    for jj in N.arange(DDB.natom):
      for dir1 in N.arange(3):
        for dir2 in N.arange(3):
          for dir3 in N.arange(3):
            for dir4 in N.arange(3):
              IFC_cart[dir1,ii,dir2,jj] += gprimd[dir1,dir3]*DDB.IFC[dir3,ii,dir4,jj] \
            *gprimd[dir2,dir4]

# Reduce the 4 dimensional IFC_cart matrice to 2 dimensional Dynamical matrice.
  ipert1 = 0
  Dyn_mat = N.zeros((3*DDB.natom,3*DDB.natom),dtype=complex)
  while ipert1 < 3*DDB.natom:
    for ii in N.arange(DDB.natom):
      for dir1 in N.arange(3):
        ipert2 = 0
        while ipert2 < 3*DDB.natom:
          for jj in N.arange(DDB.natom):
            for dir2 in N.arange(3):
              Dyn_mat[ipert1,ipert2] = IFC_cart[dir1,ii,dir2,jj]
              ipert2 += 1
        ipert1 += 1

# Hermitianize the dynamical matrix
  dynmat = N.matrix(Dyn_mat)
  dynmat = 0.5*(dynmat + dynmat.transpose().conjugate())

# Solve the eigenvalue problem with linear algebra (Diagonalize the matrix)
  [eigval,eigvect]=N.linalg.eigh(Dyn_mat)

# Orthonormality relation 
  eigvect = (eigvect)*N.sqrt(5.4857990965007152E-4/float(DDB.amu[0]))

# Phonon frequency (5.4857990946E-4 = 1 au of electron mass)
  omega = N.sqrt((eigval*5.4857990965007152E-4)/float(DDB.amu[0]))

# Now read the EIGq, EIGR2D and FAN   
  eigq.__init__(directory='.',filename=eigq_files)
  EIGR2D.__init__(directory='.',filename=EIGR2D_files)
  FANterm.__init__(directory='.',filename=FAN_files)

# Compute the displacement = eigenvectors of the DDB. 
# Due to metric problem in reduce coordinate we have to work in cartesian
# but then go back to reduce because our EIGR2D matrix elements are in reduced coord.
  displ_FAN =  N.zeros((3,3),dtype=complex)
  displ_DDW =  N.zeros((3,3),dtype=complex)
  fan_add = N.zeros((len(freq)),dtype=complex)
  fan_corr = N.zeros((),dtype=complex)
  ddw_corr = N.zeros((),dtype=complex)

  for imode in N.arange(3*EIGR2D.natom): #Loop on perturbation (6 for 2 atoms)
    if omega[imode].real > tol6:
      for iatom1 in N.arange(EIGR2D.natom):
        for iatom2 in N.arange(EIGR2D.natom):
          for idir1 in N.arange(0,3):
            for idir2 in N.arange(0,3):
              displ_FAN[idir1,idir2] = eigvect[3*iatom2+idir2,imode].conj()\
                 *eigvect[3*iatom1+idir1,imode]/(2.0*omega[imode].real)
              displ_DDW[idir1,idir2] = (eigvect[3*iatom2+idir2,imode].conj()\
                 *eigvect[3*iatom2+idir1,imode]+eigvect[3*iatom1+idir2,imode].conj()\
                 *eigvect[3*iatom1+idir1,imode])/(4.0*omega[imode].real)
          # Now switch to reduced coordinates in 2 steps (more efficient)
          tmp_displ_FAN = N.zeros((3,3),dtype=complex)
          tmp_displ_DDW = N.zeros((3,3),dtype=complex)
          for idir1 in N.arange(3):
            for idir2 in N.arange(3):
              tmp_displ_FAN[:,idir1] = tmp_displ_FAN[:,idir1]+displ_FAN[:,idir2]*gprimd[idir2,idir1]
              tmp_displ_DDW[:,idir1] = tmp_displ_DDW[:,idir1]+displ_DDW[:,idir2]*gprimd[idir2,idir1]
          displ_red_FAN = N.zeros((3,3),dtype=complex)
          displ_red_DDW = N.zeros((3,3),dtype=complex)
          for idir1 in N.arange(3):
            for idir2 in N.arange(3):
              displ_red_FAN[idir1,:] = displ_red_FAN[idir1,:] + tmp_displ_FAN[idir2,:]*gprimd[idir2,idir1]
              displ_red_DDW[idir1,:] = displ_red_DDW[idir1,:] + tmp_displ_DDW[idir2,:]*gprimd[idir2,idir1]
          # Now compute the T=0 shift due to this q point
          for idir1 in N.arange(3):
            for idir2 in N.arange(3):
              fan_corr += EIGR2D.EIG2D[kpt,band-1,idir1,iatom1,idir2,iatom2]*\
                  displ_red_FAN[idir1,idir2]
              ddw_corr += ddw_save[idir1,iatom1,idir2,iatom2]*\
                  displ_red_DDW[idir1,idir2]
      if temperature < tol6:
        bose = 0
      else:
        bose = 1.0/(N.exp(omega[imode].real/(kb_HaK*temperature))-1)
      
      fan_corr = fan_corr*(2*bose+1.0)
      ddw_corr = ddw_corr*(2*bose+1.0)
      for jband in N.arange(EIGR2D.nband):
        index = 0
        for ifreq in freq:
          delta_E = ifreq - eigq.EIG[0,ikpt,jband] + smearing*1j
          fan_add[index] = fan_add[index] + FANterm.FAN[kpt,band-1,imode,jband]*(\
                                  (bose+0.5)*(2*delta_E/(delta_E**2-(omega[imode].real)**2)) \
                                - (1-EIGR2D.occ[iband])*(omega[imode].real/(delta_E**2-(omega[imode].real)**2))\
                                 -(bose+0.5)*2/delta_E)/(2.0*omega[imode].real)
          index += 1

  tot_corr[:] = (fan_corr+ddw_corr+fan_add[:])*wtq
  return tot_corr
Exemplo n.º 4
0
try:
  nbQ = int(user_input)
except ValueError:
  raise Exception('The value you enter is not an integer!')

# Get the path of the DDB files from user
DDB_files = []
for ii in N.arange(nbQ):
  user_input = raw_input('Enter the name of the %s DDB file\n' %ii)
  if len(user_input.split()) != 1:
    raise Exception("You should provide only 1 file")
  else: # Append and TRIM the input string with STRIP
    DDB_files.append(user_input.strip(' \t\n\r'))

# Test if the first file is at the Gamma point
DDBtmp = system(directory='.',filename=DDB_files[0])
if N.allclose(DDBtmp.iqpt,[0.0,0.0,0.0]) == False:
  raise Exception('The first Q-point is not Gamma!')

# Get the path of the eigq files from user
eigq_files = []
for ii in N.arange(nbQ):
  user_input = raw_input('Enter the name of the %s eigq file\n' %ii)
  if len(user_input.split()) != 1:
    raise Exception("You should provide only 1 file")
  else:
    eigq_files.append(user_input.strip(' \t\n\r'))

# Get the path of the EIGR2D files from user
EIGR2D_files = []
for ii in N.arange(nbQ):
Exemplo n.º 5
0
# Get the nb of random Q-points from user 
user_input = raw_input('Enter the number of random Q-points you have\n')
try:
  nbQ = int(user_input)
except ValueError:
  raise Exception('The value you enter is not an integer!')

# Get the path of the DDB files from user
user_input = raw_input('Enter the name of the %s DDB files separated by a space\n' %nbQ)
if len(user_input.split()) != nbQ:
  raise Exception("You sould provide %s DDB files" %nbQ)
else:
  DDB_files = user_input.split()

# Test if the first file is at the Gamma point
DDBtmp = system(directory='.',filename=DDB_files[0])
if N.allclose(DDBtmp.iqpt,[0.0,0.0,0.0]) == False:
  raise Exception('The first Q-point is not Gamma!')

# Choose a k-point in the list below:
print 'Choose a k-point number in the list below for A_nk(omega,T)\n'
for ii in N.arange(DDBtmp.nkpt):
  print '%s) %s' % (ii,DDBtmp.kpt[ii,:])
user_input = raw_input('Enter the number of the k-point you want to analyse\n')
try:
  kpt = N.int(user_input)
except ValueError:
  raise Exception('The value you enter is not an integer!')

# Get the path of the eigq files from user
user_input = raw_input('Enter the name of the %s eigq files separated by a space\n' %nbQ)