## Code last bits

## Code last bits

(OP)

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 '

]

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 '

]

## RE: Code last bits

## CODE

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.

## RE: Code last bits

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

## RE: Code last bits

## CODE

## CODE

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.

## RE: Code last bits

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

Regards

Lehloks