Changeset 0d1ad0 for src/config.cpp


Ignore:
Timestamp:
Jun 25, 2010, 9:42:28 AM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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, Candidate_v1.7.0, 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:
04488a, 0c5eeb, 93987b
Parents:
6d574a (diff), a356f2 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'stable' into StructureRefactoring

Conflicts:

molecuilder/src/World.cpp

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/config.cpp

    r6d574a r0d1ad0  
    1010#include <cstring>
    1111
    12 #include "World.hpp"
    1312#include "atom.hpp"
    1413#include "bond.hpp"
     14#include "bondgraph.hpp"
    1515#include "config.hpp"
     16#include "ConfigFileBuffer.hpp"
    1617#include "element.hpp"
    1718#include "helpers.hpp"
     
    2324#include "molecule.hpp"
    2425#include "periodentafel.hpp"
     26#include "ThermoStatContainer.hpp"
    2527#include "World.hpp"
    26 
    27 /******************************** Functions for class ConfigFileBuffer **********************/
    28 
    29 /** Structure containing compare function for Ion_Type sorting.
    30  */
    31 struct IonTypeCompare {
    32   bool operator()(const char* s1, const char *s2) const {
    33     char number1[8];
    34     char number2[8];
    35     const char *dummy1, *dummy2;
    36     //Log() << Verbose(0) << s1 << "  " << s2 << endl;
    37     dummy1 = strchr(s1, '_')+sizeof(char)*5;  // go just after "Ion_Type"
    38     dummy2 = strchr(dummy1, '_');
    39     strncpy(number1, dummy1, dummy2-dummy1); // copy the number
    40     number1[dummy2-dummy1]='\0';
    41     dummy1 = strchr(s2, '_')+sizeof(char)*5;  // go just after "Ion_Type"
    42     dummy2 = strchr(dummy1, '_');
    43     strncpy(number2, dummy1, dummy2-dummy1); // copy the number
    44     number2[dummy2-dummy1]='\0';
    45     if (atoi(number1) != atoi(number2))
    46       return (atoi(number1) < atoi(number2));
    47     else {
    48       dummy1 = strchr(s1, '_')+sizeof(char);
    49       dummy1 = strchr(dummy1, '_')+sizeof(char);
    50       dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t');
    51       strncpy(number1, dummy1, dummy2-dummy1); // copy the number
    52       number1[dummy2-dummy1]='\0';
    53       dummy1 = strchr(s2, '_')+sizeof(char);
    54       dummy1 = strchr(dummy1, '_')+sizeof(char);
    55       dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t');
    56       strncpy(number2, dummy1, dummy2-dummy1); // copy the number
    57       number2[dummy2-dummy1]='\0';
    58       return (atoi(number1) < atoi(number2));
    59     }
    60   }
    61 };
    62 
    63 /** Constructor for ConfigFileBuffer class.
    64  */
    65 ConfigFileBuffer::ConfigFileBuffer() : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0)
    66 {
    67 };
    68 
    69 /** Constructor for ConfigFileBuffer class with filename to be parsed.
    70  * \param *filename file name
    71  */
    72 ConfigFileBuffer::ConfigFileBuffer(const char * const filename) : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0)
    73 {
    74   ifstream *file = NULL;
    75   char line[MAXSTRINGSIZE];
    76 
    77   // prescan number of lines
    78   file= new ifstream(filename);
    79   if (file == NULL) {
    80     DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl);
    81     return;
    82   }
    83   NoLines = 0; // we're overcounting by one
    84   long file_position = file->tellg(); // mark current position
    85   do {
    86     file->getline(line, 256);
    87     NoLines++;
    88   } while (!file->eof());
    89   file->clear();
    90   file->seekg(file_position, ios::beg);
    91   DoLog(1) && (Log() << Verbose(1) << NoLines-1 << " lines were recognized." << endl);
    92 
    93   // allocate buffer's 1st dimension
    94   if (buffer != NULL) {
    95     DoeLog(1) && (eLog()<< Verbose(1) << "FileBuffer->buffer is not NULL!" << endl);
    96     return;
    97   } else
    98     buffer = new char *[NoLines];
    99 
    100   // scan each line and put into buffer
    101   int lines=0;
    102   int i;
    103   do {
    104     buffer[lines] = new char[MAXSTRINGSIZE];
    105     file->getline(buffer[lines], MAXSTRINGSIZE-1);
    106     i = strlen(buffer[lines]);
    107     buffer[lines][i] = '\n';
    108     buffer[lines][i+1] = '\0';
    109     lines++;
    110   } while((!file->eof()) && (lines < NoLines));
    111   DoLog(1) && (Log() << Verbose(1) << lines-1 << " lines were read into the buffer." << endl);
    112 
    113   // close and exit
    114   file->close();
    115   file->clear();
    116   delete(file);
    117 }
    118 
    119 /** Destructor for ConfigFileBuffer class.
    120  */
    121 ConfigFileBuffer::~ConfigFileBuffer()
    122 {
    123   for(int i=0;i<NoLines;++i)
    124     delete[](buffer[i]);
    125   delete[](buffer);
    126   delete[](LineMapping);
    127 }
    128 
    129 
    130 /** Create trivial mapping.
    131  */
    132 void ConfigFileBuffer::InitMapping()
    133 {
    134   LineMapping = new int[NoLines];
    135   for (int i=0;i<NoLines;i++)
    136     LineMapping[i] = i;
    137 }
    138 
    139 /** Creates a mapping for the \a *FileBuffer's lines containing the Ion_Type keyword such that they are sorted.
    140  * \a *map on return contains a list of NoAtom entries such that going through the list, yields indices to the
    141  * lines in \a *FileBuffer in a sorted manner of the Ion_Type?_? keywords. We assume that ConfigFileBuffer::CurrentLine
    142  * points to first Ion_Type entry.
    143  * \param *FileBuffer pointer to buffer structure
    144  * \param NoAtoms of subsequent lines to look at
    145  */
    146 void ConfigFileBuffer::MapIonTypesInBuffer(const int NoAtoms)
    147 {
    148   map<const char *, int, IonTypeCompare> IonTypeLineMap;
    149   if (LineMapping == NULL) {
    150     DoeLog(0) && (eLog()<< Verbose(0) << "map pointer is NULL: " << LineMapping << endl);
    151     performCriticalExit();
    152     return;
    153   }
    154 
    155   // put all into hashed map
    156   for (int i=0; i<NoAtoms; ++i) {
    157     IonTypeLineMap.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i));
    158   }
    159 
    160   // fill map
    161   int nr=0;
    162   for (map<const char *, int, IonTypeCompare>::iterator runner = IonTypeLineMap.begin(); runner != IonTypeLineMap.end(); ++runner) {
    163     if (CurrentLine+nr < NoLines)
    164       LineMapping[CurrentLine+(nr++)] = runner->second;
    165     else {
    166       DoeLog(0) && (eLog()<< Verbose(0) << "config::MapIonTypesInBuffer - NoAtoms is wrong: We are past the end of the file!" << endl);
    167       performCriticalExit();
    168     }
    169   }
    170 }
    17128
    17229/************************************* Functions for class config ***************************/
     
    17431/** Constructor for config file class.
    17532 */
    176 config::config() : BG(NULL), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1), configpath(NULL),
    177     configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), Thermostat(4), ThermostatImplemented(NULL),
    178     ThermostatNames(NULL), TempFrequency(2.5), alpha(0.), HooverMass(0.), TargetTemp(0.00095004455), ScaleTempStep(25),  mainname(NULL), defaultpath(NULL), pseudopotpath(NULL),
     33config::config() : BG(NULL), Thermostats(0), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1),
     34    configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), mainname(NULL), defaultpath(NULL), pseudopotpath(NULL),
    17935    DoOutVis(0), DoOutMes(1), DoOutNICS(0), DoOutOrbitals(0), DoOutCurrent(0), DoFullCurrent(0), DoPerturbation(0), DoWannier(0), CommonWannier(0), SawtoothStart(0.01),
    18036    VectorPlane(0), VectorCut(0.), UseAddGramSch(1), Seed(1), OutVisStep(10), OutSrcStep(5), MaxPsiStep(0), EpsWannier(1e-7), MaxMinStep(100), RelEpsTotalEnergy(1e-7),
     
    18642  pseudopotpath = new char[MAXSTRINGSIZE];
    18743  databasepath = new char[MAXSTRINGSIZE];
    188   configpath = new char[MAXSTRINGSIZE];
    18944  configname = new char[MAXSTRINGSIZE];
     45  Thermostats = new ThermoStatContainer();
    19046  strcpy(mainname,"pcp");
    19147  strcpy(defaultpath,"not specified");
    19248  strcpy(pseudopotpath,"not specified");
    193   configpath[0]='\0';
    19449  configname[0]='\0';
    19550  basis = "3-21G";
    196 
    197   InitThermostats();
    19851};
    19952
     
    20659  delete[](pseudopotpath);
    20760  delete[](databasepath);
    208   delete[](configpath);
    20961  delete[](configname);
    210   delete[](ThermostatImplemented);
    211   for (int j=0;j<MaxThermostats;j++)
    212     delete[](ThermostatNames[j]);
    213   delete[](ThermostatNames);
     62  if (Thermostats != NULL)
     63    delete(Thermostats);
    21464
    21565  if (BG != NULL)
    21666    delete(BG);
    21767};
    218 
    219 /** Initialises variables in class config for Thermostats.
    220  */
    221 void config::InitThermostats()
    222 {
    223   ThermostatImplemented = new int[MaxThermostats];
    224   ThermostatNames = new char *[MaxThermostats];
    225   for (int j=0;j<MaxThermostats;j++)
    226     ThermostatNames[j] = new char[12];
    227 
    228   strcpy(ThermostatNames[0],"None");
    229   ThermostatImplemented[0] = 1;
    230   strcpy(ThermostatNames[1],"Woodcock");
    231   ThermostatImplemented[1] = 1;
    232   strcpy(ThermostatNames[2],"Gaussian");
    233   ThermostatImplemented[2] = 1;
    234   strcpy(ThermostatNames[3],"Langevin");
    235   ThermostatImplemented[3] = 1;
    236   strcpy(ThermostatNames[4],"Berendsen");
    237   ThermostatImplemented[4] = 1;
    238   strcpy(ThermostatNames[5],"NoseHoover");
    239   ThermostatImplemented[5] = 1;
    240 };
    241 
    242 /** Readin of Thermostat related values from parameter file.
    243  * \param *fb file buffer containing the config file
    244  */
    245 void config::ParseThermostats(class ConfigFileBuffer * const fb)
    246 {
    247   char * const thermo = new char[12];
    248   const int verbose = 0;
    249 
    250   // read desired Thermostat from file along with needed additional parameters
    251   if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {
    252     if (strcmp(thermo, ThermostatNames[0]) == 0) { // None
    253       if (ThermostatImplemented[0] == 1) {
    254         Thermostat = None;
    255       } else {
    256         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    257         Thermostat = None;
    258       }
    259     } else if (strcmp(thermo, ThermostatNames[1]) == 0) { // Woodcock
    260       if (ThermostatImplemented[1] == 1) {
    261         Thermostat = Woodcock;
    262         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read scaling frequency
    263       } else {
    264         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    265         Thermostat = None;
    266       }
    267     } else if (strcmp(thermo, ThermostatNames[2]) == 0) { // Gaussian
    268       if (ThermostatImplemented[2] == 1) {
    269         Thermostat = Gaussian;
    270         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read collision rate
    271       } else {
    272         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    273         Thermostat = None;
    274       }
    275     } else if (strcmp(thermo, ThermostatNames[3]) == 0) { // Langevin
    276       if (ThermostatImplemented[3] == 1) {
    277         Thermostat = Langevin;
    278         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read gamma
    279         if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &alpha, 1, optional)) {
    280           DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << alpha << "." << endl);
    281         } else {
    282           alpha = 1.;
    283         }
    284       } else {
    285         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    286         Thermostat = None;
    287       }
    288     } else if (strcmp(thermo, ThermostatNames[4]) == 0) { // Berendsen
    289       if (ThermostatImplemented[4] == 1) {
    290         Thermostat = Berendsen;
    291         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read \tau_T
    292       } else {
    293         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    294         Thermostat = None;
    295       }
    296     } else if (strcmp(thermo, ThermostatNames[5]) == 0) { // Nose-Hoover
    297       if (ThermostatImplemented[5] == 1) {
    298         Thermostat = NoseHoover;
    299         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &HooverMass, 1, critical); // read Hoovermass
    300         alpha = 0.;
    301       } else {
    302         DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    303         Thermostat = None;
    304       }
    305     } else {
    306       DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl);
    307       Thermostat = None;
    308     }
    309   } else {
    310     if ((MaxOuterStep > 0) && (TargetTemp != 0))
    311       DoLog(2) && (Log() << Verbose(2) <<  "No thermostat chosen despite finite temperature MD, falling back to None." << endl);
    312     Thermostat = None;
    313   }
    314   delete[](thermo);
    315 };
    316 
    31768
    31869/** Displays menu for editing each entry of the config file.
     
    629380};
    630381
    631 /** Retrieves the path in the given config file name.
    632  * \param filename config file string
    633  */
    634 void config::RetrieveConfigPathAndName(const string filename)
    635 {
    636   char *ptr = NULL;
    637   char *buffer = new char[MAXSTRINGSIZE];
    638   strncpy(buffer, filename.c_str(), MAXSTRINGSIZE);
    639   int last = -1;
    640   for(last=MAXSTRINGSIZE;last--;) {
    641     if (buffer[last] == '/')
    642       break;
    643   }
    644   if (last == -1) { // no path in front, set to local directory.
    645     strcpy(configpath, "./");
    646     ptr = buffer;
    647   } else {
    648     strncpy(configpath, buffer, last+1);
    649     ptr = &buffer[last+1];
    650     if (last < 254)
    651       configpath[last+1]='\0';
    652   }
    653   strcpy(configname, ptr);
    654   DoLog(0) && (Log() << Verbose(0) << "Found configpath: " << configpath << ", dir slash was found at " << last << ", config name is " << configname << "." << endl);
    655   delete[](buffer);
    656 };
    657 
    658 /** Initializes ConfigFileBuffer from a file.
    659  * \param *file input file stream being the opened config file
    660  * \param *FileBuffer pointer to FileBuffer on return, should point to NULL
    661  */
    662 void PrepareFileBuffer(const char * const filename, struct ConfigFileBuffer *&FileBuffer)
    663 {
    664   if (FileBuffer != NULL) {
    665     DoeLog(2) && (eLog()<< Verbose(2) << "deleting present FileBuffer in PrepareFileBuffer()." << endl);
    666     delete(FileBuffer);
    667   }
    668   FileBuffer = new ConfigFileBuffer(filename);
    669 
    670   FileBuffer->InitMapping();
    671 };
    672 
    673382/** Loads a molecule from a ConfigFileBuffer.
    674383 * \param *mol molecule to load
     
    864573  file->close();
    865574  delete(file);
    866   RetrieveConfigPathAndName(filename);
    867575
    868576  // ParseParameterFile
    869   struct ConfigFileBuffer *FileBuffer = NULL;
    870   PrepareFileBuffer(filename,FileBuffer);
     577  class ConfigFileBuffer *FileBuffer = new ConfigFileBuffer(filename);
    871578
    872579  /* Oeffne Hauptparameterdatei */
     
    877584  int verbose = 0;
    878585 
     586  //TODO: This is actually sensible?: if (MaxOuterStep > 0)
    879587  ParseThermostats(FileBuffer);
    880588 
     
    941649  ParseForParameter(verbose,FileBuffer,"OutVisStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional);
    942650  ParseForParameter(verbose,FileBuffer,"OutSrcStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional);
    943   ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &(config::TargetTemp), 1, optional);
     651  ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &(Thermostats->TargetTemp), 1, optional);
    944652  //ParseForParameter(verbose,FileBuffer,"Thermostat", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional);
    945653  if (!ParseForParameter(verbose,FileBuffer,"EpsWannier", 0, 1, 1, double_type, &(config::EpsWannier), 1, optional))
     
    1101809    return;
    1102810  }
    1103   RetrieveConfigPathAndName(filename);
    1104811  // ParseParameters
    1105812
     
    1150857  ParseForParameter(verbose,file,"VisOuterStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional);
    1151858  ParseForParameter(verbose,file,"VisSrcOuterStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional);
    1152   ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &(config::TargetTemp), 1, optional);
    1153   ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional);
     859  ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &(Thermostats->TargetTemp), 1, optional);
     860  ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &(Thermostats->ScaleTempStep), 1, optional);
    1154861  config::EpsWannier = 1e-8;
    1155862
     
    13391046    *output << "DoFullCurrent\t" << config::DoFullCurrent << "\t# Do full perturbation" << endl;
    13401047    *output << "DoConstrainedMD\t" << config::DoConstrainedMD << "\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD" << endl;
    1341     *output << "Thermostat\t" << ThermostatNames[Thermostat] << "\t";
    1342     switch(Thermostat) {
     1048    *output << "Thermostat\t" << Thermostats->ThermostatNames[Thermostats->Thermostat] << "\t";
     1049    switch(Thermostats->Thermostat) {
    13431050      default:
    13441051      case None:
    13451052        break;
    13461053      case Woodcock:
    1347         *output << ScaleTempStep;
     1054        *output << Thermostats->ScaleTempStep;
    13481055        break;
    13491056      case Gaussian:
    1350         *output << ScaleTempStep;
     1057        *output << Thermostats->ScaleTempStep;
    13511058        break;
    13521059      case Langevin:
    1353         *output << TempFrequency << "\t" << alpha;
     1060        *output << Thermostats->TempFrequency << "\t" << Thermostats->alpha;
    13541061        break;
    13551062      case Berendsen:
    1356         *output << TempFrequency;
     1063        *output << Thermostats->TempFrequency;
    13571064        break;
    13581065      case NoseHoover:
    1359         *output << HooverMass;
     1066        *output << Thermostats->HooverMass;
    13601067        break;
    13611068    };
     
    13721079    *output << "OutVisStep\t" << config::OutVisStep << "\t# Output visual data every ...th step" << endl;
    13731080    *output << "OutSrcStep\t" << config::OutSrcStep << "\t# Output \"restart\" data every ..th step" << endl;
    1374     *output << "TargetTemp\t" << config::TargetTemp << "\t# Target temperature" << endl;
     1081    *output << "TargetTemp\t" << Thermostats->TargetTemp << "\t# Target temperature" << endl;
    13751082    *output << "MaxPsiStep\t" << config::MaxPsiStep << "\t# number of Minimisation steps per state (0 - default)" << endl;
    13761083    *output << "EpsWannier\t" << config::EpsWannier << "\t# tolerance value for spread minimisation of orbitals" << endl;
     
    14831190    // output of atoms
    14841191    AtomNo = 0;
    1485     mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );
     1192    mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo );
    14861193    delete(center);
    14871194    *output << "\t}" << endl;
     
    15251232    // output of atoms
    15261233    AtomNo = 0;
    1527     mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo );
     1234    mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const) output, (const Vector *)center, &AtomNo );
    15281235    delete(center);
    15291236    *output << "\t}" << endl;
     
    17861493  molecule *mol = NULL;
    17871494
    1788   if (!strcmp(configpath, GetDefaultPath())) {
    1789     eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
    1790   }
    1791 
    1792 
    17931495  // first save as PDB data
    17941496  if (ConfigFileName != NULL)
     
    18271529    mol->doCountAtoms();
    18281530    mol->CountElements();
    1829     mol->CalculateOrbitals(*this);
     1531    //mol->CalculateOrbitals(*this);
    18301532    delete[](src);
    18311533  } else {
     
    18331535      mol = *(molecules->ListOfMolecules.begin());
    18341536      mol->doCountAtoms();
    1835       mol->CalculateOrbitals(*this);
     1537      //mol->CalculateOrbitals(*this);
    18361538    } else {
    18371539      DoeLog(1) && (eLog() << Verbose(1) << "There are no molecules to save!" << endl);
     
    18951597  else
    18961598    Log() << Verbose(0) << "\t... failed." << endl;
    1897 
    1898   if (!strcmp(configpath, GetDefaultPath())) {
    1899     eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
    1900   }
    19011599
    19021600  // don't destroy molecule as it contains all our atoms
     
    23462044  return (found); // true if found, false if not
    23472045}
     2046
     2047/** Reading of Thermostat related values from parameter file.
     2048 * \param *fb file buffer containing the config file
     2049 */
     2050void config::ParseThermostats(class ConfigFileBuffer * const fb)
     2051{
     2052  char * const thermo = new char[12];
     2053  const int verbose = 0;
     2054
     2055  // read desired Thermostat from file along with needed additional parameters
     2056  if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {
     2057    if (strcmp(thermo, Thermostats->ThermostatNames[0]) == 0) { // None
     2058      if (Thermostats->ThermostatImplemented[0] == 1) {
     2059        Thermostats->Thermostat = None;
     2060      } else {
     2061        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
     2062        Thermostats->Thermostat = None;
     2063      }
     2064    } else if (strcmp(thermo, Thermostats->ThermostatNames[1]) == 0) { // Woodcock
     2065      if (Thermostats->ThermostatImplemented[1] == 1) {
     2066        Thermostats->Thermostat = Woodcock;
     2067        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read scaling frequency
     2068      } else {
     2069        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
     2070        Thermostats->Thermostat = None;
     2071      }
     2072    } else if (strcmp(thermo, Thermostats->ThermostatNames[2]) == 0) { // Gaussian
     2073      if (Thermostats->ThermostatImplemented[2] == 1) {
     2074        Thermostats->Thermostat = Gaussian;
     2075        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read collision rate
     2076      } else {
     2077        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
     2078        Thermostats->Thermostat = None;
     2079      }
     2080    } else if (strcmp(thermo, Thermostats->ThermostatNames[3]) == 0) { // Langevin
     2081      if (Thermostats->ThermostatImplemented[3] == 1) {
     2082        Thermostats->Thermostat = Langevin;
     2083        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read gamma
     2084        if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &Thermostats->alpha, 1, optional)) {
     2085          DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << Thermostats->alpha << "." << endl);
     2086        } else {
     2087          Thermostats->alpha = 1.;
     2088        }
     2089      } else {
     2090        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
     2091        Thermostats->Thermostat = None;
     2092      }
     2093    } else if (strcmp(thermo, Thermostats->ThermostatNames[4]) == 0) { // Berendsen
     2094      if (Thermostats->ThermostatImplemented[4] == 1) {
     2095        Thermostats->Thermostat = Berendsen;
     2096        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read \tau_T
     2097      } else {
     2098        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
     2099        Thermostats->Thermostat = None;
     2100      }
     2101    } else if (strcmp(thermo, Thermostats->ThermostatNames[5]) == 0) { // Nose-Hoover
     2102      if (Thermostats->ThermostatImplemented[5] == 1) {
     2103        Thermostats->Thermostat = NoseHoover;
     2104        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->HooverMass, 1, critical); // read Hoovermass
     2105        Thermostats->alpha = 0.;
     2106      } else {
     2107        DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
     2108        Thermostats->Thermostat = None;
     2109      }
     2110    } else {
     2111      DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl);
     2112      Thermostats->Thermostat = None;
     2113    }
     2114  } else {
     2115    if ((Thermostats->TargetTemp != 0))
     2116      DoLog(2) && (Log() << Verbose(2) <<  "No thermostat chosen despite finite temperature MD, falling back to None." << endl);
     2117    Thermostats->Thermostat = None;
     2118  }
     2119  delete[](thermo);
     2120};
     2121
Note: See TracChangeset for help on using the changeset viewer.