1 |
gezelter |
1083 |
/* |
2 |
|
|
* Copyright (c) 2006 The University of Notre Dame. All Rights Reserved. |
3 |
|
|
* |
4 |
|
|
* The University of Notre Dame grants you ("Licensee") a |
5 |
|
|
* non-exclusive, royalty free, license to use, modify and |
6 |
|
|
* redistribute this software in source and binary code form, provided |
7 |
|
|
* that the following conditions are met: |
8 |
|
|
* |
9 |
gezelter |
1390 |
* 1. Redistributions of source code must retain the above copyright |
10 |
gezelter |
1083 |
* notice, this list of conditions and the following disclaimer. |
11 |
|
|
* |
12 |
gezelter |
1390 |
* 2. Redistributions in binary form must reproduce the above copyright |
13 |
gezelter |
1083 |
* notice, this list of conditions and the following disclaimer in the |
14 |
|
|
* documentation and/or other materials provided with the |
15 |
|
|
* distribution. |
16 |
|
|
* |
17 |
|
|
* This software is provided "AS IS," without a warranty of any |
18 |
|
|
* kind. All express or implied conditions, representations and |
19 |
|
|
* warranties, including any implied warranty of merchantability, |
20 |
|
|
* fitness for a particular purpose or non-infringement, are hereby |
21 |
|
|
* excluded. The University of Notre Dame and its licensors shall not |
22 |
|
|
* be liable for any damages suffered by licensee as a result of |
23 |
|
|
* using, modifying or distributing the software or its |
24 |
|
|
* derivatives. In no event will the University of Notre Dame or its |
25 |
|
|
* licensors be liable for any lost revenue, profit or data, or for |
26 |
|
|
* direct, indirect, special, consequential, incidental or punitive |
27 |
|
|
* damages, however caused and regardless of the theory of liability, |
28 |
|
|
* arising out of the use of or inability to use software, even if the |
29 |
|
|
* University of Notre Dame has been advised of the possibility of |
30 |
|
|
* such damages. |
31 |
gezelter |
1390 |
* |
32 |
|
|
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
33 |
|
|
* research, please cite the appropriate papers when you publish your |
34 |
|
|
* work. Good starting points are: |
35 |
|
|
* |
36 |
|
|
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
37 |
|
|
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
38 |
|
|
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
39 |
gezelter |
1665 |
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
40 |
|
|
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
41 |
gezelter |
1083 |
*/ |
42 |
|
|
|
43 |
|
|
/** |
44 |
|
|
* @file thermalizer.cpp |
45 |
|
|
* @author Dan Gezelter |
46 |
|
|
* @date 09/20/2006 |
47 |
|
|
* @version 1.0 |
48 |
|
|
*/ |
49 |
|
|
|
50 |
|
|
#include <cstdlib> |
51 |
|
|
#include <cstdio> |
52 |
|
|
#include <cstring> |
53 |
|
|
#include <cmath> |
54 |
|
|
#include <iostream> |
55 |
|
|
#include <string> |
56 |
|
|
#include <map> |
57 |
|
|
#include <fstream> |
58 |
|
|
|
59 |
|
|
#include "applications/thermalizer/thermalizerCmd.h" |
60 |
|
|
#include "integrators/Velocitizer.hpp" |
61 |
|
|
#include "brains/Register.hpp" |
62 |
|
|
#include "brains/SimInfo.hpp" |
63 |
|
|
#include "brains/SimCreator.hpp" |
64 |
|
|
#include "io/DumpReader.hpp" |
65 |
|
|
#include "io/DumpWriter.hpp" |
66 |
|
|
#include "utils/StringUtils.hpp" |
67 |
|
|
|
68 |
|
|
using namespace std; |
69 |
gezelter |
1390 |
using namespace OpenMD; |
70 |
gezelter |
1083 |
|
71 |
|
|
int main(int argc, char *argv []) { |
72 |
|
|
|
73 |
|
|
// register force fields |
74 |
|
|
registerForceFields(); |
75 |
|
|
registerLattice(); |
76 |
|
|
|
77 |
|
|
gengetopt_args_info args_info; |
78 |
|
|
std::string inputFileName; |
79 |
|
|
std::string outputFileName; |
80 |
|
|
RealType temperature; |
81 |
|
|
|
82 |
|
|
// parse command line arguments |
83 |
|
|
if (cmdline_parser(argc, argv, &args_info) != 0) |
84 |
|
|
exit(1); |
85 |
|
|
|
86 |
|
|
temperature = args_info.temperature_arg; |
87 |
|
|
|
88 |
|
|
if (temperature < 0.0) { |
89 |
|
|
sprintf(painCave.errMsg, "Temperatures must be positive numbers."); |
90 |
|
|
painCave.isFatal = 1; |
91 |
|
|
simError(); |
92 |
|
|
} |
93 |
|
|
|
94 |
|
|
//get input file name |
95 |
|
|
if (args_info.inputs_num) |
96 |
|
|
inputFileName = args_info.inputs[0]; |
97 |
|
|
else { |
98 |
|
|
sprintf(painCave.errMsg, "No input file name was specified " |
99 |
|
|
"on the command line"); |
100 |
|
|
painCave.isFatal = 1; |
101 |
|
|
simError(); |
102 |
|
|
} |
103 |
|
|
|
104 |
|
|
//parse md file and set up the system |
105 |
|
|
|
106 |
|
|
SimCreator creator; |
107 |
|
|
SimInfo* info = creator.createSim(inputFileName, false); |
108 |
|
|
Velocitizer* veloSet = new Velocitizer(info); |
109 |
|
|
DumpReader reader(info, inputFileName); |
110 |
|
|
// very important step: |
111 |
|
|
info->update(); |
112 |
|
|
|
113 |
|
|
outputFileName = args_info.output_arg; |
114 |
|
|
|
115 |
|
|
if (!outputFileName.compare(inputFileName)) { |
116 |
|
|
sprintf(painCave.errMsg, "Input and Output File names should be different!"); |
117 |
|
|
painCave.isFatal = 1; |
118 |
|
|
simError(); |
119 |
|
|
} |
120 |
|
|
|
121 |
|
|
DumpWriter* writer = new DumpWriter(info, outputFileName); |
122 |
|
|
|
123 |
|
|
if (writer == NULL) { |
124 |
|
|
sprintf(painCave.errMsg, "error in creating DumpWriter"); |
125 |
|
|
painCave.isFatal = 1; |
126 |
|
|
simError(); |
127 |
|
|
} |
128 |
|
|
|
129 |
|
|
int nFrames = reader.getNFrames(); |
130 |
|
|
|
131 |
|
|
for (int istep = 0; istep < nFrames; istep++) { |
132 |
|
|
reader.readFrame(istep); |
133 |
|
|
veloSet->velocitize(temperature); |
134 |
|
|
writer->writeDump(); |
135 |
|
|
} |
136 |
|
|
|
137 |
|
|
// deleting the writer will put the closing at the end of the dump file. |
138 |
|
|
|
139 |
|
|
delete writer; |
140 |
|
|
|
141 |
gezelter |
1390 |
sprintf(painCave.errMsg, "A new OpenMD file called \"%s\" has been " |
142 |
gezelter |
1083 |
"generated.\n", outputFileName.c_str()); |
143 |
|
|
painCave.isFatal = 0; |
144 |
|
|
simError(); |
145 |
|
|
return 0; |
146 |
|
|
} |