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 1454 by gezelter, Wed Jun 23 19:25:02 2010 UTC vs.
Revision 1513 by gezelter, Tue Oct 19 18:40:54 2010 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines