| 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, 234107 (2008).           | 
| 39 | 
< | 
 * [4]  Vardeman & Gezelter, in progress (2010).                         | 
| 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 | 
| 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" | 
| 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 | 
  | 
   | 
| 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++ | 
| 94 | 
  | 
  if( worldRank == 0 ){ | 
| 95 | 
  | 
#endif | 
| 96 | 
  | 
    std::cerr <<  | 
| 97 | 
< | 
      "  +-----------------------------------------------------------------------+\n"<< | 
| 98 | 
< | 
      "  |    ____                    __  ___ ____                               |\n"<< | 
| 99 | 
< | 
      "  |   / __ \\____  ___  ____   /  |/  // __ \\  The Open Molecular Dynamics |\n"<< | 
| 100 | 
< | 
      "  |  / / / / __ \\/ _ \\/ __ \\ / /|_/ // / / /  Engine (formerly OOPSE).    |\n"<< | 
| 101 | 
< | 
      "  | / /_/ / /_/ /  __/ / / // /  / // /_/ /                               |\n"<< | 
| 102 | 
< | 
      "  | \\____/ .___/\\___/_/ /_//_/  /_//_____/    Copyright 2004-2010 by the  |\n"<< | 
| 103 | 
< | 
      "  |     /_/                                   University of Notre Dame.   |\n"<< | 
| 104 | 
< | 
      "  |                                                                       |\n"<< | 
| 97 | 
> | 
      "  +--------------------------------------------------------------------------+\n"<< | 
| 98 | 
> | 
      "  |    ____                    __  ___ ____                                  |\n"<< | 
| 99 | 
> | 
      "  |   / __ \\____  ___  ____   /  |/  // __ \\  The Open Molecular Dynamics    |\n"<< | 
| 100 | 
> | 
      "  |  / / / / __ \\/ _ \\/ __ \\ / /|_/ // / / /  Engine (formerly OOPSE).       |\n"<< | 
| 101 | 
> | 
      "  | / /_/ / /_/ /  __/ / / // /  / // /_/ /                                  |\n"<< | 
| 102 | 
> | 
      "  | \\____/ .___/\\___/_/ /_//_/  /_//_____/    Copyright 2004-2012 by the     |\n"<< | 
| 103 | 
> | 
      "  |     /_/                                   University of Notre Dame.      |\n"<< | 
| 104 | 
> | 
      "  |                                                                          |\n"<< | 
| 105 | 
  | 
      "  |        version " <<  | 
| 106 | 
  | 
      OPENMD_VERSION_MAJOR << "." << OPENMD_VERSION_MINOR << revision <<  | 
| 107 | 
< | 
      "     http://www.openmd.net       |\n"<< | 
| 108 | 
< | 
      "  |                                                                       |\n"<< | 
| 109 | 
< | 
      "  | OpenMD is an OpenScience project.  All source code is available for   |\n"<< | 
| 110 | 
< | 
      "  | any use whatsoever under a BSD-style license.                         |\n"<< | 
| 111 | 
< | 
      "  |                                                                       |\n"<< | 
| 112 | 
< | 
      "  | Support OpenScience!  If you use OpenMD or its source code in your    |\n"<< | 
| 113 | 
< | 
      "  | research, please cite the appropriate papers when you publish your    |\n"<< | 
| 114 | 
< | 
      "  | work.  Good starting points are:                                      |\n"<< | 
| 115 | 
< | 
      "  |                                                                       |\n"<< | 
| 116 | 
< | 
      "  | [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).              |\n"<< | 
| 117 | 
< | 
      "  | [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).           |\n"<< | 
| 118 | 
< | 
      "  | [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).          |\n"<< | 
| 119 | 
< | 
      "  | [4]  Vardeman & Gezelter, in progress (2010).                         |\n"<< | 
| 120 | 
< | 
      "  +-----------------------------------------------------------------------+\n"<< | 
| 107 | 
> | 
      "     http://www.openmd.net          |\n"<< | 
| 108 | 
> | 
      "  |                                                                          |\n"<< | 
| 109 | 
> | 
      "  | OpenMD is an OpenScience project.  All source code is available for any  |\n"<< | 
| 110 | 
> | 
      "  | use whatsoever under a BSD-style license.                                |\n"<< | 
| 111 | 
> | 
      "  |                                                                          |\n"<< | 
| 112 | 
> | 
      "  | Support OpenScience!  If you use OpenMD or its source code in your       |\n"<< | 
| 113 | 
> | 
      "  | research, please cite the appropriate papers when you publish your work  |\n"<< | 
| 114 | 
> | 
      "  | Good starting points are:                                                |\n"<< | 
| 115 | 
> | 
      "  |                                                                          |\n"<< | 
| 116 | 
> | 
      "  | [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).                  |\n"<< | 
| 117 | 
> | 
      "  | [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).               |\n"<< | 
| 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 | 
  | 
     | 
| 125 | 
  | 
    if( argc < 2 ){ | 
| 140 | 
  | 
  //create simulation model | 
| 141 | 
  | 
  SimCreator creator; | 
| 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 | 
  | 
  } | 
| 152 | 
< | 
     | 
| 153 | 
< | 
  if (simParams->haveMinimizer()) { | 
| 152 | 
> | 
 | 
| 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 | 
| 187 | 
  | 
    Integrator* myIntegrator = IntegratorFactory::getInstance()->createIntegrator(toUpperCopy(simParams->getEnsemble()), info); | 
| 188 | 
  | 
  | 
| 189 | 
  | 
    if (myIntegrator == NULL) { | 
| 190 | 
< | 
      sprintf(painCave.errMsg, "Integrator Factory cannot create %s Integrator\n", | 
| 190 | 
> | 
      sprintf(painCave.errMsg, "Integrator Factory can not create %s Integrator\n", | 
| 191 | 
  | 
              simParams->getEnsemble().c_str()); | 
| 192 | 
  | 
      painCave.isFatal = 1; | 
| 193 | 
  | 
      simError(); |