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

Comparing:
trunk/src/applications/staticProps/StaticProps.cpp (property svn:keywords), Revision 326 by tim, Sun Feb 13 20:05:42 2005 UTC vs.
branches/development/src/applications/staticProps/StaticProps.cpp (property svn:keywords), Revision 1725 by gezelter, Sat May 26 18:13:43 2012 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines