OpenMD 3.1
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 printTIP3PFB();
439 printTIP4PFB();
440 printOPC3();
441 printOPC();
442 print WATERMD "\n\n#endif";
443}
444
445sub printCl {
446 print $waterFileHandle "\n\nmolecule{
447 name = \"Cl-\";
448
449 atom[0]{
450 type = \"Cl-\";
451 position(0.0, 0.0, 0.0);
452 }
453}"
454}
455
456sub printNa {
457 print $waterFileHandle "\n\nmolecule{
458 name = \"Na+\";
459
460 atom[0]{
461 type = \"Na+\";
462 position(0.0, 0.0, 0.0);
463 }
464}"
465}
466
467sub printSSD_E {
468 print $waterFileHandle "\n\nmolecule{
469 name = \"SSD_E\";
470
471 atom[0]{
472 type = \"SSD_E\";
473 position( 0.0, 0.0, 0.0 );
474 orientation( 0.0, 0.0, 0.0 );
475 }
476}"
477}
478
479sub printSSD_RF {
480 print $waterFileHandle "\n\nmolecule{
481 name = \"SSD_RF\";
482
483 atom[0]{
484 type = \"SSD_RF\";
485 position( 0.0, 0.0, 0.0 );
486 orientation( 0.0, 0.0, 0.0 );
487 }
488}"
489}
490
491sub printSSD {
492 print $waterFileHandle "\n\nmolecule{
493 name = \"SSD\";
494
495 atom[0]{
496 type = \"SSD\";
497 position( 0.0, 0.0, 0.0 );
498 orientation( 0.0, 0.0, 0.0 );
499 }
500}"
501}
502
503sub printSSDQ {
504 print $waterFileHandle "\n\nmolecule{
505 name = \"SSDQ\";
506
507 atom[0]{
508 type = \"SSDQ\";
509 position( 0.0, 0.0, 0.0 );
510 orientation( 0.0, 0.0, 0.0 );
511 }
512}"
513}
514
515sub printSSDQO {
516 print $waterFileHandle "\n\nmolecule{
517 name = \"SSDQO\";
518
519 atom[0]{
520 type = \"SSDQO\";
521 position( 0.0, 0.0, 0.0 );
522 orientation( 0.0, 0.0, 0.0 );
523 }
524}"
525}
526
527sub printSSD1 {
528 print $waterFileHandle "\n\nmolecule{
529 name = \"SSD1\";
530
531 atom[0]{
532 type = \"SSD1\";
533 position( 0.0, 0.0, 0.0 );
534 orientation( 0.0, 0.0, 0.0 );
535 }
536}"
537}
538
539sub printTRED {
540 print $waterFileHandle "\n\nmolecule{
541 name = \"TRED\";
542
543 atom[0]{
544 type = \"TRED\";
545 position( 0.0, 0.0, 0.0 );
546 orientation( 0.0, 0.0, 0.0 );
547 }
548 atom[1]{
549 type = \"EP_TRED\";
550 position( 0.0, 0.0, 0.5 );
551 }
552
553 rigidBody[0]{
554 members(0, 1);
555 }
556
557}"
558}
559
560sub printTIP3P {
561 print $waterFileHandle "\n\nmolecule{
562 name = \"TIP3P\";
563
564 atom[0]{
565 type = \"O_TIP3P\";
566 position( 0.0, 0.0, -0.06556 );
567 }
568 atom[1]{
569 type = \"H_TIP3P\";
570 position( 0.0, 0.75695, 0.52032 );
571 }
572 atom[2]{
573 type = \"H_TIP3P\";
574 position( 0.0, -0.75695, 0.52032 );
575 }
576
577 rigidBody[0]{
578 members(0, 1, 2);
579 }
580
581}"
582}
583
584sub printTIP4P {
585 print $waterFileHandle "\n\nmolecule{
586 name = \"TIP4P\";
587
588 atom[0]{
589 type = \"O_TIP4P\";
590 position( 0.0, 0.0, -0.06556 );
591 }
592 atom[1]{
593 type = \"H_TIP4P\";
594 position( 0.0, 0.75695, 0.52032 );
595 }
596 atom[2]{
597 type = \"H_TIP4P\";
598 position( 0.0, -0.75695, 0.52032 );
599 }
600 atom[3]{
601 type = \"EP_TIP4P\";
602 position( 0.0, 0.0, 0.08444 );
603 }
604
605 rigidBody[0]{
606 members(0, 1, 2, 3);
607 }
608
609}"
610}
611
612sub printTIP4PIce {
613 print $waterFileHandle "\n\nmolecule{
614 name = \"TIP4P-Ice\";
615
616 atom[0]{
617 type = \"O_TIP4P-Ice\";
618 position( 0.0, 0.0, -0.06556 );
619 }
620 atom[1]{
621 type = \"H_TIP4P-Ice\";
622 position( 0.0, 0.75695, 0.52032 );
623 }
624 atom[2]{
625 type = \"H_TIP4P-Ice\";
626 position( 0.0, -0.75695, 0.52032 );
627 }
628 atom[3]{
629 type = \"EP_TIP4P-Ice\";
630 position( 0.0, 0.0, 0.09214 );
631 }
632
633 rigidBody[0]{
634 members(0, 1, 2, 3);
635 }
636
637}"
638}
639
640sub printTIP4PEw {
641 print $waterFileHandle "\n\nmolecule{
642 name = \"TIP4P-Ew\";
643
644 atom[0]{
645 type = \"O_TIP4P-Ew\";
646 position( 0.0, 0.0, -0.06556 );
647 }
648 atom[1]{
649 type = \"H_TIP4P-Ew\";
650 position( 0.0, 0.75695, 0.52032 );
651 }
652 atom[2]{
653 type = \"H_TIP4P-Ew\";
654 position( 0.0, -0.75695, 0.52032 );
655 }
656 atom[3]{
657 type = \"EP_TIP4P-Ew\";
658 position( 0.0, 0.0, 0.05944 );
659 }
660
661 rigidBody[0]{
662 members(0, 1, 2, 3);
663 }
664
665}"
666}
667
668sub printTIP4P2005 {
669 print $waterFileHandle "\n\nmolecule{
670 name = \"TIP4P-2005\";
671
672 atom[0]{
673 type = \"O_TIP4P-2005\";
674 position( 0.0, 0.0, -0.06556 );
675 }
676 atom[1]{
677 type = \"H_TIP4P-2005\";
678 position( 0.0, 0.75695, 0.52032 );
679 }
680 atom[2]{
681 type = \"H_TIP4P-2005\";
682 position( 0.0, -0.75695, 0.52032 );
683 }
684 atom[3]{
685 type = \"EP_TIP4P-2005\";
686 position( 0.0, 0.0, 0.08904 );
687 }
688
689 rigidBody[0]{
690 members(0, 1, 2, 3);
691 }
692
693}"
694}
695
696sub printTIP5P {
697 print $waterFileHandle "\n\nmolecule{
698 name = \"TIP5P\";
699
700 atom[0]{
701 type = \"O_TIP5P\";
702 position( 0.0, 0.0, -0.06556 );
703 }
704 atom[1]{
705 type = \"H_TIP5P\";
706 position( 0.0, 0.75695, 0.52032 );
707 }
708 atom[2]{
709 type = \"H_TIP5P\";
710 position( 0.0, -0.75695, 0.52032 );
711 }
712 atom[3]{
713 type = \"EP_TIP5P\";
714 position( 0.57154, 0.0, -0.46971 );
715 }
716 atom[4]{
717 type = \"EP_TIP5P\";
718 position( -0.57154, 0.0, -0.46971 );
719 }
720
721 rigidBody[0]{
722 members(0, 1, 2, 3, 4);
723 }
724
725}"
726}
727
728sub printTIP5PE {
729 print $waterFileHandle "\n\nmolecule{
730 name = \"TIP5P-E\";
731
732 atom[0]{
733 type = \"O_TIP5P-E\";
734 position( 0.0, 0.0, -0.06556 );
735 }
736 atom[1]{
737 type = \"H_TIP5P\";
738 position( 0.0, 0.75695, 0.52032 );
739 }
740 atom[2]{
741 type = \"H_TIP5P\";
742 position( 0.0, -0.75695, 0.52032 );
743 }
744 atom[3]{
745 type = \"EP_TIP5P\";
746 position( 0.57154, 0.0, -0.46971 );
747 }
748 atom[4]{
749 type = \"EP_TIP5P\";
750 position( -0.57154, 0.0, -0.46971 );
751 }
752
753 rigidBody[0]{
754 members(0, 1, 2, 3, 4);
755 }
756
757}"
758}
759
760sub printNE6 {
761 print $waterFileHandle "\n\nmolecule{
762 name = \"NE6\";
763
764 atom[0]{
765 type = \"O_NE6\";
766 position( 0.0, 0.0, 0.0 );
767 }
768 atom[1]{
769 type = \"H_NE6\";
770 position( 0.0, 0.576029, 0.79283665 );
771 }
772 atom[2]{
773 type = \"H_NE6\";
774 position( 0.0, -0.576029, 0.79283665 );
775 }
776 atom[3]{
777 type = \"EP_NE6\";
778 position( 0.0, 0.23, 0.0 );
779 }
780 atom[4]{
781 type = \"LP_NE6\";
782 position( 0.732813007, -0.50364843, 0.0 );
783 }
784 atom[5]{
785 type = \"LP_NE6\";
786 position( -0.732813007, -0.50364843, 0.0 );
787 }
788
789 rigidBody[0]{
790 members(0, 1, 2, 3, 4, 5);
791 }
792}"
793}
794
795sub printSPCE {
796print $waterFileHandle "\n\nmolecule{
797 name = \"SPCE\";
798
799 atom[0]{
800 type = \"O_SPCE\";
801 position( 0.0, 0.0, -0.06461 );
802 }
803 atom[1]{
804 type = \"H_SPCE\";
805 position( 0.0, 0.81649, 0.51275 );
806 }
807 atom[2]{
808 type = \"H_SPCE\";
809 position( 0.0, -0.81649, 0.51275 );
810 }
811
812 rigidBody[0]{
813 members(0, 1, 2);
814 }
815
816}"
817}
818
819sub printSPC {
820print $waterFileHandle "\n\nmolecule{
821 name = \"SPC\";
822
823 atom[0]{
824 type = \"O_SPC\";
825 position( 0.0, 0.0, -0.06461 );
826 }
827 atom[1]{
828 type = \"H_SPC\";
829 position( 0.0, 0.81649, 0.51275 );
830 }
831 atom[2]{
832 type = \"H_SPC\";
833 position( 0.0, -0.81649, 0.51275 );
834 }
835
836 rigidBody[0]{
837 members(0, 1, 2);
838 }
839
840}"
841}
842
843sub printOPC {
844print $waterFileHandle "\n\nmolecule{
845 name = \"OPC\";
846
847 atom[0]{
848 type = \"O_OPC\";
849 position( 0.0, 0.0, -0.0603651 );
850 }
851 atom[1]{
852 type = \"H_OPC\";
853 position( 0.0, 0.685582, 0.479134 );
854 }
855 atom[2]{
856 type = \"H_OPC\";
857 position( 0.0, -0.685582, 0.479134 );
858 }
859 atom[3]{
860 type = \"EP_OPC\";
861 position( 0.0, 0.0, 0.0990349 );
862 }
863
864 rigidBody[0]{
865 members(0, 1, 2, 3);
866 }
867}"
868}
869
870sub printOPC3 {
871print $waterFileHandle "\n\nmolecule{
872 name = \"OPC3\";
873
874 atom[0]{
875 type = \"O_OPC3\";
876 position( 0.0, 0.0, -0.0632382 );
877 }
878 atom[1]{
879 type = \"H_OPC3\";
880 position( 0.0, 0.799262, 0.501939 );
881 }
882 atom[2]{
883 type = \"H_OPC3\";
884 position( 0.0, -0.799262, 0.501939 );
885 }
886
887 rigidBody[0]{
888 members(0, 1, 2);
889 }
890}"
891}
892
893sub printTIP3PFB {
894print $waterFileHandle "\n\nmolecule{
895 name = \"TIP3P-FB\";
896
897 atom[0]{
898 type = \"O_TIP3P-FB\";
899 position( 0.0, 0.0, -0.066424 );
900 }
901 atom[1]{
902 type = \"H_TIP3P-FB\";
903 position( 0.0, 0.819341, 0.527225 );
904 }
905 atom[2]{
906 type = \"H_TIP3P-FB\";
907 position( 0.0, -0.819341, 0.527225 );
908 }
909
910 rigidBody[0]{
911 members(0, 1, 2);
912 }
913}"
914}
915
916sub printTIP4PFB {
917print $waterFileHandle "\n\nmolecule{
918 name = \"TIP4P-FB\";
919
920 atom[0]{
921 type = \"O_TIP4P-FB\";
922 position( 0.0, 0.0, -0.0655549 );
923 }
924 atom[1]{
925 type = \"H_TIP4P-FB\";
926 position( 0.0, 0.75695, 0.520327 );
927 }
928 atom[2]{
929 type = \"H_TIP4P-FB\";
930 position( 0.0, -0.75695, 0.520327 );
931 }
932 atom[3]{
933 type = \"EP_TIP4P-FB\";
934 position( 0.0, 0.0, 0.0397151 );
935 }
936
937 rigidBody[0]{
938 members(0, 1, 2, 3);
939 }
940}"
941}
942
943
944sub printSPCHW {
945print $waterFileHandle "\n\nmolecule{
946 name = \"SPC-HW\";
947
948 atom[0]{
949 type = \"O_SPC-HW\";
950 position( 0.0, 0.0, -0.06461 );
951 }
952 atom[1]{
953 type = \"D_SPC-HW\";
954 position( 0.0, 0.81649, 0.51275 );
955 }
956 atom[2]{
957 type = \"D_SPC-HW\";
958 position( 0.0, -0.81649, 0.51275 );
959 }
960
961 rigidBody[0]{
962 members(0, 1, 2);
963 }
964
965}"
966}
967
968sub printDPD {
969 print $waterFileHandle "\n\nmolecule{
970 name = \"DPD\";
971
972 atom[0]{
973 type = \"DPD\";
974 position(0.0, 0.0, 0.0);
975 }
976}"
977}
978
979sub printCG2 {
980 print $waterFileHandle "\n\nmolecule{
981 name = \"CG2\";
982
983 atom[0]{
984 type = \"CG2\";
985 position(0.0, 0.0, 0.0);
986 }
987}"
988}
989
990sub printFakeWater {
991 print $waterFileHandle "\n\nmolecule{
992 name = \"$waterName\";
993
994 atom[0]{
995 type = \"$waterName\";
996 position(0.0, 0.0, 0.0);
997 }
998}"
999}
1000
1001
1002sub validateWater {
1003 if ($waterName eq 'Cl-') { $waterCase = 0; }
1004 elsif ($waterName eq 'Na+') { $waterCase = 1; }
1005 elsif ($waterName eq 'SSD_E') { $waterCase = 2; }
1006 elsif ($waterName eq 'SSD_RF') { $waterCase = 3; }
1007 elsif ($waterName eq 'SSD') { $waterCase = 4; }
1008 elsif ($waterName eq 'SSD1') { $waterCase = 5; }
1009 elsif ($waterName eq 'TIP3P') { $waterCase = 6; }
1010 elsif ($waterName eq 'TIP4P') { $waterCase = 7; }
1011 elsif ($waterName eq 'TIP4P-Ew') { $waterCase = 8; }
1012 elsif ($waterName eq 'TIP5P') { $waterCase = 9; }
1013 elsif ($waterName eq 'TIP5P-E') { $waterCase = 10; }
1014 elsif ($waterName eq 'SPCE') { $waterCase = 11; }
1015 elsif ($waterName eq 'SPC') { $waterCase = 12; }
1016 elsif ($waterName eq 'DPD') { $waterCase = 13; }
1017 elsif ($waterName eq 'CG2') { $waterCase = 14; }
1018 elsif ($waterName eq 'SSDQ') { $waterCase = 15; }
1019 elsif ($waterName eq 'SSDQO') { $waterCase = 16; }
1020 elsif ($waterName eq 'TIP4P-Ice'){ $waterCase = 17; }
1021 elsif ($waterName eq 'TIP4P-2005'){ $switchCase = 18; }
1022 elsif ($waterName eq 'SPC-HW') { $waterCase == 19; }
1023 elsif ($waterName eq 'NE6') { $waterCase == 20; }
1024 elsif ($waterName eq 'TIP3P-FB') { $waterCase == 21; }
1025 elsif ($waterName eq 'TIP4P-FB') { $waterCase == 22; }
1026 elsif ($waterName eq 'OPC') { $waterCase == 23; }
1027 elsif ($waterName eq 'OPC3') { $waterCase == 24; }
1028 else { $invalidWater = 1; }
1029}
1030
1031sub printWaterModel {
1032 if ($waterCase == 0) { printCl(); }
1033 elsif ($waterCase == 1) { printNa(); }
1034 elsif ($waterCase == 2) { printSSD_E(); }
1035 elsif ($waterCase == 3) { printSSD_RF(); }
1036 elsif ($waterCase == 4) { printSSD(); }
1037 elsif ($waterCase == 5) { printSSD1(); }
1038 elsif ($waterCase == 6) { printTIP3P(); }
1039 elsif ($waterCase == 7) { printTIP4P(); }
1040 elsif ($waterCase == 8) { printTIP4PEw(); }
1041 elsif ($waterCase == 9) { printTIP5P(); }
1042 elsif ($waterCase == 10) { printTIP5PE(); }
1043 elsif ($waterCase == 11) { printSPCE(); }
1044 elsif ($waterCase == 12) { printSPC(); }
1045 elsif ($waterCase == 13) { printDPD(); }
1046 elsif ($waterCase == 14) { printCG2(); }
1047 elsif ($waterCase == 15) { printSSDQ(); }
1048 elsif ($waterCase == 16) { printSSDQO(); }
1049 elsif ($waterCase == 17) { printTIP4PIce();}
1050 elsif ($waterCase == 18) { printTIP4P2005();}
1051 elsif ($waterCase == 19) { printSPCHW(); }
1052 elsif ($waterCase == 20) { printNE6(); }
1053 elsif ($waterCase == 21) { printTIP3PFB(); }
1054 elsif ($waterCase == 22) { printTIP4PFB(); }
1055 elsif ($waterCase == 23) { printOPC(); }
1056 elsif ($waterCase == 24) { printOPC3(); }
1057}