1 |
/* |
2 |
* Copyright (C) 2000-2004 Object Oriented Parallel Simulation Engine (OOPSE) project |
3 |
* |
4 |
* Contact: oopse@oopse.org |
5 |
* |
6 |
* This program is free software; you can redistribute it and/or |
7 |
* modify it under the terms of the GNU Lesser General Public License |
8 |
* as published by the Free Software Foundation; either version 2.1 |
9 |
* of the License, or (at your option) any later version. |
10 |
* All we ask is that proper credit is given for our work, which includes |
11 |
* - but is not limited to - adding the above copyright notice to the beginning |
12 |
* of your source code files, and to any copyright notice that you may distribute |
13 |
* with programs based on this work. |
14 |
* |
15 |
* This program is distributed in the hope that it will be useful, |
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 |
* GNU Lesser General Public License for more details. |
19 |
* |
20 |
* You should have received a copy of the GNU Lesser General Public License |
21 |
* along with this program; if not, write to the Free Software |
22 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23 |
* |
24 |
*/ |
25 |
|
26 |
#ifdef IS_MPI |
27 |
#include <mpi.h> |
28 |
#endif |
29 |
|
30 |
#include "utils/simError.h" |
31 |
#include "brains/Register.hpp" |
32 |
#include "brains/SimCreator.hpp" |
33 |
#include "brains/SimInfo.hpp" |
34 |
#include "constraints/ZconstraintForceManager.hpp" |
35 |
#include "integrators/IntegratorFactory.hpp" |
36 |
#include "integrators/Integrator.hpp" |
37 |
#include "minimizers/MinimizerFactory.hpp" |
38 |
#include "minimizers/Minimizer.hpp" |
39 |
using namespace oopse; |
40 |
|
41 |
int main(int argc,char* argv[]){ |
42 |
|
43 |
// first things first, all of the initializations |
44 |
|
45 |
#ifdef IS_MPI |
46 |
MPI_Init( &argc, &argv ); // the MPI communicators |
47 |
#endif |
48 |
|
49 |
initSimError(); // the error handler |
50 |
srand48( 1337 ); // the random number generator. |
51 |
|
52 |
#ifdef IS_MPI |
53 |
if( worldRank == 0 ){ |
54 |
#endif |
55 |
std::cerr << |
56 |
" +----------------------------------------------------------------------+\n" << |
57 |
" | ____ ____ ____ _____ ______ The OpenSource, Object-oriented |\n" << |
58 |
" | / __ \\/ __ \\/ __ \\/ ___// ____/ Parallel Simulation Engine. |\n" << |
59 |
" | / / / / / / / /_/ /\\__ \\/ __/ |\n" << |
60 |
" | / /_/ / /_/ / ____/___/ / /___ Copyright 2004 by the |\n" << |
61 |
" | \\____/\\____/_/ /____/_____/ University of Notre Dame. |\n" << |
62 |
" | http://www.oopse.org |\n" << |
63 |
" | |\n" << |
64 |
" | OOPSE is an OpenScience project. All source code is available for |\n" << |
65 |
" | any use subject to only one condition: |\n" << |
66 |
" | |\n" << |
67 |
" | Any published work resulting from the use of this code must cite the |\n" << |
68 |
" | following paper: M. A. Meineke, C. F. Vardeman II, T. Lin, |\n" << |
69 |
" | C. J. Fennell, and J. D. Gezelter, |\n" << |
70 |
" | J. Comp. Chem. XX, XXXX (2004). |\n" << |
71 |
" +----------------------------------------------------------------------+\n" << |
72 |
"\n"; |
73 |
|
74 |
if( argc < 2 ){ |
75 |
strcpy( painCave.errMsg, "Error, a meta-data file is needed to run.\n" ); |
76 |
painCave.isFatal = 1; |
77 |
simError(); |
78 |
} |
79 |
#ifdef IS_MPI |
80 |
} |
81 |
#endif |
82 |
|
83 |
#ifdef IS_MPI |
84 |
strcpy( checkPointMsg, "Successful number of arguments" ); |
85 |
MPIcheckPoint(); |
86 |
#endif |
87 |
|
88 |
|
89 |
|
90 |
//register forcefields, integrators and minimizers |
91 |
registerAll(); |
92 |
|
93 |
//create simulation model |
94 |
SimCreator creator; |
95 |
SimInfo* info = creator.createSim(argv[1]); |
96 |
Globals* simParams = info->getSimParams(); |
97 |
|
98 |
if (simParams->haveMinimizer() && simParams->haveEnsemble()) { |
99 |
sprintf(painCave.errMsg, "Minimizer keyword and Ensemble keyword can not exist together\n"); |
100 |
painCave.isFatal = 1; |
101 |
simError(); |
102 |
} |
103 |
|
104 |
if (simParams->haveMinimizer()) { |
105 |
//create minimizer |
106 |
Minimizer* myMinimizer = MinimizerFactory::getInstance()->createMinimizer(simParams->getMinimizer(), info); |
107 |
|
108 |
if (myMinimizer == NULL) { |
109 |
sprintf(painCave.errMsg, "Minimizer Factory can not create %s Minimizer\n", |
110 |
simParams->getMinimizer()); |
111 |
painCave.isFatal = 1; |
112 |
simError(); |
113 |
} |
114 |
|
115 |
myMinimizer->minimize(); |
116 |
delete myMinimizer; |
117 |
} else if (simParams->haveEnsemble()) { |
118 |
//create Integrator |
119 |
|
120 |
Integrator* myIntegrator = IntegratorFactory::getInstance()->createIntegrator(simParams->getEnsemble(), info); |
121 |
|
122 |
if (myIntegrator == NULL) { |
123 |
sprintf(painCave.errMsg, "Integrator Factory can not create %s Integrator\n", |
124 |
simParams->getEnsemble()); |
125 |
painCave.isFatal = 1; |
126 |
simError(); |
127 |
} |
128 |
|
129 |
//Thermodynamic Integration Method |
130 |
//ForceManager* fman = new ThermodynamicForceManager(info); |
131 |
//myIntegrator->setForceManager(fman); |
132 |
|
133 |
|
134 |
//Zconstraint-Method |
135 |
if (simParams->haveZconstraints()) { |
136 |
info->setNZconstraint(simParams->getNzConstraints()); |
137 |
ForceManager* fman = new ZconstraintForceManager(info); |
138 |
myIntegrator->setForceManager(fman); |
139 |
} |
140 |
|
141 |
myIntegrator->integrate(); |
142 |
delete myIntegrator; |
143 |
}else { |
144 |
sprintf(painCave.errMsg, "Integrator Factory can not create %s Integrator\n", |
145 |
simParams->getEnsemble()); |
146 |
painCave.isFatal = 1; |
147 |
simError(); |
148 |
} |
149 |
|
150 |
|
151 |
|
152 |
delete info; |
153 |
|
154 |
#ifdef IS_MPI |
155 |
strcpy( checkPointMsg, "Oh what a lovely Tea Party!" ); |
156 |
MPIcheckPoint(); |
157 |
|
158 |
MPI_Finalize(); |
159 |
#endif |
160 |
|
161 |
return 0 ; |
162 |
} |