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