ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/applications/openmd/openmd.cpp
Revision: 1746
Committed: Wed Jun 6 02:18:54 2012 UTC (12 years, 10 months ago) by gezelter
File size: 9324 byte(s)
Log Message:
added a minimizer parsing block

File Contents

# Content
1 /*
2 * Copyright (c) 2010 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. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * 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 *
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] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010).
40 * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41 * [6] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).
42 */
43
44 #ifdef IS_MPI
45 #include <mpi.h>
46 #endif
47
48 #include <fstream>
49 #include "utils/simError.h"
50 #include "utils/CaseConversion.hpp"
51 #include "brains/Register.hpp"
52 #include "brains/SimCreator.hpp"
53 #include "brains/SimInfo.hpp"
54 #include "constraints/ZconstraintForceManager.hpp"
55 #include "restraints/RestraintForceManager.hpp"
56 #include "integrators/IntegratorFactory.hpp"
57 #include "integrators/Integrator.hpp"
58 #include "optimization/OptimizationFactory.hpp"
59 #include "optimization/Method.hpp"
60 #include "optimization/Constraint.hpp"
61 #include "optimization/Problem.hpp"
62 #include "optimization/PotentialEnergyObjectiveFunction.hpp"
63 #include "restraints/ThermoIntegrationForceManager.hpp"
64
65 using namespace OpenMD;
66 using namespace QuantLib;
67
68 int main(int argc,char* argv[]){
69
70 // first things first, all of the initializations
71
72 #ifdef IS_MPI
73 MPI_Init( &argc, &argv ); // the MPI communicators
74 #endif
75
76 initSimError(); // the error handler
77 srand48( 1337 ); // the random number generator.
78
79 std::string svnrev;
80 //convert a macro from compiler to a string in c++
81 STR_DEFINE(svnrev, SVN_REV );
82
83 std::string revision;
84
85 if (!svnrev.empty()) {
86 revision.assign(" Revision: " + svnrev);
87 }
88
89 revision.resize(19,' ');
90
91 #ifdef IS_MPI
92 if( worldRank == 0 ){
93 #endif
94 std::cerr <<
95 " +--------------------------------------------------------------------------+\n"<<
96 " | ____ __ ___ ____ |\n"<<
97 " | / __ \\____ ___ ____ / |/ // __ \\ The Open Molecular Dynamics |\n"<<
98 " | / / / / __ \\/ _ \\/ __ \\ / /|_/ // / / / Engine (formerly OOPSE). |\n"<<
99 " | / /_/ / /_/ / __/ / / // / / // /_/ / |\n"<<
100 " | \\____/ .___/\\___/_/ /_//_/ /_//_____/ Copyright 2004-2012 by the |\n"<<
101 " | /_/ University of Notre Dame. |\n"<<
102 " | |\n"<<
103 " | version " <<
104 OPENMD_VERSION_MAJOR << "." << OPENMD_VERSION_MINOR << revision <<
105 " http://www.openmd.net |\n"<<
106 " | |\n"<<
107 " | OpenMD is an OpenScience project. All source code is available for any |\n"<<
108 " | use whatsoever under a BSD-style license. |\n"<<
109 " | |\n"<<
110 " | Support OpenScience! If you use OpenMD or its source code in your |\n"<<
111 " | research, please cite the appropriate papers when you publish your work |\n"<<
112 " | Good starting points are: |\n"<<
113 " | |\n"<<
114 " | [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |\n"<<
115 " | [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |\n"<<
116 " | [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |\n"<<
117 " | [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |\n"<<
118 " | [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |\n"<<
119 " | [6] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012). |\n"<<
120 " +--------------------------------------------------------------------------+\n"<<
121 "\n";
122
123 if( argc < 2 ){
124 strcpy( painCave.errMsg, "Error, a meta-data file is needed to run.\n" );
125 painCave.isFatal = 1;
126 simError();
127 }
128 #ifdef IS_MPI
129 }
130 #endif
131
132 strcpy( checkPointMsg, "Successful number of arguments" );
133 errorCheckPoint();
134
135 //register forcefields, integrators and minimizers
136 registerAll();
137
138 //create simulation model
139 SimCreator creator;
140 SimInfo* info = creator.createSim(argv[1]);
141
142 Globals* simParams = info->getSimParams();
143 MinimizerParameters* miniPars = simParams->getMinimizerParameters();
144
145 if (miniPars->haveUseMinimizer() && simParams->haveEnsemble()) {
146 sprintf(painCave.errMsg, "Ensemble keyword can not co-exist with useMinimizer = \"true\" in the minimizer block\n");
147 painCave.isFatal = 1;
148 simError();
149 }
150
151 if (miniPars->haveUseMinimizer()) {
152 //create minimizer
153 OptimizationMethod* myMinimizer =OptimizationFactory::getInstance()->createOptimization(toUpperCopy(miniPars->getMethod()), info);
154
155 if (myMinimizer == NULL) {
156 sprintf(painCave.errMsg, "Optimization Factory can not create %s OptimizationMethod\n",
157 miniPars->getMethod().c_str());
158 painCave.isFatal = 1;
159 simError();
160 }
161
162 ForceManager* fman = new ForceManager(info);
163 fman->initialize();
164
165 PotentialEnergyObjectiveFunction potObjf(info, fman);
166 DumpStatusFunction dsf(info);
167 DynamicVector<RealType> initCoords = potObjf.setInitialCoords();
168 Problem problem(potObjf, *(new NoConstraint()), dsf, initCoords);
169
170
171 int maxIter = miniPars->getMaxIterations();
172 int mssIter = miniPars->getMaxStationaryStateIterations();
173 RealType rEps = miniPars->getRootEpsilon();
174 RealType fEps = miniPars->getFunctionEpsilon();
175 RealType gnEps = miniPars->getGradientNormEpsilon();
176
177 EndCriteria endCriteria(maxIter, mssIter, rEps, fEps, gnEps);
178
179 myMinimizer->minimize(problem, endCriteria);
180
181 delete myMinimizer;
182 } else if (simParams->haveEnsemble()) {
183 //create Integrator
184
185 Integrator* myIntegrator = IntegratorFactory::getInstance()->createIntegrator(toUpperCopy(simParams->getEnsemble()), info);
186
187 if (myIntegrator == NULL) {
188 sprintf(painCave.errMsg, "Integrator Factory can not create %s Integrator\n",
189 simParams->getEnsemble().c_str());
190 painCave.isFatal = 1;
191 simError();
192 }
193
194 //Thermodynamic Integration Method
195 //set the force manager for thermodynamic integration if specified
196 if (simParams->getUseThermodynamicIntegration()){
197 ForceManager* fman = new ThermoIntegrationForceManager(info);
198 myIntegrator->setForceManager(fman);
199 }
200
201 // Restraints
202 if (simParams->getUseRestraints() && !simParams->getUseThermodynamicIntegration()) {
203 ForceManager* fman = new RestraintForceManager(info);
204 myIntegrator->setForceManager(fman);
205 }
206
207 //Zconstraint-Method
208 if (simParams->getNZconsStamps() > 0) {
209 info->setNZconstraint(simParams->getNZconsStamps());
210 ForceManager* fman = new ZconstraintForceManager(info);
211 myIntegrator->setForceManager(fman);
212 }
213
214 myIntegrator->integrate();
215 delete myIntegrator;
216 }else {
217 sprintf(painCave.errMsg, "Integrator Factory can not create %s Integrator\n",
218 simParams->getEnsemble().c_str());
219 painCave.isFatal = 1;
220 simError();
221 }
222
223 delete info;
224
225
226 strcpy( checkPointMsg, "Great googly moogly! It worked!" );
227 errorCheckPoint();
228
229 #ifdef IS_MPI
230 MPI_Finalize();
231 #endif
232
233 return 0 ;
234 }

Properties

Name Value
svn:keywords Revision