Changeset 556157 for molecuilder/src/config.cpp
- Timestamp:
- Sep 25, 2008, 5:57:19 PM (17 years ago)
- Children:
- 68cfd1
- Parents:
- c49678
- File:
-
- 1 edited
-
molecuilder/src/config.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/config.cpp
rc49678 r556157 18 18 configpath = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: mainname"); 19 19 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; 20 28 strcpy(mainname,"pcp"); 21 29 strcpy(defaultpath,"not specified"); … … 23 31 configpath[0]='\0'; 24 32 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 26 47 FastParsing = false; 27 48 ProcPEGamma=8; … … 96 117 Free((void **)&configname, "config::~config: *configname"); 97 118 }; 119 120 /** Readin of Thermostat related values from parameter file. 121 * \param *source parameter file 122 */ 123 void 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 98 195 99 196 /** Displays menu for editing each entry of the config file. … … 465 562 double value[3]; 466 563 564 InitThermostats(file); 565 467 566 /* Namen einlesen */ 468 567 … … 1001 1100 *output << "DoFullCurrent\t" << config::DoFullCurrent << "\t# Do full perturbation" << endl; 1002 1101 *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; 1003 1124 *output << "CommonWannier\t" << config::CommonWannier << "\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center" << endl; 1004 1125 *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.
