Fortran – Programming Primitive Vectors of Reciprocal Lattice

Suppose \vec{a_{1}}, \vec{a_{2}} and \vec{a_{3}} are the 3 primitive vectors of a direct lattice. The primitive vectors of the reciprocal lattice are given by

\vec{b_{1}}=2\pi\frac{\vec{a_{2}}\times \vec{a_{3}}}{\Omega_{a}}

\vec{b_{2}}=2\pi\frac{\vec{a_{3}}\times \vec{a_{1}}}{\Omega_{a}}

\vec{b_{3}}=2\pi\frac{\vec{a_{1}}\times \vec{a_{2}}}{\Omega_{a}}

, where \Omega_{a} is the volume of the primitive cell.

Fortran 90 code:

program main
  implicit none
  real(8), parameter :: PI=4.D0*datan(1.D0)
  real(8),dimension(3) :: a1,a2,a3,b1,b2,b3
  real(8),dimension(3) :: a,b
  real(8) :: Va

  print *,"Enter x, y, z coordinates of a1:"
  print *,"Enter x, y, z coordinates of a2:"
  print *,"Enter x, y, z coordinates of a3:"
  Va = dot_product(a1,cross_product(a2,a3))
  b1 = cross_product(a2,a3)*2*PI/Va
  b2 = cross_product(a3,a1)*2*PI/Va
  b3 = cross_product(a1,a2)*2*PI/Va
  print *,"b1(1)=",b1(1),"b1(2)=",b1(2),"b1(3)=",b1(3)
  print *,"b2(1)=",b2(1),"b2(2)=",b2(2),"b2(3)=",b2(3)
  print *,"b3(1)=",b3(1),"b3(2)=",b2(2),"b3(3)=",b2(3)
  print *,"Volume of Unit Cell=",Va
  function cross_product(x,y)
    implicit none
    real(8),dimension(3) :: x, y, z, cross_product
  end function cross_product

  real(8) function dot_product(x,y)
    implicit none
    real(8),dimension(3) :: x,y
    dot_product = x(1)*y(1)+x(2)*y(2)+x(3)*y(3)
  end function dot_product
end program main


The user inputs the 3 direct lattice vectors, and the program will print the 3 reciprocal lattice vectors and the volume of the direct lattice.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s