Ignore:
Timestamp:
Sep 25, 2008, 5:57:19 PM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
68cfd1
Parents:
c49678
Message:

thermostats enumerator, necessary variables included in class config, molecule::Thermostats() and ..::Constrained
Potential()

Thermostat header definitions implemented. Can be parsed from the ESPACK config file into class config
ConstrainedPotential() calculates the transformation between two given configurations my minimsing a penalty func
tional of the distance to travel per atom. This was implemented due to Michael Griebel's talk during the MultiMat

Closing meeting in order to produce some visuals. It basically mimics a "Bain Transformation". But it is not yet
perfectly implemented.

Also, MD was corrected in VerletIntegration(). However, forces are still wrong with mpqc, as the kinetic energy increases dramatically during the MD simulation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/config.cpp

    rc49678 r556157  
    1818  configpath = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: mainname");
    1919  configname = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: mainname");
     20  ThermostatImplemented = (int *) Malloc((MaxThermostats)*(sizeof(int)), "IonsInitRead: *ThermostatImplemented");
     21  ThermostatNames = (char **) Malloc((MaxThermostats)*(sizeof(char *)), "IonsInitRead: *ThermostatNames");
     22  for (int j=0;j<MaxThermostats;j++)
     23    ThermostatNames[j] = (char *) MallocString(12*(sizeof(char)), "IonsInitRead: ThermostatNames[]");
     24  Thermostat = 4;
     25  alpha = 0.;
     26  ScaleTempStep = 25;
     27  TempFrequency = 2.5;
    2028  strcpy(mainname,"pcp");
    2129  strcpy(defaultpath,"not specified");
     
    2331  configpath[0]='\0';
    2432  configname[0]='\0';
    25  
     33
     34  strcpy(ThermostatNames[0],"None");
     35  ThermostatImplemented[0] = 1;
     36  strcpy(ThermostatNames[1],"Woodcock");
     37  ThermostatImplemented[1] = 1;
     38  strcpy(ThermostatNames[2],"Gaussian");
     39  ThermostatImplemented[2] = 1;
     40  strcpy(ThermostatNames[3],"Langevin");
     41  ThermostatImplemented[3] = 1;
     42  strcpy(ThermostatNames[4],"Berendsen");
     43  ThermostatImplemented[4] = 1;
     44  strcpy(ThermostatNames[5],"NoseHoover");
     45  ThermostatImplemented[5] = 1;
     46
    2647  FastParsing = false;
    2748  ProcPEGamma=8;
     
    96117  Free((void **)&configname, "config::~config: *configname");
    97118};
     119
     120/** Readin of Thermostat related values from parameter file.
     121 * \param *source parameter file
     122 */
     123void config::InitThermostats(ifstream *source)
     124{
     125  char *thermo = MallocString(12, "IonsInitRead: thermo");
     126  int verbose = 0;
     127
     128  // read desired Thermostat from file along with needed additional parameters
     129  if (ParseForParameter(verbose,source,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {
     130    if (strcmp(thermo, ThermostatNames[0]) == 0) { // None
     131      if (ThermostatImplemented[0] == 1) {
     132        Thermostat = None;
     133      } else {
     134        cout << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;
     135        Thermostat = None;
     136      }
     137    } else if (strcmp(thermo, ThermostatNames[1]) == 0) { // Woodcock
     138      if (ThermostatImplemented[1] == 1) {
     139        Thermostat = Woodcock;
     140        ParseForParameter(verbose,source,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read scaling frequency
     141      } else {
     142        cout << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;
     143        Thermostat = None;
     144      }
     145    } else if (strcmp(thermo, ThermostatNames[2]) == 0) { // Gaussian
     146      if (ThermostatImplemented[2] == 1) {
     147        Thermostat = Gaussian;
     148        ParseForParameter(verbose,source,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read collision rate
     149      } else {
     150        cout << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;
     151        Thermostat = None;
     152      }
     153    } else if (strcmp(thermo, ThermostatNames[3]) == 0) { // Langevin
     154      if (ThermostatImplemented[3] == 1) {
     155        Thermostat = Langevin;
     156        ParseForParameter(verbose,source,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read gamma
     157        if (ParseForParameter(verbose,source,"Thermostat", 0, 3, 1, double_type, &alpha, 1, optional)) {
     158          cout << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << alpha << "." << endl;
     159        } else {
     160          alpha = 1.;
     161        }
     162      } else {
     163        cout << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;
     164        Thermostat = None;
     165      }
     166    } else if (strcmp(thermo, ThermostatNames[4]) == 0) { // Berendsen
     167      if (ThermostatImplemented[4] == 1) {
     168        Thermostat = Berendsen;
     169        ParseForParameter(verbose,source,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read \tau_T
     170      } else {
     171        cout << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;
     172        Thermostat = None;
     173      }
     174    } else if (strcmp(thermo, ThermostatNames[5]) == 0) { // Nose-Hoover
     175      if (ThermostatImplemented[5] == 1) {
     176        Thermostat = NoseHoover;
     177        ParseForParameter(verbose,source,"Thermostat", 0, 2, 1, double_type, &HooverMass, 1, critical); // read Hoovermass
     178        alpha = 0.;
     179      } else {
     180        cout << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;
     181        Thermostat = None;
     182      }
     183    } else {
     184      cout << Verbose(1) << " Warning: thermostat name was not understood!" << endl;
     185      Thermostat = None;
     186    }
     187  } else {
     188    if ((MaxOuterStep > 0) && (TargetTemp != 0))
     189      cout << Verbose(2) <<  "No thermostat chosen despite finite temperature MD, falling back to None." << endl;
     190    Thermostat = None;
     191  }
     192  Free((void **)&thermo, "InitThermostats: thermo");
     193};
     194
    98195
    99196/** Displays menu for editing each entry of the config file.
     
    465562  double value[3];
    466563 
     564  InitThermostats(file);
     565 
    467566  /* Namen einlesen */
    468567
     
    10011100    *output << "DoFullCurrent\t" << config::DoFullCurrent << "\t# Do full perturbation" << endl;
    10021101    *output << "DoConstrainedMD\t" << config::DoConstrainedMD << "\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD" << endl;
     1102    *output << "Thermostat\t" << ThermostatNames[Thermostat] << "\t";
     1103    switch(Thermostat) {
     1104      default:
     1105      case None:
     1106        break;
     1107      case Woodcock:
     1108        *output << ScaleTempStep;
     1109        break;
     1110      case Gaussian:
     1111        *output << ScaleTempStep;
     1112        break;
     1113      case Langevin:
     1114        *output << TempFrequency << "\t" << alpha;
     1115        break;
     1116      case Berendsen:
     1117        *output << TempFrequency;
     1118        break;
     1119      case NoseHoover:
     1120        *output << HooverMass;
     1121        break;
     1122    };
     1123    *output << "\t# Which Thermostat and its parameters to use in MD case." << endl;
    10031124    *output << "CommonWannier\t" << config::CommonWannier << "\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center" << endl;
    10041125    *output << "SawtoothStart\t" << config::SawtoothStart << "\t# Absolute value for smooth transition at cell border " << endl;
Note: See TracChangeset for help on using the changeset viewer.