| 1 | /*
 | 
|---|
| 2 |  * PcpParser.cpp
 | 
|---|
| 3 |  *
 | 
|---|
| 4 |  *  Created on: 12.06.2010
 | 
|---|
| 5 |  *      Author: heber
 | 
|---|
| 6 |  */
 | 
|---|
| 7 | 
 | 
|---|
| 8 | #include <iostream>
 | 
|---|
| 9 | #include <iomanip>
 | 
|---|
| 10 | 
 | 
|---|
| 11 | #include "atom.hpp"
 | 
|---|
| 12 | #include "config.hpp"
 | 
|---|
| 13 | #include "ConfigFileBuffer.hpp"
 | 
|---|
| 14 | #include "element.hpp"
 | 
|---|
| 15 | #include "Helpers/Assert.hpp"
 | 
|---|
| 16 | #include "Helpers/Log.hpp"
 | 
|---|
| 17 | #include "Helpers/Verbose.hpp"
 | 
|---|
| 18 | #include "LinearAlgebra/Matrix.hpp"
 | 
|---|
| 19 | #include "molecule.hpp"
 | 
|---|
| 20 | #include "PcpParser.hpp"
 | 
|---|
| 21 | #include "periodentafel.hpp"
 | 
|---|
| 22 | #include "ThermoStatContainer.hpp"
 | 
|---|
| 23 | #include "World.hpp"
 | 
|---|
| 24 | #include "Box.hpp"
 | 
|---|
| 25 | 
 | 
|---|
| 26 | /** Constructor of PcpParser.
 | 
|---|
| 27 |  *
 | 
|---|
| 28 |  */
 | 
|---|
| 29 | PcpParser::PcpParser()
 | 
|---|
| 30 | {
 | 
|---|
| 31 |   Parallelization.ProcPEGamma = 8;
 | 
|---|
| 32 |   Parallelization.ProcPEPsi = 1;
 | 
|---|
| 33 | 
 | 
|---|
| 34 |   Paths.databasepath = NULL;
 | 
|---|
| 35 |   Paths.configname = NULL;
 | 
|---|
| 36 |   Paths.mainname = NULL;
 | 
|---|
| 37 |   Paths.defaultpath = NULL;
 | 
|---|
| 38 |   Paths.pseudopotpath = NULL;
 | 
|---|
| 39 | 
 | 
|---|
| 40 |   Switches.DoConstrainedMD = 0;
 | 
|---|
| 41 |   Switches.DoOutVis = 0;
 | 
|---|
| 42 |   Switches.DoOutMes = 1;
 | 
|---|
| 43 |   Switches.DoOutNICS = 0;
 | 
|---|
| 44 |   Switches.DoOutOrbitals = 0;
 | 
|---|
| 45 |   Switches.DoOutCurrent = 0;
 | 
|---|
| 46 |   Switches.DoFullCurrent = 0;
 | 
|---|
| 47 |   Switches.DoPerturbation = 0;
 | 
|---|
| 48 |   Switches.DoWannier = 0;
 | 
|---|
| 49 | 
 | 
|---|
| 50 |   LocalizedOrbitals.CommonWannier = 0;
 | 
|---|
| 51 |   LocalizedOrbitals.SawtoothStart = 0.01;
 | 
|---|
| 52 |   LocalizedOrbitals.VectorPlane = 0;
 | 
|---|
| 53 |   LocalizedOrbitals.VectorCut = 0;
 | 
|---|
| 54 |   LocalizedOrbitals.UseAddGramSch = 1;
 | 
|---|
| 55 |   LocalizedOrbitals.Seed = 1;
 | 
|---|
| 56 |   LocalizedOrbitals.EpsWannier = 1e-7;
 | 
|---|
| 57 | 
 | 
|---|
| 58 |   StepCounts.MaxMinStopStep = 1;
 | 
|---|
| 59 |   StepCounts.InitMaxMinStopStep = 1;
 | 
|---|
| 60 |   StepCounts.OutVisStep = 10;
 | 
|---|
| 61 |   StepCounts.OutSrcStep = 5;
 | 
|---|
| 62 |   StepCounts.MaxPsiStep = 0;
 | 
|---|
| 63 |   StepCounts.MaxOuterStep = 0;
 | 
|---|
| 64 |   StepCounts.MaxMinStep = 100;
 | 
|---|
| 65 |   StepCounts.RelEpsTotalEnergy = 1e-07;
 | 
|---|
| 66 |   StepCounts.RelEpsKineticEnergy = 1e-05;
 | 
|---|
| 67 |   StepCounts.MaxMinGapStopStep = 0;
 | 
|---|
| 68 |   StepCounts.MaxInitMinStep = 100;
 | 
|---|
| 69 |   StepCounts.InitRelEpsTotalEnergy = 1e-05;
 | 
|---|
| 70 |   StepCounts.InitRelEpsKineticEnergy = 0.0001;
 | 
|---|
| 71 |   StepCounts.InitMaxMinGapStopStep = 0;
 | 
|---|
| 72 | 
 | 
|---|
| 73 |   PlaneWaveSpecifics.PsiType = 0;
 | 
|---|
| 74 |   PlaneWaveSpecifics.MaxPsiDouble = 0;
 | 
|---|
| 75 |   PlaneWaveSpecifics.PsiMaxNoUp = 0;
 | 
|---|
| 76 |   PlaneWaveSpecifics.PsiMaxNoDown = 0;
 | 
|---|
| 77 |   PlaneWaveSpecifics.ECut = 128;
 | 
|---|
| 78 |   PlaneWaveSpecifics.MaxLevel = 5;
 | 
|---|
| 79 |   PlaneWaveSpecifics.RiemannTensor = 0;
 | 
|---|
| 80 |   PlaneWaveSpecifics.LevRFactor = 0;
 | 
|---|
| 81 |   PlaneWaveSpecifics.RiemannLevel = 0;
 | 
|---|
| 82 |   PlaneWaveSpecifics.Lev0Factor = 2;
 | 
|---|
| 83 |   PlaneWaveSpecifics.RTActualUse = 0;
 | 
|---|
| 84 |   PlaneWaveSpecifics.AddPsis = 0;
 | 
|---|
| 85 |   PlaneWaveSpecifics.RCut = 20;
 | 
|---|
| 86 |   PlaneWaveSpecifics.PsiType = 0;
 | 
|---|
| 87 | 
 | 
|---|
| 88 |   FastParsing = false;
 | 
|---|
| 89 | 
 | 
|---|
| 90 |   Deltat = 0.01;
 | 
|---|
| 91 |   IsAngstroem = 1;
 | 
|---|
| 92 |   RelativeCoord = 0;
 | 
|---|
| 93 |   StructOpt = 0;
 | 
|---|
| 94 |   MaxTypes = 0;
 | 
|---|
| 95 | }
 | 
|---|
| 96 | 
 | 
|---|
| 97 | /** Destructor of PcpParser.
 | 
|---|
| 98 |  *
 | 
|---|
| 99 |  */
 | 
|---|
| 100 | PcpParser::~PcpParser()
 | 
|---|
| 101 | {}
 | 
|---|
| 102 | 
 | 
|---|
| 103 | void PcpParser::load(std::istream* file)
 | 
