| [43dad6] | 1 | /*
|
|---|
| 2 | * PcpParser.cpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: 12.06.2010
|
|---|
| 5 | * Author: heber
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #include <iostream>
|
|---|
| 9 |
|
|---|
| 10 | #include "atom.hpp"
|
|---|
| 11 | #include "config.hpp"
|
|---|
| 12 | #include "ConfigFileBuffer.hpp"
|
|---|
| 13 | #include "element.hpp"
|
|---|
| 14 | #include "log.hpp"
|
|---|
| 15 | #include "molecule.hpp"
|
|---|
| 16 | #include "PcpParser.hpp"
|
|---|
| 17 | #include "periodentafel.hpp"
|
|---|
| 18 | #include "ThermoStatContainer.hpp"
|
|---|
| 19 | #include "verbose.hpp"
|
|---|
| 20 | #include "World.hpp"
|
|---|
| 21 |
|
|---|
| 22 | /** Constructor of PcpParser.
|
|---|
| 23 | *
|
|---|
| 24 | */
|
|---|
| 25 | PcpParser::PcpParser()
|
|---|
| 26 | {}
|
|---|
| 27 |
|
|---|
| 28 | /** Destructor of PcpParser.
|
|---|
| 29 | *
|
|---|
| 30 | */
|
|---|
| 31 | PcpParser::~PcpParser()
|
|---|
| 32 | {}
|
|---|
| 33 |
|
|---|
| 34 | void PcpParser::load(std::istream* file)
|
|---|
| 35 | {
|
|---|
| 36 | if (file->fail()) {
|
|---|
| 37 | DoeLog(1) && (eLog()<< Verbose(1) << "could not access given file" << endl);
|
|---|
| 38 | return;
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | // ParseParameterFile
|
|---|
| 42 | class ConfigFileBuffer *FileBuffer = new ConfigFileBuffer();
|
|---|
| 43 | FileBuffer->InitFileBuffer(file);
|
|---|
| 44 |
|
|---|
| 45 | /* Oeffne Hauptparameterdatei */
|
|---|
| 46 | int di = 0;
|
|---|
| 47 | double BoxLength[9];
|
|---|
| 48 | string zeile;
|
|---|
| 49 | string dummy;
|
|---|
| 50 | int verbose = 0;
|
|---|
| 51 |
|
|---|
| 52 | ParseThermostats(FileBuffer);
|
|---|
| 53 |
|
|---|
| 54 | /* Namen einlesen */
|
|---|
| 55 |
|
|---|
| 56 | // 1. parse in options
|
|---|
| 57 | ParseForParameter(verbose,FileBuffer, "mainname", 0, 1, 1, string_type, (Paths.mainname), 1, critical);
|
|---|
| 58 | ParseForParameter(verbose,FileBuffer, "defaultpath", 0, 1, 1, string_type, (Paths.defaultpath), 1, critical);
|
|---|
| 59 | ParseForParameter(verbose,FileBuffer, "pseudopotpath", 0, 1, 1, string_type, (Paths.pseudopotpath), 1, critical);
|
|---|
| 60 | ParseForParameter(verbose,FileBuffer,"ProcPEGamma", 0, 1, 1, int_type, &(Parallelization.ProcPEGamma), 1, critical);
|
|---|
| 61 | ParseForParameter(verbose,FileBuffer,"ProcPEPsi", 0, 1, 1, int_type, &(Parallelization.ProcPEPsi), 1, critical);
|
|---|
| 62 |
|
|---|
| 63 | if (!ParseForParameter(verbose,FileBuffer,"Seed", 0, 1, 1, int_type, &(LocalizedOrbitals.Seed), 1, optional))
|
|---|
| 64 | LocalizedOrbitals.Seed = 1;
|
|---|
| 65 |
|
|---|
| 66 | if(!ParseForParameter(verbose,FileBuffer,"DoOutOrbitals", 0, 1, 1, int_type, &(Switches.DoOutOrbitals), 1, optional)) {
|
|---|
| 67 | Switches.DoOutOrbitals = 0;
|
|---|
| 68 | } else {
|
|---|
| 69 | if (Switches.DoOutOrbitals < 0) Switches.DoOutOrbitals = 0;
|
|---|
| 70 | if (Switches.DoOutOrbitals > 1) Switches.DoOutOrbitals = 1;
|
|---|
| 71 | }
|
|---|
| 72 | ParseForParameter(verbose,FileBuffer,"DoOutVis", 0, 1, 1, int_type, &(Switches.DoOutVis), 1, critical);
|
|---|
| 73 | if (Switches.DoOutVis < 0) Switches.DoOutVis = 0;
|
|---|
| 74 | if (Switches.DoOutVis > 1) Switches.DoOutVis = 1;
|
|---|
| 75 | if (!ParseForParameter(verbose,FileBuffer,"VectorPlane", 0, 1, 1, int_type, &(LocalizedOrbitals.VectorPlane), 1, optional))
|
|---|
| 76 | LocalizedOrbitals.VectorPlane = -1;
|
|---|
| 77 | if (!ParseForParameter(verbose,FileBuffer,"VectorCut", 0, 1, 1, double_type, &(LocalizedOrbitals.VectorCut), 1, optional))
|
|---|
| 78 | LocalizedOrbitals.VectorCut = 0.;
|
|---|
| 79 | ParseForParameter(verbose,FileBuffer,"DoOutMes", 0, 1, 1, int_type, &(Switches.DoOutMes), 1, critical);
|
|---|
| 80 | if (Switches.DoOutMes < 0) Switches.DoOutMes = 0;
|
|---|
| 81 | if (Switches.DoOutMes > 1) Switches.DoOutMes = 1;
|
|---|
| 82 | if (!ParseForParameter(verbose,FileBuffer,"DoOutCurr", 0, 1, 1, int_type, &(Switches.DoOutCurrent), 1, optional))
|
|---|
| 83 | Switches.DoOutCurrent = 0;
|
|---|
| 84 | if (Switches.DoOutCurrent < 0) Switches.DoOutCurrent = 0;
|
|---|
| 85 | if (Switches.DoOutCurrent > 1) Switches.DoOutCurrent = 1;
|
|---|
| 86 | ParseForParameter(verbose,FileBuffer,"AddGramSch", 0, 1, 1, int_type, &(LocalizedOrbitals.UseAddGramSch), 1, critical);
|
|---|
| 87 | if (LocalizedOrbitals.UseAddGramSch < 0) LocalizedOrbitals.UseAddGramSch = 0;
|
|---|
| 88 | if (LocalizedOrbitals.UseAddGramSch > 2) LocalizedOrbitals.UseAddGramSch = 2;
|
|---|
| 89 | if(!ParseForParameter(verbose,FileBuffer,"DoWannier", 0, 1, 1, int_type, &(Switches.DoWannier), 1, optional)) {
|
|---|
| 90 | Switches.DoWannier = 0;
|
|---|
| 91 | } else {
|
|---|
| 92 | if (Switches.DoWannier < 0) Switches.DoWannier = 0;
|
|---|
| 93 | if (Switches.DoWannier > 1) Switches.DoWannier = 1;
|
|---|
| 94 | }
|
|---|
| 95 | if(!ParseForParameter(verbose,FileBuffer,"CommonWannier", 0, 1, 1, int_type, &(LocalizedOrbitals.CommonWannier), 1, optional)) {
|
|---|
| 96 | LocalizedOrbitals.CommonWannier = 0;
|
|---|
| 97 | } else {
|
|---|
| 98 | if (LocalizedOrbitals.CommonWannier < 0) LocalizedOrbitals.CommonWannier = 0;
|
|---|
| 99 | if (LocalizedOrbitals.CommonWannier > 4) LocalizedOrbitals.CommonWannier = 4;
|
|---|
| 100 | }
|
|---|
| 101 | if(!ParseForParameter(verbose,FileBuffer,"SawtoothStart", 0, 1, 1, double_type, &(LocalizedOrbitals.SawtoothStart), 1, optional)) {
|
|---|
| 102 | LocalizedOrbitals.SawtoothStart = 0.01;
|
|---|
| 103 | } else {
|
|---|
| 104 | if (LocalizedOrbitals.SawtoothStart < 0.) LocalizedOrbitals.SawtoothStart = 0.;
|
|---|
| 105 | if (LocalizedOrbitals.SawtoothStart > 1.) LocalizedOrbitals.SawtoothStart = 1.;
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | if (ParseForParameter(verbose,FileBuffer,"DoConstrainedMD", 0, 1, 1, int_type, &(Switches.DoConstrainedMD), 1, optional))
|
|---|
| 109 | if (Switches.DoConstrainedMD < 0)
|
|---|
| 110 | Switches.DoConstrainedMD = 0;
|
|---|
| 111 | ParseForParameter(verbose,FileBuffer,"MaxOuterStep", 0, 1, 1, int_type, &(StepCounts.MaxOuterStep), 1, critical);
|
|---|
| 112 | if (!ParseForParameter(verbose,FileBuffer,"Deltat", 0, 1, 1, double_type, &(Deltat), 1, optional))
|
|---|
| 113 | Deltat = 1;
|
|---|
| 114 | ParseForParameter(verbose,FileBuffer,"OutVisStep", 0, 1, 1, int_type, &(StepCounts.OutVisStep), 1, optional);
|
|---|
| 115 | ParseForParameter(verbose,FileBuffer,"OutSrcStep", 0, 1, 1, int_type, &(StepCounts.OutSrcStep), 1, optional);
|
|---|
| 116 | ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &(World::getInstance().getThermostats()->TargetTemp), 1, optional);
|
|---|
| 117 | //ParseForParameter(verbose,FileBuffer,"Thermostat", 0, 1, 1, int_type, &(ScaleTempStep), 1, optional);
|
|---|
| 118 | if (!ParseForParameter(verbose,FileBuffer,"EpsWannier", 0, 1, 1, double_type, &(LocalizedOrbitals.EpsWannier), 1, optional))
|
|---|
| 119 | LocalizedOrbitals.EpsWannier = 1e-8;
|
|---|
| 120 |
|
|---|
| 121 | // stop conditions
|
|---|
| 122 | //if (MaxOuterStep <= 0) MaxOuterStep = 1;
|
|---|
| 123 | ParseForParameter(verbose,FileBuffer,"MaxPsiStep", 0, 1, 1, int_type, &(StepCounts.MaxPsiStep), 1, critical);
|
|---|
| 124 | if (StepCounts.MaxPsiStep <= 0) StepCounts.MaxPsiStep = 3;
|
|---|
| 125 |
|
|---|
| 126 | ParseForParameter(verbose,FileBuffer,"MaxMinStep", 0, 1, 1, int_type, &(StepCounts.MaxMinStep), 1, critical);
|
|---|
| 127 | ParseForParameter(verbose,FileBuffer,"RelEpsTotalE", 0, 1, 1, double_type, &(StepCounts.RelEpsTotalEnergy), 1, critical);
|
|---|
| 128 | ParseForParameter(verbose,FileBuffer,"RelEpsKineticE", 0, 1, 1, double_type, &(StepCounts.RelEpsKineticEnergy), 1, critical);
|
|---|
| 129 | ParseForParameter(verbose,FileBuffer,"MaxMinStopStep", 0, 1, 1, int_type, &(StepCounts.MaxMinStopStep), 1, critical);
|
|---|
| 130 | ParseForParameter(verbose,FileBuffer,"MaxMinGapStopStep", 0, 1, 1, int_type, &(StepCounts.MaxMinGapStopStep), 1, critical);
|
|---|
| 131 | if (StepCounts.MaxMinStep <= 0) StepCounts.MaxMinStep = StepCounts.MaxPsiStep;
|
|---|
| 132 | if (StepCounts.MaxMinStopStep < 1) StepCounts.MaxMinStopStep = 1;
|
|---|
| 133 | if (StepCounts.MaxMinGapStopStep < 1) StepCounts.MaxMinGapStopStep = 1;
|
|---|
| 134 |
|
|---|
| 135 | ParseForParameter(verbose,FileBuffer,"MaxInitMinStep", 0, 1, 1, int_type, &(StepCounts.MaxInitMinStep), 1, critical);
|
|---|
| 136 | ParseForParameter(verbose,FileBuffer,"InitRelEpsTotalE", 0, 1, 1, double_type, &(StepCounts.InitRelEpsTotalEnergy), 1, critical);
|
|---|
| 137 | ParseForParameter(verbose,FileBuffer,"InitRelEpsKineticE", 0, 1, 1, double_type, &(StepCounts.InitRelEpsKineticEnergy), 1, critical);
|
|---|
| 138 | ParseForParameter(verbose,FileBuffer,"InitMaxMinStopStep", 0, 1, 1, int_type, &(StepCounts.InitMaxMinStopStep), 1, critical);
|
|---|
| 139 | ParseForParameter(verbose,FileBuffer,"InitMaxMinGapStopStep", 0, 1, 1, int_type, &(StepCounts.InitMaxMinGapStopStep), 1, critical);
|
|---|
| 140 | if (StepCounts.MaxInitMinStep <= 0) StepCounts.MaxInitMinStep = StepCounts.MaxPsiStep;
|
|---|
| 141 | if (StepCounts.InitMaxMinStopStep < 1) StepCounts.InitMaxMinStopStep = 1;
|
|---|
| 142 | if (StepCounts.InitMaxMinGapStopStep < 1) StepCounts.InitMaxMinGapStopStep = 1;
|
|---|
| 143 |
|
|---|
| 144 | // Unit cell and magnetic field
|
|---|
| 145 | ParseForParameter(verbose,FileBuffer, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */
|
|---|
| 146 | double * const cell_size = World::getInstance().getDomain();
|
|---|
| 147 | cell_size[0] = BoxLength[0];
|
|---|
| 148 | cell_size[1] = BoxLength[3];
|
|---|
| 149 | cell_size[2] = BoxLength[4];
|
|---|
| 150 | cell_size[3] = BoxLength[6];
|
|---|
| 151 | cell_size[4] = BoxLength[7];
|
|---|
| 152 | cell_size[5] = BoxLength[8];
|
|---|
| 153 | //if (1) fprintf(stderr,"\n");
|
|---|
| 154 |
|
|---|
| 155 | ParseForParameter(verbose,FileBuffer,"DoPerturbation", 0, 1, 1, int_type, &(Switches.DoPerturbation), 1, optional);
|
|---|
| 156 | ParseForParameter(verbose,FileBuffer,"DoOutNICS", 0, 1, 1, int_type, &(Switches.DoOutNICS), 1, optional);
|
|---|
| 157 | if (!ParseForParameter(verbose,FileBuffer,"DoFullCurrent", 0, 1, 1, int_type, &(Switches.DoFullCurrent), 1, optional))
|
|---|
| 158 | Switches.DoFullCurrent = 0;
|
|---|
| 159 | if (Switches.DoFullCurrent < 0) Switches.DoFullCurrent = 0;
|
|---|
| 160 | if (Switches.DoFullCurrent > 2) Switches.DoFullCurrent = 2;
|
|---|
| 161 | if (Switches.DoOutNICS < 0) Switches.DoOutNICS = 0;
|
|---|
| 162 | if (Switches.DoOutNICS > 2) Switches.DoOutNICS = 2;
|
|---|
| 163 | if (Switches.DoPerturbation == 0) {
|
|---|
| 164 | Switches.DoFullCurrent = 0;
|
|---|
| 165 | Switches.DoOutNICS = 0;
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 | ParseForParameter(verbose,FileBuffer,"ECut", 0, 1, 1, double_type, &(PlaneWaveSpecifics.ECut), 1, critical);
|
|---|
| 169 | ParseForParameter(verbose,FileBuffer,"MaxLevel", 0, 1, 1, int_type, &(PlaneWaveSpecifics.MaxLevel), 1, critical);
|
|---|
| 170 | ParseForParameter(verbose,FileBuffer,"Level0Factor", 0, 1, 1, int_type, &(PlaneWaveSpecifics.Lev0Factor), 1, critical);
|
|---|
| 171 | if (PlaneWaveSpecifics.Lev0Factor < 2) {
|
|---|
| 172 | PlaneWaveSpecifics.Lev0Factor = 2;
|
|---|
| 173 | }
|
|---|
| 174 | ParseForParameter(verbose,FileBuffer,"RiemannTensor", 0, 1, 1, int_type, &di, 1, critical);
|
|---|
| 175 | if (di >= 0 && di < 2) {
|
|---|
| 176 | PlaneWaveSpecifics.RiemannTensor = di;
|
|---|
| 177 | } else {
|
|---|
| 178 | cerr << "0 <= RiemanTensor < 2: 0 UseNotRT, 1 UseRT" << endl;
|
|---|
| 179 | exit(1);
|
|---|
| 180 | }
|
|---|
| 181 | switch (PlaneWaveSpecifics.RiemannTensor) {
|
|---|
| 182 | case 0: //UseNoRT
|
|---|
| 183 | if (PlaneWaveSpecifics.MaxLevel < 2) {
|
|---|
| 184 | PlaneWaveSpecifics.MaxLevel = 2;
|
|---|
| 185 | }
|
|---|
| 186 | PlaneWaveSpecifics.LevRFactor = 2;
|
|---|
| 187 | PlaneWaveSpecifics.RTActualUse = 0;
|
|---|
| 188 | break;
|
|---|
| 189 | case 1: // UseRT
|
|---|
| 190 | if (PlaneWaveSpecifics.MaxLevel < 3) {
|
|---|
| 191 | PlaneWaveSpecifics.MaxLevel = 3;
|
|---|
| 192 | }
|
|---|
| 193 | ParseForParameter(verbose,FileBuffer,"RiemannLevel", 0, 1, 1, int_type, &(PlaneWaveSpecifics.RiemannLevel), 1, critical);
|
|---|
| 194 | if (PlaneWaveSpecifics.RiemannLevel < 2) {
|
|---|
| 195 | PlaneWaveSpecifics.RiemannLevel = 2;
|
|---|
| 196 | }
|
|---|
| 197 | if (PlaneWaveSpecifics.RiemannLevel > PlaneWaveSpecifics.MaxLevel-1) {
|
|---|
| 198 | PlaneWaveSpecifics.RiemannLevel = PlaneWaveSpecifics.MaxLevel-1;
|
|---|
| 199 | }
|
|---|
| 200 | ParseForParameter(verbose,FileBuffer,"LevRFactor", 0, 1, 1, int_type, &(PlaneWaveSpecifics.LevRFactor), 1, critical);
|
|---|
| 201 | if (PlaneWaveSpecifics.LevRFactor < 2) {
|
|---|
| 202 | PlaneWaveSpecifics.LevRFactor = 2;
|
|---|
| 203 | }
|
|---|
| 204 | PlaneWaveSpecifics.Lev0Factor = 2;
|
|---|
| 205 | PlaneWaveSpecifics.RTActualUse = 2;
|
|---|
| 206 | break;
|
|---|
| 207 | }
|
|---|
| 208 | ParseForParameter(verbose,FileBuffer,"PsiType", 0, 1, 1, int_type, &di, 1, critical);
|
|---|
| 209 | if (di >= 0 && di < 2) {
|
|---|
| 210 | PlaneWaveSpecifics.PsiType = di;
|
|---|
| 211 | } else {
|
|---|
| 212 | cerr << "0 <= PsiType < 2: 0 UseSpinDouble, 1 UseSpinUpDown" << endl;
|
|---|
| 213 | exit(1);
|
|---|
| 214 | }
|
|---|
| 215 | switch (PlaneWaveSpecifics.PsiType) {
|
|---|
| 216 | case 0: // SpinDouble
|
|---|
| 217 | ParseForParameter(verbose,FileBuffer,"MaxPsiDouble", 0, 1, 1, int_type, &(PlaneWaveSpecifics.MaxPsiDouble), 1, critical);
|
|---|
| 218 | ParseForParameter(verbose,FileBuffer,"AddPsis", 0, 1, 1, int_type, &(PlaneWaveSpecifics.AddPsis), 1, optional);
|
|---|
| 219 | break;
|
|---|
| 220 | case 1: // SpinUpDown
|
|---|
| 221 | if (Parallelization.ProcPEGamma % 2) Parallelization.ProcPEGamma*=2;
|
|---|
| 222 | ParseForParameter(verbose,FileBuffer,"PsiMaxNoUp", 0, 1, 1, int_type, &(PlaneWaveSpecifics.PsiMaxNoUp), 1, critical);
|
|---|
| 223 | ParseForParameter(verbose,FileBuffer,"PsiMaxNoDown", 0, 1, 1, int_type, &(PlaneWaveSpecifics.PsiMaxNoDown), 1, critical);
|
|---|
| 224 | ParseForParameter(verbose,FileBuffer,"AddPsis", 0, 1, 1, int_type, &(PlaneWaveSpecifics.AddPsis), 1, optional);
|
|---|
| 225 | break;
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 | // IonsInitRead
|
|---|
| 229 |
|
|---|
| 230 | ParseForParameter(verbose,FileBuffer,"RCut", 0, 1, 1, double_type, &(PlaneWaveSpecifics.RCut), 1, critical);
|
|---|
| 231 | ParseForParameter(verbose,FileBuffer,"IsAngstroem", 0, 1, 1, int_type, &(IsAngstroem), 1, critical);
|
|---|
| 232 | ParseForParameter(verbose,FileBuffer,"MaxTypes", 0, 1, 1, int_type, &(MaxTypes), 1, critical);
|
|---|
| 233 | if (!ParseForParameter(verbose,FileBuffer,"RelativeCoord", 0, 1, 1, int_type, &(RelativeCoord) , 1, optional))
|
|---|
| 234 | RelativeCoord = 0;
|
|---|
| 235 | if (!ParseForParameter(verbose,FileBuffer,"StructOpt", 0, 1, 1, int_type, &(StructOpt), 1, optional))
|
|---|
| 236 | StructOpt = 0;
|
|---|
| 237 |
|
|---|
| 238 | // 3. parse the molecule in
|
|---|
| 239 | molecule *mol = World::getInstance().createMolecule();
|
|---|
| 240 | LoadMolecule(mol, FileBuffer, World::getInstance().getPeriode(), FastParsing);
|
|---|
| 241 | //mol->SetNameFromFilename(filename);
|
|---|
| 242 | mol->ActiveFlag = true;
|
|---|
| 243 | //MolList->insert(mol);
|
|---|
| 244 |
|
|---|
| 245 | // 4. dissect the molecule into connected subgraphs
|
|---|
| 246 | // don't do this here ...
|
|---|
| 247 | //MolList->DissectMoleculeIntoConnectedSubgraphs(mol,this);
|
|---|
| 248 | //delete(mol);
|
|---|
| 249 |
|
|---|
| 250 | delete(FileBuffer);
|
|---|
| 251 | }
|
|---|
| 252 |
|
|---|
| 253 | /** Saves the World into a PCP config file.
|
|---|
| 254 | * \param *file output stream to save to
|
|---|
| 255 | */
|
|---|
| 256 | void PcpParser::save(std::ostream* file)
|
|---|
| 257 | {
|
|---|
| 258 | const double * const cell_size = World::getInstance().getDomain();
|
|---|
| 259 | class ThermoStatContainer *Thermostats = World::getInstance().getThermostats();
|
|---|
| 260 | if (!file->fail()) {
|
|---|
| 261 | *file << "# ParallelCarParinello - main configuration file - created with molecuilder" << endl;
|
|---|
| 262 | *file << endl;
|
|---|
| 263 | *file << "mainname\t" << Paths.mainname << "\t# programm name (for runtime files)" << endl;
|
|---|
| 264 | *file << "defaultpath\t" << Paths.defaultpath << "\t# where to put files during runtime" << endl;
|
|---|
| 265 | *file << "pseudopotpath\t" << Paths.pseudopotpath << "\t# where to find pseudopotentials" << endl;
|
|---|
| 266 | *file << endl;
|
|---|
| 267 | *file << "ProcPEGamma\t" << Parallelization.ProcPEGamma << "\t# for parallel computing: share constants" << endl;
|
|---|
| 268 | *file << "ProcPEPsi\t" << Parallelization.ProcPEPsi << "\t# for parallel computing: share wave functions" << endl;
|
|---|
| 269 | *file << "DoOutVis\t" << Switches.DoOutVis << "\t# Output data for OpenDX" << endl;
|
|---|
| 270 | *file << "DoOutMes\t" << Switches.DoOutMes << "\t# Output data for measurements" << endl;
|
|---|
| 271 | *file << "DoOutOrbitals\t" << Switches.DoOutOrbitals << "\t# Output all Orbitals" << endl;
|
|---|
| 272 | *file << "DoOutCurr\t" << Switches.DoOutCurrent << "\t# Ouput current density for OpenDx" << endl;
|
|---|
| 273 | *file << "DoOutNICS\t" << Switches.DoOutNICS << "\t# Output Nucleus independent current shieldings" << endl;
|
|---|
| 274 | *file << "DoPerturbation\t" << Switches.DoPerturbation << "\t# Do perturbation calculate and determine susceptibility and shielding" << endl;
|
|---|
| 275 | *file << "DoFullCurrent\t" << Switches.DoFullCurrent << "\t# Do full perturbation" << endl;
|
|---|
| 276 | *file << "DoConstrainedMD\t" << Switches.DoConstrainedMD << "\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD" << endl;
|
|---|
| 277 | *file << "Thermostat\t" << Thermostats->ThermostatNames[Thermostats->Thermostat] << "\t";
|
|---|
| 278 | switch(Thermostats->Thermostat) {
|
|---|
| 279 | default:
|
|---|
| 280 | case None:
|
|---|
| 281 | break;
|
|---|
| 282 | case Woodcock:
|
|---|
| 283 | *file << Thermostats->ScaleTempStep;
|
|---|
| 284 | break;
|
|---|
| 285 | case Gaussian:
|
|---|
| 286 | *file << Thermostats->ScaleTempStep;
|
|---|
| 287 | break;
|
|---|
| 288 | case Langevin:
|
|---|
| 289 | *file << Thermostats->TempFrequency << "\t" << Thermostats->alpha;
|
|---|
| 290 | break;
|
|---|
| 291 | case Berendsen:
|
|---|
| 292 | *file << Thermostats->TempFrequency;
|
|---|
| 293 | break;
|
|---|
| 294 | case NoseHoover:
|
|---|
| 295 | *file << Thermostats->HooverMass;
|
|---|
| 296 | break;
|
|---|
| 297 | };
|
|---|
| 298 | *file << "\t# Which Thermostat and its parameters to use in MD case." << endl;
|
|---|
| 299 | *file << "CommonWannier\t" << LocalizedOrbitals.CommonWannier << "\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center" << endl;
|
|---|
| 300 | *file << "SawtoothStart\t" << LocalizedOrbitals.SawtoothStart << "\t# Absolute value for smooth transition at cell border " << endl;
|
|---|
| 301 | *file << "VectorPlane\t" << LocalizedOrbitals.VectorPlane << "\t# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot" << endl;
|
|---|
| 302 | *file << "VectorCut\t" << LocalizedOrbitals.VectorCut << "\t# Cut plane axis value" << endl;
|
|---|
| 303 | *file << "AddGramSch\t" << LocalizedOrbitals.UseAddGramSch << "\t# Additional GramSchmidtOrtogonalization to be safe" << endl;
|
|---|
| 304 | *file << "Seed\t\t" << LocalizedOrbitals.Seed << "\t# initial value for random seed for Psi coefficients" << endl;
|
|---|
| 305 | *file << endl;
|
|---|
| 306 | *file << "MaxOuterStep\t" << StepCounts.MaxOuterStep << "\t# number of MolecularDynamics/Structure optimization steps" << endl;
|
|---|
| 307 | *file << "Deltat\t" << Deltat << "\t# time per MD step" << endl;
|
|---|
| 308 | *file << "OutVisStep\t" << StepCounts.OutVisStep << "\t# Output visual data every ...th step" << endl;
|
|---|
| 309 | *file << "OutSrcStep\t" << StepCounts.OutSrcStep << "\t# Output \"restart\" data every ..th step" << endl;
|
|---|
| 310 | *file << "TargetTemp\t" << Thermostats->TargetTemp << "\t# Target temperature" << endl;
|
|---|
| 311 | *file << "MaxPsiStep\t" << StepCounts.MaxPsiStep << "\t# number of Minimisation steps per state (0 - default)" << endl;
|
|---|
| 312 | *file << "EpsWannier\t" << LocalizedOrbitals.EpsWannier << "\t# tolerance value for spread minimisation of orbitals" << endl;
|
|---|
| 313 | *file << endl;
|
|---|
| 314 | *file << "# Values specifying when to stop" << endl;
|
|---|
| 315 | *file << "MaxMinStep\t" << StepCounts.MaxMinStep << "\t# Maximum number of steps" << endl;
|
|---|
| 316 | *file << "RelEpsTotalE\t" << StepCounts.RelEpsTotalEnergy << "\t# relative change in total energy" << endl;
|
|---|
| 317 | *file << "RelEpsKineticE\t" << StepCounts.RelEpsKineticEnergy << "\t# relative change in kinetic energy" << endl;
|
|---|
| 318 | *file << "MaxMinStopStep\t" << StepCounts.MaxMinStopStep << "\t# check every ..th steps" << endl;
|
|---|
| 319 | *file << "MaxMinGapStopStep\t" << StepCounts.MaxMinGapStopStep << "\t# check every ..th steps" << endl;
|
|---|
| 320 | *file << endl;
|
|---|
| 321 | *file << "# Values specifying when to stop for INIT, otherwise same as above" << endl;
|
|---|
| 322 | *file << "MaxInitMinStep\t" << StepCounts.MaxInitMinStep << "\t# Maximum number of steps" << endl;
|
|---|
| 323 | *file << "InitRelEpsTotalE\t" << StepCounts.InitRelEpsTotalEnergy << "\t# relative change in total energy" << endl;
|
|---|
| 324 | *file << "InitRelEpsKineticE\t" << StepCounts.InitRelEpsKineticEnergy << "\t# relative change in kinetic energy" << endl;
|
|---|
| 325 | *file << "InitMaxMinStopStep\t" << StepCounts.InitMaxMinStopStep << "\t# check every ..th steps" << endl;
|
|---|
| 326 | *file << "InitMaxMinGapStopStep\t" << StepCounts.InitMaxMinGapStopStep << "\t# check every ..th steps" << endl;
|
|---|
| 327 | *file << endl;
|
|---|
| 328 | *file << "BoxLength\t\t\t# (Length of a unit cell)" << endl;
|
|---|
| 329 | *file << cell_size[0] << "\t" << endl;
|
|---|
| 330 | *file << cell_size[1] << "\t" << cell_size[2] << "\t" << endl;
|
|---|
| 331 | *file << cell_size[3] << "\t" << cell_size[4] << "\t" << cell_size[5] << "\t" << endl;
|
|---|
| 332 | // FIXME
|
|---|
| 333 | *file << endl;
|
|---|
| 334 | *file << "ECut\t\t" << PlaneWaveSpecifics.ECut << "\t# energy cutoff for discretization in Hartrees" << endl;
|
|---|
| 335 | *file << "MaxLevel\t" << PlaneWaveSpecifics.MaxLevel << "\t# number of different levels in the code, >=2" << endl;
|
|---|
| 336 | *file << "Level0Factor\t" << PlaneWaveSpecifics.Lev0Factor << "\t# factor by which node number increases from S to 0 level" << endl;
|
|---|
| 337 | *file << "RiemannTensor\t" << PlaneWaveSpecifics.RiemannTensor << "\t# (Use metric)" << endl;
|
|---|
| 338 | switch (PlaneWaveSpecifics.RiemannTensor) {
|
|---|
| 339 | case 0: //UseNoRT
|
|---|
| 340 | break;
|
|---|
| 341 | case 1: // UseRT
|
|---|
| 342 | *file << "RiemannLevel\t" << PlaneWaveSpecifics.RiemannLevel << "\t# Number of Riemann Levels" << endl;
|
|---|
| 343 | *file << "LevRFactor\t" << PlaneWaveSpecifics.LevRFactor << "\t# factor by which node number increases from 0 to R level from" << endl;
|
|---|
| 344 | break;
|
|---|
| 345 | }
|
|---|
| 346 | *file << "PsiType\t\t" << PlaneWaveSpecifics.PsiType << "\t# 0 - doubly occupied, 1 - SpinUp,SpinDown" << endl;
|
|---|
| 347 | // write out both types for easier changing afterwards
|
|---|
| 348 | // switch (PsiType) {
|
|---|
| 349 | // case 0:
|
|---|
| 350 | *file << "MaxPsiDouble\t" << PlaneWaveSpecifics.MaxPsiDouble << "\t# here: specifying both maximum number of SpinUp- and -Down-states" << endl;
|
|---|
| 351 | // break;
|
|---|
| 352 | // case 1:
|
|---|
| 353 | *file << "PsiMaxNoUp\t" << PlaneWaveSpecifics.PsiMaxNoUp << "\t# here: specifying maximum number of SpinUp-states" << endl;
|
|---|
| 354 | *file << "PsiMaxNoDown\t" << PlaneWaveSpecifics.PsiMaxNoDown << "\t# here: specifying maximum number of SpinDown-states" << endl;
|
|---|
| 355 | // break;
|
|---|
| 356 | // }
|
|---|
| 357 | *file << "AddPsis\t\t" << PlaneWaveSpecifics.AddPsis << "\t# Additional unoccupied Psis for bandgap determination" << endl;
|
|---|
| 358 | *file << endl;
|
|---|
| 359 | *file << "RCut\t\t" << PlaneWaveSpecifics.RCut << "\t# R-cut for the ewald summation" << endl;
|
|---|
| 360 | *file << "StructOpt\t" << StructOpt << "\t# Do structure optimization beforehand" << endl;
|
|---|
| 361 | *file << "IsAngstroem\t" << IsAngstroem << "\t# 0 - Bohr, 1 - Angstroem" << endl;
|
|---|
| 362 | *file << "RelativeCoord\t" << RelativeCoord << "\t# whether ion coordinates are relative (1) or absolute (0)" << endl;
|
|---|
| 363 | *file << endl;
|
|---|
| 364 | vector<atom *> allatoms = World::getInstance().getAllAtoms();
|
|---|
| 365 | map<int, int> ZtoIndexMap;
|
|---|
| 366 | OutputElements(file, allatoms, ZtoIndexMap);
|
|---|
| 367 | OutputAtoms(file, allatoms, ZtoIndexMap);
|
|---|
| 368 | // result = result && mol->Checkout(file);
|
|---|
| 369 | // if (mol->MDSteps <=1 )
|
|---|
| 370 | // result = result && mol->Output(file);
|
|---|
| 371 | // else
|
|---|
| 372 | // result = result && mol->OutputTrajectories(file);
|
|---|
| 373 | } else {
|
|---|
| 374 | DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open output file." << endl);
|
|---|
| 375 | }
|
|---|
| 376 | }
|
|---|
| 377 |
|
|---|
| 378 | /** Prints MaxTypes and list of elements to strea,
|
|---|
| 379 | * \param *file output stream
|
|---|
| 380 | * \param &allatoms vector of all atoms in the system, such as by World::getAllAtoms()
|
|---|
| 381 | * \param &ZtoIndexMap map of which atoms belong to which ion number
|
|---|
| 382 | */
|
|---|
| 383 | void PcpParser::OutputElements(ostream *file, vector<atom *> &allatoms, map<int, int> &ZtoIndexMap)
|
|---|
| 384 | {
|
|---|
| 385 | map<int, int> PresentElements;
|
|---|
| 386 | pair < map<int, int>::iterator, bool > Inserter;
|
|---|
| 387 | // insert all found elements into the map
|
|---|
| 388 | for (vector<atom *>::iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) {
|
|---|
| 389 | Inserter = PresentElements.insert(pair<int, int>((*AtomRunner)->type->Z, 1));
|
|---|
| 390 | if (!Inserter.second) // increase if present
|
|---|
| 391 | Inserter.first->second += 1;
|
|---|
| 392 | }
|
|---|
| 393 | // print total element count
|
|---|
| 394 | *file << "MaxTypes\t" << PresentElements.size() << "\t# maximum number of different ion types" << endl;
|
|---|
| 395 | // print element list
|
|---|
| 396 | *file << "# Ion type data (PP = PseudoPotential, Z = atomic number)" << endl;
|
|---|
| 397 | *file << "#Ion_TypeNr.\tAmount\tZ\tRGauss\tL_Max(PP)L_Loc(PP)IonMass\t# chemical name, symbol" << endl;
|
|---|
| 398 | // elements are due to map sorted by Z value automatically, hence just count through them
|
|---|
| 399 | int counter = 1;
|
|---|
| 400 | for(map<int, int>::const_iterator iter=PresentElements.begin(); iter!=PresentElements.end();++iter) {
|
|---|
| 401 | const element * const elemental = World::getInstance().getPeriode()->FindElement(iter->first);
|
|---|
| 402 | ZtoIndexMap.insert( pair<int,int> (iter->first, counter) );
|
|---|
| 403 | *file << "Ion_Type" << counter++ << "\t" << iter->second << "\t" << elemental->Z << "\t1.0\t3\t3\t" << fixed << setprecision(11) << showpoint << elemental->mass << "\t" << elemental->name << "\t" << elemental->symbol <<endl;
|
|---|
| 404 | }
|
|---|
| 405 | }
|
|---|
| 406 |
|
|---|
| 407 | /** Output all atoms one per line.
|
|---|
| 408 | * \param *file output stream
|
|---|
| 409 | * \param &allatoms vector of all atoms in the system, such as by World::getAllAtoms()
|
|---|
| 410 | * \param &ZtoIndexMap map of which atoms belong to which ion number
|
|---|
| 411 | */
|
|---|
| 412 | void PcpParser::OutputAtoms(ostream *file, vector<atom *> &allatoms, map<int, int> &ZtoIndexMap)
|
|---|
| 413 | {
|
|---|
| 414 | *file << "#Ion_TypeNr._Nr.R[0] R[1] R[2] MoveType (0 MoveIon, 1 FixedIon)" << endl;
|
|---|
| 415 | map<int, int> ZtoCountMap;
|
|---|
| 416 | pair < map<int, int>::iterator, bool > Inserter;
|
|---|
| 417 | for (vector<atom *>::iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) {
|
|---|
| 418 | Inserter = ZtoCountMap.insert( pair<int, int>((*AtomRunner)->type->Z, 1) );
|
|---|
| 419 | if (!Inserter.second)
|
|---|
| 420 | Inserter.first->second += 1;
|
|---|
| 421 | (*AtomRunner)->OutputArrayIndexed(file, &ZtoIndexMap[(*AtomRunner)->type->Z], &ZtoCountMap[Inserter.first->second], NULL);
|
|---|
| 422 | }
|
|---|
| 423 | }
|
|---|
| 424 |
|
|---|
| 425 | /** Reading of Thermostat related values from parameter file.
|
|---|
| 426 | * \param *fb file buffer containing the config file
|
|---|
| 427 | */
|
|---|
| 428 | void PcpParser::ParseThermostats(class ConfigFileBuffer * const fb)
|
|---|
| 429 | {
|
|---|
| 430 | char * const thermo = new char[12];
|
|---|
| 431 | const int verbose = 0;
|
|---|
| 432 | class ThermoStatContainer *Thermostats = World::getInstance().getThermostats();
|
|---|
| 433 |
|
|---|
| 434 | // read desired Thermostat from file along with needed additional parameters
|
|---|
| 435 | if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {
|
|---|
| 436 | if (strcmp(thermo, Thermostats->ThermostatNames[0]) == 0) { // None
|
|---|
| 437 | if (Thermostats->ThermostatImplemented[0] == 1) {
|
|---|
| 438 | Thermostats->Thermostat = None;
|
|---|
| 439 | } else {
|
|---|
| 440 | DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
|
|---|
| 441 | Thermostats->Thermostat = None;
|
|---|
| 442 | }
|
|---|
| 443 | } else if (strcmp(thermo, Thermostats->ThermostatNames[1]) == 0) { // Woodcock
|
|---|
| 444 | if (Thermostats->ThermostatImplemented[1] == 1) {
|
|---|
| 445 | Thermostats->Thermostat = Woodcock;
|
|---|
| 446 | ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read scaling frequency
|
|---|
| 447 | } else {
|
|---|
| 448 | DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
|
|---|
| 449 | Thermostats->Thermostat = None;
|
|---|
| 450 | }
|
|---|
| 451 | } else if (strcmp(thermo, Thermostats->ThermostatNames[2]) == 0) { // Gaussian
|
|---|
| 452 | if (Thermostats->ThermostatImplemented[2] == 1) {
|
|---|
| 453 | Thermostats->Thermostat = Gaussian;
|
|---|
| 454 | ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read collision rate
|
|---|
| 455 | } else {
|
|---|
| 456 | DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
|
|---|
| 457 | Thermostats->Thermostat = None;
|
|---|
| 458 | }
|
|---|
| 459 | } else if (strcmp(thermo, Thermostats->ThermostatNames[3]) == 0) { // Langevin
|
|---|
| 460 | if (Thermostats->ThermostatImplemented[3] == 1) {
|
|---|
| 461 | Thermostats->Thermostat = Langevin;
|
|---|
| 462 | ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read gamma
|
|---|
| 463 | if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &Thermostats->alpha, 1, optional)) {
|
|---|
| 464 | DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << Thermostats->alpha << "." << endl);
|
|---|
| 465 | } else {
|
|---|
| 466 | Thermostats->alpha = 1.;
|
|---|
| 467 | }
|
|---|
| 468 | } else {
|
|---|
| 469 | DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
|
|---|
| 470 | Thermostats->Thermostat = None;
|
|---|
| 471 | }
|
|---|
| 472 | } else if (strcmp(thermo, Thermostats->ThermostatNames[4]) == 0) { // Berendsen
|
|---|
| 473 | if (Thermostats->ThermostatImplemented[4] == 1) {
|
|---|
| 474 | Thermostats->Thermostat = Berendsen;
|
|---|
| 475 | ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read \tau_T
|
|---|
| 476 | } else {
|
|---|
| 477 | DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
|
|---|
| 478 | Thermostats->Thermostat = None;
|
|---|
| 479 | }
|
|---|
| 480 | } else if (strcmp(thermo, Thermostats->ThermostatNames[5]) == 0) { // Nose-Hoover
|
|---|
| 481 | if (Thermostats->ThermostatImplemented[5] == 1) {
|
|---|
| 482 | Thermostats->Thermostat = NoseHoover;
|
|---|
| 483 | ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->HooverMass, 1, critical); // read Hoovermass
|
|---|
| 484 | Thermostats->alpha = 0.;
|
|---|
| 485 | } else {
|
|---|
| 486 | DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
|
|---|
| 487 | Thermostats->Thermostat = None;
|
|---|
| 488 | }
|
|---|
| 489 | } else {
|
|---|
| 490 | DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl);
|
|---|
| 491 | Thermostats->Thermostat = None;
|
|---|
| 492 | }
|
|---|
| 493 | } else {
|
|---|
| 494 | if ((Thermostats->TargetTemp != 0))
|
|---|
| 495 | DoLog(2) && (Log() << Verbose(2) << "No thermostat chosen despite finite temperature MD, falling back to None." << endl);
|
|---|
| 496 | Thermostats->Thermostat = None;
|
|---|
| 497 | }
|
|---|
| 498 | delete[](thermo);
|
|---|
| 499 | };
|
|---|
| 500 |
|
|---|