ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/thermalizer/thermalizer.cpp
Revision: 1977
Committed: Wed Mar 12 21:35:23 2014 UTC (11 years, 1 month ago) by gezelter
File size: 4635 byte(s)
Log Message:
Removed some scary errors that are really supposed to be OPENMD_INFO messages

File Contents

# User Rev Content
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 gezelter 1879 * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).
39 gezelter 1782 * [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     registerLattice();
74    
75     gengetopt_args_info args_info;
76     std::string inputFileName;
77     std::string outputFileName;
78     RealType temperature;
79    
80     // parse command line arguments
81     if (cmdline_parser(argc, argv, &args_info) != 0)
82     exit(1);
83    
84     temperature = args_info.temperature_arg;
85    
86     if (temperature < 0.0) {
87     sprintf(painCave.errMsg, "Temperatures must be positive numbers.");
88     painCave.isFatal = 1;
89     simError();
90     }
91    
92     //get input file name
93     if (args_info.inputs_num)
94     inputFileName = args_info.inputs[0];
95     else {
96     sprintf(painCave.errMsg, "No input file name was specified "
97     "on the command line");
98     painCave.isFatal = 1;
99     simError();
100     }
101    
102     //parse md file and set up the system
103    
104     SimCreator creator;
105     SimInfo* info = creator.createSim(inputFileName, false);
106     Velocitizer* veloSet = new Velocitizer(info);
107     DumpReader reader(info, inputFileName);
108     // very important step:
109     info->update();
110    
111     outputFileName = args_info.output_arg;
112    
113     if (!outputFileName.compare(inputFileName)) {
114     sprintf(painCave.errMsg, "Input and Output File names should be different!");
115     painCave.isFatal = 1;
116     simError();
117     }
118    
119     DumpWriter* writer = new DumpWriter(info, outputFileName);
120    
121     if (writer == NULL) {
122     sprintf(painCave.errMsg, "error in creating DumpWriter");
123     painCave.isFatal = 1;
124     simError();
125     }
126    
127     int nFrames = reader.getNFrames();
128    
129     for (int istep = 0; istep < nFrames; istep++) {
130     reader.readFrame(istep);
131     veloSet->velocitize(temperature);
132     writer->writeDump();
133     }
134    
135     // deleting the writer will put the closing at the end of the dump file.
136    
137     delete writer;
138    
139 gezelter 1390 sprintf(painCave.errMsg, "A new OpenMD file called \"%s\" has been "
140 gezelter 1083 "generated.\n", outputFileName.c_str());
141     painCave.isFatal = 0;
142 gezelter 1977 painCave.severity = OPENMD_INFO;
143 gezelter 1083 simError();
144     return 0;
145     }

Properties

Name Value
svn:keywords Author Id Revision Date