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 1440 by gezelter, Thu Apr 29 14:41:48 2010 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/P2OrderParameter.hpp"
61 + #include "applications/staticProps/BondOrderParameter.hpp"
62 + #include "applications/staticProps/BOPofR.hpp"
63 + #include "applications/staticProps/RippleOP.hpp"
64 + #include "applications/staticProps/SCDOrderParameter.hpp"
65 + #include "applications/staticProps/DensityPlot.hpp"
66 + #include "applications/staticProps/RhoZ.hpp"
67 + #include "applications/staticProps/pAngle.hpp"
68 + #include "applications/staticProps/BondAngleDistribution.hpp"
69 + #include "applications/staticProps/NanoVolume.hpp"
70 + #if defined(HAVE_FFTW_H) || defined(HAVE_DFFTW_H) || defined(HAVE_FFTW3_H)
71 + #include "applications/staticProps/Hxy.hpp"
72 + #endif
73 + #include "applications/staticProps/RhoR.hpp"
74  
75 < using namespace oopse;
75 > using namespace OpenMD;
76  
77   int main(int argc, char* argv[]){
78    
79 <    //register force fields
80 <    registerForceFields();
79 >  //register force fields
80 >  registerForceFields();
81  
82 <    gengetopt_args_info args_info;
82 >  gengetopt_args_info args_info;
83  
84 <    //parse the command line option
85 <    if (cmdline_parser (argc, argv, &args_info) != 0) {
86 <        exit(1) ;
84 >  //parse the command line option
85 >  if (cmdline_parser (argc, argv, &args_info) != 0) {
86 >    exit(1) ;
87 >  }
88 >
89 >  //get the dumpfile name
90 >  std::string dumpFileName = args_info.input_arg;
91 >  std::string sele1;
92 >  std::string sele2;
93 >  bool userSpecifiedSelect1;
94 >  bool userSpecifiedSelect2;
95 >
96 >  // check the first selection argument, or set it to the environment
97 >  // variable, or failing that, set it to "select all"
98 >
99 >  if (args_info.sele1_given) {
100 >    sele1 = args_info.sele1_arg;
101 >  } else {
102 >    char*  sele1Env= getenv("SELECTION1");
103 >    if (sele1Env) {
104 >      sele1 = sele1Env;
105 >    } else {
106 >      sele1 = "select all";
107      }
108 +  }
109  
110 +  // check the second selection argument, or set it to the environment
111 +  // variable, or failing that, set it to "select all"
112 +  
113 +  if (args_info.sele2_given) {
114 +    sele2 = args_info.sele2_arg;
115 +  } else {
116 +    char* sele2Env = getenv("SELECTION1");
117 +    if (sele2Env) {
118 +      sele2 = sele2Env;            
119 +    } else {
120 +      sele2 = "select all";
121 +    }
122 +  }
123  
73    //get the dumpfile name and meta-data file name
74    std::string dumpFileName = args_info.input_arg;
124  
125 <    std::string mdFileName = dumpFileName.substr(0, dumpFileName.rfind(".")) + ".md";
125 >  // Problems if sele1 wasn't specified, but
126 > // if (!args_info.scd_given) {
127 > //       sprintf( painCave.errMsg,
128 > //                "neither --sele1 option nor $SELECTION1 is set");
129 > //       painCave.severity = OPENMD_ERROR;
130 > //       painCave.isFatal = 1;
131 > //       simError();
132 > //     }
133 > //   }
134  
135 <    
79 <    std::string sele1;
80 <    std::string sele2;
135 >  // Problems if sele1 wasn't specified
136  
137 <    if (args_info.sele1_given) {
138 <        sele1 = args_info.sele1_arg;
139 <    }else {
140 <        char*  sele1Env= getenv("OOPSE_SELE1");
141 <        if (sele1Env) {
142 <            sele1 = sele1Env;
143 <        }else {
144 <            sprintf( painCave.errMsg,
145 <               "neither --sele1 option nor $OOPSE_SELE1 is set");
146 <            painCave.severity = OOPSE_ERROR;
147 <            painCave.isFatal = 1;
148 <            simError();
149 <        }
150 <    }
137 > //     if(!args_info.scd_given && !args_info.density_given && !args_info.slab_density_given)  {
138 > //       sprintf( painCave.errMsg,
139 > //                "neither --sele2 option nor $SELECTION1 is set");
140 > //       painCave.severity = OPENMD_ERROR;
141 > //       painCave.isFatal = 1;
142 > //       simError();        
143 > //     }
144 > //   }
145 >
146 >  bool batchMode;
147 >  if (args_info.scd_given){
148 >    if (args_info.sele1_given && args_info.sele2_given && args_info.sele3_given) {
149 >      batchMode = false;
150 >    } else if (args_info.molname_given && args_info.begin_given && args_info.end_given) {
151 >      if (args_info.begin_arg < 0 || args_info.end_arg < 0 || args_info.begin_arg > args_info.end_arg-2) {
152 >        sprintf( painCave.errMsg,
153 >                 "below conditions are not satisfied:\n"
154 >                 "0 <= begin && 0<= end && begin <= end-2\n");
155 >        painCave.severity = OPENMD_ERROR;
156 >        painCave.isFatal = 1;
157 >        simError();                    
158 >      }
159 >      batchMode = true;        
160 >    } else{
161 >      sprintf( painCave.errMsg,
162 >               "either --sele1, --sele2, --sele3 are specified,"
163 >               " or --molname, --begin, --end are specified\n");
164 >      painCave.severity = OPENMD_ERROR;
165 >      painCave.isFatal = 1;
166 >      simError();        
167      
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        }
168      }
169 +  }
170  
171 <    //parse md file and set up the system
172 <    SimCreator creator;
173 <    SimInfo* info = creator.createSim(mdFileName);
171 >  //parse md file and set up the system
172 >  SimCreator creator;
173 >  std::cout << "dumpFile = " << dumpFileName << "\n";
174 >  SimInfo* info = creator.createSim(dumpFileName);
175  
176 <    double maxLen;
177 <    if (args_info.length_given) {
178 <        maxLen = args_info.length_arg;
179 <    } else {
180 <        Mat3x3d hmat = info->getSnapshotManager()->getCurrentSnapshot()->getHmat();
181 <        maxLen = std::min(std::min(hmat(0, 0), hmat(1, 1)), hmat(2, 2)) /2.0;        
182 <    }    
176 >  RealType maxLen;
177 >  if (args_info.length_given) {
178 >    maxLen = args_info.length_arg;
179 >  } else {
180 >    Mat3x3d hmat = info->getSnapshotManager()->getCurrentSnapshot()->getHmat();
181 >    maxLen = std::min(std::min(hmat(0, 0), hmat(1, 1)), hmat(2, 2)) /2.0;        
182 >  }    
183  
184 <    RadialDistrFunc* rdf;
185 <    if (args_info.gofr_given){
186 <        rdf= new GofR(info, dumpFileName, sele1, sele2, maxLen, args_info.nrbins_arg);        
187 <    } else if (args_info.r_theta_given) {
188 <        rdf  = new GofRTheta(info, dumpFileName, sele1, sele2, maxLen, args_info.nrbins_arg, args_info.nanglebins_arg);
189 <    } else if (args_info.r_omega_given) {
190 <        rdf  = new GofROmega(info, dumpFileName, sele1, sele2, maxLen, args_info.nrbins_arg, args_info.nanglebins_arg);
191 <    } else if (args_info.theta_omega_given) {
192 <        rdf  = new GofAngle2(info, dumpFileName, sele1, sele2, args_info.nanglebins_arg);
193 <    } else if (args_info.gxyz_given) {
194 <        if (args_info.refsele_given) {
195 <            rdf= new GofXyz(info, dumpFileName, sele1, sele2,args_info.refsele_arg, maxLen, args_info.nrbins_arg);        
196 <        } else {
197 <            sprintf( painCave.errMsg,
184 >  StaticAnalyser* analyser;
185 >  if (args_info.gofr_given){
186 >    analyser= new GofR(info, dumpFileName, sele1, sele2, maxLen,
187 >                       args_info.nbins_arg);        
188 >  } else if (args_info.gofz_given) {
189 >    analyser= new GofZ(info, dumpFileName, sele1, sele2, maxLen,
190 >                       args_info.nbins_arg);
191 >  } else if (args_info.r_z_given) {
192 >    analyser  = new GofRZ(info, dumpFileName, sele1, sele2, maxLen,
193 >                              args_info.nbins_arg, args_info.nbins_z_arg);
194 >  } else if (args_info.r_theta_given) {
195 >    analyser  = new GofRTheta(info, dumpFileName, sele1, sele2, maxLen,
196 >                              args_info.nbins_arg, args_info.nanglebins_arg);
197 >  } else if (args_info.r_omega_given) {
198 >    analyser  = new GofROmega(info, dumpFileName, sele1, sele2, maxLen,
199 >                              args_info.nbins_arg, args_info.nanglebins_arg);
200 >  } else if (args_info.theta_omega_given) {
201 >    analyser  = new GofAngle2(info, dumpFileName, sele1, sele2,
202 >                              args_info.nanglebins_arg);
203 >  } else if (args_info.gxyz_given) {
204 >    if (args_info.refsele_given) {
205 >      analyser= new GofXyz(info, dumpFileName, sele1, sele2,args_info.refsele_arg,
206 >                           maxLen, args_info.nbins_arg);        
207 >    } else {
208 >      sprintf( painCave.errMsg,
209                 "--refsele must set when --gxyz is used");
210 <            painCave.severity = OOPSE_ERROR;
211 <            painCave.isFatal = 1;
212 <            simError();  
142 <        }
210 >      painCave.severity = OPENMD_ERROR;
211 >      painCave.isFatal = 1;
212 >      simError();  
213      }
214 <    
215 <    if (args_info.output_given) {
216 <        rdf->setOutputName(args_info.output_arg);
214 >  } else if (args_info.p2_given) {
215 >    analyser  = new P2OrderParameter(info, dumpFileName, sele1, sele2);
216 >  } else if (args_info.rp2_given){
217 >    analyser = new RippleOP(info, dumpFileName, sele1, sele2);
218 >  } else if (args_info.bo_given){
219 >    if (args_info.rcut_given) {
220 >      analyser = new BondOrderParameter(info, dumpFileName, sele1,
221 >                                        args_info.rcut_arg,
222 >                                        args_info.nbins_arg);
223 >    } else {
224 >      sprintf( painCave.errMsg,
225 >               "A cutoff radius (rcut) must be specified when calculating Bond Order Parameters");
226 >      painCave.severity = OPENMD_ERROR;
227 >      painCave.isFatal = 1;
228 >      simError();
229      }
230 <    if (args_info.step_given) {
231 <        rdf->setStep(args_info.step_arg);
230 >  } else if (args_info.bor_given){
231 >    if (args_info.rcut_given) {
232 >      analyser = new BOPofR(info, dumpFileName, sele1, args_info.rcut_arg,
233 >                            args_info.nbins_arg, maxLen);
234 >    } else {
235 >      sprintf( painCave.errMsg,
236 >               "A cutoff radius (rcut) must be specified when calculating Bond Order Parameters");
237 >      painCave.severity = OPENMD_ERROR;
238 >      painCave.isFatal = 1;
239 >      simError();
240      }
241 +  } else if (args_info.bad_given){
242 +    if (args_info.rcut_given) {
243 +      analyser = new BondAngleDistribution(info, dumpFileName, sele1, args_info.rcut_arg,
244 +                            args_info.nbins_arg);
245 +    } else {
246 +      sprintf( painCave.errMsg,
247 +               "A cutoff radius (rcut) must be specified when calculating Bond Angle Distributions");
248 +      painCave.severity = OPENMD_ERROR;
249 +      painCave.isFatal = 1;
250 +      simError();
251 +    }
252 +  } else if (args_info.scd_given) {
253 +    if (batchMode) {
254 +      analyser  = new SCDOrderParameter(info, dumpFileName, args_info.molname_arg,
255 +                                        args_info.begin_arg, args_info.end_arg);
256 +    } else{
257 +      std::string sele3 = args_info.sele3_arg;
258 +      analyser  = new SCDOrderParameter(info, dumpFileName, sele1, sele2, sele3);
259 +    }
260 +  }else if (args_info.density_given) {
261 +    analyser= new DensityPlot(info, dumpFileName, sele1, sele2, maxLen,
262 +                              args_info.nbins_arg);  
263 +  } else if (args_info.slab_density_given) {
264 +    analyser = new RhoZ(info, dumpFileName, sele1, args_info.nbins_arg);
265 +  } else if (args_info.p_angle_given) {
266 +    analyser = new pAngle(info, dumpFileName, sele1, args_info.nbins_arg);
267 + #if defined(HAVE_FFTW_H) || defined(HAVE_DFFTW_H) || defined(HAVE_FFTW3_H)
268 +  }else if (args_info.hxy_given) {
269 +    analyser = new Hxy(info, dumpFileName, sele1, args_info.nbins_x_arg,
270 +                       args_info.nbins_y_arg, args_info.nbins_arg);
271 + #endif
272 +  }else if (args_info.rho_r_given) {
273 +    if (args_info.radius_given){
274 +      analyser = new RhoR(info, dumpFileName, sele1, maxLen,args_info.nbins_arg,args_info.radius_arg);
275 +    }else{
276 +      sprintf( painCave.errMsg,
277 +               "A particle radius (radius) must be specified when calculating Rho(r)");
278 +      painCave.severity = OPENMD_ERROR;
279 +      painCave.isFatal = 1;
280 +      simError();
281 +    }
282 +        }else if (args_info.hullvol_given) {
283 +    analyser = new NanoVolume(info, dumpFileName, sele1);
284 +  }
285 +  
286 +  if (args_info.output_given) {
287 +    analyser->setOutputName(args_info.output_arg);
288 +  }
289 +  if (args_info.step_given) {
290 +    analyser->setStep(args_info.step_arg);
291 +  }
292  
293 <    rdf->process();
293 >  analyser->process();
294  
295 <    delete rdf;    
296 <    delete info;
295 >  delete analyser;    
296 >  delete info;
297  
298 <    return 0;  
298 >  return 0;  
299   }
300  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines