| [14de469] | 1 | /** \file config.cpp | 
|---|
|  | 2 | * | 
|---|
|  | 3 | * Function implementations for the class config. | 
|---|
|  | 4 | * | 
|---|
|  | 5 | */ | 
|---|
|  | 6 |  | 
|---|
|  | 7 | #include "molecules.hpp" | 
|---|
|  | 8 |  | 
|---|
|  | 9 | /************************************* Functions for class config ***************************/ | 
|---|
|  | 10 |  | 
|---|
|  | 11 | /** Constructor for config file class. | 
|---|
|  | 12 | */ | 
|---|
|  | 13 | config::config() | 
|---|
|  | 14 | { | 
|---|
| [c750cc] | 15 | mainname = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: mainname"); | 
|---|
|  | 16 | defaultpath = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: mainname"); | 
|---|
|  | 17 | pseudopotpath = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: mainname"); | 
|---|
|  | 18 | configpath = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: mainname"); | 
|---|
|  | 19 | configname = (char *) MallocString(sizeof(char)*MAXSTRINGSIZE,"config constructor: mainname"); | 
|---|
| [62f793] | 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; | 
|---|
| [14de469] | 28 | strcpy(mainname,"pcp"); | 
|---|
| [5b15ab] | 29 | strcpy(defaultpath,"not specified"); | 
|---|
|  | 30 | strcpy(pseudopotpath,"not specified"); | 
|---|
| [04980c] | 31 | configpath[0]='\0'; | 
|---|
|  | 32 | configname[0]='\0'; | 
|---|
| [2746be] | 33 | basis="3-21G"; | 
|---|
| [14de469] | 34 |  | 
|---|
| [62f793] | 35 |  | 
|---|
|  | 36 | strcpy(ThermostatNames[0],"None"); | 
|---|
|  | 37 | ThermostatImplemented[0] = 1; | 
|---|
|  | 38 | strcpy(ThermostatNames[1],"Woodcock"); | 
|---|
|  | 39 | ThermostatImplemented[1] = 1; | 
|---|
|  | 40 | strcpy(ThermostatNames[2],"Gaussian"); | 
|---|
|  | 41 | ThermostatImplemented[2] = 1; | 
|---|
|  | 42 | strcpy(ThermostatNames[3],"Langevin"); | 
|---|
|  | 43 | ThermostatImplemented[3] = 1; | 
|---|
|  | 44 | strcpy(ThermostatNames[4],"Berendsen"); | 
|---|
|  | 45 | ThermostatImplemented[4] = 1; | 
|---|
|  | 46 | strcpy(ThermostatNames[5],"NoseHoover"); | 
|---|
|  | 47 | ThermostatImplemented[5] = 1; | 
|---|
|  | 48 |  | 
|---|
| [62c16c] | 49 | FastParsing = false; | 
|---|
| [14de469] | 50 | ProcPEGamma=8; | 
|---|
|  | 51 | ProcPEPsi=1; | 
|---|
|  | 52 | DoOutVis=0; | 
|---|
|  | 53 | DoOutMes=1; | 
|---|
|  | 54 | DoOutNICS=0; | 
|---|
|  | 55 | DoOutOrbitals=0; | 
|---|
|  | 56 | DoOutCurrent=0; | 
|---|
|  | 57 | DoPerturbation=0; | 
|---|
|  | 58 | DoFullCurrent=0; | 
|---|
| [18913c] | 59 | DoWannier=0; | 
|---|
| [6e9353] | 60 | DoConstrainedMD=0; | 
|---|
| [14de469] | 61 | CommonWannier=0; | 
|---|
|  | 62 | SawtoothStart=0.01; | 
|---|
|  | 63 | VectorPlane=0; | 
|---|
|  | 64 | VectorCut=0; | 
|---|
|  | 65 | UseAddGramSch=1; | 
|---|
|  | 66 | Seed=1; | 
|---|
|  | 67 | MaxOuterStep=0; | 
|---|
| [aa5702] | 68 | Deltat=0.01; | 
|---|
| [14de469] | 69 | OutVisStep=10; | 
|---|
|  | 70 | OutSrcStep=5; | 
|---|
|  | 71 | TargetTemp=0.00095004455; | 
|---|
|  | 72 | ScaleTempStep=25; | 
|---|
|  | 73 | MaxPsiStep=0; | 
|---|
|  | 74 | EpsWannier=1e-7; | 
|---|
|  | 75 |  | 
|---|
|  | 76 | MaxMinStep=100; | 
|---|
|  | 77 | RelEpsTotalEnergy=1e-7; | 
|---|
|  | 78 | RelEpsKineticEnergy=1e-5; | 
|---|
|  | 79 | MaxMinStopStep=1; | 
|---|
|  | 80 | MaxMinGapStopStep=0; | 
|---|
|  | 81 | MaxInitMinStep=100; | 
|---|
|  | 82 | InitRelEpsTotalEnergy=1e-5; | 
|---|
|  | 83 | InitRelEpsKineticEnergy=1e-4; | 
|---|
|  | 84 | InitMaxMinStopStep=1; | 
|---|
|  | 85 | InitMaxMinGapStopStep=0; | 
|---|
|  | 86 |  | 
|---|
|  | 87 | //BoxLength[NDIM*NDIM]; | 
|---|
|  | 88 |  | 
|---|
|  | 89 | ECut=128.; | 
|---|
|  | 90 | MaxLevel=5; | 
|---|
|  | 91 | RiemannTensor=0; | 
|---|
|  | 92 | LevRFactor=0; | 
|---|
|  | 93 | RiemannLevel=0; | 
|---|
|  | 94 | Lev0Factor=2; | 
|---|
|  | 95 | RTActualUse=0; | 
|---|
|  | 96 | PsiType=0; | 
|---|
|  | 97 | MaxPsiDouble=0; | 
|---|
|  | 98 | PsiMaxNoUp=0; | 
|---|
|  | 99 | PsiMaxNoDown=0; | 
|---|
|  | 100 | AddPsis=0; | 
|---|
|  | 101 |  | 
|---|
|  | 102 | RCut=20.; | 
|---|
|  | 103 | StructOpt=0; | 
|---|
|  | 104 | IsAngstroem=1; | 
|---|
|  | 105 | RelativeCoord=0; | 
|---|
|  | 106 | MaxTypes=0; | 
|---|
|  | 107 | }; | 
|---|
|  | 108 |  | 
|---|
|  | 109 |  | 
|---|
|  | 110 | /** Destructor for config file class. | 
|---|
|  | 111 | */ | 
|---|
|  | 112 | config::~config() | 
|---|
|  | 113 | { | 
|---|
|  | 114 | Free((void **)&mainname, "config::~config: *mainname"); | 
|---|
|  | 115 | Free((void **)&defaultpath, "config::~config: *defaultpath"); | 
|---|
|  | 116 | Free((void **)&pseudopotpath, "config::~config: *pseudopotpath"); | 
|---|
| [5b15ab] | 117 | Free((void **)&configpath, "config::~config: *configpath"); | 
|---|
| [b5ecd9] | 118 | Free((void **)&configname, "config::~config: *configname"); | 
|---|
| [14de469] | 119 | }; | 
|---|
|  | 120 |  | 
|---|
| [62f793] | 121 | /** Readin of Thermostat related values from parameter file. | 
|---|
|  | 122 | * \param *source parameter file | 
|---|
|  | 123 | */ | 
|---|
|  | 124 | void config::InitThermostats(ifstream *source) | 
|---|
|  | 125 | { | 
|---|
|  | 126 | char *thermo = MallocString(12, "IonsInitRead: thermo"); | 
|---|
|  | 127 | int verbose = 0; | 
|---|
|  | 128 |  | 
|---|
|  | 129 | // read desired Thermostat from file along with needed additional parameters | 
|---|
|  | 130 | if (ParseForParameter(verbose,source,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) { | 
|---|
|  | 131 | if (strcmp(thermo, ThermostatNames[0]) == 0) { // None | 
|---|
|  | 132 | if (ThermostatImplemented[0] == 1) { | 
|---|
|  | 133 | Thermostat = None; | 
|---|
|  | 134 | } else { | 
|---|
|  | 135 | cout << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl; | 
|---|
|  | 136 | Thermostat = None; | 
|---|
|  | 137 | } | 
|---|
|  | 138 | } else if (strcmp(thermo, ThermostatNames[1]) == 0) { // Woodcock | 
|---|
|  | 139 | if (ThermostatImplemented[1] == 1) { | 
|---|
|  | 140 | Thermostat = Woodcock; | 
|---|
|  | 141 | ParseForParameter(verbose,source,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read scaling frequency | 
|---|
|  | 142 | } else { | 
|---|
|  | 143 | cout << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl; | 
|---|
|  | 144 | Thermostat = None; | 
|---|
|  | 145 | } | 
|---|
|  | 146 | } else if (strcmp(thermo, ThermostatNames[2]) == 0) { // Gaussian | 
|---|
|  | 147 | if (ThermostatImplemented[2] == 1) { | 
|---|
|  | 148 | Thermostat = Gaussian; | 
|---|
|  | 149 | ParseForParameter(verbose,source,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read collision rate | 
|---|
|  | 150 | } else { | 
|---|
|  | 151 | cout << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl; | 
|---|
|  | 152 | Thermostat = None; | 
|---|
|  | 153 | } | 
|---|
|  | 154 | } else if (strcmp(thermo, ThermostatNames[3]) == 0) { // Langevin | 
|---|
|  | 155 | if (ThermostatImplemented[3] == 1) { | 
|---|
|  | 156 | Thermostat = Langevin; | 
|---|
|  | 157 | ParseForParameter(verbose,source,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read gamma | 
|---|
|  | 158 | if (ParseForParameter(verbose,source,"Thermostat", 0, 3, 1, double_type, &alpha, 1, optional)) { | 
|---|
|  | 159 | cout << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << alpha << "." << endl; | 
|---|
|  | 160 | } else { | 
|---|
|  | 161 | alpha = 1.; | 
|---|
|  | 162 | } | 
|---|
|  | 163 | } else { | 
|---|
|  | 164 | cout << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl; | 
|---|
|  | 165 | Thermostat = None; | 
|---|
|  | 166 | } | 
|---|
|  | 167 | } else if (strcmp(thermo, ThermostatNames[4]) == 0) { // Berendsen | 
|---|
|  | 168 | if (ThermostatImplemented[4] == 1) { | 
|---|
|  | 169 | Thermostat = Berendsen; | 
|---|
|  | 170 | ParseForParameter(verbose,source,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read \tau_T | 
|---|
|  | 171 | } else { | 
|---|
|  | 172 | cout << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl; | 
|---|
|  | 173 | Thermostat = None; | 
|---|
|  | 174 | } | 
|---|
|  | 175 | } else if (strcmp(thermo, ThermostatNames[5]) == 0) { // Nose-Hoover | 
|---|
|  | 176 | if (ThermostatImplemented[5] == 1) { | 
|---|
|  | 177 | Thermostat = NoseHoover; | 
|---|
|  | 178 | ParseForParameter(verbose,source,"Thermostat", 0, 2, 1, double_type, &HooverMass, 1, critical); // read Hoovermass | 
|---|
|  | 179 | alpha = 0.; | 
|---|
|  | 180 | } else { | 
|---|
|  | 181 | cout << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl; | 
|---|
|  | 182 | Thermostat = None; | 
|---|
|  | 183 | } | 
|---|
|  | 184 | } else { | 
|---|
|  | 185 | cout << Verbose(1) << " Warning: thermostat name was not understood!" << endl; | 
|---|
|  | 186 | Thermostat = None; | 
|---|
|  | 187 | } | 
|---|
|  | 188 | } else { | 
|---|
|  | 189 | if ((MaxOuterStep > 0) && (TargetTemp != 0)) | 
|---|
|  | 190 | cout << Verbose(2) <<  "No thermostat chosen despite finite temperature MD, falling back to None." << endl; | 
|---|
|  | 191 | Thermostat = None; | 
|---|
|  | 192 | } | 
|---|
|  | 193 | Free((void **)&thermo, "InitThermostats: thermo"); | 
|---|
|  | 194 | }; | 
|---|
|  | 195 |  | 
|---|
|  | 196 |  | 
|---|
| [14de469] | 197 | /** Displays menu for editing each entry of the config file. | 
|---|
|  | 198 | * Nothing fancy here, just lots of cout << Verbose(0)s for the menu and a switch/case | 
|---|
|  | 199 | * for each entry of the config file structure. | 
|---|
|  | 200 | */ | 
|---|
|  | 201 | void config::Edit(molecule *mol) | 
|---|
|  | 202 | { | 
|---|
|  | 203 | char choice; | 
|---|
|  | 204 |  | 
|---|
|  | 205 | do { | 
|---|
|  | 206 | cout << Verbose(0) << "===========EDIT CONFIGURATION============================" << endl; | 
|---|
|  | 207 | cout << Verbose(0) << " A - mainname (prefix for all runtime files)" << endl; | 
|---|
|  | 208 | cout << Verbose(0) << " B - Default path (for runtime files)" << endl; | 
|---|
|  | 209 | cout << Verbose(0) << " C - Path of pseudopotential files" << endl; | 
|---|
|  | 210 | cout << Verbose(0) << " D - Number of coefficient sharing processes" << endl; | 
|---|
|  | 211 | cout << Verbose(0) << " E - Number of wave function sharing processes" << endl; | 
|---|
|  | 212 | cout << Verbose(0) << " F - 0: Don't output density for OpenDX, 1: do" << endl; | 
|---|
|  | 213 | cout << Verbose(0) << " G - 0: Don't output physical data, 1: do" << endl; | 
|---|
|  | 214 | cout << Verbose(0) << " H - 0: Don't output densities of each unperturbed orbital for OpenDX, 1: do" << endl; | 
|---|
|  | 215 | cout << Verbose(0) << " I - 0: Don't output current density for OpenDX, 1: do" << endl; | 
|---|
|  | 216 | cout << Verbose(0) << " J - 0: Don't do the full current calculation, 1: do" << endl; | 
|---|
|  | 217 | cout << Verbose(0) << " K - 0: Don't do perturbation calculation to obtain susceptibility and shielding, 1: do" << endl; | 
|---|
|  | 218 | cout << Verbose(0) << " L - 0: Wannier centres as calculated, 1: common centre for all, 2: unite centres according to spread, 3: cell centre, 4: shifted to nearest grid point" << endl; | 
|---|
|  | 219 | cout << Verbose(0) << " M - Absolute begin of unphysical sawtooth transfer for position operator within cell" << endl; | 
|---|
|  | 220 | cout << Verbose(0) << " N - (0,1,2) x,y,z-plane to do two-dimensional current vector cut" << endl; | 
|---|
|  | 221 | cout << Verbose(0) << " O - Absolute position along vector cut axis for cut plane" << endl; | 
|---|
|  | 222 | cout << Verbose(0) << " P - Additional Gram-Schmidt-Orthonormalization to stabilize numerics" << endl; | 
|---|
|  | 223 | cout << Verbose(0) << " Q - Initial integer value of random number generator" << endl; | 
|---|
|  | 224 | cout << Verbose(0) << " R - for perturbation 0, for structure optimization defines upper limit of iterations" << endl; | 
|---|
|  | 225 | cout << Verbose(0) << " T - Output visual after ...th step" << endl; | 
|---|
|  | 226 | cout << Verbose(0) << " U - Output source densities of wave functions after ...th step" << endl; | 
|---|
|  | 227 | cout << Verbose(0) << " X - minimization iterations per wave function, if unsure leave at default value 0" << endl; | 
|---|
|  | 228 | cout << Verbose(0) << " Y - tolerance value for total spread in iterative Jacobi diagonalization" << endl; | 
|---|
|  | 229 | cout << Verbose(0) << " Z - Maximum number of minimization iterations" << endl; | 
|---|
|  | 230 | cout << Verbose(0) << " a - Relative change in total energy to stop min. iteration" << endl; | 
|---|
|  | 231 | cout << Verbose(0) << " b - Relative change in kinetic energy to stop min. iteration" << endl; | 
|---|
|  | 232 | cout << Verbose(0) << " c - Check stop conditions every ..th step during min. iteration" << endl; | 
|---|
|  | 233 | cout << Verbose(0) << " e - Maximum number of minimization iterations during initial level" << endl; | 
|---|
|  | 234 | cout << Verbose(0) << " f - Relative change in total energy to stop min. iteration during initial level" << endl; | 
|---|
|  | 235 | cout << Verbose(0) << " g - Relative change in kinetic energy to stop min. iteration during initial level" << endl; | 
|---|
|  | 236 | cout << Verbose(0) << " h - Check stop conditions every ..th step during min. iteration during initial level" << endl; | 
|---|
|  | 237 | cout << Verbose(0) << " j - six lower diagonal entries of matrix, defining the unit cell" << endl; | 
|---|
|  | 238 | cout << Verbose(0) << " k - Energy cutoff of plane wave basis in Hartree" << endl; | 
|---|
|  | 239 | cout << Verbose(0) << " l - Maximum number of levels in multi-level-ansatz" << endl; | 
|---|
|  | 240 | cout << Verbose(0) << " m - Factor by which grid nodes increase between standard and upper level" << endl; | 
|---|
|  | 241 | cout << Verbose(0) << " n - 0: Don't use RiemannTensor, 1: Do" << endl; | 
|---|
|  | 242 | cout << Verbose(0) << " o - Factor by which grid nodes increase between Riemann and standard(?) level" << endl; | 
|---|
|  | 243 | cout << Verbose(0) << " p - Number of Riemann levels" << endl; | 
|---|
|  | 244 | cout << Verbose(0) << " r - 0: Don't Use RiemannTensor, 1: Do" << endl; | 
|---|
|  | 245 | cout << Verbose(0) << " s - 0: Doubly occupied orbitals, 1: Up-/Down-Orbitals" << endl; | 
|---|
|  | 246 | cout << Verbose(0) << " t - Number of orbitals (depends pn SpinType)" << endl; | 
|---|
|  | 247 | cout << Verbose(0) << " u - Number of SpinUp orbitals (depends on SpinType)" << endl; | 
|---|
|  | 248 | cout << Verbose(0) << " v - Number of SpinDown orbitals (depends on SpinType)" << endl; | 
|---|
|  | 249 | cout << Verbose(0) << " w - Number of additional, unoccupied orbitals" << endl; | 
|---|
|  | 250 | cout << Verbose(0) << " x - radial cutoff for ewald summation in Bohrradii" << endl; | 
|---|
|  | 251 | cout << Verbose(0) << " y - 0: Don't do structure optimization beforehand, 1: Do" << endl; | 
|---|
|  | 252 | cout << Verbose(0) << " z - 0: Units are in Bohr radii, 1: units are in Aengstrom" << endl; | 
|---|
|  | 253 | cout << Verbose(0) << " i - 0: Coordinates given in file are absolute, 1: ... are relative to unit cell" << endl; | 
|---|
|  | 254 | cout << Verbose(0) << "=========================================================" << endl; | 
|---|
|  | 255 | cout << Verbose(0) << "INPUT: "; | 
|---|
|  | 256 | cin >> choice; | 
|---|
|  | 257 |  | 
|---|
|  | 258 | switch (choice) { | 
|---|
|  | 259 | case 'A': // mainname | 
|---|
|  | 260 | cout << Verbose(0) << "Old: " << config::mainname << "\t new: "; | 
|---|
|  | 261 | cin >> config::mainname; | 
|---|
|  | 262 | break; | 
|---|
|  | 263 | case 'B': // defaultpath | 
|---|
|  | 264 | cout << Verbose(0) << "Old: " << config::defaultpath << "\t new: "; | 
|---|
|  | 265 | cin >> config::defaultpath; | 
|---|
|  | 266 | break; | 
|---|
|  | 267 | case 'C': // pseudopotpath | 
|---|
|  | 268 | cout << Verbose(0) << "Old: " << config::pseudopotpath << "\t new: "; | 
|---|
|  | 269 | cin >> config::pseudopotpath; | 
|---|
|  | 270 | break; | 
|---|
|  | 271 |  | 
|---|
|  | 272 | case 'D': // ProcPEGamma | 
|---|
|  | 273 | cout << Verbose(0) << "Old: " << config::ProcPEGamma << "\t new: "; | 
|---|
|  | 274 | cin >> config::ProcPEGamma; | 
|---|
|  | 275 | break; | 
|---|
|  | 276 | case 'E': // ProcPEPsi | 
|---|
|  | 277 | cout << Verbose(0) << "Old: " << config::ProcPEPsi << "\t new: "; | 
|---|
|  | 278 | cin >> config::ProcPEPsi; | 
|---|
|  | 279 | break; | 
|---|
|  | 280 | case 'F': // DoOutVis | 
|---|
|  | 281 | cout << Verbose(0) << "Old: " << config::DoOutVis << "\t new: "; | 
|---|
|  | 282 | cin >> config::DoOutVis; | 
|---|
|  | 283 | break; | 
|---|
|  | 284 | case 'G': // DoOutMes | 
|---|
|  | 285 | cout << Verbose(0) << "Old: " << config::DoOutMes << "\t new: "; | 
|---|
|  | 286 | cin >> config::DoOutMes; | 
|---|
|  | 287 | break; | 
|---|
|  | 288 | case 'H': // DoOutOrbitals | 
|---|
|  | 289 | cout << Verbose(0) << "Old: " << config::DoOutOrbitals << "\t new: "; | 
|---|
|  | 290 | cin >> config::DoOutOrbitals; | 
|---|
|  | 291 | break; | 
|---|
|  | 292 | case 'I': // DoOutCurrent | 
|---|
|  | 293 | cout << Verbose(0) << "Old: " << config::DoOutCurrent << "\t new: "; | 
|---|
|  | 294 | cin >> config::DoOutCurrent; | 
|---|
|  | 295 | break; | 
|---|
|  | 296 | case 'J': // DoFullCurrent | 
|---|
|  | 297 | cout << Verbose(0) << "Old: " << config::DoFullCurrent << "\t new: "; | 
|---|
|  | 298 | cin >> config::DoFullCurrent; | 
|---|
|  | 299 | break; | 
|---|
|  | 300 | case 'K': // DoPerturbation | 
|---|
|  | 301 | cout << Verbose(0) << "Old: " << config::DoPerturbation << "\t new: "; | 
|---|
|  | 302 | cin >> config::DoPerturbation; | 
|---|
|  | 303 | break; | 
|---|
|  | 304 | case 'L': // CommonWannier | 
|---|
|  | 305 | cout << Verbose(0) << "Old: " << config::CommonWannier << "\t new: "; | 
|---|
|  | 306 | cin >> config::CommonWannier; | 
|---|
|  | 307 | break; | 
|---|
|  | 308 | case 'M': // SawtoothStart | 
|---|
|  | 309 | cout << Verbose(0) << "Old: " << config::SawtoothStart << "\t new: "; | 
|---|
|  | 310 | cin >> config::SawtoothStart; | 
|---|
|  | 311 | break; | 
|---|
|  | 312 | case 'N': // VectorPlane | 
|---|
|  | 313 | cout << Verbose(0) << "Old: " << config::VectorPlane << "\t new: "; | 
|---|
|  | 314 | cin >> config::VectorPlane; | 
|---|
|  | 315 | break; | 
|---|
|  | 316 | case 'O': // VectorCut | 
|---|
|  | 317 | cout << Verbose(0) << "Old: " << config::VectorCut << "\t new: "; | 
|---|
|  | 318 | cin >> config::VectorCut; | 
|---|
|  | 319 | break; | 
|---|
|  | 320 | case 'P': // UseAddGramSch | 
|---|
|  | 321 | cout << Verbose(0) << "Old: " << config::UseAddGramSch << "\t new: "; | 
|---|
|  | 322 | cin >> config::UseAddGramSch; | 
|---|
|  | 323 | break; | 
|---|
|  | 324 | case 'Q': // Seed | 
|---|
|  | 325 | cout << Verbose(0) << "Old: " << config::Seed << "\t new: "; | 
|---|
|  | 326 | cin >> config::Seed; | 
|---|
|  | 327 | break; | 
|---|
|  | 328 |  | 
|---|
|  | 329 | case 'R': // MaxOuterStep | 
|---|
|  | 330 | cout << Verbose(0) << "Old: " << config::MaxOuterStep << "\t new: "; | 
|---|
|  | 331 | cin >> config::MaxOuterStep; | 
|---|
|  | 332 | break; | 
|---|
|  | 333 | case 'T': // OutVisStep | 
|---|
|  | 334 | cout << Verbose(0) << "Old: " << config::OutVisStep << "\t new: "; | 
|---|
|  | 335 | cin >> config::OutVisStep; | 
|---|
|  | 336 | break; | 
|---|
|  | 337 | case 'U': // OutSrcStep | 
|---|
|  | 338 | cout << Verbose(0) << "Old: " << config::OutSrcStep << "\t new: "; | 
|---|
|  | 339 | cin >> config::OutSrcStep; | 
|---|
|  | 340 | break; | 
|---|
|  | 341 | case 'X': // MaxPsiStep | 
|---|
|  | 342 | cout << Verbose(0) << "Old: " << config::MaxPsiStep << "\t new: "; | 
|---|
|  | 343 | cin >> config::MaxPsiStep; | 
|---|
|  | 344 | break; | 
|---|
|  | 345 | case 'Y': // EpsWannier | 
|---|
|  | 346 | cout << Verbose(0) << "Old: " << config::EpsWannier << "\t new: "; | 
|---|
|  | 347 | cin >> config::EpsWannier; | 
|---|
|  | 348 | break; | 
|---|
|  | 349 |  | 
|---|
|  | 350 | case 'Z': // MaxMinStep | 
|---|
|  | 351 | cout << Verbose(0) << "Old: " << config::MaxMinStep << "\t new: "; | 
|---|
|  | 352 | cin >> config::MaxMinStep; | 
|---|
|  | 353 | break; | 
|---|
|  | 354 | case 'a': // RelEpsTotalEnergy | 
|---|
|  | 355 | cout << Verbose(0) << "Old: " << config::RelEpsTotalEnergy << "\t new: "; | 
|---|
|  | 356 | cin >> config::RelEpsTotalEnergy; | 
|---|
|  | 357 | break; | 
|---|
|  | 358 | case 'b': // RelEpsKineticEnergy | 
|---|
|  | 359 | cout << Verbose(0) << "Old: " << config::RelEpsKineticEnergy << "\t new: "; | 
|---|
|  | 360 | cin >> config::RelEpsKineticEnergy; | 
|---|
|  | 361 | break; | 
|---|
|  | 362 | case 'c': // MaxMinStopStep | 
|---|
|  | 363 | cout << Verbose(0) << "Old: " << config::MaxMinStopStep << "\t new: "; | 
|---|
|  | 364 | cin >> config::MaxMinStopStep; | 
|---|
|  | 365 | break; | 
|---|
|  | 366 | case 'e': // MaxInitMinStep | 
|---|
|  | 367 | cout << Verbose(0) << "Old: " << config::MaxInitMinStep << "\t new: "; | 
|---|
|  | 368 | cin >> config::MaxInitMinStep; | 
|---|
|  | 369 | break; | 
|---|
|  | 370 | case 'f': // InitRelEpsTotalEnergy | 
|---|
|  | 371 | cout << Verbose(0) << "Old: " << config::InitRelEpsTotalEnergy << "\t new: "; | 
|---|
|  | 372 | cin >> config::InitRelEpsTotalEnergy; | 
|---|
|  | 373 | break; | 
|---|
|  | 374 | case 'g': // InitRelEpsKineticEnergy | 
|---|
|  | 375 | cout << Verbose(0) << "Old: " << config::InitRelEpsKineticEnergy << "\t new: "; | 
|---|
|  | 376 | cin >> config::InitRelEpsKineticEnergy; | 
|---|
|  | 377 | break; | 
|---|
|  | 378 | case 'h': // InitMaxMinStopStep | 
|---|
|  | 379 | cout << Verbose(0) << "Old: " << config::InitMaxMinStopStep << "\t new: "; | 
|---|
|  | 380 | cin >> config::InitMaxMinStopStep; | 
|---|
|  | 381 | break; | 
|---|
|  | 382 |  | 
|---|
|  | 383 | case 'j': // BoxLength | 
|---|
|  | 384 | cout << Verbose(0) << "enter lower triadiagonalo form of basis matrix" << endl << endl; | 
|---|
| [7e07cf] | 385 | for (int i=0;i<6;i++) { | 
|---|
| [14de469] | 386 | cout << Verbose(0) << "Cell size" << i << ": "; | 
|---|
|  | 387 | cin >> mol->cell_size[i]; | 
|---|
|  | 388 | } | 
|---|
|  | 389 | break; | 
|---|
|  | 390 |  | 
|---|
|  | 391 | case 'k': // ECut | 
|---|
|  | 392 | cout << Verbose(0) << "Old: " << config::ECut << "\t new: "; | 
|---|
|  | 393 | cin >> config::ECut; | 
|---|
|  | 394 | break; | 
|---|
|  | 395 | case 'l': // MaxLevel | 
|---|
|  | 396 | cout << Verbose(0) << "Old: " << config::MaxLevel << "\t new: "; | 
|---|
|  | 397 | cin >> config::MaxLevel; | 
|---|
|  | 398 | break; | 
|---|
|  | 399 | case 'm': // RiemannTensor | 
|---|
|  | 400 | cout << Verbose(0) << "Old: " << config::RiemannTensor << "\t new: "; | 
|---|
|  | 401 | cin >> config::RiemannTensor; | 
|---|
|  | 402 | break; | 
|---|
|  | 403 | case 'n': // LevRFactor | 
|---|
|  | 404 | cout << Verbose(0) << "Old: " << config::LevRFactor << "\t new: "; | 
|---|
|  | 405 | cin >> config::LevRFactor; | 
|---|
|  | 406 | break; | 
|---|
|  | 407 | case 'o': // RiemannLevel | 
|---|
|  | 408 | cout << Verbose(0) << "Old: " << config::RiemannLevel << "\t new: "; | 
|---|
|  | 409 | cin >> config::RiemannLevel; | 
|---|
|  | 410 | break; | 
|---|
|  | 411 | case 'p': // Lev0Factor | 
|---|
|  | 412 | cout << Verbose(0) << "Old: " << config::Lev0Factor << "\t new: "; | 
|---|
|  | 413 | cin >> config::Lev0Factor; | 
|---|
|  | 414 | break; | 
|---|
|  | 415 | case 'r': // RTActualUse | 
|---|
|  | 416 | cout << Verbose(0) << "Old: " << config::RTActualUse << "\t new: "; | 
|---|
|  | 417 | cin >> config::RTActualUse; | 
|---|
|  | 418 | break; | 
|---|
|  | 419 | case 's': // PsiType | 
|---|
|  | 420 | cout << Verbose(0) << "Old: " << config::PsiType << "\t new: "; | 
|---|
|  | 421 | cin >> config::PsiType; | 
|---|
|  | 422 | break; | 
|---|
|  | 423 | case 't': // MaxPsiDouble | 
|---|
|  | 424 | cout << Verbose(0) << "Old: " << config::MaxPsiDouble << "\t new: "; | 
|---|
|  | 425 | cin >> config::MaxPsiDouble; | 
|---|
|  | 426 | break; | 
|---|
|  | 427 | case 'u': // PsiMaxNoUp | 
|---|
|  | 428 | cout << Verbose(0) << "Old: " << config::PsiMaxNoUp << "\t new: "; | 
|---|
|  | 429 | cin >> config::PsiMaxNoUp; | 
|---|
|  | 430 | break; | 
|---|
|  | 431 | case 'v': // PsiMaxNoDown | 
|---|
|  | 432 | cout << Verbose(0) << "Old: " << config::PsiMaxNoDown << "\t new: "; | 
|---|
|  | 433 | cin >> config::PsiMaxNoDown; | 
|---|
|  | 434 | break; | 
|---|
|  | 435 | case 'w': // AddPsis | 
|---|
|  | 436 | cout << Verbose(0) << "Old: " << config::AddPsis << "\t new: "; | 
|---|
|  | 437 | cin >> config::AddPsis; | 
|---|
|  | 438 | break; | 
|---|
|  | 439 |  | 
|---|
|  | 440 | case 'x': // RCut | 
|---|
|  | 441 | cout << Verbose(0) << "Old: " << config::RCut << "\t new: "; | 
|---|
|  | 442 | cin >> config::RCut; | 
|---|
|  | 443 | break; | 
|---|
|  | 444 | case 'y': // StructOpt | 
|---|
|  | 445 | cout << Verbose(0) << "Old: " << config::StructOpt << "\t new: "; | 
|---|
|  | 446 | cin >> config::StructOpt; | 
|---|
|  | 447 | break; | 
|---|
|  | 448 | case 'z': // IsAngstroem | 
|---|
|  | 449 | cout << Verbose(0) << "Old: " << config::IsAngstroem << "\t new: "; | 
|---|
|  | 450 | cin >> config::IsAngstroem; | 
|---|
|  | 451 | break; | 
|---|
|  | 452 | case 'i': // RelativeCoord | 
|---|
|  | 453 | cout << Verbose(0) << "Old: " << config::RelativeCoord << "\t new: "; | 
|---|
|  | 454 | cin >> config::RelativeCoord; | 
|---|
|  | 455 | break; | 
|---|
|  | 456 | }; | 
|---|
|  | 457 | } while (choice != 'q'); | 
|---|
|  | 458 | }; | 
|---|
|  | 459 |  | 
|---|
|  | 460 | /** Tests whether a given configuration file adhears to old or new syntax. | 
|---|
| [5b15ab] | 461 | * \param *filename filename of config file to be tested | 
|---|
| [14de469] | 462 | * \param *periode pointer to a periodentafel class with all elements | 
|---|
|  | 463 | * \param *mol pointer to molecule containing all atoms of the molecule | 
|---|
|  | 464 | * \return 0 - old syntax, 1 - new syntax, -1 - unknown syntax | 
|---|
|  | 465 | */ | 
|---|
| [5b15ab] | 466 | int config::TestSyntax(char *filename, periodentafel *periode, molecule *mol) | 
|---|
| [14de469] | 467 | { | 
|---|
|  | 468 | int test; | 
|---|
| [5b15ab] | 469 | ifstream file(filename); | 
|---|
|  | 470 |  | 
|---|
| [14de469] | 471 | // search file for keyword: ProcPEGamma (new syntax) | 
|---|
| [5b15ab] | 472 | if (ParseForParameter(1,&file,"ProcPEGamma", 0, 1, 1, int_type, &test, 1, optional)) { | 
|---|
|  | 473 | file.close(); | 
|---|
| [14de469] | 474 | return 1; | 
|---|
| [5b15ab] | 475 | } | 
|---|
| [14de469] | 476 | // search file for keyword: ProcsGammaPsi (old syntax) | 
|---|
| [5b15ab] | 477 | if (ParseForParameter(1,&file,"ProcsGammaPsi", 0, 1, 1, int_type, &test, 1, optional)) { | 
|---|
|  | 478 | file.close(); | 
|---|
| [14de469] | 479 | return 0; | 
|---|
| [5b15ab] | 480 | } | 
|---|
|  | 481 | file.close(); | 
|---|
| [14de469] | 482 | return -1; | 
|---|
|  | 483 | } | 
|---|
|  | 484 |  | 
|---|
|  | 485 | /** Returns private config::IsAngstroem. | 
|---|
|  | 486 | * \return IsAngstroem | 
|---|
|  | 487 | */ | 
|---|
|  | 488 | bool config::GetIsAngstroem() const | 
|---|
|  | 489 | { | 
|---|
|  | 490 | return (IsAngstroem == 1); | 
|---|
|  | 491 | }; | 
|---|
|  | 492 |  | 
|---|
|  | 493 | /** Returns private config::*defaultpath. | 
|---|
|  | 494 | * \return *defaultpath | 
|---|
|  | 495 | */ | 
|---|
|  | 496 | char * config::GetDefaultPath() const | 
|---|
|  | 497 | { | 
|---|
|  | 498 | return defaultpath; | 
|---|
|  | 499 | }; | 
|---|
|  | 500 |  | 
|---|
|  | 501 |  | 
|---|
|  | 502 | /** Returns private config::*defaultpath. | 
|---|
|  | 503 | * \return *defaultpath | 
|---|
|  | 504 | */ | 
|---|
|  | 505 | void config::SetDefaultPath(const char *path) | 
|---|
|  | 506 | { | 
|---|
|  | 507 | strcpy(defaultpath, path); | 
|---|
|  | 508 | }; | 
|---|
|  | 509 |  | 
|---|
| [5b15ab] | 510 | /** Retrieves the path in the given config file name. | 
|---|
| [7f3b9d] | 511 | * \param filename config file string | 
|---|
| [5b15ab] | 512 | */ | 
|---|
| [7f3b9d] | 513 | void config::RetrieveConfigPathAndName(string filename) | 
|---|
| [5b15ab] | 514 | { | 
|---|
| [b5ecd9] | 515 | char *ptr = NULL; | 
|---|
| [7f3b9d] | 516 | char *buffer = new char[MAXSTRINGSIZE]; | 
|---|
|  | 517 | strncpy(buffer, filename.c_str(), MAXSTRINGSIZE); | 
|---|
| [5b15ab] | 518 | int last = -1; | 
|---|
| [7f3b9d] | 519 | for(last=MAXSTRINGSIZE;last--;) { | 
|---|
|  | 520 | if (buffer[last] == '/') | 
|---|
| [5b15ab] | 521 | break; | 
|---|
|  | 522 | } | 
|---|
| [a2c084] | 523 | if (last == -1) { // no path in front, set to local directory. | 
|---|
| [5b15ab] | 524 | strcpy(configpath, "./"); | 
|---|
| [7f3b9d] | 525 | ptr = buffer; | 
|---|
| [5b15ab] | 526 | } else { | 
|---|
| [7f3b9d] | 527 | strncpy(configpath, buffer, last+1); | 
|---|
|  | 528 | ptr = &buffer[last+1]; | 
|---|
| [5b15ab] | 529 | if (last < 254) | 
|---|
|  | 530 | configpath[last+1]='\0'; | 
|---|
|  | 531 | } | 
|---|
| [b5ecd9] | 532 | strcpy(configname, ptr); | 
|---|
|  | 533 | cout << "Found configpath: " << configpath << ", dir slash was found at " << last << ", config name is " << configname << "." << endl; | 
|---|
| [7f3b9d] | 534 | delete[](buffer); | 
|---|
| [5b15ab] | 535 | }; | 
|---|
|  | 536 |  | 
|---|
|  | 537 |  | 
|---|
| [14de469] | 538 | /** Initializes config file structure by loading elements from a give file. | 
|---|
|  | 539 | * \param *file input file stream being the opened config file | 
|---|
|  | 540 | * \param *periode pointer to a periodentafel class with all elements | 
|---|
|  | 541 | * \param *mol pointer to molecule containing all atoms of the molecule | 
|---|
|  | 542 | */ | 
|---|
| [5b15ab] | 543 | void config::Load(char *filename, periodentafel *periode, molecule *mol) | 
|---|
| [14de469] | 544 | { | 
|---|
| [5b15ab] | 545 | ifstream *file = new ifstream(filename); | 
|---|
|  | 546 | if (file == NULL) { | 
|---|
|  | 547 | cerr << "ERROR: config file " << filename << " missing!" << endl; | 
|---|
|  | 548 | return; | 
|---|
|  | 549 | } | 
|---|
| [b5ecd9] | 550 | RetrieveConfigPathAndName(filename); | 
|---|
| [14de469] | 551 | // ParseParameters | 
|---|
|  | 552 |  | 
|---|
|  | 553 | /* Oeffne Hauptparameterdatei */ | 
|---|
|  | 554 | int di; | 
|---|
|  | 555 | double BoxLength[9]; | 
|---|
|  | 556 | string zeile; | 
|---|
|  | 557 | string dummy; | 
|---|
| [cdee6b] | 558 | element *elementhash[MAX_ELEMENTS]; | 
|---|
|  | 559 | char name[MAX_ELEMENTS]; | 
|---|
|  | 560 | char keyword[MAX_ELEMENTS]; | 
|---|
|  | 561 | int Z, No[MAX_ELEMENTS]; | 
|---|
| [14de469] | 562 | int verbose = 0; | 
|---|
| [362b0e] | 563 | double value[3]; | 
|---|
| [14de469] | 564 |  | 
|---|
| [62f793] | 565 | InitThermostats(file); | 
|---|
|  | 566 |  | 
|---|
| [14de469] | 567 | /* Namen einlesen */ | 
|---|
|  | 568 |  | 
|---|
|  | 569 | ParseForParameter(verbose,file, "mainname", 0, 1, 1, string_type, (config::mainname), 1, critical); | 
|---|
|  | 570 | ParseForParameter(verbose,file, "defaultpath", 0, 1, 1, string_type, (config::defaultpath), 1, critical); | 
|---|
|  | 571 | ParseForParameter(verbose,file, "pseudopotpath", 0, 1, 1, string_type, (config::pseudopotpath), 1, critical); | 
|---|
|  | 572 | ParseForParameter(verbose,file,"ProcPEGamma", 0, 1, 1, int_type, &(config::ProcPEGamma), 1, critical); | 
|---|
|  | 573 | ParseForParameter(verbose,file,"ProcPEPsi", 0, 1, 1, int_type, &(config::ProcPEPsi), 1, critical); | 
|---|
|  | 574 |  | 
|---|
|  | 575 | if (!ParseForParameter(verbose,file,"Seed", 0, 1, 1, int_type, &(config::Seed), 1, optional)) | 
|---|
|  | 576 | config::Seed = 1; | 
|---|
|  | 577 |  | 
|---|
|  | 578 | if(!ParseForParameter(verbose,file,"DoOutOrbitals", 0, 1, 1, int_type, &(config::DoOutOrbitals), 1, optional)) { | 
|---|
|  | 579 | config::DoOutOrbitals = 0; | 
|---|
|  | 580 | } else { | 
|---|
|  | 581 | if (config::DoOutOrbitals < 0) config::DoOutOrbitals = 0; | 
|---|
|  | 582 | if (config::DoOutOrbitals > 1) config::DoOutOrbitals = 1; | 
|---|
|  | 583 | } | 
|---|
|  | 584 | ParseForParameter(verbose,file,"DoOutVis", 0, 1, 1, int_type, &(config::DoOutVis), 1, critical); | 
|---|
|  | 585 | if (config::DoOutVis < 0) config::DoOutVis = 0; | 
|---|
|  | 586 | if (config::DoOutVis > 1) config::DoOutVis = 1; | 
|---|
|  | 587 | if (!ParseForParameter(verbose,file,"VectorPlane", 0, 1, 1, int_type, &(config::VectorPlane), 1, optional)) | 
|---|
|  | 588 | config::VectorPlane = -1; | 
|---|
|  | 589 | if (!ParseForParameter(verbose,file,"VectorCut", 0, 1, 1, double_type, &(config::VectorCut), 1, optional)) | 
|---|
|  | 590 | config::VectorCut = 0.; | 
|---|
|  | 591 | ParseForParameter(verbose,file,"DoOutMes", 0, 1, 1, int_type, &(config::DoOutMes), 1, critical); | 
|---|
|  | 592 | if (config::DoOutMes < 0) config::DoOutMes = 0; | 
|---|
|  | 593 | if (config::DoOutMes > 1) config::DoOutMes = 1; | 
|---|
|  | 594 | if (!ParseForParameter(verbose,file,"DoOutCurr", 0, 1, 1, int_type, &(config::DoOutCurrent), 1, optional)) | 
|---|
|  | 595 | config::DoOutCurrent = 0; | 
|---|
|  | 596 | if (config::DoOutCurrent < 0) config::DoOutCurrent = 0; | 
|---|
|  | 597 | if (config::DoOutCurrent > 1) config::DoOutCurrent = 1; | 
|---|
|  | 598 | ParseForParameter(verbose,file,"AddGramSch", 0, 1, 1, int_type, &(config::UseAddGramSch), 1, critical); | 
|---|
|  | 599 | if (config::UseAddGramSch < 0) config::UseAddGramSch = 0; | 
|---|
|  | 600 | if (config::UseAddGramSch > 2) config::UseAddGramSch = 2; | 
|---|
| [18913c] | 601 | if(!ParseForParameter(verbose,file,"DoWannier", 0, 1, 1, int_type, &(config::DoWannier), 1, optional)) { | 
|---|
|  | 602 | config::DoWannier = 0; | 
|---|
|  | 603 | } else { | 
|---|
|  | 604 | if (config::DoWannier < 0) config::DoWannier = 0; | 
|---|
|  | 605 | if (config::DoWannier > 1) config::DoWannier = 1; | 
|---|
|  | 606 | } | 
|---|
| [14de469] | 607 | if(!ParseForParameter(verbose,file,"CommonWannier", 0, 1, 1, int_type, &(config::CommonWannier), 1, optional)) { | 
|---|
|  | 608 | config::CommonWannier = 0; | 
|---|
|  | 609 | } else { | 
|---|
|  | 610 | if (config::CommonWannier < 0) config::CommonWannier = 0; | 
|---|
|  | 611 | if (config::CommonWannier > 4) config::CommonWannier = 4; | 
|---|
|  | 612 | } | 
|---|
|  | 613 | if(!ParseForParameter(verbose,file,"SawtoothStart", 0, 1, 1, double_type, &(config::SawtoothStart), 1, optional)) { | 
|---|
|  | 614 | config::SawtoothStart = 0.01; | 
|---|
|  | 615 | } else { | 
|---|
|  | 616 | if (config::SawtoothStart < 0.) config::SawtoothStart = 0.; | 
|---|
|  | 617 | if (config::SawtoothStart > 1.) config::SawtoothStart = 1.; | 
|---|
|  | 618 | } | 
|---|
|  | 619 |  | 
|---|
| [6e9353] | 620 | if (ParseForParameter(verbose,file,"DoConstrainedMD", 0, 1, 1, int_type, &(config::DoConstrainedMD), 1, optional)) | 
|---|
|  | 621 | if (config::DoConstrainedMD < 0) | 
|---|
|  | 622 | config::DoConstrainedMD = 0; | 
|---|
| [14de469] | 623 | ParseForParameter(verbose,file,"MaxOuterStep", 0, 1, 1, int_type, &(config::MaxOuterStep), 1, critical); | 
|---|
| [362b0e] | 624 | if (!ParseForParameter(verbose,file,"Deltat", 0, 1, 1, double_type, &(config::Deltat), 1, optional)) | 
|---|
|  | 625 | config::Deltat = 1; | 
|---|
| [14de469] | 626 | ParseForParameter(verbose,file,"OutVisStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); | 
|---|
|  | 627 | ParseForParameter(verbose,file,"OutSrcStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional); | 
|---|
|  | 628 | ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &(config::TargetTemp), 1, optional); | 
|---|
|  | 629 | //ParseForParameter(verbose,file,"Thermostat", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional); | 
|---|
|  | 630 | if (!ParseForParameter(verbose,file,"EpsWannier", 0, 1, 1, double_type, &(config::EpsWannier), 1, optional)) | 
|---|
|  | 631 | config::EpsWannier = 1e-8; | 
|---|
|  | 632 |  | 
|---|
|  | 633 | // stop conditions | 
|---|
|  | 634 | //if (config::MaxOuterStep <= 0) config::MaxOuterStep = 1; | 
|---|
|  | 635 | ParseForParameter(verbose,file,"MaxPsiStep", 0, 1, 1, int_type, &(config::MaxPsiStep), 1, critical); | 
|---|
|  | 636 | if (config::MaxPsiStep <= 0) config::MaxPsiStep = 3; | 
|---|
|  | 637 |  | 
|---|
|  | 638 | ParseForParameter(verbose,file,"MaxMinStep", 0, 1, 1, int_type, &(config::MaxMinStep), 1, critical); | 
|---|
|  | 639 | ParseForParameter(verbose,file,"RelEpsTotalE", 0, 1, 1, double_type, &(config::RelEpsTotalEnergy), 1, critical); | 
|---|
|  | 640 | ParseForParameter(verbose,file,"RelEpsKineticE", 0, 1, 1, double_type, &(config::RelEpsKineticEnergy), 1, critical); | 
|---|
|  | 641 | ParseForParameter(verbose,file,"MaxMinStopStep", 0, 1, 1, int_type, &(config::MaxMinStopStep), 1, critical); | 
|---|
|  | 642 | ParseForParameter(verbose,file,"MaxMinGapStopStep", 0, 1, 1, int_type, &(config::MaxMinGapStopStep), 1, critical); | 
|---|
|  | 643 | if (config::MaxMinStep <= 0) config::MaxMinStep = config::MaxPsiStep; | 
|---|
|  | 644 | if (config::MaxMinStopStep < 1) config::MaxMinStopStep = 1; | 
|---|
|  | 645 | if (config::MaxMinGapStopStep < 1) config::MaxMinGapStopStep = 1; | 
|---|
|  | 646 |  | 
|---|
|  | 647 | ParseForParameter(verbose,file,"MaxInitMinStep", 0, 1, 1, int_type, &(config::MaxInitMinStep), 1, critical); | 
|---|
|  | 648 | ParseForParameter(verbose,file,"InitRelEpsTotalE", 0, 1, 1, double_type, &(config::InitRelEpsTotalEnergy), 1, critical); | 
|---|
|  | 649 | ParseForParameter(verbose,file,"InitRelEpsKineticE", 0, 1, 1, double_type, &(config::InitRelEpsKineticEnergy), 1, critical); | 
|---|
|  | 650 | ParseForParameter(verbose,file,"InitMaxMinStopStep", 0, 1, 1, int_type, &(config::InitMaxMinStopStep), 1, critical); | 
|---|
|  | 651 | ParseForParameter(verbose,file,"InitMaxMinGapStopStep", 0, 1, 1, int_type, &(config::InitMaxMinGapStopStep), 1, critical); | 
|---|
|  | 652 | if (config::MaxInitMinStep <= 0) config::MaxInitMinStep = config::MaxPsiStep; | 
|---|
|  | 653 | if (config::InitMaxMinStopStep < 1) config::InitMaxMinStopStep = 1; | 
|---|
|  | 654 | if (config::InitMaxMinGapStopStep < 1) config::InitMaxMinGapStopStep = 1; | 
|---|
|  | 655 |  | 
|---|
|  | 656 | // Unit cell and magnetic field | 
|---|
|  | 657 | ParseForParameter(verbose,file, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ | 
|---|
|  | 658 | mol->cell_size[0] = BoxLength[0]; | 
|---|
|  | 659 | mol->cell_size[1] = BoxLength[3]; | 
|---|
|  | 660 | mol->cell_size[2] = BoxLength[4]; | 
|---|
|  | 661 | mol->cell_size[3] = BoxLength[6]; | 
|---|
|  | 662 | mol->cell_size[4] = BoxLength[7]; | 
|---|
|  | 663 | mol->cell_size[5] = BoxLength[8]; | 
|---|
|  | 664 | if (1) fprintf(stderr,"\n"); | 
|---|
|  | 665 |  | 
|---|
|  | 666 | ParseForParameter(verbose,file,"DoPerturbation", 0, 1, 1, int_type, &(config::DoPerturbation), 1, optional); | 
|---|
|  | 667 | ParseForParameter(verbose,file,"DoOutNICS", 0, 1, 1, int_type, &(config::DoOutNICS), 1, optional); | 
|---|
|  | 668 | if (!ParseForParameter(verbose,file,"DoFullCurrent", 0, 1, 1, int_type, &(config::DoFullCurrent), 1, optional)) | 
|---|
|  | 669 | config::DoFullCurrent = 0; | 
|---|
|  | 670 | if (config::DoFullCurrent < 0) config::DoFullCurrent = 0; | 
|---|
|  | 671 | if (config::DoFullCurrent > 2) config::DoFullCurrent = 2; | 
|---|
|  | 672 | if (config::DoOutNICS < 0) config::DoOutNICS = 0; | 
|---|
|  | 673 | if (config::DoOutNICS > 2) config::DoOutNICS = 2; | 
|---|
|  | 674 | if (config::DoPerturbation == 0) { | 
|---|
|  | 675 | config::DoFullCurrent = 0; | 
|---|
|  | 676 | config::DoOutNICS = 0; | 
|---|
|  | 677 | } | 
|---|
|  | 678 |  | 
|---|
|  | 679 | ParseForParameter(verbose,file,"ECut", 0, 1, 1, double_type, &(config::ECut), 1, critical); | 
|---|
|  | 680 | ParseForParameter(verbose,file,"MaxLevel", 0, 1, 1, int_type, &(config::MaxLevel), 1, critical); | 
|---|
|  | 681 | ParseForParameter(verbose,file,"Level0Factor", 0, 1, 1, int_type, &(config::Lev0Factor), 1, critical); | 
|---|
|  | 682 | if (config::Lev0Factor < 2) { | 
|---|
|  | 683 | config::Lev0Factor = 2; | 
|---|
|  | 684 | } | 
|---|
|  | 685 | ParseForParameter(verbose,file,"RiemannTensor", 0, 1, 1, int_type, &di, 1, critical); | 
|---|
|  | 686 | if (di >= 0 && di < 2) { | 
|---|
|  | 687 | config::RiemannTensor = di; | 
|---|
|  | 688 | } else { | 
|---|
|  | 689 | fprintf(stderr, "0 <= RiemanTensor < 2: 0 UseNotRT, 1 UseRT"); | 
|---|
|  | 690 | exit(1); | 
|---|
|  | 691 | } | 
|---|
|  | 692 | switch (config::RiemannTensor) { | 
|---|
|  | 693 | case 0: //UseNoRT | 
|---|
|  | 694 | if (config::MaxLevel < 2) { | 
|---|
|  | 695 | config::MaxLevel = 2; | 
|---|
|  | 696 | } | 
|---|
|  | 697 | config::LevRFactor = 2; | 
|---|
|  | 698 | config::RTActualUse = 0; | 
|---|
|  | 699 | break; | 
|---|
|  | 700 | case 1: // UseRT | 
|---|
|  | 701 | if (config::MaxLevel < 3) { | 
|---|
|  | 702 | config::MaxLevel = 3; | 
|---|
|  | 703 | } | 
|---|
|  | 704 | ParseForParameter(verbose,file,"RiemannLevel", 0, 1, 1, int_type, &(config::RiemannLevel), 1, critical); | 
|---|
|  | 705 | if (config::RiemannLevel < 2) { | 
|---|
|  | 706 | config::RiemannLevel = 2; | 
|---|
|  | 707 | } | 
|---|
|  | 708 | if (config::RiemannLevel > config::MaxLevel-1) { | 
|---|
|  | 709 | config::RiemannLevel = config::MaxLevel-1; | 
|---|
|  | 710 | } | 
|---|
|  | 711 | ParseForParameter(verbose,file,"LevRFactor", 0, 1, 1, int_type, &(config::LevRFactor), 1, critical); | 
|---|
|  | 712 | if (config::LevRFactor < 2) { | 
|---|
|  | 713 | config::LevRFactor = 2; | 
|---|
|  | 714 | } | 
|---|
|  | 715 | config::Lev0Factor = 2; | 
|---|
|  | 716 | config::RTActualUse = 2; | 
|---|
|  | 717 | break; | 
|---|
|  | 718 | } | 
|---|
|  | 719 | ParseForParameter(verbose,file,"PsiType", 0, 1, 1, int_type, &di, 1, critical); | 
|---|
|  | 720 | if (di >= 0 && di < 2) { | 
|---|
|  | 721 | config::PsiType = di; | 
|---|
|  | 722 | } else { | 
|---|
|  | 723 | fprintf(stderr, "0 <= PsiType < 2: 0 UseSpinDouble, 1 UseSpinUpDown"); | 
|---|
|  | 724 | exit(1); | 
|---|
|  | 725 | } | 
|---|
|  | 726 | switch (config::PsiType) { | 
|---|
|  | 727 | case 0: // SpinDouble | 
|---|
|  | 728 | ParseForParameter(verbose,file,"MaxPsiDouble", 0, 1, 1, int_type, &(config::MaxPsiDouble), 1, critical); | 
|---|
|  | 729 | ParseForParameter(verbose,file,"AddPsis", 0, 1, 1, int_type, &(config::AddPsis), 1, optional); | 
|---|
|  | 730 | break; | 
|---|
|  | 731 | case 1: // SpinUpDown | 
|---|
|  | 732 | if (config::ProcPEGamma % 2) config::ProcPEGamma*=2; | 
|---|
|  | 733 | ParseForParameter(verbose,file,"PsiMaxNoUp", 0, 1, 1, int_type, &(config::PsiMaxNoUp), 1, critical); | 
|---|
|  | 734 | ParseForParameter(verbose,file,"PsiMaxNoDown", 0, 1, 1, int_type, &(config::PsiMaxNoDown), 1, critical); | 
|---|
|  | 735 | ParseForParameter(verbose,file,"AddPsis", 0, 1, 1, int_type, &(config::AddPsis), 1, optional); | 
|---|
|  | 736 | break; | 
|---|
|  | 737 | } | 
|---|
|  | 738 |  | 
|---|
|  | 739 | // IonsInitRead | 
|---|
|  | 740 |  | 
|---|
|  | 741 | ParseForParameter(verbose,file,"RCut", 0, 1, 1, double_type, &(config::RCut), 1, critical); | 
|---|
|  | 742 | ParseForParameter(verbose,file,"IsAngstroem", 0, 1, 1, int_type, &(config::IsAngstroem), 1, critical); | 
|---|
|  | 743 | ParseForParameter(verbose,file,"MaxTypes", 0, 1, 1, int_type, &(config::MaxTypes), 1, critical); | 
|---|
|  | 744 | if (!ParseForParameter(verbose,file,"RelativeCoord", 0, 1, 1, int_type, &(config::RelativeCoord) , 1, optional)) | 
|---|
|  | 745 | config::RelativeCoord = 0; | 
|---|
|  | 746 | if (!ParseForParameter(verbose,file,"StructOpt", 0, 1, 1, int_type, &(config::StructOpt), 1, optional)) | 
|---|
|  | 747 | config::StructOpt = 0; | 
|---|
| [7e27e7] | 748 | if (MaxTypes == 0) { | 
|---|
|  | 749 | cerr << "There are no atoms according to MaxTypes in this config file." << endl; | 
|---|
|  | 750 | } else { | 
|---|
|  | 751 | // prescan number of ions per type | 
|---|
|  | 752 | cout << Verbose(0) << "Prescanning ions per type: " << endl; | 
|---|
|  | 753 | for (int i=0; i < config::MaxTypes; i++) { | 
|---|
|  | 754 | sprintf(name,"Ion_Type%i",i+1); | 
|---|
|  | 755 | ParseForParameter(verbose,file, (const char*)name, 0, 1, 1, int_type, &No[i], 1, critical); | 
|---|
|  | 756 | ParseForParameter(verbose,file, name, 0, 2, 1, int_type, &Z, 1, critical); | 
|---|
|  | 757 | elementhash[i] = periode->FindElement(Z); | 
|---|
|  | 758 | cout << Verbose(1) << i << ". Z = " << elementhash[i]->Z << " with " << No[i] << " ions." << endl; | 
|---|
|  | 759 | } | 
|---|
|  | 760 | int repetition = 0; // which repeated keyword shall be read | 
|---|
|  | 761 |  | 
|---|
|  | 762 | map<int, atom *> AtomList[config::MaxTypes]; | 
|---|
|  | 763 | if (!FastParsing) { | 
|---|
|  | 764 | // parse in trajectories | 
|---|
|  | 765 | bool status = true; | 
|---|
|  | 766 | atom *neues = NULL; | 
|---|
|  | 767 | while (status) { | 
|---|
|  | 768 | cout << "Currently parsing MD step " << repetition << "." << endl; | 
|---|
|  | 769 | for (int i=0; i < config::MaxTypes; i++) { | 
|---|
|  | 770 | sprintf(name,"Ion_Type%i",i+1); | 
|---|
|  | 771 | for(int j=0;j<No[i];j++) { | 
|---|
|  | 772 | sprintf(keyword,"%s_%i",name, j+1); | 
|---|
|  | 773 | if (repetition == 0) { | 
|---|
|  | 774 | neues = new atom(); | 
|---|
|  | 775 | AtomList[i][j] = neues; | 
|---|
|  | 776 | neues->type = elementhash[i]; // find element type | 
|---|
|  | 777 | mol->AddAtom(neues); | 
|---|
|  | 778 | } else | 
|---|
|  | 779 | neues = AtomList[i][j]; | 
|---|
|  | 780 | status = (status && | 
|---|
|  | 781 | ParseForParameter(verbose,file, keyword, 0, 1, 1, double_type, &neues->x.x[0], 1, (repetition == 0) ? critical : optional) && | 
|---|
|  | 782 | ParseForParameter(verbose,file, keyword, 0, 2, 1, double_type, &neues->x.x[1], 1, (repetition == 0) ? critical : optional) && | 
|---|
|  | 783 | ParseForParameter(verbose,file, keyword, 0, 3, 1, double_type, &neues->x.x[2], 1, (repetition == 0) ? critical : optional) && | 
|---|
|  | 784 | ParseForParameter(verbose,file, keyword, 0, 4, 1, int_type, &neues->FixedIon, 1, (repetition == 0) ? critical : optional)); | 
|---|
|  | 785 | if (!status) break; | 
|---|
|  | 786 |  | 
|---|
|  | 787 | // check size of vectors | 
|---|
|  | 788 | if (mol->Trajectories[neues].R.size() <= (unsigned int)(repetition)) { | 
|---|
|  | 789 | //cout << "Increasing size for trajectory array of " << keyword << " to " << (repetition+10) << "." << endl; | 
|---|
|  | 790 | mol->Trajectories[neues].R.resize(repetition+10); | 
|---|
|  | 791 | mol->Trajectories[neues].U.resize(repetition+10); | 
|---|
|  | 792 | mol->Trajectories[neues].F.resize(repetition+10); | 
|---|
|  | 793 | } | 
|---|
|  | 794 |  | 
|---|
|  | 795 | // put into trajectories list | 
|---|
|  | 796 | for (int d=0;d<NDIM;d++) | 
|---|
|  | 797 | mol->Trajectories[neues].R.at(repetition).x[d] = neues->x.x[d]; | 
|---|
|  | 798 |  | 
|---|
|  | 799 | // parse velocities if present | 
|---|
|  | 800 | if(!ParseForParameter(verbose,file, keyword, 0, 5, 1, double_type, &neues->v.x[0], 1,optional)) | 
|---|
|  | 801 | neues->v.x[0] = 0.; | 
|---|
|  | 802 | if(!ParseForParameter(verbose,file, keyword, 0, 6, 1, double_type, &neues->v.x[1], 1,optional)) | 
|---|
|  | 803 | neues->v.x[1] = 0.; | 
|---|
|  | 804 | if(!ParseForParameter(verbose,file, keyword, 0, 7, 1, double_type, &neues->v.x[2], 1,optional)) | 
|---|
|  | 805 | neues->v.x[2] = 0.; | 
|---|
|  | 806 | for (int d=0;d<NDIM;d++) | 
|---|
|  | 807 | mol->Trajectories[neues].U.at(repetition).x[d] = neues->v.x[d]; | 
|---|
|  | 808 |  | 
|---|
|  | 809 | // parse forces if present | 
|---|
|  | 810 | if(!ParseForParameter(verbose,file, keyword, 0, 8, 1, double_type, &value[0], 1,optional)) | 
|---|
|  | 811 | value[0] = 0.; | 
|---|
|  | 812 | if(!ParseForParameter(verbose,file, keyword, 0, 9, 1, double_type, &value[1], 1,optional)) | 
|---|
|  | 813 | value[1] = 0.; | 
|---|
|  | 814 | if(!ParseForParameter(verbose,file, keyword, 1, 10, 1, double_type, &value[2], 1,optional)) | 
|---|
|  | 815 | value[2] = 0.; | 
|---|
|  | 816 | for (int d=0;d<NDIM;d++) | 
|---|
|  | 817 | mol->Trajectories[neues].F.at(repetition).x[d] = value[d]; | 
|---|
|  | 818 |  | 
|---|
|  | 819 | //            cout << "Parsed position of step " << (repetition) << ": ("; | 
|---|
|  | 820 | //            for (int d=0;d<NDIM;d++) | 
|---|
|  | 821 | //              cout << mol->Trajectories[neues].R.at(repetition).x[d] << " ";          // next step | 
|---|
|  | 822 | //            cout << ")\t("; | 
|---|
|  | 823 | //            for (int d=0;d<NDIM;d++) | 
|---|
|  | 824 | //              cout << mol->Trajectories[neues].U.at(repetition).x[d] << " ";          // next step | 
|---|
|  | 825 | //            cout << ")\t("; | 
|---|
|  | 826 | //            for (int d=0;d<NDIM;d++) | 
|---|
|  | 827 | //              cout << mol->Trajectories[neues].F.at(repetition).x[d] << " ";          // next step | 
|---|
|  | 828 | //            cout << ")" << endl; | 
|---|
|  | 829 | } | 
|---|
|  | 830 | } | 
|---|
|  | 831 | repetition++; | 
|---|
|  | 832 | } | 
|---|
|  | 833 | repetition--; | 
|---|
|  | 834 | cout << "Found " << repetition << " trajectory steps." << endl; | 
|---|
|  | 835 | mol->MDSteps = repetition; | 
|---|
|  | 836 | } else { | 
|---|
|  | 837 | // find the maximum number of MD steps so that we may parse last one (Ion_Type1_1 must always be present, because is the first atom) | 
|---|
|  | 838 | repetition = 0; | 
|---|
|  | 839 | while ( ParseForParameter(verbose,file, "Ion_Type1_1", 0, 1, 1, double_type, &value[0], repetition, (repetition == 0) ? critical : optional) && | 
|---|
|  | 840 | ParseForParameter(verbose,file, "Ion_Type1_1", 0, 2, 1, double_type, &value[1], repetition, (repetition == 0) ? critical : optional) && | 
|---|
|  | 841 | ParseForParameter(verbose,file, "Ion_Type1_1", 0, 3, 1, double_type, &value[2], repetition, (repetition == 0) ? critical : optional)) | 
|---|
|  | 842 | repetition++; | 
|---|
|  | 843 | cout << "I found " << repetition << " times the keyword Ion_Type1_1." << endl; | 
|---|
|  | 844 | // parse in molecule coordinates | 
|---|
| [362b0e] | 845 | for (int i=0; i < config::MaxTypes; i++) { | 
|---|
|  | 846 | sprintf(name,"Ion_Type%i",i+1); | 
|---|
|  | 847 | for(int j=0;j<No[i];j++) { | 
|---|
|  | 848 | sprintf(keyword,"%s_%i",name, j+1); | 
|---|
| [7e27e7] | 849 | atom *neues = new atom(); | 
|---|
|  | 850 | // then parse for each atom the coordinates as often as present | 
|---|
|  | 851 | ParseForParameter(verbose,file, keyword, 0, 1, 1, double_type, &neues->x.x[0], repetition,critical); | 
|---|
|  | 852 | ParseForParameter(verbose,file, keyword, 0, 2, 1, double_type, &neues->x.x[1], repetition,critical); | 
|---|
|  | 853 | ParseForParameter(verbose,file, keyword, 0, 3, 1, double_type, &neues->x.x[2], repetition,critical); | 
|---|
|  | 854 | ParseForParameter(verbose,file, keyword, 0, 4, 1, int_type, &neues->FixedIon, repetition,critical); | 
|---|
|  | 855 | if(!ParseForParameter(verbose,file, keyword, 0, 5, 1, double_type, &neues->v.x[0], repetition,optional)) | 
|---|
| [5e0d1f] | 856 | neues->v.x[0] = 0.; | 
|---|
| [7e27e7] | 857 | if(!ParseForParameter(verbose,file, keyword, 0, 6, 1, double_type, &neues->v.x[1], repetition,optional)) | 
|---|
| [5e0d1f] | 858 | neues->v.x[1] = 0.; | 
|---|
| [7e27e7] | 859 | if(!ParseForParameter(verbose,file, keyword, 0, 7, 1, double_type, &neues->v.x[2], repetition,optional)) | 
|---|
| [5e0d1f] | 860 | neues->v.x[2] = 0.; | 
|---|
| [7e27e7] | 861 | // here we don't care if forces are present (last in trajectories is always equal to current position) | 
|---|
|  | 862 | neues->type = elementhash[i]; // find element type | 
|---|
|  | 863 | mol->AddAtom(neues); | 
|---|
| [5e0d1f] | 864 | } | 
|---|
| [62c16c] | 865 | } | 
|---|
| [14de469] | 866 | } | 
|---|
|  | 867 | } | 
|---|
| [5b15ab] | 868 | file->close(); | 
|---|
|  | 869 | delete(file); | 
|---|
| [14de469] | 870 | }; | 
|---|
|  | 871 |  | 
|---|
|  | 872 | /** Initializes config file structure by loading elements from a give file with old pcp syntax. | 
|---|
|  | 873 | * \param *file input file stream being the opened config file with old pcp syntax | 
|---|
|  | 874 | * \param *periode pointer to a periodentafel class with all elements | 
|---|
|  | 875 | * \param *mol pointer to molecule containing all atoms of the molecule | 
|---|
|  | 876 | */ | 
|---|
| [5b15ab] | 877 | void config::LoadOld(char *filename, periodentafel *periode, molecule *mol) | 
|---|
| [14de469] | 878 | { | 
|---|
| [5b15ab] | 879 | ifstream *file = new ifstream(filename); | 
|---|
|  | 880 | if (file == NULL) { | 
|---|
|  | 881 | cerr << "ERROR: config file " << filename << " missing!" << endl; | 
|---|
|  | 882 | return; | 
|---|
|  | 883 | } | 
|---|
| [b5ecd9] | 884 | RetrieveConfigPathAndName(filename); | 
|---|
| [14de469] | 885 | // ParseParameters | 
|---|
|  | 886 |  | 
|---|
|  | 887 | /* Oeffne Hauptparameterdatei */ | 
|---|
|  | 888 | int l, i, di; | 
|---|
|  | 889 | double a,b; | 
|---|
|  | 890 | double BoxLength[9]; | 
|---|
|  | 891 | string zeile; | 
|---|
|  | 892 | string dummy; | 
|---|
|  | 893 | element *elementhash[128]; | 
|---|
|  | 894 | int Z, No, AtomNo, found; | 
|---|
|  | 895 | int verbose = 0; | 
|---|
|  | 896 |  | 
|---|
|  | 897 | /* Namen einlesen */ | 
|---|
|  | 898 |  | 
|---|
|  | 899 | ParseForParameter(verbose,file, "mainname", 0, 1, 1, string_type, (config::mainname), 1, critical); | 
|---|
|  | 900 | ParseForParameter(verbose,file, "defaultpath", 0, 1, 1, string_type, (config::defaultpath), 1, critical); | 
|---|
|  | 901 | ParseForParameter(verbose,file, "pseudopotpath", 0, 1, 1, string_type, (config::pseudopotpath), 1, critical); | 
|---|
|  | 902 | ParseForParameter(verbose,file, "ProcsGammaPsi", 0, 1, 1, int_type, &(config::ProcPEGamma), 1, critical); | 
|---|
|  | 903 | ParseForParameter(verbose,file, "ProcsGammaPsi", 0, 2, 1, int_type, &(config::ProcPEPsi), 1, critical); | 
|---|
|  | 904 | config::Seed = 1; | 
|---|
|  | 905 | config::DoOutOrbitals = 0; | 
|---|
|  | 906 | ParseForParameter(verbose,file,"DoOutVis", 0, 1, 1, int_type, &(config::DoOutVis), 1, critical); | 
|---|
|  | 907 | if (config::DoOutVis < 0) config::DoOutVis = 0; | 
|---|
|  | 908 | if (config::DoOutVis > 1) config::DoOutVis = 1; | 
|---|
|  | 909 | config::VectorPlane = -1; | 
|---|
|  | 910 | config::VectorCut = 0.; | 
|---|
|  | 911 | ParseForParameter(verbose,file,"DoOutMes", 0, 1, 1, int_type, &(config::DoOutMes), 1, critical); | 
|---|
|  | 912 | if (config::DoOutMes < 0) config::DoOutMes = 0; | 
|---|
|  | 913 | if (config::DoOutMes > 1) config::DoOutMes = 1; | 
|---|
|  | 914 | config::DoOutCurrent = 0; | 
|---|
|  | 915 | ParseForParameter(verbose,file,"AddGramSch", 0, 1, 1, int_type, &(config::UseAddGramSch), 1, critical); | 
|---|
|  | 916 | if (config::UseAddGramSch < 0) config::UseAddGramSch = 0; | 
|---|
|  | 917 | if (config::UseAddGramSch > 2) config::UseAddGramSch = 2; | 
|---|
|  | 918 | config::CommonWannier = 0; | 
|---|
|  | 919 | config::SawtoothStart = 0.01; | 
|---|
|  | 920 |  | 
|---|
|  | 921 | ParseForParameter(verbose,file,"MaxOuterStep", 0, 1, 1, double_type, &(config::MaxOuterStep), 1, critical); | 
|---|
|  | 922 | ParseForParameter(verbose,file,"Deltat", 0, 1, 1, double_type, &(config::Deltat), 1, optional); | 
|---|
|  | 923 | ParseForParameter(verbose,file,"VisOuterStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); | 
|---|
|  | 924 | ParseForParameter(verbose,file,"VisSrcOuterStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional); | 
|---|
|  | 925 | ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &(config::TargetTemp), 1, optional); | 
|---|
|  | 926 | ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional); | 
|---|
|  | 927 | config::EpsWannier = 1e-8; | 
|---|
|  | 928 |  | 
|---|
|  | 929 | // stop conditions | 
|---|
|  | 930 | //if (config::MaxOuterStep <= 0) config::MaxOuterStep = 1; | 
|---|
|  | 931 | ParseForParameter(verbose,file,"MaxPsiStep", 0, 1, 1, int_type, &(config::MaxPsiStep), 1, critical); | 
|---|
|  | 932 | if (config::MaxPsiStep <= 0) config::MaxPsiStep = 3; | 
|---|
|  | 933 |  | 
|---|
|  | 934 | ParseForParameter(verbose,file,"MaxMinStep", 0, 1, 1, int_type, &(config::MaxMinStep), 1, critical); | 
|---|
|  | 935 | ParseForParameter(verbose,file,"MaxMinStep", 0, 2, 1, double_type, &(config::RelEpsTotalEnergy), 1, critical); | 
|---|
|  | 936 | ParseForParameter(verbose,file,"MaxMinStep", 0, 3, 1, double_type, &(config::RelEpsKineticEnergy), 1, critical); | 
|---|
|  | 937 | ParseForParameter(verbose,file,"MaxMinStep", 0, 4, 1, int_type, &(config::MaxMinStopStep), 1, critical); | 
|---|
|  | 938 | if (config::MaxMinStep <= 0) config::MaxMinStep = config::MaxPsiStep; | 
|---|
|  | 939 | if (config::MaxMinStopStep < 1) config::MaxMinStopStep = 1; | 
|---|
|  | 940 | config::MaxMinGapStopStep = 1; | 
|---|
|  | 941 |  | 
|---|
|  | 942 | ParseForParameter(verbose,file,"MaxInitMinStep", 0, 1, 1, int_type, &(config::MaxInitMinStep), 1, critical); | 
|---|
|  | 943 | ParseForParameter(verbose,file,"MaxInitMinStep", 0, 2, 1, double_type, &(config::InitRelEpsTotalEnergy), 1, critical); | 
|---|
|  | 944 | ParseForParameter(verbose,file,"MaxInitMinStep", 0, 3, 1, double_type, &(config::InitRelEpsKineticEnergy), 1, critical); | 
|---|
|  | 945 | ParseForParameter(verbose,file,"MaxInitMinStep", 0, 4, 1, int_type, &(config::InitMaxMinStopStep), 1, critical); | 
|---|
|  | 946 | if (config::MaxInitMinStep <= 0) config::MaxInitMinStep = config::MaxPsiStep; | 
|---|
|  | 947 | if (config::InitMaxMinStopStep < 1) config::InitMaxMinStopStep = 1; | 
|---|
|  | 948 | config::InitMaxMinGapStopStep = 1; | 
|---|
|  | 949 |  | 
|---|
|  | 950 | ParseForParameter(verbose,file, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ | 
|---|
|  | 951 | mol->cell_size[0] = BoxLength[0]; | 
|---|
|  | 952 | mol->cell_size[1] = BoxLength[3]; | 
|---|
|  | 953 | mol->cell_size[2] = BoxLength[4]; | 
|---|
|  | 954 | mol->cell_size[3] = BoxLength[6]; | 
|---|
|  | 955 | mol->cell_size[4] = BoxLength[7]; | 
|---|
|  | 956 | mol->cell_size[5] = BoxLength[8]; | 
|---|
|  | 957 | if (1) fprintf(stderr,"\n"); | 
|---|
|  | 958 | config::DoPerturbation = 0; | 
|---|
|  | 959 | config::DoFullCurrent = 0; | 
|---|
|  | 960 |  | 
|---|
|  | 961 | ParseForParameter(verbose,file,"ECut", 0, 1, 1, double_type, &(config::ECut), 1, critical); | 
|---|
|  | 962 | ParseForParameter(verbose,file,"MaxLevel", 0, 1, 1, int_type, &(config::MaxLevel), 1, critical); | 
|---|
|  | 963 | ParseForParameter(verbose,file,"Level0Factor", 0, 1, 1, int_type, &(config::Lev0Factor), 1, critical); | 
|---|
|  | 964 | if (config::Lev0Factor < 2) { | 
|---|
|  | 965 | config::Lev0Factor = 2; | 
|---|
|  | 966 | } | 
|---|
|  | 967 | ParseForParameter(verbose,file,"RiemannTensor", 0, 1, 1, int_type, &di, 1, critical); | 
|---|
|  | 968 | if (di >= 0 && di < 2) { | 
|---|
|  | 969 | config::RiemannTensor = di; | 
|---|
|  | 970 | } else { | 
|---|
|  | 971 | fprintf(stderr, "0 <= RiemanTensor < 2: 0 UseNotRT, 1 UseRT"); | 
|---|
|  | 972 | exit(1); | 
|---|
|  | 973 | } | 
|---|
|  | 974 | switch (config::RiemannTensor) { | 
|---|
|  | 975 | case 0: //UseNoRT | 
|---|
|  | 976 | if (config::MaxLevel < 2) { | 
|---|
|  | 977 | config::MaxLevel = 2; | 
|---|
|  | 978 | } | 
|---|
|  | 979 | config::LevRFactor = 2; | 
|---|
|  | 980 | config::RTActualUse = 0; | 
|---|
|  | 981 | break; | 
|---|
|  | 982 | case 1: // UseRT | 
|---|
|  | 983 | if (config::MaxLevel < 3) { | 
|---|
|  | 984 | config::MaxLevel = 3; | 
|---|
|  | 985 | } | 
|---|
|  | 986 | ParseForParameter(verbose,file,"RiemannLevel", 0, 1, 1, int_type, &(config::RiemannLevel), 1, critical); | 
|---|
|  | 987 | if (config::RiemannLevel < 2) { | 
|---|
|  | 988 | config::RiemannLevel = 2; | 
|---|
|  | 989 | } | 
|---|
|  | 990 | if (config::RiemannLevel > config::MaxLevel-1) { | 
|---|
|  | 991 | config::RiemannLevel = config::MaxLevel-1; | 
|---|
|  | 992 | } | 
|---|
|  | 993 | ParseForParameter(verbose,file,"LevRFactor", 0, 1, 1, int_type, &(config::LevRFactor), 1, critical); | 
|---|
|  | 994 | if (config::LevRFactor < 2) { | 
|---|
|  | 995 | config::LevRFactor = 2; | 
|---|
|  | 996 | } | 
|---|
|  | 997 | config::Lev0Factor = 2; | 
|---|
|  | 998 | config::RTActualUse = 2; | 
|---|
|  | 999 | break; | 
|---|
|  | 1000 | } | 
|---|
|  | 1001 | ParseForParameter(verbose,file,"PsiType", 0, 1, 1, int_type, &di, 1, critical); | 
|---|
|  | 1002 | if (di >= 0 && di < 2) { | 
|---|
|  | 1003 | config::PsiType = di; | 
|---|
|  | 1004 | } else { | 
|---|
|  | 1005 | fprintf(stderr, "0 <= PsiType < 2: 0 UseSpinDouble, 1 UseSpinUpDown"); | 
|---|
|  | 1006 | exit(1); | 
|---|
|  | 1007 | } | 
|---|
|  | 1008 | switch (config::PsiType) { | 
|---|
|  | 1009 | case 0: // SpinDouble | 
|---|
|  | 1010 | ParseForParameter(verbose,file,"MaxPsiDouble", 0, 1, 1, int_type, &(config::MaxPsiDouble), 1, critical); | 
|---|
|  | 1011 | config::AddPsis = 0; | 
|---|
|  | 1012 | break; | 
|---|
|  | 1013 | case 1: // SpinUpDown | 
|---|
|  | 1014 | if (config::ProcPEGamma % 2) config::ProcPEGamma*=2; | 
|---|
|  | 1015 | ParseForParameter(verbose,file,"MaxPsiUp", 0, 1, 1, int_type, &(config::PsiMaxNoUp), 1, critical); | 
|---|
|  | 1016 | ParseForParameter(verbose,file,"MaxPsiDown", 0, 1, 1, int_type, &(config::PsiMaxNoDown), 1, critical); | 
|---|
|  | 1017 | config::AddPsis = 0; | 
|---|
|  | 1018 | break; | 
|---|
|  | 1019 | } | 
|---|
|  | 1020 |  | 
|---|
|  | 1021 | // IonsInitRead | 
|---|
|  | 1022 |  | 
|---|
|  | 1023 | ParseForParameter(verbose,file,"RCut", 0, 1, 1, double_type, &(config::RCut), 1, critical); | 
|---|
|  | 1024 | ParseForParameter(verbose,file,"IsAngstroem", 0, 1, 1, int_type, &(config::IsAngstroem), 1, critical); | 
|---|
|  | 1025 | config::RelativeCoord = 0; | 
|---|
|  | 1026 | config::StructOpt = 0; | 
|---|
|  | 1027 |  | 
|---|
|  | 1028 | // Routine from builder.cpp | 
|---|
|  | 1029 |  | 
|---|
|  | 1030 |  | 
|---|
| [7f3b9d] | 1031 | for (i=MAX_ELEMENTS;i--;) | 
|---|
|  | 1032 | elementhash[i] = NULL; | 
|---|
| [14de469] | 1033 | cout << Verbose(0) << "Parsing Ions ..." << endl; | 
|---|
|  | 1034 | No=0; | 
|---|
|  | 1035 | found = 0; | 
|---|
|  | 1036 | while (getline(*file,zeile,'\n')) { | 
|---|
|  | 1037 | if (zeile.find("Ions_Data") == 0) { | 
|---|
|  | 1038 | cout << Verbose(1) << "found Ions_Data...begin parsing" << endl; | 
|---|
|  | 1039 | found ++; | 
|---|
|  | 1040 | } | 
|---|
|  | 1041 | if (found > 0) { | 
|---|
|  | 1042 | if (zeile.find("Ions_Data") == 0) | 
|---|
|  | 1043 | getline(*file,zeile,'\n'); // read next line and parse this one | 
|---|
|  | 1044 | istringstream input(zeile); | 
|---|
|  | 1045 | input >> AtomNo;  // number of atoms | 
|---|
|  | 1046 | input >> Z;       // atomic number | 
|---|
|  | 1047 | input >> a; | 
|---|
|  | 1048 | input >> l; | 
|---|
|  | 1049 | input >> l; | 
|---|
|  | 1050 | input >> b;     // element mass | 
|---|
|  | 1051 | elementhash[No] = periode->FindElement(Z); | 
|---|
|  | 1052 | cout << Verbose(1) << "AtomNo: " << AtomNo << "\tZ: " << Z << "\ta:" << a << "\tl:"  << l << "\b:" << b << "\tElement:" << elementhash[No] << "\t:" << endl; | 
|---|
|  | 1053 | for(i=0;i<AtomNo;i++) { | 
|---|
|  | 1054 | if (!getline(*file,zeile,'\n')) {// parse on and on | 
|---|
|  | 1055 | cout << Verbose(2) << "Error: Too few items in ionic list of element" << elementhash[No] << "." << endl << "Exiting." << endl; | 
|---|
|  | 1056 | // return 1; | 
|---|
|  | 1057 | } else { | 
|---|
|  | 1058 | //cout << Verbose(2) << "Reading line: " << zeile << endl; | 
|---|
|  | 1059 | } | 
|---|
|  | 1060 | istringstream input2(zeile); | 
|---|
|  | 1061 | atom *neues = new atom(); | 
|---|
|  | 1062 | input2 >> neues->x.x[0]; // x | 
|---|
|  | 1063 | input2 >> neues->x.x[1]; // y | 
|---|
|  | 1064 | input2 >> neues->x.x[2]; // z | 
|---|
|  | 1065 | input2 >> l; | 
|---|
|  | 1066 | neues->type = elementhash[No]; // find element type | 
|---|
|  | 1067 | mol->AddAtom(neues); | 
|---|
|  | 1068 | } | 
|---|
|  | 1069 | No++; | 
|---|
|  | 1070 | } | 
|---|
|  | 1071 | } | 
|---|
| [5b15ab] | 1072 | file->close(); | 
|---|
|  | 1073 | delete(file); | 
|---|
| [14de469] | 1074 | }; | 
|---|
|  | 1075 |  | 
|---|
|  | 1076 | /** Stores all elements of config structure from which they can be re-read. | 
|---|
| [9a5bcd] | 1077 | * \param *filename name of file | 
|---|
| [14de469] | 1078 | * \param *periode pointer to a periodentafel class with all elements | 
|---|
|  | 1079 | * \param *mol pointer to molecule containing all atoms of the molecule | 
|---|
|  | 1080 | */ | 
|---|
| [9a5bcd] | 1081 | bool config::Save(const char *filename, periodentafel *periode, molecule *mol) const | 
|---|
| [14de469] | 1082 | { | 
|---|
|  | 1083 | bool result = true; | 
|---|
| [ce5ac3] | 1084 | // bring MaxTypes up to date | 
|---|
|  | 1085 | mol->CountElements(); | 
|---|
| [9a5bcd] | 1086 | ofstream *output = NULL; | 
|---|
|  | 1087 | output = new ofstream(filename, ios::out); | 
|---|
| [14de469] | 1088 | if (output != NULL) { | 
|---|
|  | 1089 | *output << "# ParallelCarParinello - main configuration file - created with molecuilder" << endl; | 
|---|
|  | 1090 | *output << endl; | 
|---|
|  | 1091 | *output << "mainname\t" << config::mainname << "\t# programm name (for runtime files)" << endl; | 
|---|
|  | 1092 | *output << "defaultpath\t" << config::defaultpath << "\t# where to put files during runtime" << endl; | 
|---|
|  | 1093 | *output << "pseudopotpath\t" << config::pseudopotpath << "\t# where to find pseudopotentials" << endl; | 
|---|
|  | 1094 | *output << endl; | 
|---|
|  | 1095 | *output << "ProcPEGamma\t" << config::ProcPEGamma << "\t# for parallel computing: share constants" << endl; | 
|---|
|  | 1096 | *output << "ProcPEPsi\t" << config::ProcPEPsi << "\t# for parallel computing: share wave functions" << endl; | 
|---|
|  | 1097 | *output << "DoOutVis\t" << config::DoOutVis << "\t# Output data for OpenDX" << endl; | 
|---|
|  | 1098 | *output << "DoOutMes\t" << config::DoOutMes << "\t# Output data for measurements" << endl; | 
|---|
|  | 1099 | *output << "DoOutOrbitals\t" << config::DoOutOrbitals << "\t# Output all Orbitals" << endl; | 
|---|
|  | 1100 | *output << "DoOutCurr\t" << config::DoOutCurrent << "\t# Ouput current density for OpenDx" << endl; | 
|---|
|  | 1101 | *output << "DoOutNICS\t" << config::DoOutNICS << "\t# Output Nucleus independent current shieldings" << endl; | 
|---|
|  | 1102 | *output << "DoPerturbation\t" << config::DoPerturbation << "\t# Do perturbation calculate and determine susceptibility and shielding" << endl; | 
|---|
|  | 1103 | *output << "DoFullCurrent\t" << config::DoFullCurrent << "\t# Do full perturbation" << endl; | 
|---|
| [a1fe77] | 1104 | *output << "DoConstrainedMD\t" << config::DoConstrainedMD << "\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD" << endl; | 
|---|
| [62f793] | 1105 | *output << "Thermostat\t" << ThermostatNames[Thermostat] << "\t"; | 
|---|
|  | 1106 | switch(Thermostat) { | 
|---|
|  | 1107 | default: | 
|---|
|  | 1108 | case None: | 
|---|
|  | 1109 | break; | 
|---|
|  | 1110 | case Woodcock: | 
|---|
|  | 1111 | *output << ScaleTempStep; | 
|---|
|  | 1112 | break; | 
|---|
|  | 1113 | case Gaussian: | 
|---|
|  | 1114 | *output << ScaleTempStep; | 
|---|
|  | 1115 | break; | 
|---|
|  | 1116 | case Langevin: | 
|---|
|  | 1117 | *output << TempFrequency << "\t" << alpha; | 
|---|
|  | 1118 | break; | 
|---|
|  | 1119 | case Berendsen: | 
|---|
|  | 1120 | *output << TempFrequency; | 
|---|
|  | 1121 | break; | 
|---|
|  | 1122 | case NoseHoover: | 
|---|
|  | 1123 | *output << HooverMass; | 
|---|
|  | 1124 | break; | 
|---|
|  | 1125 | }; | 
|---|
|  | 1126 | *output << "\t# Which Thermostat and its parameters to use in MD case." << endl; | 
|---|
| [14de469] | 1127 | *output << "CommonWannier\t" << config::CommonWannier << "\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center" << endl; | 
|---|
|  | 1128 | *output << "SawtoothStart\t" << config::SawtoothStart << "\t# Absolute value for smooth transition at cell border " << endl; | 
|---|
|  | 1129 | *output << "VectorPlane\t" << config::VectorPlane << "\t# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot" << endl; | 
|---|
|  | 1130 | *output << "VectorCut\t" << config::VectorCut << "\t# Cut plane axis value" << endl; | 
|---|
|  | 1131 | *output << "AddGramSch\t" << config::UseAddGramSch << "\t# Additional GramSchmidtOrtogonalization to be safe" << endl; | 
|---|
|  | 1132 | *output << "Seed\t\t" << config::Seed << "\t# initial value for random seed for Psi coefficients" << endl; | 
|---|
|  | 1133 | *output << endl; | 
|---|
|  | 1134 | *output << "MaxOuterStep\t" << config::MaxOuterStep << "\t# number of MolecularDynamics/Structure optimization steps" << endl; | 
|---|
|  | 1135 | *output << "Deltat\t" << config::Deltat << "\t# time per MD step" << endl; | 
|---|
|  | 1136 | *output << "OutVisStep\t" << config::OutVisStep << "\t# Output visual data every ...th step" << endl; | 
|---|
|  | 1137 | *output << "OutSrcStep\t" << config::OutSrcStep << "\t# Output \"restart\" data every ..th step" << endl; | 
|---|
|  | 1138 | *output << "TargetTemp\t" << config::TargetTemp << "\t# Target temperature" << endl; | 
|---|
|  | 1139 | *output << "MaxPsiStep\t" << config::MaxPsiStep << "\t# number of Minimisation steps per state (0 - default)" << endl; | 
|---|
|  | 1140 | *output << "EpsWannier\t" << config::EpsWannier << "\t# tolerance value for spread minimisation of orbitals" << endl; | 
|---|
|  | 1141 | *output << endl; | 
|---|
|  | 1142 | *output << "# Values specifying when to stop" << endl; | 
|---|
|  | 1143 | *output << "MaxMinStep\t" << config::MaxMinStep << "\t# Maximum number of steps" << endl; | 
|---|
|  | 1144 | *output << "RelEpsTotalE\t" << config::RelEpsTotalEnergy << "\t# relative change in total energy" << endl; | 
|---|
|  | 1145 | *output << "RelEpsKineticE\t" << config::RelEpsKineticEnergy << "\t# relative change in kinetic energy" << endl; | 
|---|
|  | 1146 | *output << "MaxMinStopStep\t" << config::MaxMinStopStep << "\t# check every ..th steps" << endl; | 
|---|
|  | 1147 | *output << "MaxMinGapStopStep\t" << config::MaxMinGapStopStep << "\t# check every ..th steps" << endl; | 
|---|
|  | 1148 | *output << endl; | 
|---|
|  | 1149 | *output << "# Values specifying when to stop for INIT, otherwise same as above" << endl; | 
|---|
|  | 1150 | *output << "MaxInitMinStep\t" << config::MaxInitMinStep << "\t# Maximum number of steps" << endl; | 
|---|
|  | 1151 | *output << "InitRelEpsTotalE\t" << config::InitRelEpsTotalEnergy << "\t# relative change in total energy" << endl; | 
|---|
|  | 1152 | *output << "InitRelEpsKineticE\t" << config::InitRelEpsKineticEnergy << "\t# relative change in kinetic energy" << endl; | 
|---|
|  | 1153 | *output << "InitMaxMinStopStep\t" << config::InitMaxMinStopStep << "\t# check every ..th steps" << endl; | 
|---|
|  | 1154 | *output << "InitMaxMinGapStopStep\t" << config::InitMaxMinGapStopStep << "\t# check every ..th steps" << endl; | 
|---|
|  | 1155 | *output << endl; | 
|---|
|  | 1156 | *output << "BoxLength\t\t\t# (Length of a unit cell)" << endl; | 
|---|
|  | 1157 | *output << mol->cell_size[0] << "\t" << endl; | 
|---|
|  | 1158 | *output << mol->cell_size[1] << "\t" << mol->cell_size[2] << "\t" << endl; | 
|---|
|  | 1159 | *output << mol->cell_size[3] << "\t" << mol->cell_size[4] << "\t" << mol->cell_size[5] << "\t" << endl; | 
|---|
|  | 1160 | // FIXME | 
|---|
|  | 1161 | *output << endl; | 
|---|
|  | 1162 | *output << "ECut\t\t" << config::ECut << "\t# energy cutoff for discretization in Hartrees" << endl; | 
|---|
|  | 1163 | *output << "MaxLevel\t" << config::MaxLevel << "\t# number of different levels in the code, >=2" << endl; | 
|---|
|  | 1164 | *output << "Level0Factor\t" << config::Lev0Factor << "\t# factor by which node number increases from S to 0 level" << endl; | 
|---|
|  | 1165 | *output << "RiemannTensor\t" << config::RiemannTensor << "\t# (Use metric)" << endl; | 
|---|
|  | 1166 | switch (config::RiemannTensor) { | 
|---|
|  | 1167 | case 0: //UseNoRT | 
|---|
|  | 1168 | break; | 
|---|
|  | 1169 | case 1: // UseRT | 
|---|
|  | 1170 | *output << "RiemannLevel\t" << config::RiemannLevel << "\t# Number of Riemann Levels" << endl; | 
|---|
|  | 1171 | *output << "LevRFactor\t" << config::LevRFactor << "\t# factor by which node number increases from 0 to R level from" << endl; | 
|---|
|  | 1172 | break; | 
|---|
|  | 1173 | } | 
|---|
|  | 1174 | *output << "PsiType\t\t" << config::PsiType << "\t# 0 - doubly occupied, 1 - SpinUp,SpinDown" << endl; | 
|---|
|  | 1175 | // write out both types for easier changing afterwards | 
|---|
|  | 1176 | //  switch (PsiType) { | 
|---|
|  | 1177 | //    case 0: | 
|---|
|  | 1178 | *output << "MaxPsiDouble\t" << config::MaxPsiDouble << "\t# here: specifying both maximum number of SpinUp- and -Down-states" << endl; | 
|---|
|  | 1179 | //      break; | 
|---|
|  | 1180 | //    case 1: | 
|---|
|  | 1181 | *output << "PsiMaxNoUp\t" << config::PsiMaxNoUp << "\t# here: specifying maximum number of SpinUp-states" << endl; | 
|---|
|  | 1182 | *output << "PsiMaxNoDown\t" << config::PsiMaxNoDown << "\t# here: specifying maximum number of SpinDown-states" << endl; | 
|---|
|  | 1183 | //      break; | 
|---|
|  | 1184 | //  } | 
|---|
|  | 1185 | *output << "AddPsis\t\t" << config::AddPsis << "\t# Additional unoccupied Psis for bandgap determination" << endl; | 
|---|
|  | 1186 | *output << endl; | 
|---|
|  | 1187 | *output << "RCut\t\t" << config::RCut << "\t# R-cut for the ewald summation" << endl; | 
|---|
|  | 1188 | *output << "StructOpt\t" << config::StructOpt << "\t# Do structure optimization beforehand" << endl; | 
|---|
|  | 1189 | *output << "IsAngstroem\t" << config::IsAngstroem << "\t# 0 - Bohr, 1 - Angstroem" << endl; | 
|---|
|  | 1190 | *output << "RelativeCoord\t" << config::RelativeCoord << "\t# whether ion coordinates are relative (1) or absolute (0)" << endl; | 
|---|
|  | 1191 | *output << "MaxTypes\t" << mol->ElementCount <<  "\t# maximum number of different ion types" << endl; | 
|---|
|  | 1192 | *output << endl; | 
|---|
|  | 1193 | result = result && mol->Checkout(output); | 
|---|
| [362b0e] | 1194 | if (mol->MDSteps <=1 ) | 
|---|
|  | 1195 | result = result && mol->Output(output); | 
|---|
|  | 1196 | else | 
|---|
|  | 1197 | result = result && mol->OutputTrajectories(output); | 
|---|
| [9a5bcd] | 1198 | output->close(); | 
|---|
|  | 1199 | output->clear(); | 
|---|
|  | 1200 | delete(output); | 
|---|
| [14de469] | 1201 | return result; | 
|---|
|  | 1202 | } else | 
|---|
|  | 1203 | return false; | 
|---|
|  | 1204 | }; | 
|---|
|  | 1205 |  | 
|---|
| [6b8b57] | 1206 | /** Stores all elements in a MPQC input file. | 
|---|
|  | 1207 | * Note that this format cannot be parsed again. | 
|---|
| [9a5bcd] | 1208 | * \param *filename name of file (without ".in" suffix!) | 
|---|
| [6b8b57] | 1209 | * \param *mol pointer to molecule containing all atoms of the molecule | 
|---|
|  | 1210 | */ | 
|---|
| [9a5bcd] | 1211 | bool config::SaveMPQC(const char *filename, molecule *mol) const | 
|---|
| [6b8b57] | 1212 | { | 
|---|
| [a6b7fb] | 1213 | int ElementNo = 0; | 
|---|
| [6b8b57] | 1214 | int AtomNo; | 
|---|
|  | 1215 | atom *Walker = NULL; | 
|---|
| [9a5bcd] | 1216 | element *runner = NULL; | 
|---|
| [a6b7fb] | 1217 | Vector *center = NULL; | 
|---|
| [9a5bcd] | 1218 | ofstream *output = NULL; | 
|---|
|  | 1219 | stringstream *fname = NULL; | 
|---|
|  | 1220 |  | 
|---|
|  | 1221 | // first without hessian | 
|---|
|  | 1222 | fname = new stringstream; | 
|---|
|  | 1223 | *fname << filename << ".in"; | 
|---|
|  | 1224 | output = new ofstream(fname->str().c_str(), ios::out); | 
|---|
|  | 1225 | *output << "% Created by MoleCuilder" << endl; | 
|---|
|  | 1226 | *output << "mpqc: (" << endl; | 
|---|
|  | 1227 | *output << "\tsavestate = no" << endl; | 
|---|
|  | 1228 | *output << "\tdo_gradient = yes" << endl; | 
|---|
|  | 1229 | *output << "\tmole<CLHF>: (" << endl; | 
|---|
|  | 1230 | *output << "\t\tmaxiter = 200" << endl; | 
|---|
|  | 1231 | *output << "\t\tbasis = $:basis" << endl; | 
|---|
|  | 1232 | *output << "\t\tmolecule = $:molecule" << endl; | 
|---|
|  | 1233 | *output << "\t)" << endl; | 
|---|
|  | 1234 | *output << ")" << endl; | 
|---|
|  | 1235 | *output << "molecule<Molecule>: (" << endl; | 
|---|
|  | 1236 | *output << "\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl; | 
|---|
|  | 1237 | *output << "\t{ atoms geometry } = {" << endl; | 
|---|
|  | 1238 | center = mol->DetermineCenterOfAll(output); | 
|---|
|  | 1239 | // output of atoms | 
|---|
|  | 1240 | runner = mol->elemente->start; | 
|---|
|  | 1241 | while (runner->next != mol->elemente->end) { // go through every element | 
|---|
|  | 1242 | runner = runner->next; | 
|---|
|  | 1243 | if (mol->ElementsInMolecule[runner->Z]) { // if this element got atoms | 
|---|
|  | 1244 | ElementNo++; | 
|---|
|  | 1245 | AtomNo = 0; | 
|---|
|  | 1246 | Walker = mol->start; | 
|---|
|  | 1247 | while (Walker->next != mol->end) { // go through every atom of this element | 
|---|
|  | 1248 | Walker = Walker->next; | 
|---|
|  | 1249 | if (Walker->type == runner) { // if this atom fits to element | 
|---|
|  | 1250 | AtomNo++; | 
|---|
|  | 1251 | *output << "\t\t" << Walker->type->symbol << " [ " << Walker->x.x[0]-center->x[0] << "\t" << Walker->x.x[1]-center->x[1] << "\t" << Walker->x.x[2]-center->x[2] << " ]" << endl; | 
|---|
|  | 1252 | } | 
|---|
|  | 1253 | } | 
|---|
|  | 1254 | } | 
|---|
|  | 1255 | } | 
|---|
|  | 1256 | delete(center); | 
|---|
|  | 1257 | *output << "\t}" << endl; | 
|---|
|  | 1258 | *output << ")" << endl; | 
|---|
|  | 1259 | *output << "basis<GaussianBasisSet>: (" << endl; | 
|---|
| [2746be] | 1260 | *output << "\tname = \"" << basis << "\"" << endl; | 
|---|
| [9a5bcd] | 1261 | *output << "\tmolecule = $:molecule" << endl; | 
|---|
|  | 1262 | *output << ")" << endl; | 
|---|
|  | 1263 | output->close(); | 
|---|
|  | 1264 | delete(output); | 
|---|
|  | 1265 | delete(fname); | 
|---|
| [6b8b57] | 1266 |  | 
|---|
| [9a5bcd] | 1267 | // second with hessian | 
|---|
|  | 1268 | fname = new stringstream; | 
|---|
|  | 1269 | *fname << filename << ".hess.in"; | 
|---|
|  | 1270 | output = new ofstream(fname->str().c_str(), ios::out); | 
|---|
| [6b8b57] | 1271 | *output << "% Created by MoleCuilder" << endl; | 
|---|
|  | 1272 | *output << "mpqc: (" << endl; | 
|---|
|  | 1273 | *output << "\tsavestate = no" << endl; | 
|---|
|  | 1274 | *output << "\tdo_gradient = yes" << endl; | 
|---|
|  | 1275 | *output << "\tmole<CLHF>: (" << endl; | 
|---|
| [ec7ba8] | 1276 | *output << "\t\tmaxiter = 200" << endl; | 
|---|
|  | 1277 | *output << "\t\tbasis = $:basis" << endl; | 
|---|
|  | 1278 | *output << "\t\tmolecule = $:molecule" << endl; | 
|---|
|  | 1279 | *output << "\t)" << endl; | 
|---|
| [9a5bcd] | 1280 | *output << "\tfreq<MolecularFrequencies>: (" << endl; | 
|---|
|  | 1281 | *output << "\t\tmolecule=$:molecule" << endl; | 
|---|
|  | 1282 | *output << "\t)" << endl; | 
|---|
| [ec7ba8] | 1283 | *output << ")" << endl; | 
|---|
|  | 1284 | *output << "molecule<Molecule>: (" << endl; | 
|---|
|  | 1285 | *output << "\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl; | 
|---|
|  | 1286 | *output << "\t{ atoms geometry } = {" << endl; | 
|---|
| [a6b7fb] | 1287 | center = mol->DetermineCenterOfAll(output); | 
|---|
| [6b8b57] | 1288 | // output of atoms | 
|---|
| [9a5bcd] | 1289 | runner = mol->elemente->start; | 
|---|
| [6b8b57] | 1290 | while (runner->next != mol->elemente->end) { // go through every element | 
|---|
|  | 1291 | runner = runner->next; | 
|---|
|  | 1292 | if (mol->ElementsInMolecule[runner->Z]) { // if this element got atoms | 
|---|
|  | 1293 | ElementNo++; | 
|---|
|  | 1294 | AtomNo = 0; | 
|---|
|  | 1295 | Walker = mol->start; | 
|---|
|  | 1296 | while (Walker->next != mol->end) { // go through every atom of this element | 
|---|
|  | 1297 | Walker = Walker->next; | 
|---|
|  | 1298 | if (Walker->type == runner) { // if this atom fits to element | 
|---|
|  | 1299 | AtomNo++; | 
|---|
| [ec7ba8] | 1300 | *output << "\t\t" << Walker->type->symbol << " [ " << Walker->x.x[0]-center->x[0] << "\t" << Walker->x.x[1]-center->x[1] << "\t" << Walker->x.x[2]-center->x[2] << " ]" << endl; | 
|---|
| [6b8b57] | 1301 | } | 
|---|
|  | 1302 | } | 
|---|
|  | 1303 | } | 
|---|
|  | 1304 | } | 
|---|
| [a6b7fb] | 1305 | delete(center); | 
|---|
| [ec7ba8] | 1306 | *output << "\t}" << endl; | 
|---|
|  | 1307 | *output << ")" << endl; | 
|---|
|  | 1308 | *output << "basis<GaussianBasisSet>: (" << endl; | 
|---|
|  | 1309 | *output << "\tname = \"3-21G\"" << endl; | 
|---|
|  | 1310 | *output << "\tmolecule = $:molecule" << endl; | 
|---|
| [6b8b57] | 1311 | *output << ")" << endl; | 
|---|
| [9a5bcd] | 1312 | output->close(); | 
|---|
|  | 1313 | delete(output); | 
|---|
|  | 1314 | delete(fname); | 
|---|
|  | 1315 |  | 
|---|
| [6b8b57] | 1316 | return true; | 
|---|
|  | 1317 | }; | 
|---|
|  | 1318 |  | 
|---|
| [14de469] | 1319 | /** Reads parameter from a parsed file. | 
|---|
|  | 1320 | * The file is either parsed for a certain keyword or if null is given for | 
|---|
|  | 1321 | * the value in row yth and column xth. If the keyword was necessity#critical, | 
|---|
|  | 1322 | * then an error is thrown and the programme aborted. | 
|---|
|  | 1323 | * \warning value is modified (both in contents and position)! | 
|---|
|  | 1324 | * \param verbose 1 - print found value to stderr, 0 - don't | 
|---|
|  | 1325 | * \param file file to be parsed | 
|---|
|  | 1326 | * \param name Name of value in file (at least 3 chars!) | 
|---|
|  | 1327 | * \param sequential 1 - do not reset file pointer to begin of file, 0 - set to beginning | 
|---|
|  | 1328 | *        (if file is sequentially parsed this can be way faster! However, beware of multiple values per line, as whole line is read - | 
|---|
|  | 1329 | *         best approach: 0 0 0 1 (not resetted only on last value of line) - and of yth, which is now | 
|---|
|  | 1330 | *         counted from this unresetted position!) | 
|---|
|  | 1331 | * \param xth Which among a number of parameters it is (in grid case it's row number as grid is read as a whole!) | 
|---|
|  | 1332 | * \param yth In grid case specifying column number, otherwise the yth \a name matching line | 
|---|
|  | 1333 | * \param type Type of the Parameter to be read | 
|---|
|  | 1334 | * \param value address of the value to be read (must have been allocated) | 
|---|
|  | 1335 | * \param repetition determines, if the keyword appears multiply in the config file, which repetition shall be parsed, i.e. 1 if not multiply | 
|---|
|  | 1336 | * \param critical necessity of this keyword being specified (optional, critical) | 
|---|
|  | 1337 | * \return 1 - found, 0 - not found | 
|---|
|  | 1338 | * \note Routine is taken from the pcp project and hack-a-slack adapted to C++ | 
|---|
|  | 1339 | */ | 
|---|
|  | 1340 | int config::ParseForParameter(int verbose, ifstream *file, const char *name, int sequential, int const xth, int const yth, int type, void *value, int repetition, int critical) { | 
|---|
|  | 1341 | int i,j;  // loop variables | 
|---|
|  | 1342 | int length = 0, maxlength = -1; | 
|---|
|  | 1343 | long file_position = file->tellg(); // mark current position | 
|---|
|  | 1344 | char *dummy1, *dummy, *free_dummy;    // pointers in the line that is read in per step | 
|---|
|  | 1345 | dummy1 = free_dummy = (char *) Malloc(256 * sizeof(char), "config::ParseForParameter: *free_dummy"); | 
|---|
|  | 1346 |  | 
|---|
|  | 1347 | //fprintf(stderr,"Parsing for %s\n",name); | 
|---|
|  | 1348 | if (repetition == 0) | 
|---|
|  | 1349 | //Error(SomeError, "ParseForParameter(): argument repetition must not be 0!"); | 
|---|
|  | 1350 | return 0; | 
|---|
|  | 1351 |  | 
|---|
|  | 1352 | int line = 0; // marks line where parameter was found | 
|---|
|  | 1353 | int found = (type >= grid) ? 0 : (-yth + 1);  // marks if yth parameter name was found | 
|---|
|  | 1354 | while((found != repetition)) { | 
|---|
|  | 1355 | dummy1 = dummy = free_dummy; | 
|---|
|  | 1356 | do { | 
|---|
|  | 1357 | file->getline(dummy1, 256); // Read the whole line | 
|---|
|  | 1358 | if (file->eof()) { | 
|---|
|  | 1359 | if ((critical) && (found == 0)) { | 
|---|
|  | 1360 | Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); | 
|---|
|  | 1361 | //Error(InitReading, name); | 
|---|
| [7e27e7] | 1362 | fprintf(stderr,"Error:InitReading, critical %s not found\n", name); | 
|---|
| [14de469] | 1363 | exit(255); | 
|---|
|  | 1364 | } else { | 
|---|
|  | 1365 | //if (!sequential) | 
|---|
|  | 1366 | file->clear(); | 
|---|
|  | 1367 | file->seekg(file_position, ios::beg);  // rewind to start position | 
|---|
|  | 1368 | Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); | 
|---|
|  | 1369 | return 0; | 
|---|
|  | 1370 | } | 
|---|
|  | 1371 | } | 
|---|
|  | 1372 | line++; | 
|---|
| [6b8b57] | 1373 | } while (dummy != NULL && dummy1 != NULL && ((dummy1[0] == '#') || (dummy1[0] == '\0'))); // skip commentary and empty lines | 
|---|
| [14de469] | 1374 |  | 
|---|
|  | 1375 | // C++ getline removes newline at end, thus re-add | 
|---|
|  | 1376 | if ((dummy1 != NULL) && (strchr(dummy1,'\n') == NULL)) { | 
|---|
|  | 1377 | i = strlen(dummy1); | 
|---|
|  | 1378 | dummy1[i] = '\n'; | 
|---|
|  | 1379 | dummy1[i+1] = '\0'; | 
|---|
|  | 1380 | } | 
|---|
| [6b8b57] | 1381 | //fprintf(stderr,"line %i ends at %i, newline at %i\n", line, strlen(dummy1), strchr(dummy1,'\n')-free_dummy); | 
|---|
|  | 1382 |  | 
|---|
| [14de469] | 1383 | if (dummy1 == NULL) { | 
|---|
|  | 1384 | if (verbose) fprintf(stderr,"Error reading line %i\n",line); | 
|---|
|  | 1385 | } else { | 
|---|
| [6b8b57] | 1386 | //fprintf(stderr,"Now parsing the line %i: %s\n", line, dummy1); | 
|---|
| [14de469] | 1387 | } | 
|---|
|  | 1388 | // Seek for possible end of keyword on line if given ... | 
|---|
|  | 1389 | if (name != NULL) { | 
|---|
|  | 1390 | dummy = strchr(dummy1,'\t');  // set dummy on first tab or space which ever's nearer | 
|---|
|  | 1391 | if (dummy == NULL) { | 
|---|
|  | 1392 | dummy = strchr(dummy1, ' ');  // if not found seek for space | 
|---|
|  | 1393 | while ((dummy != NULL) && ((*dummy == '\t') || (*dummy == ' ')))    // skip some more tabs and spaces if necessary | 
|---|
|  | 1394 | dummy++; | 
|---|
|  | 1395 | } | 
|---|
|  | 1396 | if (dummy == NULL) { | 
|---|
|  | 1397 | dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword) | 
|---|
|  | 1398 | //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name); | 
|---|
|  | 1399 | //Free((void **)&free_dummy); | 
|---|
|  | 1400 | //Error(FileOpenParams, NULL); | 
|---|
|  | 1401 | } else { | 
|---|
|  | 1402 | //fprintf(stderr,"found tab at %i\n",(char *)dummy-(char *)dummy1); | 
|---|
|  | 1403 | } | 
|---|
|  | 1404 | } else dummy = dummy1; | 
|---|
|  | 1405 | // ... and check if it is the keyword! | 
|---|
|  | 1406 | //fprintf(stderr,"name %p, dummy %i/%c, dummy1 %i/%c, strlen(name) %i\n", &name, dummy, *dummy, dummy1, *dummy1, strlen(name)); | 
|---|
| [362b0e] | 1407 | if ((name == NULL) || (((dummy-dummy1 >= 3) && (strncmp(dummy1, name, strlen(name)) == 0)) && ((unsigned int)(dummy-dummy1) == strlen(name)))) { | 
|---|
| [14de469] | 1408 | found++; // found the parameter! | 
|---|
|  | 1409 | //fprintf(stderr,"found %s at line %i between %i and %i\n", name, line, dummy1, dummy); | 
|---|
|  | 1410 |  | 
|---|
|  | 1411 | if (found == repetition) { | 
|---|
|  | 1412 | for (i=0;i<xth;i++) { // i = rows | 
|---|
|  | 1413 | if (type >= grid) { | 
|---|
|  | 1414 | // grid structure means that grid starts on the next line, not right after keyword | 
|---|
|  | 1415 | dummy1 = dummy = free_dummy; | 
|---|
|  | 1416 | do { | 
|---|
|  | 1417 | file->getline(dummy1, 256); // Read the whole line, skip commentary and empty ones | 
|---|
|  | 1418 | if (file->eof()) { | 
|---|
|  | 1419 | if ((critical) && (found == 0)) { | 
|---|
|  | 1420 | Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); | 
|---|
|  | 1421 | //Error(InitReading, name); | 
|---|
|  | 1422 | fprintf(stderr,"Error:InitReading, critical %s not found\n", name); | 
|---|
|  | 1423 | exit(255); | 
|---|
|  | 1424 | } else { | 
|---|
|  | 1425 | //if (!sequential) | 
|---|
|  | 1426 | file->clear(); | 
|---|
|  | 1427 | file->seekg(file_position, ios::beg);  // rewind to start position | 
|---|
|  | 1428 | Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); | 
|---|
|  | 1429 | return 0; | 
|---|
|  | 1430 | } | 
|---|
|  | 1431 | } | 
|---|
|  | 1432 | line++; | 
|---|
|  | 1433 | } while ((dummy1[0] == '#') || (dummy1[0] == '\n')); | 
|---|
|  | 1434 | if (dummy1 == NULL){ | 
|---|
|  | 1435 | if (verbose) fprintf(stderr,"Error reading line %i\n", line); | 
|---|
|  | 1436 | } else { | 
|---|
|  | 1437 | //fprintf(stderr,"Reading next line %i: %s\n", line, dummy1); | 
|---|
|  | 1438 | } | 
|---|
|  | 1439 | } else { // simple int, strings or doubles start in the same line | 
|---|
|  | 1440 | while ((*dummy == '\t') || (*dummy == ' '))   // skip interjacent tabs and spaces | 
|---|
|  | 1441 | dummy++; | 
|---|
|  | 1442 | } | 
|---|
|  | 1443 | // C++ getline removes newline at end, thus re-add | 
|---|
|  | 1444 | if ((dummy1 != NULL) && (strchr(dummy1,'\n') == NULL)) { | 
|---|
|  | 1445 | j = strlen(dummy1); | 
|---|
|  | 1446 | dummy1[j] = '\n'; | 
|---|
|  | 1447 | dummy1[j+1] = '\0'; | 
|---|
|  | 1448 | } | 
|---|
|  | 1449 |  | 
|---|
|  | 1450 | int start = (type >= grid) ? 0 : yth-1 ; | 
|---|
|  | 1451 | for (j=start;j<yth;j++) { // j = columns | 
|---|
|  | 1452 | // check for lower triangular area and upper triangular area | 
|---|
|  | 1453 | if ( ((i > j) && (type == upper_trigrid)) || ((j > i) && (type == lower_trigrid))) { | 
|---|
|  | 1454 | *((double *)value) = 0.0; | 
|---|
|  | 1455 | fprintf(stderr,"%f\t",*((double *)value)); | 
|---|
|  | 1456 | value = (void *)((long)value + sizeof(double)); | 
|---|
|  | 1457 | //value += sizeof(double); | 
|---|
|  | 1458 | } else { | 
|---|
|  | 1459 | // otherwise we must skip all interjacent tabs and spaces and find next value | 
|---|
|  | 1460 | dummy1 = dummy; | 
|---|
|  | 1461 | dummy = strchr(dummy1, '\t'); // seek for tab or space | 
|---|
| [362b0e] | 1462 | if (dummy == NULL) | 
|---|
| [14de469] | 1463 | dummy = strchr(dummy1, ' ');  // if not found seek for space | 
|---|
|  | 1464 | if (dummy == NULL) { // if still zero returned ... | 
|---|
|  | 1465 | dummy = strchr(dummy1, '\n');  // ... at line end then | 
|---|
|  | 1466 | if ((j < yth-1) && (type < 4)) {  // check if xth value or not yet | 
|---|
|  | 1467 | if (critical) { | 
|---|
|  | 1468 | if (verbose) fprintf(stderr,"Error: EoL at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name); | 
|---|
|  | 1469 | Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); | 
|---|
|  | 1470 | //return 0; | 
|---|
|  | 1471 | exit(255); | 
|---|
|  | 1472 | //Error(FileOpenParams, NULL); | 
|---|
|  | 1473 | } else { | 
|---|
|  | 1474 | //if (!sequential) | 
|---|
|  | 1475 | file->clear(); | 
|---|
|  | 1476 | file->seekg(file_position, ios::beg);  // rewind to start position | 
|---|
|  | 1477 | Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); | 
|---|
|  | 1478 | return 0; | 
|---|
|  | 1479 | } | 
|---|
|  | 1480 | } | 
|---|
|  | 1481 | } else { | 
|---|
|  | 1482 | //fprintf(stderr,"found tab at %i\n",(char *)dummy-(char *)free_dummy); | 
|---|
|  | 1483 | } | 
|---|
| [362b0e] | 1484 | if (*dummy1 == '#') { | 
|---|
|  | 1485 | // found comment, skipping rest of line | 
|---|
|  | 1486 | //if (verbose) fprintf(stderr,"Error: '#' at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name); | 
|---|
|  | 1487 | if (!sequential) { // here we need it! | 
|---|
|  | 1488 | file->seekg(file_position, ios::beg);  // rewind to start position | 
|---|
|  | 1489 | } | 
|---|
|  | 1490 | Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); | 
|---|
|  | 1491 | return 0; | 
|---|
|  | 1492 | } | 
|---|
| [14de469] | 1493 | //fprintf(stderr,"value from %i to %i\n",(char *)dummy1-(char *)free_dummy,(char *)dummy-(char *)free_dummy); | 
|---|
|  | 1494 | switch(type) { | 
|---|
|  | 1495 | case (row_int): | 
|---|
|  | 1496 | *((int *)value) = atoi(dummy1); | 
|---|
|  | 1497 | if ((verbose) && (i==0) && (j==0)) fprintf(stderr,"%s = ", name); | 
|---|
|  | 1498 | if (verbose) fprintf(stderr,"%i\t",*((int *)value)); | 
|---|
|  | 1499 | value = (void *)((long)value + sizeof(int)); | 
|---|
|  | 1500 | //value += sizeof(int); | 
|---|
|  | 1501 | break; | 
|---|
|  | 1502 | case(row_double): | 
|---|
|  | 1503 | case(grid): | 
|---|
|  | 1504 | case(lower_trigrid): | 
|---|
|  | 1505 | case(upper_trigrid): | 
|---|
|  | 1506 | *((double *)value) = atof(dummy1); | 
|---|
|  | 1507 | if ((verbose) && (i==0) && (j==0)) fprintf(stderr,"%s = ", name); | 
|---|
|  | 1508 | if (verbose) fprintf(stderr,"%lg\t",*((double *)value)); | 
|---|
|  | 1509 | value = (void *)((long)value + sizeof(double)); | 
|---|
|  | 1510 | //value += sizeof(double); | 
|---|
|  | 1511 | break; | 
|---|
|  | 1512 | case(double_type): | 
|---|
|  | 1513 | *((double *)value) = atof(dummy1); | 
|---|
|  | 1514 | if ((verbose) && (i == xth-1)) fprintf(stderr,"%s = %lg\n", name, *((double *) value)); | 
|---|
|  | 1515 | //value += sizeof(double); | 
|---|
|  | 1516 | break; | 
|---|
|  | 1517 | case(int_type): | 
|---|
|  | 1518 | *((int *)value) = atoi(dummy1); | 
|---|
|  | 1519 | if ((verbose) && (i == xth-1)) fprintf(stderr,"%s = %i\n", name, *((int *) value)); | 
|---|
|  | 1520 | //value += sizeof(int); | 
|---|
|  | 1521 | break; | 
|---|
|  | 1522 | default: | 
|---|
|  | 1523 | case(string_type): | 
|---|
|  | 1524 | if (value != NULL) { | 
|---|
| [c750cc] | 1525 | //if (maxlength == -1) maxlength = strlen((char *)value); // get maximum size of string array | 
|---|
|  | 1526 | maxlength = MAXSTRINGSIZE; | 
|---|
| [14de469] | 1527 | length = maxlength > (dummy-dummy1) ? (dummy-dummy1) : maxlength; // cap at maximum | 
|---|
|  | 1528 | strncpy((char *)value, dummy1, length);  // copy as much | 
|---|
|  | 1529 | ((char *)value)[length] = '\0';  // and set end marker | 
|---|
|  | 1530 | if ((verbose) && (i == xth-1)) fprintf(stderr,"%s is '%s' (%i chars)\n",name,((char *) value), length); | 
|---|
|  | 1531 | //value += sizeof(char); | 
|---|
|  | 1532 | } else { | 
|---|
|  | 1533 | } | 
|---|
|  | 1534 | break; | 
|---|
|  | 1535 | } | 
|---|
|  | 1536 | } | 
|---|
|  | 1537 | while (*dummy == '\t') | 
|---|
|  | 1538 | dummy++; | 
|---|
|  | 1539 | } | 
|---|
|  | 1540 | } | 
|---|
|  | 1541 | } | 
|---|
|  | 1542 | } | 
|---|
|  | 1543 | } | 
|---|
|  | 1544 | if ((type >= row_int) && (verbose)) fprintf(stderr,"\n"); | 
|---|
|  | 1545 | Free((void **)&free_dummy, "config::ParseForParameter: *free_dummy"); | 
|---|
|  | 1546 | if (!sequential) { | 
|---|
|  | 1547 | file->clear(); | 
|---|
|  | 1548 | file->seekg(file_position, ios::beg);  // rewind to start position | 
|---|
|  | 1549 | } | 
|---|
|  | 1550 | //fprintf(stderr, "End of Parsing\n\n"); | 
|---|
|  | 1551 |  | 
|---|
|  | 1552 | return (found); // true if found, false if not | 
|---|
|  | 1553 | } | 
|---|