|---|
| 104 | {
 | 
|---|
| 105 |   if (file->fail()) {
 | 
|---|
| 106 |     DoeLog(1) && (eLog()<< Verbose(1) << "could not access given file" << endl);
 | 
|---|
| 107 |     return;
 | 
|---|
| 108 |   }
 | 
|---|
| 109 | 
 | 
|---|
| 110 |   // ParseParameterFile
 | 
|---|
| 111 |   class ConfigFileBuffer *FileBuffer = new ConfigFileBuffer();
 | 
|---|
| 112 |   FileBuffer->InitFileBuffer(file);
 | 
|---|
| 113 | 
 | 
|---|
| 114 |   /* Oeffne Hauptparameterdatei */
 | 
|---|
| 115 |   int di = 0;
 | 
|---|
| 116 |   double BoxLength[9];
 | 
|---|
| 117 |   string zeile;
 | 
|---|
| 118 |   string dummy;
 | 
|---|
| 119 |   int verbose = 0;
 | 
|---|
| 120 | 
 | 
|---|
| 121 |   ParseThermostats(FileBuffer);
 | 
|---|
| 122 | 
 | 
|---|
| 123 |   /* Namen einlesen */
 | 
|---|
| 124 | 
 | 
|---|
| 125 |   // 1. parse in options
 | 
|---|
| 126 |   ParseForParameter(verbose,FileBuffer, "mainname", 0, 1, 1, string_type, (Paths.mainname), 1, critical);
 | 
|---|
| 127 |   ParseForParameter(verbose,FileBuffer, "defaultpath", 0, 1, 1, string_type, (Paths.defaultpath), 1, critical);
 | 
|---|
| 128 |   ParseForParameter(verbose,FileBuffer, "pseudopotpath", 0, 1, 1, string_type, (Paths.pseudopotpath), 1, critical);
 | 
|---|
| 129 |   ParseForParameter(verbose,FileBuffer,"ProcPEGamma", 0, 1, 1, int_type, &(Parallelization.ProcPEGamma), 1, critical);
 | 
|---|
| 130 |   ParseForParameter(verbose,FileBuffer,"ProcPEPsi", 0, 1, 1, int_type, &(Parallelization.ProcPEPsi), 1, critical);
 | 
|---|
| 131 | 
 | 
|---|
| 132 |   if (!ParseForParameter(verbose,FileBuffer,"Seed", 0, 1, 1, int_type, &(LocalizedOrbitals.Seed), 1, optional))
 | 
|---|
| 133 |     LocalizedOrbitals.Seed = 1;
 | 
|---|
| 134 | 
 | 
|---|
| 135 |   if(!ParseForParameter(verbose,FileBuffer,"DoOutOrbitals", 0, 1, 1, int_type, &(Switches.DoOutOrbitals), 1, optional)) {
 | 
|---|
| 136 |     Switches.DoOutOrbitals = 0;
 | 
|---|
| 137 |   } else {
 | 
|---|
| 138 |     if (Switches.DoOutOrbitals < 0) Switches.DoOutOrbitals = 0;
 | 
|---|
| 139 |     if (Switches.DoOutOrbitals > 1) Switches.DoOutOrbitals = 1;
 | 
|---|
| 140 |   }
 | 
|---|
| 141 |   ParseForParameter(verbose,FileBuffer,"DoOutVis", 0, 1, 1, int_type, &(Switches.DoOutVis), 1, critical);
 | 
|---|
| 142 |   if (Switches.DoOutVis < 0) Switches.DoOutVis = 0;
 | 
|---|
| 143 |   if (Switches.DoOutVis > 1) Switches.DoOutVis = 1;
 | 
|---|
| 144 |   if (!ParseForParameter(verbose,FileBuffer,"VectorPlane", 0, 1, 1, int_type, &(LocalizedOrbitals.VectorPlane), 1, optional))
 | 
|---|
| 145 |     LocalizedOrbitals.VectorPlane = -1;
 | 
|---|
| 146 |   if (!ParseForParameter(verbose,FileBuffer,"VectorCut", 0, 1, 1, double_type, &(LocalizedOrbitals.VectorCut), 1, optional))
 | 
|---|
| 147 |     LocalizedOrbitals.VectorCut = 0.;
 | 
|---|
| 148 |   ParseForParameter(verbose,FileBuffer,"DoOutMes", 0, 1, 1, int_type, &(Switches.DoOutMes), 1, critical);
 | 
|---|
| 149 |   if (Switches.DoOutMes < 0) Switches.DoOutMes = 0;
 | 
|---|
| 150 |   if (Switches.DoOutMes > 1) Switches.DoOutMes = 1;
 | 
|---|
| 151 |   if (!ParseForParameter(verbose,FileBuffer,"DoOutCurr", 0, 1, 1, int_type, &(Switches.DoOutCurrent), 1, optional))
 | 
|---|
| 152 |     Switches.DoOutCurrent = 0;
 | 
|---|
| 153 |   if (Switches.DoOutCurrent < 0) Switches.DoOutCurrent = 0;
 | 
|---|
| 154 |   if (Switches.DoOutCurrent > 1) Switches.DoOutCurrent = 1;
 | 
|---|
| 155 |   ParseForParameter(verbose,FileBuffer,"AddGramSch", 0, 1, 1, int_type, &(LocalizedOrbitals.UseAddGramSch), 1, critical);
 | 
|---|
| 156 |   if (LocalizedOrbitals.UseAddGramSch < 0) LocalizedOrbitals.UseAddGramSch = 0;
 | 
|---|
| 157 |   if (LocalizedOrbitals.UseAddGramSch > 2) LocalizedOrbitals.UseAddGramSch = 2;
 | 
|---|
| 158 |   if(!ParseForParameter(verbose,FileBuffer,"DoWannier", 0, 1, 1, int_type, &(Switches.DoWannier), 1, optional)) {
 | 
|---|
| 159 |     Switches.DoWannier = 0;
 | 
|---|
| 160 |   } else {
 | 
|---|
| 161 |     if (Switches.DoWannier < 0) Switches.DoWannier = 0;
 | 
|---|
| 162 |     if (Switches.DoWannier > 1) Switches.DoWannier = 1;
 | 
|---|
| 163 |   }
 | 
|---|
| 164 |   if(!ParseForParameter(verbose,FileBuffer,"CommonWannier", 0, 1, 1, int_type, &(LocalizedOrbitals.CommonWannier), 1, optional)) {
 | 
|---|
| 165 |     LocalizedOrbitals.CommonWannier = 0;
 | 
|---|
| 166 |   } else {
 | 
|---|
| 167 |     if (LocalizedOrbitals.CommonWannier < 0) LocalizedOrbitals.CommonWannier = 0;
 | 
|---|
| 168 |     if (LocalizedOrbitals.CommonWannier > 4) LocalizedOrbitals.CommonWannier = 4;
 | 
|---|
| 169 |   }
 | 
|---|
| 170 |   if(!ParseForParameter(verbose,FileBuffer,"SawtoothStart", 0, 1, 1, double_type, &(LocalizedOrbitals.SawtoothStart), 1, optional)) {
 | 
|---|
| 171 |     LocalizedOrbitals.SawtoothStart = 0.01;
 | 
|---|
| 172 |   } else {
 | 
|---|
| 173 |     if (LocalizedOrbitals.SawtoothStart < 0.) LocalizedOrbitals.SawtoothStart = 0.;
 | 
|---|
| 174 |     if (LocalizedOrbitals.SawtoothStart > 1.) LocalizedOrbitals.SawtoothStart = 1.;
 | 
|---|
| 175 |   }
 | 
|---|
| 176 | 
 | 
|---|
| 177 |   if (ParseForParameter(verbose,FileBuffer,"DoConstrainedMD", 0, 1, 1, int_type, &(Switches.DoConstrainedMD), 1, optional))
 | 
|---|
| 178 |     if (Switches.DoConstrainedMD < 0)
 | 
|---|
| 179 |       Switches.DoConstrainedMD = 0;
 | 
|---|
| 180 |   ParseForParameter(verbose,FileBuffer,"MaxOuterStep", 0, 1, 1, int_type, &(StepCounts.MaxOuterStep), 1, critical);
 | 
|---|
| 181 |   if (!ParseForParameter(verbose,FileBuffer,"Deltat", 0, 1, 1, double_type, &(Deltat), 1, optional))
 | 
|---|
| 182 |     Deltat = 1;
 | 
|---|
| 183 |   ParseForParameter(verbose,FileBuffer,"OutVisStep", 0, 1, 1, int_type, &(StepCounts.OutVisStep), 1, optional);
 | 
|---|
| 184 |   ParseForParameter(verbose,FileBuffer,"OutSrcStep", 0, 1, 1, int_type, &(StepCounts.OutSrcStep), 1, optional);
 | 
|---|
| 185 |   ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &(World::getInstance().getThermostats()->TargetTemp), 1, optional);
 | 
|---|
| 186 |   //ParseForParameter(verbose,FileBuffer,"Thermostat", 0, 1, 1, int_type, &(ScaleTempStep), 1, optional);
 | 
|---|
| 187 |   if (!ParseForParameter(verbose,FileBuffer,"EpsWannier", 0, 1, 1, double_type, &(LocalizedOrbitals.EpsWannier), 1, optional))
 | 
|---|
| 188 |     LocalizedOrbitals.EpsWannier = 1e-8;
 | 
|---|
| 189 | 
 | 
|---|
| 190 |   // stop conditions
 | 
|---|
| 191 |   //if (MaxOuterStep <= 0) MaxOuterStep = 1;
 | 
|---|
| 192 |   ParseForParameter(verbose,FileBuffer,"MaxPsiStep", 0, 1, 1, int_type, &(StepCounts.MaxPsiStep), 1, critical);
 | 
|---|
| 193 |   if (StepCounts.MaxPsiStep <= 0) StepCounts.MaxPsiStep = 3;
 | 
|---|
| 194 | 
 | 
|---|
| 195 |   ParseForParameter(verbose,FileBuffer,"MaxMinStep", 0, 1, 1, int_type, &(StepCounts.MaxMinStep), 1, critical);
 | 
|---|
| 196 |   ParseForParameter(verbose,FileBuffer,"RelEpsTotalE", 0, 1, 1, double_type, &(StepCounts.RelEpsTotalEnergy), 1, critical);
 | 
|---|
| 197 |   ParseForParameter(verbose,FileBuffer,"RelEpsKineticE", 0, 1, 1, double_type, &(StepCounts.RelEpsKineticEnergy), 1, critical);
 | 
|---|
| 198 |   ParseForParameter(verbose,FileBuffer,"MaxMinStopStep", 0, 1, 1, int_type, &(StepCounts.MaxMinStopStep), 1, critical);
 | 
|---|
| 199 |   ParseForParameter(verbose,FileBuffer,"MaxMinGapStopStep", 0, 1, 1, int_type, &(StepCounts.MaxMinGapStopStep), 1, critical);
 | 
|---|
| 200 |   if (StepCounts.MaxMinStep <= 0) StepCounts.MaxMinStep = StepCounts.MaxPsiStep;
 | 
|---|
| 201 |   if (StepCounts.MaxMinStopStep < 1) StepCounts.MaxMinStopStep = 1;
 | 
|---|
| 202 |   if (StepCounts.MaxMinGapStopStep < 1) StepCounts.MaxMinGapStopStep = 1;
 | 
|---|
| 203 | 
 | 
|---|
| 204 |   ParseForParameter(verbose,FileBuffer,"MaxInitMinStep", 0, 1, 1, int_type, &(StepCounts.MaxInitMinStep), 1, critical);
 | 
|---|
| 205 |   ParseForParameter(verbose,FileBuffer,"InitRelEpsTotalE", 0, 1, 1, double_type, &(StepCounts.InitRelEpsTotalEnergy), 1, critical);
 | 
|---|
| 206 |   ParseForParameter(verbose,FileBuffer,"InitRelEpsKineticE", 0, 1, 1, double_type, &(StepCounts.InitRelEpsKineticEnergy), 1, critical);
 | 
|---|
| 207 |   ParseForParameter(verbose,FileBuffer,"InitMaxMinStopStep", 0, 1, 1, int_type, &(StepCounts.InitMaxMinStopStep), 1, critical);
 | 
|---|
| 208 |   ParseForParameter(verbose,FileBuffer,"InitMaxMinGapStopStep", 0, 1, 1, int_type, &(StepCounts.InitMaxMinGapStopStep), 1, critical);
 | 
|---|
| 209 |   if (StepCounts.MaxInitMinStep <= 0) StepCounts.MaxInitMinStep = StepCounts.MaxPsiStep;
 | 
|---|
| 210 |   if (StepCounts.InitMaxMinStopStep < 1) StepCounts.InitMaxMinStopStep = 1;
 | 
|---|
| 211 |   if (StepCounts.InitMaxMinGapStopStep < 1) StepCounts.InitMaxMinGapStopStep = 1;
 | 
|---|
| 212 | 
 | 
|---|
| 213 |   // Unit cell and magnetic field
 | 
|---|
| 214 |   ParseForParameter(verbose,FileBuffer, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */
 | 
|---|
| 215 |   double *cell_size = new double[6];
 | 
|---|
| 216 |   cell_size[0] = BoxLength[0];
 | 
|---|
| 217 |   cell_size[1] = BoxLength[3];
 | 
|---|
| 218 |   cell_size[2] = BoxLength[4];
 | 
|---|
| 219 |   cell_size[3] = BoxLength[6];
 | 
|---|
| 220 |   cell_size[4] = BoxLength[7];
 | 
|---|
| 221 |   cell_size[5] = BoxLength[8];
 | 
|---|
| 222 |   World::getInstance().setDomain(cell_size);
 | 
|---|
| 223 |   delete[] cell_size;
 | 
|---|
| 224 |   //if (1) fprintf(stderr,"\n");
 | 
|---|
| 225 | 
 | 
|---|
| 226 |   ParseForParameter(verbose,FileBuffer,"DoPerturbation", 0, 1, 1, int_type, &(Switches.DoPerturbation), 1, optional);
 | 
|---|
| 227 |   ParseForParameter(verbose,FileBuffer,"DoOutNICS", 0, 1, 1, int_type, &(Switches.DoOutNICS), 1, optional);
 | 
|---|
| 228 |   if (!ParseForParameter(verbose,FileBuffer,"DoFullCurrent", 0, 1, 1, int_type, &(Switches.DoFullCurrent), 1, optional))
 | 
|---|
| 229 |     Switches.DoFullCurrent = 0;
 | 
|---|
| 230 |   if (Switches.DoFullCurrent < 0) Switches.DoFullCurrent = 0;
 | 
|---|
| 231 |   if (Switches.DoFullCurrent > 2) Switches.DoFullCurrent = 2;
 | 
|---|
| 232 |   if (Switches.DoOutNICS < 0) Switches.DoOutNICS = 0;
 | 
|---|
| 233 |   if (Switches.DoOutNICS > 2) Switches.DoOutNICS = 2;
 | 
|---|
| 234 |   if (Switches.DoPerturbation == 0) {
 | 
|---|
| 235 |     Switches.DoFullCurrent = 0;
 | 
|---|
| 236 |     Switches.DoOutNICS = 0;
 | 
|---|
| 237 |   }
 | 
|---|
| 238 | 
 | 
|---|
| 239 |   ParseForParameter(verbose,FileBuffer,"ECut", 0, 1, 1, double_type, &(PlaneWaveSpecifics.ECut), 1, critical);
 | 
|---|
| 240 |   ParseForParameter(verbose,FileBuffer,"MaxLevel", 0, 1, 1, int_type, &(PlaneWaveSpecifics.MaxLevel), 1, critical);
 | 
|---|
| 241 |   ParseForParameter(verbose,FileBuffer,"Level0Factor", 0, 1, 1, int_type, &(PlaneWaveSpecifics.Lev0Factor), 1, critical);
 | 
|---|
| 242 |   if (PlaneWaveSpecifics.Lev0Factor < 2) {
 | 
|---|
| 243 |     PlaneWaveSpecifics.Lev0Factor = 2;
 | 
|---|
| 244 |   }
 | 
|---|
| 245 |   ParseForParameter(verbose,FileBuffer,"RiemannTensor", 0, 1, 1, int_type, &di, 1, critical);
 | 
|---|
| 246 |   if (di >= 0 && di < 2) {
 | 
|---|
| 247 |     PlaneWaveSpecifics.RiemannTensor = di;
 | 
|---|
| 248 |   } else {
 | 
|---|
| 249 |     cerr << "0 <= RiemanTensor < 2: 0 UseNotRT, 1 UseRT" << endl;
 | 
|---|
| 250 |     exit(1);
 | 
|---|
| 251 |   }
 | 
|---|
| 252 |   switch (PlaneWaveSpecifics.RiemannTensor) {
 | 
|---|
| 253 |     case 0: //UseNoRT
 | 
|---|
| 254 |       if (PlaneWaveSpecifics.MaxLevel < 2) {
 | 
|---|
| 255 |         PlaneWaveSpecifics.MaxLevel = 2;
 | 
|---|
| 256 |       }
 | 
|---|
| 257 |       PlaneWaveSpecifics.LevRFactor = 2;
 | 
|---|
| 258 |       PlaneWaveSpecifics.RTActualUse = 0;
 | 
|---|
| 259 |       break;
 | 
|---|
| 260 |     case 1: // UseRT
 | 
|---|
| 261 |       if (PlaneWaveSpecifics.MaxLevel < 3) {
 | 
|---|
| 262 |         PlaneWaveSpecifics.MaxLevel = 3;
 | 
|---|
| 263 |       }
 | 
|---|
| 264 |       ParseForParameter(verbose,FileBuffer,"RiemannLevel", 0, 1, 1, int_type, &(PlaneWaveSpecifics.RiemannLevel), 1, critical);
 | 
|---|
| 265 |       if (PlaneWaveSpecifics.RiemannLevel < 2) {
 | 
|---|
| 266 |         PlaneWaveSpecifics.RiemannLevel = 2;
 | 
|---|
| 267 |       }
 | 
|---|
| 268 |       if (PlaneWaveSpecifics.RiemannLevel > PlaneWaveSpecifics.MaxLevel-1) {
 | 
|---|
| 269 |         PlaneWaveSpecifics.RiemannLevel = PlaneWaveSpecifics.MaxLevel-1;
 | 
|---|
| 270 |       }
 | 
|---|
| 271 |       ParseForParameter(verbose,FileBuffer,"LevRFactor", 0, 1, 1, int_type, &(PlaneWaveSpecifics.LevRFactor), 1, critical);
 | 
|---|
| 272 |       if (PlaneWaveSpecifics.LevRFactor < 2) {
 | 
|---|
| 273 |         PlaneWaveSpecifics.LevRFactor = 2;
 | 
|---|
| 274 |       }
 | 
|---|
| 275 |       PlaneWaveSpecifics.Lev0Factor = 2;
 | 
|---|
| 276 |       PlaneWaveSpecifics.RTActualUse = 2;
 | 
|---|
| 277 |       break;
 | 
|---|
| 278 |   }
 | 
|---|
| 279 |   ParseForParameter(verbose,FileBuffer,"PsiType", 0, 1, 1, int_type, &di, 1, critical);
 | 
|---|
| 280 |   if (di >= 0 && di < 2) {
 | 
|---|
| 281 |     PlaneWaveSpecifics.PsiType = di;
 | 
|---|
| 282 |   } else {
 | 
|---|
| 283 |     cerr << "0 <= PsiType < 2: 0 UseSpinDouble, 1 UseSpinUpDown" << endl;
 | 
|---|
| 284 |     exit(1);
 | 
|---|
| 285 |   }
 | 
|---|
| 286 |   switch (PlaneWaveSpecifics.PsiType) {
 | 
|---|
| 287 |   case 0: // SpinDouble
 | 
|---|
| 288 |     ParseForParameter(verbose,FileBuffer,"MaxPsiDouble", 0, 1, 1, int_type, &(PlaneWaveSpecifics.MaxPsiDouble), 1, critical);
 | 
|---|
| 289 |     ParseForParameter(verbose,FileBuffer,"PsiMaxNoUp", 0, 1, 1, int_type, &(PlaneWaveSpecifics.PsiMaxNoUp), 1, optional);
 | 
|---|
| 290 |     ParseForParameter(verbose,FileBuffer,"PsiMaxNoDown", 0, 1, 1, int_type, &(PlaneWaveSpecifics.PsiMaxNoDown), 1, optional);
 | 
|---|
| 291 |     ParseForParameter(verbose,FileBuffer,"AddPsis", 0, 1, 1, int_type, &(PlaneWaveSpecifics.AddPsis), 1, optional);
 | 
|---|
| 292 |     break;
 | 
|---|
| 293 |   case 1: // SpinUpDown
 | 
|---|
| 294 |     if (Parallelization.ProcPEGamma % 2) Parallelization.ProcPEGamma*=2;
 | 
|---|
| 295 |     ParseForParameter(verbose,FileBuffer,"MaxPsiDouble", 0, 1, 1, int_type, &(PlaneWaveSpecifics.MaxPsiDouble), 1, optional);
 | 
|---|
| 296 |     ParseForParameter(verbose,FileBuffer,"PsiMaxNoUp", 0, 1, 1, int_type, &(PlaneWaveSpecifics.PsiMaxNoUp), 1, critical);
 | 
|---|
| 297 |     ParseForParameter(verbose,FileBuffer,"PsiMaxNoDown", 0, 1, 1, int_type, &(PlaneWaveSpecifics.PsiMaxNoDown), 1, critical);
 | 
|---|
| 298 |     ParseForParameter(verbose,FileBuffer,"AddPsis", 0, 1, 1, int_type, &(PlaneWaveSpecifics.AddPsis), 1, optional);
 | 
|---|
| 299 |     break;
 | 
|---|
| 300 |   }
 | 
|---|
| 301 | 
 | 
|---|
| 302 |   // IonsInitRead
 | 
|---|
| 303 | 
 | 
|---|
| 304 |   ParseForParameter(verbose,FileBuffer,"RCut", 0, 1, 1, double_type, &(PlaneWaveSpecifics.RCut), 1, critical);
 | 
|---|
| 305 |   ParseForParameter(verbose,FileBuffer,"IsAngstroem", 0, 1, 1, int_type, &(IsAngstroem), 1, critical);
 | 
|---|
| 306 |   ParseForParameter(verbose,FileBuffer,"MaxTypes", 0, 1, 1, int_type, &(MaxTypes), 1, critical);
 | 
|---|
| 307 |   if (!ParseForParameter(verbose,FileBuffer,"RelativeCoord", 0, 1, 1, int_type, &(RelativeCoord) , 1, optional))
 | 
|---|
| 308 |     RelativeCoord = 0;
 | 
|---|
| 309 |   if (!ParseForParameter(verbose,FileBuffer,"StructOpt", 0, 1, 1, int_type, &(StructOpt), 1, optional))
 | 
|---|
| 310 |     StructOpt = 0;
 | 
|---|
| 311 | 
 | 
|---|
| 312 |   // 3. parse the molecule in
 | 
|---|
| 313 |   molecule *mol = World::getInstance().createMolecule();
 | 
|---|
| 314 |   MoleculeListClass *molecules = World::getInstance().getMolecules();
 | 
|---|
| 315 |   molecules->insert(mol);
 | 
|---|
| 316 |   LoadMolecule(mol, FileBuffer, World::getInstance().getPeriode(), FastParsing);
 | 
|---|
| 317 |   //mol->SetNameFromFilename(filename);
 | 
|---|
| 318 |   mol->ActiveFlag = true;
 | 
|---|
| 319 |   //MolList->insert(mol);
 | 
|---|
| 320 | 
 | 
|---|
| 321 |   // 4. dissect the molecule into connected subgraphs
 | 
|---|
| 322 |   // don't do this here ...
 | 
|---|
| 323 |   //MolList->DissectMoleculeIntoConnectedSubgraphs(mol,this);
 | 
|---|
| 324 |   //delete(mol);
 | 
|---|
| 325 | 
 | 
|---|
| 326 |   delete(FileBuffer);
 | 
|---|
| 327 | }
 | 
|---|
| 328 | 
 | 
|---|
| 329 | /** Saves the World into a PCP config file.
 | 
|---|
| 330 |  * \param *file output stream to save to
 | 
|---|
| 331 |  */
 | 
|---|
| 332 | void PcpParser::save(std::ostream* file)
 | 
|---|
| 333 | {
 | 
|---|
| 334 |   DoLog(0) && (Log() << Verbose(0) << "Saving changes to pcp." << std::endl);
 | 
|---|
| 335 | 
 | 
|---|
| 336 |   const Matrix &domain = World::getInstance().getDomain().getM();
 | 
|---|
| 337 |   class ThermoStatContainer *Thermostats = World::getInstance().getThermostats();
 | 
|---|
| 338 |   if (!file->fail()) {
 | 
|---|
| 339 |     // calculate number of Psis
 | 
|---|
| 340 |     vector<atom *> allatoms = World::getInstance().getAllAtoms();
 | 
|---|
| 341 |     CalculateOrbitals(allatoms);
 | 
|---|
| 342 |     *file << "# ParallelCarParinello - main configuration file - created with molecuilder" << endl;
 | 
|---|
| 343 |     *file << endl;
 | 
|---|
| 344 |     if (Paths.mainname != NULL)
 | 
|---|
| 345 |       *file << "mainname\t" << Paths.mainname << "\t# programm name (for runtime files)" << endl;
 | 
|---|
| 346 |     else
 | 
|---|
| 347 |       *file << "mainname\tpcp\t# programm name (for runtime files)" << endl;
 | 
|---|
| 348 |     if (Paths.defaultpath != NULL)
 | 
|---|
| 349 |       *file << "defaultpath\t" << Paths.defaultpath << "\t# where to put files during runtime" << endl;
 | 
|---|
| 350 |     else
 | 
|---|
| 351 |       *file << "defaultpath\tnot specified\t# where to put files during runtime" << endl;
 | 
|---|
| 352 |     if (Paths.pseudopotpath != NULL)
 | 
|---|
| 353 |       *file << "pseudopotpath\t" << Paths.pseudopotpath << "\t# where to find pseudopotentials" << endl;
 | 
|---|
| 354 |     else
 | 
|---|
| 355 |       *file << "pseudopotpath\tnot specified\t# where to find pseudopotentials" << endl;
 | 
|---|
| 356 |     *file << endl;
 | 
|---|
| 357 |     *file << "ProcPEGamma\t" << Parallelization.ProcPEGamma << "\t# for parallel computing: share constants" << endl;
 | 
|---|
| 358 |     *file << "ProcPEPsi\t" << Parallelization.ProcPEPsi << "\t# for parallel computing: share wave functions" << endl;
 | 
|---|
| 359 |     *file << "DoOutVis\t" << Switches.DoOutVis << "\t# Output data for OpenDX" << endl;
 | 
|---|
| 360 |     *file << "DoOutMes\t" << Switches.DoOutMes << "\t# Output data for measurements" << endl;
 | 
|---|
| 361 |     *file << "DoOutOrbitals\t" << Switches.DoOutOrbitals << "\t# Output all Orbitals" << endl;
 | 
|---|
| 362 |     *file << "DoOutCurr\t" << Switches.DoOutCurrent << "\t# Ouput current density for OpenDx" << endl;
 | 
|---|
| 363 |     *file << "DoOutNICS\t" << Switches.DoOutNICS << "\t# Output Nucleus independent current shieldings" << endl;
 | 
|---|
| 364 |     *file << "DoPerturbation\t" << Switches.DoPerturbation << "\t# Do perturbation calculate and determine susceptibility and shielding" << endl;
 | 
|---|
| 365 |     *file << "DoFullCurrent\t" << Switches.DoFullCurrent << "\t# Do full perturbation" << endl;
 | 
|---|
| 366 |     *file << "DoConstrainedMD\t" << Switches.DoConstrainedMD << "\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD" << endl;
 | 
|---|
| 367 |     ASSERT(Thermostats != NULL, "PcpParser::save() - Thermostats not initialized!");
 | 
|---|
| 368 |     ASSERT(Thermostats->ThermostatNames != NULL, "PcpParser::save() - Thermostats not initialized!");
 | 
|---|
| 369 |     *file << "Thermostat\t" << Thermostats->ThermostatNames[Thermostats->Thermostat] << "\t";
 | 
|---|
| 370 |     switch(Thermostats->Thermostat) {
 | 
|---|
| 371 |       default:
 | 
|---|
| 372 |       case None:
 | 
|---|
| 373 |         break;
 | 
|---|
| 374 |       case Woodcock:
 | 
|---|
| 375 |         *file << Thermostats->ScaleTempStep;
 | 
|---|
| 376 |         break;
 | 
|---|
| 377 |       case Gaussian:
 | 
|---|
| 378 |         *file << Thermostats->ScaleTempStep;
 | 
|---|
| 379 |         break;
 | 
|---|
| 380 |       case Langevin:
 | 
|---|
| 381 |         *file << Thermostats->TempFrequency << "\t" << Thermostats->alpha;
 | 
|---|
| 382 |         break;
 | 
|---|
| 383 |       case Berendsen:
 | 
|---|
| 384 |         *file << Thermostats->TempFrequency;
 | 
|---|
| 385 |         break;
 | 
|---|
| 386 |       case NoseHoover:
 | 
|---|
| 387 |         *file << Thermostats->HooverMass;
 | 
|---|
| 388 |         break;
 | 
|---|
| 389 |     };
 | 
|---|
| 390 |     *file << "\t# Which Thermostat and its parameters to use in MD case." << endl;
 | 
|---|
| 391 |     *file << "CommonWannier\t" << LocalizedOrbitals.CommonWannier << "\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center" << endl;
 | 
|---|
| 392 |     *file << "SawtoothStart\t" << LocalizedOrbitals.SawtoothStart << "\t# Absolute value for smooth transition at cell border " << endl;
 | 
|---|
| 393 |     *file << "VectorPlane\t" << LocalizedOrbitals.VectorPlane << "\t# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot" << endl;
 | 
|---|
| 394 |     *file << "VectorCut\t" << LocalizedOrbitals.VectorCut << "\t# Cut plane axis value" << endl;
 | 
|---|
| 395 |     *file << "AddGramSch\t" << LocalizedOrbitals.UseAddGramSch << "\t# Additional GramSchmidtOrtogonalization to be safe" << endl;
 | 
|---|
| 396 |     *file << "Seed\t\t" << LocalizedOrbitals.Seed << "\t# initial value for random seed for Psi coefficients" << endl;
 | 
|---|
| 397 |     *file << endl;
 | 
|---|
| 398 |     *file << "MaxOuterStep\t" << StepCounts.MaxOuterStep << "\t# number of MolecularDynamics/Structure optimization steps" << endl;
 | 
|---|
| 399 |     *file << "Deltat\t" << Deltat << "\t# time per MD step" << endl;
 | 
|---|
| 400 |     *file << "OutVisStep\t" << StepCounts.OutVisStep << "\t# Output visual data every ...th step" << endl;
 | 
|---|
| 401 |     *file << "OutSrcStep\t" << StepCounts.OutSrcStep << "\t# Output \"restart\" data every ..th step" << endl;
 | 
|---|
| 402 |     *file << "TargetTemp\t" << Thermostats->TargetTemp << "\t# Target temperature" << endl;
 | 
|---|
| 403 |     *file << "MaxPsiStep\t" << StepCounts.MaxPsiStep << "\t# number of Minimisation steps per state (0 - default)" << endl;
 | 
|---|
| 404 |     *file << "EpsWannier\t" << LocalizedOrbitals.EpsWannier << "\t# tolerance value for spread minimisation of orbitals" << endl;
 | 
|---|
| 405 |     *file << endl;
 | 
|---|
| 406 |     *file << "# Values specifying when to stop" << endl;
 | 
|---|
| 407 |     *file << "MaxMinStep\t" << StepCounts.MaxMinStep << "\t# Maximum number of steps" << endl;
 | 
|---|
| 408 |     *file << "RelEpsTotalE\t" << StepCounts.RelEpsTotalEnergy << "\t# relative change in total energy" << endl;
 | 
|---|
| 409 |     *file << "RelEpsKineticE\t" << StepCounts.RelEpsKineticEnergy << "\t# relative change in kinetic energy" << endl;
 | 
|---|
| 410 |     *file << "MaxMinStopStep\t" << StepCounts.MaxMinStopStep << "\t# check every ..th steps" << endl;
 | 
|---|
| 411 |     *file << "MaxMinGapStopStep\t" << StepCounts.MaxMinGapStopStep << "\t# check every ..th steps" << endl;
 | 
|---|
| 412 |     *file << endl;
 | 
|---|
| 413 |     *file << "# Values specifying when to stop for INIT, otherwise same as above" << endl;
 | 
|---|
| 414 |     *file << "MaxInitMinStep\t" << StepCounts.MaxInitMinStep << "\t# Maximum number of steps" << endl;
 | 
|---|
| 415 |     *file << "InitRelEpsTotalE\t" << StepCounts.InitRelEpsTotalEnergy << "\t# relative change in total energy" << endl;
 | 
|---|
| 416 |     *file << "InitRelEpsKineticE\t" << StepCounts.InitRelEpsKineticEnergy << "\t# relative change in kinetic energy" << endl;
 | 
|---|
| 417 |     *file << "InitMaxMinStopStep\t" << StepCounts.InitMaxMinStopStep << "\t# check every ..th steps" << endl;
 | 
|---|
| 418 |     *file << "InitMaxMinGapStopStep\t" << StepCounts.InitMaxMinGapStopStep << "\t# check every ..th steps" << endl;
 | 
|---|
| 419 |     *file << endl;
 | 
|---|
| 420 |     *file << "BoxLength\t\t\t# (Length of a unit cell)" << endl;
 | 
|---|
| 421 |     *file << domain.at(0,0) << "\t" << endl;
 | 
|---|
| 422 |     *file << domain.at(1,0) << "\t" << domain.at(1,1) << "\t" << endl;
 | 
|---|
| 423 |     *file << domain.at(2,0) << "\t" << domain.at(2,1) << "\t" << domain.at(2,2) << "\t" << endl;
 | 
|---|
| 424 |     // FIXME
 | 
|---|
| 425 |     *file << endl;
 | 
|---|
| 426 |     *file << "ECut\t\t" << PlaneWaveSpecifics.ECut << "\t# energy cutoff for discretization in Hartrees" << endl;
 | 
|---|
| 427 |     *file << "MaxLevel\t" << PlaneWaveSpecifics.MaxLevel << "\t# number of different levels in the code, >=2" << endl;
 | 
|---|
| 428 |     *file << "Level0Factor\t" << PlaneWaveSpecifics.Lev0Factor << "\t# factor by which node number increases from S to 0 level" << endl;
 | 
|---|
| 429 |     *file << "RiemannTensor\t" << PlaneWaveSpecifics.RiemannTensor << "\t# (Use metric)" << endl;
 | 
|---|
| 430 |     switch (PlaneWaveSpecifics.RiemannTensor) {
 | 
|---|
| 431 |       case 0: //UseNoRT
 | 
|---|
| 432 |         break;
 | 
|---|
| 433 |       case 1: // UseRT
 | 
|---|
| 434 |         *file << "RiemannLevel\t" << PlaneWaveSpecifics.RiemannLevel << "\t# Number of Riemann Levels" << endl;
 | 
|---|
| 435 |         *file << "LevRFactor\t" << PlaneWaveSpecifics.LevRFactor << "\t# factor by which node number increases from 0 to R level from" << endl;
 | 
|---|
| 436 |         break;
 | 
|---|
| 437 |     }
 | 
|---|
| 438 |     *file << "PsiType\t\t" << PlaneWaveSpecifics.PsiType << "\t# 0 - doubly occupied, 1 - SpinUp,SpinDown" << endl;
 | 
|---|
| 439 |     *file << "MaxPsiDouble\t" << PlaneWaveSpecifics.MaxPsiDouble << "\t# here: specifying both maximum number of SpinUp- and -Down-states" << endl;
 | 
|---|
| 440 |     *file << "PsiMaxNoUp\t" << PlaneWaveSpecifics.PsiMaxNoUp << "\t# here: specifying maximum number of SpinUp-states" << endl;
 | 
|---|
| 441 |     *file << "PsiMaxNoDown\t" << PlaneWaveSpecifics.PsiMaxNoDown << "\t# here: specifying maximum number of SpinDown-states" << endl;
 | 
|---|
| 442 |     *file << "AddPsis\t\t" << PlaneWaveSpecifics.AddPsis << "\t# Additional unoccupied Psis for bandgap determination" << endl;
 | 
|---|
| 443 |     *file << endl;
 | 
|---|
| 444 |     *file << "RCut\t\t" << PlaneWaveSpecifics.RCut << "\t# R-cut for the ewald summation" << endl;
 | 
|---|
| 445 |     *file << "StructOpt\t" << StructOpt << "\t# Do structure optimization beforehand" << endl;
 | 
|---|
| 446 |     *file << "IsAngstroem\t" << IsAngstroem << "\t# 0 - Bohr, 1 - Angstroem" << endl;
 | 
|---|
| 447 |     *file << "RelativeCoord\t" << RelativeCoord << "\t# whether ion coordinates are relative (1) or absolute (0)" << endl;
 | 
|---|
| 448 |     map<int, int> ZtoIndexMap;
 | 
|---|
| 449 |     OutputElements(file, allatoms, ZtoIndexMap);
 | 
|---|
| 450 |     OutputAtoms(file, allatoms, ZtoIndexMap);
 | 
|---|
| 451 |   } else {
 | 
|---|
| 452 |     DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open output file." << endl);
 | 
|---|
| 453 |   }
 | 
|---|
| 454 | }
 | 
|---|
| 455 | 
 | 
|---|
| 456 | 
 | 
|---|
| 457 | /** Counts necessary number of valence electrons and returns number and SpinType.
 | 
|---|
| 458 |  * \param &allatoms all atoms to store away
 | 
|---|
| 459 |  */
 | 
|---|
| 460 | void PcpParser::CalculateOrbitals(vector<atom *> &allatoms)
 | 
|---|
| 461 | {
 | 
|---|
| 462 |   PlaneWaveSpecifics.MaxPsiDouble = PlaneWaveSpecifics.PsiMaxNoDown = PlaneWaveSpecifics.PsiMaxNoUp = PlaneWaveSpecifics.PsiType = 0;
 | 
|---|
| 463 |   for (vector<atom *>::iterator runner = allatoms.begin(); runner != allatoms.end(); ++runner) {
 | 
|---|
| 464 |     PlaneWaveSpecifics.MaxPsiDouble += (*runner)->type->NoValenceOrbitals;
 | 
|---|
| 465 |   }
 | 
|---|
| 466 |   cout << PlaneWaveSpecifics.MaxPsiDouble << endl;
 | 
|---|
| 467 |   PlaneWaveSpecifics.PsiMaxNoDown = PlaneWaveSpecifics.MaxPsiDouble/2 + (PlaneWaveSpecifics.MaxPsiDouble % 2);
 | 
|---|
| 468 |   PlaneWaveSpecifics.PsiMaxNoUp = PlaneWaveSpecifics.MaxPsiDouble/2;
 | 
|---|
| 469 |   PlaneWaveSpecifics.MaxPsiDouble /= 2;
 | 
|---|
| 470 |   PlaneWaveSpecifics.PsiType = (PlaneWaveSpecifics.PsiMaxNoDown == PlaneWaveSpecifics.PsiMaxNoUp) ? 0 : 1;
 | 
|---|
| 471 |   if ((PlaneWaveSpecifics.PsiType == 1) && (Parallelization.ProcPEPsi < 2) && ((PlaneWaveSpecifics.PsiMaxNoDown != 1) || (PlaneWaveSpecifics.PsiMaxNoUp != 0))) {
 | 
|---|
| 472 |     Parallelization.ProcPEGamma /= 2;
 | 
|---|
| 473 |     Parallelization.ProcPEPsi *= 2;
 | 
|---|
| 474 |   } else {
 | 
|---|
| 475 |     Parallelization.ProcPEGamma *= Parallelization.ProcPEPsi;
 | 
|---|
| 476 |     Parallelization.ProcPEPsi = 1;
 | 
|---|
| 477 |   }
 | 
|---|
| 478 |   cout << PlaneWaveSpecifics.PsiMaxNoDown << ">" << PlaneWaveSpecifics.PsiMaxNoUp << endl;
 | 
|---|
| 479 |   if (PlaneWaveSpecifics.PsiMaxNoDown > PlaneWaveSpecifics.PsiMaxNoUp) {
 | 
|---|
| 480 |     StepCounts.InitMaxMinStopStep = StepCounts.MaxMinStopStep = PlaneWaveSpecifics.PsiMaxNoDown;
 | 
|---|
| 481 |     cout << PlaneWaveSpecifics.PsiMaxNoDown << " " << StepCounts.InitMaxMinStopStep << endl;
 | 
|---|
| 482 |   } else {
 | 
|---|
| 483 |     StepCounts.InitMaxMinStopStep = StepCounts.MaxMinStopStep = PlaneWaveSpecifics.PsiMaxNoUp;
 | 
|---|
| 484 |     cout << PlaneWaveSpecifics.PsiMaxNoUp << " " << StepCounts.InitMaxMinStopStep << endl;
 | 
|---|
| 485 |   }
 | 
|---|
| 486 | };
 | 
