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

Comparing trunk/src/applications/staticProps/StaticProps.cpp (property svn:keywords):
Revision 326 by tim, Sun Feb 13 20:05:42 2005 UTC vs.
Revision 1998 by gezelter, Fri May 30 19:48:35 2014 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines