[go: up one dir, main page]

Menu

[r47]: / Utils / faux2towhee.F  Maximize  Restore  History

Download this file

246 lines (221 with data), 8.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
c ******************************************************************
c * MCCCS - Towhee: A Monte Carlo molecular simulation program *
c * Copyright (C) 2004 Marcus G. Martin *
c * see the file license.gpl for the full license information *
c * *
c * This program is free software; you can redistribute it and/or *
c * modify it under the terms of the GNU General Public License *
c * as published by the Free Software Foundation; either version 2 *
c * of the License, or (at your option) any later version. *
c * *
c * This program is distributed in the hope that it will be useful,*
c * but WITHOUT ANY WARRANTY; without even the implied warranty of *
c * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
c * GNU General Public License for more details. *
c * *
c * You should have received a copy of the GNU General Public *
c * License along with this program; if not, write to the Free *
c * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,*
c * MA 02111-1307, USA. *
c ******************************************************************
program faux2towhee
c *****************************************************************
c * converts the files from David Faux into a format for towhee *
c * originally written 02-09-2001 by M.G. Martin *
c * last modified 06-28-2004 by M.G. Martin *
c *****************************************************************
implicit none
integer natoms,nangles,nnbond,nntype
parameter (nnbond = 4, natoms = 672, nangles = 1152,nntype=10)
logical lfound
integer invib,ijvib,inpstyle
dimension invib(natoms),ijvib(natoms,nnbond)
integer inben,ijben1,ijben2
dimension inben(natoms)
dimension ijben1(natoms,nnbond**2),ijben2(natoms,nnbond**2)
integer type
dimension type(natoms)
integer ivib,ibend,iuone,iutwo,iuthree
double precision qqu,xpos,ypos,zpos,xadjust,yadjust,zadjust
dimension qqu(natoms),xpos(natoms),ypos(natoms),zpos(natoms)
integer count
dimension count(4)
integer iatom,iangle,iend,idum,ispot,triplet
dimension triplet(nangles,3)
character*4 cdum
character*6 name
dimension name(nntype)
c --- here we set the inpstyle that we wish to generate
inpstyle = 2
open(20,file='faux_4a.atoms',form='formatted')
do iatom = 1,natoms
read(20,*) idum,idum,type(iatom),qqu(iatom),xpos(iatom)
& ,ypos(iatom),zpos(iatom)
enddo
close(20)
open(21,file='faux_4a.ang',form='formatted')
c --- skip the first 10 lines
do iangle = 1,10
read(21,*)
enddo
do iangle = 1,nangles
read(21,*) cdum,(triplet(iangle,ispot),ispot=1,3)
enddo
close(21)
c --- initialize arrays
do iatom = 1,natoms
invib(iatom) = 0
inben(iatom) = 0
enddo
c --- find vibrations and bends
do iangle = 1,nangles
do iend = 1,2
if ( iend .eq. 1 ) then
iuone = triplet(iangle,1)
iuthree = triplet(iangle,3)
else
iuone = triplet(iangle,3)
iuthree = triplet(iangle,1)
endif
iutwo = triplet(iangle,2)
c --- check the iuone list for bonds
lfound = .false.
do ivib = 1,invib(iuone)
if ( ijvib(iuone,ivib) .eq. iutwo ) lfound = .true.
enddo
if ( .not. lfound ) then
c --- add this to the vibration list
invib(iuone) = invib(iuone) + 1
ijvib(iuone,invib(iuone)) = iutwo
endif
c --- check the iutwo list for bonds
lfound = .false.
do ivib = 1,invib(iutwo)
if ( ijvib(iutwo,ivib) .eq. iuone ) lfound = .true.
enddo
if ( .not. lfound ) then
c --- add this to the vibration list
invib(iutwo) = invib(iutwo) + 1
ijvib(iutwo,invib(iutwo)) = iuone
endif
c --- check the iuone list for angles
lfound = .false.
do ibend = 1,inben(iuone)
if ( ijben1(iuone,ibend) .eq. iutwo .and.
& ijben2(iuone,ibend) .eq. iuthree ) lfound=.true.
enddo
if ( .not. lfound ) then
c --- add this to the angle list
inben(iuone) = inben(iuone) + 1
ijben1(iuone,inben(iuone)) = iutwo
ijben2(iuone,inben(iuone)) = iuthree
endif
c --- check the iuthree list for angles
lfound = .false.
do ibend = 1,inben(iuthree)
if ( ijben1(iuthree,ibend) .eq. iutwo .and.
& ijben2(iuthree,ibend) .eq. iuone ) lfound=.true.
enddo
if ( .not. lfound ) then
c --- add this to the angle list
inben(iuthree) = inben(iuthree) + 1
ijben1(iuthree,inben(iuthree)) = iutwo
ijben2(iuthree,inben(iuthree)) = iuone
endif
enddo
enddo
c --- initialize counter
do iend = 1,4
count(iend) = 0
enddo
c --- setup type converter
name(1) = 'OZ'
name(2) = 'Si'
name(3) = 'Al'
name(4) = 'Na'
c --- convert atom types
do iatom = 1,natoms
if ( type(iatom) .eq. 10 ) then
type(iatom) = 1
count(1) = count(1) + 1
elseif ( type(iatom) .eq. 8 ) then
type(iatom) = 2
count(2) = count(2) + 1
elseif ( type(iatom) .eq. 9 ) then
type(iatom) = 3
count(3) = count(3) + 1
elseif ( type(iatom) .eq. 11 ) then
type(iatom) = 4
count(4) = count(4) + 1
else
write(6,*) 'unknown atom type ',iatom,type(iatom)
endif
enddo
do iend = 1,4
write(6,*) 'atom count',iend,count(iend)
enddo
c --- output all of the information for towhee
open(3,file='towhee_altinp',form='formatted')
write(3,*) 'inpstyle'
write(3,*) inpstyle
write(3,*) 'nunit'
write(3,*) natoms
write(3,*) 'nmaxcbmc'
write(3,*) natoms
write(3,*) 'lelect'
write(3,*) 'T'
if ( inpstyle .eq. 0 ) then
write(3,*) 'lpdb'
write(3,*) 'F'
do iatom = 1,natoms
write(3,*) 'unit ntype qqatom'
write(3,*) iatom,type(iatom),qqu(iatom)
write(3,*) 'vibration'
write(3,*) invib(iatom)
do ivib = 1,invib(iatom)
write(3,*) ijvib(iatom,ivib),49
enddo
write(3,*) 'bending'
write(3,*) inben(iatom)
do ibend = 1,inben(iatom)
write(3,*) ijben1(iatom,ibend),ijben2(iatom,ibend),48
enddo
write(3,*) 'torsion'
write(3,*) 0
write(3,*) 'angle-angle'
write(3,*) 0
write(3,*) 'improper torsion'
write(3,*) 0
enddo
elseif ( inpstyle .eq. 2 ) then
write(3,*) 'forcefield'
write(3,*) 'Faux'
do iatom = 1,natoms
write(3,*) 'unit ntype qqatom'
write(3,*) iatom,' ',char(39),name(type(iatom)),char(39)
& ,' ',qqu(iatom)
write(3,*) 'vibration'
write(3,*) invib(iatom)
if ( invib(iatom) .ne. 0 ) then
write(3,*) (ijvib(iatom,ivib),ivib=1,invib(iatom))
endif
write(3,*) 'improper torsion'
write(3,*) 0
enddo
else
write(6,*) 'invalid inpstyle ',inpstyle
stop
endif
c --- close the output file
close(3)
xadjust = 24.555d0/2.0d0
yadjust = 24.555d0/2.0d0
zadjust = 24.555d0/2.0d0
c --- output all of the information for towhee_coords
open(9,file='towhee_coords',form='formatted')
do iatom = 1,natoms
write(9,*) xpos(iatom)+xadjust
& ,ypos(iatom)+yadjust,zpos(iatom)+zadjust,qqu(iatom)
enddo
close(9)
end