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