ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/staticProps/StaticProps.cpp
(Generate patch)

Comparing trunk/src/applications/staticProps/StaticProps.cpp (file contents):
Revision 980 by xsun, Thu Jun 1 18:06:33 2006 UTC vs.
Revision 1994 by gezelter, Wed Apr 30 18:50:45 2014 UTC

# Line 6 | Line 6
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
9 > * 1. Redistributions of source code must retain the above copyright
10   *    notice, this list of conditions and the following disclaimer.
11   *
12 < * 3. Redistributions in binary form must reproduce the above copyright
12 > * 2. Redistributions in binary form must reproduce the above copyright
13   *    notice, this list of conditions and the following disclaimer in the
14   *    documentation and/or other materials provided with the
15   *    distribution.
# Line 37 | Line 28
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 + *
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, 234107 (2008).          
39 + * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 + * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42  
43   #include <iostream>
44   #include <fstream>
45   #include <string>
46  
46 #include "brains/Register.hpp"
47   #include "brains/SimCreator.hpp"
48   #include "brains/SimInfo.hpp"
49   #include "io/DumpReader.hpp"
# Line 52 | Line 52
52   #include "applications/staticProps/StaticPropsCmd.h"
53   #include "applications/staticProps/StaticAnalyser.hpp"
54   #include "applications/staticProps/GofR.hpp"
55 + #include "applications/staticProps/GofZ.hpp"
56 + #include "applications/staticProps/GofRZ.hpp"
57   #include "applications/staticProps/GofRAngle.hpp"
58   #include "applications/staticProps/GofAngle2.hpp"
59   #include "applications/staticProps/GofXyz.hpp"
60 + #include "applications/staticProps/TwoDGofR.hpp"
61   #include "applications/staticProps/P2OrderParameter.hpp"
62 + #include "applications/staticProps/BondOrderParameter.hpp"
63 + #include "applications/staticProps/BOPofR.hpp"
64   #include "applications/staticProps/RippleOP.hpp"
65   #include "applications/staticProps/SCDOrderParameter.hpp"
66   #include "applications/staticProps/DensityPlot.hpp"
67 + #include "applications/staticProps/ObjectCount.hpp"
68   #include "applications/staticProps/RhoZ.hpp"
69 + #include "applications/staticProps/pAngle.hpp"
70 + #include "applications/staticProps/BondAngleDistribution.hpp"
71 + #include "applications/staticProps/NanoVolume.hpp"
72 + #include "applications/staticProps/NanoLength.hpp"
73   #if defined(HAVE_FFTW_H) || defined(HAVE_DFFTW_H) || defined(HAVE_FFTW3_H)
74   #include "applications/staticProps/Hxy.hpp"
75   #endif
76 + #include "applications/staticProps/RhoR.hpp"
77 + #include "applications/staticProps/AngleR.hpp"
78 + #include "applications/staticProps/TetrahedralityParam.hpp"
79 + #include "applications/staticProps/TetrahedralityParamZ.hpp"
80 + #include "applications/staticProps/RNEMDStats.hpp"
81 + #include "applications/staticProps/NitrileFrequencyMap.hpp"
82  
83 < using namespace oopse;
83 > using namespace OpenMD;
84  
85   int main(int argc, char* argv[]){
86    
87 <  //register force fields
72 <  registerForceFields();
73 <
87 >  
88    gengetopt_args_info args_info;
89 <
89 >  
90    //parse the command line option
91    if (cmdline_parser (argc, argv, &args_info) != 0) {
92      exit(1) ;
93    }
94 <
95 <
82 <  //get the dumpfile name and meta-data file name
94 >  
95 >  //get the dumpfile name
96    std::string dumpFileName = args_info.input_arg;
84
85  std::string mdFileName = dumpFileName.substr(0, dumpFileName.rfind(".")) + ".md";
86
87    
97    std::string sele1;
98    std::string sele2;
99 <
99 >  
100 >  // check the first selection argument, or set it to the environment
101 >  // variable, or failing that, set it to "select all"
102 >  
103    if (args_info.sele1_given) {
104      sele1 = args_info.sele1_arg;
105 <  }else {
106 <    char*  sele1Env= getenv("OOPSE_SELE1");
105 >  } else {
106 >    char*  sele1Env= getenv("SELECTION1");
107      if (sele1Env) {
108        sele1 = sele1Env;
109 <    }else if (!args_info.scd_given) {
110 <      sprintf( painCave.errMsg,
99 <               "neither --sele1 option nor $OOPSE_SELE1 is set");
100 <      painCave.severity = OOPSE_ERROR;
101 <      painCave.isFatal = 1;
102 <      simError();
109 >    } else {
110 >      sele1 = "select all";
111      }
112    }
113 <    
113 >  
114 >  // check the second selection argument, or set it to the environment
115 >  // variable, or failing that, set it to the first selection
116 >  
117    if (args_info.sele2_given) {
118      sele2 = args_info.sele2_arg;
119 <  }else {
120 <    char* sele2Env = getenv("OOPSE_SELE2");
119 >  } else {
120 >    char* sele2Env = getenv("SELECTION2");
121      if (sele2Env) {
122        sele2 = sele2Env;            
123 <    } else if (args_info.density_given) {
124 <      sele2 = "select all";
125 <    } else if(!args_info.scd_given && !args_info.density_given && !args_info.slab_density_given)  {
126 <      sprintf( painCave.errMsg,
116 <               "neither --sele2 option nor $OOPSE_SELE2 is set");
117 <      painCave.severity = OOPSE_ERROR;
118 <      painCave.isFatal = 1;
119 <      simError();        
123 >    } else {
124 >      //If sele2 is not specified, then the default behavior
125 >      //should be what is already intended for sele1
126 >      sele2 = sele1;
127      }
128    }
129  
130    bool batchMode;
131    if (args_info.scd_given){
132 <    if (args_info.sele1_given && args_info.sele2_given && args_info.sele3_given) {
133 <        batchMode = false;
134 <    } else if (args_info.molname_given && args_info.begin_given && args_info.end_given) {
135 <        if (args_info.begin_arg < 0 || args_info.end_arg < 0 || args_info.begin_arg > args_info.end_arg-2) {
136 <            sprintf( painCave.errMsg,
137 <                     "below conditions are not satisfied:\n"
138 <                     "0 <= begin && 0<= end && begin <= end-2\n");
132 <            painCave.severity = OOPSE_ERROR;
133 <            painCave.isFatal = 1;
134 <            simError();                    
135 <        }
136 <        batchMode = true;        
137 <    } else{
132 >    if (args_info.sele1_given &&
133 >        args_info.sele2_given && args_info.sele3_given) {
134 >      batchMode = false;
135 >    } else if (args_info.molname_given &&
136 >               args_info.begin_given && args_info.end_given) {
137 >      if (args_info.begin_arg < 0 ||
138 >          args_info.end_arg < 0 || args_info.begin_arg > args_info.end_arg-2) {
139          sprintf( painCave.errMsg,
140 <                 "either --sele1, --sele2, --sele3 are specified,"
141 <                 " or --molname, --begin, --end are specified\n");
142 <        painCave.severity = OOPSE_ERROR;
140 >                 "below conditions are not satisfied:\n"
141 >                 "0 <= begin && 0<= end && begin <= end-2\n");
142 >        painCave.severity = OPENMD_ERROR;
143          painCave.isFatal = 1;
144 <        simError();        
145 <    
144 >        simError();                    
145 >      }
146 >      batchMode = true;        
147 >    } else{
148 >      sprintf( painCave.errMsg,
149 >               "either --sele1, --sele2, --sele3 are specified,"
150 >               " or --molname, --begin, --end are specified\n");
151 >      painCave.severity = OPENMD_ERROR;
152 >      painCave.isFatal = 1;
153 >      simError();
154      }
155    }
156 <
156 >  
157    //parse md file and set up the system
158    SimCreator creator;
159 <  SimInfo* info = creator.createSim(mdFileName);
159 >  SimInfo* info = creator.createSim(dumpFileName);
160  
161    RealType maxLen;
162 +  RealType zmaxLen;
163    if (args_info.length_given) {
164      maxLen = args_info.length_arg;
165 +    if (args_info.zlength_given){
166 +      zmaxLen = args_info.zlength_arg;
167 +    }
168    } else {
169      Mat3x3d hmat = info->getSnapshotManager()->getCurrentSnapshot()->getHmat();
170 <    maxLen = std::min(std::min(hmat(0, 0), hmat(1, 1)), hmat(2, 2)) /2.0;        
170 >    maxLen = std::min(std::min(hmat(0, 0), hmat(1, 1)), hmat(2, 2)) /2.0;
171 >    zmaxLen = hmat(2,2);    
172    }    
173 <
173 >  
174    StaticAnalyser* analyser;
175    if (args_info.gofr_given){
176 <    analyser= new GofR(info, dumpFileName, sele1, sele2, maxLen, args_info.nrbins_arg);        
176 >    analyser= new GofR(info, dumpFileName, sele1, sele2, maxLen,
177 >                       args_info.nbins_arg);        
178 >  } else if (args_info.gofz_given) {
179 >    analyser= new GofZ(info, dumpFileName, sele1, sele2, maxLen,
180 >                       args_info.nbins_arg);
181 >  } else if (args_info.r_z_given) {
182 >    analyser  = new GofRZ(info, dumpFileName, sele1, sele2, maxLen, zmaxLen,
183 >                          args_info.nbins_arg, args_info.nbins_z_arg);
184    } else if (args_info.r_theta_given) {
185 <    analyser  = new GofRTheta(info, dumpFileName, sele1, sele2, maxLen, args_info.nrbins_arg, args_info.nanglebins_arg);
185 >    analyser  = new GofRTheta(info, dumpFileName, sele1, sele2, maxLen,
186 >                              args_info.nbins_arg, args_info.nanglebins_arg);
187    } else if (args_info.r_omega_given) {
188 <    analyser  = new GofROmega(info, dumpFileName, sele1, sele2, maxLen, args_info.nrbins_arg, args_info.nanglebins_arg);
188 >    analyser  = new GofROmega(info, dumpFileName, sele1, sele2, maxLen,
189 >                              args_info.nbins_arg, args_info.nanglebins_arg);
190    } else if (args_info.theta_omega_given) {
191 <    analyser  = new GofAngle2(info, dumpFileName, sele1, sele2, args_info.nanglebins_arg);
191 >    analyser  = new GofAngle2(info, dumpFileName, sele1, sele2,
192 >                              args_info.nanglebins_arg);
193    } else if (args_info.gxyz_given) {
194      if (args_info.refsele_given) {
195 <      analyser= new GofXyz(info, dumpFileName, sele1, sele2,args_info.refsele_arg, maxLen, args_info.nrbins_arg);        
195 >      analyser= new GofXyz(info, dumpFileName, sele1, sele2,
196 >                           args_info.refsele_arg, maxLen, args_info.nbins_arg);
197      } else {
198        sprintf( painCave.errMsg,
199 <               "--refsele must set when --gxyz is used");
200 <      painCave.severity = OOPSE_ERROR;
199 >               "--refsele must set when --gxyz is used");
200 >      painCave.severity = OPENMD_ERROR;
201        painCave.isFatal = 1;
202        simError();  
203      }
204 <  } else if (args_info.p2_given) {
205 <      analyser  = new P2OrderParameter(info, dumpFileName, sele1, sele2);
206 <  }    else if (args_info.rp2_given){
207 <      analyser = new RippleOP(info, dumpFileName, sele1, sele2);
208 < }else if (args_info.scd_given) {
209 <      if (batchMode) {
210 <          analyser  = new SCDOrderParameter(info, dumpFileName, args_info.molname_arg,
211 <            args_info.begin_arg, args_info.end_arg);
212 <      } else{
213 <          std::string sele3 = args_info.sele3_arg;
214 <          analyser  = new SCDOrderParameter(info, dumpFileName, sele1, sele2, sele3);
215 <      }
216 <  }else if (args_info.density_given) {
217 <      analyser= new DensityPlot(info, dumpFileName, sele1, sele2, maxLen, args_info.nrbins_arg);  
204 >  } else if (args_info.twodgofr_given){
205 >    if (args_info.dz_given) {
206 >      analyser= new TwoDGofR(info, dumpFileName, sele1, sele2, maxLen,
207 >                             args_info.dz_arg, args_info.nbins_arg);        
208 >    } else {
209 >      sprintf( painCave.errMsg,
210 >               "A slab width (dz) must be specified when calculating TwoDGofR");
211 >      painCave.severity = OPENMD_ERROR;
212 >      painCave.isFatal = 1;
213 >      simError();
214 >    }    
215 >  } else if (args_info.p2_given) {
216 >    if (args_info.sele1_given) {    
217 >      if (args_info.sele2_given)
218 >        analyser  = new P2OrderParameter(info, dumpFileName, sele1, sele2);
219 >      else
220 >        if (args_info.seleoffset_given)
221 >          analyser  = new P2OrderParameter(info, dumpFileName, sele1,
222 >                                           args_info.seleoffset_arg);
223 >        else
224 >          analyser  = new P2OrderParameter(info, dumpFileName, sele1);
225 >    } else {
226 >      sprintf( painCave.errMsg,
227 >               "At least one selection script (--sele1) must be specified when calculating P2 order parameters");
228 >      painCave.severity = OPENMD_ERROR;
229 >      painCave.isFatal = 1;
230 >      simError();
231 >    }
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 >    
247 >  } else if (args_info.tet_param_given) {
248 >    if (args_info.rcut_given) {  
249 >      analyser = new TetrahedralityParam(info, dumpFileName, sele1,
250 >                                         args_info.rcut_arg,
251 >                                         args_info.nbins_arg);
252 >    } else {
253 >      sprintf( painCave.errMsg,
254 >               "A cutoff radius (rcut) must be specified when calculating Tetrahedrality Parameters");
255 >      painCave.severity = OPENMD_ERROR;
256 >      painCave.isFatal = 1;
257 >      simError();
258 >    }
259 >  } else if (args_info.tet_param_z_given) {
260 >    if (args_info.rcut_given) {  
261 >      analyser = new TetrahedralityParamZ(info, dumpFileName, sele1, sele2,
262 >                                          args_info.rcut_arg,
263 >                                          args_info.nbins_arg);
264 >    } else {
265 >      sprintf( painCave.errMsg,
266 >               "A cutoff radius (rcut) must be specified when calculating Tetrahedrality Parameters");
267 >      painCave.severity = OPENMD_ERROR;
268 >      painCave.isFatal = 1;
269 >      simError();
270 >    }
271 >  } else if (args_info.ior_given){
272 >    if (args_info.rcut_given) {
273 >      analyser = new IcosahedralOfR(info, dumpFileName, sele1,
274 >                                    args_info.rcut_arg,
275 >                                    args_info.nbins_arg, maxLen);
276 >    } else {
277 >      sprintf( painCave.errMsg,
278 >               "A cutoff radius (rcut) must be specified when calculating Bond Order Parameters");
279 >      painCave.severity = OPENMD_ERROR;
280 >      painCave.isFatal = 1;
281 >      simError();
282 >    }
283 >  } else if (args_info.for_given){
284 >    if (args_info.rcut_given) {
285 >      analyser = new FCCOfR(info, dumpFileName, sele1, args_info.rcut_arg,
286 >                            args_info.nbins_arg, maxLen);
287 >    } else {
288 >      sprintf( painCave.errMsg,
289 >               "A cutoff radius (rcut) must be specified when calculating Bond Order Parameters");
290 >      painCave.severity = OPENMD_ERROR;
291 >      painCave.isFatal = 1;
292 >      simError();
293 >    }
294 >  } else if (args_info.bad_given){
295 >    if (args_info.rcut_given) {
296 >      analyser = new BondAngleDistribution(info, dumpFileName, sele1,
297 >                                           args_info.rcut_arg,
298 >                                           args_info.nbins_arg);
299 >    } else {
300 >      sprintf( painCave.errMsg,
301 >               "A cutoff radius (rcut) must be specified when calculating Bond Angle Distributions");
302 >      painCave.severity = OPENMD_ERROR;
303 >      painCave.isFatal = 1;
304 >      simError();
305 >    }
306 >  } else if (args_info.scd_given) {
307 >    if (batchMode) {
308 >      analyser  = new SCDOrderParameter(info, dumpFileName,
309 >                                        args_info.molname_arg,
310 >                                        args_info.begin_arg, args_info.end_arg);
311 >    } else{
312 >      std::string sele3 = args_info.sele3_arg;
313 >      analyser  = new SCDOrderParameter(info, dumpFileName,
314 >                                        sele1, sele2, sele3);
315 >    }
316 >  }else if (args_info.density_given) {
317 >    analyser= new DensityPlot(info, dumpFileName, sele1, sele2, maxLen,
318 >                              args_info.nbins_arg);  
319 >  } else if (args_info.count_given) {
320 >    analyser = new ObjectCount(info, dumpFileName, sele1 );
321    } else if (args_info.slab_density_given) {
322 <      Mat3x3d hmat = info->getSnapshotManager()->getCurrentSnapshot()->getHmat();
323 <      analyser = new RhoZ(info, dumpFileName, sele1, hmat(2, 2), args_info.nrbins_arg);
322 >    analyser = new RhoZ(info, dumpFileName, sele1, args_info.nbins_arg);
323 >  } else if (args_info.rnemdz_given) {
324 >    analyser = new RNEMDZ(info, dumpFileName, sele1, args_info.nbins_arg);
325 >  } else if (args_info.rnemdr_given) {
326 >    analyser = new RNEMDR(info, dumpFileName, sele1, args_info.nbins_arg);
327 >  } else if (args_info.rnemdrt_given) {
328 >    analyser = new RNEMDRTheta(info, dumpFileName, sele1,
329 >                               args_info.nbins_arg, args_info.nanglebins_arg);
330 >  } else if (args_info.nitrile_given) {
331 >    analyser = new NitrileFrequencyMap(info, dumpFileName, sele1,
332 >                                       args_info.nbins_arg);
333 >  } else if (args_info.p_angle_given) {
334 >    if (args_info.sele1_given) {    
335 >      if (args_info.sele2_given)
336 >        analyser  = new pAngle(info, dumpFileName, sele1, sele2,
337 >                               args_info.nbins_arg);
338 >      else
339 >        if (args_info.seleoffset_given) {
340 >          if (args_info.seleoffset2_given) {
341 >            analyser  = new pAngle(info, dumpFileName, sele1,
342 >                                   args_info.seleoffset_arg,
343 >                                   args_info.seleoffset2_arg,
344 >                                   args_info.nbins_arg);
345 >          } else {
346 >            analyser  = new pAngle(info, dumpFileName, sele1,
347 >                                   args_info.seleoffset_arg,
348 >                                   args_info.nbins_arg);
349 >          }
350 >        } else
351 >          analyser  = new pAngle(info, dumpFileName, sele1,
352 >                                 args_info.nbins_arg);
353 >    } else {
354 >      sprintf( painCave.errMsg,
355 >               "At least one selection script (--sele1) must be specified when "
356 >               "calculating P(angle) distributions");
357 >      painCave.severity = OPENMD_ERROR;
358 >      painCave.isFatal = 1;
359 >      simError();
360 >    }
361   #if defined(HAVE_FFTW_H) || defined(HAVE_DFFTW_H) || defined(HAVE_FFTW3_H)
362    }else if (args_info.hxy_given) {
363 <    analyser = new Hxy(info, dumpFileName, sele1, args_info.nbins_x_arg, args_info.nbins_y_arg, args_info.nrbins_arg);
363 >    analyser = new Hxy(info, dumpFileName, sele1, args_info.nbins_x_arg,
364 >                       args_info.nbins_y_arg, args_info.nbins_arg);
365   #endif
366 +  }else if (args_info.rho_r_given) {
367 +    if (args_info.radius_given){
368 +      analyser = new RhoR(info, dumpFileName, sele1, maxLen,args_info.nbins_arg,args_info.radius_arg);
369 +    }else{
370 +      sprintf( painCave.errMsg,
371 +               "A particle radius (radius) must be specified when calculating Rho(r)");
372 +      painCave.severity = OPENMD_ERROR;
373 +      painCave.isFatal = 1;
374 +      simError();
375 +    }
376 +  } else if (args_info.hullvol_given) {
377 +    analyser = new NanoVolume(info, dumpFileName, sele1);
378 +  } else if (args_info.rodlength_given) {
379 +    analyser = new NanoLength(info, dumpFileName, sele1);
380 +  } else if (args_info.angle_r_given) {
381 +    analyser = new AngleR(info, dumpFileName, sele1, maxLen,args_info.nbins_arg);
382    }
383 <    
383 >  
384    if (args_info.output_given) {
385      analyser->setOutputName(args_info.output_arg);
386    }
387    if (args_info.step_given) {
388      analyser->setStep(args_info.step_arg);
389    }
390 <
390 >  
391    analyser->process();
392 <
392 >  
393    delete analyser;    
394    delete info;
395 <
395 >  
396    return 0;  
397   }
216

Comparing trunk/src/applications/staticProps/StaticProps.cpp (property svn:keywords):
Revision 980 by xsun, Thu Jun 1 18:06:33 2006 UTC vs.
Revision 1994 by gezelter, Wed Apr 30 18:50:45 2014 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines