Changeset 1907a7 for src/config.cpp
- Timestamp:
- Apr 2, 2009, 4:12:54 PM (16 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- ca3ccc
- Parents:
- d8b94a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/config.cpp
rd8b94a r1907a7 1 1 /** \file config.cpp 2 * 2 * 3 3 * Function implementations for the class config. 4 * 4 * 5 5 */ 6 6 … … 24 24 configname[0]='\0'; 25 25 basis = "3-21G"; 26 26 27 27 FastParsing = false; 28 28 ProcPEGamma=8; … … 42 42 UseAddGramSch=1; 43 43 Seed=1; 44 44 45 45 MaxOuterStep=0; 46 46 Deltat=1; … … 51 51 MaxPsiStep=0; 52 52 EpsWannier=1e-7; 53 53 54 54 MaxMinStep=100; 55 55 RelEpsTotalEnergy=1e-7; … … 62 62 InitMaxMinStopStep=1; 63 63 InitMaxMinGapStopStep=0; 64 64 65 65 //BoxLength[NDIM*NDIM]; 66 66 67 67 ECut=128.; 68 68 MaxLevel=5; … … 77 77 PsiMaxNoDown=0; 78 78 AddPsis=0; 79 79 80 80 RCut=20.; 81 81 StructOpt=0; … … 101 101 * for each entry of the config file structure. 102 102 */ 103 void config::Edit( molecule *mol)103 void config::Edit() 104 104 { 105 105 char choice; 106 106 107 107 do { 108 108 cout << Verbose(0) << "===========EDIT CONFIGURATION============================" << endl; … … 137 137 cout << Verbose(0) << " g - Relative change in kinetic energy to stop min. iteration during initial level" << endl; 138 138 cout << Verbose(0) << " h - Check stop conditions every ..th step during min. iteration during initial level" << endl; 139 cout << Verbose(0) << " j - six lower diagonal entries of matrix, defining the unit cell" << endl;139 // cout << Verbose(0) << " j - six lower diagonal entries of matrix, defining the unit cell" << endl; 140 140 cout << Verbose(0) << " k - Energy cutoff of plane wave basis in Hartree" << endl; 141 141 cout << Verbose(0) << " l - Maximum number of levels in multi-level-ansatz" << endl; … … 157 157 cout << Verbose(0) << "INPUT: "; 158 158 cin >> choice; 159 159 160 160 switch (choice) { 161 161 case 'A': // mainname … … 282 282 cin >> config::InitMaxMinStopStep; 283 283 break; 284 285 case 'j': // BoxLength286 cout << Verbose(0) << "enter lower triadiagonalo form of basis matrix" << endl << endl;287 for (int i=0;i<6;i++) {288 cout << Verbose(0) << "Cell size" << i << ": ";289 cin >> mol->cell_size[i];290 }291 break;292 284 285 // case 'j': // BoxLength 286 // cout << Verbose(0) << "enter lower triadiagonalo form of basis matrix" << endl << endl; 287 // for (int i=0;i<6;i++) { 288 // cout << Verbose(0) << "Cell size" << i << ": "; 289 // cin >> mol->cell_size[i]; 290 // } 291 // break; 292 293 293 case 'k': // ECut 294 294 cout << Verbose(0) << "Old: " << config::ECut << "\t new: "; … … 364 364 * \param *periode pointer to a periodentafel class with all elements 365 365 * \param *mol pointer to molecule containing all atoms of the molecule 366 * \return 0 - old syntax, 1 - new syntax, -1 - unknown syntax 366 * \return 0 - old syntax, 1 - new syntax, -1 - unknown syntax 367 367 */ 368 368 int config::TestSyntax(char *filename, periodentafel *periode, molecule *mol) … … 370 370 int test; 371 371 ifstream file(filename); 372 372 373 373 // search file for keyword: ProcPEGamma (new syntax) 374 374 if (ParseForParameter(1,&file,"ProcPEGamma", 0, 1, 1, int_type, &test, 1, optional)) { … … 441 441 * \param *file input file stream being the opened config file 442 442 * \param *periode pointer to a periodentafel class with all elements 443 * \param *mol pointer to molecule containing all atoms of the molecule 443 * \param *mol pointer to molecule containing all atoms of the molecule 444 444 */ 445 445 void config::Load(char *filename, periodentafel *periode, molecule *mol) … … 452 452 RetrieveConfigPathAndName(filename); 453 453 // ParseParameters 454 454 455 455 /* Oeffne Hauptparameterdatei */ 456 456 int di; … … 464 464 int verbose = 0; 465 465 double value[3]; 466 466 467 467 /* Namen einlesen */ 468 468 … … 495 495 config::DoOutCurrent = 0; 496 496 if (config::DoOutCurrent < 0) config::DoOutCurrent = 0; 497 if (config::DoOutCurrent > 1) config::DoOutCurrent = 1; 497 if (config::DoOutCurrent > 1) config::DoOutCurrent = 1; 498 498 ParseForParameter(verbose,file,"AddGramSch", 0, 1, 1, int_type, &(config::UseAddGramSch), 1, critical); 499 499 if (config::UseAddGramSch < 0) config::UseAddGramSch = 0; … … 517 517 if (config::SawtoothStart > 1.) config::SawtoothStart = 1.; 518 518 } 519 519 520 520 ParseForParameter(verbose,file,"MaxOuterStep", 0, 1, 1, int_type, &(config::MaxOuterStep), 1, critical); 521 521 if (!ParseForParameter(verbose,file,"Deltat", 0, 1, 1, double_type, &(config::Deltat), 1, optional)) … … 527 527 if (!ParseForParameter(verbose,file,"EpsWannier", 0, 1, 1, double_type, &(config::EpsWannier), 1, optional)) 528 528 config::EpsWannier = 1e-8; 529 529 530 530 // stop conditions 531 531 //if (config::MaxOuterStep <= 0) config::MaxOuterStep = 1; 532 532 ParseForParameter(verbose,file,"MaxPsiStep", 0, 1, 1, int_type, &(config::MaxPsiStep), 1, critical); 533 533 if (config::MaxPsiStep <= 0) config::MaxPsiStep = 3; 534 534 535 535 ParseForParameter(verbose,file,"MaxMinStep", 0, 1, 1, int_type, &(config::MaxMinStep), 1, critical); 536 536 ParseForParameter(verbose,file,"RelEpsTotalE", 0, 1, 1, double_type, &(config::RelEpsTotalEnergy), 1, critical); … … 541 541 if (config::MaxMinStopStep < 1) config::MaxMinStopStep = 1; 542 542 if (config::MaxMinGapStopStep < 1) config::MaxMinGapStopStep = 1; 543 543 544 544 ParseForParameter(verbose,file,"MaxInitMinStep", 0, 1, 1, int_type, &(config::MaxInitMinStep), 1, critical); 545 545 ParseForParameter(verbose,file,"InitRelEpsTotalE", 0, 1, 1, double_type, &(config::InitRelEpsTotalEnergy), 1, critical); … … 550 550 if (config::InitMaxMinStopStep < 1) config::InitMaxMinStopStep = 1; 551 551 if (config::InitMaxMinGapStopStep < 1) config::InitMaxMinGapStopStep = 1; 552 552 553 553 // Unit cell and magnetic field 554 554 ParseForParameter(verbose,file, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ … … 566 566 config::DoFullCurrent = 0; 567 567 if (config::DoFullCurrent < 0) config::DoFullCurrent = 0; 568 if (config::DoFullCurrent > 2) config::DoFullCurrent = 2; 568 if (config::DoFullCurrent > 2) config::DoFullCurrent = 2; 569 569 if (config::DoOutNICS < 0) config::DoOutNICS = 0; 570 if (config::DoOutNICS > 2) config::DoOutNICS = 2; 570 if (config::DoOutNICS > 2) config::DoOutNICS = 2; 571 571 if (config::DoPerturbation == 0) { 572 572 config::DoFullCurrent = 0; … … 585 585 } else { 586 586 fprintf(stderr, "0 <= RiemanTensor < 2: 0 UseNotRT, 1 UseRT"); 587 exit(1); 587 exit(1); 588 588 } 589 589 switch (config::RiemannTensor) { … … 602 602 if (config::RiemannLevel < 2) { 603 603 config::RiemannLevel = 2; 604 } 604 } 605 605 if (config::RiemannLevel > config::MaxLevel-1) { 606 606 config::RiemannLevel = config::MaxLevel-1; … … 609 609 if (config::LevRFactor < 2) { 610 610 config::LevRFactor = 2; 611 } 611 } 612 612 config::Lev0Factor = 2; 613 613 config::RTActualUse = 2; … … 619 619 } else { 620 620 fprintf(stderr, "0 <= PsiType < 2: 0 UseSpinDouble, 1 UseSpinUpDown"); 621 exit(1); 621 exit(1); 622 622 } 623 623 switch (config::PsiType) { … … 633 633 break; 634 634 } 635 635 636 636 // IonsInitRead 637 637 638 638 ParseForParameter(verbose,file,"RCut", 0, 1, 1, double_type, &(config::RCut), 1, critical); 639 639 ParseForParameter(verbose,file,"IsAngstroem", 0, 1, 1, int_type, &(config::IsAngstroem), 1, critical); … … 653 653 ParseForParameter(verbose,file, name, 0, 2, 1, int_type, &Z, 1, critical); 654 654 elementhash[i] = periode->FindElement(Z); 655 cout << Verbose(1) << i << ". Z = " << elementhash[i]->Z << " with " << No[i] << " ions." << endl; 655 cout << Verbose(1) << i << ". Z = " << elementhash[i]->Z << " with " << No[i] << " ions." << endl; 656 656 } 657 657 int repetition = 0; // which repeated keyword shall be read 658 658 659 659 map<int, atom *> AtomList[config::MaxTypes]; 660 660 if (!FastParsing) { … … 675 675 } else 676 676 neues = AtomList[i][j]; 677 status = (status && 677 status = (status && 678 678 ParseForParameter(verbose,file, keyword, 0, 1, 1, double_type, &neues->x.x[0], 1, (repetition == 0) ? critical : optional) && 679 679 ParseForParameter(verbose,file, keyword, 0, 2, 1, double_type, &neues->x.x[1], 1, (repetition == 0) ? critical : optional) && … … 681 681 ParseForParameter(verbose,file, keyword, 0, 4, 1, int_type, &neues->FixedIon, 1, (repetition == 0) ? critical : optional)); 682 682 if (!status) break; 683 683 684 684 // check size of vectors 685 685 if (mol->Trajectories[neues].R.size() <= (unsigned int)(repetition)) { … … 689 689 mol->Trajectories[neues].F.resize(repetition+10); 690 690 } 691 691 692 692 // put into trajectories list 693 693 for (int d=0;d<NDIM;d++) 694 694 mol->Trajectories[neues].R.at(repetition).x[d] = neues->x.x[d]; 695 695 696 696 // parse velocities if present 697 697 if(!ParseForParameter(verbose,file, keyword, 0, 5, 1, double_type, &neues->v.x[0], 1,optional)) … … 703 703 for (int d=0;d<NDIM;d++) 704 704 mol->Trajectories[neues].U.at(repetition).x[d] = neues->v.x[d]; 705 705 706 706 // parse forces if present 707 707 if(!ParseForParameter(verbose,file, keyword, 0, 8, 1, double_type, &value[0], 1,optional)) … … 713 713 for (int d=0;d<NDIM;d++) 714 714 mol->Trajectories[neues].F.at(repetition).x[d] = value[d]; 715 716 // cout << "Parsed position of step " << (repetition) << ": ("; 715 716 // cout << "Parsed position of step " << (repetition) << ": ("; 717 717 // for (int d=0;d<NDIM;d++) 718 718 // cout << mol->Trajectories[neues].R.at(repetition).x[d] << " "; // next step … … 770 770 * \param *file input file stream being the opened config file with old pcp syntax 771 771 * \param *periode pointer to a periodentafel class with all elements 772 * \param *mol pointer to molecule containing all atoms of the molecule 772 * \param *mol pointer to molecule containing all atoms of the molecule 773 773 */ 774 774 void config::LoadOld(char *filename, periodentafel *periode, molecule *mol) … … 781 781 RetrieveConfigPathAndName(filename); 782 782 // ParseParameters 783 783 784 784 /* Oeffne Hauptparameterdatei */ 785 785 int l, i, di; … … 791 791 int Z, No, AtomNo, found; 792 792 int verbose = 0; 793 793 794 794 /* Namen einlesen */ 795 795 … … 823 823 ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional); 824 824 config::EpsWannier = 1e-8; 825 825 826 826 // stop conditions 827 827 //if (config::MaxOuterStep <= 0) config::MaxOuterStep = 1; 828 828 ParseForParameter(verbose,file,"MaxPsiStep", 0, 1, 1, int_type, &(config::MaxPsiStep), 1, critical); 829 829 if (config::MaxPsiStep <= 0) config::MaxPsiStep = 3; 830 830 831 831 ParseForParameter(verbose,file,"MaxMinStep", 0, 1, 1, int_type, &(config::MaxMinStep), 1, critical); 832 832 ParseForParameter(verbose,file,"MaxMinStep", 0, 2, 1, double_type, &(config::RelEpsTotalEnergy), 1, critical); … … 836 836 if (config::MaxMinStopStep < 1) config::MaxMinStopStep = 1; 837 837 config::MaxMinGapStopStep = 1; 838 838 839 839 ParseForParameter(verbose,file,"MaxInitMinStep", 0, 1, 1, int_type, &(config::MaxInitMinStep), 1, critical); 840 840 ParseForParameter(verbose,file,"MaxInitMinStep", 0, 2, 1, double_type, &(config::InitRelEpsTotalEnergy), 1, critical); … … 867 867 } else { 868 868 fprintf(stderr, "0 <= RiemanTensor < 2: 0 UseNotRT, 1 UseRT"); 869 exit(1); 869 exit(1); 870 870 } 871 871 switch (config::RiemannTensor) { … … 884 884 if (config::RiemannLevel < 2) { 885 885 config::RiemannLevel = 2; 886 } 886 } 887 887 if (config::RiemannLevel > config::MaxLevel-1) { 888 888 config::RiemannLevel = config::MaxLevel-1; … … 891 891 if (config::LevRFactor < 2) { 892 892 config::LevRFactor = 2; 893 } 893 } 894 894 config::Lev0Factor = 2; 895 895 config::RTActualUse = 2; … … 901 901 } else { 902 902 fprintf(stderr, "0 <= PsiType < 2: 0 UseSpinDouble, 1 UseSpinUpDown"); 903 exit(1); 903 exit(1); 904 904 } 905 905 switch (config::PsiType) { … … 915 915 break; 916 916 } 917 917 918 918 // IonsInitRead 919 919 920 920 ParseForParameter(verbose,file,"RCut", 0, 1, 1, double_type, &(config::RCut), 1, critical); 921 921 ParseForParameter(verbose,file,"IsAngstroem", 0, 1, 1, int_type, &(config::IsAngstroem), 1, critical); … … 924 924 925 925 // Routine from builder.cpp 926 927 928 for (i=MAX_ELEMENTS;i--;) 926 927 928 for (i=MAX_ELEMENTS;i--;) 929 929 elementhash[i] = NULL; 930 930 cout << Verbose(0) << "Parsing Ions ..." << endl; … … 937 937 } 938 938 if (found > 0) { 939 if (zeile.find("Ions_Data") == 0) 939 if (zeile.find("Ions_Data") == 0) 940 940 getline(*file,zeile,'\n'); // read next line and parse this one 941 941 istringstream input(zeile); … … 966 966 No++; 967 967 } 968 } 968 } 969 969 file->close(); 970 970 delete(file); … … 974 974 * \param *filename name of file 975 975 * \param *periode pointer to a periodentafel class with all elements 976 * \param *mol pointer to molecule containing all atoms of the molecule 976 * \param *mol pointer to molecule containing all atoms of the molecule 977 977 */ 978 978 bool config::Save(const char *filename, periodentafel *periode, molecule *mol) const … … 1081 1081 * Note that this format cannot be parsed again. 1082 1082 * \param *filename name of file (without ".in" suffix!) 1083 * \param *mol pointer to molecule containing all atoms of the molecule 1083 * \param *mol pointer to molecule containing all atoms of the molecule 1084 1084 */ 1085 1085 bool config::SaveMPQC(const char *filename, molecule *mol) const … … 1092 1092 ofstream *output = NULL; 1093 1093 stringstream *fname = NULL; 1094 1094 1095 1095 // first without hessian 1096 1096 fname = new stringstream; … … 1191 1191 delete(output); 1192 1192 delete(fname); 1193 1193 1194 1194 return true; 1195 1195 }; … … 1203 1203 * \param file file to be parsed 1204 1204 * \param name Name of value in file (at least 3 chars!) 1205 * \param sequential 1 - do not reset file pointer to begin of file, 0 - set to beginning 1205 * \param sequential 1 - do not reset file pointer to begin of file, 0 - set to beginning 1206 1206 * (if file is sequentially parsed this can be way faster! However, beware of multiple values per line, as whole line is read - 1207 1207 * best approach: 0 0 0 1 (not resetted only on last value of line) - and of yth, which is now … … 1223 1223 dummy1 = free_dummy = (char *) Malloc(256 * sizeof(char), "config::ParseForParameter: *free_dummy"); 1224 1224 1225 //fprintf(stderr,"Parsing for %s\n",name); 1225 //fprintf(stderr,"Parsing for %s\n",name); 1226 1226 if (repetition == 0) 1227 1227 //Error(SomeError, "ParseForParameter(): argument repetition must not be 0!"); … … 1244 1244 file->clear(); 1245 1245 file->seekg(file_position, ios::beg); // rewind to start position 1246 Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); 1246 Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); 1247 1247 return 0; 1248 1248 } … … 1250 1250 line++; 1251 1251 } while (dummy != NULL && dummy1 != NULL && ((dummy1[0] == '#') || (dummy1[0] == '\0'))); // skip commentary and empty lines 1252 1252 1253 1253 // C++ getline removes newline at end, thus re-add 1254 1254 if ((dummy1 != NULL) && (strchr(dummy1,'\n') == NULL)) { … … 1276 1276 //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name); 1277 1277 //Free((void **)&free_dummy); 1278 //Error(FileOpenParams, NULL); 1278 //Error(FileOpenParams, NULL); 1279 1279 } else { 1280 1280 //fprintf(stderr,"found tab at %i\n",(char *)dummy-(char *)dummy1); … … 1285 1285 if ((name == NULL) || (((dummy-dummy1 >= 3) && (strncmp(dummy1, name, strlen(name)) == 0)) && ((unsigned int)(dummy-dummy1) == strlen(name)))) { 1286 1286 found++; // found the parameter! 1287 //fprintf(stderr,"found %s at line %i between %i and %i\n", name, line, dummy1, dummy); 1288 1287 //fprintf(stderr,"found %s at line %i between %i and %i\n", name, line, dummy1, dummy); 1288 1289 1289 if (found == repetition) { 1290 1290 for (i=0;i<xth;i++) { // i = rows … … 1325 1325 dummy1[j+1] = '\0'; 1326 1326 } 1327 1327 1328 1328 int start = (type >= grid) ? 0 : yth-1 ; 1329 1329 for (j=start;j<yth;j++) { // j = columns … … 1348 1348 //return 0; 1349 1349 exit(255); 1350 //Error(FileOpenParams, NULL); 1350 //Error(FileOpenParams, NULL); 1351 1351 } else { 1352 1352 //if (!sequential) … … 1363 1363 // found comment, skipping rest of line 1364 1364 //if (verbose) fprintf(stderr,"Error: '#' at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name); 1365 if (!sequential) { // here we need it! 1365 if (!sequential) { // here we need it! 1366 1366 file->seekg(file_position, ios::beg); // rewind to start position 1367 1367 } … … 1378 1378 //value += sizeof(int); 1379 1379 break; 1380 case(row_double): 1380 case(row_double): 1381 1381 case(grid): 1382 1382 case(lower_trigrid): … … 1419 1419 } 1420 1420 } 1421 } 1421 } 1422 1422 if ((type >= row_int) && (verbose)) fprintf(stderr,"\n"); 1423 1423 Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); … … 1427 1427 } 1428 1428 //fprintf(stderr, "End of Parsing\n\n"); 1429 1429 1430 1430 return (found); // true if found, false if not 1431 1431 }
Note:
See TracChangeset
for help on using the changeset viewer.