Advertisement
Guest User

Untitled

a guest
Apr 29th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module real_space_moire
  2.      contains
  3.      subroutine unit_cell_creation()
  4.             implicit none
  5.             double precision :: d1,d2,d
  6.             double precision, dimension(2) :: a1, a2,  unit_cell_position
  7.             integer :: unit_cell_ind1, unit_cell_ind2
  8.             double precision :: cutoff_radius_inner, cutoff_radius_outer, theta
  9.             double precision, dimension(2) :: tau_a, tau_b, pos1_long, pos2_long, U_j,  R_0, R_B1
  10.             integer :: pre_lattice_size
  11.             integer :: unit_cell_counter
  12.             double precision, allocatable :: uc_pos(:,:)
  13.             double precision, parameter :: pi=4.0d0*atan(1.0d0)
  14.        
  15.             cutoff_radius_inner=0.0d0
  16.             cutoff_radius_outer=100.0d0
  17.  
  18.             d1=1.42
  19.            
  20.             R_0 = 0.0d0
  21.             R_B1(1)=d1
  22.             R_B1(2)=0.0d0
  23.  
  24.             !creation of lattice
  25.  
  26.             a1(1)=0.0d0
  27.             a1(2)=d1*sqrt(3.0d0)
  28.  
  29.             a2(1)=(d1/2.0d0)*3.0d0
  30.             a2(2)=(-d1/2.0d0)*sqrt(3.0d0)
  31.  
  32.             pre_lattice_size=1000+INT(cutoff_radius_outer)
  33.             !cutoff_radius_inner = 0.00d0 !in Angst.
  34.             !cutoff_radius_outer = 200.0d0 !in Angst.
  35.        
  36.  
  37.             unit_cell_counter=0
  38.             !lattice generation
  39.             do unit_cell_ind1=-pre_lattice_size,pre_lattice_size
  40.             do unit_cell_ind2=-pre_lattice_size,pre_lattice_size
  41.        
  42.                 unit_cell_position(1) = unit_cell_ind1*a1(1)+unit_cell_ind2*a2(1)
  43.                 unit_cell_position(2) = unit_cell_ind1*a1(2)+unit_cell_ind2*a2(2)
  44.        
  45.                 if ( sqrt(unit_cell_position(1)**2.0d0 + unit_cell_position(2)**2.0d0) .GE. cutoff_radius_inner .AND. &
  46.                      sqrt(unit_cell_position(1)**2.0d0 + unit_cell_position(2)**2.0d0) .LE. cutoff_radius_outer   ) then
  47.                 unit_cell_counter=unit_cell_counter+1
  48.                 end if
  49.  
  50.             end do
  51.             end do
  52.  
  53.             !write(*,*) 'unit_cell_counter', unit_cell_counter
  54.             open (unit=10, file="atom_A.dat", recl=512)
  55.             open (unit=11, file="atom_B.dat", recl=512)
  56.             open (unit=12, file="atom_Ap.dat", recl=512)
  57.             open (unit=13, file="atom_Bp.dat", recl=512)
  58.             allocate( uc_pos(unit_cell_counter,2) )
  59.  
  60.             unit_cell_counter=1
  61.             do unit_cell_ind1=-pre_lattice_size,pre_lattice_size
  62.              do unit_cell_ind2=-pre_lattice_size,pre_lattice_size
  63.                 unit_cell_position(1) = unit_cell_ind1*a1(1)+unit_cell_ind2*a2(1)
  64.                 unit_cell_position(2) = unit_cell_ind1*a1(2)+unit_cell_ind2*a2(2)
  65.        
  66.        
  67.                 if ( sqrt(unit_cell_position(1)**2.0d0 + unit_cell_position(2)**2.0d0) .GE. cutoff_radius_inner .AND. &
  68.                   sqrt(unit_cell_position(1)**2.0d0 + unit_cell_position(2)**2.0d0) .LE. cutoff_radius_outer   ) then
  69.            
  70.                     uc_pos(unit_cell_counter,1)=unit_cell_position(1)
  71.                     uc_pos(unit_cell_counter,2)=unit_cell_position(2)
  72.  
  73.                     !atom A
  74.                     write(10,*) uc_pos(unit_cell_counter,1)+R_0(1), uc_pos(unit_cell_counter,2)+R_0(2), 0.0d0
  75.                     !atom B
  76.                     write(11,*) uc_pos(unit_cell_counter,1)+R_B1(1), uc_pos(unit_cell_counter,2)+R_B1(2), 0.0d0
  77.                    
  78.                     theta=0.3802512066 !60.0d0/360.0d0 * 2.0d0 *pi
  79.                     !atom A'
  80.                     write(12,*) cos(theta)*( uc_pos(unit_cell_counter,1)+R_0(1) -R_B1(1)) - sin(theta)*( uc_pos(unit_cell_counter,2)+R_0(2)- R_B1(2)), & ! x
  81.                                 sin(theta)*(uc_pos(unit_cell_counter,1) +R_0(1) -R_B1(1)) + cos(theta)*( uc_pos(unit_cell_counter,2)+R_0(2)- R_B1(2)), & ! y
  82.                                 -3.35d0 !z
  83.                     !atom B'
  84.                     write(13,*) cos(theta)*( uc_pos(unit_cell_counter,1) ) - sin(theta)* (uc_pos(unit_cell_counter,2)), & !x
  85.                                 sin(theta)*( uc_pos(unit_cell_counter,1) ) + cos(theta)* (uc_pos(unit_cell_counter,2)), & !y
  86.                                 -3.35d0 !z
  87.                     unit_cell_counter=unit_cell_counter+1
  88.                 end if
  89.  
  90.               end do
  91.             end do
  92.             close(10)
  93.             close(11)
  94.             close(12)
  95.             close(13)
  96.            
  97.             unit_cell_counter=unit_cell_counter-1
  98.         end subroutine unit_cell_creation
  99.        
  100.     end module real_space_moire
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement