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 369 by tim, Fri Feb 18 23:07:32 2005 UTC vs.
Revision 1585 by gezelter, Sun Jun 19 17:51:15 2011 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, 24107 (2008).          
39 + * [4]  Vardeman & Gezelter, in progress (2009).                        
40   */
41  
42   #include <iostream>
# Line 50 | Line 50
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/RhoAngleR.hpp"
79 + #include "applications/staticProps/TetrahedralityParam.hpp"
80  
81 < using namespace oopse;
81 > using namespace OpenMD;
82  
83   int main(int argc, char* argv[]){
84    
85 <    //register force fields
86 <    registerForceFields();
87 <
88 <    gengetopt_args_info args_info;
89 <
90 <    //parse the command line option
91 <    if (cmdline_parser (argc, argv, &args_info) != 0) {
92 <        exit(1) ;
85 >  //register force fields
86 >  registerForceFields();
87 >  
88 >  gengetopt_args_info args_info;
89 >  
90 >  //parse the command line option
91 >  if (cmdline_parser (argc, argv, &args_info) != 0) {
92 >    exit(1) ;
93 >  }
94 >  
95 >  //get the dumpfile name
96 >  std::string dumpFileName = args_info.input_arg;
97 >  std::string sele1;
98 >  std::string sele2;
99 >  bool userSpecifiedSelect1;
100 >  bool userSpecifiedSelect2;
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 <    //get the dumpfile name and meta-data file name
117 <    std::string dumpFileName = args_info.input_arg;
118 <
119 <    std::string mdFileName = dumpFileName.substr(0, dumpFileName.rfind(".")) + ".md";
120 <
121 <    
122 <    std::string sele1;
123 <    std::string sele2;
124 <
125 <    if (args_info.sele1_given) {
126 <        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 <        }
114 >  }
115 >  
116 >  // check the second selection argument, or set it to the environment
117 >  // variable, or failing that, set it to "select all"
118 >  
119 >  if (args_info.sele2_given) {
120 >    sele2 = args_info.sele2_arg;
121 >  } else {
122 >    char* sele2Env = getenv("SELECTION1");
123 >    if (sele2Env) {
124 >      sele2 = sele2Env;            
125 >    } else {
126 >      sele2 = "select all";
127      }
128 <    
129 <    if (args_info.sele2_given) {
130 <        sele2 = args_info.sele2_arg;
131 <    }else {
132 <        char* sele2Env = getenv("OOPSE_SELE2");
133 <        if (sele2Env) {
134 <            sele2 = sele2Env;            
135 <        } else {
136 <            sprintf( painCave.errMsg,
137 <               "neither --sele2 option nor $OOPSE_SELE2 is set");
138 <            painCave.severity = OOPSE_ERROR;
139 <            painCave.isFatal = 1;
140 <            simError();        
141 <        }
128 >  }
129 >  
130 >  
131 >  // Problems if sele1 wasn't specified, but
132 >  // if (!args_info.scd_given) {
133 >  //       sprintf( painCave.errMsg,
134 >  //                "neither --sele1 option nor $SELECTION1 is set");
135 >  //       painCave.severity = OPENMD_ERROR;
136 >  //       painCave.isFatal = 1;
137 >  //       simError();
138 >  //     }
139 >  //   }
140 >  
141 >  // Problems if sele1 wasn't specified
142 >  
143 >  //     if(!args_info.scd_given && !args_info.density_given && !args_info.slab_density_given)  {
144 >  //       sprintf( painCave.errMsg,
145 >  //                "neither --sele2 option nor $SELECTION1 is set");
146 >  //       painCave.severity = OPENMD_ERROR;
147 >  //       painCave.isFatal = 1;
148 >  //       simError();        
149 >  //     }
150 >  //   }
151 >  
152 >  bool batchMode;
153 >  if (args_info.scd_given){
154 >    if (args_info.sele1_given && args_info.sele2_given && args_info.sele3_given) {
155 >      batchMode = false;
156 >    } else if (args_info.molname_given && args_info.begin_given && args_info.end_given) {
157 >      if (args_info.begin_arg < 0 || args_info.end_arg < 0 || args_info.begin_arg > args_info.end_arg-2) {
158 >        sprintf( painCave.errMsg,
159 >                 "below conditions are not satisfied:\n"
160 >                 "0 <= begin && 0<= end && begin <= end-2\n");
161 >        painCave.severity = OPENMD_ERROR;
162 >        painCave.isFatal = 1;
163 >        simError();                    
164 >      }
165 >      batchMode = true;        
166 >    } else{
167 >      sprintf( painCave.errMsg,
168 >               "either --sele1, --sele2, --sele3 are specified,"
169 >               " or --molname, --begin, --end are specified\n");
170 >      painCave.severity = OPENMD_ERROR;
171 >      painCave.isFatal = 1;
172 >      simError();        
173 >      
174      }
175 +  }
176 +  
177 +  //parse md file and set up the system
178 +  SimCreator creator;
179 +  std::cout << "dumpFile = " << dumpFileName << "\n";
180 +  SimInfo* info = creator.createSim(dumpFileName);
181  
182 <    //parse md file and set up the system
183 <    SimCreator creator;
184 <    SimInfo* info = creator.createSim(mdFileName);
185 <
186 <    double maxLen;
187 <    if (args_info.length_given) {
188 <        maxLen = args_info.length_arg;
182 >  RealType maxLen;
183 >  RealType zmaxLen;
184 >  if (args_info.length_given) {
185 >    maxLen = args_info.length_arg;
186 >    if (args_info.zlength_given){
187 >      zmaxLen = args_info.zlength_arg;
188 >    }
189 >  } else {
190 >    Mat3x3d hmat = info->getSnapshotManager()->getCurrentSnapshot()->getHmat();
191 >    maxLen = std::min(std::min(hmat(0, 0), hmat(1, 1)), hmat(2, 2)) /2.0;
192 >    zmaxLen = hmat(2,2);    
193 >  }    
194 >  
195 >  StaticAnalyser* analyser;
196 >  if (args_info.gofr_given){
197 >    analyser= new GofR(info, dumpFileName, sele1, sele2, maxLen,
198 >                       args_info.nbins_arg);        
199 >  } else if (args_info.gofz_given) {
200 >    analyser= new GofZ(info, dumpFileName, sele1, sele2, maxLen,
201 >                       args_info.nbins_arg);
202 >  } else if (args_info.r_z_given) {
203 >    analyser  = new GofRZ(info, dumpFileName, sele1, sele2, maxLen, zmaxLen,
204 >                          args_info.nbins_arg, args_info.nbins_z_arg);
205 >  } else if (args_info.r_theta_given) {
206 >    analyser  = new GofRTheta(info, dumpFileName, sele1, sele2, maxLen,
207 >                              args_info.nbins_arg, args_info.nanglebins_arg);
208 >  } else if (args_info.r_omega_given) {
209 >    analyser  = new GofROmega(info, dumpFileName, sele1, sele2, maxLen,
210 >                              args_info.nbins_arg, args_info.nanglebins_arg);
211 >  } else if (args_info.theta_omega_given) {
212 >    analyser  = new GofAngle2(info, dumpFileName, sele1, sele2,
213 >                              args_info.nanglebins_arg);
214 >  } else if (args_info.gxyz_given) {
215 >    if (args_info.refsele_given) {
216 >      analyser= new GofXyz(info, dumpFileName, sele1, sele2,args_info.refsele_arg,
217 >                           maxLen, args_info.nbins_arg);        
218      } else {
219 <        Mat3x3d hmat = info->getSnapshotManager()->getCurrentSnapshot()->getHmat();
220 <        maxLen = std::min(std::min(hmat(0, 0), hmat(1, 1)), hmat(2, 2)) /2.0;        
219 >      sprintf( painCave.errMsg,
220 >               "--refsele must set when --gxyz is used");
221 >      painCave.severity = OPENMD_ERROR;
222 >      painCave.isFatal = 1;
223 >      simError();  
224 >    }
225 >  } else if (args_info.twodgofr_given){
226 >    if (args_info.dz_given) {
227 >      analyser= new TwoDGofR(info, dumpFileName, sele1, sele2, maxLen,
228 >                             args_info.dz_arg, args_info.nbins_arg);        
229 >    } else {
230 >      sprintf( painCave.errMsg,
231 >               "A slab width (dz) must be specified when calculating TwoDGofR");
232 >      painCave.severity = OPENMD_ERROR;
233 >      painCave.isFatal = 1;
234 >      simError();
235      }    
236 <
237 <    RadialDistrFunc* rdf;
238 <    if (args_info.gofr_given){
239 <        rdf= new GofR(info, dumpFileName, sele1, sele2, maxLen, args_info.nrbins_arg);        
240 <    } else if (args_info.r_theta_given) {
241 <        rdf  = new GofRTheta(info, dumpFileName, sele1, sele2, maxLen, args_info.nrbins_arg, args_info.nanglebins_arg);
242 <    } else if (args_info.r_omega_given) {
243 <        rdf  = new GofROmega(info, dumpFileName, sele1, sele2, maxLen, args_info.nrbins_arg, args_info.nanglebins_arg);
244 <    } else if (args_info.theta_omega_given) {
245 <        rdf  = new GofAngle2(info, dumpFileName, sele1, sele2, args_info.nanglebins_arg);
246 <    } else if (args_info.gxyz_given) {
247 <        if (args_info.refsele_given) {
135 <            rdf= new GofXyz(info, dumpFileName, sele1, sele2,args_info.refsele_arg, maxLen, args_info.nrbins_arg);        
136 <        } else {
137 <            sprintf( painCave.errMsg,
138 <               "--refsele must set when --gxyz is used");
139 <            painCave.severity = OOPSE_ERROR;
140 <            painCave.isFatal = 1;
141 <            simError();  
142 <        }
236 >  } else if (args_info.p2_given) {
237 >    if (args_info.sele1_given) {    
238 >      if (args_info.sele2_given)
239 >        analyser  = new P2OrderParameter(info, dumpFileName, sele1, sele2);
240 >      else
241 >        analyser  = new P2OrderParameter(info, dumpFileName, sele1);
242 >    } else {
243 >      sprintf( painCave.errMsg,
244 >               "At least one selection script (--sele1) must be specified when calculating P2 order parameters");
245 >      painCave.severity = OPENMD_ERROR;
246 >      painCave.isFatal = 1;
247 >      simError();
248      }
249 +  } else if (args_info.rp2_given){
250 +    analyser = new RippleOP(info, dumpFileName, sele1, sele2);
251 +  } else if (args_info.bo_given){
252 +    if (args_info.rcut_given) {
253 +      analyser = new BondOrderParameter(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 Bond Order Parameters");
259 +      painCave.severity = OPENMD_ERROR;
260 +      painCave.isFatal = 1;
261 +      simError();
262 +    }
263      
264 <    if (args_info.output_given) {
265 <        rdf->setOutputName(args_info.output_arg);
264 >  } else if (args_info.tet_param_given) {
265 >    if (args_info.rcut_given) {  
266 >      analyser = new TetrahedralityParam(info, dumpFileName, sele1,
267 >                                         args_info.rcut_arg,
268 >                                         args_info.nbins_arg);
269 >    } else {
270 >      sprintf( painCave.errMsg,
271 >               "A cutoff radius (rcut) must be specified when calculating Tetrahedrality Parameters");
272 >      painCave.severity = OPENMD_ERROR;
273 >      painCave.isFatal = 1;
274 >      simError();
275      }
276 <    if (args_info.step_given) {
277 <        rdf->setStep(args_info.step_arg);
276 >  } else if (args_info.bor_given){
277 >    if (args_info.rcut_given) {
278 >      analyser = new BOPofR(info, dumpFileName, sele1, args_info.rcut_arg,
279 >                            args_info.nbins_arg, maxLen);
280 >    } else {
281 >      sprintf( painCave.errMsg,
282 >               "A cutoff radius (rcut) must be specified when calculating Bond Order Parameters");
283 >      painCave.severity = OPENMD_ERROR;
284 >      painCave.isFatal = 1;
285 >      simError();
286      }
287 +  } else if (args_info.bad_given){
288 +    if (args_info.rcut_given) {
289 +      analyser = new BondAngleDistribution(info, dumpFileName, sele1, args_info.rcut_arg,
290 +                                           args_info.nbins_arg);
291 +    } else {
292 +      sprintf( painCave.errMsg,
293 +               "A cutoff radius (rcut) must be specified when calculating Bond Angle Distributions");
294 +      painCave.severity = OPENMD_ERROR;
295 +      painCave.isFatal = 1;
296 +      simError();
297 +      }
298 +  } else if (args_info.scd_given) {
299 +    if (batchMode) {
300 +      analyser  = new SCDOrderParameter(info, dumpFileName, args_info.molname_arg,
301 +                                        args_info.begin_arg, args_info.end_arg);
302 +    } else{
303 +      std::string sele3 = args_info.sele3_arg;
304 +      analyser  = new SCDOrderParameter(info, dumpFileName, sele1, sele2, sele3);
305 +    }
306 +  }else if (args_info.density_given) {
307 +    analyser= new DensityPlot(info, dumpFileName, sele1, sele2, maxLen,
308 +                              args_info.nbins_arg);  
309 +  } else if (args_info.count_given) {
310 +    analyser = new ObjectCount(info, dumpFileName, sele1 );
311 +  } else if (args_info.slab_density_given) {
312 +    analyser = new RhoZ(info, dumpFileName, sele1, args_info.nbins_arg);
313 +  } else if (args_info.p_angle_given) {
314 +    analyser = new pAngle(info, dumpFileName, sele1, args_info.nbins_arg);
315 + #if defined(HAVE_FFTW_H) || defined(HAVE_DFFTW_H) || defined(HAVE_FFTW3_H)
316 +  }else if (args_info.hxy_given) {
317 +    analyser = new Hxy(info, dumpFileName, sele1, args_info.nbins_x_arg,
318 +                       args_info.nbins_y_arg, args_info.nbins_arg);
319 + #endif
320 +  }else if (args_info.rho_r_given) {
321 +    if (args_info.radius_given){
322 +      analyser = new RhoR(info, dumpFileName, sele1, maxLen,args_info.nbins_arg,args_info.radius_arg);
323 +    }else{
324 +      sprintf( painCave.errMsg,
325 +               "A particle radius (radius) must be specified when calculating Rho(r)");
326 +      painCave.severity = OPENMD_ERROR;
327 +      painCave.isFatal = 1;
328 +      simError();
329 +    }
330 +  } else if (args_info.hullvol_given) {
331 +    analyser = new NanoVolume(info, dumpFileName, sele1);
332 +  } else if (args_info.rodlength_given) {
333 +    analyser = new NanoLength(info, dumpFileName, sele1);
334 +  } else if (args_info.angle_r_given) {
335 +    analyser = new AngleR(info, dumpFileName, sele1, maxLen,args_info.nbins_arg);
336 +  }
337 +    
338 +  if (args_info.output_given) {
339 +    analyser->setOutputName(args_info.output_arg);
340 +  }
341 +  if (args_info.step_given) {
342 +    analyser->setStep(args_info.step_arg);
343 +  }
344 +  
345 +  analyser->process();
346 +  
347 +  delete analyser;    
348 +  delete info;
349  
350 <    rdf->process();
153 <
154 <    delete rdf;    
155 <    delete info;
156 <
157 <    return 0;  
350 >  return 0;  
351   }
352  

Comparing trunk/src/applications/staticProps/StaticProps.cpp (property svn:keywords):
Revision 369 by tim, Fri Feb 18 23:07:32 2005 UTC vs.
Revision 1585 by gezelter, Sun Jun 19 17:51:15 2011 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines