Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #this program will calculate the Madelung constant for sodium chloride.
- #sodium atoms will be located at positions where i+j+k is even
- #chlorine atoms will be located at positions where i+j+k is odd
- #i,j,k are unit vectors in the x,y,z directions
- from math import exp, log, sqrt, cos, sin, tan, pi
- sqrt(((i*a)**2)+((j*a)**2)+((k*a)**2))=a*sqrt((i**2)+(j**2)+(k**2))
- q=1
- e=exp(1)
- eo=8.854187817*10**-12
- i=float(input("Please enter the x coordinate of the atom:"))
- j=float(input("Please enter the y coordinate of the atom:"))
- k=float(input("Please enter the z coordinate of the atom:"))
- a=float(input("Please enter the spacing of atoms on the lattice:"))
- Li=float(input("Please enter the number of atoms in the positive x direction with respect to the atom:"))
- Lj=float(input("Please enter the number of atoms in the positive y direction with respect to the atom:"))
- Lk=float(input("Please enter the number of atoms in the positive z direction with respect to the atom:"))
- if (i+j+k)%2==0:
- V[i,j,k]=(e/(4*pi*eo*a*sqrt((i**2)+(j**2)+(k**2))))
- else
- V[i,j,k]=-(e/(4*pi*eo*a*sqrt((i**2)+(j**2)+(k**2))))
- position=[i,j,k]
- L=[i,j,k]+[Li,Lj,Lk]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement