ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/applications/openmd/openmd.cpp
(Generate patch)

Comparing branches/development/src/applications/openmd/openmd.cpp (file contents):
Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC vs.
Revision 1794 by gezelter, Thu Sep 6 19:44:06 2012 UTC

# Line 38 | Line 38
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
# Line 45 | 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 "brains/Register.hpp"
# Line 54 | Line 57
57   #include "restraints/RestraintForceManager.hpp"
58   #include "integrators/IntegratorFactory.hpp"
59   #include "integrators/Integrator.hpp"
60 < #include "minimizers/MinimizerFactory.hpp"
61 < #include "minimizers/Minimizer.hpp"
60 > #include "optimization/OptimizationFactory.hpp"
61 > #include "optimization/Method.hpp"
62 > #include "optimization/Constraint.hpp"
63 > #include "optimization/Problem.hpp"
64 > #include "optimization/PotentialEnergyObjectiveFunction.hpp"
65   #include "restraints/ThermoIntegrationForceManager.hpp"
66  
67   using namespace OpenMD;
68 + using namespace QuantLib;
69  
70   int main(int argc,char* argv[]){
71    
# Line 69 | Line 76 | int main(int argc,char* argv[]){
76   #endif
77    
78    initSimError();           // the error handler
79 <  srand48( 1337 );          // the random number generator.
79 >  //srand48( 1337 );          // the random number generator.
80  
81    std::string svnrev;
82    //convert a macro from compiler to a string in c++
# Line 92 | Line 99 | int main(int argc,char* argv[]){
99        "  |   / __ \\____  ___  ____   /  |/  // __ \\  The Open Molecular Dynamics    |\n"<<
100        "  |  / / / / __ \\/ _ \\/ __ \\ / /|_/ // / / /  Engine (formerly OOPSE).       |\n"<<
101        "  | / /_/ / /_/ /  __/ / / // /  / // /_/ /                                  |\n"<<
102 <      "  | \\____/ .___/\\___/_/ /_//_/  /_//_____/    Copyright 2004-2011 by the     |\n"<<
102 >      "  | \\____/ .___/\\___/_/ /_//_/  /_//_____/    Copyright 2004-2012 by the     |\n"<<
103        "  |     /_/                                   University of Notre Dame.      |\n"<<
104        "  |                                                                          |\n"<<
105        "  |        version " <<
# Line 111 | Line 118 | int main(int argc,char* argv[]){
118        "  | [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).               |\n"<<
119        "  | [4] Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).                |\n"<<
120        "  | [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |\n"<<
121 +      "  | [6] Kuang & Gezelter, Mol. Phys., 110, 691-701 (2012).                   |\n"<<
122        "  +--------------------------------------------------------------------------+\n"<<
123        "\n";
124      
# Line 134 | Line 142 | int main(int argc,char* argv[]){
142    SimInfo* info = creator.createSim(argv[1]);
143  
144    Globals* simParams = info->getSimParams();
145 +  MinimizerParameters* miniPars = simParams->getMinimizerParameters();
146  
147 <  if (simParams->haveMinimizer() && simParams->haveEnsemble()) {
148 <    sprintf(painCave.errMsg, "Minimizer keyword and Ensemble keyword can not exist together\n");
147 >  if (miniPars->getUseMinimizer() && simParams->haveEnsemble()) {
148 >    sprintf(painCave.errMsg, "Ensemble keyword can not co-exist with useMinimizer = \"true\" in the minimizer block\n");
149      painCave.isFatal = 1;
150      simError();        
151    }
143  
152  
153 <  if (simParams->haveMinimizer()) {
153 >  if (miniPars->getUseMinimizer()) {
154      //create minimizer
155 <    Minimizer* myMinimizer = MinimizerFactory::getInstance()->createMinimizer(toUpperCopy(simParams->getMinimizer()), info);
155 >    OptimizationMethod* myMinimizer =OptimizationFactory::getInstance()->createOptimization(toUpperCopy(miniPars->getMethod()), info);
156  
157      if (myMinimizer == NULL) {
158 <      sprintf(painCave.errMsg, "Minimizer Factory can not create %s Minimizer\n",
159 <              simParams->getMinimizer().c_str());
158 >      sprintf(painCave.errMsg, "Optimization Factory can not create %s OptimizationMethod\n",
159 >              miniPars->getMethod().c_str());
160        painCave.isFatal = 1;
161        simError();
162      }
163  
164 <    myMinimizer->minimize();
164 >    ForceManager* fman = new ForceManager(info);      
165 >    fman->initialize();
166 >
167 >    PotentialEnergyObjectiveFunction potObjf(info, fman);
168 >    DumpStatusFunction dsf(info);
169 >    DynamicVector<RealType> initCoords = potObjf.setInitialCoords();
170 >    Problem problem(potObjf, *(new NoConstraint()), dsf, initCoords);
171 >
172 >
173 >    int maxIter = miniPars->getMaxIterations();
174 >    int mssIter = miniPars->getMaxStationaryStateIterations();
175 >    RealType rEps = miniPars->getRootEpsilon();
176 >    RealType fEps = miniPars->getFunctionEpsilon();
177 >    RealType gnEps = miniPars->getGradientNormEpsilon();
178 >
179 >    EndCriteria endCriteria(maxIter, mssIter, rEps, fEps, gnEps);
180 >
181 >    myMinimizer->minimize(problem, endCriteria);
182 >
183      delete myMinimizer;
184    } else if (simParams->haveEnsemble()) {
185      //create Integrator

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines