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: 1913
Committed: Mon Jan 10 22:04:20 2005 UTC (21 years, 4 months ago) by tim
File size: 5866 byte(s)
Log Message:
create a register module to register force fields, integrators and minimizers

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 1913 #include "brains/Register.hpp"
32 tim 1775 #include "brains/SimCreator.hpp"
33 tim 1501 #include "brains/SimInfo.hpp"
34 tim 1912 #include "constraints/ZconstraintForceManager.hpp"
35 tim 1775 #include "integrators/IntegratorFactory.hpp"
36 tim 1822 #include "integrators/Integrator.hpp"
37 tim 1903 #include "minimizers/MinimizerFactory.hpp"
38 tim 1913 #include "minimizers/Minimizer.hpp"
39 tim 1822 using namespace oopse;
40 tim 1501
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 tim 1837
88 tim 1843
89 tim 1913
90     //register forcefields, integrators and minimizers
91     registerAll();
92    
93 tim 1775 //create simulation model
94     SimCreator creator;
95     SimInfo* info = creator.createSim(argv[1]);
96 tim 1903 Globals* simParams = info->getSimParams();
97 tim 1501
98 tim 1903 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 tim 1841 Integrator* myIntegrator = IntegratorFactory::getInstance()->createIntegrator(simParams->getEnsemble(), info);
121 tim 1501
122 tim 1843 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 tim 1912
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 tim 1843
141 tim 1822 myIntegrator->integrate();
142     delete myIntegrator;
143 tim 1903 }else {
144     sprintf(painCave.errMsg, "Integrator Factory can not create %s Integrator\n",
145     simParams->getEnsemble());
146     painCave.isFatal = 1;
147     simError();
148 tim 1822 }
149 tim 1903
150    
151 tim 1775
152     delete info;
153 tim 1501
154     #ifdef IS_MPI
155     strcpy( checkPointMsg, "Oh what a lovely Tea Party!" );
156     MPIcheckPoint();
157    
158 tim 1822 MPI_Finalize();
159 tim 1501 #endif
160    
161     return 0 ;
162     }