# | Line 36 | Line 36 | |
---|---|---|
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, 234107 (2008). | |
39 | < | * [4] Vardeman & Gezelter, in progress (2010). |
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 | |
# | Line 44 | Line 46 | |
46 | #endif | |
47 | ||
48 | #include <fstream> | |
49 | + | #include <iostream> |
50 | + | #include <locale> |
51 | #include "utils/simError.h" | |
52 | #include "utils/CaseConversion.hpp" | |
53 | + | #include "utils/Revision.hpp" |
54 | #include "brains/Register.hpp" | |
55 | #include "brains/SimCreator.hpp" | |
56 | #include "brains/SimInfo.hpp" | |
# | Line 53 | Line 58 | |
58 | #include "restraints/RestraintForceManager.hpp" | |
59 | #include "integrators/IntegratorFactory.hpp" | |
60 | #include "integrators/Integrator.hpp" | |
61 | < | #include "minimizers/MinimizerFactory.hpp" |
62 | < | #include "minimizers/Minimizer.hpp" |
61 | > | #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 | #include "restraints/ThermoIntegrationForceManager.hpp" | |
67 | ||
68 | using namespace OpenMD; | |
69 | + | using namespace QuantLib; |
70 | ||
71 | < | |
63 | < | int main(int argc,char* argv[]){ |
71 | > | int main(int argc, char* argv[]){ |
72 | ||
73 | // first things first, all of the initializations | |
74 | ||
# | Line 69 | Line 77 | int main(int argc,char* argv[]){ | |
77 | #endif | |
78 | ||
79 | initSimError(); // the error handler | |
80 | < | srand48( 1337 ); // the random number generator. |
81 | < | |
80 | > | //srand48( 1337 ); // the random number generator. |
81 | > | |
82 | > | std::string svnrev(g_REVISION, strnlen(g_REVISION, 20)); |
83 | > | //convert a macro from compiler to a string in c++ |
84 | > | //STR_DEFINE(svnrev, SVN_REV ); |
85 | > | |
86 | > | std::string revision; |
87 | > | |
88 | > | if (!svnrev.empty()) { |
89 | > | revision.assign(" Revision: " + svnrev); |
90 | > | } |
91 | > | |
92 | > | revision.resize(19,' '); |
93 | > | |
94 | #ifdef IS_MPI | |
95 | if( worldRank == 0 ){ | |
96 | #endif | |
97 | std::cerr << | |
98 | < | " +-----------------------------------------------------------------------+\n"<< |
99 | < | " | ____ __ ___ ____ |\n"<< |
100 | < | " | / __ \\____ ___ ____ / |/ // __ \\ The Open Molecular Dynamics |\n"<< |
101 | < | " | / / / / __ \\/ _ \\/ __ \\ / /|_/ // / / / Engine (formerly OOPSE). |\n"<< |
102 | < | " | / /_/ / /_/ / __/ / / // / / // /_/ / |\n"<< |
103 | < | " | \\____/ .___/\\___/_/ /_//_/ /_//_____/ Copyright 2004-2010 by the |\n"<< |
104 | < | " | /_/ University of Notre Dame. |\n"<< |
105 | < | " | |\n"<< |
106 | < | " | version " << |
107 | < | OPENMD_VERSION_MAJOR << "." << OPENMD_VERSION_MINOR << " Rev:" << __get_svn_version() << |
108 | < | " http://www.openmd.net |\n"<< |
109 | < | " | |\n"<< |
110 | < | " | OpenMD is an OpenScience project. All source code is available for |\n"<< |
111 | < | " | any 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 | < | " | research, please cite the appropriate papers when you publish your |\n"<< |
115 | < | " | work. Good starting points are: |\n"<< |
116 | < | " | |\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 | < | " | [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). |\n"<< |
120 | < | " | [4] Vardeman & Gezelter, in progress (2010). |\n"<< |
121 | < | " +-----------------------------------------------------------------------+\n"<< |
98 | > | " +--------------------------------------------------------------------------+\n"<< |
99 | > | " | ____ __ ___ ____ |\n"<< |
100 | > | " | / __ \\____ ___ ____ / |/ // __ \\ The Open Molecular Dynamics |\n"<< |
101 | > | " | / / / / __ \\/ _ \\/ __ \\ / /|_/ // / / / Engine (formerly OOPSE). |\n"<< |
102 | > | " | / /_/ / /_/ / __/ / / // / / // /_/ / |\n"<< |
103 | > | " | \\____/ .___/\\___/_/ /_//_/ /_//_____/ Copyright 2004-2014 by the |\n"<< |
104 | > | " | /_/ University of Notre Dame. |\n"<< |
105 | > | " | |\n"<< |
106 | > | " | version " << |
107 | > | OPENMD_VERSION_MAJOR << "." << OPENMD_VERSION_MINOR << revision << |
108 | > | " http://www.openmd.org |\n"<< |
109 | > | " | |\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 | > | " | research, please cite the appropriate papers when you publish your work |\n"<< |
115 | > | " | Good starting points are: |\n"<< |
116 | > | " | |\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 | > | " | [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). |\n"<< |
120 | > | " | [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |\n"<< |
121 | > | " | [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |\n"<< |
122 | > | " | [6] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012). |\n"<< |
123 | > | " +--------------------------------------------------------------------------+\n"<< |
124 | "\n"; | |
125 | ||
126 | if( argc < 2 ){ | |
# | Line 119 | Line 141 | int main(int argc,char* argv[]){ | |
141 | //create simulation model | |
142 | SimCreator creator; | |
143 | SimInfo* info = creator.createSim(argv[1]); | |
144 | + | |
145 | Globals* simParams = info->getSimParams(); | |
146 | + | MinimizerParameters* miniPars = simParams->getMinimizerParameters(); |
147 | ||
148 | < | if (simParams->haveMinimizer() && simParams->haveEnsemble()) { |
149 | < | sprintf(painCave.errMsg, "Minimizer keyword and Ensemble keyword can not exist together\n"); |
148 | > | if (miniPars->getUseMinimizer() && simParams->haveEnsemble()) { |
149 | > | sprintf(painCave.errMsg, "Ensemble keyword can not co-exist with useMinimizer = \"true\" in the minimizer block\n"); |
150 | painCave.isFatal = 1; | |
151 | simError(); | |
152 | } | |
153 | < | |
154 | < | if (simParams->haveMinimizer()) { |
153 | > | |
154 | > | if (miniPars->getUseMinimizer()) { |
155 | //create minimizer | |
156 | < | Minimizer* myMinimizer = MinimizerFactory::getInstance()->createMinimizer(toUpperCopy(simParams->getMinimizer()), info); |
156 | > | OptimizationMethod* myMinimizer =OptimizationFactory::getInstance()->createOptimization(toUpperCopy(miniPars->getMethod()), info); |
157 | ||
158 | if (myMinimizer == NULL) { | |
159 | < | sprintf(painCave.errMsg, "Minimizer Factory can not create %s Minimizer\n", |
160 | < | simParams->getMinimizer().c_str()); |
159 | > | sprintf(painCave.errMsg, "Optimization Factory can not create %s OptimizationMethod\n", |
160 | > | miniPars->getMethod().c_str()); |
161 | painCave.isFatal = 1; | |
162 | simError(); | |
163 | } | |
164 | ||
165 | < | myMinimizer->minimize(); |
165 | > | ForceManager* fman = new ForceManager(info); |
166 | > | fman->initialize(); |
167 | > | |
168 | > | PotentialEnergyObjectiveFunction potObjf(info, fman); |
169 | > | DumpStatusFunction dsf(info); |
170 | > | DynamicVector<RealType> initCoords = potObjf.setInitialCoords(); |
171 | > | Problem problem(potObjf, *(new NoConstraint()), dsf, initCoords); |
172 | > | |
173 | > | |
174 | > | int maxIter = miniPars->getMaxIterations(); |
175 | > | int mssIter = miniPars->getMaxStationaryStateIterations(); |
176 | > | RealType rEps = miniPars->getRootEpsilon(); |
177 | > | RealType fEps = miniPars->getFunctionEpsilon(); |
178 | > | RealType gnEps = miniPars->getGradientNormEpsilon(); |
179 | > | |
180 | > | EndCriteria endCriteria(maxIter, mssIter, rEps, fEps, gnEps); |
181 | > | |
182 | > | myMinimizer->minimize(problem, endCriteria); |
183 | > | |
184 | delete myMinimizer; | |
185 | } else if (simParams->haveEnsemble()) { | |
186 | //create Integrator | |
# | Line 193 | Line 235 | int main(int argc,char* argv[]){ | |
235 | ||
236 | return 0 ; | |
237 | } | |
196 | – | |
197 | – | extern "C" { |
198 | – | |
199 | – | char svnVersionString[1024]; |
200 | – | char* __get_svn_version(){ |
201 | – | int howMuchToCopy=0; |
202 | – | char *theVersion="$Revision$"; |
203 | – | howMuchToCopy=strlen(theVersion+11) - 2; |
204 | – | assert(howMuchToCopy>0); |
205 | – | memcpy(svnVersionString, theVersion+11, howMuchToCopy); |
206 | – | svnVersionString[howMuchToCopy] = '\0'; |
207 | – | return svnVersionString; |
208 | – | } |
209 | – | |
210 | – | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |