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: 1912
Committed: Mon Jan 10 20:52:07 2005 UTC (21 years, 4 months ago) by tim
File size: 6855 byte(s)
Log Message:
zconstraint method is working now

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