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