ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/openmd/openmd.cpp
Revision: 2064
Committed: Tue Mar 3 17:02:20 2015 UTC (10 years, 2 months ago) by gezelter
File size: 9524 byte(s)
Log Message:
Removed inlining, updated papers & copyright

File Contents

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

Properties

Name Value
svn:keywords Revision