ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-4/src/applications/oopse/oopse.cpp
Revision: 1903
Committed: Thu Jan 6 00:16:07 2005 UTC (19 years, 7 months ago) by tim
File size: 6671 byte(s)
Log Message:
simpleBuilder in progress

File Contents

# Content
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/SimCreator.hpp"
32 #include "brains/SimInfo.hpp"
33 #include "integrators/IntegratorFactory.hpp"
34 #include "integrators/IntegratorCreator.hpp"
35 #include "integrators/Integrator.hpp"
36 #include "integrators/NVE.hpp"
37 #include "integrators/NVT.hpp"
38 #include "integrators/NPTi.hpp"
39 #include "integrators/NPTf.hpp"
40 #include "integrators/NPTxyz.hpp"
41 #include "minimizers/MinimizerFactory.hpp"
42 #include "minimizers/MinimizerCreator.hpp"
43 #include "minimizers/PRCG.hpp"
44 #include "minimizers/SDMinimizer.hpp"
45
46 #include "UseTheForce/DUFF.hpp"
47 #include "UseTheForce/EAM.hpp"
48 #include "UseTheForce/ForceFieldCreator.hpp"
49
50 using namespace oopse;
51
52 int main(int argc,char* argv[]){
53
54 // first things first, all of the initializations
55
56 #ifdef IS_MPI
57 MPI_Init( &argc, &argv ); // the MPI communicators
58 #endif
59
60 initSimError(); // the error handler
61 srand48( 1337 ); // the random number generator.
62
63 #ifdef IS_MPI
64 if( worldRank == 0 ){
65 #endif
66 std::cerr <<
67 " +----------------------------------------------------------------------+\n" <<
68 " | ____ ____ ____ _____ ______ The OpenSource, Object-oriented |\n" <<
69 " | / __ \\/ __ \\/ __ \\/ ___// ____/ Parallel Simulation Engine. |\n" <<
70 " | / / / / / / / /_/ /\\__ \\/ __/ |\n" <<
71 " | / /_/ / /_/ / ____/___/ / /___ Copyright 2004 by the |\n" <<
72 " | \\____/\\____/_/ /____/_____/ University of Notre Dame. |\n" <<
73 " | http://www.oopse.org |\n" <<
74 " | |\n" <<
75 " | OOPSE is an OpenScience project. All source code is available for |\n" <<
76 " | any use subject to only one condition: |\n" <<
77 " | |\n" <<
78 " | Any published work resulting from the use of this code must cite the |\n" <<
79 " | following paper: M. A. Meineke, C. F. Vardeman II, T. Lin, |\n" <<
80 " | C. J. Fennell, and J. D. Gezelter, |\n" <<
81 " | J. Comp. Chem. XX, XXXX (2004). |\n" <<
82 " +----------------------------------------------------------------------+\n" <<
83 "\n";
84
85 if( argc < 2 ){
86 strcpy( painCave.errMsg, "Error, a meta-data file is needed to run.\n" );
87 painCave.isFatal = 1;
88 simError();
89 }
90 #ifdef IS_MPI
91 }
92 #endif
93
94 #ifdef IS_MPI
95 strcpy( checkPointMsg, "Successful number of arguments" );
96 MPIcheckPoint();
97 #endif
98
99 /** @todo move to a seperate initialization module */
100 //DUFF, WATER and LJ are merged into one force field
101 ForceFieldBuilder<DUFF> DUFFCreator("DUFF");
102 ForceFieldBuilder<DUFF> WATERCreator("WATER");
103 ForceFieldBuilder<DUFF> LJCreator("LJ");
104 //in theory, EAM can also be merged
105 ForceFieldBuilder<EAM> EAMCreator("EAM");
106
107 IntegratorBuilder<NVE> NVECreator("NVE");
108 IntegratorBuilder<NVT> NVTCreator("NVT");
109 IntegratorBuilder<NPTi> NPTiCreator("NPTi");
110 IntegratorBuilder<NPTf> NPTfCreator("NPTf");
111 IntegratorBuilder<NPTxyz> NPTxyzCreator("NPTxyz");
112
113 MinimizerBuilder<SDMinimizer> SDCreator("SD");
114 MinimizerBuilder<PRCGMinimizer> CGCreator("CG");
115
116 //create simulation model
117 SimCreator creator;
118 SimInfo* info = creator.createSim(argv[1]);
119 Globals* simParams = info->getSimParams();
120
121 if (simParams->haveMinimizer() && simParams->haveEnsemble()) {
122 sprintf(painCave.errMsg, "Minimizer keyword and Ensemble keyword can not exist together\n");
123 painCave.isFatal = 1;
124 simError();
125 }
126
127 if (simParams->haveMinimizer()) {
128 //create minimizer
129 Minimizer* myMinimizer = MinimizerFactory::getInstance()->createMinimizer(simParams->getMinimizer(), info);
130
131 if (myMinimizer == NULL) {
132 sprintf(painCave.errMsg, "Minimizer Factory can not create %s Minimizer\n",
133 simParams->getMinimizer());
134 painCave.isFatal = 1;
135 simError();
136 }
137
138 myMinimizer->minimize();
139 delete myMinimizer;
140 } else if (simParams->haveEnsemble()) {
141 //create Integrator
142
143 Integrator* myIntegrator = IntegratorFactory::getInstance()->createIntegrator(simParams->getEnsemble(), info);
144
145 //Thermodynamic Integration Method
146 //ForceManager* fman = new ThermodynamicForceManager(info);
147 //myIntegrator->setForceManager(fman);
148
149
150 //Zconstraint-Method
151 //ForceManager* fman = new ZconstraintForceManager(info);
152 //myIntegrator->setForceManager(fman);
153
154 if (myIntegrator == NULL) {
155 sprintf(painCave.errMsg, "Integrator Factory can not create %s Integrator\n",
156 simParams->getEnsemble());
157 painCave.isFatal = 1;
158 simError();
159 }
160
161 myIntegrator->integrate();
162 delete myIntegrator;
163 }else {
164 sprintf(painCave.errMsg, "Integrator Factory can not create %s Integrator\n",
165 simParams->getEnsemble());
166 painCave.isFatal = 1;
167 simError();
168 }
169
170
171
172 delete info;
173
174 #ifdef IS_MPI
175 strcpy( checkPointMsg, "Oh what a lovely Tea Party!" );
176 MPIcheckPoint();
177
178 MPI_Finalize();
179 #endif
180
181 return 0 ;
182 }