| 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) ; | 
| 87 | < | } | 
| 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; | 
| 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" | 
| 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; | 
| 99 | > | if (args_info.sele1_given) { | 
| 100 | > | sele1 = args_info.sele1_arg; | 
| 101 |  | } else { | 
| 102 | < | sele1 = "select all"; | 
| 102 | > | char*  sele1Env= getenv("SELECTION1"); | 
| 103 | > | if (sele1Env) { | 
| 104 | > | sele1 = sele1Env; | 
| 105 | > | } else { | 
| 106 | > | sele1 = "select all"; | 
| 107 | > | } | 
| 108 |  | } | 
| 108 | – | } | 
| 109 |  |  | 
| 110 | < | // check the second selection argument, or set it to the environment | 
| 111 | < | // variable, or failing that, set it to "select all" | 
| 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"; | 
| 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 |  | } | 
| 122 | – | } | 
| 123 |  |  | 
| 124 |  |  | 
| 125 | < | // Problems if sele1 wasn't specified, but | 
| 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"); | 
| 132 |  | //     } | 
| 133 |  | //   } | 
| 134 |  |  | 
| 135 | < | // Problems if sele1 wasn't specified | 
| 135 | > | // Problems if sele1 wasn't specified | 
| 136 |  |  | 
| 137 |  | //     if(!args_info.scd_given && !args_info.density_given && !args_info.slab_density_given)  { | 
| 138 |  | //       sprintf( painCave.errMsg, | 
| 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(); | 
| 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 |  |  | 
| 168 | + | } | 
| 169 |  | } | 
| 169 | – | } | 
| 170 |  |  | 
| 171 | < | //parse md file and set up the system | 
| 172 | < | SimCreator creator; | 
| 173 | < | std::cout << "dumpFile = " << dumpFileName << "\n"; | 
| 174 | < | SimInfo* info = creator.createSim(dumpFileName); | 
| 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 | < | 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 | < | } | 
| 176 | > | RealType maxLen; | 
| 177 | > | RealType zmaxLen; | 
| 178 | > | if (args_info.length_given) { | 
| 179 | > | maxLen = args_info.length_arg; | 
| 180 | > | if (args_info.zlength_given){ | 
| 181 | > | zmaxLen = args_info.zlength_arg; | 
| 182 | > | } | 
| 183 | > | } else { | 
| 184 | > | Mat3x3d hmat = info->getSnapshotManager()->getCurrentSnapshot()->getHmat(); | 
| 185 | > | maxLen = std::min(std::min(hmat(0, 0), hmat(1, 1)), hmat(2, 2)) /2.0; | 
| 186 | > | zmaxLen = hmat(2,2); | 
| 187 | > | } | 
| 188 |  |  | 
| 189 | < | StaticAnalyser* analyser; | 
| 190 | < | if (args_info.gofr_given){ | 
| 191 | < | analyser= new GofR(info, dumpFileName, sele1, sele2, maxLen, | 
| 192 | < | args_info.nbins_arg); | 
| 193 | < | } else if (args_info.gofz_given) { | 
| 194 | < | analyser= new GofZ(info, dumpFileName, sele1, sele2, maxLen, | 
| 195 | < | args_info.nbins_arg); | 
| 196 | < | } else if (args_info.r_z_given) { | 
| 197 | < | analyser  = new GofRZ(info, dumpFileName, sele1, sele2, maxLen, | 
| 189 | > | StaticAnalyser* analyser; | 
| 190 | > | if (args_info.gofr_given){ | 
| 191 | > | analyser= new GofR(info, dumpFileName, sele1, sele2, maxLen, | 
| 192 | > | args_info.nbins_arg); | 
| 193 | > | } else if (args_info.gofz_given) { | 
| 194 | > | analyser= new GofZ(info, dumpFileName, sele1, sele2, maxLen, | 
| 195 | > | args_info.nbins_arg); | 
| 196 | > | } else if (args_info.r_z_given) { | 
| 197 | > | analyser  = new GofRZ(info, dumpFileName, sele1, sele2, maxLen, zmaxLen, | 
| 198 |  | args_info.nbins_arg, args_info.nbins_z_arg); | 
| 199 | < | } else if (args_info.r_theta_given) { | 
| 200 | < | analyser  = new GofRTheta(info, dumpFileName, sele1, sele2, maxLen, | 
| 201 | < | args_info.nbins_arg, args_info.nanglebins_arg); | 
| 202 | < | } else if (args_info.r_omega_given) { | 
| 203 | < | analyser  = new GofROmega(info, dumpFileName, sele1, sele2, maxLen, | 
| 204 | < | args_info.nbins_arg, args_info.nanglebins_arg); | 
| 205 | < | } else if (args_info.theta_omega_given) { | 
| 206 | < | analyser  = new GofAngle2(info, dumpFileName, sele1, sele2, | 
| 207 | < | args_info.nanglebins_arg); | 
| 208 | < | } else if (args_info.gxyz_given) { | 
| 209 | < | if (args_info.refsele_given) { | 
| 210 | < | analyser= new GofXyz(info, dumpFileName, sele1, sele2,args_info.refsele_arg, | 
| 211 | < | maxLen, args_info.nbins_arg); | 
| 212 | < | } else { | 
| 213 | < | sprintf( painCave.errMsg, | 
| 214 | < | "--refsele must set when --gxyz is used"); | 
| 215 | < | painCave.severity = OPENMD_ERROR; | 
| 216 | < | painCave.isFatal = 1; | 
| 217 | < | simError(); | 
| 218 | < | } | 
| 219 | < | } else if (args_info.p2_given) { | 
| 220 | < | analyser  = new P2OrderParameter(info, dumpFileName, sele1, sele2); | 
| 221 | < | } else if (args_info.rp2_given){ | 
| 222 | < | analyser = new RippleOP(info, dumpFileName, sele1, sele2); | 
| 223 | < | } else if (args_info.bo_given){ | 
| 224 | < | if (args_info.rcut_given) { | 
| 225 | < | analyser = new BondOrderParameter(info, dumpFileName, sele1, | 
| 226 | < | args_info.rcut_arg, | 
| 227 | < | args_info.nbins_arg); | 
| 228 | < | } else { | 
| 229 | < | sprintf( painCave.errMsg, | 
| 230 | < | "A cutoff radius (rcut) must be specified when calculating Bond Order Parameters"); | 
| 231 | < | painCave.severity = OPENMD_ERROR; | 
| 232 | < | painCave.isFatal = 1; | 
| 233 | < | simError(); | 
| 234 | < | } | 
| 235 | < | } else if (args_info.bor_given){ | 
| 236 | < | if (args_info.rcut_given) { | 
| 237 | < | analyser = new BOPofR(info, dumpFileName, sele1, args_info.rcut_arg, | 
| 238 | < | args_info.nbins_arg, maxLen); | 
| 239 | < | } else { | 
| 240 | < | sprintf( painCave.errMsg, | 
| 241 | < | "A cutoff radius (rcut) must be specified when calculating Bond Order Parameters"); | 
| 242 | < | painCave.severity = OPENMD_ERROR; | 
| 243 | < | painCave.isFatal = 1; | 
| 244 | < | simError(); | 
| 245 | < | } | 
| 246 | < | } else if (args_info.bad_given){ | 
| 247 | < | if (args_info.rcut_given) { | 
| 248 | < | analyser = new BondAngleDistribution(info, dumpFileName, sele1, args_info.rcut_arg, | 
| 249 | < | args_info.nbins_arg); | 
| 250 | < | } else { | 
| 251 | < | sprintf( painCave.errMsg, | 
| 252 | < | "A cutoff radius (rcut) must be specified when calculating Bond Angle Distributions"); | 
| 253 | < | painCave.severity = OPENMD_ERROR; | 
| 254 | < | painCave.isFatal = 1; | 
| 255 | < | simError(); | 
| 256 | < | } | 
| 257 | < | } else if (args_info.scd_given) { | 
| 258 | < | if (batchMode) { | 
| 259 | < | analyser  = new SCDOrderParameter(info, dumpFileName, args_info.molname_arg, | 
| 260 | < | args_info.begin_arg, args_info.end_arg); | 
| 261 | < | } else{ | 
| 262 | < | std::string sele3 = args_info.sele3_arg; | 
| 263 | < | analyser  = new SCDOrderParameter(info, dumpFileName, sele1, sele2, sele3); | 
| 264 | < | } | 
| 265 | < | }else if (args_info.density_given) { | 
| 266 | < | analyser= new DensityPlot(info, dumpFileName, sele1, sele2, maxLen, | 
| 267 | < | args_info.nbins_arg); | 
| 268 | < | } else if (args_info.slab_density_given) { | 
| 269 | < | analyser = new RhoZ(info, dumpFileName, sele1, args_info.nbins_arg); | 
| 270 | < | } else if (args_info.p_angle_given) { | 
| 271 | < | analyser = new pAngle(info, dumpFileName, sele1, args_info.nbins_arg); | 
| 199 | > | } else if (args_info.r_theta_given) { | 
| 200 | > | analyser  = new GofRTheta(info, dumpFileName, sele1, sele2, maxLen, | 
| 201 | > | args_info.nbins_arg, args_info.nanglebins_arg); | 
| 202 | > | } else if (args_info.r_omega_given) { | 
| 203 | > | analyser  = new GofROmega(info, dumpFileName, sele1, sele2, maxLen, | 
| 204 | > | args_info.nbins_arg, args_info.nanglebins_arg); | 
| 205 | > | } else if (args_info.theta_omega_given) { | 
| 206 | > | analyser  = new GofAngle2(info, dumpFileName, sele1, sele2, | 
| 207 | > | args_info.nanglebins_arg); | 
| 208 | > | } else if (args_info.gxyz_given) { | 
| 209 | > | if (args_info.refsele_given) { | 
| 210 | > | analyser= new GofXyz(info, dumpFileName, sele1, sele2,args_info.refsele_arg, | 
| 211 | > | maxLen, args_info.nbins_arg); | 
| 212 | > | } else { | 
| 213 | > | sprintf( painCave.errMsg, | 
| 214 | > | "--refsele must set when --gxyz is used"); | 
| 215 | > | painCave.severity = OPENMD_ERROR; | 
| 216 | > | painCave.isFatal = 1; | 
| 217 | > | simError(); | 
| 218 | > | } | 
| 219 | > | } else if (args_info.p2_given) { | 
| 220 | > | analyser  = new P2OrderParameter(info, dumpFileName, sele1, sele2); | 
| 221 | > | } else if (args_info.rp2_given){ | 
| 222 | > | analyser = new RippleOP(info, dumpFileName, sele1, sele2); | 
| 223 | > | } else if (args_info.bo_given){ | 
| 224 | > | if (args_info.rcut_given) { | 
| 225 | > | analyser = new BondOrderParameter(info, dumpFileName, sele1, | 
| 226 | > | args_info.rcut_arg, | 
| 227 | > | args_info.nbins_arg); | 
| 228 | > | } else { | 
| 229 | > | sprintf( painCave.errMsg, | 
| 230 | > | "A cutoff radius (rcut) must be specified when calculating Bond Order Parameters"); | 
| 231 | > | painCave.severity = OPENMD_ERROR; | 
| 232 | > | painCave.isFatal = 1; | 
| 233 | > | simError(); | 
| 234 | > | } | 
| 235 | > | } else if (args_info.bor_given){ | 
| 236 | > | if (args_info.rcut_given) { | 
| 237 | > | analyser = new BOPofR(info, dumpFileName, sele1, args_info.rcut_arg, | 
| 238 | > | args_info.nbins_arg, maxLen); | 
| 239 | > | } else { | 
| 240 | > | sprintf( painCave.errMsg, | 
| 241 | > | "A cutoff radius (rcut) must be specified when calculating Bond Order Parameters"); | 
| 242 | > | painCave.severity = OPENMD_ERROR; | 
| 243 | > | painCave.isFatal = 1; | 
| 244 | > | simError(); | 
| 245 | > | } | 
| 246 | > | } else if (args_info.bad_given){ | 
| 247 | > | if (args_info.rcut_given) { | 
| 248 | > | analyser = new BondAngleDistribution(info, dumpFileName, sele1, args_info.rcut_arg, | 
| 249 | > | args_info.nbins_arg); | 
| 250 | > | } else { | 
| 251 | > | sprintf( painCave.errMsg, | 
| 252 | > | "A cutoff radius (rcut) must be specified when calculating Bond Angle Distributions"); | 
| 253 | > | painCave.severity = OPENMD_ERROR; | 
| 254 | > | painCave.isFatal = 1; | 
| 255 | > | simError(); | 
| 256 | > | } | 
| 257 | > | } else if (args_info.scd_given) { | 
| 258 | > | if (batchMode) { | 
| 259 | > | analyser  = new SCDOrderParameter(info, dumpFileName, args_info.molname_arg, | 
| 260 | > | args_info.begin_arg, args_info.end_arg); | 
| 261 | > | } else{ | 
| 262 | > | std::string sele3 = args_info.sele3_arg; | 
| 263 | > | analyser  = new SCDOrderParameter(info, dumpFileName, sele1, sele2, sele3); | 
| 264 | > | } | 
| 265 | > | }else if (args_info.density_given) { | 
| 266 | > | analyser= new DensityPlot(info, dumpFileName, sele1, sele2, maxLen, | 
| 267 | > | args_info.nbins_arg); | 
| 268 | > | } else if (args_info.slab_density_given) { | 
| 269 | > | analyser = new RhoZ(info, dumpFileName, sele1, args_info.nbins_arg); | 
| 270 | > | } else if (args_info.p_angle_given) { | 
| 271 | > | analyser = new pAngle(info, dumpFileName, sele1, args_info.nbins_arg); | 
| 272 |  | #if defined(HAVE_FFTW_H) || defined(HAVE_DFFTW_H) || defined(HAVE_FFTW3_H) | 
| 273 | < | }else if (args_info.hxy_given) { | 
| 274 | < | analyser = new Hxy(info, dumpFileName, sele1, args_info.nbins_x_arg, | 
| 275 | < | args_info.nbins_y_arg, args_info.nbins_arg); | 
| 273 | > | }else if (args_info.hxy_given) { | 
| 274 | > | analyser = new Hxy(info, dumpFileName, sele1, args_info.nbins_x_arg, | 
| 275 | > | args_info.nbins_y_arg, args_info.nbins_arg); | 
| 276 |  | #endif | 
| 277 | < | }else if (args_info.rho_r_given) { | 
| 278 | < | if (args_info.radius_given){ | 
| 279 | < | analyser = new RhoR(info, dumpFileName, sele1, maxLen,args_info.nbins_arg,args_info.radius_arg); | 
| 280 | < | }else{ | 
| 281 | < | sprintf( painCave.errMsg, | 
| 282 | < | "A particle radius (radius) must be specified when calculating Rho(r)"); | 
| 283 | < | painCave.severity = OPENMD_ERROR; | 
| 284 | < | painCave.isFatal = 1; | 
| 285 | < | simError(); | 
| 277 | > | }else if (args_info.rho_r_given) { | 
| 278 | > | if (args_info.radius_given){ | 
| 279 | > | analyser = new RhoR(info, dumpFileName, sele1, maxLen,args_info.nbins_arg,args_info.radius_arg); | 
| 280 | > | }else{ | 
| 281 | > | sprintf( painCave.errMsg, | 
| 282 | > | "A particle radius (radius) must be specified when calculating Rho(r)"); | 
| 283 | > | painCave.severity = OPENMD_ERROR; | 
| 284 | > | painCave.isFatal = 1; | 
| 285 | > | simError(); | 
| 286 | > | } | 
| 287 | > | }else if (args_info.hullvol_given) { | 
| 288 | > | analyser = new NanoVolume(info, dumpFileName, sele1); | 
| 289 |  | } | 
| 282 | – | }else if (args_info.hullvol_given) { | 
| 283 | – | analyser = new NanoVolume(info, dumpFileName, sele1); | 
| 284 | – | } | 
| 290 |  |  | 
| 291 | < | if (args_info.output_given) { | 
| 292 | < | analyser->setOutputName(args_info.output_arg); | 
| 293 | < | } | 
| 294 | < | if (args_info.step_given) { | 
| 295 | < | analyser->setStep(args_info.step_arg); | 
| 296 | < | } | 
| 291 | > | if (args_info.output_given) { | 
| 292 | > | analyser->setOutputName(args_info.output_arg); | 
| 293 | > | } | 
| 294 | > | if (args_info.step_given) { | 
| 295 | > | analyser->setStep(args_info.step_arg); | 
| 296 | > | } | 
| 297 |  |  | 
| 298 | < | analyser->process(); | 
| 298 | > | analyser->process(); | 
| 299 |  |  | 
| 300 | < | delete analyser; | 
| 301 | < | delete info; | 
| 300 | > | delete analyser; | 
| 301 | > | delete info; | 
| 302 |  |  | 
| 303 | < | return 0; | 
| 303 | > | return 0; | 
| 304 |  | } | 
| 305 |  |  |