Changeset 62dabe
- Timestamp:
- Jul 6, 2012, 5:43:58 PM (13 years ago)
- Children:
- aa42a9
- Parents:
- d11832
- File:
-
- 1 edited
-
src/bin/mpqc/mpqc.cc (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/bin/mpqc/mpqc.cc
rd11832 r62dabe 49 49 #include <fstream> 50 50 51 #include <boost/bind.hpp> 52 #include <boost/function.hpp> 53 51 54 #include <scconfig.h> 52 55 #ifdef HAVE_SSTREAM … … 178 181 } 179 182 180 int 181 try_main(int argc, char *argv[]) 183 double EvaluateDensity( 184 SCVector3 &r, 185 Ref<Integral> &intgrl, 186 GaussianBasisSet::ValueData &vdat, 187 Ref<Wavefunction> &wfn); 188 189 /** Places all known options into \a options and parses them from argc,argv. 190 * 191 * \param options options structure 192 * \param argc argument count 193 * \param argv argument array 194 * \return return value by GetLongOpt::parse() function 195 */ 196 int ParseOptions(GetLongOpt &options, int argc, char **argv) 182 197 { 183 //trash_stack();184 185 KeyValValueboolean truevalue(1), falsevalue(0);186 int i;187 const char *devnull = "/dev/null";188 atexit(clean_up);189 190 #ifdef HAVE_FEENABLEEXCEPT191 // this uses a glibc extension to trap on individual exceptions192 # ifdef FE_DIVBYZERO193 feenableexcept(FE_DIVBYZERO);194 # endif195 # ifdef FE_INVALID196 feenableexcept(FE_INVALID);197 # endif198 # ifdef FE_OVERFLOW199 feenableexcept(FE_OVERFLOW);200 # endif201 #endif202 203 #ifdef HAVE_FEDISABLEEXCEPT204 // this uses a glibc extension to not trap on individual exceptions205 # ifdef FE_UNDERFLOW206 fedisableexcept(FE_UNDERFLOW);207 # endif208 # ifdef FE_INEXACT209 fedisableexcept(FE_INEXACT);210 # endif211 #endif212 213 #if defined(HAVE_SETRLIMIT)214 struct rlimit rlim;215 rlim.rlim_cur = 0;216 rlim.rlim_max = 0;217 setrlimit(RLIMIT_CORE,&rlim);218 #endif219 220 ExEnv::init(argc, argv);221 222 Ref<MessageGrp> grp;223 #if defined(HAVE_MPI) && defined(ALWAYS_USE_MPI)224 grp = new MPIMessageGrp(&argc, &argv);225 #endif226 227 // parse commandline options228 GetLongOpt options;229 230 198 options.usage("[options] [filename]"); 231 199 options.enroll("f", GetLongOpt::MandatoryValue, … … 254 222 options.enroll("d", GetLongOpt::NoValue, "debug", 0); 255 223 options.enroll("h", GetLongOpt::NoValue, "print this message", 0); 256 options.enroll("cca-path", GetLongOpt::OptionalValue, 224 options.enroll("cca-path", GetLongOpt::OptionalValue, 257 225 "cca component path", ""); 258 226 options.enroll("cca-load", GetLongOpt::OptionalValue, … … 261 229 int optind = options.parse(argc, argv); 262 230 263 const char *output = options.retrieve("o"); 264 ostream *outstream = 0; 231 return optind; 232 } 233 234 /** Checks for each known option and acts accordingly. 235 * 236 * \param options option structure 237 * \param *output name of outputfile on return 238 * \param *outstream open output stream on return 239 */ 240 void ComputeOptions(GetLongOpt &options, const char *&output, ostream *&outstream) 241 { 242 output = options.retrieve("o"); 243 outstream = 0; 265 244 if (output != 0) { 266 245 outstream = new ofstream(output); … … 276 255 exit(0); 277 256 } 278 257 279 258 if (options.retrieve("v")) { 280 259 ExEnv::out0() … … 284 263 exit(0); 285 264 } 286 265 287 266 if (options.retrieve("w")) { 288 267 ExEnv::out0() … … 293 272 exit(0); 294 273 } 295 274 296 275 if (options.retrieve("L")) { 297 276 ExEnv::out0() … … 305 284 // set the working dir 306 285 if (strcmp(options.retrieve("W"),".")) 307 chdir(options.retrieve("W"));286 int retval = chdir(options.retrieve("W")); 308 287 309 288 // check that n and f/o are not given at the same time … … 311 290 throw invalid_argument("-n must not be given with -f or -o"); 312 291 } 292 } 293 294 int 295 try_main(int argc, char *argv[]) 296 { 297 //trash_stack(); 298 299 KeyValValueboolean truevalue(1), falsevalue(0); 300 int i; 301 const char *devnull = "/dev/null"; 302 atexit(clean_up); 303 304 #ifdef HAVE_FEENABLEEXCEPT 305 // this uses a glibc extension to trap on individual exceptions 306 # ifdef FE_DIVBYZERO 307 feenableexcept(FE_DIVBYZERO); 308 # endif 309 # ifdef FE_INVALID 310 feenableexcept(FE_INVALID); 311 # endif 312 # ifdef FE_OVERFLOW 313 feenableexcept(FE_OVERFLOW); 314 # endif 315 #endif 316 317 #ifdef HAVE_FEDISABLEEXCEPT 318 // this uses a glibc extension to not trap on individual exceptions 319 # ifdef FE_UNDERFLOW 320 fedisableexcept(FE_UNDERFLOW); 321 # endif 322 # ifdef FE_INEXACT 323 fedisableexcept(FE_INEXACT); 324 # endif 325 #endif 326 327 #if defined(HAVE_SETRLIMIT) 328 struct rlimit rlim; 329 rlim.rlim_cur = 0; 330 rlim.rlim_max = 0; 331 setrlimit(RLIMIT_CORE,&rlim); 332 #endif 333 334 ExEnv::init(argc, argv); 335 336 // parse commandline options 337 GetLongOpt options; 338 int optind = ParseOptions(options, argc, argv); 339 const char *output = 0; 340 ostream *outstream = 0; 341 ComputeOptions(options, output, outstream); 313 342 314 343 // initialize keyval input … … 327 356 328 357 // get the message group. first try the commandline and environment 358 Ref<MessageGrp> grp; 359 #if defined(HAVE_MPI) && defined(ALWAYS_USE_MPI) 360 grp = new MPIMessageGrp(&argc, &argv); 361 #endif 329 362 if (grp.null()) grp = MessageGrp::initial_messagegrp(argc, argv); 330 363 if (grp.nonnull()) … … 962 995 ExEnv::out0() << "The AO density matrix is "; 963 996 wfn->ao_density()->print(ExEnv::out0()); 997 ExEnv::out0() << "The natural density matrix is "; 998 wfn->natural_density()->print(ExEnv::out0()); 964 999 ExEnv::out0() << "The Gaussian basis is " << wfn->basis()->name() << endl; 965 1000 ExEnv::out0() << "The Gaussians sit at the following centers: " << endl; … … 970 1005 ExEnv::out0() << endl; 971 1006 } 972 // GaussianShell is the actual orbital functionas it seems ... 973 ExEnv::out0() << "There are the following Gaussian Shells: " << endl; 974 for (int nr = 0; nr< wfn->basis()->nshell(); ++nr) { 975 ExEnv::out0() << "Shell nr. " << nr << ": "; 976 (*wfn->basis())[nr].print(ExEnv::out0()); 1007 // GaussianShell is the actual orbital functions it seems ... 1008 //ExEnv::out0() << "There are the following Gaussian Shells: " << endl; 1009 SCVector3 r; 1010 r.x() = r.y() = r.z() = 10; 1011 ExEnv::out0() << "We get the following value at " << r << "." << endl; 1012 Ref<Integral> intgrl = Integral::get_default_integral(); 1013 GaussianBasisSet::ValueData vdat(wfn->basis(), integral); 1014 ExEnv::out0() << "Value at (10,10,10) is " << EvaluateDensity(r, intgrl, vdat, wfn) << endl; 1015 boost::function<double (SCVector3 &r)> evaluator = 1016 boost::bind(&EvaluateDensity, _1, boost::ref(intgrl), boost::ref(vdat), boost::ref(wfn)); 1017 ExEnv::out0() << "Check against values at " << r << "." << endl; 1018 int nbasis = wfn->basis()->nbasis(); 1019 double *b_val = new double[nbasis]; 1020 wfn->basis()->values(r, &vdat, b_val); 1021 for (int i=0; i<nbasis; i++) { 1022 //ExEnv::out0() << "Shell nr. " << nr << ": "; 1023 ExEnv::out0() << "Value at (10,10,10) is " << b_val[i] << endl; 977 1024 } 1025 // perform test integration of density 1026 double delta = 1.; 1027 double sum = 0.; 1028 for (r.x() = -10. ; r.x() < 10.; r.x() += delta) 1029 for (r.y() = -10. ; r.y() < 10.; r.y() += delta) 1030 for (r.z() = -10. ; r.z() < 10.; r.z() += delta) { 1031 wfn->basis()->values(r, &vdat, b_val); 1032 for (int i=0; i<nbasis; i++) 1033 sum += wfn->ao_density()->get_element(i,i)*b_val[i]; 1034 } 1035 sum /= pow(20/delta,3); 1036 ExEnv::out0() << "Sum over domain [0:20]^3 with " << delta << " delta is " << sum << "." << endl; 1037 delete[] b_val; 978 1038 } 979 1039 … … 1016 1076 } 1017 1077 1078 double EvaluateDensity(SCVector3 &r, Ref<Integral> &intgrl, GaussianBasisSet::ValueData &vdat, Ref<Wavefunction> &wfn) 1079 { 1080 ExEnv::out0() << "We get the following values at " << r << "." << endl; 1081 int nbasis = wfn->basis()->nbasis(); 1082 double *b_val = new double[nbasis]; 1083 wfn->basis()->values(r, &vdat, b_val); 1084 double sum=0.; 1085 for (int i=0; i<nbasis; i++) 1086 sum += b_val[i]; 1087 delete[] b_val; 1088 return sum; 1089 } 1090 1018 1091 int 1019 1092 main(int argc, char *argv[])
Note:
See TracChangeset
for help on using the changeset viewer.
