Changeset 68cb0f
- Timestamp:
- Jun 27, 2008, 9:14:58 PM (17 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:
- 1b62f3
- Parents:
- 1f066fe
- git-author:
- Frederik Heber <heber@…> (06/27/08 21:12:52)
- git-committer:
- Frederik Heber <heber@…> (06/27/08 21:14:58)
- Location:
- src
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Makefile.am
r1f066fe r68cb0f 1 1 SOURCE = atom.cpp bond.cpp boundary.cpp builder.cpp config.cpp element.cpp helpers.cpp molecules.cpp moleculelist.cpp periodentafel.cpp vector.cpp verbose.cpp 2 HEADER = boundary.hpp defs.hpp helpers.hpp molecules.hpp stackclass.hpp vector.hpp2 HEADER = boundary.hpp defs.hpp helpers.hpp molecules.hpp periodentafel.hpp stackclass.hpp vector.hpp 3 3 4 4 bin_PROGRAMS = molecuilder joiner analyzer … … 6 6 molecuilder_DATA = elements.db valence.db orbitals.db Hbonddistance.db Hbondangle.db 7 7 molecuilder_SOURCES = ${SOURCE} ${HEADER} 8 joiner_SOURCES = joiner.cpp parser.cpp helpers.cpp verbose.cpp helpers.hpp parser.hpp datacreator.cpp datacreator.hpp9 analyzer_SOURCES = analyzer.cpp parser.cpp datacreator.cpp helpers.cpp verbose.cpp helpers.hpp parser.hpp datacreator.hpp8 joiner_SOURCES = joiner.cpp datacreator.cpp element.cpp helpers.cpp periodentafel.cpp parser.cpp verbose.cpp datacreator.hpp helpers.hpp parser.hpp periodentafel.hpp 9 analyzer_SOURCES = analyzer.cpp datacreator.cpp element.cpp helpers.cpp periodentafel.cpp parser.cpp verbose.cpp helpers.hpp periodentafel.hpp parser.hpp datacreator.hpp 10 10 11 11 -
src/analyzer.cpp
r1f066fe r68cb0f 8 8 //============================ INCLUDES =========================== 9 9 10 #include "datacreator.hpp" 10 11 #include "helpers.hpp" 11 12 #include "parser.hpp" 12 #include "datacreator.hpp" 13 #include "periodentafel.hpp" 14 15 // include config.h 16 #ifdef HAVE_CONFIG_H 17 #include <config.h> 18 #endif 13 19 14 20 … … 17 23 int main(int argc, char **argv) 18 24 { 25 periodentafel *periode = NULL; // and a period table of all elements 19 26 EnergyMatrix Energy; 20 27 ForceMatrix Force; 28 ForceMatrix Shielding; 29 ForceMatrix ShieldingPAS; 21 30 MatrixContainer Time; 22 31 EnergyMatrix EnergyFragments; 23 32 ForceMatrix ForceFragments; 24 KeySetsContainer KeySet; 33 ForceMatrix ShieldingFragments; 34 ForceMatrix ShieldingPASFragments; 35 KeySetsContainer KeySet; 25 36 ofstream output; 26 37 ofstream output2; 27 38 ofstream output3; 28 39 ofstream output4; 40 ifstream input; 29 41 stringstream filename; 30 42 time_t t = time(NULL); … … 39 51 // Get the command line options 40 52 if (argc < 4) { 41 cout << "Usage: " << argv[0] << " <inputdir> <prefix> <outputdir> " << endl;53 cout << "Usage: " << argv[0] << " <inputdir> <prefix> <outputdir> [elementsdb]" << endl; 42 54 cout << "<inputdir>\ttherein the output of a molecuilder fragmentation is expected, each fragment with a subdir containing an energy.all and a forces.all file." << endl; 43 55 cout << "<prefix>\tprefix of energy and forces file." << endl; 44 56 cout << "<outputdir>\tcreated plotfiles and datafiles are placed into this directory " << endl; 57 cout << "[elementsdb]\tpath to elements database, needed for shieldings." << endl; 45 58 return 1; 59 } 60 if (argc > 4) { 61 cout << "Loading periodentafel." << endl; 62 periode = new periodentafel; 63 periode->LoadPeriodentafel(argv[4]); 46 64 } 47 65 … … 56 74 if (!Force.ParseMatrix(argv[1], argv[2], ForcesSuffix,0,0)) return 1; 57 75 if (!Time.ParseMatrix(argv[1], argv[2], TimeSuffix, 10,1)) return 1; 76 if (periode != NULL) { // also look for PAS values 77 if (!Shielding.ParseMatrix(argv[1], argv[2], ShieldingSuffix, 1, 0)) return 1; 78 if (!ShieldingPAS.ParseMatrix(argv[1], argv[2], ShieldingPASSuffix, 1, 0)) return 1; 79 } 58 80 59 81 // ---------- Parse the TE Factors into an array ----------------- … … 62 84 // ---------- Parse the Force indices into an array --------------- 63 85 if (!Force.ParseIndices(argv[1])) return 1; 86 87 // ---------- Parse the shielding indices into an array --------------- 88 if (periode != NULL) { // also look for PAS values 89 if(!Shielding.ParseIndices(argv[1])) return 1; 90 if(!ShieldingPAS.ParseIndices(argv[1])) return 1; 91 } 64 92 65 93 // ---------- Parse the KeySets into an array --------------- 66 94 if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1; 67 95 if (!KeySet.ParseManyBodyTerms()) return 1; 96 97 // ---------- Parse fragment files created by 'joiner' into an array ------------- 68 98 if (!EnergyFragments.ParseMatrix(argv[1], argv[2], EnergyFragmentSuffix,0,0)) return 1; 69 99 if (!ForceFragments.ParseMatrix(argv[1], argv[2], ForceFragmentSuffix,0,0)) return 1; 100 if (periode != NULL) { // also look for PAS values 101 if (!ShieldingFragments.ParseMatrix(argv[1], argv[2], ShieldingSuffix, 1, 0)) return 1; 102 if (!ShieldingPASFragments.ParseMatrix(argv[1], argv[2], ShieldingPASSuffix, 1, 0)) return 1; 103 } 70 104 71 105 // +++++++++++++++ TESTING ++++++++++++++++++++++++++++++ … … 91 125 output << endl; 92 126 127 if (periode != NULL) { // also look for PAS values 128 output << endl << "Total Shieldings" << endl << "===============" << endl << Shielding.Header << endl; 129 for(int j=0;j<Shielding.RowCounter[Shielding.MatrixCounter];j++) { 130 for(int k=0;k<Shielding.ColumnCounter;k++) 131 output << scientific << Shielding.Matrix[ Shielding.MatrixCounter ][j][k] << "\t"; 132 output << endl; 133 } 134 output << endl; 135 136 output << endl << "Total Shieldings PAS" << endl << "===============" << endl << ShieldingPAS.Header << endl; 137 for(int j=0;j<ShieldingPAS.RowCounter[ShieldingPAS.MatrixCounter];j++) { 138 for(int k=0;k<ShieldingPAS.ColumnCounter;k++) 139 output << scientific << ShieldingPAS.Matrix[ ShieldingPAS.MatrixCounter ][j][k] << "\t"; 140 output << endl; 141 } 142 output << endl; 143 } 144 93 145 output << endl << "Total Times" << endl << "===============" << endl << Time.Header << endl; 94 146 Time.SetLastMatrix(0., 0); … … 380 432 output.close(); 381 433 382 // ++++++++++++++++ exit ++++++++++++++++++++++++++++++++++ 434 // ++++++++++++++++ exit ++++++++++++++++++++++++++++++++++ 435 delete(periode); 383 436 cout << "done." << endl; 384 437 return 0; -
src/boundary.cpp
r1f066fe r68cb0f 702 702 secondline++; 703 703 } while (!( 704 ( BPS[0] == secondline->second.first->second) && (BPS[1] != secondline->second.second->second) ||705 ( BPS[0] == secondline->second.second->second) && (BPS[1] != secondline->second.first->second) ||706 ( BPS[1] == secondline->second.first->second) && (BPS[0] != secondline->second.second->second) ||707 ( BPS[1] == secondline->second.second->second) && (BPS[0] != secondline->second.first->second)704 ((BPS[0] == secondline->second.first->second) && (BPS[1] != secondline->second.second->second)) || 705 ((BPS[0] == secondline->second.second->second) && (BPS[1] != secondline->second.first->second)) || 706 ((BPS[1] == secondline->second.first->second) && (BPS[0] != secondline->second.second->second)) || 707 ((BPS[1] == secondline->second.second->second) && (BPS[0] != secondline->second.first->second)) 708 708 )); 709 709 BPS[0] = secondline->second.first->second; -
src/builder.cpp
r1f066fe r68cb0f 764 764 cout << "\t-f <dist> <order>\tFragments the molecule in BOSSANOVA manner and stores config files in same dir as config." << endl; 765 765 cout << "\t-h/-H/-?\tGive this help screen." << endl; 766 cout << "\t-m \tAlign inPAS with greatest EV along z axis." << endl;766 cout << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl; 767 767 cout << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl; 768 768 cout << "\t-o\tGet volume of the convex envelope (and store to tecplot file)." << endl; -
src/defs.hpp
r1f066fe r68cb0f 49 49 #define TEFACTORSFILE "TE-Factors.dat" //!< default filename of BOSSANOVA total energy factors file 50 50 #define FORCESFILE "Forces-Factors.dat" //!< default filename of BOSSANOVA force factors file 51 #define SHIELDINGSUFFIX "sigma_all.csv" //!< default filename of BOSSANOVA shieldings file 52 #define SHIELDINGPASSUFFIX "sigma_all_PAS.csv" //!< default filename of BOSSANOVA shieldings PAS file 51 53 #define ORDERATSITEFILE "OrderAtSite.dat" //!< default filename of BOSSANOVA Bond Order at each atom file 52 54 #define ENERGYPERFRAGMENT "EnergyPerFragment" //!< default filename of BOSSANOVA Energy contribution Per Fragment file -
src/element.cpp
r1f066fe r68cb0f 5 5 */ 6 6 7 #include " molecules.hpp"7 #include "periodentafel.hpp" 8 8 9 9 /************************************* Functions for class element **********************************/ -
src/joiner.cpp
r1f066fe r68cb0f 11 11 #include "helpers.hpp" 12 12 #include "parser.hpp" 13 #include "periodentafel.hpp" 13 14 14 15 //============================== MAIN ============================= … … 16 17 int main(int argc, char **argv) 17 18 { 19 periodentafel *periode = NULL; // and a period table of all elements 18 20 EnergyMatrix Energy; 19 21 ForceMatrix Force; 20 22 EnergyMatrix EnergyFragments; 21 23 ForceMatrix ForceFragments; 24 ForceMatrix Shielding; 25 ForceMatrix ShieldingPAS; 26 ForceMatrix ShieldingFragments; 27 ForceMatrix ShieldingPASFragments; 22 28 KeySetsContainer KeySet; 23 29 stringstream prefix; … … 28 34 // Get the command line options 29 35 if (argc < 3) { 30 cout << "Usage: " << argv[0] << " <inputdir> <prefix> " << endl;36 cout << "Usage: " << argv[0] << " <inputdir> <prefix> [elementsdb]" << endl; 31 37 cout << "<inputdir>\ttherein the output of a molecuilder fragmentation is expected, each fragment with a subdir containing an energy.all and a forces.all file." << endl; 32 38 cout << "<prefix>\tprefix of energy and forces file." << endl; 39 cout << "[elementsdb]\tpath to elements database, needed for shieldings." << endl; 33 40 return 1; 41 } 42 if (argc > 3) { 43 periode = new periodentafel; 44 periode->LoadPeriodentafel(argv[3]); 34 45 } 35 46 … … 42 53 // ------------- Parse through all Fragment subdirs -------- 43 54 if (!Energy.ParseMatrix(argv[1], argv[2], EnergySuffix, 0,0)) return 1; 44 //if (!ParseSubEnergies(argv[1], argv[2], EnergySuffix, data.EnergyHeader, data.Energies, data.EnergyIndices, data.LevelCounter, data.ColumnCounter, data.FragmentCounter)) return 1;45 55 if (!Force.ParseMatrix(argv[1], argv[2], ForcesSuffix, 0,0)) return 1; 46 //if (!ParseSubForces(argv[1], argv[2], ForcesSuffix, data.ForcesHeader, data.Forces, data.AtomCounter, data.Column2Counter, data.FragmentCounter)) return 1; 56 if (periode != NULL) { // also look for PAS values 57 if (!Shielding.ParseMatrix(argv[1], argv[2], ShieldingSuffix, 1, 0)) return 1; 58 if (!ShieldingPAS.ParseMatrix(argv[1], argv[2], ShieldingPASSuffix, 1, 0)) return 1; 59 } 47 60 48 61 // ---------- Parse the TE Factors into an array ----------------- … … 51 64 // ---------- Parse the Force indices into an array --------------- 52 65 if (!Force.ParseIndices(argv[1])) return 1; 53 //if (!ParseForceIndices(argv[1], data.ForcesIndices, data.AtomCounter, data.FragmentCounter)) return 1; 66 67 // ---------- Parse the shielding indices into an array --------------- 68 if (periode != NULL) { // also look for PAS values 69 if(!Shielding.ParseIndices(argv[1])) return 1; 70 if(!ShieldingPAS.ParseIndices(argv[1])) return 1; 71 } 54 72 55 73 // ---------- Parse the KeySets into an array --------------- 56 74 if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1; 57 //if (!ParseKeySets(argv[1], data.KeySets, data.AtomCounter, data.FragmentCounter)) return 1;58 75 59 76 if (!KeySet.ParseManyBodyTerms()) return 1; 60 //if (!ParseManyBodyTerms(data.Order, data.OrderSet, data.FragmentsPerOrder, data.KeySets, data.AtomCounter, data.FragmentCounter)) return 1;61 77 if (!EnergyFragments.AllocateMatrix(Energy.Header, Energy.MatrixCounter, Energy.RowCounter, Energy.ColumnCounter)) return 1; 62 //if (!ParseSubEnergies(argv[1], argv[2], EnergyFragmentSuffix, data.EnergyHeader, data.EnergyFragments, data.EnergyFragmentIndices, data.LevelFragmentCounter, data.ColumnFragmentCounter, data.FragmentCounter)) return 1;63 78 if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return 1; 64 //if (!ParseSubForces(argv[1], argv[2], ForceFragmentSuffix, data.ForcesHeader, data.ForceFragments, data.AtomCounter, data.Column2Counter, data.FragmentCounter)) return 1; 79 if (periode != NULL) { // also look for PAS values 80 if (!ShieldingFragments.AllocateMatrix(Shielding.Header, Shielding.MatrixCounter, Shielding.RowCounter, Shielding.ColumnCounter)) return 1; 81 if (!ShieldingPASFragments.AllocateMatrix(ShieldingPAS.Header, ShieldingPAS.MatrixCounter, ShieldingPAS.RowCounter, ShieldingPAS.ColumnCounter)) return 1; 82 } 65 83 66 84 // ----------- Resetting last matrices (where full QM values are stored right now) 67 85 if(!Energy.SetLastMatrix(0., 0)) return 1; 68 86 if(!Force.SetLastMatrix(0., 2)) return 1; 69 87 if (periode != NULL) { // also look for PAS values 88 if(!Shielding.SetLastMatrix(0., 0)) return 1; 89 if(!ShieldingPAS.SetLastMatrix(0., 2)) return 1; 90 } 91 70 92 // +++++++++++++++++ SUMMING +++++++++++++++++++++++++++++++ 71 93 … … 80 102 if (!ForceFragments.SumSubManyBodyTerms(Force, KeySet, BondOrder)) return 1; 81 103 if (!Force.SumSubForces(ForceFragments, KeySet, BondOrder)) return 1; 104 if (periode != NULL) { // also look for PAS values 105 cout << "Summing shieldings of order " << BondOrder+1 << " ..." << endl; 106 if (!ShieldingFragments.SumSubManyBodyTerms(Shielding, KeySet, BondOrder)) return 1; 107 if (!Shielding.SumSubForces(ShieldingFragments, KeySet, BondOrder)) return 1; 108 if (!ShieldingPASFragments.SumSubManyBodyTerms(ShieldingPAS, KeySet, BondOrder)) return 1; 109 if (!ShieldingPAS.SumSubForces(ShieldingPASFragments, KeySet, BondOrder)) return 1; 110 } 82 111 83 112 // --------- write the energy and forces file -------------------- … … 89 118 // forces 90 119 if (!Force.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ForcesSuffix)) return 1; 120 // shieldings 121 if (periode != NULL) { // also look for PAS values 122 if (!Shielding.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ShieldingSuffix)) return 1; 123 if (!ShieldingPAS.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ShieldingPASSuffix)) return 1; 124 } 91 125 } 92 126 // fragments … … 98 132 if (!ForceFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1; 99 133 if (!CreateDataFragment(EnergyFragments, KeySet, argv[1], FRAGMENTPREFIX ENERGYPERFRAGMENT, "fragment energy versus the Fragment No", "today", CreateEnergy)) return 1; 134 if (periode != NULL) { // also look for PAS values 135 prefix.str(" "); 136 prefix << argv[2] << ShieldingFragmentSuffix; 137 if (!ShieldingFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1; 138 prefix.str(" "); 139 prefix << argv[2] << ShieldingPASFragmentSuffix; 140 if (!ShieldingPASFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1; 141 } 100 142 101 143 // write last matrices as fragments into central dir (not subdir as above), for analyzer to know index bounds 102 144 if (!Energy.WriteLastMatrix(argv[1], argv[2], EnergyFragmentSuffix)) return 1; 103 145 if (!Force.WriteLastMatrix(argv[1], argv[2], ForceFragmentSuffix)) return 1; 146 if (periode != NULL) { // also look for PAS values 147 if (!Shielding.WriteLastMatrix(argv[1], argv[2], ShieldingFragmentSuffix)) return 1; 148 if (!ShieldingPAS.WriteLastMatrix(argv[1], argv[2], ShieldingPASFragmentSuffix)) return 1; 149 } 104 150 105 151 // exit 152 delete(periode); 106 153 cout << "done." << endl; 107 154 return 0; -
src/molecules.hpp
r1f066fe r68cb0f 22 22 23 23 #include "helpers.hpp" 24 #include "periodentafel.hpp" 24 25 #include "stackclass.hpp" 25 26 #include "vector.hpp" … … 28 29 class bond; 29 30 class config; 30 class element;31 31 class molecule; 32 32 class MoleculeListClass; 33 class periodentafel;34 33 class vector; 35 34 class Verbose; … … 58 57 /************************************* Class definitions ****************************************/ 59 58 60 /** Chemical element.61 * Class incorporates data for a certain chemical element to be referenced from atom class.62 */63 class element {64 public:65 double mass; //!< mass in g/mol66 double CovalentRadius; //!< covalent radius67 double VanDerWaalsRadius; //!< can-der-Waals radius68 int Z; //!< atomic number69 char name[64]; //!< atom name, i.e. "Hydrogren"70 char symbol[3]; //!< short form of the atom, i.e. "H"71 char period[8]; //!< period: n quantum number72 char group[8]; //!< group: l quantum number73 char block[8]; //!< block: l quantum number74 element *previous; //!< previous item in list75 element *next; //!< next element in list76 int *sort; //!< sorc criteria77 int No; //!< number of element set on periodentafel::Output()78 double Valence; //!< number of valence electrons for this element79 int NoValenceOrbitals; //!< number of valence orbitals, used for determining bond degree in molecule::CreateConnectmatrix()80 double HBondDistance[NDIM]; //!< distance in Angstrom of this element to hydrogen (for single, double and triple bonds)81 double HBondAngle[NDIM]; //!< typical angle for one, two, three bonded hydrogen (in degrees)82 83 element();84 ~element();85 86 //> print element entries to screen87 bool Output(ofstream *out) const;88 bool Checkout(ofstream *out, const int No, const int NoOfAtoms) const;89 90 private:91 };92 93 /** Periodentafel is a list of all elements sorted by their atomic number.94 */95 class periodentafel {96 public:97 element *start; //!< start of element list98 element *end; //!< end of element list99 char header1[MAXSTRINGSIZE]; //!< store first header line100 char header2[MAXSTRINGSIZE]; //!< store second header line101 102 periodentafel();103 ~periodentafel();104 105 bool AddElement(element *pointer);106 bool RemoveElement(element *pointer);107 bool CleanupPeriodtable();108 element * FindElement(int Z);109 element * FindElement(char *shorthand) const;110 element * AskElement();111 bool Output(ofstream *output) const;112 bool Checkout(ofstream *output, const int *checkliste) const;113 bool LoadPeriodentafel(char *filename = NULL);114 bool StorePeriodentafel(char *filename = NULL) const;115 116 private:117 };118 59 119 60 // some algebraic matrix stuff -
src/parser.cpp
r1f066fe r68cb0f 10 10 #include "parser.hpp" 11 11 12 // include config.h 13 #ifdef HAVE_CONFIG_H 14 #include <config.h> 15 #endif 16 12 17 // ======================================= FUNCTIONS ========================================== 13 18 14 19 /** Test if given filename can be opened. 15 20 * \param filename name of file 21 * \param test true - no error message, false - print error 16 22 * \return given file exists 17 23 */ 18 #ifdef HAVE_INLINE 19 inline bool FilePresent(const char *filename) 20 #else 21 bool FilePresent(const char *filename) 22 #endif 24 bool FilePresent(const char *filename, bool test) 23 25 { 24 26 ifstream input; … … 26 28 input.open(filename, ios::in); 27 29 if (input == NULL) { 28 cout << endl << "Unable to open " << filename << ", is the directory correct?" << endl; 30 if (!test) 31 cout << endl << "Unable to open " << filename << ", is the directory correct?" << endl; 29 32 return false; 30 33 } … … 44 47 45 48 line << argv[1] << FRAGMENTPREFIX << KEYSETFILE; 46 return FilePresent(line.str().c_str() );49 return FilePresent(line.str().c_str(), false); 47 50 }; 48 51 … … 89 92 90 93 /** Parsing a number of matrices. 94 * -# First, count the number of matrices by counting lines in KEYSETFILE 95 * -# Then, 96 * -# construct the fragment number 97 * -# open the matrix file 98 * -# skip some lines (\a skiplines) 99 * -# scan header lines for number of columns 100 * -# scan lines for number of rows 101 * -# allocate matrix 102 * -# loop over found column and row counts and parse in each entry 103 * -# Finally, allocate one additional matrix (\a MatrixCounter) containing combined or temporary values 91 104 * \param *name directory with files 92 105 * \param *prefix prefix of each matrix file … … 131 144 stringstream line; 132 145 FragmentNumber = FixedDigitNumber(MatrixCounter, i); 146 file.str(" "); 133 147 if (i != MatrixCounter) 134 line << name << FRAGMENTPREFIX << FragmentNumber << "/" << prefix << suffix;148 file << name << FRAGMENTPREFIX << FragmentNumber << "/" << prefix << suffix; 135 149 else 136 line << name << prefix << suffix;150 file << name << prefix << suffix; 137 151 Free((void **)&FragmentNumber, "MatrixContainer::ParseMatrix: *FragmentNumber"); 138 input.open( line.str().c_str(), ios::in);139 //cout << "Opening " << line.str() << " ... " << input << endl;152 input.open(file.str().c_str(), ios::in); 153 //cout << "Opening " << file.str() << " ... " << input << endl; 140 154 if (input == NULL) { 141 cerr << endl << "Unable to open " << line.str() << ", is the directory correct?" << endl;155 cerr << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl; 142 156 return false; 143 157 } 158 144 159 // skip some initial lines 145 160 for (int m=skiplines+1;m--;) 146 161 input.getline(Header, 1023); 162 147 163 // scan header for number of columns 148 164 line.str(Header); … … 159 175 //cout << line.str() << endl; 160 176 //cout << "ColumnCounter: " << ColumnCounter << endl; 177 161 178 // scan rest for number of rows/lines 162 179 RowCounter[i]=-1; // counts one line too much … … 169 186 } 170 187 } 171 cout << "RowCounter[" << i << "]: " << RowCounter[i] << endl; 172 Matrix[i] = (double **) Malloc(sizeof(double *)*(RowCounter[i]+1), "MatrixContainer::ParseMatrix: **Matrix[]"); 173 input.clear(); 174 input.seekg(ios::beg); 175 for (int m=skiplines+1;m--;) 176 input.getline(Header, 1023); // skip header 177 line.str(Header); 178 for(int k=skipcolumns;k--;) // skip columns in header too 179 line >> filename; 180 strncpy(Header, line.str().c_str(), 1023); 181 for(int j=0;j<RowCounter[i];j++) { 182 Matrix[i][j] = (double *) Malloc(sizeof(double)*ColumnCounter, "MatrixContainer::ParseMatrix: *Matrix[][]"); 183 input.getline(filename, 1023); 184 stringstream lines(filename); 185 //cout << "Matrix at level " << j << ":";// << filename << endl; 186 for(int k=skipcolumns;k--;) 187 lines >> filename; 188 for(int k=0;(k<ColumnCounter) && (!lines.eof());k++) { 189 lines >> Matrix[i][j][k]; 190 //cout << " " << setprecision(2) << Matrix[i][j][k];; 188 //cout << "RowCounter[" << i << "]: " << RowCounter[i] << " from file " << file.str() << "." << endl; 189 190 // allocate matrix if it's not zero dimension in one direction 191 if ((ColumnCounter > 0) && (RowCounter[i] > -1)) { 192 Matrix[i] = (double **) Malloc(sizeof(double *)*(RowCounter[i]+1), "MatrixContainer::ParseMatrix: **Matrix[]"); 193 194 // parse in each entry for this matrix 195 input.clear(); 196 input.seekg(ios::beg); 197 for (int m=skiplines+1;m--;) 198 input.getline(Header, 1023); // skip header 199 line.str(Header); 200 for(int k=skipcolumns;k--;) // skip columns in header too 201 line >> filename; 202 strncpy(Header, line.str().c_str(), 1023); 203 for(int j=0;j<RowCounter[i];j++) { 204 Matrix[i][j] = (double *) Malloc(sizeof(double)*ColumnCounter, "MatrixContainer::ParseMatrix: *Matrix[][]"); 205 input.getline(filename, 1023); 206 stringstream lines(filename); 207 //cout << "Matrix at level " << j << ":";// << filename << endl; 208 for(int k=skipcolumns;k--;) 209 lines >> filename; 210 for(int k=0;(k<ColumnCounter) && (!lines.eof());k++) { 211 lines >> Matrix[i][j][k]; 212 //cout << " " << setprecision(2) << Matrix[i][j][k];; 213 } 214 //cout << endl; 215 Matrix[i][ RowCounter[i] ] = (double *) Malloc(sizeof(double)*ColumnCounter, "MatrixContainer::ParseMatrix: *Matrix[RowCounter[i]][]"); 216 for(int j=ColumnCounter;j--;) 217 Matrix[i][ RowCounter[i] ][j] = 0.; 191 218 } 192 //cout << endl; 193 } 194 Matrix[i][ RowCounter[i] ] = (double *) Malloc(sizeof(double)*ColumnCounter, "MatrixContainer::ParseMatrix: *Matrix[RowCounter[i]][]"); 195 for(int j=ColumnCounter;j--;) 196 Matrix[i][ RowCounter[i] ][j] = 0.; 219 } else { 220 cerr << "ERROR: Matrix nr. " << i << " has column and row count of (" << ColumnCounter << "," << RowCounter[i] << "), could not allocate nor parse!" << endl; 221 } 197 222 input.close(); 198 223 } … … 430 455 stringstream line; 431 456 432 cout << "Parsing force indices ." << endl;457 cout << "Parsing force indices for " << MatrixCounter << " matrices." << endl; 433 458 Indices = (int **) Malloc(sizeof(int *)*(MatrixCounter+1), "ForceMatrix::ParseIndices: **Indices"); 434 459 line << name << FRAGMENTPREFIX << FORCESFILE; … … 446 471 Indices[i] = (int *) Malloc(sizeof(int)*RowCounter[i], "ForceMatrix::ParseIndices: *Indices[]"); 447 472 FragmentNumber = FixedDigitNumber(MatrixCounter, i); 448 cout << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:";473 //cout << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:"; 449 474 Free((void **)&FragmentNumber, "ForceMatrix::ParseIndices: *FragmentNumber"); 450 475 for(int j=0;(j<RowCounter[i]) && (!line.eof());j++) { 451 476 line >> Indices[i][j]; 452 cout << " " << Indices[i][j];453 } 454 cout << endl;477 //cout << " " << Indices[i][j]; 478 } 479 //cout << endl; 455 480 } 456 481 Indices[MatrixCounter] = (int *) Malloc(sizeof(int)*RowCounter[MatrixCounter], "ForceMatrix::ParseIndices: *Indices[]"); … … 568 593 569 594 cout << "Creating Fragment terms." << endl; 570 // scan through all to determine order595 // scan through all to determine maximum order 571 596 Order=0; 572 597 for(int i=FragmentCounter;i--;) { -
src/parser.hpp
r1f066fe r68cb0f 20 20 #define EnergySuffix ".energy.all" 21 21 #define ForcesSuffix ".forces.all" 22 #define ShieldingSuffix ".sigma_all.csv" 23 #define ShieldingPASSuffix ".sigma_all_PAS.csv" 24 #define ShieldingFragmentSuffix ".sigma_all_fragment.all" 25 #define ShieldingPASFragmentSuffix ".sigma_all_PAS_fragment.all" 22 26 #define TimeSuffix ".speed" 23 27 #define EnergyFragmentSuffix ".energyfragment.all" … … 27 31 // ======================================= FUNCTIONS ========================================== 28 32 29 #ifdef HAVE_INLINE 30 inline bool FilePresent(const char *filename); 31 #else 32 bool FilePresent(const char *filename); 33 #endif 34 33 bool FilePresent(const char *filename, bool test); 35 34 bool TestParams(int argc, char **argv); 36 35 -
src/periodentafel.cpp
r1f066fe r68cb0f 5 5 */ 6 6 7 #include "molecules.hpp" 7 using namespace std; 8 9 #include "periodentafel.hpp" 8 10 9 11 /************************************* Functions for class periodentafel ***************************/
Note:
See TracChangeset
for help on using the changeset viewer.