Advertisement
Guest User

Untitled

a guest
Sep 20th, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #this program will calculate the Madelung constant for sodium chloride.
  2. #sodium atoms will be located at positions where i+j+k is even
  3. #chlorine atoms will be located at positions where i+j+k is odd
  4. #i,j,k are unit vectors in the x,y,z directions
  5.  
  6. from math import exp, log, sqrt, cos, sin, tan, pi
  7.  
  8. sqrt(((i*a)**2)+((j*a)**2)+((k*a)**2))=a*sqrt((i**2)+(j**2)+(k**2))
  9. q=1
  10. e=exp(1)
  11. eo=8.854187817*10**-12
  12.  
  13. i=float(input("Please enter the x coordinate of the atom:"))
  14. j=float(input("Please enter the y coordinate of the atom:"))
  15. k=float(input("Please enter the z coordinate of the atom:"))
  16. a=float(input("Please enter the spacing of atoms on the lattice:"))
  17. Li=float(input("Please enter the number of atoms in the positive x direction with respect to the atom:"))
  18. Lj=float(input("Please enter the number of atoms in the positive y direction with respect to the atom:"))
  19. Lk=float(input("Please enter the number of atoms in the positive z direction with respect to the atom:"))
  20.  
  21. if (i+j+k)%2==0:
  22. V[i,j,k]=(e/(4*pi*eo*a*sqrt((i**2)+(j**2)+(k**2))))
  23. else
  24. V[i,j,k]=-(e/(4*pi*eo*a*sqrt((i**2)+(j**2)+(k**2))))
  25.  
  26. position=[i,j,k]
  27. L=[i,j,k]+[Li,Lj,Lk]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement