Changeset 68cb0f


Ignore:
Timestamp:
Jun 27, 2008, 9:14:58 PM (17 years ago)
Author:
Frederik Heber <heber@…>
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)
Message:

introduced shieldings to analyzer and joiner

both now handle pcp.sigma_all...csv files just as pcp.forces.all. Therefore the data format in pcp/perturbed.c was adapted a bit, as we need a header.
periodentafel.hpp got periodentafel and element class from molecules.hpp

Location:
src
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • src/Makefile.am

    r1f066fe r68cb0f  
    11SOURCE = 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.hpp
     2HEADER = boundary.hpp defs.hpp helpers.hpp molecules.hpp periodentafel.hpp stackclass.hpp vector.hpp
    33
    44bin_PROGRAMS = molecuilder joiner analyzer
     
    66molecuilder_DATA = elements.db valence.db       orbitals.db Hbonddistance.db Hbondangle.db
    77molecuilder_SOURCES =  ${SOURCE} ${HEADER}
    8 joiner_SOURCES = joiner.cpp parser.cpp helpers.cpp verbose.cpp helpers.hpp parser.hpp datacreator.cpp datacreator.hpp
    9 analyzer_SOURCES = analyzer.cpp parser.cpp datacreator.cpp helpers.cpp verbose.cpp helpers.hpp parser.hpp datacreator.hpp
     8joiner_SOURCES = joiner.cpp datacreator.cpp element.cpp helpers.cpp periodentafel.cpp parser.cpp verbose.cpp datacreator.hpp helpers.hpp parser.hpp periodentafel.hpp
     9analyzer_SOURCES = analyzer.cpp datacreator.cpp element.cpp helpers.cpp periodentafel.cpp parser.cpp verbose.cpp helpers.hpp periodentafel.hpp parser.hpp datacreator.hpp
    1010
    1111
  • src/analyzer.cpp

    r1f066fe r68cb0f  
    88//============================ INCLUDES ===========================
    99
     10#include "datacreator.hpp"
    1011#include "helpers.hpp"
    1112#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
    1319
    1420
     
    1723int main(int argc, char **argv)
    1824{
     25  periodentafel *periode = NULL; // and a period table of all elements
    1926  EnergyMatrix Energy;
    2027  ForceMatrix Force;
     28  ForceMatrix Shielding;
     29  ForceMatrix ShieldingPAS;
    2130  MatrixContainer Time;
    2231  EnergyMatrix EnergyFragments;
    2332  ForceMatrix ForceFragments;
    24   KeySetsContainer KeySet; 
     33  ForceMatrix ShieldingFragments;
     34  ForceMatrix ShieldingPASFragments;
     35  KeySetsContainer KeySet;
    2536  ofstream output;
    2637  ofstream output2;
    2738  ofstream output3;
    2839  ofstream output4;
     40  ifstream input;
    2941  stringstream filename;
    3042  time_t t = time(NULL);
     
    3951  // Get the command line options
    4052  if (argc < 4) {
    41     cout << "Usage: " << argv[0] << " <inputdir> <prefix> <outputdir>" << endl;
     53    cout << "Usage: " << argv[0] << " <inputdir> <prefix> <outputdir> [elementsdb]" << endl;
    4254    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;
    4355    cout << "<prefix>\tprefix of energy and forces file." << endl;
    4456    cout << "<outputdir>\tcreated plotfiles and datafiles are placed into this directory " << endl;
     57    cout << "[elementsdb]\tpath to elements database, needed for shieldings." << endl;
    4558    return 1;
     59  }
     60  if (argc > 4) {
     61    cout << "Loading periodentafel." << endl;
     62    periode = new periodentafel;
     63    periode->LoadPeriodentafel(argv[4]);
    4664  }
    4765 
     
    5674  if (!Force.ParseMatrix(argv[1], argv[2], ForcesSuffix,0,0)) return 1;
    5775  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  }
    5880
    5981  // ---------- Parse the TE Factors into an array -----------------
     
    6284  // ---------- Parse the Force indices into an array ---------------
    6385  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  }
    6492
    6593  // ---------- Parse the KeySets into an array ---------------
    6694  if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1;
    6795  if (!KeySet.ParseManyBodyTerms()) return 1;
     96 
     97  // ---------- Parse fragment files created by 'joiner' into an array -------------
    6898  if (!EnergyFragments.ParseMatrix(argv[1], argv[2], EnergyFragmentSuffix,0,0)) return 1;
    6999  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  }
    70104
    71105  // +++++++++++++++ TESTING ++++++++++++++++++++++++++++++
     
    91125  output << endl;
    92126
     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 
    93145  output << endl << "Total Times" << endl << "===============" << endl << Time.Header << endl;
    94146  Time.SetLastMatrix(0., 0);
     
    380432  output.close();
    381433 
    382   // ++++++++++++++++ exit ++++++++++++++++++++++++++++++++++ 
     434  // ++++++++++++++++ exit ++++++++++++++++++++++++++++++++++
     435  delete(periode);
    383436  cout << "done." << endl;
    384437  return 0;
  • src/boundary.cpp

    r1f066fe r68cb0f  
    702702    secondline++;
    703703  } 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))
    708708    ));
    709709  BPS[0] = secondline->second.first->second;
  • src/builder.cpp

    r1f066fe r68cb0f  
    764764            cout << "\t-f <dist> <order>\tFragments the molecule in BOSSANOVA manner and stores config files in same dir as config." << endl;
    765765            cout << "\t-h/-H/-?\tGive this help screen." << endl;
    766             cout << "\t-m\tAlign in PAS 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;
    767767            cout << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl;
    768768            cout << "\t-o\tGet volume of the convex envelope (and store to tecplot file)." << endl;
  • src/defs.hpp

    r1f066fe r68cb0f  
    4949#define TEFACTORSFILE "TE-Factors.dat"    //!< default filename of BOSSANOVA total energy factors file
    5050#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
    5153#define ORDERATSITEFILE "OrderAtSite.dat"    //!< default filename of BOSSANOVA Bond Order at each atom file
    5254#define ENERGYPERFRAGMENT "EnergyPerFragment"    //!< default filename of BOSSANOVA Energy contribution Per Fragment file
  • src/element.cpp

    r1f066fe r68cb0f  
    55 */
    66
    7 #include "molecules.hpp"
     7#include "periodentafel.hpp"
    88
    99/************************************* Functions for class element **********************************/
  • src/joiner.cpp

    r1f066fe r68cb0f  
    1111#include "helpers.hpp"
    1212#include "parser.hpp"
     13#include "periodentafel.hpp"
    1314
    1415//============================== MAIN =============================
     
    1617int main(int argc, char **argv)
    1718{
     19  periodentafel *periode = NULL; // and a period table of all elements
    1820  EnergyMatrix Energy;
    1921  ForceMatrix Force;
    2022  EnergyMatrix EnergyFragments;
    2123  ForceMatrix ForceFragments;
     24  ForceMatrix Shielding;
     25  ForceMatrix ShieldingPAS;
     26  ForceMatrix ShieldingFragments;
     27  ForceMatrix ShieldingPASFragments;
    2228  KeySetsContainer KeySet; 
    2329  stringstream prefix;
     
    2834  // Get the command line options
    2935  if (argc < 3) {
    30     cout << "Usage: " << argv[0] << " <inputdir> <prefix>" << endl;
     36    cout << "Usage: " << argv[0] << " <inputdir> <prefix> [elementsdb]" << endl;
    3137    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;
    3238    cout << "<prefix>\tprefix of energy and forces file." << endl;
     39    cout << "[elementsdb]\tpath to elements database, needed for shieldings." << endl;
    3340    return 1;
     41  }
     42  if (argc > 3) {
     43    periode = new periodentafel;
     44    periode->LoadPeriodentafel(argv[3]);
    3445  }
    3546 
     
    4253  // ------------- Parse through all Fragment subdirs --------
    4354  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;
    4555  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  }
    4760
    4861  // ---------- Parse the TE Factors into an array -----------------
     
    5164  // ---------- Parse the Force indices into an array ---------------
    5265  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  }
    5472
    5573  // ---------- Parse the KeySets into an array ---------------
    5674  if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1;
    57   //if (!ParseKeySets(argv[1], data.KeySets, data.AtomCounter, data.FragmentCounter)) return 1;
    5875
    5976  if (!KeySet.ParseManyBodyTerms()) return 1;
    60   //if (!ParseManyBodyTerms(data.Order, data.OrderSet, data.FragmentsPerOrder, data.KeySets, data.AtomCounter, data.FragmentCounter)) return 1;
    6177  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;
    6378  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  }
    6583 
    6684  // ----------- Resetting last matrices (where full QM values are stored right now)
    6785  if(!Energy.SetLastMatrix(0., 0)) return 1;
    6886  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
    7092  // +++++++++++++++++ SUMMING +++++++++++++++++++++++++++++++
    7193
     
    80102    if (!ForceFragments.SumSubManyBodyTerms(Force, KeySet, BondOrder)) return 1;
    81103    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    }
    82111
    83112    // --------- write the energy and forces file --------------------
     
    89118    // forces
    90119    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    }
    91125  }
    92126  // fragments
     
    98132  if (!ForceFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
    99133  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  }
    100142
    101143  // write last matrices as fragments into central dir (not subdir as above), for analyzer to know index bounds
    102144  if (!Energy.WriteLastMatrix(argv[1], argv[2], EnergyFragmentSuffix)) return 1;
    103145  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  }
    104150
    105151  // exit 
     152  delete(periode);
    106153  cout << "done." << endl;
    107154  return 0;
  • src/molecules.hpp

    r1f066fe r68cb0f  
    2222
    2323#include "helpers.hpp"
     24#include "periodentafel.hpp"
    2425#include "stackclass.hpp"
    2526#include "vector.hpp"
     
    2829class bond;
    2930class config;
    30 class element;
    3131class molecule;
    3232class MoleculeListClass;
    33 class periodentafel;
    3433class vector;
    3534class Verbose;
     
    5857/************************************* Class definitions ****************************************/
    5958
    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/mol
    66     double CovalentRadius;  //!< covalent radius
    67     double VanDerWaalsRadius;  //!< can-der-Waals radius
    68     int Z;          //!< atomic number
    69     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 number
    72     char group[8];    //!< group: l quantum number
    73     char block[8];    //!< block: l quantum number
    74     element *previous;  //!< previous item in list
    75     element *next;  //!< next element in list
    76     int *sort;      //!< sorc criteria
    77     int No;         //!< number of element set on periodentafel::Output()
    78     double Valence;             //!< number of valence electrons for this element
    79     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 screen
    87   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 list
    98     element *end;   //!< end of element list
    99     char header1[MAXSTRINGSIZE]; //!< store first header line
    100     char header2[MAXSTRINGSIZE]; //!< store second header line
    101  
    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 };
    11859
    11960// some algebraic matrix stuff
  • src/parser.cpp

    r1f066fe r68cb0f  
    1010#include "parser.hpp"
    1111
     12// include config.h
     13#ifdef HAVE_CONFIG_H
     14#include <config.h>
     15#endif
     16
    1217// ======================================= FUNCTIONS ==========================================
    1318
    1419/** Test if given filename can be opened.
    1520 * \param filename name of file
     21 * \param test true - no error message, false - print error
    1622 * \return given file exists
    1723 */
    18 #ifdef HAVE_INLINE
    19 inline bool FilePresent(const char *filename)
    20 #else
    21 bool FilePresent(const char *filename)
    22 #endif
     24bool FilePresent(const char *filename, bool test)
    2325{
    2426  ifstream input;
     
    2628  input.open(filename, ios::in);
    2729  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;
    2932    return false;
    3033  }
     
    4447
    4548  line << argv[1] << FRAGMENTPREFIX << KEYSETFILE;
    46   return FilePresent(line.str().c_str());
     49  return FilePresent(line.str().c_str(), false);
    4750};
    4851
     
    8992
    9093/** 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
    91104 * \param *name directory with files
    92105 * \param *prefix prefix of each matrix file
     
    131144    stringstream line;
    132145    FragmentNumber = FixedDigitNumber(MatrixCounter, i);
     146    file.str(" ");
    133147    if (i != MatrixCounter) 
    134       line << name << FRAGMENTPREFIX << FragmentNumber << "/" << prefix << suffix;
     148      file << name << FRAGMENTPREFIX << FragmentNumber << "/" << prefix << suffix;
    135149    else
    136       line << name << prefix << suffix;
     150      file << name << prefix << suffix;
    137151    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;
    140154    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;
    142156      return false;
    143157    }
     158   
    144159    // skip some initial lines
    145160    for (int m=skiplines+1;m--;)
    146161      input.getline(Header, 1023);
     162   
    147163    // scan header for number of columns
    148164    line.str(Header);
     
    159175    //cout << line.str() << endl;
    160176    //cout << "ColumnCounter: " << ColumnCounter << endl;
     177   
    161178    // scan rest for number of rows/lines
    162179    RowCounter[i]=-1;    // counts one line too much
     
    169186      }
    170187    }
    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.;
    191218      }
    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    }
    197222    input.close();
    198223  }
     
    430455  stringstream line;
    431456 
    432   cout << "Parsing force indices." << endl;
     457  cout << "Parsing force indices for " << MatrixCounter << " matrices." << endl;
    433458  Indices = (int **) Malloc(sizeof(int *)*(MatrixCounter+1), "ForceMatrix::ParseIndices: **Indices");
    434459  line << name << FRAGMENTPREFIX << FORCESFILE;
     
    446471    Indices[i] = (int *) Malloc(sizeof(int)*RowCounter[i], "ForceMatrix::ParseIndices: *Indices[]");
    447472    FragmentNumber = FixedDigitNumber(MatrixCounter, i);
    448     cout << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:";
     473    //cout << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:";
    449474    Free((void **)&FragmentNumber, "ForceMatrix::ParseIndices: *FragmentNumber");
    450475    for(int j=0;(j<RowCounter[i]) && (!line.eof());j++) {
    451476      line >> Indices[i][j];
    452       cout << " " << Indices[i][j];
    453     }
    454     cout << endl;
     477      //cout << " " << Indices[i][j];
     478    }
     479    //cout << endl;
    455480  }
    456481  Indices[MatrixCounter] = (int *) Malloc(sizeof(int)*RowCounter[MatrixCounter], "ForceMatrix::ParseIndices: *Indices[]");
     
    568593 
    569594  cout << "Creating Fragment terms." << endl;
    570   // scan through all to determine order
     595  // scan through all to determine maximum order
    571596  Order=0;
    572597  for(int i=FragmentCounter;i--;) {
  • src/parser.hpp

    r1f066fe r68cb0f  
    2020#define EnergySuffix ".energy.all"
    2121#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"
    2226#define TimeSuffix ".speed"
    2327#define EnergyFragmentSuffix ".energyfragment.all"
     
    2731// ======================================= FUNCTIONS ==========================================
    2832
    29 #ifdef HAVE_INLINE
    30 inline bool FilePresent(const char *filename);
    31 #else
    32 bool FilePresent(const char *filename);
    33 #endif
    34 
     33bool FilePresent(const char *filename, bool test);
    3534bool TestParams(int argc, char **argv);
    3635
  • src/periodentafel.cpp

    r1f066fe r68cb0f  
    55 */
    66
    7 #include "molecules.hpp"
     7using namespace std;
     8
     9#include "periodentafel.hpp"
    810
    911/************************************* Functions for class periodentafel ***************************/
Note: See TracChangeset for help on using the changeset viewer.