ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/applications/thermalizer/thermalizer.cpp
Revision: 1465
Committed: Fri Jul 9 23:08:25 2010 UTC (14 years, 9 months ago) by chuckv
File size: 4585 byte(s)
Log Message:
Creating busticated version of OpenMD

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     * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).
39     * [4] Vardeman & Gezelter, in progress (2009).
40 gezelter 1083 */
41    
42     /**
43     * @file thermalizer.cpp
44     * @author Dan Gezelter
45     * @date 09/20/2006
46     * @version 1.0
47     */
48    
49     #include <cstdlib>
50     #include <cstdio>
51     #include <cstring>
52     #include <cmath>
53     #include <iostream>
54     #include <string>
55     #include <map>
56     #include <fstream>
57    
58     #include "applications/thermalizer/thermalizerCmd.h"
59     #include "integrators/Velocitizer.hpp"
60     #include "brains/Register.hpp"
61     #include "brains/SimInfo.hpp"
62     #include "brains/SimCreator.hpp"
63     #include "io/DumpReader.hpp"
64     #include "io/DumpWriter.hpp"
65     #include "utils/StringUtils.hpp"
66    
67     using namespace std;
68 gezelter 1390 using namespace OpenMD;
69 gezelter 1083
70     int main(int argc, char *argv []) {
71    
72     // register force fields
73     registerForceFields();
74     registerLattice();
75    
76     gengetopt_args_info args_info;
77     std::string inputFileName;
78     std::string outputFileName;
79     RealType temperature;
80    
81     // parse command line arguments
82     if (cmdline_parser(argc, argv, &args_info) != 0)
83     exit(1);
84    
85     temperature = args_info.temperature_arg;
86    
87     if (temperature < 0.0) {
88     sprintf(painCave.errMsg, "Temperatures must be positive numbers.");
89     painCave.isFatal = 1;
90     simError();
91     }
92    
93     //get input file name
94     if (args_info.inputs_num)
95     inputFileName = args_info.inputs[0];
96     else {
97     sprintf(painCave.errMsg, "No input file name was specified "
98     "on the command line");
99     painCave.isFatal = 1;
100     simError();
101     }
102    
103     //parse md file and set up the system
104    
105     SimCreator creator;
106     SimInfo* info = creator.createSim(inputFileName, false);
107     Velocitizer* veloSet = new Velocitizer(info);
108     DumpReader reader(info, inputFileName);
109     // very important step:
110     info->update();
111    
112     outputFileName = args_info.output_arg;
113    
114     if (!outputFileName.compare(inputFileName)) {
115     sprintf(painCave.errMsg, "Input and Output File names should be different!");
116     painCave.isFatal = 1;
117     simError();
118     }
119    
120     DumpWriter* writer = new DumpWriter(info, outputFileName);
121    
122     if (writer == NULL) {
123     sprintf(painCave.errMsg, "error in creating DumpWriter");
124     painCave.isFatal = 1;
125     simError();
126     }
127    
128     int nFrames = reader.getNFrames();
129    
130     for (int istep = 0; istep < nFrames; istep++) {
131     reader.readFrame(istep);
132     veloSet->velocitize(temperature);
133     writer->writeDump();
134     }
135    
136     // deleting the writer will put the closing at the end of the dump file.
137    
138     delete writer;
139    
140 gezelter 1390 sprintf(painCave.errMsg, "A new OpenMD file called \"%s\" has been "
141 gezelter 1083 "generated.\n", outputFileName.c_str());
142     painCave.isFatal = 0;
143     simError();
144     return 0;
145     }

Properties

Name Value
svn:keywords Author Id Revision Date