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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines