ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/applications/oopse/oopse.cpp
Revision: 1930
Committed: Wed Jan 12 22:41:40 2005 UTC (19 years, 6 months ago) by gezelter
File size: 6795 byte(s)
Log Message:
merging new_design branch into OOPSE-2.0

File Contents

# User Rev Content
1 gezelter 1930 /*
2     * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3     *
4     * The University of Notre Dame grants you ("Licensee") a
5     * non-exclusive, royalty free, license to use, modify and
6     * redistribute this software in source and binary code form, provided
7     * that the following conditions are met:
8     *
9     * 1. Acknowledgement of the program authors must be made in any
10     * publication of scientific results based in part on use of the
11     * program. An acceptable form of acknowledgement is citation of
12     * the article in which the program was described (Matthew
13     * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14     * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15     * Parallel Simulation Engine for Molecular Dynamics,"
16     * J. Comput. Chem. 26, pp. 252-271 (2005))
17     *
18     * 2. Redistributions of source code must retain the above copyright
19     * notice, this list of conditions and the following disclaimer.
20     *
21     * 3. Redistributions in binary form must reproduce the above copyright
22     * notice, this list of conditions and the following disclaimer in the
23     * documentation and/or other materials provided with the
24     * distribution.
25     *
26     * This software is provided "AS IS," without a warranty of any
27     * kind. All express or implied conditions, representations and
28     * warranties, including any implied warranty of merchantability,
29     * fitness for a particular purpose or non-infringement, are hereby
30     * excluded. The University of Notre Dame and its licensors shall not
31     * be liable for any damages suffered by licensee as a result of
32     * using, modifying or distributing the software or its
33     * derivatives. In no event will the University of Notre Dame or its
34     * licensors be liable for any lost revenue, profit or data, or for
35     * direct, indirect, special, consequential, incidental or punitive
36     * damages, however caused and regardless of the theory of liability,
37     * arising out of the use of or inability to use software, even if the
38     * University of Notre Dame has been advised of the possibility of
39     * such damages.
40     */
41    
42 tim 1501 #ifdef IS_MPI
43     #include <mpi.h>
44     #endif
45    
46     #include "utils/simError.h"
47 gezelter 1930 #include "brains/Register.hpp"
48     #include "brains/SimCreator.hpp"
49 tim 1501 #include "brains/SimInfo.hpp"
50 gezelter 1930 #include "constraints/ZconstraintForceManager.hpp"
51     #include "integrators/IntegratorFactory.hpp"
52 tim 1501 #include "integrators/Integrator.hpp"
53 gezelter 1930 #include "minimizers/MinimizerFactory.hpp"
54     #include "minimizers/Minimizer.hpp"
55     using namespace oopse;
56 tim 1501
57     int main(int argc,char* argv[]){
58    
59     // first things first, all of the initializations
60    
61     #ifdef IS_MPI
62     MPI_Init( &argc, &argv ); // the MPI communicators
63     #endif
64    
65     initSimError(); // the error handler
66     srand48( 1337 ); // the random number generator.
67    
68     #ifdef IS_MPI
69     if( worldRank == 0 ){
70     #endif
71     std::cerr <<
72     " +----------------------------------------------------------------------+\n" <<
73     " | ____ ____ ____ _____ ______ The OpenSource, Object-oriented |\n" <<
74     " | / __ \\/ __ \\/ __ \\/ ___// ____/ Parallel Simulation Engine. |\n" <<
75     " | / / / / / / / /_/ /\\__ \\/ __/ |\n" <<
76     " | / /_/ / /_/ / ____/___/ / /___ Copyright 2004 by the |\n" <<
77     " | \\____/\\____/_/ /____/_____/ University of Notre Dame. |\n" <<
78     " | http://www.oopse.org |\n" <<
79     " | |\n" <<
80     " | OOPSE is an OpenScience project. All source code is available for |\n" <<
81     " | any use subject to only one condition: |\n" <<
82     " | |\n" <<
83     " | Any published work resulting from the use of this code must cite the |\n" <<
84     " | following paper: M. A. Meineke, C. F. Vardeman II, T. Lin, |\n" <<
85     " | C. J. Fennell, and J. D. Gezelter, |\n" <<
86     " | J. Comp. Chem. XX, XXXX (2004). |\n" <<
87     " +----------------------------------------------------------------------+\n" <<
88     "\n";
89    
90     if( argc < 2 ){
91     strcpy( painCave.errMsg, "Error, a meta-data file is needed to run.\n" );
92     painCave.isFatal = 1;
93     simError();
94     }
95     #ifdef IS_MPI
96     }
97     #endif
98    
99     #ifdef IS_MPI
100     strcpy( checkPointMsg, "Successful number of arguments" );
101     MPIcheckPoint();
102     #endif
103 gezelter 1930
104    
105    
106     //register forcefields, integrators and minimizers
107     registerAll();
108    
109     //create simulation model
110     SimCreator creator;
111     SimInfo* info = creator.createSim(argv[1]);
112     Globals* simParams = info->getSimParams();
113    
114     if (simParams->haveMinimizer() && simParams->haveEnsemble()) {
115     sprintf(painCave.errMsg, "Minimizer keyword and Ensemble keyword can not exist together\n");
116     painCave.isFatal = 1;
117     simError();
118     }
119 tim 1501
120 gezelter 1930 if (simParams->haveMinimizer()) {
121     //create minimizer
122     Minimizer* myMinimizer = MinimizerFactory::getInstance()->createMinimizer(simParams->getMinimizer(), info);
123 tim 1501
124 gezelter 1930 if (myMinimizer == NULL) {
125     sprintf(painCave.errMsg, "Minimizer Factory can not create %s Minimizer\n",
126     simParams->getMinimizer());
127     painCave.isFatal = 1;
128     simError();
129     }
130 tim 1501
131 gezelter 1930 myMinimizer->minimize();
132     delete myMinimizer;
133     } else if (simParams->haveEnsemble()) {
134     //create Integrator
135 tim 1501
136 gezelter 1930 Integrator* myIntegrator = IntegratorFactory::getInstance()->createIntegrator(simParams->getEnsemble(), info);
137 tim 1501
138 gezelter 1930 if (myIntegrator == NULL) {
139     sprintf(painCave.errMsg, "Integrator Factory can not create %s Integrator\n",
140     simParams->getEnsemble());
141     painCave.isFatal = 1;
142     simError();
143     }
144    
145     //Thermodynamic Integration Method
146     //ForceManager* fman = new ThermodynamicForceManager(info);
147     //myIntegrator->setForceManager(fman);
148 tim 1501
149    
150 gezelter 1930 //Zconstraint-Method
151     if (simParams->haveZconstraints()) {
152     info->setNZconstraint(simParams->getNzConstraints());
153     ForceManager* fman = new ZconstraintForceManager(info);
154     myIntegrator->setForceManager(fman);
155     }
156    
157     myIntegrator->integrate();
158     delete myIntegrator;
159     }else {
160     sprintf(painCave.errMsg, "Integrator Factory can not create %s Integrator\n",
161     simParams->getEnsemble());
162     painCave.isFatal = 1;
163     simError();
164     }
165 tim 1501
166    
167 gezelter 1930
168     delete info;
169 tim 1501
170     #ifdef IS_MPI
171     strcpy( checkPointMsg, "Oh what a lovely Tea Party!" );
172     MPIcheckPoint();
173    
174 gezelter 1930 MPI_Finalize();
175 tim 1501 #endif
176    
177     return 0 ;
178     }