ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-3.0/src/applications/oopse/oopse.cpp
Revision: 1912
Committed: Mon Jan 10 20:52:07 2005 UTC (19 years, 6 months ago) by tim
File size: 6855 byte(s)
Log Message:
zconstraint method is working now

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