OpenMD 3.0
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
275 $counter++;
276 }
277 }
278 }
279}
280
281writeOutFile();
282print "The water box \"$fileName\" was generated.\n";
283
284if ($opt_m){
285 printWaterMD();
286 print "The file \"water.inc\" was generated for inclusion in \"$fileName\"\n";
287}
288
289
290
291# this marks the end of the main program, below is subroutines
292
293sub acos {
294 my ($rad) = @_;
295 my $ret = atan2(sqrt(1 - $rad*$rad), $rad);
296 return $ret;
297}
298
299sub writeOutFile {
300 # write out the header
301 print OUTFILE "<OpenMD version=1>\n";
302 findCutoff();
303 printMetaData();
304 printFrameData();
305 print OUTFILE " <StuntDoubles>\n";
306
307 # shift the box center to the origin and write out the coordinates
308 for ($i = 0; $i < $nMol; $i++) {
309 $xCorr[$i] -= 0.5*$boxx;
310 $yCorr[$i] -= 0.5*$boxy;
311 $zCorr[$i] -= 0.5*$boxz;
312
313 $q0 = 1.0;
314 $q1 = 0.0;
315 $q2 = 0.0;
316 $q3 = 0.0;
317
318 if ($doRandomize == 1){
319 $cosTheta = 2.0*rand() - 1.0;
320 $theta = acos($cosTheta);
321 $phi = 2.0*3.14159265359*rand();
322 $psi = 2.0*3.14159265359*rand();
323
324 $q0 = cos(0.5*$theta)*cos(0.5*($phi + $psi));
325 $q1 = sin(0.5*$theta)*cos(0.5*($phi - $psi));
326 $q2 = sin(0.5*$theta)*sin(0.5*($phi - $psi));
327 $q3 = cos(0.5*$theta)*sin(0.5*($phi + $psi));
328 }
329
330 print OUTFILE "$i\tpq\t$xCorr[$i] $yCorr[$i] $zCorr[$i] ";
331 print OUTFILE "$q0 $q1 $q2 $q3\n";
332 }
333
334 print OUTFILE " </StuntDoubles>\n </Snapshot>\n</OpenMD>\n";
335}
336
337sub printMetaData {
338 print OUTFILE " <MetaData>\n";
339
340# print the water model or includes
341 if ($opt_m){
342 print OUTFILE "#include \"water.inc\"";
343 } else {
344 printWaterModel();
345 }
346 printFakeWater() if $invalidWater == 1;
347
348# now back to the metaData output
349 print OUTFILE "\n\ncomponent{
350 type = \"$waterName\";
351 nMol = $nMol;
352}
353
354ensemble = NVT;
355forceField = \"Water\";
356electrostaticSummationMethod = \"shifted_force\";
357electrostaticScreeningMethod = \"damped\";
358cutoffRadius = $cutoff;
359switchingRadius = $cutoff;
360dampingAlpha = $alpha;
361
362targetTemp = 300;
363targetPressure = 1.0;
364
365tauThermostat = 1e3;
366tauBarostat = 1e4;
367
368dt = 2.0;
369runTime = 1e3;
370
371tempSet = \"true\";
372thermalTime = 10;
373sampleTime = 100;
374statusTime = 2;
375 </MetaData>\n";
376}
377
378sub findCutoff {
379 if ($boxy < $boxx) {
380 $bm = $boxy;
381 } else {
382 $bm = $boxx;
383 }
384 if ($boxz < $bm) {
385 $bm = $boxz;
386 }
387 $boxLength2 = 0.5*$bm;
388 if ($boxLength2 > $cutoff){
389 # the default is good
390 } else {
391 $cutoff = int($boxLength2);
392 }
393}
394
395sub printFrameData {
396print OUTFILE
397" <Snapshot>
398 <FrameData>
399 Time: 0
400 Hmat: {{ $boxx, 0, 0 }, { 0, $boxy, 0 }, { 0, 0, $boxz }}
401 </FrameData>\n";
402}
403
404sub printWaterMD {
405 open(WATERMD, ">./water.inc") || die "Error: can't open file water.inc\n";
406 $waterFileHandle = 'WATERMD';
407
408 print WATERMD "#ifndef _WATER_INC_\n#define _WATER_INC_\n";
409 printCl();
410 printNa();
411 printSSD_E();
412 printSSD_RF();
413 printSSD();
414 printSSDQ();
415 printSSDQO();
416 printSSD1();
417 printTRED();
418 printTIP3P();
419 printTIP4P();
420 printTIP4PIce();
421 printTIP4PEw();
422 printTIP4P2005();
423 printTIP5P();
424 printTIP5PE();
425 printNE6();
426 printSPCE();
427 printSPC();
428 printSPCHW();
429 printDPD();
430 printCG2();
431 print WATERMD "\n\n#endif";
432}
433
434sub printCl {
435 print $waterFileHandle "\n\nmolecule{
436 name = \"Cl-\";
437
438 atom[0]{
439 type = \"Cl-\";
440 position(0.0, 0.0, 0.0);
441 }
442}"
443}
444
445sub printNa {
446 print $waterFileHandle "\n\nmolecule{
447 name = \"Na+\";
448
449 atom[0]{
450 type = \"Na+\";
451 position(0.0, 0.0, 0.0);
452 }
453}"
454}
455
456sub printSSD_E {
457 print $waterFileHandle "\n\nmolecule{
458 name = \"SSD_E\";
459
460 atom[0]{
461 type = \"SSD_E\";
462 position( 0.0, 0.0, 0.0 );
463 orientation( 0.0, 0.0, 0.0 );
464 }
465}"
466}
467
468sub printSSD_RF {
469 print $waterFileHandle "\n\nmolecule{
470 name = \"SSD_RF\";
471
472 atom[0]{
473 type = \"SSD_RF\";
474 position( 0.0, 0.0, 0.0 );
475 orientation( 0.0, 0.0, 0.0 );
476 }
477}"
478}
479
480sub printSSD {
481 print $waterFileHandle "\n\nmolecule{
482 name = \"SSD\";
483
484 atom[0]{
485 type = \"SSD\";
486 position( 0.0, 0.0, 0.0 );
487 orientation( 0.0, 0.0, 0.0 );
488 }
489}"
490}
491
492sub printSSDQ {
493 print $waterFileHandle "\n\nmolecule{
494 name = \"SSDQ\";
495
496 atom[0]{
497 type = \"SSDQ\";
498 position( 0.0, 0.0, 0.0 );
499 orientation( 0.0, 0.0, 0.0 );
500 }
501}"
502}
503
504sub printSSDQO {
505 print $waterFileHandle "\n\nmolecule{
506 name = \"SSDQO\";
507
508 atom[0]{
509 type = \"SSDQO\";
510 position( 0.0, 0.0, 0.0 );
511 orientation( 0.0, 0.0, 0.0 );
512 }
513}"
514}
515
516sub printSSD1 {
517 print $waterFileHandle "\n\nmolecule{
518 name = \"SSD1\";
519
520 atom[0]{
521 type = \"SSD1\";
522 position( 0.0, 0.0, 0.0 );
523 orientation( 0.0, 0.0, 0.0 );
524 }
525}"
526}
527
528sub printTRED {
529 print $waterFileHandle "\n\nmolecule{
530 name = \"TRED\";
531
532 atom[0]{
533 type = \"TRED\";
534 position( 0.0, 0.0, 0.0 );
535 orientation( 0.0, 0.0, 0.0 );
536 }
537 atom[1]{
538 type = \"EP_TRED\";
539 position( 0.0, 0.0, 0.5 );
540 }
541
542 rigidBody[0]{
543 members(0, 1);
544 }
545
546}"
547}
548
549sub printTIP3P {
550 print $waterFileHandle "\n\nmolecule{
551 name = \"TIP3P\";
552
553 atom[0]{
554 type = \"O_TIP3P\";
555 position( 0.0, 0.0, -0.06556 );
556 }
557 atom[1]{
558 type = \"H_TIP3P\";
559 position( 0.0, 0.75695, 0.52032 );
560 }
561 atom[2]{
562 type = \"H_TIP3P\";
563 position( 0.0, -0.75695, 0.52032 );
564 }
565
566 rigidBody[0]{
567 members(0, 1, 2);
568 }
569
570}"
571}
572
573sub printTIP4P {
574 print $waterFileHandle "\n\nmolecule{
575 name = \"TIP4P\";
576
577 atom[0]{
578 type = \"O_TIP4P\";
579 position( 0.0, 0.0, -0.06556 );
580 }
581 atom[1]{
582 type = \"H_TIP4P\";
583 position( 0.0, 0.75695, 0.52032 );
584 }
585 atom[2]{
586 type = \"H_TIP4P\";
587 position( 0.0, -0.75695, 0.52032 );
588 }
589 atom[3]{
590 type = \"EP_TIP4P\";
591 position( 0.0, 0.0, 0.08444 );
592 }
593
594 rigidBody[0]{
595 members(0, 1, 2, 3);
596 }
597
598}"
599}
600
601sub printTIP4PIce {
602 print $waterFileHandle "\n\nmolecule{
603 name = \"TIP4P-Ice\";
604
605 atom[0]{
606 type = \"O_TIP4P-Ice\";
607 position( 0.0, 0.0, -0.06556 );
608 }
609 atom[1]{
610 type = \"H_TIP4P-Ice\";
611 position( 0.0, 0.75695, 0.52032 );
612 }
613 atom[2]{
614 type = \"H_TIP4P-Ice\";
615 position( 0.0, -0.75695, 0.52032 );
616 }
617 atom[3]{
618 type = \"EP_TIP4P-Ice\";
619 position( 0.0, 0.0, 0.09214 );
620 }
621
622 rigidBody[0]{
623 members(0, 1, 2, 3);
624 }
625
626}"
627}
628
629sub printTIP4PEw {
630 print $waterFileHandle "\n\nmolecule{
631 name = \"TIP4P-Ew\";
632
633 atom[0]{
634 type = \"O_TIP4P-Ew\";
635 position( 0.0, 0.0, -0.06556 );
636 }
637 atom[1]{
638 type = \"H_TIP4P-Ew\";
639 position( 0.0, 0.75695, 0.52032 );
640 }
641 atom[2]{
642 type = \"H_TIP4P-Ew\";
643 position( 0.0, -0.75695, 0.52032 );
644 }
645 atom[3]{
646 type = \"EP_TIP4P-Ew\";
647 position( 0.0, 0.0, 0.05944 );
648 }
649
650 rigidBody[0]{
651 members(0, 1, 2, 3);
652 }
653
654}"
655}
656
657sub printTIP4P2005 {
658 print $waterFileHandle "\n\nmolecule{
659 name = \"TIP4P-2005\";
660
661 atom[0]{
662 type = \"O_TIP4P-2005\";
663 position( 0.0, 0.0, -0.06556 );
664 }
665 atom[1]{
666 type = \"H_TIP4P-2005\";
667 position( 0.0, 0.75695, 0.52032 );
668 }
669 atom[2]{
670 type = \"H_TIP4P-2005\";
671 position( 0.0, -0.75695, 0.52032 );
672 }
673 atom[3]{
674 type = \"EP_TIP4P-2005\";
675 position( 0.0, 0.0, 0.08904 );
676 }
677
678 rigidBody[0]{
679 members(0, 1, 2, 3);
680 }
681
682}"
683}
684
685sub printTIP5P {
686 print $waterFileHandle "\n\nmolecule{
687 name = \"TIP5P\";
688
689 atom[0]{
690 type = \"O_TIP5P\";
691 position( 0.0, 0.0, -0.06556 );
692 }
693 atom[1]{
694 type = \"H_TIP5P\";
695 position( 0.0, 0.75695, 0.52032 );
696 }
697 atom[2]{
698 type = \"H_TIP5P\";
699 position( 0.0, -0.75695, 0.52032 );
700 }
701 atom[3]{
702 type = \"EP_TIP5P\";
703 position( 0.57154, 0.0, -0.46971 );
704 }
705 atom[4]{
706 type = \"EP_TIP5P\";
707 position( -0.57154, 0.0, -0.46971 );
708 }
709
710 rigidBody[0]{
711 members(0, 1, 2, 3, 4);
712 }
713
714}"
715}
716
717sub printTIP5PE {
718 print $waterFileHandle "\n\nmolecule{
719 name = \"TIP5P-E\";
720
721 atom[0]{
722 type = \"O_TIP5P-E\";
723 position( 0.0, 0.0, -0.06556 );
724 }
725 atom[1]{
726 type = \"H_TIP5P\";
727 position( 0.0, 0.75695, 0.52032 );
728 }
729 atom[2]{
730 type = \"H_TIP5P\";
731 position( 0.0, -0.75695, 0.52032 );
732 }
733 atom[3]{
734 type = \"EP_TIP5P\";
735 position( 0.57154, 0.0, -0.46971 );
736 }
737 atom[4]{
738 type = \"EP_TIP5P\";
739 position( -0.57154, 0.0, -0.46971 );
740 }
741
742 rigidBody[0]{
743 members(0, 1, 2, 3, 4);
744 }
745
746}"
747}
748
749sub printNE6 {
750 print $waterFileHandle "\n\nmolecule{
751 name = \"NE6\";
752
753 atom[0]{
754 type = \"O_NE6\";
755 position( 0.0, 0.0, 0.0 );
756 }
757 atom[1]{
758 type = \"H_NE6\";
759 position( 0.0, 0.576029, 0.79283665 );
760 }
761 atom[2]{
762 type = \"H_NE6\";
763 position( 0.0, -0.576029, 0.79283665 );
764 }
765 atom[3]{
766 type = \"EP_NE6\";
767 position( 0.0, 0.23, 0.0 );
768 }
769 atom[4]{
770 type = \"LP_NE6\";
771 position( 0.732813007, -0.50364843, 0.0 );
772 }
773 atom[5]{
774 type = \"LP_NE6\";
775 position( -0.732813007, -0.50364843, 0.0 );
776 }
777
778 rigidBody[0]{
779 members(0, 1, 2, 3, 4, 5);
780 }
781}"
782}
783
784sub printSPCE {
785print $waterFileHandle "\n\nmolecule{
786 name = \"SPCE\";
787
788 atom[0]{
789 type = \"O_SPCE\";
790 position( 0.0, 0.0, -0.06461 );
791 }
792 atom[1]{
793 type = \"H_SPCE\";
794 position( 0.0, 0.81649, 0.51275 );
795 }
796 atom[2]{
797 type = \"H_SPCE\";
798 position( 0.0, -0.81649, 0.51275 );
799 }
800
801 rigidBody[0]{
802 members(0, 1, 2);
803 }
804
805}"
806}
807
808sub printSPC {
809print $waterFileHandle "\n\nmolecule{
810 name = \"SPC\";
811
812 atom[0]{
813 type = \"O_SPC\";
814 position( 0.0, 0.0, -0.06461 );
815 }
816 atom[1]{
817 type = \"H_SPC\";
818 position( 0.0, 0.81649, 0.51275 );
819 }
820 atom[2]{
821 type = \"H_SPC\";
822 position( 0.0, -0.81649, 0.51275 );
823 }
824
825 rigidBody[0]{
826 members(0, 1, 2);
827 }
828
829}"
830}
831
832
833sub printSPCHW {
834print $waterFileHandle "\n\nmolecule{
835 name = \"SPC-HW\";
836
837 atom[0]{
838 type = \"O_SPC-HW\";
839 position( 0.0, 0.0, -0.06461 );
840 }
841 atom[1]{
842 type = \"D_SPC-HW\";
843 position( 0.0, 0.81649, 0.51275 );
844 }
845 atom[2]{
846 type = \"D_SPC-HW\";
847 position( 0.0, -0.81649, 0.51275 );
848 }
849
850 rigidBody[0]{
851 members(0, 1, 2);
852 }
853
854}"
855}
856
857sub printDPD {
858 print $waterFileHandle "\n\nmolecule{
859 name = \"DPD\";
860
861 atom[0]{
862 type = \"DPD\";
863 position(0.0, 0.0, 0.0);
864 }
865}"
866}
867
868sub printCG2 {
869 print $waterFileHandle "\n\nmolecule{
870 name = \"CG2\";
871
872 atom[0]{
873 type = \"CG2\";
874 position(0.0, 0.0, 0.0);
875 }
876}"
877}
878
879sub printFakeWater {
880 print $waterFileHandle "\n\nmolecule{
881 name = \"$waterName\";
882
883 atom[0]{
884 type = \"$waterName\";
885 position(0.0, 0.0, 0.0);
886 }
887}"
888}
889
890
891sub validateWater {
892 if ($waterName eq 'Cl-') { $waterCase = 0; }
893 elsif ($waterName eq 'Na+') { $waterCase = 1; }
894 elsif ($waterName eq 'SSD_E') { $waterCase = 2; }
895 elsif ($waterName eq 'SSD_RF') { $waterCase = 3; }
896 elsif ($waterName eq 'SSD') { $waterCase = 4; }
897 elsif ($waterName eq 'SSD1') { $waterCase = 5; }
898 elsif ($waterName eq 'TIP3P') { $waterCase = 6; }
899 elsif ($waterName eq 'TIP4P') { $waterCase = 7; }
900 elsif ($waterName eq 'TIP4P-Ew') { $waterCase = 8; }
901 elsif ($waterName eq 'TIP5P') { $waterCase = 9; }
902 elsif ($waterName eq 'TIP5P-E') { $waterCase = 10; }
903 elsif ($waterName eq 'SPCE') { $waterCase = 11; }
904 elsif ($waterName eq 'SPC') { $waterCase = 12; }
905 elsif ($waterName eq 'DPD') { $waterCase = 13; }
906 elsif ($waterName eq 'CG2') { $waterCase = 14; }
907 elsif ($waterName eq 'SSDQ') { $waterCase = 15; }
908 elsif ($waterName eq 'SSDQO') { $waterCase = 16; }
909 elsif ($waterName eq 'TIP4P-Ice'){ $waterCase = 17; }
910 elsif ($waterName eq 'TIP4P-2005'){ $switchCase = 18; }
911 elsif ($waterName eq 'SPC-HW') { $waterCase == 19; }
912 elsif ($waterName eq 'NE6') { $waterCase == 20; }
913 else { $invalidWater = 1; }
914}
915
916sub printWaterModel {
917 if ($waterCase == 0) { printCl(); }
918 elsif ($waterCase == 1) { printNa(); }
919 elsif ($waterCase == 2) { printSSD_E(); }
920 elsif ($waterCase == 3) { printSSD_RF(); }
921 elsif ($waterCase == 4) { printSSD(); }
922 elsif ($waterCase == 5) { printSSD1(); }
923 elsif ($waterCase == 6) { printTIP3P(); }
924 elsif ($waterCase == 7) { printTIP4P(); }
925 elsif ($waterCase == 8) { printTIP4PEw(); }
926 elsif ($waterCase == 9) { printTIP5P(); }
927 elsif ($waterCase == 10) { printTIP5PE(); }
928 elsif ($waterCase == 11) { printSPCE(); }
929 elsif ($waterCase == 12) { printSPC(); }
930 elsif ($waterCase == 13) { printDPD(); }
931 elsif ($waterCase == 14) { printCG2(); }
932 elsif ($waterCase == 15) { printSSDQ(); }
933 elsif ($waterCase == 16) { printSSDQO(); }
934 elsif ($waterCase == 17) { printTIP4PIce();}
935 elsif ($waterCase == 18) { printTIP4P2005();}
936 elsif ($waterCase == 19) { printSPCHW(); }
937 elsif ($waterCase == 20) { printNE6(); }
938}