ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/staticProps/StaticProps.cpp
Revision: 1785
Committed: Wed Aug 22 18:43:27 2012 UTC (12 years, 8 months ago) by jmichalk
File size: 13729 byte(s)
Log Message:
Trunk: The changes in this commit are confined to applications/staticProps and for the most part deal with a misspelling of initialize.

The one other change took place in StaticProps.cpp and deals with the default treatment of sele2. It had previously been set to 'select all' which seems to go against what would be desired by not specifying it with regard to proper operations of many of the analysis programs ( g of r's especially)

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 gezelter 1782 * [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010).
40     * [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41 tim 310 */
42    
43     #include <iostream>
44     #include <fstream>
45     #include <string>
46    
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 gezelter 1513 #include "applications/staticProps/ObjectCount.hpp"
68 tim 840 #include "applications/staticProps/RhoZ.hpp"
69 gezelter 1413 #include "applications/staticProps/pAngle.hpp"
70 chuckv 1180 #include "applications/staticProps/BondAngleDistribution.hpp"
71     #include "applications/staticProps/NanoVolume.hpp"
72 gezelter 1585 #include "applications/staticProps/NanoLength.hpp"
73 gezelter 957 #if defined(HAVE_FFTW_H) || defined(HAVE_DFFTW_H) || defined(HAVE_FFTW3_H)
74 xsun 955 #include "applications/staticProps/Hxy.hpp"
75 gezelter 956 #endif
76 chuckv 1091 #include "applications/staticProps/RhoR.hpp"
77 kstocke1 1522 #include "applications/staticProps/AngleR.hpp"
78     #include "applications/staticProps/TetrahedralityParam.hpp"
79 gezelter 1782 #include "applications/staticProps/TetrahedralityParamZ.hpp"
80 gezelter 1390 using namespace OpenMD;
81 tim 310
82     int main(int argc, char* argv[]){
83    
84 gezelter 1513
85     gengetopt_args_info args_info;
86    
87     //parse the command line option
88     if (cmdline_parser (argc, argv, &args_info) != 0) {
89     exit(1) ;
90     }
91    
92     //get the dumpfile name
93     std::string dumpFileName = args_info.input_arg;
94     std::string sele1;
95     std::string sele2;
96    
97     // check the first selection argument, or set it to the environment
98     // variable, or failing that, set it to "select all"
99    
100     if (args_info.sele1_given) {
101     sele1 = args_info.sele1_arg;
102     } else {
103     char* sele1Env= getenv("SELECTION1");
104     if (sele1Env) {
105     sele1 = sele1Env;
106     } else {
107     sele1 = "select all";
108     }
109     }
110    
111     // check the second selection argument, or set it to the environment
112     // variable, or failing that, set it to "select all"
113    
114     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 jmichalk 1785 //It seems likely (from previous discussions) that if sele2 is not specified, then the default behavior
122     //should not be 'select all' but rather what is already intended for sele1
123     //JRM 8/22/12
124     sele2 = sele1;
125     //sele2 = "select all";
126 gezelter 1513 }
127     }
128    
129    
130     // Problems if sele1 wasn't specified, but
131     // if (!args_info.scd_given) {
132     // sprintf( painCave.errMsg,
133     // "neither --sele1 option nor $SELECTION1 is set");
134     // painCave.severity = OPENMD_ERROR;
135     // painCave.isFatal = 1;
136     // simError();
137     // }
138     // }
139    
140     // Problems if sele1 wasn't specified
141    
142     // if(!args_info.scd_given && !args_info.density_given && !args_info.slab_density_given) {
143     // sprintf( painCave.errMsg,
144     // "neither --sele2 option nor $SELECTION1 is set");
145     // painCave.severity = OPENMD_ERROR;
146     // painCave.isFatal = 1;
147     // simError();
148     // }
149     // }
150    
151     bool batchMode;
152     if (args_info.scd_given){
153     if (args_info.sele1_given && args_info.sele2_given && args_info.sele3_given) {
154     batchMode = false;
155     } else if (args_info.molname_given && args_info.begin_given && args_info.end_given) {
156     if (args_info.begin_arg < 0 || args_info.end_arg < 0 || args_info.begin_arg > args_info.end_arg-2) {
157     sprintf( painCave.errMsg,
158     "below conditions are not satisfied:\n"
159     "0 <= begin && 0<= end && begin <= end-2\n");
160     painCave.severity = OPENMD_ERROR;
161     painCave.isFatal = 1;
162     simError();
163     }
164     batchMode = true;
165     } else{
166     sprintf( painCave.errMsg,
167     "either --sele1, --sele2, --sele3 are specified,"
168     " or --molname, --begin, --end are specified\n");
169     painCave.severity = OPENMD_ERROR;
170     painCave.isFatal = 1;
171     simError();
172    
173     }
174     }
175    
176     //parse md file and set up the system
177     SimCreator creator;
178     std::cout << "dumpFile = " << dumpFileName << "\n";
179     SimInfo* info = creator.createSim(dumpFileName);
180 tim 310
181 gezelter 1513 RealType maxLen;
182     RealType zmaxLen;
183     if (args_info.length_given) {
184     maxLen = args_info.length_arg;
185     if (args_info.zlength_given){
186     zmaxLen = args_info.zlength_arg;
187 chuckv 1445 }
188 gezelter 1513 } else {
189     Mat3x3d hmat = info->getSnapshotManager()->getCurrentSnapshot()->getHmat();
190     maxLen = std::min(std::min(hmat(0, 0), hmat(1, 1)), hmat(2, 2)) /2.0;
191     zmaxLen = hmat(2,2);
192     }
193 kstocke1 1522
194 gezelter 1513 StaticAnalyser* analyser;
195     if (args_info.gofr_given){
196     analyser= new GofR(info, dumpFileName, sele1, sele2, maxLen,
197 kstocke1 1522 args_info.nbins_arg);
198 gezelter 1513 } else if (args_info.gofz_given) {
199     analyser= new GofZ(info, dumpFileName, sele1, sele2, maxLen,
200 kstocke1 1522 args_info.nbins_arg);
201 gezelter 1513 } else if (args_info.r_z_given) {
202     analyser = new GofRZ(info, dumpFileName, sele1, sele2, maxLen, zmaxLen,
203 kstocke1 1522 args_info.nbins_arg, args_info.nbins_z_arg);
204 gezelter 1513 } else if (args_info.r_theta_given) {
205     analyser = new GofRTheta(info, dumpFileName, sele1, sele2, maxLen,
206 kstocke1 1522 args_info.nbins_arg, args_info.nanglebins_arg);
207 gezelter 1513 } else if (args_info.r_omega_given) {
208     analyser = new GofROmega(info, dumpFileName, sele1, sele2, maxLen,
209 kstocke1 1522 args_info.nbins_arg, args_info.nanglebins_arg);
210 gezelter 1513 } else if (args_info.theta_omega_given) {
211     analyser = new GofAngle2(info, dumpFileName, sele1, sele2,
212 kstocke1 1522 args_info.nanglebins_arg);
213 gezelter 1513 } else if (args_info.gxyz_given) {
214     if (args_info.refsele_given) {
215     analyser= new GofXyz(info, dumpFileName, sele1, sele2,args_info.refsele_arg,
216 kstocke1 1522 maxLen, args_info.nbins_arg);
217 gezelter 1039 } else {
218 gezelter 1513 sprintf( painCave.errMsg,
219 kstocke1 1522 "--refsele must set when --gxyz is used");
220 gezelter 1513 painCave.severity = OPENMD_ERROR;
221     painCave.isFatal = 1;
222     simError();
223 tim 310 }
224 gezelter 1513 } else if (args_info.twodgofr_given){
225     if (args_info.dz_given) {
226     analyser= new TwoDGofR(info, dumpFileName, sele1, sele2, maxLen,
227 kstocke1 1522 args_info.dz_arg, args_info.nbins_arg);
228 chuckv 1445 } else {
229 gezelter 1513 sprintf( painCave.errMsg,
230 kstocke1 1522 "A slab width (dz) must be specified when calculating TwoDGofR");
231 gezelter 1513 painCave.severity = OPENMD_ERROR;
232     painCave.isFatal = 1;
233     simError();
234 kstocke1 1522 }
235 gezelter 1513 } else if (args_info.p2_given) {
236 gezelter 1542 if (args_info.sele1_given) {
237     if (args_info.sele2_given)
238     analyser = new P2OrderParameter(info, dumpFileName, sele1, sele2);
239     else
240     analyser = new P2OrderParameter(info, dumpFileName, sele1);
241     } else {
242     sprintf( painCave.errMsg,
243     "At least one selection script (--sele1) must be specified when calculating P2 order parameters");
244     painCave.severity = OPENMD_ERROR;
245     painCave.isFatal = 1;
246     simError();
247     }
248 gezelter 1513 } else if (args_info.rp2_given){
249     analyser = new RippleOP(info, dumpFileName, sele1, sele2);
250     } else if (args_info.bo_given){
251     if (args_info.rcut_given) {
252     analyser = new BondOrderParameter(info, dumpFileName, sele1,
253 kstocke1 1522 args_info.rcut_arg,
254     args_info.nbins_arg);
255 gezelter 1513 } else {
256     sprintf( painCave.errMsg,
257 kstocke1 1522 "A cutoff radius (rcut) must be specified when calculating Bond Order Parameters");
258 gezelter 1513 painCave.severity = OPENMD_ERROR;
259     painCave.isFatal = 1;
260     simError();
261 tim 544 }
262 kstocke1 1522
263     } else if (args_info.tet_param_given) {
264     if (args_info.rcut_given) {
265     analyser = new TetrahedralityParam(info, dumpFileName, sele1,
266     args_info.rcut_arg,
267     args_info.nbins_arg);
268     } else {
269     sprintf( painCave.errMsg,
270     "A cutoff radius (rcut) must be specified when calculating Tetrahedrality Parameters");
271     painCave.severity = OPENMD_ERROR;
272     painCave.isFatal = 1;
273     simError();
274     }
275 gezelter 1782 } else if (args_info.tet_param_z_given) {
276     if (args_info.rcut_given) {
277     analyser = new TetrahedralityParamZ(info, dumpFileName, sele1,
278     args_info.rcut_arg,
279     args_info.nbins_arg);
280     } else {
281     sprintf( painCave.errMsg,
282     "A cutoff radius (rcut) must be specified when calculating Tetrahedrality Parameters");
283     painCave.severity = OPENMD_ERROR;
284     painCave.isFatal = 1;
285     simError();
286     }
287 gezelter 1513 } else if (args_info.bor_given){
288     if (args_info.rcut_given) {
289     analyser = new BOPofR(info, dumpFileName, sele1, args_info.rcut_arg,
290 kstocke1 1522 args_info.nbins_arg, maxLen);
291 chuckv 1445 } else {
292 gezelter 1513 sprintf( painCave.errMsg,
293 kstocke1 1522 "A cutoff radius (rcut) must be specified when calculating Bond Order Parameters");
294 gezelter 1513 painCave.severity = OPENMD_ERROR;
295     painCave.isFatal = 1;
296     simError();
297     }
298     } else if (args_info.bad_given){
299     if (args_info.rcut_given) {
300     analyser = new BondAngleDistribution(info, dumpFileName, sele1, args_info.rcut_arg,
301 kstocke1 1522 args_info.nbins_arg);
302 gezelter 1513 } else {
303     sprintf( painCave.errMsg,
304 kstocke1 1522 "A cutoff radius (rcut) must be specified when calculating Bond Angle Distributions");
305 gezelter 1513 painCave.severity = OPENMD_ERROR;
306     painCave.isFatal = 1;
307     simError();
308 kstocke1 1522 }
309 gezelter 1513 } else if (args_info.scd_given) {
310     if (batchMode) {
311     analyser = new SCDOrderParameter(info, dumpFileName, args_info.molname_arg,
312 kstocke1 1522 args_info.begin_arg, args_info.end_arg);
313 gezelter 1513 } else{
314     std::string sele3 = args_info.sele3_arg;
315     analyser = new SCDOrderParameter(info, dumpFileName, sele1, sele2, sele3);
316     }
317     }else if (args_info.density_given) {
318     analyser= new DensityPlot(info, dumpFileName, sele1, sele2, maxLen,
319 kstocke1 1522 args_info.nbins_arg);
320 gezelter 1513 } else if (args_info.count_given) {
321     analyser = new ObjectCount(info, dumpFileName, sele1 );
322     } else if (args_info.slab_density_given) {
323     analyser = new RhoZ(info, dumpFileName, sele1, args_info.nbins_arg);
324     } else if (args_info.p_angle_given) {
325     analyser = new pAngle(info, dumpFileName, sele1, args_info.nbins_arg);
326 gezelter 957 #if defined(HAVE_FFTW_H) || defined(HAVE_DFFTW_H) || defined(HAVE_FFTW3_H)
327 gezelter 1513 }else if (args_info.hxy_given) {
328     analyser = new Hxy(info, dumpFileName, sele1, args_info.nbins_x_arg,
329 kstocke1 1522 args_info.nbins_y_arg, args_info.nbins_arg);
330 gezelter 956 #endif
331 gezelter 1513 }else if (args_info.rho_r_given) {
332     if (args_info.radius_given){
333     analyser = new RhoR(info, dumpFileName, sele1, maxLen,args_info.nbins_arg,args_info.radius_arg);
334     }else{
335     sprintf( painCave.errMsg,
336 kstocke1 1522 "A particle radius (radius) must be specified when calculating Rho(r)");
337 gezelter 1513 painCave.severity = OPENMD_ERROR;
338     painCave.isFatal = 1;
339     simError();
340 chuckv 1091 }
341 kstocke1 1522 } else if (args_info.hullvol_given) {
342 gezelter 1513 analyser = new NanoVolume(info, dumpFileName, sele1);
343 gezelter 1585 } else if (args_info.rodlength_given) {
344     analyser = new NanoLength(info, dumpFileName, sele1);
345 kstocke1 1522 } else if (args_info.angle_r_given) {
346     analyser = new AngleR(info, dumpFileName, sele1, maxLen,args_info.nbins_arg);
347 gezelter 1513 }
348 kstocke1 1522
349 gezelter 1513 if (args_info.output_given) {
350     analyser->setOutputName(args_info.output_arg);
351     }
352     if (args_info.step_given) {
353     analyser->setStep(args_info.step_arg);
354     }
355 gezelter 1782
356 gezelter 1513 analyser->process();
357 kstocke1 1522
358 gezelter 1513 delete analyser;
359     delete info;
360 tim 310
361 gezelter 1513 return 0;
362 tim 310 }
363    

Properties

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