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 (21 years, 4 months ago) by tim
File size: 6671 byte(s)
Log Message:
simpleBuilder in progress

File Contents

# User Rev Content
1 tim 1890 /*
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 tim 1501 #ifdef IS_MPI
27     #include <mpi.h>
28     #endif
29    
30     #include "utils/simError.h"
31 tim 1775 #include "brains/SimCreator.hpp"
32 tim 1501 #include "brains/SimInfo.hpp"
33 tim 1775 #include "integrators/IntegratorFactory.hpp"
34 tim 1843 #include "integrators/IntegratorCreator.hpp"
35 tim 1822 #include "integrators/Integrator.hpp"
36 tim 1843 #include "integrators/NVE.hpp"
37 tim 1852 #include "integrators/NVT.hpp"
38     #include "integrators/NPTi.hpp"
39     #include "integrators/NPTf.hpp"
40     #include "integrators/NPTxyz.hpp"
41 tim 1903 #include "minimizers/MinimizerFactory.hpp"
42     #include "minimizers/MinimizerCreator.hpp"
43     #include "minimizers/PRCG.hpp"
44     #include "minimizers/SDMinimizer.hpp"
45    
46 tim 1837 #include "UseTheForce/DUFF.hpp"
47 tim 1890 #include "UseTheForce/EAM.hpp"
48 tim 1843 #include "UseTheForce/ForceFieldCreator.hpp"
49    
50 tim 1822 using namespace oopse;
51 tim 1501
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 tim 1837
99 tim 1883 /** @todo move to a seperate initialization module */
100 tim 1890 //DUFF, WATER and LJ are merged into one force field
101 tim 1852 ForceFieldBuilder<DUFF> DUFFCreator("DUFF");
102 tim 1883 ForceFieldBuilder<DUFF> WATERCreator("WATER");
103 tim 1889 ForceFieldBuilder<DUFF> LJCreator("LJ");
104 tim 1890 //in theory, EAM can also be merged
105     ForceFieldBuilder<EAM> EAMCreator("EAM");
106 tim 1889
107 tim 1852 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 tim 1843
113 tim 1903 MinimizerBuilder<SDMinimizer> SDCreator("SD");
114     MinimizerBuilder<PRCGMinimizer> CGCreator("CG");
115    
116 tim 1775 //create simulation model
117     SimCreator creator;
118     SimInfo* info = creator.createSim(argv[1]);
119 tim 1903 Globals* simParams = info->getSimParams();
120 tim 1501
121 tim 1903 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 tim 1841 Integrator* myIntegrator = IntegratorFactory::getInstance()->createIntegrator(simParams->getEnsemble(), info);
144 tim 1822
145     //Thermodynamic Integration Method
146     //ForceManager* fman = new ThermodynamicForceManager(info);
147     //myIntegrator->setForceManager(fman);
148 tim 1501
149    
150 tim 1822 //Zconstraint-Method
151     //ForceManager* fman = new ZconstraintForceManager(info);
152     //myIntegrator->setForceManager(fman);
153 tim 1501
154 tim 1843 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 tim 1822 myIntegrator->integrate();
162     delete myIntegrator;
163 tim 1903 }else {
164     sprintf(painCave.errMsg, "Integrator Factory can not create %s Integrator\n",
165     simParams->getEnsemble());
166     painCave.isFatal = 1;
167     simError();
168 tim 1822 }
169 tim 1903
170    
171 tim 1775
172     delete info;
173 tim 1501
174     #ifdef IS_MPI
175     strcpy( checkPointMsg, "Oh what a lovely Tea Party!" );
176     MPIcheckPoint();
177    
178 tim 1822 MPI_Finalize();
179 tim 1501 #endif
180    
181     return 0 ;
182     }