- Timestamp:
- Oct 17, 2009, 4:47:06 PM (15 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:
- ad8b0d
- Parents:
- b1f254
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/config.cpp
-
Property mode
changed from
100755
to100644
rb1f254 r3a9fe9 8 8 #include "config.hpp" 9 9 #include "element.hpp" 10 #include "helpers.hpp" 10 11 #include "memoryallocator.hpp" 11 12 #include "molecule.hpp" … … 696 697 }; 697 698 698 699 /** Initializes config file structure by loading elements from a give file. 699 /** Initializes ConfigFileBuffer from a file. 700 700 * \param *file input file stream being the opened config file 701 * \param *periode pointer to a periodentafel class with all elements 702 * \param *mol pointer to molecule containing all atoms of the molecule 703 */ 704 void config::Load(char *filename, periodentafel *periode, molecule *mol) 701 * \param *FileBuffer pointer to FileBuffer on return, should point to NULL 702 */ 703 void PrepareFileBuffer(char *filename, struct ConfigFileBuffer *&FileBuffer) 705 704 { 706 ifstream *file = new ifstream(filename); 707 if (file == NULL) { 708 cerr << "ERROR: config file " << filename << " missing!" << endl; 709 return; 710 } 711 file->close(); 712 delete(file); 713 RetrieveConfigPathAndName(filename); 714 715 // ParseParameterFile 716 struct ConfigFileBuffer *FileBuffer = new ConfigFileBuffer(filename); 705 if (FileBuffer != NULL) { 706 cerr << Verbose(1) << "WARNING: deleting present FileBuffer in PrepareFileBuffer()." << endl; 707 delete(FileBuffer); 708 } 709 FileBuffer = new ConfigFileBuffer(filename); 710 717 711 FileBuffer->InitMapping(); 718 719 /* Oeffne Hauptparameterdatei */ 720 int di; 721 double BoxLength[9]; 722 string zeile; 723 string dummy; 712 }; 713 714 /** Loads a molecule from a ConfigFileBuffer. 715 * \param *mol molecule to load 716 * \param *FileBuffer ConfigFileBuffer to use 717 * \param *periode periodentafel for finding elements 718 * \param FastParsing whether to parse trajectories or not 719 */ 720 void LoadMolecule(molecule *&mol, struct ConfigFileBuffer *&FileBuffer, periodentafel *periode, bool FastParsing) 721 { 722 int MaxTypes = 0; 724 723 element *elementhash[MAX_ELEMENTS]; 725 724 char name[MAX_ELEMENTS]; 726 725 char keyword[MAX_ELEMENTS]; 727 int Z, No[MAX_ELEMENTS]; 726 int Z = -1; 727 int No[MAX_ELEMENTS]; 728 728 int verbose = 0; 729 729 double value[3]; 730 731 InitThermostats(FileBuffer); 732 733 /* Namen einlesen */ 734 735 ParseForParameter(verbose,FileBuffer, "mainname", 0, 1, 1, string_type, (config::mainname), 1, critical); 736 ParseForParameter(verbose,FileBuffer, "defaultpath", 0, 1, 1, string_type, (config::defaultpath), 1, critical); 737 ParseForParameter(verbose,FileBuffer, "pseudopotpath", 0, 1, 1, string_type, (config::pseudopotpath), 1, critical); 738 ParseForParameter(verbose,FileBuffer,"ProcPEGamma", 0, 1, 1, int_type, &(config::ProcPEGamma), 1, critical); 739 ParseForParameter(verbose,FileBuffer,"ProcPEPsi", 0, 1, 1, int_type, &(config::ProcPEPsi), 1, critical); 740 741 if (!ParseForParameter(verbose,FileBuffer,"Seed", 0, 1, 1, int_type, &(config::Seed), 1, optional)) 742 config::Seed = 1; 743 744 if(!ParseForParameter(verbose,FileBuffer,"DoOutOrbitals", 0, 1, 1, int_type, &(config::DoOutOrbitals), 1, optional)) { 745 config::DoOutOrbitals = 0; 746 } else { 747 if (config::DoOutOrbitals < 0) config::DoOutOrbitals = 0; 748 if (config::DoOutOrbitals > 1) config::DoOutOrbitals = 1; 749 } 750 ParseForParameter(verbose,FileBuffer,"DoOutVis", 0, 1, 1, int_type, &(config::DoOutVis), 1, critical); 751 if (config::DoOutVis < 0) config::DoOutVis = 0; 752 if (config::DoOutVis > 1) config::DoOutVis = 1; 753 if (!ParseForParameter(verbose,FileBuffer,"VectorPlane", 0, 1, 1, int_type, &(config::VectorPlane), 1, optional)) 754 config::VectorPlane = -1; 755 if (!ParseForParameter(verbose,FileBuffer,"VectorCut", 0, 1, 1, double_type, &(config::VectorCut), 1, optional)) 756 config::VectorCut = 0.; 757 ParseForParameter(verbose,FileBuffer,"DoOutMes", 0, 1, 1, int_type, &(config::DoOutMes), 1, critical); 758 if (config::DoOutMes < 0) config::DoOutMes = 0; 759 if (config::DoOutMes > 1) config::DoOutMes = 1; 760 if (!ParseForParameter(verbose,FileBuffer,"DoOutCurr", 0, 1, 1, int_type, &(config::DoOutCurrent), 1, optional)) 761 config::DoOutCurrent = 0; 762 if (config::DoOutCurrent < 0) config::DoOutCurrent = 0; 763 if (config::DoOutCurrent > 1) config::DoOutCurrent = 1; 764 ParseForParameter(verbose,FileBuffer,"AddGramSch", 0, 1, 1, int_type, &(config::UseAddGramSch), 1, critical); 765 if (config::UseAddGramSch < 0) config::UseAddGramSch = 0; 766 if (config::UseAddGramSch > 2) config::UseAddGramSch = 2; 767 if(!ParseForParameter(verbose,FileBuffer,"DoWannier", 0, 1, 1, int_type, &(config::DoWannier), 1, optional)) { 768 config::DoWannier = 0; 769 } else { 770 if (config::DoWannier < 0) config::DoWannier = 0; 771 if (config::DoWannier > 1) config::DoWannier = 1; 772 } 773 if(!ParseForParameter(verbose,FileBuffer,"CommonWannier", 0, 1, 1, int_type, &(config::CommonWannier), 1, optional)) { 774 config::CommonWannier = 0; 775 } else { 776 if (config::CommonWannier < 0) config::CommonWannier = 0; 777 if (config::CommonWannier > 4) config::CommonWannier = 4; 778 } 779 if(!ParseForParameter(verbose,FileBuffer,"SawtoothStart", 0, 1, 1, double_type, &(config::SawtoothStart), 1, optional)) { 780 config::SawtoothStart = 0.01; 781 } else { 782 if (config::SawtoothStart < 0.) config::SawtoothStart = 0.; 783 if (config::SawtoothStart > 1.) config::SawtoothStart = 1.; 784 } 785 786 if (ParseForParameter(verbose,FileBuffer,"DoConstrainedMD", 0, 1, 1, int_type, &(config::DoConstrainedMD), 1, optional)) 787 if (config::DoConstrainedMD < 0) 788 config::DoConstrainedMD = 0; 789 ParseForParameter(verbose,FileBuffer,"MaxOuterStep", 0, 1, 1, int_type, &(config::MaxOuterStep), 1, critical); 790 if (!ParseForParameter(verbose,FileBuffer,"Deltat", 0, 1, 1, double_type, &(config::Deltat), 1, optional)) 791 config::Deltat = 1; 792 ParseForParameter(verbose,FileBuffer,"OutVisStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); 793 ParseForParameter(verbose,FileBuffer,"OutSrcStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional); 794 ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &(config::TargetTemp), 1, optional); 795 //ParseForParameter(verbose,FileBuffer,"Thermostat", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional); 796 if (!ParseForParameter(verbose,FileBuffer,"EpsWannier", 0, 1, 1, double_type, &(config::EpsWannier), 1, optional)) 797 config::EpsWannier = 1e-8; 798 799 // stop conditions 800 //if (config::MaxOuterStep <= 0) config::MaxOuterStep = 1; 801 ParseForParameter(verbose,FileBuffer,"MaxPsiStep", 0, 1, 1, int_type, &(config::MaxPsiStep), 1, critical); 802 if (config::MaxPsiStep <= 0) config::MaxPsiStep = 3; 803 804 ParseForParameter(verbose,FileBuffer,"MaxMinStep", 0, 1, 1, int_type, &(config::MaxMinStep), 1, critical); 805 ParseForParameter(verbose,FileBuffer,"RelEpsTotalE", 0, 1, 1, double_type, &(config::RelEpsTotalEnergy), 1, critical); 806 ParseForParameter(verbose,FileBuffer,"RelEpsKineticE", 0, 1, 1, double_type, &(config::RelEpsKineticEnergy), 1, critical); 807 ParseForParameter(verbose,FileBuffer,"MaxMinStopStep", 0, 1, 1, int_type, &(config::MaxMinStopStep), 1, critical); 808 ParseForParameter(verbose,FileBuffer,"MaxMinGapStopStep", 0, 1, 1, int_type, &(config::MaxMinGapStopStep), 1, critical); 809 if (config::MaxMinStep <= 0) config::MaxMinStep = config::MaxPsiStep; 810 if (config::MaxMinStopStep < 1) config::MaxMinStopStep = 1; 811 if (config::MaxMinGapStopStep < 1) config::MaxMinGapStopStep = 1; 812 813 ParseForParameter(verbose,FileBuffer,"MaxInitMinStep", 0, 1, 1, int_type, &(config::MaxInitMinStep), 1, critical); 814 ParseForParameter(verbose,FileBuffer,"InitRelEpsTotalE", 0, 1, 1, double_type, &(config::InitRelEpsTotalEnergy), 1, critical); 815 ParseForParameter(verbose,FileBuffer,"InitRelEpsKineticE", 0, 1, 1, double_type, &(config::InitRelEpsKineticEnergy), 1, critical); 816 ParseForParameter(verbose,FileBuffer,"InitMaxMinStopStep", 0, 1, 1, int_type, &(config::InitMaxMinStopStep), 1, critical); 817 ParseForParameter(verbose,FileBuffer,"InitMaxMinGapStopStep", 0, 1, 1, int_type, &(config::InitMaxMinGapStopStep), 1, critical); 818 if (config::MaxInitMinStep <= 0) config::MaxInitMinStep = config::MaxPsiStep; 819 if (config::InitMaxMinStopStep < 1) config::InitMaxMinStopStep = 1; 820 if (config::InitMaxMinGapStopStep < 1) config::InitMaxMinGapStopStep = 1; 821 822 // Unit cell and magnetic field 823 ParseForParameter(verbose,FileBuffer, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ 824 mol->cell_size[0] = BoxLength[0]; 825 mol->cell_size[1] = BoxLength[3]; 826 mol->cell_size[2] = BoxLength[4]; 827 mol->cell_size[3] = BoxLength[6]; 828 mol->cell_size[4] = BoxLength[7]; 829 mol->cell_size[5] = BoxLength[8]; 830 //if (1) fprintf(stderr,"\n"); 831 832 ParseForParameter(verbose,FileBuffer,"DoPerturbation", 0, 1, 1, int_type, &(config::DoPerturbation), 1, optional); 833 ParseForParameter(verbose,FileBuffer,"DoOutNICS", 0, 1, 1, int_type, &(config::DoOutNICS), 1, optional); 834 if (!ParseForParameter(verbose,FileBuffer,"DoFullCurrent", 0, 1, 1, int_type, &(config::DoFullCurrent), 1, optional)) 835 config::DoFullCurrent = 0; 836 if (config::DoFullCurrent < 0) config::DoFullCurrent = 0; 837 if (config::DoFullCurrent > 2) config::DoFullCurrent = 2; 838 if (config::DoOutNICS < 0) config::DoOutNICS = 0; 839 if (config::DoOutNICS > 2) config::DoOutNICS = 2; 840 if (config::DoPerturbation == 0) { 841 config::DoFullCurrent = 0; 842 config::DoOutNICS = 0; 843 } 844 845 ParseForParameter(verbose,FileBuffer,"ECut", 0, 1, 1, double_type, &(config::ECut), 1, critical); 846 ParseForParameter(verbose,FileBuffer,"MaxLevel", 0, 1, 1, int_type, &(config::MaxLevel), 1, critical); 847 ParseForParameter(verbose,FileBuffer,"Level0Factor", 0, 1, 1, int_type, &(config::Lev0Factor), 1, critical); 848 if (config::Lev0Factor < 2) { 849 config::Lev0Factor = 2; 850 } 851 ParseForParameter(verbose,FileBuffer,"RiemannTensor", 0, 1, 1, int_type, &di, 1, critical); 852 if (di >= 0 && di < 2) { 853 config::RiemannTensor = di; 854 } else { 855 fprintf(stderr, "0 <= RiemanTensor < 2: 0 UseNotRT, 1 UseRT"); 856 exit(1); 857 } 858 switch (config::RiemannTensor) { 859 case 0: //UseNoRT 860 if (config::MaxLevel < 2) { 861 config::MaxLevel = 2; 862 } 863 config::LevRFactor = 2; 864 config::RTActualUse = 0; 865 break; 866 case 1: // UseRT 867 if (config::MaxLevel < 3) { 868 config::MaxLevel = 3; 869 } 870 ParseForParameter(verbose,FileBuffer,"RiemannLevel", 0, 1, 1, int_type, &(config::RiemannLevel), 1, critical); 871 if (config::RiemannLevel < 2) { 872 config::RiemannLevel = 2; 873 } 874 if (config::RiemannLevel > config::MaxLevel-1) { 875 config::RiemannLevel = config::MaxLevel-1; 876 } 877 ParseForParameter(verbose,FileBuffer,"LevRFactor", 0, 1, 1, int_type, &(config::LevRFactor), 1, critical); 878 if (config::LevRFactor < 2) { 879 config::LevRFactor = 2; 880 } 881 config::Lev0Factor = 2; 882 config::RTActualUse = 2; 883 break; 884 } 885 ParseForParameter(verbose,FileBuffer,"PsiType", 0, 1, 1, int_type, &di, 1, critical); 886 if (di >= 0 && di < 2) { 887 config::PsiType = di; 888 } else { 889 fprintf(stderr, "0 <= PsiType < 2: 0 UseSpinDouble, 1 UseSpinUpDown"); 890 exit(1); 891 } 892 switch (config::PsiType) { 893 case 0: // SpinDouble 894 ParseForParameter(verbose,FileBuffer,"MaxPsiDouble", 0, 1, 1, int_type, &(config::MaxPsiDouble), 1, critical); 895 ParseForParameter(verbose,FileBuffer,"AddPsis", 0, 1, 1, int_type, &(config::AddPsis), 1, optional); 896 break; 897 case 1: // SpinUpDown 898 if (config::ProcPEGamma % 2) config::ProcPEGamma*=2; 899 ParseForParameter(verbose,FileBuffer,"PsiMaxNoUp", 0, 1, 1, int_type, &(config::PsiMaxNoUp), 1, critical); 900 ParseForParameter(verbose,FileBuffer,"PsiMaxNoDown", 0, 1, 1, int_type, &(config::PsiMaxNoDown), 1, critical); 901 ParseForParameter(verbose,FileBuffer,"AddPsis", 0, 1, 1, int_type, &(config::AddPsis), 1, optional); 902 break; 903 } 904 905 // IonsInitRead 906 907 ParseForParameter(verbose,FileBuffer,"RCut", 0, 1, 1, double_type, &(config::RCut), 1, critical); 908 ParseForParameter(verbose,FileBuffer,"IsAngstroem", 0, 1, 1, int_type, &(config::IsAngstroem), 1, critical); 909 ParseForParameter(verbose,FileBuffer,"MaxTypes", 0, 1, 1, int_type, &(config::MaxTypes), 1, critical); 910 if (!ParseForParameter(verbose,FileBuffer,"RelativeCoord", 0, 1, 1, int_type, &(config::RelativeCoord) , 1, optional)) 911 config::RelativeCoord = 0; 912 if (!ParseForParameter(verbose,FileBuffer,"StructOpt", 0, 1, 1, int_type, &(config::StructOpt), 1, optional)) 913 config::StructOpt = 0; 730 731 if (mol == NULL) { 732 cerr << "Molecule is not allocated in LoadMolecule(), exit."; 733 performCriticalExit(); 734 } 735 736 ParseForParameter(verbose,FileBuffer,"MaxTypes", 0, 1, 1, int_type, &(MaxTypes), 1, critical); 914 737 if (MaxTypes == 0) { 915 738 cerr << "There are no atoms according to MaxTypes in this config file." << endl; … … 918 741 cout << Verbose(0) << "Prescanning ions per type: " << endl; 919 742 int NoAtoms = 0; 920 for (int i=0; i < config::MaxTypes; i++) {743 for (int i=0; i < MaxTypes; i++) { 921 744 sprintf(name,"Ion_Type%i",i+1); 922 745 ParseForParameter(verbose,FileBuffer, (const char*)name, 0, 1, 1, int_type, &No[i], 1, critical); … … 929 752 930 753 // sort the lines via the LineMapping 931 sprintf(name,"Ion_Type%i", config::MaxTypes);754 sprintf(name,"Ion_Type%i",MaxTypes); 932 755 if (!ParseForParameter(verbose,FileBuffer, (const char*)name, 1, 1, 1, int_type, &value[0], 1, critical)) { 933 756 cerr << "There are no atoms in the config file!" << endl; … … 941 764 //} 942 765 943 map<int, atom *> AtomList[ config::MaxTypes];766 map<int, atom *> AtomList[MaxTypes]; 944 767 map<int, atom *> LinearList; 945 768 atom *neues = NULL; … … 949 772 while (status) { 950 773 cout << "Currently parsing MD step " << repetition << "." << endl; 951 for (int i=0; i < config::MaxTypes; i++) {774 for (int i=0; i < MaxTypes; i++) { 952 775 sprintf(name,"Ion_Type%i",i+1); 953 776 for(int j=0;j<No[i];j++) { … … 1028 851 cout << "I found " << repetition << " times the keyword Ion_Type1_1." << endl; 1029 852 // parse in molecule coordinates 1030 for (int i=0; i < config::MaxTypes; i++) {853 for (int i=0; i < MaxTypes; i++) { 1031 854 sprintf(name,"Ion_Type%i",i+1); 1032 855 for(int j=0;j<No[i];j++) { … … 1061 884 } 1062 885 } 886 }; 887 888 889 /** Initializes config file structure by loading elements from a give file. 890 * \param *file input file stream being the opened config file 891 * \param *periode pointer to a periodentafel class with all elements 892 * \param *mol pointer to molecule containing all atoms of the molecule 893 */ 894 void config::Load(char *filename, periodentafel *periode, molecule *mol) 895 { 896 ifstream *file = new ifstream(filename); 897 if (file == NULL) { 898 cerr << "ERROR: config file " << filename << " missing!" << endl; 899 return; 900 } 901 file->close(); 902 delete(file); 903 RetrieveConfigPathAndName(filename); 904 905 // ParseParameterFile 906 struct ConfigFileBuffer *FileBuffer = NULL; 907 PrepareFileBuffer(filename,FileBuffer); 908 909 /* Oeffne Hauptparameterdatei */ 910 int di; 911 double BoxLength[9]; 912 string zeile; 913 string dummy; 914 int verbose = 0; 915 916 InitThermostats(FileBuffer); 917 918 /* Namen einlesen */ 919 920 ParseForParameter(verbose,FileBuffer, "mainname", 0, 1, 1, string_type, (config::mainname), 1, critical); 921 ParseForParameter(verbose,FileBuffer, "defaultpath", 0, 1, 1, string_type, (config::defaultpath), 1, critical); 922 ParseForParameter(verbose,FileBuffer, "pseudopotpath", 0, 1, 1, string_type, (config::pseudopotpath), 1, critical); 923 ParseForParameter(verbose,FileBuffer,"ProcPEGamma", 0, 1, 1, int_type, &(config::ProcPEGamma), 1, critical); 924 ParseForParameter(verbose,FileBuffer,"ProcPEPsi", 0, 1, 1, int_type, &(config::ProcPEPsi), 1, critical); 925 926 if (!ParseForParameter(verbose,FileBuffer,"Seed", 0, 1, 1, int_type, &(config::Seed), 1, optional)) 927 config::Seed = 1; 928 929 if(!ParseForParameter(verbose,FileBuffer,"DoOutOrbitals", 0, 1, 1, int_type, &(config::DoOutOrbitals), 1, optional)) { 930 config::DoOutOrbitals = 0; 931 } else { 932 if (config::DoOutOrbitals < 0) config::DoOutOrbitals = 0; 933 if (config::DoOutOrbitals > 1) config::DoOutOrbitals = 1; 934 } 935 ParseForParameter(verbose,FileBuffer,"DoOutVis", 0, 1, 1, int_type, &(config::DoOutVis), 1, critical); 936 if (config::DoOutVis < 0) config::DoOutVis = 0; 937 if (config::DoOutVis > 1) config::DoOutVis = 1; 938 if (!ParseForParameter(verbose,FileBuffer,"VectorPlane", 0, 1, 1, int_type, &(config::VectorPlane), 1, optional)) 939 config::VectorPlane = -1; 940 if (!ParseForParameter(verbose,FileBuffer,"VectorCut", 0, 1, 1, double_type, &(config::VectorCut), 1, optional)) 941 config::VectorCut = 0.; 942 ParseForParameter(verbose,FileBuffer,"DoOutMes", 0, 1, 1, int_type, &(config::DoOutMes), 1, critical); 943 if (config::DoOutMes < 0) config::DoOutMes = 0; 944 if (config::DoOutMes > 1) config::DoOutMes = 1; 945 if (!ParseForParameter(verbose,FileBuffer,"DoOutCurr", 0, 1, 1, int_type, &(config::DoOutCurrent), 1, optional)) 946 config::DoOutCurrent = 0; 947 if (config::DoOutCurrent < 0) config::DoOutCurrent = 0; 948 if (config::DoOutCurrent > 1) config::DoOutCurrent = 1; 949 ParseForParameter(verbose,FileBuffer,"AddGramSch", 0, 1, 1, int_type, &(config::UseAddGramSch), 1, critical); 950 if (config::UseAddGramSch < 0) config::UseAddGramSch = 0; 951 if (config::UseAddGramSch > 2) config::UseAddGramSch = 2; 952 if(!ParseForParameter(verbose,FileBuffer,"DoWannier", 0, 1, 1, int_type, &(config::DoWannier), 1, optional)) { 953 config::DoWannier = 0; 954 } else { 955 if (config::DoWannier < 0) config::DoWannier = 0; 956 if (config::DoWannier > 1) config::DoWannier = 1; 957 } 958 if(!ParseForParameter(verbose,FileBuffer,"CommonWannier", 0, 1, 1, int_type, &(config::CommonWannier), 1, optional)) { 959 config::CommonWannier = 0; 960 } else { 961 if (config::CommonWannier < 0) config::CommonWannier = 0; 962 if (config::CommonWannier > 4) config::CommonWannier = 4; 963 } 964 if(!ParseForParameter(verbose,FileBuffer,"SawtoothStart", 0, 1, 1, double_type, &(config::SawtoothStart), 1, optional)) { 965 config::SawtoothStart = 0.01; 966 } else { 967 if (config::SawtoothStart < 0.) config::SawtoothStart = 0.; 968 if (config::SawtoothStart > 1.) config::SawtoothStart = 1.; 969 } 970 971 if (ParseForParameter(verbose,FileBuffer,"DoConstrainedMD", 0, 1, 1, int_type, &(config::DoConstrainedMD), 1, optional)) 972 if (config::DoConstrainedMD < 0) 973 config::DoConstrainedMD = 0; 974 ParseForParameter(verbose,FileBuffer,"MaxOuterStep", 0, 1, 1, int_type, &(config::MaxOuterStep), 1, critical); 975 if (!ParseForParameter(verbose,FileBuffer,"Deltat", 0, 1, 1, double_type, &(config::Deltat), 1, optional)) 976 config::Deltat = 1; 977 ParseForParameter(verbose,FileBuffer,"OutVisStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); 978 ParseForParameter(verbose,FileBuffer,"OutSrcStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional); 979 ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &(config::TargetTemp), 1, optional); 980 //ParseForParameter(verbose,FileBuffer,"Thermostat", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional); 981 if (!ParseForParameter(verbose,FileBuffer,"EpsWannier", 0, 1, 1, double_type, &(config::EpsWannier), 1, optional)) 982 config::EpsWannier = 1e-8; 983 984 // stop conditions 985 //if (config::MaxOuterStep <= 0) config::MaxOuterStep = 1; 986 ParseForParameter(verbose,FileBuffer,"MaxPsiStep", 0, 1, 1, int_type, &(config::MaxPsiStep), 1, critical); 987 if (config::MaxPsiStep <= 0) config::MaxPsiStep = 3; 988 989 ParseForParameter(verbose,FileBuffer,"MaxMinStep", 0, 1, 1, int_type, &(config::MaxMinStep), 1, critical); 990 ParseForParameter(verbose,FileBuffer,"RelEpsTotalE", 0, 1, 1, double_type, &(config::RelEpsTotalEnergy), 1, critical); 991 ParseForParameter(verbose,FileBuffer,"RelEpsKineticE", 0, 1, 1, double_type, &(config::RelEpsKineticEnergy), 1, critical); 992 ParseForParameter(verbose,FileBuffer,"MaxMinStopStep", 0, 1, 1, int_type, &(config::MaxMinStopStep), 1, critical); 993 ParseForParameter(verbose,FileBuffer,"MaxMinGapStopStep", 0, 1, 1, int_type, &(config::MaxMinGapStopStep), 1, critical); 994 if (config::MaxMinStep <= 0) config::MaxMinStep = config::MaxPsiStep; 995 if (config::MaxMinStopStep < 1) config::MaxMinStopStep = 1; 996 if (config::MaxMinGapStopStep < 1) config::MaxMinGapStopStep = 1; 997 998 ParseForParameter(verbose,FileBuffer,"MaxInitMinStep", 0, 1, 1, int_type, &(config::MaxInitMinStep), 1, critical); 999 ParseForParameter(verbose,FileBuffer,"InitRelEpsTotalE", 0, 1, 1, double_type, &(config::InitRelEpsTotalEnergy), 1, critical); 1000 ParseForParameter(verbose,FileBuffer,"InitRelEpsKineticE", 0, 1, 1, double_type, &(config::InitRelEpsKineticEnergy), 1, critical); 1001 ParseForParameter(verbose,FileBuffer,"InitMaxMinStopStep", 0, 1, 1, int_type, &(config::InitMaxMinStopStep), 1, critical); 1002 ParseForParameter(verbose,FileBuffer,"InitMaxMinGapStopStep", 0, 1, 1, int_type, &(config::InitMaxMinGapStopStep), 1, critical); 1003 if (config::MaxInitMinStep <= 0) config::MaxInitMinStep = config::MaxPsiStep; 1004 if (config::InitMaxMinStopStep < 1) config::InitMaxMinStopStep = 1; 1005 if (config::InitMaxMinGapStopStep < 1) config::InitMaxMinGapStopStep = 1; 1006 1007 // Unit cell and magnetic field 1008 ParseForParameter(verbose,FileBuffer, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ 1009 mol->cell_size[0] = BoxLength[0]; 1010 mol->cell_size[1] = BoxLength[3]; 1011 mol->cell_size[2] = BoxLength[4]; 1012 mol->cell_size[3] = BoxLength[6]; 1013 mol->cell_size[4] = BoxLength[7]; 1014 mol->cell_size[5] = BoxLength[8]; 1015 //if (1) fprintf(stderr,"\n"); 1016 1017 ParseForParameter(verbose,FileBuffer,"DoPerturbation", 0, 1, 1, int_type, &(config::DoPerturbation), 1, optional); 1018 ParseForParameter(verbose,FileBuffer,"DoOutNICS", 0, 1, 1, int_type, &(config::DoOutNICS), 1, optional); 1019 if (!ParseForParameter(verbose,FileBuffer,"DoFullCurrent", 0, 1, 1, int_type, &(config::DoFullCurrent), 1, optional)) 1020 config::DoFullCurrent = 0; 1021 if (config::DoFullCurrent < 0) config::DoFullCurrent = 0; 1022 if (config::DoFullCurrent > 2) config::DoFullCurrent = 2; 1023 if (config::DoOutNICS < 0) config::DoOutNICS = 0; 1024 if (config::DoOutNICS > 2) config::DoOutNICS = 2; 1025 if (config::DoPerturbation == 0) { 1026 config::DoFullCurrent = 0; 1027 config::DoOutNICS = 0; 1028 } 1029 1030 ParseForParameter(verbose,FileBuffer,"ECut", 0, 1, 1, double_type, &(config::ECut), 1, critical); 1031 ParseForParameter(verbose,FileBuffer,"MaxLevel", 0, 1, 1, int_type, &(config::MaxLevel), 1, critical); 1032 ParseForParameter(verbose,FileBuffer,"Level0Factor", 0, 1, 1, int_type, &(config::Lev0Factor), 1, critical); 1033 if (config::Lev0Factor < 2) { 1034 config::Lev0Factor = 2; 1035 } 1036 ParseForParameter(verbose,FileBuffer,"RiemannTensor", 0, 1, 1, int_type, &di, 1, critical); 1037 if (di >= 0 && di < 2) { 1038 config::RiemannTensor = di; 1039 } else { 1040 fprintf(stderr, "0 <= RiemanTensor < 2: 0 UseNotRT, 1 UseRT"); 1041 exit(1); 1042 } 1043 switch (config::RiemannTensor) { 1044 case 0: //UseNoRT 1045 if (config::MaxLevel < 2) { 1046 config::MaxLevel = 2; 1047 } 1048 config::LevRFactor = 2; 1049 config::RTActualUse = 0; 1050 break; 1051 case 1: // UseRT 1052 if (config::MaxLevel < 3) { 1053 config::MaxLevel = 3; 1054 } 1055 ParseForParameter(verbose,FileBuffer,"RiemannLevel", 0, 1, 1, int_type, &(config::RiemannLevel), 1, critical); 1056 if (config::RiemannLevel < 2) { 1057 config::RiemannLevel = 2; 1058 } 1059 if (config::RiemannLevel > config::MaxLevel-1) { 1060 config::RiemannLevel = config::MaxLevel-1; 1061 } 1062 ParseForParameter(verbose,FileBuffer,"LevRFactor", 0, 1, 1, int_type, &(config::LevRFactor), 1, critical); 1063 if (config::LevRFactor < 2) { 1064 config::LevRFactor = 2; 1065 } 1066 config::Lev0Factor = 2; 1067 config::RTActualUse = 2; 1068 break; 1069 } 1070 ParseForParameter(verbose,FileBuffer,"PsiType", 0, 1, 1, int_type, &di, 1, critical); 1071 if (di >= 0 && di < 2) { 1072 config::PsiType = di; 1073 } else { 1074 fprintf(stderr, "0 <= PsiType < 2: 0 UseSpinDouble, 1 UseSpinUpDown"); 1075 exit(1); 1076 } 1077 switch (config::PsiType) { 1078 case 0: // SpinDouble 1079 ParseForParameter(verbose,FileBuffer,"MaxPsiDouble", 0, 1, 1, int_type, &(config::MaxPsiDouble), 1, critical); 1080 ParseForParameter(verbose,FileBuffer,"AddPsis", 0, 1, 1, int_type, &(config::AddPsis), 1, optional); 1081 break; 1082 case 1: // SpinUpDown 1083 if (config::ProcPEGamma % 2) config::ProcPEGamma*=2; 1084 ParseForParameter(verbose,FileBuffer,"PsiMaxNoUp", 0, 1, 1, int_type, &(config::PsiMaxNoUp), 1, critical); 1085 ParseForParameter(verbose,FileBuffer,"PsiMaxNoDown", 0, 1, 1, int_type, &(config::PsiMaxNoDown), 1, critical); 1086 ParseForParameter(verbose,FileBuffer,"AddPsis", 0, 1, 1, int_type, &(config::AddPsis), 1, optional); 1087 break; 1088 } 1089 1090 // IonsInitRead 1091 1092 ParseForParameter(verbose,FileBuffer,"RCut", 0, 1, 1, double_type, &(config::RCut), 1, critical); 1093 ParseForParameter(verbose,FileBuffer,"IsAngstroem", 0, 1, 1, int_type, &(config::IsAngstroem), 1, critical); 1094 ParseForParameter(verbose,FileBuffer,"MaxTypes", 0, 1, 1, int_type, &(MaxTypes), 1, critical); 1095 if (!ParseForParameter(verbose,FileBuffer,"RelativeCoord", 0, 1, 1, int_type, &(config::RelativeCoord) , 1, optional)) 1096 config::RelativeCoord = 0; 1097 if (!ParseForParameter(verbose,FileBuffer,"StructOpt", 0, 1, 1, int_type, &(config::StructOpt), 1, optional)) 1098 config::StructOpt = 0; 1099 1100 LoadMolecule(mol, FileBuffer, periode, FastParsing); 1101 1063 1102 delete(FileBuffer); 1064 1103 }; … … 1536 1575 * \note Routine is taken from the pcp project and hack-a-slack adapted to C++ 1537 1576 */ 1538 int config::ParseForParameter(int verbose, ifstream *file, const char *name, int sequential, int const xth, int const yth, int type, void *value, int repetition, int critical) {1577 int ParseForParameter(int verbose, ifstream *file, const char *name, int sequential, int const xth, int const yth, int type, void *value, int repetition, int critical) { 1539 1578 int i,j; // loop variables 1540 1579 int length = 0, maxlength = -1; … … 1774 1813 * \note Routine is taken from the pcp project and hack-a-slack adapted to C++ 1775 1814 */ 1776 int config::ParseForParameter(int verbose, struct ConfigFileBuffer *FileBuffer, const char *name, int sequential, int const xth, int const yth, int type, void *value, int repetition, int critical) {1815 int ParseForParameter(int verbose, struct ConfigFileBuffer *FileBuffer, const char *name, int sequential, int const xth, int const yth, int type, void *value, int repetition, int critical) { 1777 1816 int i,j; // loop variables 1778 1817 int length = 0, maxlength = -1; -
Property mode
changed from
-
src/config.hpp
rb1f254 r3a9fe9 126 126 127 127 128 int ParseForParameter(int verbose, ifstream *file, const char *name, int sequential, int const xth, int const yth, int type, void *value, int repetition, int critical);129 int ParseForParameter(int verbose, struct ConfigFileBuffer *FileBuffer, const char *name, int sequential, int const xth, int const yth, int type, void *value, int repetition, int critical);130 131 128 public: 132 129 config(); … … 146 143 }; 147 144 145 int ParseForParameter(int verbose, ifstream *file, const char *name, int sequential, int const xth, int const yth, int type, void *value, int repetition, int critical); 146 int ParseForParameter(int verbose, struct ConfigFileBuffer *FileBuffer, const char *name, int sequential, int const xth, int const yth, int type, void *value, int repetition, int critical); 147 void LoadMolecule(molecule *&mol, struct ConfigFileBuffer *&FileBuffer, periodentafel *periode, bool FastParsing); 148 void PrepareFileBuffer(char *filename, struct ConfigFileBuffer *&FileBuffer); 149 148 150 #endif /* CONFIG_HPP_ */
Note:
See TracChangeset
for help on using the changeset viewer.