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