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