|---|
| 487 | 
 | 
|---|
| 488 | /** Prints MaxTypes and list of elements to strea,
 | 
|---|
| 489 |  * \param *file output stream
 | 
|---|
| 490 |  * \param &allatoms vector of all atoms in the system, such as by World::getAllAtoms()
 | 
|---|
| 491 |  * \param &ZtoIndexMap map of which atoms belong to which ion number
 | 
|---|
| 492 |  */
 | 
|---|
| 493 | void PcpParser::OutputElements(ostream *file, vector<atom *> &allatoms, map<int, int> &ZtoIndexMap)
 | 
|---|
| 494 | {
 | 
|---|
| 495 |   map<int, int> PresentElements;
 | 
|---|
| 496 |   pair <   map<int, int>::iterator, bool > Inserter;
 | 
|---|
| 497 |   // insert all found elements into the map
 | 
|---|
| 498 |   for (vector<atom *>::iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) {
 | 
|---|
| 499 |     Inserter = PresentElements.insert(pair<int, int>((*AtomRunner)->type->Z, 1));
 | 
|---|
| 500 |     if (!Inserter.second) // increase if present
 | 
|---|
| 501 |       Inserter.first->second += 1;
 | 
|---|
| 502 |   }
 | 
|---|
| 503 |   // print total element count
 | 
|---|
| 504 |   *file << "MaxTypes\t" << PresentElements.size() <<  "\t# maximum number of different ion types" << endl;
 | 
|---|
| 505 |   *file << endl;
 | 
|---|
| 506 |   // print element list
 | 
|---|
| 507 |   *file << "# Ion type data (PP = PseudoPotential, Z = atomic number)" << endl;
 | 
|---|
| 508 |   *file << "#Ion_TypeNr.\tAmount\tZ\tRGauss\tL_Max(PP)L_Loc(PP)IonMass\t# chemical name, symbol" << endl;
 | 
|---|
| 509 |   // elements are due to map sorted by Z value automatically, hence just count through them
 | 
|---|
| 510 |   int counter = 1;
 | 
|---|
| 511 |   for(map<int, int>::const_iterator iter=PresentElements.begin(); iter!=PresentElements.end();++iter) {
 | 
|---|
| 512 |     const element * const elemental = World::getInstance().getPeriode()->FindElement(iter->first);
 | 
|---|
| 513 |     ZtoIndexMap.insert( pair<int,int> (iter->first, counter) );
 | 
|---|
| 514 |     *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;
 | 
|---|
| 515 |   }
 | 
|---|
| 516 | }
 | 
|---|
| 517 | 
 | 
|---|
| 518 | /** Output all atoms one per line.
 | 
|---|
| 519 |  * \param *file output stream
 | 
|---|
| 520 |  * \param &allatoms vector of all atoms in the system, such as by World::getAllAtoms()
 | 
|---|
| 521 |  * \param &ZtoIndexMap map of which atoms belong to which ion number
 | 
|---|
| 522 |  */
 | 
|---|
| 523 | void PcpParser::OutputAtoms(ostream *file, vector<atom *> &allatoms, map<int, int> &ZtoIndexMap)
 | 
