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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code last bits

Status
Not open for further replies.

lehloks

Programmer
Jul 12, 2013
40
0
0
ZA
Dear Forum users

I have this piece of code which calculate coordination numbers around a specific atom. The code below works well to calculate the coordination numbers around Si and Al atoms. Now I want to increase number of atoms ,for example at Ca and Mg.then from there I want to work out this relationship: when an oxygen is bridging, does it form a Si-O-Si, Al-O-Si or Al-O-Al linkage and also establish the number of oxygens involved in bonding. Any idea how can I implement this? I am able to calculate for instance the Si-O or Al-O, but how do I include the third atom to complete the bonding as shown above.

Your help will be much appreciated.


[ atname(1) = 'Si'
atname(2) = 'Al'
atname(3) = 'O'
shell(1) = 2.275d0
shell(2) = 2.475d0
write(9,*)' Start Frame ',iconf,atname(1),atname(3)
do i = 1,natms
if (atmnam(i) .eq. atname(1)) then
do j = 1,natms
if (atmnam(j) .eq. atname(3)) then
if (d(i,j) .le. shell(1)) then
write(9,*)i,j,d(i,j)
nbl(i,j) = 1
nb(i)=nb(i)+1
endif
endif
enddo
endif
enddo
write(9,*)' End Frame '

write(9,*)' Start Frame ',iconf,atname(2),atname(3)
do i = 1,natms
if (atmnam(i) .eq. atname(2)) then
do j = 1,natms
if (atmnam(j) .eq. atname(3)) then
if (d(i,j) .le. shell(2)) then
write(9,*)i,j,d(i,j)
nbl(i,j) = 1
c nb(i)=nb(i)+1
endif
endif
enddo
endif
enddo
write(9,*)' End Frame '
]
 
If you jam your loops, what you will get is
Code:
integer, parameter:: nat = 3
character(len=2):: atname(nat)
...
do k = 1, nat - 1
   write(9,*)' Start Frame ',iconf,atname(k),atname(nat)
   do i = 1,natms
      if (atmnam(i) .eq. atname(k)) then
         do j = 1,natms
            if (atmnam(j) .eq. atname(k)) then
               if (d(i,j) .le. shell(k)) then
                  write(9,*)i,j,d(i,j)
                  nbl(i,j) = 1
                  if (k .eq. 1) nb(i)=nb(i)+1
               endif
            endif
         enddo
      endif
   enddo
   write(9,*)' End Frame '
enddo
Try that first and see if the results are the same as what you have now.

If they are the same, if you then increase nat and the sizes of the arrays of the other relevant variables like atname, d, shell, nbl you may be able to achieve what you wish.
 
Thanks a lot XWB

I this think this is an elegant way of doing it,I assume atname(k),atname(nat) are general statements I thing I should replace them with atname(1) = 'Si' as an example and shell k replace it with shell 1 ,correct me if im wrong. Then that will take care of bonding between atom 1 and atom 2, then I would need to add statement for atom2 linked to atom 2 and atom 3 must also fall within the shell of atom 2. Can let me know how do I do this ?


Kind regards
Lehloks
 
Sorry, error in the coding

Code:
          if (atmnam(j) .eq. atname(k)) then
Should read
Code:
          if (atmnam(j) .eq. atname(nat)) then
In the 2nd loop, it goes through atname(1) and atname(2). The third loop should compare it with atname(3).

My Chemistry is zilch - I last looked at this topic 40 years ago and I can't remember anything about it. In simple minded computing terms, it is just a question of permutations and combinations. For 4 items, do you want to compute just

1-4, 2-4, 3-4 or
1-2, 2-3, 2-4, 3-4 or
something else

Basically what pattern of combinations do you want when there are more than 3 items in atname. Could you work out what patterns you want to see when there are 5 items in the list.
 
Hi XWB

I want this pattern 1-4. Let me try it.

Regards
Lehloks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top