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