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