|---|
| 524 | {
 | 
|---|
| 525 |   *file << "#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)" << endl;
 | 
|---|
| 526 |   map<int, int> ZtoCountMap;
 | 
|---|
| 527 |   pair <   map<int, int>::iterator, bool > Inserter;
 | 
|---|
| 528 |   int nr = 0;
 | 
|---|
| 529 |   for (vector<atom *>::iterator AtomRunner = allatoms.begin();AtomRunner != allatoms.end();++AtomRunner) {
 | 
|---|
| 530 |     Inserter = ZtoCountMap.insert( pair<int, int>((*AtomRunner)->type->Z, 1) );
 | 
|---|
| 531 |     if (!Inserter.second)
 | 
|---|
| 532 |       Inserter.first->second += 1;
 | 
|---|
| 533 |     const int Z = (*AtomRunner)->type->Z;
 | 
|---|
| 534 |     *file << "Ion_Type" << ZtoIndexMap[Z] << "_" << ZtoCountMap[Z] << "\t"  << fixed << setprecision(9) << showpoint;
 | 
|---|
| 535 |     *file << (*AtomRunner)->x[0] << "\t" << (*AtomRunner)->x[1] << "\t" << (*AtomRunner)->x[2];
 | 
|---|
| 536 |     *file << "\t" << (*AtomRunner)->FixedIon;
 | 
|---|
| 537 |     if ((*AtomRunner)->v.Norm() > MYEPSILON)
 | 
|---|
| 538 |       *file << "\t" << scientific << setprecision(6) << (*AtomRunner)->v[0] << "\t" << (*AtomRunner)->v[1] << "\t" << (*AtomRunner)->v[2] << "\t";
 | 
|---|
| 539 |     *file << " # molecule nr " << nr++ << endl;
 | 
|---|
| 540 |   }
 | 
|---|
| 541 | }
 | 
|---|
| 542 | 
 | 
|---|
| 543 | /** Reading of Thermostat related values from parameter file.
 | 
|---|
| 544 |  * \param *fb file buffer containing the config file
 | 
|---|
| 545 |  */
 | 
|---|
| 546 | void PcpParser::ParseThermostats(class ConfigFileBuffer * const fb)
 | 
|---|
| 547 | {
 | 
|---|
| 548 |   char * const thermo = new char[12];
 | 
|---|
| 549 |   const int verbose = 0;
 | 
|---|
| 550 |   class ThermoStatContainer *Thermostats = World::getInstance().getThermostats();
 | 
|---|
| 551 | 
 | 
|---|
| 552 |   // read desired Thermostat from file along with needed additional parameters
 | 
|---|
| 553 |   if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {
 | 
|---|
| 554 |     if (strcmp(thermo, Thermostats->ThermostatNames[0]) == 0) { // None
 | 
|---|
| 555 |       if (Thermostats->ThermostatImplemented[0] == 1) {
 | 
|---|
| 556 |         Thermostats->Thermostat = None;
 | 
|---|
| 557 |       } else {
 | 
|---|
| 558 |         DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
 | 
|---|
| 559 |         Thermostats->Thermostat = None;
 | 
|---|
| 560 |       }
 | 
|---|
| 561 |     } else if (strcmp(thermo, Thermostats->ThermostatNames[1]) == 0) { // Woodcock
 | 
|---|
| 562 |       if (Thermostats->ThermostatImplemented[1] == 1) {
 | 
|---|
| 563 |         Thermostats->Thermostat = Woodcock;
 | 
|---|
| 564 |         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read scaling frequency
 | 
|---|
| 565 |       } else {
 | 
|---|
| 566 |         DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
 | 
|---|
| 567 |         Thermostats->Thermostat = None;
 | 
|---|
| 568 |       }
 | 
|---|
| 569 |     } else if (strcmp(thermo, Thermostats->ThermostatNames[2]) == 0) { // Gaussian
 | 
|---|
| 570 |       if (Thermostats->ThermostatImplemented[2] == 1) {
 | 
|---|
| 571 |         Thermostats->Thermostat = Gaussian;
 | 
|---|
| 572 |         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read collision rate
 | 
|---|
| 573 |       } else {
 | 
|---|
| 574 |         DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
 | 
|---|
| 575 |         Thermostats->Thermostat = None;
 | 
|---|
| 576 |       }
 | 
|---|
| 577 |     } else if (strcmp(thermo, Thermostats->ThermostatNames[3]) == 0) { // Langevin
 | 
|---|
| 578 |       if (Thermostats->ThermostatImplemented[3] == 1) {
 | 
|---|
| 579 |         Thermostats->Thermostat = Langevin;
 | 
|---|
| 580 |         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read gamma
 | 
|---|
| 581 |         if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &Thermostats->alpha, 1, optional)) {
 | 
|---|
| 582 |           DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << Thermostats->alpha << "." << endl);
 | 
|---|
| 583 |         } else {
 | 
|---|
| 584 |           Thermostats->alpha = 1.;
 | 
|---|
| 585 |         }
 | 
|---|
| 586 |       } else {
 | 
|---|
| 587 |         DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
 | 
|---|
| 588 |         Thermostats->Thermostat = None;
 | 
|---|
| 589 |       }
 | 
|---|
| 590 |     } else if (strcmp(thermo, Thermostats->ThermostatNames[4]) == 0) { // Berendsen
 | 
|---|
| 591 |       if (Thermostats->ThermostatImplemented[4] == 1) {
 | 
|---|
| 592 |         Thermostats->Thermostat = Berendsen;
 | 
|---|
| 593 |         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read \tau_T
 | 
|---|
| 594 |       } else {
 | 
|---|
| 595 |         DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
 | 
|---|
| 596 |         Thermostats->Thermostat = None;
 | 
|---|
| 597 |       }
 | 
|---|
| 598 |     } else if (strcmp(thermo, Thermostats->ThermostatNames[5]) == 0) { // Nose-Hoover
 | 
|---|
| 599 |       if (Thermostats->ThermostatImplemented[5] == 1) {
 | 
|---|
| 600 |         Thermostats->Thermostat = NoseHoover;
 | 
|---|
| 601 |         ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->HooverMass, 1, critical); // read Hoovermass
 | 
|---|
| 602 |         Thermostats->alpha = 0.;
 | 
|---|
| 603 |       } else {
 | 
|---|
| 604 |         DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
 | 
|---|
| 605 |         Thermostats->Thermostat = None;
 | 
|---|
| 606 |       }
 | 
|---|
| 607 |     } else {
 | 
|---|
| 608 |       DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl);
 | 
|---|
| 609 |       Thermostats->Thermostat = None;
 | 
|---|
| 610 |     }
 | 
|---|
| 611 |   } else {
 | 
|---|
| 612 |     if ((Thermostats->TargetTemp != 0))
 | 
|---|
| 613 |       DoLog(2) && (Log() << Verbose(2) <<  "No thermostat chosen despite finite temperature MD, falling back to None." << endl);
 | 
|---|
| 614 |     Thermostats->Thermostat = None;
 | 
|---|
| 615 |   }
 | 
|---|
| 616 |   delete[](thermo);
 | 
|---|
| 617 | };
 | 
|---|
| 618 | 
 | 
|---|
| 619 | bool PcpParser::operator==(const PcpParser& b) const
 | 
