Changeset fb73b8


Ignore:
Timestamp:
Oct 27, 2009, 5:16:31 PM (15 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:
c0f6c6
Parents:
776b64
git-author:
Frederik Heber <heber@…> (10/27/09 16:42:42)
git-committer:
Frederik Heber <heber@…> (10/27/09 17:16:31)
Message:

class config, ConfigFileBuffer, periodentafel and Vector are refactored with respect to ticket #38, #4 and #39.

  • <type> * const ptr ... means the pointer itself is const (not its contents that he points at).
  • const <type> * ptr ... means the pointer's content is const.
  • "ofstream *out" ... can be changed to "ofstream * const out" (pointer is constant, not output).

Signed-off-by: Frederik Heber <heber@…>

Location:
src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/bond.cpp

    r776b64 rfb73b8  
    2525 * \param number increasing index
    2626 */
    27 bond::bond(atom *left, atom *right, int degree, int number) : leftatom(left), rightatom(right), previous(NULL), next(NULL), HydrogenBond(0), BondDegree(degree), nr(number), Cyclic(false), Type(Undetermined), Used(white)
     27bond::bond(atom *left, atom *right, const int degree, const int number) : leftatom(left), rightatom(right), previous(NULL), next(NULL), HydrogenBond(0), BondDegree(degree), nr(number), Cyclic(false), Type(Undetermined), Used(white)
    2828{
    2929  if ((left != NULL) && (right != NULL)) {
     
    4747};
    4848
    49 ostream & operator << (ostream &ost, const bond &b) 
     49ostream & operator << (ostream &ost, const bond &b)
    5050{
    5151  ost << "[" << b.leftatom->Name << " <" << b.BondDegree << "(H" << b.HydrogenBond << ")>" << b.rightatom->Name << "]";
     
    5757 * \return pointer to the other atom in the bond, NULL if no match (indicates something's wrong with the bond)
    5858 */
    59 atom * bond::GetOtherAtom(const ParticleInfo *Atom) const
     59atom * bond::GetOtherAtom(const ParticleInfo * const Atom) const
    6060{
    6161  if(leftatom == Atom)
     
    8080 * \return true if it is either bond::leftatom or bond::rightatom, false otherwise
    8181 */
    82 bool bond::Contains(const ParticleInfo *ptr)
     82bool bond::Contains(const ParticleInfo * const ptr)
    8383{
    8484  return ((leftatom == ptr) || (rightatom == ptr));
     
    9797 * \return bond::Used, false if bond was already marked used
    9898 */
    99 bool bond::MarkUsed(enum Shading color) {
     99bool bond::MarkUsed(const enum Shading color) {
    100100  if (Used == black) {
    101101    cerr << "ERROR: Bond " << this << " was already marked black!." << endl;
  • src/bond.hpp

    r776b64 rfb73b8  
    4444    enum EdgeType Type;//!< whether this is a tree or back edge
    4545
    46   atom * GetOtherAtom(const ParticleInfo *Atom) const;
     46  atom * GetOtherAtom(const ParticleInfo * const Atom) const;
    4747
    48   bool MarkUsed(enum Shading color);
     48  bool MarkUsed(const enum Shading color);
    4949  enum Shading IsUsed();
    5050  void ResetUsed();
    51   bool Contains(const ParticleInfo *ptr);
     51  bool Contains(const ParticleInfo * const ptr);
    5252  bool Contains(const int nr);
    5353
    5454  bond();
    55   bond(atom *left, atom *right, int degree=1, int number=0);
     55  bond(atom *left, atom *right, const int degree=1, const int number=0);
    5656  ~bond();
    5757
  • src/config.cpp

    r776b64 rfb73b8  
    5252/** Constructor for ConfigFileBuffer class.
    5353 */
    54 ConfigFileBuffer::ConfigFileBuffer()
     54ConfigFileBuffer::ConfigFileBuffer() : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0)
    5555{
    56   NoLines = 0;
    57   CurrentLine = 0;
    58   buffer = NULL;
    59   LineMapping = NULL;
    60 }
     56};
    6157
    6258/** Constructor for ConfigFileBuffer class with filename to be parsed.
    6359 * \param *filename file name
    6460 */
    65 ConfigFileBuffer::ConfigFileBuffer(char *filename)
     61ConfigFileBuffer::ConfigFileBuffer(const char * const filename) : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0)
    6662{
    67   NoLines = 0;
    68   CurrentLine = 0;
    69   buffer = NULL;
    70   LineMapping = NULL;
    7163  ifstream *file = NULL;
    7264  char line[MAXSTRINGSIZE];
     
    141133 * \param NoAtoms of subsequent lines to look at
    142134 */
    143 void ConfigFileBuffer::MapIonTypesInBuffer(int NoAtoms)
     135void ConfigFileBuffer::MapIonTypesInBuffer(const int NoAtoms)
    144136{
    145137  map<const char *, int, IonTypeCompare> LineList;
     
    168160/** Constructor for config file class.
    169161 */
    170 config::config()
    171 {
     162config::config() : PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1), configpath(NULL),
     163    configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), Thermostat(4), ThermostatImplemented(NULL),
     164    ThermostatNames(NULL), TempFrequency(2.5), alpha(0.), HooverMass(0.), TargetTemp(0.00095004455), ScaleTempStep(25),  mainname(NULL), defaultpath(NULL), pseudopotpath(NULL),
     165    DoOutVis(0), DoOutMes(1), DoOutNICS(0), DoOutOrbitals(0), DoOutCurrent(0), DoFullCurrent(0), DoPerturbation(0), DoWannier(0), CommonWannier(0), SawtoothStart(0.01),
     166    VectorPlane(0), VectorCut(0.), UseAddGramSch(1), Seed(1), OutVisStep(10), OutSrcStep(5), MaxPsiStep(0), EpsWannier(1e-7), MaxMinStep(100), RelEpsTotalEnergy(1e-7),
     167    RelEpsKineticEnergy(1e-5), MaxMinGapStopStep(0), MaxInitMinStep(100), InitRelEpsTotalEnergy(1e-5), InitRelEpsKineticEnergy(1e-4), InitMaxMinGapStopStep(0), ECut(128.),
     168    MaxLevel(5), RiemannTensor(0), LevRFactor(0), RiemannLevel(0), Lev0Factor(2), RTActualUse(0), AddPsis(0), RCut(20.), StructOpt(0), IsAngstroem(1), RelativeCoord(0),
     169    MaxTypes(0) {
    172170  mainname = Malloc<char>(MAXSTRINGSIZE,"config constructor: mainname");
    173171  defaultpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: defaultpath");
     
    176174  configpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: configpath");
    177175  configname = Malloc<char>(MAXSTRINGSIZE,"config constructor: configname");
    178   ThermostatImplemented = Malloc<int>(MaxThermostats, "config constructor: *ThermostatImplemented");
    179   ThermostatNames = Malloc<char*>(MaxThermostats, "config constructor: *ThermostatNames");
    180   for (int j=0;j<MaxThermostats;j++)
    181     ThermostatNames[j] = Malloc<char>(12, "config constructor: ThermostatNames[]");
    182   Thermostat = 4;
    183   alpha = 0.;
    184   ScaleTempStep = 25;
    185   TempFrequency = 2.5;
    186176  strcpy(mainname,"pcp");
    187177  strcpy(defaultpath,"not specified");
     
    191181  basis = "3-21G";
    192182
    193   strcpy(ThermostatNames[0],"None");
    194   ThermostatImplemented[0] = 1;
    195   strcpy(ThermostatNames[1],"Woodcock");
    196   ThermostatImplemented[1] = 1;
    197   strcpy(ThermostatNames[2],"Gaussian");
    198   ThermostatImplemented[2] = 1;
    199   strcpy(ThermostatNames[3],"Langevin");
    200   ThermostatImplemented[3] = 1;
    201   strcpy(ThermostatNames[4],"Berendsen");
    202   ThermostatImplemented[4] = 1;
    203   strcpy(ThermostatNames[5],"NoseHoover");
    204   ThermostatImplemented[5] = 1;
    205 
    206   FastParsing = false;
    207   ProcPEGamma=8;
    208   ProcPEPsi=1;
    209   DoOutVis=0;
    210   DoOutMes=1;
    211   DoOutNICS=0;
    212   DoOutOrbitals=0;
    213   DoOutCurrent=0;
    214   DoPerturbation=0;
    215   DoFullCurrent=0;
    216   DoWannier=0;
    217   DoConstrainedMD=0;
    218   CommonWannier=0;
    219   SawtoothStart=0.01;
    220   VectorPlane=0;
    221   VectorCut=0;
    222   UseAddGramSch=1;
    223   Seed=1;
    224 
    225   MaxOuterStep=0;
    226   Deltat=0.01;
    227   OutVisStep=10;
    228   OutSrcStep=5;
    229   TargetTemp=0.00095004455;
    230   ScaleTempStep=25;
    231   MaxPsiStep=0;
    232   EpsWannier=1e-7;
    233 
    234   MaxMinStep=100;
    235   RelEpsTotalEnergy=1e-7;
    236   RelEpsKineticEnergy=1e-5;
    237   MaxMinStopStep=1;
    238   MaxMinGapStopStep=0;
    239   MaxInitMinStep=100;
    240   InitRelEpsTotalEnergy=1e-5;
    241   InitRelEpsKineticEnergy=1e-4;
    242   InitMaxMinStopStep=1;
    243   InitMaxMinGapStopStep=0;
    244 
    245   //BoxLength[NDIM*NDIM];
    246 
    247   ECut=128.;
    248   MaxLevel=5;
    249   RiemannTensor=0;
    250   LevRFactor=0;
    251   RiemannLevel=0;
    252   Lev0Factor=2;
    253   RTActualUse=0;
    254   PsiType=0;
    255   MaxPsiDouble=0;
    256   PsiMaxNoUp=0;
    257   PsiMaxNoDown=0;
    258   AddPsis=0;
    259 
    260   RCut=20.;
    261   StructOpt=0;
    262   IsAngstroem=1;
    263   RelativeCoord=0;
    264   MaxTypes=0;
     183  InitThermostats();
    265184};
    266 
    267185
    268186/** Destructor for config file class.
     
    282200};
    283201
     202/** Initialises variables in class config for Thermostats.
     203 */
     204void config::InitThermostats()
     205{
     206  ThermostatImplemented = Malloc<int>(MaxThermostats, "config constructor: *ThermostatImplemented");
     207  ThermostatNames = Malloc<char*>(MaxThermostats, "config constructor: *ThermostatNames");
     208  for (int j=0;j<MaxThermostats;j++)
     209    ThermostatNames[j] = Malloc<char>(12, "config constructor: ThermostatNames[]");
     210
     211  strcpy(ThermostatNames[0],"None");
     212  ThermostatImplemented[0] = 1;
     213  strcpy(ThermostatNames[1],"Woodcock");
     214  ThermostatImplemented[1] = 1;
     215  strcpy(ThermostatNames[2],"Gaussian");
     216  ThermostatImplemented[2] = 1;
     217  strcpy(ThermostatNames[3],"Langevin");
     218  ThermostatImplemented[3] = 1;
     219  strcpy(ThermostatNames[4],"Berendsen");
     220  ThermostatImplemented[4] = 1;
     221  strcpy(ThermostatNames[5],"NoseHoover");
     222  ThermostatImplemented[5] = 1;
     223};
     224
    284225/** Readin of Thermostat related values from parameter file.
    285226 * \param *fb file buffer containing the config file
    286227 */
    287 void config::InitThermostats(class ConfigFileBuffer *fb)
     228void config::ParseThermostats(class ConfigFileBuffer * const fb)
    288229{
    289   char *thermo = Malloc<char>(12, "IonsInitRead: thermo");
    290   int verbose = 0;
     230  char * const thermo = Malloc<char>(12, "IonsInitRead: thermo");
     231  const int verbose = 0;
    291232
    292233  // read desired Thermostat from file along with needed additional parameters
     
    354295    Thermostat = None;
    355296  }
    356   Free(&thermo);
     297  Free(thermo);
    357298};
    358299
     
    627568 * \return 0 - old syntax, 1 - new syntax, -1 - unknown syntax
    628569 */
    629 int config::TestSyntax(char *filename, periodentafel *periode, molecule *mol)
     570int config::TestSyntax(const char * const filename, const periodentafel * const periode, const molecule * const mol) const
    630571{
    631572  int test;
     
    666607 * \return *defaultpath
    667608 */
    668 void config::SetDefaultPath(const char *path)
     609void config::SetDefaultPath(const char * const path)
    669610{
    670611  strcpy(defaultpath, path);
     
    674615 * \param filename config file string
    675616 */
    676 void config::RetrieveConfigPathAndName(string filename)
     617void config::RetrieveConfigPathAndName(const string filename)
    677618{
    678619  char *ptr = NULL;
     
    702643 * \param *FileBuffer pointer to FileBuffer on return, should point to NULL
    703644 */
    704 void PrepareFileBuffer(char *filename, struct ConfigFileBuffer *&FileBuffer)
     645void PrepareFileBuffer(const char * const filename, struct ConfigFileBuffer *&FileBuffer)
    705646{
    706647  if (FileBuffer != NULL) {
     
    719660 * \param FastParsing whether to parse trajectories or not
    720661 */
    721 void LoadMolecule(molecule *&mol, struct ConfigFileBuffer *&FileBuffer, periodentafel *periode, bool FastParsing)
     662void LoadMolecule(molecule * const &mol, struct ConfigFileBuffer * const &FileBuffer, const periodentafel * const periode, const bool FastParsing)
    722663{
    723664  int MaxTypes = 0;
     
    893834 * \param *mol pointer to molecule containing all atoms of the molecule
    894835 */
    895 void config::Load(char *filename, periodentafel *periode, molecule *mol)
     836void config::Load(const char * const filename, const periodentafel * const periode, molecule * const &mol)
    896837{
    897838  ifstream *file = new ifstream(filename);
     
    909850
    910851  /* Oeffne Hauptparameterdatei */
    911   int di;
     852  int di = 0;
    912853  double BoxLength[9];
    913854  string zeile;
     
    915856  int verbose = 0;
    916857 
    917   InitThermostats(FileBuffer);
     858  ParseThermostats(FileBuffer);
    918859 
    919860  /* Namen einlesen */
     
    11091050 * \param *mol pointer to molecule containing all atoms of the molecule
    11101051 */
    1111 void config::LoadOld(char *filename, periodentafel *periode, molecule *mol)
     1052void config::LoadOld(const char * const filename, const periodentafel * const periode, molecule * const &mol)
    11121053{
    11131054  ifstream *file = new ifstream(filename);
     
    11201061
    11211062  /* Oeffne Hauptparameterdatei */
    1122   int l, i, di;
    1123   double a,b;
     1063  int l = 0;
     1064  int i = 0;
     1065  int di = 0;
     1066  double a = 0.;
     1067  double b = 0.;
    11241068  double BoxLength[9];
    11251069  string zeile;
    11261070  string dummy;
    11271071  element *elementhash[128];
    1128   int Z, No, AtomNo, found;
     1072  int Z = -1;
     1073  int No = -1;
     1074  int AtomNo = -1;
     1075  int found = 0;
    11291076  int verbose = 0;
    11301077
     
    13131260 * \param *mol pointer to molecule containing all atoms of the molecule
    13141261 */
    1315 bool config::Save(const char *filename, periodentafel *periode, molecule *mol) const
     1262bool config::Save(const char * const filename, const periodentafel * const periode, molecule * const mol) const
    13161263{
    13171264  bool result = true;
    13181265  // bring MaxTypes up to date
    13191266  mol->CountElements();
    1320   ofstream *output = NULL;
    1321   output = new ofstream(filename, ios::out);
     1267  ofstream * const output = new ofstream(filename, ios::out);
    13221268  if (output != NULL) {
    13231269    *output << "# ParallelCarParinello - main configuration file - created with molecuilder" << endl;
     
    14431389 * \param *mol pointer to molecule containing all atoms of the molecule
    14441390 */
    1445 bool config::SaveMPQC(const char *filename, molecule *mol) const
     1391bool config::SaveMPQC(const char * const filename, const molecule * const mol) const
    14461392{
    1447   int AtomNo;
     1393  int AtomNo = -1;
    14481394  Vector *center = NULL;
    14491395  ofstream *output = NULL;
    1450   stringstream *fname = NULL;
    14511396
    14521397  // first without hessian
    1453   fname = new stringstream;
    1454   *fname << filename << ".in";
    1455   output = new ofstream(fname->str().c_str(), ios::out);
    1456   *output << "% Created by MoleCuilder" << endl;
    1457   *output << "mpqc: (" << endl;
    1458   *output << "\tsavestate = no" << endl;
    1459   *output << "\tdo_gradient = yes" << endl;
    1460   *output << "\tmole<MBPT2>: (" << endl;
    1461   *output << "\t\tmaxiter = 200" << endl;
    1462   *output << "\t\tbasis = $:basis" << endl;
    1463   *output << "\t\tmolecule = $:molecule" << endl;
    1464   *output << "\t\treference<CLHF>: (" << endl;
    1465   *output << "\t\t\tbasis = $:basis" << endl;
    1466   *output << "\t\t\tmolecule = $:molecule" << endl;
    1467   *output << "\t\t)" << endl;
    1468   *output << "\t)" << endl;
    1469   *output << ")" << endl;
    1470   *output << "molecule<Molecule>: (" << endl;
    1471   *output << "\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl;
    1472   *output << "\t{ atoms geometry } = {" << endl;
    1473   center = mol->DetermineCenterOfAll(output);
    1474   // output of atoms
    1475   AtomNo = 0;
    1476   mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );
    1477   delete(center);
    1478   *output << "\t}" << endl;
    1479   *output << ")" << endl;
    1480   *output << "basis<GaussianBasisSet>: (" << endl;
    1481   *output << "\tname = \"" << basis << "\"" << endl;
    1482   *output << "\tmolecule = $:molecule" << endl;
    1483   *output << ")" << endl;
    1484   output->close();
    1485   delete(output);
    1486   delete(fname);
     1398  {
     1399    stringstream * const fname = new stringstream;;
     1400    *fname << filename << ".in";
     1401    output = new ofstream(fname->str().c_str(), ios::out);
     1402    *output << "% Created by MoleCuilder" << endl;
     1403    *output << "mpqc: (" << endl;
     1404    *output << "\tsavestate = no" << endl;
     1405    *output << "\tdo_gradient = yes" << endl;
     1406    *output << "\tmole<MBPT2>: (" << endl;
     1407    *output << "\t\tmaxiter = 200" << endl;
     1408    *output << "\t\tbasis = $:basis" << endl;
     1409    *output << "\t\tmolecule = $:molecule" << endl;
     1410    *output << "\t\treference<CLHF>: (" << endl;
     1411    *output << "\t\t\tbasis = $:basis" << endl;
     1412    *output << "\t\t\tmolecule = $:molecule" << endl;
     1413    *output << "\t\t)" << endl;
     1414    *output << "\t)" << endl;
     1415    *output << ")" << endl;
     1416    *output << "molecule<Molecule>: (" << endl;
     1417    *output << "\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl;
     1418    *output << "\t{ atoms geometry } = {" << endl;
     1419    center = mol->DetermineCenterOfAll(output);
     1420    // output of atoms
     1421    AtomNo = 0;
     1422    mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );
     1423    delete(center);
     1424    *output << "\t}" << endl;
     1425    *output << ")" << endl;
     1426    *output << "basis<GaussianBasisSet>: (" << endl;
     1427    *output << "\tname = \"" << basis << "\"" << endl;
     1428    *output << "\tmolecule = $:molecule" << endl;
     1429    *output << ")" << endl;
     1430    output->close();
     1431    delete(output);
     1432    delete(fname);
     1433  }
    14871434
    14881435  // second with hessian
    1489   fname = new stringstream;
    1490   *fname << filename << ".hess.in";
    1491   output = new ofstream(fname->str().c_str(), ios::out);
    1492   *output << "% Created by MoleCuilder" << endl;
    1493   *output << "mpqc: (" << endl;
    1494   *output << "\tsavestate = no" << endl;
    1495   *output << "\tdo_gradient = yes" << endl;
    1496   *output << "\tmole<CLHF>: (" << endl;
    1497   *output << "\t\tmaxiter = 200" << endl;
    1498   *output << "\t\tbasis = $:basis" << endl;
    1499   *output << "\t\tmolecule = $:molecule" << endl;
    1500   *output << "\t)" << endl;
    1501   *output << "\tfreq<MolecularFrequencies>: (" << endl;
    1502   *output << "\t\tmolecule=$:molecule" << endl;
    1503   *output << "\t)" << endl;
    1504   *output << ")" << endl;
    1505   *output << "molecule<Molecule>: (" << endl;
    1506   *output << "\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl;
    1507   *output << "\t{ atoms geometry } = {" << endl;
    1508   center = mol->DetermineCenterOfAll(output);
    1509   // output of atoms
    1510   AtomNo = 0;
    1511   mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );
    1512   delete(center);
    1513   *output << "\t}" << endl;
    1514   *output << ")" << endl;
    1515   *output << "basis<GaussianBasisSet>: (" << endl;
    1516   *output << "\tname = \"3-21G\"" << endl;
    1517   *output << "\tmolecule = $:molecule" << endl;
    1518   *output << ")" << endl;
    1519   output->close();
    1520   delete(output);
    1521   delete(fname);
     1436  {
     1437    stringstream * const fname = new stringstream;
     1438    *fname << filename << ".hess.in";
     1439    output = new ofstream(fname->str().c_str(), ios::out);
     1440    *output << "% Created by MoleCuilder" << endl;
     1441    *output << "mpqc: (" << endl;
     1442    *output << "\tsavestate = no" << endl;
     1443    *output << "\tdo_gradient = yes" << endl;
     1444    *output << "\tmole<CLHF>: (" << endl;
     1445    *output << "\t\tmaxiter = 200" << endl;
     1446    *output << "\t\tbasis = $:basis" << endl;
     1447    *output << "\t\tmolecule = $:molecule" << endl;
     1448    *output << "\t)" << endl;
     1449    *output << "\tfreq<MolecularFrequencies>: (" << endl;
     1450    *output << "\t\tmolecule=$:molecule" << endl;
     1451    *output << "\t)" << endl;
     1452    *output << ")" << endl;
     1453    *output << "molecule<Molecule>: (" << endl;
     1454    *output << "\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl;
     1455    *output << "\t{ atoms geometry } = {" << endl;
     1456    center = mol->DetermineCenterOfAll(output);
     1457    // output of atoms
     1458    AtomNo = 0;
     1459    mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );
     1460    delete(center);
     1461    *output << "\t}" << endl;
     1462    *output << ")" << endl;
     1463    *output << "basis<GaussianBasisSet>: (" << endl;
     1464    *output << "\tname = \"3-21G\"" << endl;
     1465    *output << "\tmolecule = $:molecule" << endl;
     1466    *output << ")" << endl;
     1467    output->close();
     1468    delete(output);
     1469    delete(fname);
     1470  }
    15221471
    15231472  return true;
     
    15451494 * \note Routine is taken from the pcp project and hack-a-slack adapted to C++
    15461495 */
    1547 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) {
    1548   int i,j;  // loop variables
    1549   int length = 0, maxlength = -1;
     1496int ParseForParameter(const int verbose, ifstream * const file, const char * const name, const int sequential, const int xth, const int yth, const int type, void * value, const int repetition, const int critical) {
     1497  int i = 0;
     1498  int j = 0;  // loop variables
     1499  int length = 0;
     1500  int maxlength = -1;
    15501501  long file_position = file->tellg(); // mark current position
    1551   char *dummy1, *dummy, *free_dummy;    // pointers in the line that is read in per step
    1552   dummy1 = free_dummy = Malloc<char>(256, "config::ParseForParameter: *free_dummy");
     1502  char *dummy1 = NULL;
     1503  char *dummy = NULL;
     1504  char * const free_dummy = Malloc<char>(256, "config::ParseForParameter: *free_dummy");    // pointers in the line that is read in per step
     1505  dummy1 = free_dummy;
    15531506
    15541507  //fprintf(stderr,"Parsing for %s\n",name);
     
    15651518      if (file->eof()) {
    15661519        if ((critical) && (found == 0)) {
    1567           Free(&free_dummy);
     1520          Free(free_dummy);
    15681521          //Error(InitReading, name);
    15691522          fprintf(stderr,"Error:InitReading, critical %s not found\n", name);
     
    15731526          file->clear();
    15741527          file->seekg(file_position, ios::beg);  // rewind to start position
    1575           Free(&free_dummy);
     1528          Free(free_dummy);
    15761529          return 0;
    15771530        }
     
    16251578              if (file->eof()) {
    16261579                if ((critical) && (found == 0)) {
    1627                   Free(&free_dummy);
     1580                  Free(free_dummy);
    16281581                  //Error(InitReading, name);
    16291582                  fprintf(stderr,"Error:InitReading, critical %s not found\n", name);
     
    16331586                  file->clear();
    16341587                  file->seekg(file_position, ios::beg);  // rewind to start position
    1635                   Free(&free_dummy);
     1588                  Free(free_dummy);
    16361589                  return 0;
    16371590                }
     
    16741627                  if (critical) {
    16751628                    if (verbose) fprintf(stderr,"Error: EoL at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name);
    1676                     Free(&free_dummy);
     1629                    Free(free_dummy);
    16771630                    //return 0;
    16781631                    exit(255);
     
    16821635                    file->clear();
    16831636                    file->seekg(file_position, ios::beg);  // rewind to start position
    1684                     Free(&free_dummy);
     1637                    Free(free_dummy);
    16851638                    return 0;
    16861639                  }
     
    16951648                  file->seekg(file_position, ios::beg);  // rewind to start position
    16961649                }
    1697                 Free(&free_dummy);
     1650                Free(free_dummy);
    16981651                return 0;
    16991652              }
     
    17511704  if ((type >= row_int) && (verbose))
    17521705    fprintf(stderr,"\n");
    1753   Free(&free_dummy);
     1706  Free(free_dummy);
    17541707  if (!sequential) {
    17551708    file->clear();
     
    17831736 * \note Routine is taken from the pcp project and hack-a-slack adapted to C++
    17841737 */
    1785 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) {
    1786   int i,j;  // loop variables
    1787   int length = 0, maxlength = -1;
     1738int ParseForParameter(const int verbose, struct ConfigFileBuffer * const FileBuffer, const char * const name, const int sequential, const int xth, const int yth, const int type, void * value, const int repetition, const int critical) {
     1739  int i = 0;
     1740  int j = 0;  // loop variables
     1741  int length = 0;
     1742  int maxlength = -1;
    17881743  int OldCurrentLine = FileBuffer->CurrentLine;
    1789   char *dummy1, *dummy;    // pointers in the line that is read in per step
     1744  char *dummy1 = NULL;
     1745  char *dummy = NULL;    // pointers in the line that is read in per step
    17901746
    17911747  //fprintf(stderr,"Parsing for %s\n",name);
  • src/config.hpp

    r776b64 rfb73b8  
    3535
    3636    ConfigFileBuffer();
    37     ConfigFileBuffer(char *filename);
     37    ConfigFileBuffer(const char * const filename);
    3838    ~ConfigFileBuffer();
    3939
    4040    void InitMapping();
    41     void MapIonTypesInBuffer(int NoAtoms);
     41    void MapIonTypesInBuffer(const int NoAtoms);
    4242};
    4343
     
    130130  ~config();
    131131
    132   int TestSyntax(char *filename, periodentafel *periode, molecule *mol);
    133   void Load(char *filename, periodentafel *periode, molecule *mol);
    134   void LoadOld(char *filename, periodentafel *periode, molecule *mol);
    135   void RetrieveConfigPathAndName(string filename);
    136   bool Save(const char *filename, periodentafel *periode, molecule *mol) const;
    137   bool SaveMPQC(const char *filename, molecule *mol) const;
     132  int TestSyntax(const char * const filename, const periodentafel * const periode, const molecule * const mol) const;
     133  void Load(const char * const filename, const periodentafel * const periode, molecule * const &mol);
     134  void LoadOld(const char * const filename, const periodentafel * const periode, molecule * const &mol);
     135  void RetrieveConfigPathAndName(const string filename);
     136  bool Save(const char * const filename, const periodentafel * const periode, molecule * const mol) const;
     137  bool SaveMPQC(const char * const filename, const molecule * const mol) const;
    138138  void Edit();
    139139  bool GetIsAngstroem() const;
    140140  char *GetDefaultPath() const;
    141   void SetDefaultPath(const char *path);
    142   void InitThermostats(class ConfigFileBuffer *fb);
     141  void SetDefaultPath(const char * const path);
     142  void InitThermostats();
     143  void ParseThermostats(class ConfigFileBuffer * const fb);
    143144};
    144145
    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);
     146int ParseForParameter(const int verbose, ifstream * const file, const char * const name, const int sequential, const int xth, const int yth, const int type, void * value, const int repetition, const int critical);
     147int ParseForParameter(const int verbose, struct ConfigFileBuffer * const FileBuffer, const char * const name, const int sequential, const int xth, const int yth, const int type, void * value, const int repetition, const int critical);
     148void LoadMolecule(molecule * const &mol, struct ConfigFileBuffer * const &FileBuffer, const periodentafel * const periode, const bool FastParsing);
     149void PrepareFileBuffer(const char * const filename, struct ConfigFileBuffer *&FileBuffer);
    149150
    150151#endif /* CONFIG_HPP_ */
  • src/memoryallocator.hpp

    r776b64 rfb73b8  
    105105};
    106106
    107 /** Frees allocated memory range using free().
     107/** Frees allocated memory range using free(), NULL'ing \a **buffer.
    108108 *
    109  * \param pointer to the allocated memory range to free; may be NULL, this function is a no-op then
     109 * \param **buffer to the allocated memory range to free; may be NULL, this function is a no-op then
    110110 * \param *msg optional error message
    111111 */
     
    120120};
    121121
     122/** Frees allocated memory range using free() for ... * const \a buffer types.
     123 *
     124 * \param *buffer to the allocated memory range to free; may be NULL, this function is a no-op then
     125 * \param *msg optional error message
     126 */
     127template <typename X> void Free(X* const buffer, const char *msg = NULL)
     128{
     129  if ((buffer == NULL))
     130    return;
     131
     132  MemoryUsageObserver::getInstance()->removeMemory(buffer, msg);
     133  free(buffer);
     134};
     135
    122136#endif /*MEMORYALLOCATOR_HPP_*/
  • src/periodentafel.cpp

    r776b64 rfb73b8  
    2121 * Initialises start and end of list and resets periodentafel::checkliste to false.
    2222 */
    23 periodentafel::periodentafel()
    24 {
    25   start = new element;
    26   end = new element;
     23periodentafel::periodentafel() : start(new element), end(new element)
     24{
    2725  start->previous = NULL;
    2826  start->next = end;
     
    4543 * \return true - succeeded, false - does not occur
    4644 */
    47 bool periodentafel::AddElement(element *pointer)
     45bool periodentafel::AddElement(element * const pointer)
    4846{
    4947  pointer->sort = &pointer->Z;
     
    5755 * \return true - succeeded, false - element not found
    5856 */
    59 bool periodentafel::RemoveElement(element *pointer)
     57bool periodentafel::RemoveElement(element * const pointer)
    6058{
    6159  return remove(pointer, start, end);
     
    7169
    7270/** Finds an element by its atomic number.
    73  * If element is not yet in list, datas are asked and stored in database.
     71 * If element is not yet in list, returns NULL.
    7472 * \param Z atomic number
    75  * \return pointer to element
    76  */
    77 element * periodentafel::FindElement(int Z)
     73 * \return pointer to element or NULL if not found
     74 */
     75element * const periodentafel::FindElement(const int Z) const
    7876{
    7977  element *walker = find(&Z, start,end);
    80   if (walker == NULL) { // not found: enter and put into db
    81     cout << Verbose(0) << "Element not found in database, please enter." << endl;
    82     walker = new element;
    83     cout << Verbose(0) << "Mass: " << endl;
    84     cin >> walker->mass;
    85     walker->Z = Z;
    86     cout << Verbose(0) << "Atomic number: " << walker->Z << endl;
    87     cout << Verbose(0) << "Name [max 64 chars]: " << endl;
    88     cin >> walker->name;
    89     cout << Verbose(0) << "Short form [max 3 chars]: " << endl;
    90     cin >> walker->symbol;
    91     periodentafel::AddElement(walker);
    92   }
    9378  return(walker);
    9479};
     
    9984 * \return pointer to element
    10085 */
    101 element * periodentafel::FindElement(const char *shorthand) const
     86element * const periodentafel::FindElement(const char * const shorthand) const
    10287{
    10388  element *walker =  periodentafel::start;
     
    11297/** Asks for element number and returns pointer to element
    11398 */
    114 element * periodentafel::AskElement()
     99element * const periodentafel::AskElement() const
    115100{
    116101  element *walker = NULL;
     
    124109};
    125110
     111/** Asks for element and if not found, presents mask to enter info.
     112 * \return pointer to either present or newly created element
     113 */
     114element * const periodentafel::EnterElement()
     115{
     116  element *walker = NULL;
     117  int Z = -1;
     118  cout << Verbose(0) << "Atomic number: " << Z << endl;
     119  cin >> Z;
     120  walker = FindElement(Z);
     121  if (walker == NULL) {
     122    cout << Verbose(0) << "Element not found in database, please enter." << endl;
     123    walker = new element;
     124    walker->Z = Z;
     125    cout << Verbose(0) << "Mass: " << endl;
     126    cin >> walker->mass;
     127    cout << Verbose(0) << "Name [max 64 chars]: " << endl;
     128    cin >> walker->name;
     129    cout << Verbose(0) << "Short form [max 3 chars]: " << endl;
     130    cin >> walker->symbol;
     131    periodentafel::AddElement(walker);
     132  }
     133  return(walker);
     134};
     135
    126136/** Prints period table to given stream.
    127137 * \param output stream
    128138 */
    129 bool periodentafel::Output(ofstream *output) const
     139bool periodentafel::Output(ofstream * const output) const
    130140{
    131141  bool result = true;
     
    145155 * \param *checkliste elements table for this molecule
    146156 */
    147 bool periodentafel::Checkout(ofstream *output, const int *checkliste) const
     157bool periodentafel::Checkout(ofstream * const output, const int * const checkliste) const
    148158{
    149159  element *walker = start;
  • src/periodentafel.hpp

    r776b64 rfb73b8  
    3434  ~periodentafel();
    3535
    36   bool AddElement(element *pointer);
    37   bool RemoveElement(element *pointer);
     36  bool AddElement(element * const pointer);
     37  bool RemoveElement(element * const pointer);
    3838  bool CleanupPeriodtable();
    39   element * FindElement(int Z);
    40   element * FindElement(const char *shorthand) const;
    41   element * AskElement();
    42   bool Output(ofstream *output) const;
    43   bool Checkout(ofstream *output, const int *checkliste) const;
    44   bool LoadPeriodentafel(const char *path);
    45   bool StorePeriodentafel(const char *path) const;
     39  element * const FindElement(const int Z) const;
     40  element * const FindElement(const char * const shorthand) const;
     41  element * const AskElement() const;
     42  element * const EnterElement();
     43  bool Output(ofstream * const output) const;
     44  bool Checkout(ofstream * const output, const int * const checkliste) const;
     45  bool LoadPeriodentafel(const char * const path);
     46  bool StorePeriodentafel(const char * const path) const;
    4647
    4748  private:
  • src/vector.hpp

    r776b64 rfb73b8  
    2727
    2828  Vector();
    29   Vector(double x1, double x2, double x3);
     29  Vector(const double x1, const double x2, const double x3);
    3030  ~Vector();
    3131
Note: See TracChangeset for help on using the changeset viewer.