ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/applications/staticProps/StaticProps.cpp
Revision: 1601
Committed: Thu Aug 4 20:04:35 2011 UTC (13 years, 8 months ago) by gezelter
File size: 11492 byte(s)
Log Message:
removed spurious prints, fixed one bug, but there's still a parallel problem

File Contents

# User Rev Content
1 gezelter 507 /*
2 tim 310 * 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 gezelter 1390 * 1. Redistributions of source code must retain the above copyright
10 tim 310 * notice, this list of conditions and the following disclaimer.
11     *
12 gezelter 1390 * 2. Redistributions in binary form must reproduce the above copyright
13 tim 310 * notice, this list of conditions and the following disclaimer in the
14     * documentation and/or other materials provided with the
15     * distribution.
16     *
17     * This software is provided "AS IS," without a warranty of any
18     * kind. All express or implied conditions, representations and
19     * warranties, including any implied warranty of merchantability,
20     * fitness for a particular purpose or non-infringement, are hereby
21     * excluded. The University of Notre Dame and its licensors shall not
22     * be liable for any damages suffered by licensee as a result of
23     * using, modifying or distributing the software or its
24     * derivatives. In no event will the University of Notre Dame or its
25     * licensors be liable for any lost revenue, profit or data, or for
26     * direct, indirect, special, consequential, incidental or punitive
27     * damages, however caused and regardless of the theory of liability,
28     * arising out of the use of or inability to use software, even if the
29     * University of Notre Dame has been advised of the possibility of
30     * such damages.
31 gezelter 1390 *
32     * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
33     * research, please cite the appropriate papers when you publish your
34     * work. Good starting points are:
35     *
36     * [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).
37     * [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).
38     * [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).
39     * [4] Vardeman & Gezelter, in progress (2009).
40 tim 310 */
41    
42     #include <iostream>
43     #include <fstream>
44     #include <string>
45    
46     #include "brains/Register.hpp"
47     #include "brains/SimCreator.hpp"
48     #include "brains/SimInfo.hpp"
49     #include "io/DumpReader.hpp"
50     #include "utils/simError.h"
51    
52 tim 311 #include "applications/staticProps/StaticPropsCmd.h"
53 tim 543 #include "applications/staticProps/StaticAnalyser.hpp"
54 tim 311 #include "applications/staticProps/GofR.hpp"
55 xsun 1213 #include "applications/staticProps/GofZ.hpp"
56 gezelter 1440 #include "applications/staticProps/GofRZ.hpp"
57 tim 311 #include "applications/staticProps/GofRAngle.hpp"
58     #include "applications/staticProps/GofAngle2.hpp"
59     #include "applications/staticProps/GofXyz.hpp"
60 gezelter 1454 #include "applications/staticProps/TwoDGofR.hpp"
61 tim 543 #include "applications/staticProps/P2OrderParameter.hpp"
62 gezelter 1039 #include "applications/staticProps/BondOrderParameter.hpp"
63 chuckv 1128 #include "applications/staticProps/BOPofR.hpp"
64 xsun 980 #include "applications/staticProps/RippleOP.hpp"
65 tim 544 #include "applications/staticProps/SCDOrderParameter.hpp"
66 tim 545 #include "applications/staticProps/DensityPlot.hpp"
67 tim 840 #include "applications/staticProps/RhoZ.hpp"
68 gezelter 1413 #include "applications/staticProps/pAngle.hpp"
69 chuckv 1180 #include "applications/staticProps/BondAngleDistribution.hpp"
70     #include "applications/staticProps/NanoVolume.hpp"
71 gezelter 957 #if defined(HAVE_FFTW_H) || defined(HAVE_DFFTW_H) || defined(HAVE_FFTW3_H)
72 xsun 955 #include "applications/staticProps/Hxy.hpp"
73 gezelter 956 #endif
74 chuckv 1091 #include "applications/staticProps/RhoR.hpp"
75 tim 311
76 gezelter 1390 using namespace OpenMD;
77 tim 310
78     int main(int argc, char* argv[]){
79    
80 chuckv 1445 //register force fields
81     registerForceFields();
82 tim 310
83 chuckv 1445 gengetopt_args_info args_info;
84 tim 310
85 chuckv 1445 //parse the command line option
86     if (cmdline_parser (argc, argv, &args_info) != 0) {
87     exit(1) ;
88     }
89 tim 310
90 chuckv 1445 //get the dumpfile name
91     std::string dumpFileName = args_info.input_arg;
92     std::string sele1;
93     std::string sele2;
94     bool userSpecifiedSelect1;
95     bool userSpecifiedSelect2;
96 tim 310
97 chuckv 1445 // check the first selection argument, or set it to the environment
98     // variable, or failing that, set it to "select all"
99 gezelter 1039
100 chuckv 1445 if (args_info.sele1_given) {
101     sele1 = args_info.sele1_arg;
102 gezelter 1039 } else {
103 chuckv 1445 char* sele1Env= getenv("SELECTION1");
104     if (sele1Env) {
105     sele1 = sele1Env;
106     } else {
107     sele1 = "select all";
108     }
109 tim 310 }
110 gezelter 1039
111 chuckv 1445 // check the second selection argument, or set it to the environment
112     // variable, or failing that, set it to "select all"
113 gezelter 1039
114 chuckv 1445 if (args_info.sele2_given) {
115     sele2 = args_info.sele2_arg;
116     } else {
117     char* sele2Env = getenv("SELECTION1");
118     if (sele2Env) {
119     sele2 = sele2Env;
120     } else {
121     sele2 = "select all";
122     }
123 tim 311 }
124 tim 310
125 gezelter 1039
126 chuckv 1445 // Problems if sele1 wasn't specified, but
127 gezelter 1039 // if (!args_info.scd_given) {
128     // sprintf( painCave.errMsg,
129 gezelter 1390 // "neither --sele1 option nor $SELECTION1 is set");
130     // painCave.severity = OPENMD_ERROR;
131 gezelter 1039 // painCave.isFatal = 1;
132     // simError();
133     // }
134     // }
135    
136 chuckv 1445 // Problems if sele1 wasn't specified
137 gezelter 1039
138     // if(!args_info.scd_given && !args_info.density_given && !args_info.slab_density_given) {
139     // sprintf( painCave.errMsg,
140 gezelter 1390 // "neither --sele2 option nor $SELECTION1 is set");
141     // painCave.severity = OPENMD_ERROR;
142 gezelter 1039 // painCave.isFatal = 1;
143     // simError();
144     // }
145     // }
146    
147 chuckv 1445 bool batchMode;
148     if (args_info.scd_given){
149     if (args_info.sele1_given && args_info.sele2_given && args_info.sele3_given) {
150     batchMode = false;
151     } else if (args_info.molname_given && args_info.begin_given && args_info.end_given) {
152     if (args_info.begin_arg < 0 || args_info.end_arg < 0 || args_info.begin_arg > args_info.end_arg-2) {
153     sprintf( painCave.errMsg,
154     "below conditions are not satisfied:\n"
155     "0 <= begin && 0<= end && begin <= end-2\n");
156     painCave.severity = OPENMD_ERROR;
157     painCave.isFatal = 1;
158     simError();
159     }
160     batchMode = true;
161     } else{
162     sprintf( painCave.errMsg,
163     "either --sele1, --sele2, --sele3 are specified,"
164     " or --molname, --begin, --end are specified\n");
165     painCave.severity = OPENMD_ERROR;
166     painCave.isFatal = 1;
167     simError();
168 tim 544
169 chuckv 1445 }
170 tim 544 }
171    
172 chuckv 1445 //parse md file and set up the system
173     SimCreator creator;
174     SimInfo* info = creator.createSim(dumpFileName);
175 tim 311
176 chuckv 1445 RealType maxLen;
177     RealType zmaxLen;
178     if (args_info.length_given) {
179     maxLen = args_info.length_arg;
180     if (args_info.zlength_given){
181     zmaxLen = args_info.zlength_arg;
182     }
183     } else {
184     Mat3x3d hmat = info->getSnapshotManager()->getCurrentSnapshot()->getHmat();
185     maxLen = std::min(std::min(hmat(0, 0), hmat(1, 1)), hmat(2, 2)) /2.0;
186     zmaxLen = hmat(2,2);
187     }
188 gezelter 507
189 chuckv 1445 StaticAnalyser* analyser;
190     if (args_info.gofr_given){
191     analyser= new GofR(info, dumpFileName, sele1, sele2, maxLen,
192     args_info.nbins_arg);
193     } else if (args_info.gofz_given) {
194     analyser= new GofZ(info, dumpFileName, sele1, sele2, maxLen,
195     args_info.nbins_arg);
196     } else if (args_info.r_z_given) {
197     analyser = new GofRZ(info, dumpFileName, sele1, sele2, maxLen, zmaxLen,
198 gezelter 1440 args_info.nbins_arg, args_info.nbins_z_arg);
199 chuckv 1445 } else if (args_info.r_theta_given) {
200     analyser = new GofRTheta(info, dumpFileName, sele1, sele2, maxLen,
201     args_info.nbins_arg, args_info.nanglebins_arg);
202     } else if (args_info.r_omega_given) {
203     analyser = new GofROmega(info, dumpFileName, sele1, sele2, maxLen,
204     args_info.nbins_arg, args_info.nanglebins_arg);
205     } else if (args_info.theta_omega_given) {
206     analyser = new GofAngle2(info, dumpFileName, sele1, sele2,
207     args_info.nanglebins_arg);
208     } else if (args_info.gxyz_given) {
209     if (args_info.refsele_given) {
210     analyser= new GofXyz(info, dumpFileName, sele1, sele2,args_info.refsele_arg,
211     maxLen, args_info.nbins_arg);
212     } else {
213     sprintf( painCave.errMsg,
214     "--refsele must set when --gxyz is used");
215     painCave.severity = OPENMD_ERROR;
216     painCave.isFatal = 1;
217     simError();
218     }
219 gezelter 1454 } else if (args_info.twodgofr_given){
220     if (args_info.dz_given) {
221     analyser= new TwoDGofR(info, dumpFileName, sele1, sele2, maxLen,
222     args_info.dz_arg, args_info.nbins_arg);
223     } else {
224     sprintf( painCave.errMsg,
225     "A slab width (dz) must be specified when calculating TwoDGofR");
226     painCave.severity = OPENMD_ERROR;
227     painCave.isFatal = 1;
228     simError();
229     }
230 chuckv 1445 } else if (args_info.p2_given) {
231     analyser = new P2OrderParameter(info, dumpFileName, sele1, sele2);
232     } else if (args_info.rp2_given){
233     analyser = new RippleOP(info, dumpFileName, sele1, sele2);
234     } else if (args_info.bo_given){
235     if (args_info.rcut_given) {
236     analyser = new BondOrderParameter(info, dumpFileName, sele1,
237     args_info.rcut_arg,
238     args_info.nbins_arg);
239     } else {
240     sprintf( painCave.errMsg,
241     "A cutoff radius (rcut) must be specified when calculating Bond Order Parameters");
242     painCave.severity = OPENMD_ERROR;
243     painCave.isFatal = 1;
244     simError();
245     }
246     } else if (args_info.bor_given){
247     if (args_info.rcut_given) {
248     analyser = new BOPofR(info, dumpFileName, sele1, args_info.rcut_arg,
249     args_info.nbins_arg, maxLen);
250     } else {
251     sprintf( painCave.errMsg,
252     "A cutoff radius (rcut) must be specified when calculating Bond Order Parameters");
253     painCave.severity = OPENMD_ERROR;
254     painCave.isFatal = 1;
255     simError();
256     }
257     } else if (args_info.bad_given){
258     if (args_info.rcut_given) {
259     analyser = new BondAngleDistribution(info, dumpFileName, sele1, args_info.rcut_arg,
260     args_info.nbins_arg);
261     } else {
262     sprintf( painCave.errMsg,
263     "A cutoff radius (rcut) must be specified when calculating Bond Angle Distributions");
264     painCave.severity = OPENMD_ERROR;
265     painCave.isFatal = 1;
266     simError();
267     }
268     } else if (args_info.scd_given) {
269     if (batchMode) {
270     analyser = new SCDOrderParameter(info, dumpFileName, args_info.molname_arg,
271     args_info.begin_arg, args_info.end_arg);
272     } else{
273     std::string sele3 = args_info.sele3_arg;
274     analyser = new SCDOrderParameter(info, dumpFileName, sele1, sele2, sele3);
275     }
276     }else if (args_info.density_given) {
277     analyser= new DensityPlot(info, dumpFileName, sele1, sele2, maxLen,
278     args_info.nbins_arg);
279     } else if (args_info.slab_density_given) {
280     analyser = new RhoZ(info, dumpFileName, sele1, args_info.nbins_arg);
281     } else if (args_info.p_angle_given) {
282     analyser = new pAngle(info, dumpFileName, sele1, args_info.nbins_arg);
283 gezelter 957 #if defined(HAVE_FFTW_H) || defined(HAVE_DFFTW_H) || defined(HAVE_FFTW3_H)
284 chuckv 1445 }else if (args_info.hxy_given) {
285     analyser = new Hxy(info, dumpFileName, sele1, args_info.nbins_x_arg,
286     args_info.nbins_y_arg, args_info.nbins_arg);
287 gezelter 956 #endif
288 chuckv 1445 }else if (args_info.rho_r_given) {
289     if (args_info.radius_given){
290     analyser = new RhoR(info, dumpFileName, sele1, maxLen,args_info.nbins_arg,args_info.radius_arg);
291     }else{
292     sprintf( painCave.errMsg,
293     "A particle radius (radius) must be specified when calculating Rho(r)");
294     painCave.severity = OPENMD_ERROR;
295     painCave.isFatal = 1;
296     simError();
297     }
298     }else if (args_info.hullvol_given) {
299     analyser = new NanoVolume(info, dumpFileName, sele1);
300 chuckv 1091 }
301 gezelter 1039
302 chuckv 1445 if (args_info.output_given) {
303     analyser->setOutputName(args_info.output_arg);
304     }
305     if (args_info.step_given) {
306     analyser->setStep(args_info.step_arg);
307     }
308 tim 311
309 chuckv 1445 analyser->process();
310 tim 311
311 chuckv 1445 delete analyser;
312     delete info;
313 tim 310
314 chuckv 1445 return 0;
315 tim 310 }
316    

Properties

Name Value
svn:executable *
svn:keywords Author Id Revision Date