|---|
| 620 | {
 | 
|---|
| 621 |   ASSERT(Parallelization.ProcPEGamma == b.Parallelization.ProcPEGamma, "PcpParser ==: ProcPEGamma not");
 | 
|---|
| 622 |   ASSERT(Parallelization.ProcPEPsi == b.Parallelization.ProcPEPsi, "PcpParser ==: ProcPEPsi not");
 | 
|---|
| 623 | 
 | 
|---|
| 624 |   if ((Paths.databasepath != NULL) && (b.Paths.databasepath != NULL))
 | 
|---|
| 625 |     ASSERT(strcmp(Paths.databasepath, b.Paths.databasepath), "PcpParser ==: databasepath not");
 | 
|---|
| 626 |   if ((Paths.configname != NULL) && (b.Paths.configname != NULL))
 | 
|---|
| 627 |     ASSERT(strcmp(Paths.configname, b.Paths.configname), "PcpParser ==: configname not");
 | 
|---|
| 628 |   if ((Paths.mainname != NULL) && (b.Paths.mainname != NULL))
 | 
|---|
| 629 |     ASSERT(strcmp(Paths.mainname, b.Paths.mainname), "PcpParser ==: mainname not");
 | 
|---|
| 630 |   if ((Paths.defaultpath != NULL) && (b.Paths.defaultpath != NULL))
 | 
|---|
| 631 |     ASSERT(strcmp(Paths.defaultpath, b.Paths.defaultpath), "PcpParser ==: defaultpath not");
 | 
|---|
| 632 |   if ((Paths.pseudopotpath != NULL) && (b.Paths.pseudopotpath != NULL))
 | 
|---|
| 633 |     ASSERT(strcmp(Paths.pseudopotpath, b.Paths.pseudopotpath), "PcpParser ==: pseudopotpath not");
 | 
|---|
| 634 | 
 | 
|---|
| 635 |   ASSERT(Switches.DoConstrainedMD == b.Switches.DoConstrainedMD, "PcpParser ==: DoConstrainedMD not");
 | 
|---|
| 636 |   ASSERT(Switches.DoOutVis == b.Switches.DoOutVis, "PcpParser ==: DoOutVis not");
 | 
|---|
| 637 |   ASSERT(Switches.DoOutMes == b.Switches.DoOutMes, "PcpParser ==: DoOutMes not");
 | 
|---|
| 638 |   ASSERT(Switches.DoOutNICS == b.Switches.DoOutNICS, "PcpParser ==: DoOutNICS not");
 | 
|---|
| 639 |   ASSERT(Switches.DoOutOrbitals == b.Switches.DoOutOrbitals, "PcpParser ==: DoOutOrbitals not");
 | 
|---|
| 640 |   ASSERT(Switches.DoOutCurrent == b.Switches.DoOutCurrent, "PcpParser ==: DoOutCurrent not");
 | 
|---|
| 641 |   ASSERT(Switches.DoFullCurrent == b.Switches.DoFullCurrent, "PcpParser ==: DoFullCurrent not");
 | 
|---|
| 642 |   ASSERT(Switches.DoPerturbation == b.Switches.DoPerturbation, "PcpParser ==: DoPerturbation not");
 | 
|---|
| 643 |   ASSERT(Switches.DoWannier == b.Switches.DoWannier, "PcpParser ==: DoWannier not");
 | 
|---|
| 644 | 
 | 
|---|
| 645 |   ASSERT(LocalizedOrbitals.CommonWannier == b.LocalizedOrbitals.CommonWannier, "PcpParser ==: CommonWannier not");
 | 
|---|
| 646 |   ASSERT(LocalizedOrbitals.SawtoothStart == b.LocalizedOrbitals.SawtoothStart, "PcpParser ==: SawtoothStart not");
 | 
|---|
| 647 |   ASSERT(LocalizedOrbitals.VectorPlane == b.LocalizedOrbitals.VectorPlane, "PcpParser ==: VectorPlane not");
 | 
|---|
| 648 |   ASSERT(LocalizedOrbitals.VectorCut == b.LocalizedOrbitals.VectorCut, "PcpParser ==: VectorCut not");
 | 
|---|
| 649 |   ASSERT(LocalizedOrbitals.UseAddGramSch == b.LocalizedOrbitals.UseAddGramSch, "PcpParser ==: UseAddGramSch not");
 | 
|---|
| 650 |   ASSERT(LocalizedOrbitals.Seed == b.LocalizedOrbitals.Seed, "PcpParser ==: Seed not");
 | 
|---|
| 651 |   ASSERT(LocalizedOrbitals.EpsWannier == b.LocalizedOrbitals.EpsWannier, "PcpParser ==: EpsWannier not");
 | 
|---|
| 652 | 
 | 
|---|
| 653 |   ASSERT(StepCounts.MaxMinStopStep == b.StepCounts.MaxMinStopStep, "PcpParser ==: MaxMinStopStep not");
 | 
|---|
| 654 |   ASSERT(StepCounts.InitMaxMinStopStep == b.StepCounts.InitMaxMinStopStep, "PcpParser ==: InitMaxMinStopStep not");
 | 
|---|
| 655 |   ASSERT(StepCounts.OutVisStep == b.StepCounts.OutVisStep, "PcpParser ==: OutVisStep not");
 | 
|---|
| 656 |   ASSERT(StepCounts.OutSrcStep == b.StepCounts.OutSrcStep, "PcpParser ==: OutSrcStep not");
 | 
|---|
| 657 |   ASSERT(StepCounts.MaxPsiStep == b.StepCounts.MaxPsiStep, "PcpParser ==: MaxPsiStep not");
 | 
|---|
| 658 |   ASSERT(StepCounts.MaxOuterStep == b.StepCounts.MaxOuterStep, "PcpParser ==: MaxOuterStep not");
 | 
|---|
| 659 |   ASSERT(StepCounts.MaxMinStep == b.StepCounts.MaxMinStep, "PcpParser ==: MaxMinStep not");
 | 
|---|
| 660 |   ASSERT(StepCounts.RelEpsTotalEnergy == b.StepCounts.RelEpsTotalEnergy, "PcpParser ==: RelEpsTotalEnergy not");
 | 
|---|
| 661 |   ASSERT(StepCounts.MaxMinGapStopStep == b.StepCounts.MaxMinGapStopStep, "PcpParser ==: MaxMinGapStopStep not");
 | 
|---|
| 662 |   ASSERT(StepCounts.MaxInitMinStep == b.StepCounts.MaxInitMinStep, "PcpParser ==: MaxInitMinStep not");
 | 
|---|
| 663 |   ASSERT(StepCounts.InitRelEpsTotalEnergy == b.StepCounts.InitRelEpsTotalEnergy, "PcpParser ==: InitRelEpsTotalEnergy not");
 | 
|---|
| 664 |   ASSERT(StepCounts.InitRelEpsKineticEnergy == b.StepCounts.InitRelEpsKineticEnergy, "PcpParser ==: InitRelEpsKineticEnergy not");
 | 
|---|
| 665 |   ASSERT(StepCounts.InitMaxMinGapStopStep == b.StepCounts.InitMaxMinGapStopStep, "PcpParser ==: InitMaxMinGapStopStep not");
 | 
|---|
| 666 | 
 | 
|---|
| 667 |   ASSERT(PlaneWaveSpecifics.PsiType == b.PlaneWaveSpecifics.PsiType, "PcpParser ==: PsiType not");
 | 
|---|
| 668 |   ASSERT(PlaneWaveSpecifics.MaxPsiDouble == b.PlaneWaveSpecifics.MaxPsiDouble, "PcpParser ==: MaxPsiDouble not");
 | 
|---|
| 669 |   ASSERT(PlaneWaveSpecifics.PsiMaxNoUp == b.PlaneWaveSpecifics.PsiMaxNoUp, "PcpParser ==: PsiMaxNoUp not");
 | 
|---|
| 670 |   ASSERT(PlaneWaveSpecifics.PsiMaxNoDown == b.PlaneWaveSpecifics.PsiMaxNoDown, "PcpParser ==: PsiMaxNoDown not");
 | 
|---|
| 671 |   ASSERT(PlaneWaveSpecifics.ECut == b.PlaneWaveSpecifics.ECut, "PcpParser ==: ECut not");
 | 
|---|
| 672 |   ASSERT(PlaneWaveSpecifics.MaxLevel == b.PlaneWaveSpecifics.MaxLevel, "PcpParser ==: MaxLevel not");
 | 
|---|
| 673 |   ASSERT(PlaneWaveSpecifics.RiemannTensor == b.PlaneWaveSpecifics.RiemannTensor, "PcpParser ==: RiemannTensor not");
 | 
|---|
| 674 |   ASSERT(PlaneWaveSpecifics.LevRFactor == b.PlaneWaveSpecifics.LevRFactor, "PcpParser ==: LevRFactor not");
 | 
|---|
| 675 |   ASSERT(PlaneWaveSpecifics.RiemannLevel == b.PlaneWaveSpecifics.RiemannLevel, "PcpParser ==: RiemannLevel not");
 | 
|---|
| 676 |   ASSERT(PlaneWaveSpecifics.Lev0Factor == b.PlaneWaveSpecifics.Lev0Factor, "PcpParser ==: Lev0Factor not");
 | 
|---|
| 677 |   ASSERT(PlaneWaveSpecifics.RTActualUse == b.PlaneWaveSpecifics.RTActualUse, "PcpParser ==: RTActualUse not");
 | 
|---|
| 678 |   ASSERT(PlaneWaveSpecifics.AddPsis == b.PlaneWaveSpecifics.AddPsis, "PcpParser ==: AddPsis not");
 | 
|---|
| 679 |   ASSERT(PlaneWaveSpecifics.AddPsis == b.PlaneWaveSpecifics.AddPsis, "PcpParser ==: AddPsis not");
 | 
|---|
| 680 |   ASSERT(PlaneWaveSpecifics.RCut == b.PlaneWaveSpecifics.RCut, "PcpParser ==: RCut not");
 | 
|---|
| 681 | 
 | 
|---|
| 682 |   ASSERT(FastParsing == b.FastParsing, "PcpParser ==: FastParsing not");
 | 
|---|
| 683 | 
 | 
|---|
| 684 |   ASSERT(Deltat == b.Deltat, "PcpParser ==: Deltat not");
 | 
|---|
| 685 |   ASSERT(IsAngstroem == b.IsAngstroem, "PcpParser ==: IsAngstroem not");
 | 
|---|
| 686 |   ASSERT(RelativeCoord == b.RelativeCoord, "PcpParser ==: RelativeCoord not");
 | 
|---|
| 687 |   ASSERT(StructOpt == b.StructOpt, "PcpParser ==: StructOpt not");
 | 
|---|
| 688 |   ASSERT(MaxTypes == b.MaxTypes, "PcpParser ==: MaxTypes not");
 | 
|---|
| 689 |   ASSERT(basis == b.basis, "PcpParser ==: basis not");
 | 
|---|
| 690 | 
 | 
|---|
| 691 |   return true;
 | 
|---|
| 692 | }
 | 
|---|