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 354 by tim, Wed Feb 16 20:30:50 2005 UTC vs.
Revision 2015 by gezelter, Wed Aug 13 20:42:43 2014 UTC

# Line 1 | Line 1
1 < /*
1 > /*
2   * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3   *
4   * The University of Notre Dame grants you ("Licensee") a
# 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"
50   #include "utils/simError.h"
51  
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/TetrahedralityParamXYZ.hpp"
81 + #include "applications/staticProps/RNEMDStats.hpp"
82 + #include "applications/staticProps/NitrileFrequencyMap.hpp"
83 + #include "applications/staticProps/MultipoleSum.hpp"
84  
85 < using namespace oopse;
85 > using namespace OpenMD;
86  
87   int main(int argc, char* argv[]){
88    
89 <    //register force fields
90 <    registerForceFields();
89 >  
90 >  gengetopt_args_info args_info;
91 >  
92 >  //parse the command line option
93 >  if (cmdline_parser (argc, argv, &args_info) != 0) {
94 >    exit(1) ;
95 >  }
96 >  
97 >  //get the dumpfile name
98 >  std::string dumpFileName = args_info.input_arg;
99 >  std::string sele1;
100 >  std::string sele2;
101 >  
102 >  // check the first selection argument, or set it to the environment
103 >  // variable, or failing that, set it to "select all"
104 >  
105 >  if (args_info.sele1_given) {
106 >    sele1 = args_info.sele1_arg;
107 >  } else {
108 >    char*  sele1Env= getenv("SELECTION1");
109 >    if (sele1Env) {
110 >      sele1 = sele1Env;
111 >    } else {
112 >      sele1 = "select all";
113 >    }
114 >  }
115 >  
116 >  // check the second selection argument, or set it to the environment
117 >  // variable, or failing that, set it to the first selection
118 >  
119 >  if (args_info.sele2_given) {
120 >    sele2 = args_info.sele2_arg;
121 >  } else {
122 >    char* sele2Env = getenv("SELECTION2");
123 >    if (sele2Env) {
124 >      sele2 = sele2Env;            
125 >    } else {
126 >      //If sele2 is not specified, then the default behavior
127 >      //should be what is already intended for sele1
128 >      sele2 = sele1;
129 >    }
130 >  }
131  
132 <    gengetopt_args_info args_info;
133 <
134 <    //parse the command line option
135 <    if (cmdline_parser (argc, argv, &args_info) != 0) {
136 <        exit(1) ;
132 >  bool batchMode;
133 >  if (args_info.scd_given){
134 >    if (args_info.sele1_given &&
135 >        args_info.sele2_given && args_info.sele3_given) {
136 >      batchMode = false;
137 >    } else if (args_info.molname_given &&
138 >               args_info.begin_given && args_info.end_given) {
139 >      if (args_info.begin_arg < 0 ||
140 >          args_info.end_arg < 0 || args_info.begin_arg > args_info.end_arg-2) {
141 >        sprintf( painCave.errMsg,
142 >                 "below conditions are not satisfied:\n"
143 >                 "0 <= begin && 0<= end && begin <= end-2\n");
144 >        painCave.severity = OPENMD_ERROR;
145 >        painCave.isFatal = 1;
146 >        simError();                    
147 >      }
148 >      batchMode = true;        
149 >    } else{
150 >      sprintf( painCave.errMsg,
151 >               "either --sele1, --sele2, --sele3 are specified,"
152 >               " or --molname, --begin, --end are specified\n");
153 >      painCave.severity = OPENMD_ERROR;
154 >      painCave.isFatal = 1;
155 >      simError();
156      }
157 +  }
158 +  
159 +  //parse md file and set up the system
160 +  SimCreator creator;
161 +  SimInfo* info = creator.createSim(dumpFileName);
162  
163 <
164 <    //get the dumpfile name and meta-data file name
165 <    std::string dumpFileName = args_info.input_arg;
166 <
167 <    std::string mdFileName = dumpFileName.substr(0, dumpFileName.rfind(".")) + ".md";
168 <
78 <    
79 <    std::string sele1;
80 <    std::string sele2;
81 <
82 <    if (args_info.sele1_given) {
83 <        sele1 = args_info.sele1_arg;
84 <    }else {
85 <        char*  sele1Env= getenv("OOPSE_SELE1");
86 <        if (sele1Env) {
87 <            sele1 = sele1Env;
88 <        }else {
89 <            sprintf( painCave.errMsg,
90 <               "neither --sele1 option nor $OOPSE_SELE1 is set");
91 <            painCave.severity = OOPSE_ERROR;
92 <            painCave.isFatal = 1;
93 <            simError();
94 <        }
163 >  RealType maxLen;
164 >  RealType zmaxLen;
165 >  if (args_info.length_given) {
166 >    maxLen = args_info.length_arg;
167 >    if (args_info.zlength_given){
168 >      zmaxLen = args_info.zlength_arg;
169      }
170 <    
171 <    if (args_info.sele2_given) {
172 <        sele2 = args_info.sele2_arg;
173 <    }else {
174 <        char* sele2Env = getenv("OOPSE_SELE2");
175 <        if (sele2Env) {
176 <            sele2 = sele2Env;            
177 <        } else {
178 <            sprintf( painCave.errMsg,
179 <               "neither --sele2 option nor $OOPSE_SELE2 is set");
180 <            painCave.severity = OOPSE_ERROR;
181 <            painCave.isFatal = 1;
182 <            simError();        
183 <        }
170 >  } else {
171 >    Mat3x3d hmat = info->getSnapshotManager()->getCurrentSnapshot()->getHmat();
172 >    maxLen = std::min(std::min(hmat(0, 0), hmat(1, 1)), hmat(2, 2)) /2.0;
173 >    zmaxLen = hmat(2,2);    
174 >  }    
175 >  
176 >  StaticAnalyser* analyser;
177 >  if (args_info.gofr_given){
178 >    analyser= new GofR(info, dumpFileName, sele1, sele2, maxLen,
179 >                       args_info.nbins_arg);        
180 >  } else if (args_info.gofz_given) {
181 >    analyser= new GofZ(info, dumpFileName, sele1, sele2, maxLen,
182 >                       args_info.nbins_arg);
183 >  } else if (args_info.r_z_given) {
184 >    analyser  = new GofRZ(info, dumpFileName, sele1, sele2, maxLen, zmaxLen,
185 >                          args_info.nbins_arg, args_info.nbins_z_arg);
186 >  } else if (args_info.r_theta_given) {
187 >    analyser  = new GofRTheta(info, dumpFileName, sele1, sele2, maxLen,
188 >                              args_info.nbins_arg, args_info.nanglebins_arg);
189 >  } else if (args_info.r_omega_given) {
190 >    analyser  = new GofROmega(info, dumpFileName, sele1, sele2, maxLen,
191 >                              args_info.nbins_arg, args_info.nanglebins_arg);
192 >  } else if (args_info.theta_omega_given) {
193 >    analyser  = new GofAngle2(info, dumpFileName, sele1, sele2,
194 >                              args_info.nanglebins_arg);
195 >  } else if (args_info.gxyz_given) {
196 >    if (args_info.refsele_given) {
197 >      analyser= new GofXyz(info, dumpFileName, sele1, sele2,
198 >                           args_info.refsele_arg, maxLen, args_info.nbins_arg);
199 >    } else {
200 >      sprintf( painCave.errMsg,
201 >               "--refsele must set when --gxyz is used");
202 >      painCave.severity = OPENMD_ERROR;
203 >      painCave.isFatal = 1;
204 >      simError();  
205      }
206 <
207 <    //parse md file and set up the system
208 <    SimCreator creator;
209 <    SimInfo* info = creator.createSim(mdFileName);
115 <
116 <    double maxLen;
117 <    if (args_info.length_given) {
118 <        maxLen = args_info.length_arg;
206 >  } else if (args_info.twodgofr_given){
207 >    if (args_info.dz_given) {
208 >      analyser= new TwoDGofR(info, dumpFileName, sele1, sele2, maxLen,
209 >                             args_info.dz_arg, args_info.nbins_arg);        
210      } else {
211 <        Mat3x3d hmat = info->getSnapshotManager()->getCurrentSnapshot()->getHmat();
212 <        maxLen = std::min(std::min(hmat(0, 0), hmat(1, 1)), hmat(2, 2)) /2.0;        
211 >      sprintf( painCave.errMsg,
212 >               "A slab width (dz) must be specified when calculating TwoDGofR");
213 >      painCave.severity = OPENMD_ERROR;
214 >      painCave.isFatal = 1;
215 >      simError();
216      }    
217 <
218 <    RadialDistrFunc* rdf;
219 <    if (args_info.gofr_given){
220 <        rdf= new GofR(info, dumpFileName, sele1, sele2, maxLen, args_info.nrbins_arg);        
221 <    } else if (args_info.r_theta_given) {
222 <        rdf  = new GofRTheta(info, dumpFileName, sele1, sele2, maxLen, args_info.nrbins_arg, args_info.nanglebins_arg);
223 <    } else if (args_info.r_omega_given) {
224 <        rdf  = new GofROmega(info, dumpFileName, sele1, sele2, maxLen, args_info.nrbins_arg, args_info.nanglebins_arg);
225 <    } else if (args_info.theta_omega_given) {
226 <        rdf  = new GofAngle2(info, dumpFileName, sele1, sele2, args_info.nanglebins_arg);
227 <    } else if (args_info.xyz_given) {
228 <        rdf= new GofXyz(info, dumpFileName, sele1, sele2, maxLen, args_info.nrbins_arg);        
217 >  } else if (args_info.p2_given) {
218 >    if (args_info.sele1_given) {    
219 >      if (args_info.sele2_given)
220 >        analyser  = new P2OrderParameter(info, dumpFileName, sele1, sele2);
221 >      else
222 >        if (args_info.seleoffset_given)
223 >          analyser  = new P2OrderParameter(info, dumpFileName, sele1,
224 >                                           args_info.seleoffset_arg);
225 >        else
226 >          analyser  = new P2OrderParameter(info, dumpFileName, sele1);
227 >    } else {
228 >      sprintf( painCave.errMsg,
229 >               "At least one selection script (--sele1) must be specified when calculating P2 order parameters");
230 >      painCave.severity = OPENMD_ERROR;
231 >      painCave.isFatal = 1;
232 >      simError();
233      }
234 <    
235 <    if (args_info.output_given) {
236 <        rdf->setOutputName(args_info.output_arg);
234 >  } else if (args_info.rp2_given){
235 >    analyser = new RippleOP(info, dumpFileName, sele1, sele2);
236 >  } else if (args_info.bo_given){
237 >    if (args_info.rcut_given) {
238 >      analyser = new BondOrderParameter(info, dumpFileName, sele1,
239 >                                        args_info.rcut_arg,
240 >                                        args_info.nbins_arg);
241 >    } else {
242 >      sprintf( painCave.errMsg,
243 >               "A cutoff radius (rcut) must be specified when calculating Bond Order Parameters");
244 >      painCave.severity = OPENMD_ERROR;
245 >      painCave.isFatal = 1;
246 >      simError();
247      }
248 <    if (args_info.step_given) {
249 <        rdf->setStep(args_info.step_arg);
248 >  } else if (args_info.multipole_given){
249 >    analyser = new MultipoleSum(info, dumpFileName, sele1,
250 >                                maxLen, args_info.nbins_arg);
251 >  } else if (args_info.tet_param_given) {
252 >    if (args_info.rcut_given) {  
253 >      analyser = new TetrahedralityParam(info, dumpFileName, sele1,
254 >                                         args_info.rcut_arg,
255 >                                         args_info.nbins_arg);
256 >    } else {
257 >      sprintf( painCave.errMsg,
258 >               "A cutoff radius (rcut) must be specified when calculating Tetrahedrality Parameters");
259 >      painCave.severity = OPENMD_ERROR;
260 >      painCave.isFatal = 1;
261 >      simError();
262      }
263 <
264 <    rdf->process();
265 <
266 <    delete rdf;    
267 <    delete info;
268 <
269 <    return 0;  
263 >  } else if (args_info.tet_param_z_given) {
264 >    if (args_info.rcut_given) {  
265 >      analyser = new TetrahedralityParamZ(info, dumpFileName, sele1, sele2,
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 >  } else if (args_info.tet_param_xyz_given) {
276 >    if (!args_info.rcut_given) {
277 >      sprintf( painCave.errMsg,
278 >               "A cutoff radius (rcut) must be specified when calculating"
279 >               " Tetrahedrality Parameters");
280 >      painCave.severity = OPENMD_ERROR;
281 >      painCave.isFatal = 1;
282 >      simError();
283 >    }
284 >    if (!args_info.voxelSize_given) {
285 >      sprintf( painCave.errMsg,
286 >               "A voxel size must be specified when calculating"
287 >               " volume-resolved Tetrahedrality Parameters");
288 >      painCave.severity = OPENMD_ERROR;
289 >      painCave.isFatal = 1;
290 >      simError();
291 >    }
292 >    if (!args_info.gaussWidth_given) {
293 >      sprintf( painCave.errMsg,
294 >               "A gaussian width must be specified when calculating"
295 >               " volume-resolved Tetrahedrality Parameters");
296 >      painCave.severity = OPENMD_ERROR;
297 >      painCave.isFatal = 1;
298 >      simError();
299 >    }
300 >    analyser = new TetrahedralityParamXYZ(info, dumpFileName, sele1, sele2,
301 >                                          args_info.rcut_arg,
302 >                                          args_info.voxelSize_arg,
303 >                                          args_info.gaussWidth_arg);
304 >  } else if (args_info.ior_given){
305 >    if (args_info.rcut_given) {
306 >      analyser = new IcosahedralOfR(info, dumpFileName, sele1,
307 >                                    args_info.rcut_arg,
308 >                                    args_info.nbins_arg, maxLen);
309 >    } else {
310 >      sprintf( painCave.errMsg,
311 >               "A cutoff radius (rcut) must be specified when calculating Bond Order Parameters");
312 >      painCave.severity = OPENMD_ERROR;
313 >      painCave.isFatal = 1;
314 >      simError();
315 >    }
316 >  } else if (args_info.for_given){
317 >    if (args_info.rcut_given) {
318 >      analyser = new FCCOfR(info, dumpFileName, sele1, args_info.rcut_arg,
319 >                            args_info.nbins_arg, maxLen);
320 >    } else {
321 >      sprintf( painCave.errMsg,
322 >               "A cutoff radius (rcut) must be specified when calculating Bond Order Parameters");
323 >      painCave.severity = OPENMD_ERROR;
324 >      painCave.isFatal = 1;
325 >      simError();
326 >    }
327 >  } else if (args_info.bad_given){
328 >    if (args_info.rcut_given) {
329 >      analyser = new BondAngleDistribution(info, dumpFileName, sele1,
330 >                                           args_info.rcut_arg,
331 >                                           args_info.nbins_arg);
332 >    } else {
333 >      sprintf( painCave.errMsg,
334 >               "A cutoff radius (rcut) must be specified when calculating Bond Angle Distributions");
335 >      painCave.severity = OPENMD_ERROR;
336 >      painCave.isFatal = 1;
337 >      simError();
338 >    }
339 >  } else if (args_info.scd_given) {
340 >    if (batchMode) {
341 >      analyser  = new SCDOrderParameter(info, dumpFileName,
342 >                                        args_info.molname_arg,
343 >                                        args_info.begin_arg, args_info.end_arg);
344 >    } else{
345 >      std::string sele3 = args_info.sele3_arg;
346 >      analyser  = new SCDOrderParameter(info, dumpFileName,
347 >                                        sele1, sele2, sele3);
348 >    }
349 >  }else if (args_info.density_given) {
350 >    analyser= new DensityPlot(info, dumpFileName, sele1, sele2, maxLen,
351 >                              args_info.nbins_arg);  
352 >  } else if (args_info.count_given) {
353 >    analyser = new ObjectCount(info, dumpFileName, sele1 );
354 >  } else if (args_info.slab_density_given) {
355 >    analyser = new RhoZ(info, dumpFileName, sele1, args_info.nbins_arg);
356 >  } else if (args_info.rnemdz_given) {
357 >    analyser = new RNEMDZ(info, dumpFileName, sele1, args_info.nbins_arg);
358 >  } else if (args_info.rnemdr_given) {
359 >    analyser = new RNEMDR(info, dumpFileName, sele1, args_info.nbins_arg);
360 >  } else if (args_info.rnemdrt_given) {
361 >    analyser = new RNEMDRTheta(info, dumpFileName, sele1,
362 >                               args_info.nbins_arg, args_info.nanglebins_arg);
363 >  } else if (args_info.nitrile_given) {
364 >    analyser = new NitrileFrequencyMap(info, dumpFileName, sele1,
365 >                                       args_info.nbins_arg);
366 >  } else if (args_info.p_angle_given) {
367 >    if (args_info.sele1_given) {    
368 >      if (args_info.sele2_given)
369 >        analyser  = new pAngle(info, dumpFileName, sele1, sele2,
370 >                               args_info.nbins_arg);
371 >      else
372 >        if (args_info.seleoffset_given) {
373 >          if (args_info.seleoffset2_given) {
374 >            analyser  = new pAngle(info, dumpFileName, sele1,
375 >                                   args_info.seleoffset_arg,
376 >                                   args_info.seleoffset2_arg,
377 >                                   args_info.nbins_arg);
378 >          } else {
379 >            analyser  = new pAngle(info, dumpFileName, sele1,
380 >                                   args_info.seleoffset_arg,
381 >                                   args_info.nbins_arg);
382 >          }
383 >        } else
384 >          analyser  = new pAngle(info, dumpFileName, sele1,
385 >                                 args_info.nbins_arg);
386 >    } else {
387 >      sprintf( painCave.errMsg,
388 >               "At least one selection script (--sele1) must be specified when "
389 >               "calculating P(angle) distributions");
390 >      painCave.severity = OPENMD_ERROR;
391 >      painCave.isFatal = 1;
392 >      simError();
393 >    }
394 > #if defined(HAVE_FFTW_H) || defined(HAVE_DFFTW_H) || defined(HAVE_FFTW3_H)
395 >  }else if (args_info.hxy_given) {
396 >    analyser = new Hxy(info, dumpFileName, sele1, args_info.nbins_x_arg,
397 >                       args_info.nbins_y_arg, args_info.nbins_arg);
398 > #endif
399 >  }else if (args_info.rho_r_given) {
400 >    if (args_info.radius_given){
401 >      analyser = new RhoR(info, dumpFileName, sele1, maxLen,args_info.nbins_arg,args_info.radius_arg);
402 >    }else{
403 >      sprintf( painCave.errMsg,
404 >               "A particle radius (radius) must be specified when calculating Rho(r)");
405 >      painCave.severity = OPENMD_ERROR;
406 >      painCave.isFatal = 1;
407 >      simError();
408 >    }
409 >  } else if (args_info.hullvol_given) {
410 >    analyser = new NanoVolume(info, dumpFileName, sele1);
411 >  } else if (args_info.rodlength_given) {
412 >    analyser = new NanoLength(info, dumpFileName, sele1);
413 >  } else if (args_info.angle_r_given) {
414 >    analyser = new AngleR(info, dumpFileName, sele1, maxLen,args_info.nbins_arg);
415 >  }
416 >  
417 >  if (args_info.output_given) {
418 >    analyser->setOutputName(args_info.output_arg);
419 >  }
420 >  if (args_info.step_given) {
421 >    analyser->setStep(args_info.step_arg);
422 >  }
423 >  
424 >  analyser->process();
425 >  
426 >  delete analyser;    
427 >  delete info;
428 >  
429 >  return 0;  
430   }
151

Comparing trunk/src/applications/staticProps/StaticProps.cpp (property svn:keywords):
Revision 354 by tim, Wed Feb 16 20:30:50 2005 UTC vs.
Revision 2015 by gezelter, Wed Aug 13 20:42:43 2014 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines