×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

periodic boundary conditions (PBC) using cshift function

periodic boundary conditions (PBC) using cshift function

periodic boundary conditions (PBC) using cshift function

(OP)
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

RE: periodic boundary conditions (PBC) using cshift function

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 https://gcc.gnu.org/onlinedocs/gcc-4.6.1/gfortran/...

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 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close