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