Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

periodic boundary conditions (PBC) using cshift function 1

Status
Not open for further replies.

ignacio_b

Technical User
Jul 29, 2019
10
GB
Dear all,

I have written a code for PBC for a cubic system, however, I need to implement PBC for a crystal lattice with different geometry (not cubic). I read that the cshift function might help, however, i feel lost regarding how to implement PBC using cshift function. My code for the cubic system is the following:

do i=1,4 !Ti - 4 atomos
n=0
do j=5,12
if (i.ne.j) then
dx=crd(1,i)-crd(1,j)
if (dx.gt.sx/2.0) dx=dx-sx
if (dx.lt.-sx/2.0) dx=dx+sx

dy=crd(2,i)-crd(2,j)
if (dy.gt.sy/2.0) dy=dy-sy
if (dy.lt.-sy/2.0) dy=dy+sy

dz=crd(3,i)-crd(3,j)
if (dz.gt.sz/2.0) dz=dz-sz
if (dz.lt.-sz/2.0) dz=dz+sz

dist=sqrt(dx**2+dy**2+dz**2)

if (dist.lt.3.2) then
! bv=exp((1.985-dist)/0.37)
! sum_bv_moc(i)=sum_bv_moc(i)+bv
n=n+1
!write(111,*)i,(j-32)
endif

endif
endif
enddo
enddo stop

These are the lattice parameters for the required geometry:

a = 6.14400 Å α = 90.0000°
b = 6.14400 Å β = 90.0000°
c = 18.72999 Å γ =120.0000°


I would like to know if someone has an idea of how to use cshift function and how implement it for PBC...


Many thanks and kind regards,


Ignacio Borge
 
I can tell you about cshift but I have no idea about crystal lattices and PBCs.

cshift is a circular shift. This is an example in one dimension. If you want 2 dimensions, look at
Code:
program test_cshift
    integer, dimension(10) :: b
    b = (/ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9/)
    ! print the array
    print '(10I3)', b

    ! shift left 2.  The 0 and 1 will be at the back, 2 will be in front
    !    0 1 2 3 4 5 6 7 8 9
    ! => 2 3 4 5 6 7 8 9 0 1
    b = cshift(b, 2)
    print '(10I3)', b

    ! shift right 3.  The 9 will be in front, followed by 0 and 2
    !    2 3 4 5 6 7 8 9 0 1
    ! => 9 0 1 2 3 4 5 6 7 8
    b = cshift(b, -3)
    print '(10I3)', b
end program
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top