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