ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/applications/thermalizer/thermalizer.cpp
Revision: 3059
Committed: Fri Oct 20 14:59:05 2006 UTC (17 years, 9 months ago) by gezelter
File size: 4545 byte(s)
Log Message:
more openbabel updates, also changing velocitizer to thermalizer to
avoid a filename collision on case-insensitve file systems

File Contents

# User Rev Content
1 gezelter 3059 /*
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     * 1. Acknowledgement of the program authors must be made in any
10     * publication of scientific results based in part on use of the
11     * program. An acceptable form of acknowledgement is citation of
12     * the article in which the program was described (Matthew
13     * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14     * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15     * Parallel Simulation Engine for Molecular Dynamics,"
16     * J. Comput. Chem. 26, pp. 252-271 (2005))
17     *
18     * 2. Redistributions of source code must retain the above copyright
19     * notice, this list of conditions and the following disclaimer.
20     *
21     * 3. Redistributions in binary form must reproduce the above copyright
22     * notice, this list of conditions and the following disclaimer in the
23     * documentation and/or other materials provided with the
24     * distribution.
25     *
26     * This software is provided "AS IS," without a warranty of any
27     * kind. All express or implied conditions, representations and
28     * warranties, including any implied warranty of merchantability,
29     * fitness for a particular purpose or non-infringement, are hereby
30     * excluded. The University of Notre Dame and its licensors shall not
31     * be liable for any damages suffered by licensee as a result of
32     * using, modifying or distributing the software or its
33     * derivatives. In no event will the University of Notre Dame or its
34     * licensors be liable for any lost revenue, profit or data, or for
35     * direct, indirect, special, consequential, incidental or punitive
36     * damages, however caused and regardless of the theory of liability,
37     * arising out of the use of or inability to use software, even if the
38     * University of Notre Dame has been advised of the possibility of
39     * such damages.
40     */
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     using namespace oopse;
69    
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     sprintf(painCave.errMsg, "A new OOPSE MD file called \"%s\" has been "
141     "generated.\n", outputFileName.c_str());
142     painCave.isFatal = 0;
143     simError();
144     return 0;
145     }