1 |
#!@PERL_EXECUTABLE@ |
2 |
|
3 |
# program that builds water boxes |
4 |
|
5 |
# author = "Chris Fennell |
6 |
# version = "$Revision$" |
7 |
# date = "$Date$" |
8 |
# copyright = "Copyright (c) 2006 by the University of Notre Dame" |
9 |
# license = "OpenMD" |
10 |
|
11 |
use Getopt::Std; |
12 |
|
13 |
$tolerance = 1.0E-8; |
14 |
$mass = 2.99151E-23; # mass of H2O in grams |
15 |
$cm3ToAng3 = 1E24; # convert cm^3 to angstroms^3 |
16 |
$densityConvert = $mass*$cm3ToAng3; |
17 |
$lattice = 0; |
18 |
$nMol = 500; |
19 |
$density = 1.0; |
20 |
$doRandomize = 0; |
21 |
$cutoff = 9; |
22 |
$alpha = 0.18; |
23 |
$invalidWater = 0; |
24 |
$waterCase = -1; |
25 |
$nothingSelected = 1; |
26 |
|
27 |
# get our options |
28 |
getopts('hmrvd:l:n:o:w:x:y:z:'); |
29 |
|
30 |
# just to test opt_h |
31 |
$opt_h = "true" if $#ARGV >= 0; |
32 |
|
33 |
# our option output |
34 |
if ($opt_h){ |
35 |
print "waterBoxer: builds water boxes\n\n"; |
36 |
print "usage: waterBoxer [-hmrv] [-d density] [-l lattice] [-n # waters]\n"; |
37 |
print "\t[-o file name] [-w water name] \n\n"; |
38 |
print " -h : show this message\n"; |
39 |
print " -m : print out a water.md file (file with all water models)\n"; |
40 |
print " -r : randomize orientations\n"; |
41 |
print " -v : verbose output\n\n"; |
42 |
print " -d real : density in g/cm^3\n"; |
43 |
print " (default: 1)\n"; |
44 |
print " -l integer : 0 - face centered cubic, 1 - simple cubic\n"; |
45 |
print " (default: 0)\n"; |
46 |
print " -n integer : # of water molecules\n"; |
47 |
print " (default: 500)\n"; |
48 |
print " -o char : output file name\n"; |
49 |
print " (default: freshWater.md)\n"; |
50 |
print " -w char : name of the water stunt double\n"; |
51 |
print " (default: SPCE)\n"; |
52 |
print " -x real : dimension of the box along the x direction\n"; |
53 |
print " -y real : dimension of the box along the y direction\n"; |
54 |
print " -z real : dimension of the box along the z direction\n\n"; |
55 |
print "Note: you can only use values of x, y, or z that are smaller\n"; |
56 |
print " than the derived box length for a given density and\n"; |
57 |
print " number of molecules.\n\n"; |
58 |
print "Example:\n"; |
59 |
die " waterBoxer -d 0.997 -n 864 -w SSD_RF -o ssdrfWater.md\n"; |
60 |
} |
61 |
|
62 |
# set some variables to be used in the code |
63 |
if (defined($opt_o)){ |
64 |
$fileName = $opt_o; |
65 |
$nothingSelected = 0; |
66 |
} else { |
67 |
$fileName = 'freshWater.md'; |
68 |
} |
69 |
if ($opt_m){ |
70 |
die "Error: $fileName cannot be \"water.md\"\n Please choose a different name\n" if $fileName eq 'water.md'; |
71 |
$waterFileHandle = 'WATERMD'; |
72 |
$nothingSelected = 0; |
73 |
} else { |
74 |
$waterFileHandle = 'OUTFILE'; |
75 |
} |
76 |
if ($opt_r){ |
77 |
$doRandomize = $opt_r; |
78 |
$nothingSelected = 0; |
79 |
} |
80 |
|
81 |
if (defined($opt_d)){ |
82 |
$nothingSelected = 0; |
83 |
if ($opt_d =~ /^[0-9]/) { |
84 |
$density = $opt_d; |
85 |
} else { |
86 |
die "Error: the value for '-d' ($opt_d) is not a valid number\n Please choose a positive real # value\n"; |
87 |
} |
88 |
} |
89 |
if (defined($opt_w)){ |
90 |
$waterName = $opt_w; |
91 |
$nothingSelected = 0; |
92 |
} else { |
93 |
$waterName = 'SPCE'; |
94 |
} |
95 |
validateWater(); |
96 |
if ($invalidWater == 1){ |
97 |
print "Warning: \'$waterName\' is not a recognized water model name.\n"; |
98 |
print " Use the \'-m\' option to generate a \'water.md\' with the\n"; |
99 |
print " recognized water model geometries.\n\n"; |
100 |
} |
101 |
if ($waterName eq 'DPD') { |
102 |
# DPD waters are stand-ins for 4 water molecules |
103 |
$density = $density * 0.25; |
104 |
} |
105 |
if ($waterName eq 'CG2') { |
106 |
# CG2 waters are stand-ins for 2 water molecules |
107 |
$density = $density * 0.5; |
108 |
} |
109 |
|
110 |
if (defined($opt_l)){ |
111 |
$nothingSelected = 0; |
112 |
if ($opt_l =~ /^[0-9]/) { |
113 |
$lattice = $opt_l; |
114 |
if ($lattice != 0 && $lattice != 1){ |
115 |
die "Error: the '-l' value ($opt_l) is not a valid number\n Please choose 0 or 1\n"; |
116 |
} |
117 |
} else { |
118 |
die "Error: the '-l' value ($opt_l) is not a valid number\n Please choose 0 or 1\n"; |
119 |
} |
120 |
} |
121 |
if (defined($opt_n)){ |
122 |
$nothingSelected = 0; |
123 |
if ($opt_n =~ /^[0-9]/) { |
124 |
$nMol = $opt_n; |
125 |
} else { |
126 |
die "Error: the '-n' value ($opt_n) is not a valid number\n Please choose a non-negative integer\n"; |
127 |
} |
128 |
} |
129 |
if (defined($opt_x)){ |
130 |
$nothingSelected = 0; |
131 |
if ($opt_x =~ /^[0-9]/) { |
132 |
$boxx = $opt_x; |
133 |
} else { |
134 |
die "Error: the value for '-x' ($opt_x) is not a valid number\n Please choose a positive real # value\n"; |
135 |
} |
136 |
} |
137 |
if (defined($opt_y)){ |
138 |
$nothingSelected = 0; |
139 |
if ($opt_y =~ /^[0-9]/) { |
140 |
$boxy = $opt_y; |
141 |
} else { |
142 |
die "Error: the value for '-y' ($opt_y) is not a valid number\n Please choose a positive real # value\n"; |
143 |
} |
144 |
} |
145 |
if (defined($opt_z)){ |
146 |
$nothingSelected = 0; |
147 |
if ($opt_z =~ /^[0-9]/) { |
148 |
$boxz = $opt_z; |
149 |
} else { |
150 |
die "Error: the value for '-z' ($opt_z) is not a valid number\n Please choose a positive real # value\n"; |
151 |
} |
152 |
} |
153 |
|
154 |
|
155 |
# open the file writer |
156 |
open(OUTFILE, ">./$fileName") || die "Error: can't open file $fileName\n"; |
157 |
|
158 |
# check to set magic lattice numbers |
159 |
if ($lattice == 0){ |
160 |
$crystalNumReal = ($nMol/4.0)**(1.0/3.0); |
161 |
$crystalNum = int($crystalNumReal + $tolerance); |
162 |
$remainder = $crystalNumReal - $crystalNum; |
163 |
|
164 |
# if crystalNumReal wasn't an integer, we bump the crystal to the next |
165 |
# magic number |
166 |
if ($remainder > $tolerance){ |
167 |
$crystalNum = $crystalNum + 1; |
168 |
$newMol = 4 * $crystalNum**3; |
169 |
print "Warning: The number chosen ($nMol) failed to build a clean fcc lattice.\n"; |
170 |
print " The number of molecules has been increased to the next magic number ($newMol).\n\n"; |
171 |
$nMol = $newMol; |
172 |
} |
173 |
} elsif ($lattice == 1){ |
174 |
$crystalNumReal = ($nMol/1.0)**(1.0/3.0); |
175 |
$crystalNum = int($crystalNumReal + $tolerance); |
176 |
$remainder = $crystalNumReal - $crystalNum; |
177 |
|
178 |
# again, if crystalNumReal wasn't an integer, we bump the crystal to the next |
179 |
# magic number |
180 |
if ($remainder > $tolerance){ |
181 |
$crystalNum = $crystalNum + 1; |
182 |
$newMol = $crystalNum**3; |
183 |
print "Warning: The number chosen ($nMol) failed to build a clean simple cubic lattice.\n"; |
184 |
print " The number of molecules has been increased to the next magic number ($newMol).\n\n"; |
185 |
$nMol = $newMol; |
186 |
} |
187 |
} |
188 |
|
189 |
# now we can start building the crystals |
190 |
$boxLength = ($nMol*$densityConvert/$density)**(1.0/3.0); |
191 |
$cellLength = $boxLength / $crystalNum; |
192 |
|
193 |
if ($boxx != 0) { |
194 |
if ($boxLength < $boxx) { |
195 |
print "Computed box length is smaller than requested x axis. Use more\n"; |
196 |
die "molecules."; |
197 |
} |
198 |
} else { |
199 |
$boxx = $boxLength; |
200 |
} |
201 |
if ($boxy != 0) { |
202 |
if ($boxLength < $boxy) { |
203 |
print "Computed box length is smaller than requested y axis. Use more\n"; |
204 |
die "molecules."; |
205 |
} |
206 |
} else { |
207 |
$boxy = $boxLength; |
208 |
} |
209 |
if ($boxz != 0) { |
210 |
if ($boxLength < $boxz) { |
211 |
print "Computed box length is smaller than requested z axis. Use more\n"; |
212 |
die "molecules."; |
213 |
} |
214 |
} else { |
215 |
$boxz = $boxLength; |
216 |
} |
217 |
|
218 |
$nx = int($boxx / $cellLength); |
219 |
$ny = int($boxy / $cellLength); |
220 |
$nz = int($boxz / $cellLength); |
221 |
|
222 |
if ($lattice == 0) { |
223 |
$nMol = 4 * $nx * $ny * $nz; |
224 |
} else { |
225 |
$nMol = $nx * $ny * $nz; |
226 |
} |
227 |
|
228 |
$newDensity = $nMol * $densityConvert / ($boxx*$boxy*$boxz); |
229 |
|
230 |
if (abs($newDensity-$density) > $tolerance) { |
231 |
print "Resetting density to $newDensity to make chosen box sides work out\n"; |
232 |
} |
233 |
$cellLengthX = $boxx/$nx; |
234 |
$cellLengthY = $boxy/$ny; |
235 |
$cellLengthZ = $boxz/$nz; |
236 |
|
237 |
$cell2X = $cellLengthX*0.5; |
238 |
$cell2Y = $cellLengthY*0.5; |
239 |
$cell2Z = $cellLengthZ*0.5; |
240 |
|
241 |
if ($lattice == 0) { |
242 |
# build the unit cell |
243 |
# molecule 0 |
244 |
$xCorr[0] = 0.0; |
245 |
$yCorr[0] = 0.0; |
246 |
$zCorr[0] = 0.0; |
247 |
# molecule 1 |
248 |
$xCorr[1] = 0.0; |
249 |
$yCorr[1] = $cell2Y; |
250 |
$zCorr[1] = $cell2Z; |
251 |
# molecule 2 |
252 |
$xCorr[2] = $cell2X; |
253 |
$yCorr[2] = $cell2Y; |
254 |
$zCorr[2] = 0.0; |
255 |
# molecule 3 |
256 |
$xCorr[3] = $cell2X; |
257 |
$yCorr[3] = 0.0; |
258 |
$zCorr[3] = $cell2Z; |
259 |
# assemble the lattice |
260 |
$counter = 0; |
261 |
for ($z = 0; $z < $nz; $z++) { |
262 |
for ($y = 0; $y < $ny; $y++) { |
263 |
for ($x = 0; $x < $nx; $x++) { |
264 |
for ($uc = 0; $uc < 4; $uc++) { |
265 |
$xCorr[$uc+$counter] = $xCorr[$uc] + $cellLengthX*$x; |
266 |
$yCorr[$uc+$counter] = $yCorr[$uc] + $cellLengthY*$y; |
267 |
$zCorr[$uc+$counter] = $zCorr[$uc] + $cellLengthZ*$z; |
268 |
} |
269 |
$counter = $counter + 4; |
270 |
} |
271 |
} |
272 |
} |
273 |
|
274 |
} elsif ($lattice == 1) { |
275 |
# build the unit cell |
276 |
# molecule 0 |
277 |
$xCorr[0] = $cell2X; |
278 |
$yCorr[0] = $cell2Y; |
279 |
$zCorr[0] = $cell2Z; |
280 |
#assemble the lattice |
281 |
$counter = 0; |
282 |
for ($z = 0; $z < $nz; $z++) { |
283 |
for ($y = 0; $y < $ny; $y++) { |
284 |
for ($x = 0; $x < $nx; $x++) { |
285 |
$xCorr[$counter] = $xCorr[0] + $cellLengthX*$x; |
286 |
$yCorr[$counter] = $yCorr[0] + $cellLengthY*$y; |
287 |
$zCorr[$counter] = $zCorr[0] + $cellLengthZ*$z; |
288 |
|
289 |
$counter++; |
290 |
} |
291 |
} |
292 |
} |
293 |
} |
294 |
|
295 |
writeOutFile(); |
296 |
print "The water box \"$fileName\" was generated.\n"; |
297 |
|
298 |
if ($opt_m){ |
299 |
printWaterMD(); |
300 |
print "The file \"water.md\" was generated for inclusion in \"$fileName\"\n"; |
301 |
} |
302 |
|
303 |
if ($nothingSelected == 1) { |
304 |
print "(For help, use the \'-h\' option.)\n"; |
305 |
} |
306 |
|
307 |
|
308 |
# this marks the end of the main program, below is subroutines |
309 |
|
310 |
sub acos { |
311 |
my ($rad) = @_; |
312 |
my $ret = atan2(sqrt(1 - $rad*$rad), $rad); |
313 |
return $ret; |
314 |
} |
315 |
|
316 |
sub writeOutFile { |
317 |
# write out the header |
318 |
print OUTFILE "<OpenMD version=1>\n"; |
319 |
findCutoff(); |
320 |
printMetaData(); |
321 |
printFrameData(); |
322 |
print OUTFILE " <StuntDoubles>\n"; |
323 |
|
324 |
# shift the box center to the origin and write out the coordinates |
325 |
for ($i = 0; $i < $nMol; $i++) { |
326 |
$xCorr[$i] -= 0.5*$boxx; |
327 |
$yCorr[$i] -= 0.5*$boxy; |
328 |
$zCorr[$i] -= 0.5*$boxz; |
329 |
|
330 |
$q0 = 1.0; |
331 |
$q1 = 0.0; |
332 |
$q2 = 0.0; |
333 |
$q3 = 0.0; |
334 |
|
335 |
if ($doRandomize == 1){ |
336 |
$cosTheta = 2.0*rand() - 1.0; |
337 |
$theta = acos($cosTheta); |
338 |
$phi = 2.0*3.14159265359*rand(); |
339 |
$psi = 2.0*3.14159265359*rand(); |
340 |
|
341 |
$q0 = cos(0.5*$theta)*cos(0.5*($phi + $psi)); |
342 |
$q1 = sin(0.5*$theta)*cos(0.5*($phi - $psi)); |
343 |
$q2 = sin(0.5*$theta)*sin(0.5*($phi - $psi)); |
344 |
$q3 = cos(0.5*$theta)*sin(0.5*($phi + $psi)); |
345 |
} |
346 |
|
347 |
print OUTFILE "$i\tpq\t$xCorr[$i] $yCorr[$i] $zCorr[$i] "; |
348 |
print OUTFILE "$q0 $q1 $q2 $q3\n"; |
349 |
} |
350 |
|
351 |
print OUTFILE " </StuntDoubles>\n </Snapshot>\n</OpenMD>\n"; |
352 |
} |
353 |
|
354 |
sub printMetaData { |
355 |
print OUTFILE " <MetaData>\n"; |
356 |
|
357 |
# print the water model or includes |
358 |
if ($opt_m){ |
359 |
print OUTFILE "#include \"water.md\""; |
360 |
} else { |
361 |
printWaterModel(); |
362 |
} |
363 |
printFakeWater() if $invalidWater == 1; |
364 |
|
365 |
# now back to the metaData output |
366 |
print OUTFILE "\n\ncomponent{ |
367 |
type = \"$waterName\"; |
368 |
nMol = $nMol; |
369 |
} |
370 |
|
371 |
ensemble = NVE; |
372 |
forceField = \"Amber\"; |
373 |
electrostaticSummationMethod = \"shifted_force\"; |
374 |
electrostaticScreeningMethod = \"damped\"; |
375 |
cutoffRadius = $cutoff; |
376 |
switchingRadius = $cutoff; |
377 |
dampingAlpha = $alpha; |
378 |
|
379 |
targetTemp = 300; |
380 |
targetPressure = 1.0; |
381 |
|
382 |
tauThermostat = 1e3; |
383 |
tauBarostat = 1e4; |
384 |
|
385 |
dt = 2.0; |
386 |
runTime = 1e3; |
387 |
|
388 |
tempSet = \"true\"; |
389 |
thermalTime = 10; |
390 |
sampleTime = 100; |
391 |
statusTime = 2; |
392 |
</MetaData>\n"; |
393 |
} |
394 |
|
395 |
sub findCutoff { |
396 |
if ($boxy < $boxx) { |
397 |
$bm = $boxy; |
398 |
} else { |
399 |
$bm = $boxx; |
400 |
} |
401 |
if ($boxz < $bm) { |
402 |
$bm = $boxz; |
403 |
} |
404 |
$boxLength2 = 0.5*$bm; |
405 |
if ($boxLength2 > $cutoff){ |
406 |
# the default is good |
407 |
} else { |
408 |
$cutoff = int($boxLength2); |
409 |
} |
410 |
} |
411 |
|
412 |
sub printFrameData { |
413 |
print OUTFILE |
414 |
" <Snapshot> |
415 |
<FrameData> |
416 |
Time: 0 |
417 |
Hmat: {{ $boxx, 0, 0 }, { 0, $boxy, 0 }, { 0, 0, $boxz }} |
418 |
</FrameData>\n"; |
419 |
} |
420 |
|
421 |
sub printWaterMD { |
422 |
open(WATERMD, ">./water.md") || die "Error: can't open file water.md\n"; |
423 |
$waterFileHandle = 'WATERMD'; |
424 |
|
425 |
print WATERMD "#ifndef _WATER_MD_\n#define _WATER_MD_\n"; |
426 |
printCl(); |
427 |
printNa(); |
428 |
printSSD_E(); |
429 |
printSSD_RF(); |
430 |
printSSD(); |
431 |
printSSDQ(); |
432 |
printSSDQO(); |
433 |
printSSD1(); |
434 |
printTRED(); |
435 |
printTIP3P(); |
436 |
printTIP4P(); |
437 |
printTIP4PEw(); |
438 |
printTIP5P(); |
439 |
printTIP5PE(); |
440 |
printSPCE(); |
441 |
printSPC(); |
442 |
printDPD(); |
443 |
printCG2(); |
444 |
print WATERMD "\n\n#endif"; |
445 |
} |
446 |
|
447 |
sub printCl { |
448 |
print $waterFileHandle "\n\nmolecule{ |
449 |
name = \"Cl-\"; |
450 |
|
451 |
atom[0]{ |
452 |
type = \"Cl-\"; |
453 |
position(0.0, 0.0, 0.0); |
454 |
} |
455 |
}" |
456 |
} |
457 |
|
458 |
sub printNa { |
459 |
print $waterFileHandle "\n\nmolecule{ |
460 |
name = \"Na+\"; |
461 |
|
462 |
atom[0]{ |
463 |
type = \"Na+\"; |
464 |
position(0.0, 0.0, 0.0); |
465 |
} |
466 |
}" |
467 |
} |
468 |
|
469 |
sub printSSD_E { |
470 |
print $waterFileHandle "\n\nmolecule{ |
471 |
name = \"SSD_E\"; |
472 |
|
473 |
atom[0]{ |
474 |
type = \"SSD_E\"; |
475 |
position( 0.0, 0.0, 0.0 ); |
476 |
orientation( 0.0, 0.0, 0.0 ); |
477 |
} |
478 |
}" |
479 |
} |
480 |
|
481 |
sub printSSD_RF { |
482 |
print $waterFileHandle "\n\nmolecule{ |
483 |
name = \"SSD_RF\"; |
484 |
|
485 |
atom[0]{ |
486 |
type = \"SSD_RF\"; |
487 |
position( 0.0, 0.0, 0.0 ); |
488 |
orientation( 0.0, 0.0, 0.0 ); |
489 |
} |
490 |
}" |
491 |
} |
492 |
|
493 |
sub printSSD { |
494 |
print $waterFileHandle "\n\nmolecule{ |
495 |
name = \"SSD\"; |
496 |
|
497 |
atom[0]{ |
498 |
type = \"SSD\"; |
499 |
position( 0.0, 0.0, 0.0 ); |
500 |
orientation( 0.0, 0.0, 0.0 ); |
501 |
} |
502 |
}" |
503 |
} |
504 |
|
505 |
sub printSSDQ { |
506 |
print $waterFileHandle "\n\nmolecule{ |
507 |
name = \"SSDQ\"; |
508 |
|
509 |
atom[0]{ |
510 |
type = \"SSDQ\"; |
511 |
position( 0.0, 0.0, 0.0 ); |
512 |
orientation( 0.0, 0.0, 0.0 ); |
513 |
} |
514 |
}" |
515 |
} |
516 |
|
517 |
sub printSSDQO { |
518 |
print $waterFileHandle "\n\nmolecule{ |
519 |
name = \"SSDQO\"; |
520 |
|
521 |
atom[0]{ |
522 |
type = \"SSDQO\"; |
523 |
position( 0.0, 0.0, 0.0 ); |
524 |
orientation( 0.0, 0.0, 0.0 ); |
525 |
} |
526 |
}" |
527 |
} |
528 |
|
529 |
sub printSSD1 { |
530 |
print $waterFileHandle "\n\nmolecule{ |
531 |
name = \"SSD1\"; |
532 |
|
533 |
atom[0]{ |
534 |
type = \"SSD1\"; |
535 |
position( 0.0, 0.0, 0.0 ); |
536 |
orientation( 0.0, 0.0, 0.0 ); |
537 |
} |
538 |
}" |
539 |
} |
540 |
|
541 |
sub printTRED { |
542 |
print $waterFileHandle "\n\nmolecule{ |
543 |
name = \"TRED\"; |
544 |
|
545 |
atom[0]{ |
546 |
type = \"TRED\"; |
547 |
position( 0.0, 0.0, 0.0 ); |
548 |
orientation( 0.0, 0.0, 0.0 ); |
549 |
} |
550 |
atom[1]{ |
551 |
type = \"EP_TRED\"; |
552 |
position( 0.0, 0.0, 0.5 ); |
553 |
} |
554 |
|
555 |
rigidBody[0]{ |
556 |
members(0, 1); |
557 |
} |
558 |
|
559 |
}" |
560 |
} |
561 |
|
562 |
sub printTIP3P { |
563 |
print $waterFileHandle "\n\nmolecule{ |
564 |
name = \"TIP3P\"; |
565 |
|
566 |
atom[0]{ |
567 |
type = \"O_TIP3P\"; |
568 |
position( 0.0, 0.0, -0.06556 ); |
569 |
} |
570 |
atom[1]{ |
571 |
type = \"H_TIP3P\"; |
572 |
position( 0.0, 0.75695, 0.52032 ); |
573 |
} |
574 |
atom[2]{ |
575 |
type = \"H_TIP3P\"; |
576 |
position( 0.0, -0.75695, 0.52032 ); |
577 |
} |
578 |
|
579 |
rigidBody[0]{ |
580 |
members(0, 1, 2); |
581 |
} |
582 |
|
583 |
}" |
584 |
} |
585 |
|
586 |
sub printTIP4P { |
587 |
print $waterFileHandle "\n\nmolecule{ |
588 |
name = \"TIP4P\"; |
589 |
|
590 |
atom[0]{ |
591 |
type = \"O_TIP4P\"; |
592 |
position( 0.0, 0.0, -0.06556 ); |
593 |
} |
594 |
atom[1]{ |
595 |
type = \"H_TIP4P\"; |
596 |
position( 0.0, 0.75695, 0.52032 ); |
597 |
} |
598 |
atom[2]{ |
599 |
type = \"H_TIP4P\"; |
600 |
position( 0.0, -0.75695, 0.52032 ); |
601 |
} |
602 |
atom[3]{ |
603 |
type = \"EP_TIP4P\"; |
604 |
position( 0.0, 0.0, 0.08444 ); |
605 |
} |
606 |
|
607 |
rigidBody[0]{ |
608 |
members(0, 1, 2, 3); |
609 |
} |
610 |
|
611 |
}" |
612 |
} |
613 |
|
614 |
sub printTIP4PEw { |
615 |
print $waterFileHandle "\n\nmolecule{ |
616 |
name = \"TIP4P-Ew\"; |
617 |
|
618 |
atom[0]{ |
619 |
type = \"O_TIP4P-Ew\"; |
620 |
position( 0.0, 0.0, -0.06556 ); |
621 |
} |
622 |
atom[1]{ |
623 |
type = \"H_TIP4P-Ew\"; |
624 |
position( 0.0, 0.75695, 0.52032 ); |
625 |
} |
626 |
atom[2]{ |
627 |
type = \"H_TIP4P-Ew\"; |
628 |
position( 0.0, -0.75695, 0.52032 ); |
629 |
} |
630 |
atom[3]{ |
631 |
type = \"EP_TIP4P-Ew\"; |
632 |
position( 0.0, 0.0, 0.05944 ); |
633 |
} |
634 |
|
635 |
rigidBody[0]{ |
636 |
members(0, 1, 2, 3); |
637 |
} |
638 |
|
639 |
}" |
640 |
} |
641 |
|
642 |
sub printTIP5P { |
643 |
print $waterFileHandle "\n\nmolecule{ |
644 |
name = \"TIP5P\"; |
645 |
|
646 |
atom[0]{ |
647 |
type = \"O_TIP5P\"; |
648 |
position( 0.0, 0.0, -0.06556 ); |
649 |
} |
650 |
atom[1]{ |
651 |
type = \"H_TIP5P\"; |
652 |
position( 0.0, 0.75695, 0.52032 ); |
653 |
} |
654 |
atom[2]{ |
655 |
type = \"H_TIP5P\"; |
656 |
position( 0.0, -0.75695, 0.52032 ); |
657 |
} |
658 |
atom[3]{ |
659 |
type = \"EP_TIP5P\"; |
660 |
position( 0.57154, 0.0, -0.46971 ); |
661 |
} |
662 |
atom[4]{ |
663 |
type = \"EP_TIP5P\"; |
664 |
position( -0.57154, 0.0, -0.46971 ); |
665 |
} |
666 |
|
667 |
rigidBody[0]{ |
668 |
members(0, 1, 2, 3, 4); |
669 |
} |
670 |
|
671 |
}" |
672 |
} |
673 |
|
674 |
sub printTIP5PE { |
675 |
print $waterFileHandle "\n\nmolecule{ |
676 |
name = \"TIP5P-E\"; |
677 |
|
678 |
atom[0]{ |
679 |
type = \"O_TIP5P-E\"; |
680 |
position( 0.0, 0.0, -0.06556 ); |
681 |
} |
682 |
atom[1]{ |
683 |
type = \"H_TIP5P\"; |
684 |
position( 0.0, 0.75695, 0.52032 ); |
685 |
} |
686 |
atom[2]{ |
687 |
type = \"H_TIP5P\"; |
688 |
position( 0.0, -0.75695, 0.52032 ); |
689 |
} |
690 |
atom[3]{ |
691 |
type = \"EP_TIP5P\"; |
692 |
position( 0.57154, 0.0, -0.46971 ); |
693 |
} |
694 |
atom[4]{ |
695 |
type = \"EP_TIP5P\"; |
696 |
position( -0.57154, 0.0, -0.46971 ); |
697 |
} |
698 |
|
699 |
rigidBody[0]{ |
700 |
members(0, 1, 2, 3, 4); |
701 |
} |
702 |
|
703 |
}" |
704 |
} |
705 |
|
706 |
sub printSPCE { |
707 |
print $waterFileHandle "\n\nmolecule{ |
708 |
name = \"SPCE\"; |
709 |
|
710 |
atom[0]{ |
711 |
type = \"O_SPCE\"; |
712 |
position( 0.0, 0.0, -0.06461 ); |
713 |
} |
714 |
atom[1]{ |
715 |
type = \"H_SPCE\"; |
716 |
position( 0.0, 0.81649, 0.51275 ); |
717 |
} |
718 |
atom[2]{ |
719 |
type = \"H_SPCE\"; |
720 |
position( 0.0, -0.81649, 0.51275 ); |
721 |
} |
722 |
|
723 |
rigidBody[0]{ |
724 |
members(0, 1, 2); |
725 |
} |
726 |
|
727 |
}" |
728 |
} |
729 |
|
730 |
sub printSPC { |
731 |
print $waterFileHandle "\n\nmolecule{ |
732 |
name = \"SPC\"; |
733 |
|
734 |
atom[0]{ |
735 |
type = \"O_SPC\"; |
736 |
position( 0.0, 0.0, -0.06461 ); |
737 |
} |
738 |
atom[1]{ |
739 |
type = \"H_SPC\"; |
740 |
position( 0.0, 0.81649, 0.51275 ); |
741 |
} |
742 |
atom[2]{ |
743 |
type = \"H_SPC\"; |
744 |
position( 0.0, -0.81649, 0.51275 ); |
745 |
} |
746 |
|
747 |
rigidBody[0]{ |
748 |
members(0, 1, 2); |
749 |
} |
750 |
|
751 |
}" |
752 |
} |
753 |
|
754 |
sub printDPD { |
755 |
print $waterFileHandle "\n\nmolecule{ |
756 |
name = \"DPD\"; |
757 |
|
758 |
atom[0]{ |
759 |
type = \"DPD\"; |
760 |
position(0.0, 0.0, 0.0); |
761 |
} |
762 |
}" |
763 |
} |
764 |
|
765 |
sub printCG2 { |
766 |
print $waterFileHandle "\n\nmolecule{ |
767 |
name = \"CG2\"; |
768 |
|
769 |
atom[0]{ |
770 |
type = \"CG2\"; |
771 |
position(0.0, 0.0, 0.0); |
772 |
} |
773 |
}" |
774 |
} |
775 |
|
776 |
sub printFakeWater { |
777 |
print $waterFileHandle "\n\nmolecule{ |
778 |
name = \"$waterName\"; |
779 |
|
780 |
atom[0]{ |
781 |
type = \"$waterName\"; |
782 |
position(0.0, 0.0, 0.0); |
783 |
} |
784 |
}" |
785 |
} |
786 |
|
787 |
|
788 |
sub validateWater { |
789 |
if ($waterName eq 'Cl-') { $waterCase = 0; } |
790 |
elsif ($waterName eq 'Na+') { $waterCase = 1; } |
791 |
elsif ($waterName eq 'SSD_E') { $waterCase = 2; } |
792 |
elsif ($waterName eq 'SSD_RF') { $waterCase = 3; } |
793 |
elsif ($waterName eq 'SSD') { $waterCase = 4; } |
794 |
elsif ($waterName eq 'SSD1') { $waterCase = 5; } |
795 |
elsif ($waterName eq 'TIP3P') { $waterCase = 6; } |
796 |
elsif ($waterName eq 'TIP4P') { $waterCase = 7; } |
797 |
elsif ($waterName eq 'TIP4P-Ew') { $waterCase = 8; } |
798 |
elsif ($waterName eq 'TIP5P') { $waterCase = 9; } |
799 |
elsif ($waterName eq 'TIP5P-E') { $waterCase = 10; } |
800 |
elsif ($waterName eq 'SPCE') { $waterCase = 11; } |
801 |
elsif ($waterName eq 'SPC') { $waterCase = 12; } |
802 |
elsif ($waterName eq 'DPD') { $waterCase = 13; } |
803 |
elsif ($waterName eq 'CG2') { $waterCase = 14; } |
804 |
elsif ($waterName eq 'SSDQ') { $waterCase = 15; } |
805 |
elsif ($waterName eq 'SSDQO') { $waterCase = 16; } |
806 |
else { $invalidWater = 1; } |
807 |
} |
808 |
|
809 |
sub printWaterModel { |
810 |
if ($waterCase == 0) { printCl(); } |
811 |
elsif ($waterCase == 1) { printNa(); } |
812 |
elsif ($waterCase == 2) { printSSD_E(); } |
813 |
elsif ($waterCase == 3) { printSSD_RF(); } |
814 |
elsif ($waterCase == 4) { printSSD(); } |
815 |
elsif ($waterCase == 5) { printSSD1(); } |
816 |
elsif ($waterCase == 6) { printTIP3P(); } |
817 |
elsif ($waterCase == 7) { printTIP4P(); } |
818 |
elsif ($waterCase == 8) { printTIP4PEw(); } |
819 |
elsif ($waterCase == 9) { printTIP5P(); } |
820 |
elsif ($waterCase == 10) { printTIP5PE(); } |
821 |
elsif ($waterCase == 11) { printSPCE(); } |
822 |
elsif ($waterCase == 12) { printSPC(); } |
823 |
elsif ($waterCase == 13) { printDPD(); } |
824 |
elsif ($waterCase == 14) { printCG2(); } |
825 |
elsif ($waterCase == 15) { printSSDQ(); } |
826 |
elsif ($waterCase == 16) { printSSDQO(); } |
827 |
} |