OpenMD 3.1
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
waterBoxer
1#!@PERL_EXECUTABLE@
2
3# program that builds water boxes
4
5# author = "Chris Fennell
6# copyright = "Copyright (c) 2004-present The University of Notre Dame. All Rights Reserved."
7# license = "OpenMD"
8
9use Getopt::Std;
10use List::Util qw[min max];
11
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$density = 1.0;
19$doRandomize = 0;
20$cutoff = 9;
21$rcut = 3.2;
22$alpha = 0.18;
23$invalidWater = 0;
24$waterCase = -1;
25$nothingSelected = 1;
26
27# get our options
28getopts('hmrvd:l:c:o:w:x:y:z:');
29
30# just to test opt_h
31$opt_h = "true" if $#ARGV >= 0;
32
33# our option output
34if ($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.inc 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
47
48 print " -c real : default overlap cutoff in angstroms\n";
49 print " (default: 3.3)\n";
50 print " -o char : output file name\n";
51 print " (default: freshWater.omd)\n";
52 print " -w char : name of the water stunt double\n";
53 print " (default: SPCE)\n";
54 print " -x real : dimension of the box along the x direction\n";
55 print " -y real : dimension of the box along the y direction\n";
56 print " -z real : dimension of the box along the z direction\n\n";
57 print "Note: you can only use values of x, y, or z that are smaller\n";
58 print " than the derived box length for a given density and\n";
59 print " number of molecules.\n\n";
60 print "Example:\n";
61 die " waterBoxer -d 0.997 -w SSD_RF -o ssdrfWater.omd\n";
62}
63
64# set some variables to be used in the code
65if (defined($opt_o)){
66 $fileName = $opt_o;
67 $nothingSelected = 0;
68} else {
69 $fileName = 'freshWater.omd';
70}
71if ($opt_m){
72 die "Error: $fileName cannot be \"water.inc\"\n Please choose a different name\n" if $fileName eq 'water.inc';
73 $waterFileHandle = 'WATERMD';
74 $nothingSelected = 0;
75} else {
76 $waterFileHandle = 'OUTFILE';
77}
78if ($opt_r){
79 $doRandomize = $opt_r;
80 $nothingSelected = 0;
81}
82
83if (defined($opt_d)){
84 $nothingSelected = 0;
85 if ($opt_d =~ /^[0-9]/) {
86 $density = $opt_d;
87 } else {
88 die "Error: the value for '-d' ($opt_d) is not a valid number\n Please choose a positive real # value\n";
89 }
90}
91if (defined($opt_c)){
92 $nothingSelected = 0;
93 if ($opt_c =~ /^[0-9]/) {
94 $rcut = $opt_c;
95 } else {
96 die "Error: the value for '-c' ($opt_c) is not a valid number\n Please choose a positive real # value\n";
97 }
98}
99
100if (defined($opt_w)){
101 $waterName = $opt_w;
102 $nothingSelected = 0;
103} else {
104 $waterName = 'SPCE';
105}
106validateWater();
107if ($invalidWater == 1){
108 print "Warning: \'$waterName\' is not a recognized water model name.\n";
109 print " Use the \'-m\' option to generate a \'water.inc\' with the\n";
110 print " recognized water model geometries.\n\n";
111}
112if ($waterName eq 'DPD') {
113 # DPD waters are stand-ins for 4 water molecules
114 $density = $density * 0.25;
115}
116if ($waterName eq 'CG2') {
117 # CG2 waters are stand-ins for 2 water molecules
118 $density = $density * 0.5;
119}
120
121if (defined($opt_l)){
122 $nothingSelected = 0;
123 if ($opt_l =~ /^[0-9]/) {
124 $lattice = $opt_l;
125 if ($lattice != 0 && $lattice != 1){
126 die "Error: the '-l' value ($opt_l) is not a valid number\n Please choose 0 or 1\n";
127 }
128 } else {
129 die "Error: the '-l' value ($opt_l) is not a valid number\n Please choose 0 or 1\n";
130 }
131}
132if (defined($opt_x)){
133 $nothingSelected = 0;
134 if ($opt_x =~ /^[0-9]/) {
135 $boxx = $opt_x;
136 } else {
137 die "Error: the value for '-x' ($opt_x) is not a valid number\n Please choose a positive real # value\n";
138 }
139} else {
140 die "Error: the size of the box '-x' must be set\n";
141}
142if (defined($opt_y)){
143 $nothingSelected = 0;
144 if ($opt_y =~ /^[0-9]/) {
145 $boxy = $opt_y;
146 } else {
147 die "Error: the value for '-y' ($opt_y) is not a valid number\n Please choose a positive real # value\n";
148 }
149} else {
150 die "Error: the size of the box '-y' must be set\n";
151}
152if (defined($opt_z)){
153 $nothingSelected = 0;
154 if ($opt_z =~ /^[0-9]/) {
155 $boxz = $opt_z;
156 } else {
157 die "Error: the value for '-z' ($opt_z) is not a valid number\n Please choose a positive real # value\n";
158 }
159} else {
160 die "Error: the size of the box '-z' must be set\n";
161}
162
163if ($nothingSelected == 1) {
164 die "(For help, use the \'-h\' option.)\n";
165}
166
167# open the file writer
168open(OUTFILE, ">./$fileName") || die "Error: can't open file $fileName\n";
169
170# check to set magic lattice numbers
171if ($lattice == 0){
172 $a = (4*18.01/(0.602*$density))**(1.0/3.0);
173 $acut = $rcut * sqrt(2.0);
174 if ($acut > $a) {
175 $a = $acut;
176 $newDensity = 4.0*18.01/(0.602*$a**3);
177 print "using density of $newDensity to match cutoff value ($rcut)\n";
178 }
179} elsif ($lattice == 1){
180 $a = (18.01/(0.602*$density))**(1.0/3.0);
181 $acut = $rcut;
182 if ($acut > $a) {
183 $a = $acut;
184 $newDensity = 18.01/(0.602*$a**3);
185 print "using density of $newDensity to match cutoff value ($rcut)\n";
186 }
187}
188$nxFloat = $boxx/$a;
189$nx = int($nxFloat + $nxFloat/abs($nxFloat*2));
190$nyFloat = $boxy/$a;
191$ny = int($nyFloat + $nyFloat/abs($nyFloat*2));
192$nzFloat = $boxz/$a;
193$nz = int($nzFloat + $nzFloat/abs($nzFloat*2));
194
195$anew = min($boxx/$nx, $boxy/$ny, $boxz/$nz);
196
197if ($anew < $acut) {
198 $anew = $acut;
199}
200
201$nxFloat = $boxx/$anew;
202$nx = int($nxFloat + $nxFloat/abs($nxFloat*2));
203$nyFloat = $boxy/$anew;
204$ny = int($nyFloat + $nyFloat/abs($nyFloat*2));
205$nzFloat = $boxz/$anew;
206$nz = int($nzFloat + $nzFloat/abs($nzFloat*2));
207
208if ($lattice == 0) {
209 $nMol = 4 * $nx * $ny * $nz;
210} else {
211 $nMol = $nx * $ny * $nz;
212}
213
214$newDensity = $nMol * $densityConvert / ($boxx*$boxy*$boxz);
215
216if (abs($newDensity-$density) > $tolerance) {
217 print "Resetting density to $newDensity to make chosen box sides work out\n";
218}
219$cellLengthX = $boxx/$nx;
220$cellLengthY = $boxy/$ny;
221$cellLengthZ = $boxz/$nz;
222
223$cell2X = $cellLengthX*0.5;
224$cell2Y = $cellLengthY*0.5;
225$cell2Z = $cellLengthZ*0.5;
226
227if ($lattice == 0) {
228# build the unit cell
229# molecule 0
230 $xCorr[0] = 0.0;
231 $yCorr[0] = 0.0;
232 $zCorr[0] = 0.0;
233# molecule 1
234 $xCorr[1] = 0.0;
235 $yCorr[1] = $cell2Y;
236 $zCorr[1] = $cell2Z;
237# molecule 2
238 $xCorr[2] = $cell2X;
239 $yCorr[2] = $cell2Y;
240 $zCorr[2] = 0.0;
241# molecule 3
242 $xCorr[3] = $cell2X;
243 $yCorr[3] = 0.0;
244 $zCorr[3] = $cell2Z;
245# assemble the lattice
246 $counter = 0;
247 for ($z = 0; $z < $nz; $z++) {
248 for ($y = 0; $y < $ny; $y++) {
249 for ($x = 0; $x < $nx; $x++) {
250 for ($uc = 0; $uc < 4; $uc++) {
251 $xCorr[$uc+$counter] = $xCorr[$uc] + $cellLengthX*$x;
252 $yCorr[$uc+$counter] = $yCorr[$uc] + $cellLengthY*$y;
253 $zCorr[$uc+$counter] = $zCorr[$uc] + $cellLengthZ*$z;
254 }
255 $counter = $counter + 4;
256 }
257 }
258 }
259
260} elsif ($lattice == 1) {
261 # build the unit cell
262 # molecule 0
263 $xCorr[0] = $cell2X;
264 $yCorr[0] = $cell2Y;
265 $zCorr[0] = $cell2Z;
266#assemble the lattice
267 $counter = 0;
268 for ($z = 0; $z < $nz; $z++) {
269 for ($y = 0; $y < $ny; $y++) {
270 for ($x = 0; $x < $nx; $x++) {
271 $xCorr[$counter] = $xCorr[0] + $cellLengthX*$x;
272 $yCorr[$counter] = $yCorr[0] + $cellLengthY*$y;
273 $zCorr[$counter] = $zCorr[0] + $cellLengthZ*$z;
274 $counter++;
275 }
276 }
277 }
278}
279
280writeOutFile();
281print "The water box \"$fileName\" was generated.\n";
282
283if ($opt_m){
284 printWaterMD();
285 print "The file \"water.inc\" was generated for inclusion in \"$fileName\"\n";
286}
287
288
289
290# this marks the end of the main program, below is subroutines
291
292sub acos {
293 my ($rad) = @_;
294 my $ret = atan2(sqrt(1 - $rad*$rad), $rad);
295 return $ret;
296}
297
298sub writeOutFile {
299 # write out the header
300 print OUTFILE "<OpenMD version=1>\n";
301 findCutoff();
302 printMetaData();
303 printFrameData();
304 print OUTFILE " <StuntDoubles>\n";
305
306 # shift the box center to the origin and write out the coordinates
307 for ($i = 0; $i < $nMol; $i++) {
308 $xCorr[$i] -= 0.5*$boxx;
309 $yCorr[$i] -= 0.5*$boxy;
310 $zCorr[$i] -= 0.5*$boxz;
311
312 $q0 = 1.0;
313 $q1 = 0.0;
314 $q2 = 0.0;
315 $q3 = 0.0;
316
317 if ($doRandomize == 1){
318 $cosTheta = 2.0*rand() - 1.0;
319 $theta = acos($cosTheta);
320 $phi = 2.0*3.14159265359*rand();
321 $psi = 2.0*3.14159265359*rand();
322
323 $q0 = cos(0.5*$theta)*cos(0.5*($phi + $psi));
324 $q1 = sin(0.5*$theta)*cos(0.5*($phi - $psi));
325 $q2 = sin(0.5*$theta)*sin(0.5*($phi - $psi));
326 $q3 = cos(0.5*$theta)*sin(0.5*($phi + $psi));
327 }
328
329 print OUTFILE "$i\tpq\t$xCorr[$i] $yCorr[$i] $zCorr[$i] ";
330 print OUTFILE "$q0 $q1 $q2 $q3\n";
331 }
332
333 print OUTFILE " </StuntDoubles>\n </Snapshot>\n</OpenMD>\n";
334}
335
336sub printMetaData {
337 print OUTFILE " <MetaData>\n";
338
339# print the water model or includes
340 if ($opt_m){
341 print OUTFILE "#include \"water.inc\"";
342 } else {
343 printWaterModel();
344 }
345 printFakeWater() if $invalidWater == 1;
346
347# now back to the metaData output
348 print OUTFILE "\n\ncomponent{
349 type = \"$waterName\";
350 nMol = $nMol;
351}
352
353ensemble = NVT;
354forceField = \"Water\";
355electrostaticSummationMethod = \"shifted_force\";
356electrostaticScreeningMethod = \"damped\";
357cutoffRadius = $cutoff;
358switchingRadius = $cutoff;
359dampingAlpha = $alpha;
360
361targetTemp = 300;
362targetPressure = 1.0;
363
364tauThermostat = 1e3;
365tauBarostat = 1e4;
366
367dt = 2.0;
368runTime = 1e3;
369
370tempSet = \"true\";
371thermalTime = 10;
372sampleTime = 100;
373statusTime = 2;
374 </MetaData>\n";
375}
376
377sub findCutoff {
378 if ($boxy < $boxx) {
379 $bm = $boxy;
380 } else {
381 $bm = $boxx;
382 }
383 if ($boxz < $bm) {
384 $bm = $boxz;
385 }
386 $boxLength2 = 0.5*$bm;
387 if ($boxLength2 > $cutoff){
388 # the default is good
389 } else {
390 $cutoff = int($boxLength2);
391 }
392}
393
394sub printFrameData {
395print OUTFILE
396" <Snapshot>
397 <FrameData>
398 Time: 0
399 Hmat: {{ $boxx, 0, 0 }, { 0, $boxy, 0 }, { 0, 0, $boxz }}
400 </FrameData>\n";
401}
402
403sub printWaterMD {
404 open(WATERMD, ">./water.inc") || die "Error: can't open file water.inc\n";
405 $waterFileHandle = 'WATERMD';
406
407 print WATERMD "#ifndef _WATER_INC_\n#define _WATER_INC_\n";
408 printCl();
409 printNa();
410 printSSD_E();
411 printSSD_RF();
412 printSSD();
413 printSSDQ();
414 printSSDQO();
415 printSSD1();
416 printTRED();
417 printTIP3P();
418 printTIP4P();
419 printTIP4PIce();
420 printTIP4PEw();
421 printTIP4P2005();
422 printTIP5P();
423 printTIP5PE();
424 printNE6();
425 printSPCE();
426 printSPC();
427 printSPCHW();
428 printDPD();
429 printCG2();
430 printTIP3PFB();
431 printTIP4PFB();
432 printOPC3();
433 printOPC();
434 print WATERMD "\n\n#endif";
435}
436
437sub printCl {
438 print $waterFileHandle "\n\nmolecule{
439 name = \"Cl-\";
440
441 atom[0]{
442 type = \"Cl-\";
443 position(0.0, 0.0, 0.0);
444 }
445}"
446}
447
448sub printNa {
449 print $waterFileHandle "\n\nmolecule{
450 name = \"Na+\";
451
452 atom[0]{
453 type = \"Na+\";
454 position(0.0, 0.0, 0.0);
455 }
456}"
457}
458
459sub printSSD_E {
460 print $waterFileHandle "\n\nmolecule{
461 name = \"SSD_E\";
462
463 atom[0]{
464 type = \"SSD_E\";
465 position( 0.0, 0.0, 0.0 );
466 orientation( 0.0, 0.0, 0.0 );
467 }
468}"
469}
470
471sub printSSD_RF {
472 print $waterFileHandle "\n\nmolecule{
473 name = \"SSD_RF\";
474
475 atom[0]{
476 type = \"SSD_RF\";
477 position( 0.0, 0.0, 0.0 );
478 orientation( 0.0, 0.0, 0.0 );
479 }
480}"
481}
482
483sub printSSD {
484 print $waterFileHandle "\n\nmolecule{
485 name = \"SSD\";
486
487 atom[0]{
488 type = \"SSD\";
489 position( 0.0, 0.0, 0.0 );
490 orientation( 0.0, 0.0, 0.0 );
491 }
492}"
493}
494
495sub printSSDQ {
496 print $waterFileHandle "\n\nmolecule{
497 name = \"SSDQ\";
498
499 atom[0]{
500 type = \"SSDQ\";
501 position( 0.0, 0.0, 0.0 );
502 orientation( 0.0, 0.0, 0.0 );
503 }
504}"
505}
506
507sub printSSDQO {
508 print $waterFileHandle "\n\nmolecule{
509 name = \"SSDQO\";
510
511 atom[0]{
512 type = \"SSDQO\";
513 position( 0.0, 0.0, 0.0 );
514 orientation( 0.0, 0.0, 0.0 );
515 }
516}"
517}
518
519sub printSSD1 {
520 print $waterFileHandle "\n\nmolecule{
521 name = \"SSD1\";
522
523 atom[0]{
524 type = \"SSD1\";
525 position( 0.0, 0.0, 0.0 );
526 orientation( 0.0, 0.0, 0.0 );
527 }
528}"
529}
530
531sub printTRED {
532 print $waterFileHandle "\n\nmolecule{
533 name = \"TRED\";
534
535 atom[0]{
536 type = \"TRED\";
537 position( 0.0, 0.0, 0.0 );
538 orientation( 0.0, 0.0, 0.0 );
539 }
540 atom[1]{
541 type = \"EP_TRED\";
542 position( 0.0, 0.0, 0.5 );
543 }
544
545 rigidBody[0]{
546 members(0, 1);
547 }
548
549}"
550}
551
552sub printTIP3P {
553 print $waterFileHandle "\n\nmolecule{
554 name = \"TIP3P\";
555
556 atom[0]{
557 type = \"O_TIP3P\";
558 position( 0.0, 0.0, -0.06556 );
559 }
560 atom[1]{
561 type = \"H_TIP3P\";
562 position( 0.0, 0.75695, 0.52032 );
563 }
564 atom[2]{
565 type = \"H_TIP3P\";
566 position( 0.0, -0.75695, 0.52032 );
567 }
568
569 rigidBody[0]{
570 members(0, 1, 2);
571 }
572
573}"
574}
575
576sub printTIP4P {
577 print $waterFileHandle "\n\nmolecule{
578 name = \"TIP4P\";
579
580 atom[0]{
581 type = \"O_TIP4P\";
582 position( 0.0, 0.0, -0.06556 );
583 }
584 atom[1]{
585 type = \"H_TIP4P\";
586 position( 0.0, 0.75695, 0.52032 );
587 }
588 atom[2]{
589 type = \"H_TIP4P\";
590 position( 0.0, -0.75695, 0.52032 );
591 }
592 atom[3]{
593 type = \"EP_TIP4P\";
594 position( 0.0, 0.0, 0.08444 );
595 }
596
597 rigidBody[0]{
598 members(0, 1, 2, 3);
599 }
600
601}"
602}
603
604sub printTIP4PIce {
605 print $waterFileHandle "\n\nmolecule{
606 name = \"TIP4P-Ice\";
607
608 atom[0]{
609 type = \"O_TIP4P-Ice\";
610 position( 0.0, 0.0, -0.06556 );
611 }
612 atom[1]{
613 type = \"H_TIP4P-Ice\";
614 position( 0.0, 0.75695, 0.52032 );
615 }
616 atom[2]{
617 type = \"H_TIP4P-Ice\";
618 position( 0.0, -0.75695, 0.52032 );
619 }
620 atom[3]{
621 type = \"EP_TIP4P-Ice\";
622 position( 0.0, 0.0, 0.09214 );
623 }
624
625 rigidBody[0]{
626 members(0, 1, 2, 3);
627 }
628
629}"
630}
631
632sub printTIP4PEw {
633 print $waterFileHandle "\n\nmolecule{
634 name = \"TIP4P-Ew\";
635
636 atom[0]{
637 type = \"O_TIP4P-Ew\";
638 position( 0.0, 0.0, -0.06556 );
639 }
640 atom[1]{
641 type = \"H_TIP4P-Ew\";
642 position( 0.0, 0.75695, 0.52032 );
643 }
644 atom[2]{
645 type = \"H_TIP4P-Ew\";
646 position( 0.0, -0.75695, 0.52032 );
647 }
648 atom[3]{
649 type = \"EP_TIP4P-Ew\";
650 position( 0.0, 0.0, 0.05944 );
651 }
652
653 rigidBody[0]{
654 members(0, 1, 2, 3);
655 }
656
657}"
658}
659
660sub printTIP4P2005 {
661 print $waterFileHandle "\n\nmolecule{
662 name = \"TIP4P-2005\";
663
664 atom[0]{
665 type = \"O_TIP4P-2005\";
666 position( 0.0, 0.0, -0.06556 );
667 }
668 atom[1]{
669 type = \"H_TIP4P-2005\";
670 position( 0.0, 0.75695, 0.52032 );
671 }
672 atom[2]{
673 type = \"H_TIP4P-2005\";
674 position( 0.0, -0.75695, 0.52032 );
675 }
676 atom[3]{
677 type = \"EP_TIP4P-2005\";
678 position( 0.0, 0.0, 0.08904 );
679 }
680
681 rigidBody[0]{
682 members(0, 1, 2, 3);
683 }
684
685}"
686}
687
688sub printTIP5P {
689 print $waterFileHandle "\n\nmolecule{
690 name = \"TIP5P\";
691
692 atom[0]{
693 type = \"O_TIP5P\";
694 position( 0.0, 0.0, -0.06556 );
695 }
696 atom[1]{
697 type = \"H_TIP5P\";
698 position( 0.0, 0.75695, 0.52032 );
699 }
700 atom[2]{
701 type = \"H_TIP5P\";
702 position( 0.0, -0.75695, 0.52032 );
703 }
704 atom[3]{
705 type = \"EP_TIP5P\";
706 position( 0.57154, 0.0, -0.46971 );
707 }
708 atom[4]{
709 type = \"EP_TIP5P\";
710 position( -0.57154, 0.0, -0.46971 );
711 }
712
713 rigidBody[0]{
714 members(0, 1, 2, 3, 4);
715 }
716
717}"
718}
719
720sub printTIP5PE {
721 print $waterFileHandle "\n\nmolecule{
722 name = \"TIP5P-E\";
723
724 atom[0]{
725 type = \"O_TIP5P-E\";
726 position( 0.0, 0.0, -0.06556 );
727 }
728 atom[1]{
729 type = \"H_TIP5P\";
730 position( 0.0, 0.75695, 0.52032 );
731 }
732 atom[2]{
733 type = \"H_TIP5P\";
734 position( 0.0, -0.75695, 0.52032 );
735 }
736 atom[3]{
737 type = \"EP_TIP5P\";
738 position( 0.57154, 0.0, -0.46971 );
739 }
740 atom[4]{
741 type = \"EP_TIP5P\";
742 position( -0.57154, 0.0, -0.46971 );
743 }
744
745 rigidBody[0]{
746 members(0, 1, 2, 3, 4);
747 }
748
749}"
750}
751
752sub printNE6 {
753 print $waterFileHandle "\n\nmolecule{
754 name = \"NE6\";
755
756 atom[0]{
757 type = \"O_NE6\";
758 position( 0.0, 0.0, 0.0 );
759 }
760 atom[1]{
761 type = \"H_NE6\";
762 position( 0.0, 0.576029, 0.79283665 );
763 }
764 atom[2]{
765 type = \"H_NE6\";
766 position( 0.0, -0.576029, 0.79283665 );
767 }
768 atom[3]{
769 type = \"EP_NE6\";
770 position( 0.0, 0.23, 0.0 );
771 }
772 atom[4]{
773 type = \"LP_NE6\";
774 position( 0.732813007, -0.50364843, 0.0 );
775 }
776 atom[5]{
777 type = \"LP_NE6\";
778 position( -0.732813007, -0.50364843, 0.0 );
779 }
780
781 rigidBody[0]{
782 members(0, 1, 2, 3, 4, 5);
783 }
784}"
785}
786
787sub printSPCE {
788print $waterFileHandle "\n\nmolecule{
789 name = \"SPCE\";
790
791 atom[0]{
792 type = \"O_SPCE\";
793 position( 0.0, 0.0, -0.06461 );
794 }
795 atom[1]{
796 type = \"H_SPCE\";
797 position( 0.0, 0.81649, 0.51275 );
798 }
799 atom[2]{
800 type = \"H_SPCE\";
801 position( 0.0, -0.81649, 0.51275 );
802 }
803
804 rigidBody[0]{
805 members(0, 1, 2);
806 }
807
808}"
809}
810
811sub printSPC {
812print $waterFileHandle "\n\nmolecule{
813 name = \"SPC\";
814
815 atom[0]{
816 type = \"O_SPC\";
817 position( 0.0, 0.0, -0.06461 );
818 }
819 atom[1]{
820 type = \"H_SPC\";
821 position( 0.0, 0.81649, 0.51275 );
822 }
823 atom[2]{
824 type = \"H_SPC\";
825 position( 0.0, -0.81649, 0.51275 );
826 }
827
828 rigidBody[0]{
829 members(0, 1, 2);
830 }
831
832}"
833}
834
835sub printOPC {
836print $waterFileHandle "\n\nmolecule{
837 name = \"OPC\";
838
839 atom[0]{
840 type = \"O_OPC\";
841 position( 0.0, 0.0, -0.0603651 );
842 }
843 atom[1]{
844 type = \"H_OPC\";
845 position( 0.0, 0.685582, 0.479134 );
846 }
847 atom[2]{
848 type = \"H_OPC\";
849 position( 0.0, -0.685582, 0.479134 );
850 }
851 atom[3]{
852 type = \"EP_OPC\";
853 position( 0.0, 0.0, 0.0990349 );
854 }
855
856 rigidBody[0]{
857 members(0, 1, 2, 3);
858 }
859}"
860}
861
862sub printOPC3 {
863print $waterFileHandle "\n\nmolecule{
864 name = \"OPC3\";
865
866 atom[0]{
867 type = \"O_OPC3\";
868 position( 0.0, 0.0, -0.0632382 );
869 }
870 atom[1]{
871 type = \"H_OPC3\";
872 position( 0.0, 0.799262, 0.501939 );
873 }
874 atom[2]{
875 type = \"H_OPC3\";
876 position( 0.0, -0.799262, 0.501939 );
877 }
878
879 rigidBody[0]{
880 members(0, 1, 2);
881 }
882}"
883}
884
885sub printTIP3PFB {
886print $waterFileHandle "\n\nmolecule{
887 name = \"TIP3P-FB\";
888
889 atom[0]{
890 type = \"O_TIP3P-FB\";
891 position( 0.0, 0.0, -0.066424 );
892 }
893 atom[1]{
894 type = \"H_TIP3P-FB\";
895 position( 0.0, 0.819341, 0.527225 );
896 }
897 atom[2]{
898 type = \"H_TIP3P-FB\";
899 position( 0.0, -0.819341, 0.527225 );
900 }
901
902 rigidBody[0]{
903 members(0, 1, 2);
904 }
905}"
906}
907
908sub printTIP4PFB {
909print $waterFileHandle "\n\nmolecule{
910 name = \"TIP4P-FB\";
911
912 atom[0]{
913 type = \"O_TIP4P-FB\";
914 position( 0.0, 0.0, -0.0655549 );
915 }
916 atom[1]{
917 type = \"H_TIP4P-FB\";
918 position( 0.0, 0.75695, 0.520327 );
919 }
920 atom[2]{
921 type = \"H_TIP4P-FB\";
922 position( 0.0, -0.75695, 0.520327 );
923 }
924 atom[3]{
925 type = \"EP_TIP4P-FB\";
926 position( 0.0, 0.0, 0.0397151 );
927 }
928
929 rigidBody[0]{
930 members(0, 1, 2, 3);
931 }
932}"
933}
934
935sub printSPCHW {
936print $waterFileHandle "\n\nmolecule{
937 name = \"SPC-HW\";
938
939 atom[0]{
940 type = \"O_SPC-HW\";
941 position( 0.0, 0.0, -0.06461 );
942 }
943 atom[1]{
944 type = \"D_SPC-HW\";
945 position( 0.0, 0.81649, 0.51275 );
946 }
947 atom[2]{
948 type = \"D_SPC-HW\";
949 position( 0.0, -0.81649, 0.51275 );
950 }
951
952 rigidBody[0]{
953 members(0, 1, 2);
954 }
955
956}"
957}
958
959sub printDPD {
960 print $waterFileHandle "\n\nmolecule{
961 name = \"DPD\";
962
963 atom[0]{
964 type = \"DPD\";
965 position(0.0, 0.0, 0.0);
966 }
967}"
968}
969
970sub printCG2 {
971 print $waterFileHandle "\n\nmolecule{
972 name = \"CG2\";
973
974 atom[0]{
975 type = \"CG2\";
976 position(0.0, 0.0, 0.0);
977 }
978}"
979}
980
981sub printFakeWater {
982 print $waterFileHandle "\n\nmolecule{
983 name = \"$waterName\";
984
985 atom[0]{
986 type = \"$waterName\";
987 position(0.0, 0.0, 0.0);
988 }
989}"
990}
991
992
993sub validateWater {
994 if ($waterName eq 'Cl-') { $waterCase = 0; }
995 elsif ($waterName eq 'Na+') { $waterCase = 1; }
996 elsif ($waterName eq 'SSD_E') { $waterCase = 2; }
997 elsif ($waterName eq 'SSD_RF') { $waterCase = 3; }
998 elsif ($waterName eq 'SSD') { $waterCase = 4; }
999 elsif ($waterName eq 'SSD1') { $waterCase = 5; }
1000 elsif ($waterName eq 'TIP3P') { $waterCase = 6; }
1001 elsif ($waterName eq 'TIP4P') { $waterCase = 7; }
1002 elsif ($waterName eq 'TIP4P-Ew') { $waterCase = 8; }
1003 elsif ($waterName eq 'TIP5P') { $waterCase = 9; }
1004 elsif ($waterName eq 'TIP5P-E') { $waterCase = 10; }
1005 elsif ($waterName eq 'SPCE') { $waterCase = 11; }
1006 elsif ($waterName eq 'SPC') { $waterCase = 12; }
1007 elsif ($waterName eq 'DPD') { $waterCase = 13; }
1008 elsif ($waterName eq 'CG2') { $waterCase = 14; }
1009 elsif ($waterName eq 'SSDQ') { $waterCase = 15; }
1010 elsif ($waterName eq 'SSDQO') { $waterCase = 16; }
1011 elsif ($waterName eq 'TIP4P-Ice'){ $waterCase = 17; }
1012 elsif ($waterName eq 'TIP4P-2005'){ $switchCase = 18; }
1013 elsif ($waterName eq 'SPC-HW') { $waterCase == 19; }
1014 elsif ($waterName eq 'NE6') { $waterCase == 20; }
1015 elsif ($waterName eq 'TIP3P-FB') { $waterCase == 21; }
1016 elsif ($waterName eq 'TIP4P-FB') { $waterCase == 22; }
1017 elsif ($waterName eq 'OPC') { $waterCase == 23; }
1018 elsif ($waterName eq 'OPC3') { $waterCase == 24; }
1019 else { $invalidWater = 1; }
1020}
1021
1022sub printWaterModel {
1023 if ($waterCase == 0) { printCl(); }
1024 elsif ($waterCase == 1) { printNa(); }
1025 elsif ($waterCase == 2) { printSSD_E(); }
1026 elsif ($waterCase == 3) { printSSD_RF(); }
1027 elsif ($waterCase == 4) { printSSD(); }
1028 elsif ($waterCase == 5) { printSSD1(); }
1029 elsif ($waterCase == 6) { printTIP3P(); }
1030 elsif ($waterCase == 7) { printTIP4P(); }
1031 elsif ($waterCase == 8) { printTIP4PEw(); }
1032 elsif ($waterCase == 9) { printTIP5P(); }
1033 elsif ($waterCase == 10) { printTIP5PE(); }
1034 elsif ($waterCase == 11) { printSPCE(); }
1035 elsif ($waterCase == 12) { printSPC(); }
1036 elsif ($waterCase == 13) { printDPD(); }
1037 elsif ($waterCase == 14) { printCG2(); }
1038 elsif ($waterCase == 15) { printSSDQ(); }
1039 elsif ($waterCase == 16) { printSSDQO(); }
1040 elsif ($waterCase == 17) { printTIP4PIce();}
1041 elsif ($waterCase == 18) { printTIP4P2005();}
1042 elsif ($waterCase == 19) { printSPCHW(); }
1043 elsif ($waterCase == 20) { printNE6(); }
1044 elsif ($waterCase == 21) { printTIP3PFB(); }
1045 elsif ($waterCase == 22) { printTIP4PFB(); }
1046 elsif ($waterCase == 23) { printOPC(); }
1047 elsif ($waterCase == 24) { printOPC3(); }
1048}