Changeset 41a467
- Timestamp:
- Nov 3, 2011, 7:44:01 PM (14 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- ab26c3
- Parents:
- 47d041
- git-author:
- Frederik Heber <heber@…> (10/27/11 15:08:36)
- git-committer:
- Frederik Heber <heber@…> (11/03/11 19:44:01)
- Location:
- src
- Files:
-
- 2 added
- 23 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/CommandAction/BondLengthTableAction.cpp
r47d041 r41a467 24 24 #include "CodePatterns/MemDebug.hpp" 25 25 26 #include "Graph/BondGraph.hpp"27 #include "config.hpp"28 26 #include "CodePatterns/Log.hpp" 29 27 #include "CodePatterns/Verbose.hpp" 28 #include "Graph/BondGraph.hpp" 30 29 #include "World.hpp" 31 30 -
src/Actions/FragmentationAction/FragmentationAction.cpp
r47d041 r41a467 21 21 22 22 #include "atom.hpp" 23 #include "Graph/BondGraph.hpp"24 #include "config.hpp"25 23 #include "CodePatterns/Log.hpp" 26 #include "CodePatterns/Verbose.hpp"27 24 #include "Fragmentation/Fragmentation.hpp" 28 25 #include "Fragmentation/HydrogenSaturation_enum.hpp" 29 26 #include "Graph/DepthFirstSearchAnalysis.hpp" 30 27 #include "molecule.hpp" 31 #include "Descriptors/MoleculeDescriptor.hpp"32 28 #include "World.hpp" 33 29 -
src/Actions/GraphAction/SubgraphDissectionAction.cpp
r47d041 r41a467 25 25 #include "atom.hpp" 26 26 #include "Bond/bond.hpp" 27 #include "config.hpp"28 27 #include "CodePatterns/Log.hpp" 29 28 #include "CodePatterns/Verbose.hpp" -
src/Actions/MoleculeAction/FillVoidWithMoleculeAction.cpp
r47d041 r41a467 21 21 22 22 #include "atom.hpp" 23 #include "Graph/BondGraph.hpp"24 #include "Tesselation/boundary.hpp"25 23 #include "CodePatterns/Verbose.hpp" 26 #include "config.hpp"27 24 #include "Descriptors/MoleculeIdDescriptor.hpp" 28 25 #include "Descriptors/MoleculeOrderDescriptor.hpp" 26 #include "Graph/BondGraph.hpp" 29 27 #include "molecule.hpp" 30 28 #include "MoleculeListClass.hpp" 31 29 #include "Parser/FormatParserInterface.hpp" 32 30 #include "Parser/FormatParserStorage.hpp" 31 #include "Tesselation/boundary.hpp" 33 32 #include "World.hpp" 34 33 -
src/Actions/MoleculeAction/FillWithMoleculeAction.cpp
r47d041 r41a467 21 21 22 22 #include "atom.hpp" 23 #include "Graph/BondGraph.hpp"24 #include "Tesselation/boundary.hpp"25 23 #include "CodePatterns/Verbose.hpp" 26 #include "config.hpp"27 24 #include "Descriptors/MoleculeIdDescriptor.hpp" 28 25 #include "Descriptors/MoleculeOrderDescriptor.hpp" 26 #include "Graph/BondGraph.hpp" 29 27 #include "molecule.hpp" 30 28 #include "MoleculeListClass.hpp" 31 29 #include "Parser/FormatParserInterface.hpp" 32 30 #include "Parser/FormatParserStorage.hpp" 31 #include "Tesselation/boundary.hpp" 33 32 #include "World.hpp" 34 33 -
src/Actions/MoleculeAction/SaveAdjacencyAction.cpp
r47d041 r41a467 20 20 #include "CodePatterns/MemDebug.hpp" 21 21 22 #include "Graph/BondGraph.hpp"23 #include "config.hpp"24 #include "CodePatterns/Log.hpp"25 #include "molecule.hpp"26 #include "CodePatterns/Verbose.hpp"27 #include "World.hpp"28 29 22 #include <iostream> 30 23 #include <fstream> 31 24 #include <string> 25 26 #include "CodePatterns/Log.hpp" 27 #include "Graph/BondGraph.hpp" 28 #include "molecule.hpp" 29 #include "World.hpp" 32 30 33 31 #include "Actions/MoleculeAction/SaveAdjacencyAction.hpp" -
src/Actions/MoleculeAction/SaveBondsAction.cpp
r47d041 r41a467 20 20 #include "CodePatterns/MemDebug.hpp" 21 21 22 #include "Graph/BondGraph.hpp"23 #include "config.hpp"24 #include "CodePatterns/Log.hpp"25 #include "molecule.hpp"26 #include "CodePatterns/Verbose.hpp"27 #include "World.hpp"28 29 22 #include <iostream> 30 23 #include <fstream> 31 24 #include <string> 25 26 #include "CodePatterns/Log.hpp" 27 #include "Graph/BondGraph.hpp" 28 #include "molecule.hpp" 29 #include "World.hpp" 32 30 33 31 #include "Actions/MoleculeAction/SaveBondsAction.hpp" -
src/Actions/MoleculeAction/SuspendInWaterAction.cpp
r47d041 r41a467 20 20 #include "CodePatterns/MemDebug.hpp" 21 21 22 #include "CodePatterns/Log.hpp" 22 23 #include "Tesselation/boundary.hpp" 23 #include "config.hpp"24 #include "CodePatterns/Log.hpp"25 #include "CodePatterns/Verbose.hpp"26 24 #include "World.hpp" 27 25 … … 30 28 31 29 #include "Actions/MoleculeAction/SuspendInWaterAction.hpp" 30 31 class config; 32 32 33 33 using namespace MoleCuilder; -
src/Dynamics/MinimiseConstrainedPotential.cpp
r47d041 r41a467 25 25 26 26 #include "atom.hpp" 27 #include "config.hpp"28 27 #include "Element/element.hpp" 29 28 #include "CodePatterns/enumeration.hpp" -
src/Makefile.am
r47d041 r41a467 169 169 Box.cpp \ 170 170 config.cpp \ 171 ConfigFileBuffer.cpp \172 171 Formula.cpp \ 173 172 linkedcell.cpp \ … … 193 192 Box.hpp \ 194 193 config.hpp \ 195 ConfigFileBuffer.hpp \196 194 Formula.hpp \ 197 195 linkedcell.hpp \ -
src/Parser/Makefile.am
r47d041 r41a467 5 5 PARSERSOURCE = \ 6 6 Parser/ChangeTracker.cpp \ 7 Parser/ConfigFileBuffer.cpp \ 7 8 Parser/FormatParser_common.cpp \ 8 9 Parser/FormatParser_Parameters.cpp \ … … 13 14 Parser/ParserTypes.cpp \ 14 15 Parser/PcpParser.cpp \ 16 Parser/PcpParser_helper.cpp \ 15 17 Parser/PdbAtomInfoContainer.cpp \ 16 18 Parser/PdbParser.cpp \ … … 23 25 PARSERHEADER = \ 24 26 Parser/ChangeTracker.hpp \ 27 Parser/ConfigFileBuffer.hpp \ 25 28 Parser/FormatParser.hpp \ 26 29 Parser/FormatParser_specializations_header.hpp \ … … 37 40 Parser/ParserTypes.undef \ 38 41 Parser/PcpParser.hpp \ 42 Parser/PcpParser_helper.hpp \ 39 43 Parser/PdbAtomInfoContainer.hpp \ 40 44 Parser/PdbKey.hpp \ -
src/Parser/MpqcParser.cpp
r47d041 r41a467 28 28 29 29 #include "atom.hpp" 30 #include "CodePatterns/Log.hpp" 31 #include "CodePatterns/toString.hpp" 30 32 #include "config.hpp" 31 33 #include "Element/element.hpp" 34 #include "Element/periodentafel.hpp" 35 #include "LinearAlgebra/Vector.hpp" 32 36 #include "molecule.hpp" 33 37 #include "MoleculeListClass.hpp" 34 #include "CodePatterns/Log.hpp"35 #include "CodePatterns/toString.hpp"36 #include "CodePatterns/Verbose.hpp"37 #include "LinearAlgebra/Vector.hpp"38 #include "Element/periodentafel.hpp"39 38 #include "World.hpp" 40 39 -
src/Parser/PcpParser.cpp
r47d041 r41a467 23 23 #include <iomanip> 24 24 25 //#include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"26 25 #include "atom.hpp" 27 #include "config.hpp" 28 #include "ConfigFileBuffer.hpp" 29 #include "Element/element.hpp" 26 #include "Box.hpp" 30 27 #include "CodePatterns/Assert.hpp" 31 28 #include "CodePatterns/Log.hpp" 32 29 #include "CodePatterns/Verbose.hpp" 30 #include "Element/element.hpp" 31 #include "Element/periodentafel.hpp" 33 32 #include "LinearAlgebra/RealSpaceMatrix.hpp" 34 33 #include "molecule.hpp" 35 34 #include "MoleculeListClass.hpp" 36 35 #include "PcpParser.hpp" 37 #include "Element/periodentafel.hpp" 36 #include "Parser/ConfigFileBuffer.hpp" 37 #include "Parser/PcpParser_helper.hpp" 38 38 #include "ThermoStatContainer.hpp" 39 39 #include "World.hpp" 40 #include "Box.hpp"41 40 42 41 -
src/Parser/Psi3Parser.cpp
r47d041 r41a467 28 28 29 29 #include "atom.hpp" 30 #include "config.hpp" 30 #include "CodePatterns/Log.hpp" 31 #include "CodePatterns/toString.hpp" 31 32 #include "Element/element.hpp" 32 33 #include "Element/periodentafel.hpp" 34 #include "LinearAlgebra/Vector.hpp" 33 35 #include "molecule.hpp" 34 36 #include "MoleculeListClass.hpp" 35 #include "CodePatterns/Log.hpp"36 #include "CodePatterns/toString.hpp"37 #include "CodePatterns/Verbose.hpp"38 #include "LinearAlgebra/Vector.hpp"39 37 #include "World.hpp" 40 38 … … 60 58 {} 61 59 62 /** Load an MPQCconfig file into the World.60 /** Load an PSI3 config file into the World. 63 61 * \param *file input stream 64 62 */ … … 155 153 } 156 154 157 /** Saves all atoms and data into a MPQCconfig file.155 /** Saves all atoms and data into a PSI3 config file. 158 156 * \param *file output stream 159 157 * \param atoms atoms to store -
src/ThermoStatContainer.cpp
r47d041 r41a467 22 22 #include <cstring> 23 23 24 #include "ConfigFileBuffer.hpp"25 #include "config.hpp"26 24 #include "CodePatterns/Log.hpp" 27 25 #include "ThermoStatContainer.hpp" 28 #include " CodePatterns/Verbose.hpp"26 #include "Parser/ConfigFileBuffer.hpp" 29 27 30 28 #include <Thermostats/Berendsen.hpp> -
src/Thermostats/Berendsen.cpp
r47d041 r41a467 14 14 15 15 #include "Berendsen.hpp" 16 17 #include "CodePatterns/Log.hpp" 18 #include "config.hpp" 16 19 #include "Element/element.hpp" 17 #include "config.hpp"18 #include "CodePatterns/Verbose.hpp"19 #include "CodePatterns/Log.hpp"20 20 #include "Helpers/defs.hpp" 21 #include "Parser/PcpParser_helper.hpp" 21 22 #include "ThermoStatContainer.hpp" 22 23 #include "World.hpp" -
src/Thermostats/GaussianThermostat.cpp
r47d041 r41a467 14 14 15 15 #include "GaussianThermostat.hpp" 16 17 #include "AtomSet.hpp" 16 18 #include "CodePatterns/Log.hpp" 17 #include "CodePatterns/Verbose.hpp" 19 #include "config.hpp" 20 #include "Element/element.hpp" 18 21 #include "Helpers/defs.hpp" 19 22 #include "LinearAlgebra/Vector.hpp" 20 #include "AtomSet.hpp" 21 #include "Element/element.hpp" 22 #include "config.hpp" 23 #include "Parser/PcpParser_helper.hpp" 23 24 #include "World.hpp" 24 25 -
src/Thermostats/Langevin.cpp
r47d041 r41a467 14 14 15 15 #include "Langevin.hpp" 16 17 #include "CodePatterns/Log.hpp" 18 #include "Parser/PcpParser_helper.hpp" 16 19 #include "Element/element.hpp" 17 #include "config.hpp"18 #include "CodePatterns/Verbose.hpp"19 #include "CodePatterns/Log.hpp"20 20 #include "Helpers/defs.hpp" 21 21 #include "ThermoStatContainer.hpp" -
src/Thermostats/NoseHoover.cpp
r47d041 r41a467 15 15 #include "NoseHoover.hpp" 16 16 17 #include "CodePatterns/Log.hpp" 18 #include "config.hpp" 17 19 #include "Element/element.hpp" 18 #include "config.hpp"19 #include "CodePatterns/Verbose.hpp"20 #include "CodePatterns/Log.hpp"21 20 #include "Helpers/defs.hpp" 21 #include "Parser/PcpParser_helper.hpp" 22 22 #include "ThermoStatContainer.hpp" 23 23 #include "World.hpp" -
src/Thermostats/Woodcock.cpp
r47d041 r41a467 15 15 #include "Woodcock.hpp" 16 16 17 #include "CodePatterns/Log.hpp" 17 18 #include "Element/element.hpp" 18 #include "config.hpp"19 #include "CodePatterns/Verbose.hpp"20 #include "CodePatterns/Log.hpp"21 19 #include "Helpers/defs.hpp" 20 #include "Parser/PcpParser_helper.hpp" 22 21 #include "ThermoStatContainer.hpp" 23 22 -
src/UIElements/TextUI/TextWindow.cpp
r47d041 r41a467 42 42 #include "CodePatterns/Log.hpp" 43 43 #include "CodePatterns/Verbose.hpp" 44 45 // all needed due to config::SaveAll()46 #include "config.hpp"47 #include "Element/periodentafel.hpp"48 44 49 45 // needed due to Enumerate() -
src/config.cpp
r47d041 r41a467 19 19 #include "CodePatterns/MemDebug.hpp" 20 20 21 #include <stdio.h>22 21 #include <cstring> 23 #include <iostream>24 #include <boost/tokenizer.hpp>25 #include <string>26 22 27 #include "atom.hpp"28 #include "Bond/bond.hpp"29 #include "Box.hpp"30 #include "CodePatterns/Info.hpp"31 #include "CodePatterns/Log.hpp"32 #include "CodePatterns/toString.hpp"33 #include "CodePatterns/Verbose.hpp"34 23 #include "config.hpp" 35 #include "ConfigFileBuffer.hpp" 36 #include "Element/element.hpp" 37 #include "Element/periodentafel.hpp" 38 #include "Graph/BondGraph.hpp" 39 #include "Helpers/helpers.hpp" 40 #include "LinearAlgebra/RealSpaceMatrix.hpp" 41 #include "molecule.hpp" 42 #include "MoleculeListClass.hpp" 43 #include "ThermoStatContainer.hpp" 44 #include "World.hpp" 24 25 #include "Helpers/defs.hpp" 45 26 46 27 /************************************* Functions for class config ***************************/ … … 49 30 */ 50 31 config::config() : 51 PsiType(0), 52 MaxPsiDouble(0), 53 PsiMaxNoUp(0), 54 PsiMaxNoDown(0), 55 MaxMinStopStep(1), 56 InitMaxMinStopStep(1), 57 ProcPEGamma(8), 58 ProcPEPsi(1), 59 configname(NULL), 32 databasepath(NULL), 33 defaultpath(NULL), 60 34 FastParsing(false), 61 Deltat(0.01),62 databasepath(NULL),63 DoConstrainedMD(0),64 MaxOuterStep(0),65 mainname(NULL),66 defaultpath(NULL),67 pseudopotpath(NULL),68 DoOutVis(0),69 DoOutMes(1),70 DoOutNICS(0),71 DoOutOrbitals(0),72 DoOutCurrent(0),73 DoFullCurrent(0),74 DoPerturbation(0),75 DoWannier(0),76 CommonWannier(0),77 SawtoothStart(0.01),78 VectorPlane(0),79 VectorCut(0.),80 UseAddGramSch(1),81 Seed(1),82 OutVisStep(10),83 OutSrcStep(5),84 MaxPsiStep(0),85 EpsWannier(1e-7),86 MaxMinStep(100),87 RelEpsTotalEnergy(1e-7),88 RelEpsKineticEnergy(1e-5),89 MaxMinGapStopStep(0),90 MaxInitMinStep(100),91 InitRelEpsTotalEnergy(1e-5),92 InitRelEpsKineticEnergy(1e-4),93 InitMaxMinGapStopStep(0),94 ECut(128.),95 MaxLevel(5),96 RiemannTensor(0),97 LevRFactor(0),98 RiemannLevel(0),99 Lev0Factor(2),100 RTActualUse(0),101 AddPsis(0),102 RCut(20.),103 StructOpt(0),104 35 IsAngstroem(1), 105 RelativeCoord(0), 106 MaxTypes(0) 36 Deltat(0.01) 107 37 { 108 mainname = new char[MAXSTRINGSIZE];109 38 defaultpath = new char[MAXSTRINGSIZE]; 110 pseudopotpath = new char[MAXSTRINGSIZE];111 39 databasepath = new char[MAXSTRINGSIZE]; 112 configname = new char[MAXSTRINGSIZE]; 113 strcpy(mainname,"pcp"); 114 strcpy(defaultpath,"not specified"); 115 strcpy(pseudopotpath,"not specified"); 116 configname[0]='\0'; 40 strncpy(defaultpath,"not specified", MAXSTRINGSIZE); 117 41 }; 118 42 … … 121 45 config::~config() 122 46 { 123 delete[](mainname);124 47 delete[](defaultpath); 125 delete[](pseudopotpath);126 48 delete[](databasepath); 127 delete[](configname);128 49 }; 129 130 /** Displays menu for editing each entry of the config file.131 * Nothing fancy here, just lots of std::cout's for the menu and a switch/case132 * for each entry of the config file structure.133 */134 void config::Edit()135 {136 char choice;137 138 do {139 std::cout << "===========EDIT CONFIGURATION============================" << std::endl;140 std::cout << " A - mainname (prefix for all runtime files)" << std::endl;141 std::cout << " B - Default path (for runtime files)" << std::endl;142 std::cout << " C - Path of pseudopotential files" << std::endl;143 std::cout << " D - Number of coefficient sharing processes" << std::endl;144 std::cout << " E - Number of wave function sharing processes" << std::endl;145 std::cout << " F - 0: Don't output density for OpenDX, 1: do" << std::endl;146 std::cout << " G - 0: Don't output physical data, 1: do" << std::endl;147 std::cout << " H - 0: Don't output densities of each unperturbed orbital for OpenDX, 1: do" << std::endl;148 std::cout << " I - 0: Don't output current density for OpenDX, 1: do" << std::endl;149 std::cout << " J - 0: Don't do the full current calculation, 1: do" << std::endl;150 std::cout << " K - 0: Don't do perturbation calculation to obtain susceptibility and shielding, 1: do" << std::endl;151 std::cout << " L - 0: Wannier centres as calculated, 1: common centre for all, 2: unite centres according to spread, 3: cell centre, 4: shifted to nearest grid point" << std::endl;152 std::cout << " M - Absolute begin of unphysical sawtooth transfer for position operator within cell" << std::endl;153 std::cout << " N - (0,1,2) x,y,z-plane to do two-dimensional current vector cut" << std::endl;154 std::cout << " O - Absolute position along vector cut axis for cut plane" << std::endl;155 std::cout << " P - Additional Gram-Schmidt-Orthonormalization to stabilize numerics" << std::endl;156 std::cout << " Q - Initial integer value of random number generator" << std::endl;157 std::cout << " R - for perturbation 0, for structure optimization defines upper limit of iterations" << std::endl;158 std::cout << " T - Output visual after ...th step" << std::endl;159 std::cout << " U - Output source densities of wave functions after ...th step" << std::endl;160 std::cout << " X - minimization iterations per wave function, if unsure leave at default value 0" << std::endl;161 std::cout << " Y - tolerance value for total spread in iterative Jacobi diagonalization" << std::endl;162 std::cout << " Z - Maximum number of minimization iterations" << std::endl;163 std::cout << " a - Relative change in total energy to stop min. iteration" << std::endl;164 std::cout << " b - Relative change in kinetic energy to stop min. iteration" << std::endl;165 std::cout << " c - Check stop conditions every ..th step during min. iteration" << std::endl;166 std::cout << " e - Maximum number of minimization iterations during initial level" << std::endl;167 std::cout << " f - Relative change in total energy to stop min. iteration during initial level" << std::endl;168 std::cout << " g - Relative change in kinetic energy to stop min. iteration during initial level" << std::endl;169 std::cout << " h - Check stop conditions every ..th step during min. iteration during initial level" << std::endl;170 // std::cout << " j - six lower diagonal entries of matrix, defining the unit cell" << std::endl;171 std::cout << " k - Energy cutoff of plane wave basis in Hartree" << std::endl;172 std::cout << " l - Maximum number of levels in multi-level-ansatz" << std::endl;173 std::cout << " m - Factor by which grid nodes increase between standard and upper level" << std::endl;174 std::cout << " n - 0: Don't use RiemannTensor, 1: Do" << std::endl;175 std::cout << " o - Factor by which grid nodes increase between Riemann and standard(?) level" << std::endl;176 std::cout << " p - Number of Riemann levels" << std::endl;177 std::cout << " r - 0: Don't Use RiemannTensor, 1: Do" << std::endl;178 std::cout << " s - 0: Doubly occupied orbitals, 1: Up-/Down-Orbitals" << std::endl;179 std::cout << " t - Number of orbitals (depends pn SpinType)" << std::endl;180 std::cout << " u - Number of SpinUp orbitals (depends on SpinType)" << std::endl;181 std::cout << " v - Number of SpinDown orbitals (depends on SpinType)" << std::endl;182 std::cout << " w - Number of additional, unoccupied orbitals" << std::endl;183 std::cout << " x - radial cutoff for ewald summation in Bohrradii" << std::endl;184 std::cout << " y - 0: Don't do structure optimization beforehand, 1: Do" << std::endl;185 std::cout << " z - 0: Units are in Bohr radii, 1: units are in Aengstrom" << std::endl;186 std::cout << " i - 0: Coordinates given in file are absolute, 1: ... are relative to unit cell" << std::endl;187 std::cout << "=========================================================" << std::endl;188 std::cout << "INPUT: " << std::endl;189 cin >> choice;190 191 switch (choice) {192 case 'A': // mainname193 std::cout << "Old: " << config::mainname << "\t new: " << std::endl;194 cin >> config::mainname;195 break;196 case 'B': // defaultpath197 std::cout << "Old: " << config::defaultpath << "\t new: " << std::endl;198 cin >> config::defaultpath;199 break;200 case 'C': // pseudopotpath201 std::cout << "Old: " << config::pseudopotpath << "\t new: " << std::endl;202 cin >> config::pseudopotpath;203 break;204 205 case 'D': // ProcPEGamma206 std::cout << "Old: " << config::ProcPEGamma << "\t new: " << std::endl;207 cin >> config::ProcPEGamma;208 break;209 case 'E': // ProcPEPsi210 std::cout << "Old: " << config::ProcPEPsi << "\t new: " << std::endl;211 cin >> config::ProcPEPsi;212 break;213 case 'F': // DoOutVis214 std::cout << "Old: " << config::DoOutVis << "\t new: " << std::endl;215 cin >> config::DoOutVis;216 break;217 case 'G': // DoOutMes218 std::cout << "Old: " << config::DoOutMes << "\t new: " << std::endl;219 cin >> config::DoOutMes;220 break;221 case 'H': // DoOutOrbitals222 std::cout << "Old: " << config::DoOutOrbitals << "\t new: " << std::endl;223 cin >> config::DoOutOrbitals;224 break;225 case 'I': // DoOutCurrent226 std::cout << "Old: " << config::DoOutCurrent << "\t new: " << std::endl;227 cin >> config::DoOutCurrent;228 break;229 case 'J': // DoFullCurrent230 std::cout << "Old: " << config::DoFullCurrent << "\t new: " << std::endl;231 cin >> config::DoFullCurrent;232 break;233 case 'K': // DoPerturbation234 std::cout << "Old: " << config::DoPerturbation << "\t new: " << std::endl;235 cin >> config::DoPerturbation;236 break;237 case 'L': // CommonWannier238 std::cout << "Old: " << config::CommonWannier << "\t new: " << std::endl;239 cin >> config::CommonWannier;240 break;241 case 'M': // SawtoothStart242 std::cout << "Old: " << config::SawtoothStart << "\t new: " << std::endl;243 cin >> config::SawtoothStart;244 break;245 case 'N': // VectorPlane246 std::cout << "Old: " << config::VectorPlane << "\t new: " << std::endl;247 cin >> config::VectorPlane;248 break;249 case 'O': // VectorCut250 std::cout << "Old: " << config::VectorCut << "\t new: " << std::endl;251 cin >> config::VectorCut;252 break;253 case 'P': // UseAddGramSch254 std::cout << "Old: " << config::UseAddGramSch << "\t new: " << std::endl;255 cin >> config::UseAddGramSch;256 break;257 case 'Q': // Seed258 std::cout << "Old: " << config::Seed << "\t new: " << std::endl;259 cin >> config::Seed;260 break;261 262 case 'R': // MaxOuterStep263 std::cout << "Old: " << config::MaxOuterStep << "\t new: " << std::endl;264 cin >> config::MaxOuterStep;265 break;266 case 'T': // OutVisStep267 std::cout << "Old: " << config::OutVisStep << "\t new: " << std::endl;268 cin >> config::OutVisStep;269 break;270 case 'U': // OutSrcStep271 std::cout << "Old: " << config::OutSrcStep << "\t new: " << std::endl;272 cin >> config::OutSrcStep;273 break;274 case 'X': // MaxPsiStep275 std::cout << "Old: " << config::MaxPsiStep << "\t new: " << std::endl;276 cin >> config::MaxPsiStep;277 break;278 case 'Y': // EpsWannier279 std::cout << "Old: " << config::EpsWannier << "\t new: " << std::endl;280 cin >> config::EpsWannier;281 break;282 283 case 'Z': // MaxMinStep284 std::cout << "Old: " << config::MaxMinStep << "\t new: " << std::endl;285 cin >> config::MaxMinStep;286 break;287 case 'a': // RelEpsTotalEnergy288 std::cout << "Old: " << config::RelEpsTotalEnergy << "\t new: " << std::endl;289 cin >> config::RelEpsTotalEnergy;290 break;291 case 'b': // RelEpsKineticEnergy292 std::cout << "Old: " << config::RelEpsKineticEnergy << "\t new: " << std::endl;293 cin >> config::RelEpsKineticEnergy;294 break;295 case 'c': // MaxMinStopStep296 std::cout << "Old: " << config::MaxMinStopStep << "\t new: " << std::endl;297 cin >> config::MaxMinStopStep;298 break;299 case 'e': // MaxInitMinStep300 std::cout << "Old: " << config::MaxInitMinStep << "\t new: " << std::endl;301 cin >> config::MaxInitMinStep;302 break;303 case 'f': // InitRelEpsTotalEnergy304 std::cout << "Old: " << config::InitRelEpsTotalEnergy << "\t new: " << std::endl;305 cin >> config::InitRelEpsTotalEnergy;306 break;307 case 'g': // InitRelEpsKineticEnergy308 std::cout << "Old: " << config::InitRelEpsKineticEnergy << "\t new: " << std::endl;309 cin >> config::InitRelEpsKineticEnergy;310 break;311 case 'h': // InitMaxMinStopStep312 std::cout << "Old: " << config::InitMaxMinStopStep << "\t new: " << std::endl;313 cin >> config::InitMaxMinStopStep;314 break;315 316 // case 'j': // BoxLength317 // std::cout << "enter lower triadiagonalo form of basis matrix" << std::endl << std::endl;318 // double * const cell_size = World::getInstance().getDomain();319 // for (int i=0;i<6;i++) {320 // std::cout << "Cell size" << i << ": ";321 // cin >> cell_size[i];322 // }323 // break;324 325 case 'k': // ECut326 std::cout << "Old: " << config::ECut << "\t new: " << std::endl;327 cin >> config::ECut;328 break;329 case 'l': // MaxLevel330 std::cout << "Old: " << config::MaxLevel << "\t new: " << std::endl;331 cin >> config::MaxLevel;332 break;333 case 'm': // RiemannTensor334 std::cout << "Old: " << config::RiemannTensor << "\t new: " << std::endl;335 cin >> config::RiemannTensor;336 break;337 case 'n': // LevRFactor338 std::cout << "Old: " << config::LevRFactor << "\t new: " << std::endl;339 cin >> config::LevRFactor;340 break;341 case 'o': // RiemannLevel342 std::cout << "Old: " << config::RiemannLevel << "\t new: " << std::endl;343 cin >> config::RiemannLevel;344 break;345 case 'p': // Lev0Factor346 std::cout << "Old: " << config::Lev0Factor << "\t new: " << std::endl;347 cin >> config::Lev0Factor;348 break;349 case 'r': // RTActualUse350 std::cout << "Old: " << config::RTActualUse << "\t new: " << std::endl;351 cin >> config::RTActualUse;352 break;353 case 's': // PsiType354 std::cout << "Old: " << config::PsiType << "\t new: " << std::endl;355 cin >> config::PsiType;356 break;357 case 't': // MaxPsiDouble358 std::cout << "Old: " << config::MaxPsiDouble << "\t new: " << std::endl;359 cin >> config::MaxPsiDouble;360 break;361 case 'u': // PsiMaxNoUp362 std::cout << "Old: " << config::PsiMaxNoUp << "\t new: " << std::endl;363 cin >> config::PsiMaxNoUp;364 break;365 case 'v': // PsiMaxNoDown366 std::cout << "Old: " << config::PsiMaxNoDown << "\t new: " << std::endl;367 cin >> config::PsiMaxNoDown;368 break;369 case 'w': // AddPsis370 std::cout << "Old: " << config::AddPsis << "\t new: " << std::endl;371 cin >> config::AddPsis;372 break;373 374 case 'x': // RCut375 std::cout << "Old: " << config::RCut << "\t new: " << std::endl;376 cin >> config::RCut;377 break;378 case 'y': // StructOpt379 std::cout << "Old: " << config::StructOpt << "\t new: " << std::endl;380 cin >> config::StructOpt;381 break;382 case 'z': // IsAngstroem383 std::cout << "Old: " << config::IsAngstroem << "\t new: " << std::endl;384 cin >> config::IsAngstroem;385 break;386 case 'i': // RelativeCoord387 std::cout << "Old: " << config::RelativeCoord << "\t new: " << std::endl;388 cin >> config::RelativeCoord;389 break;390 };391 } while (choice != 'q');392 };393 394 /** Tests whether a given configuration file adhears to old or new syntax.395 * \param *filename filename of config file to be tested396 * \param *periode pointer to a periodentafel class with all elements397 * \return 0 - old syntax, 1 - new syntax, -1 - unknown syntax398 */399 int config::TestSyntax(const char * const filename, const periodentafel * const periode) const400 {401 int test;402 ifstream file(filename);403 404 // search file for keyword: ProcPEGamma (new syntax)405 if (ParseForParameter(1,&file,"ProcPEGamma", 0, 1, 1, int_type, &test, 1, optional)) {406 file.close();407 return 1;408 }409 // search file for keyword: ProcsGammaPsi (old syntax)410 if (ParseForParameter(1,&file,"ProcsGammaPsi", 0, 1, 1, int_type, &test, 1, optional)) {411 file.close();412 return 0;413 }414 file.close();415 return -1;416 }417 50 418 51 /** Returns private config::IsAngstroem. … … 424 57 }; 425 58 426 /** Returns private config::*defaultpath.427 * \return *defaultpath428 */429 char * config::GetDefaultPath() const430 {431 return defaultpath;432 };433 434 435 /** Returns private config::*defaultpath.436 * \return *defaultpath437 */438 void config::SetDefaultPath(const char * const path)439 {440 strcpy(defaultpath, path);441 };442 443 /** Loads a molecule from a ConfigFileBuffer.444 * \param *mol molecule to load445 * \param *FileBuffer ConfigFileBuffer to use446 * \param *periode periodentafel for finding elements447 * \param FastParsing whether to parse trajectories or not448 */449 void LoadMolecule(molecule * const &mol, struct ConfigFileBuffer * const &FileBuffer, const periodentafel * const periode, const bool FastParsing)450 {451 int MaxTypes = 0;452 const element *elementhash[MAX_ELEMENTS];453 char name[MAXSTRINGSIZE];454 int Z = -1;455 int No[MAX_ELEMENTS];456 int verbose = DoLog(4);457 double value[3];458 459 if (mol == NULL) {460 ELOG(0, "Molecule is not allocated in LoadMolecule(), exit.");461 performCriticalExit();462 }463 464 ParseForParameter(verbose,FileBuffer,"MaxTypes", 0, 1, 1, int_type, &(MaxTypes), 1, critical);465 if (MaxTypes == 0) {466 ELOG(1, "There are no atoms according to MaxTypes in this config file." << endl);467 //performCriticalExit();468 } else {469 // prescan number of ions per type470 LOG(0, "STATUS: Prescanning ions per type: " << endl);471 int NoAtoms = 0;472 for (int i=0; i < MaxTypes; i++) {473 sprintf(name,"Ion_Type%i",i+1);474 ParseForParameter(verbose,FileBuffer, (const char*)name, 0, 1, 1, int_type, &No[i], 1, critical);475 ParseForParameter(verbose,FileBuffer, name, 0, 2, 1, int_type, &Z, 1, critical);476 elementhash[i] = periode->FindElement(Z);477 LOG(1, i << ". Z = " << elementhash[i]->getAtomicNumber() << " with " << No[i] << " ions.");478 NoAtoms += No[i];479 }480 int repetition = -1; // which repeated keyword shall be read481 482 // sort the lines via the LineMapping483 sprintf(name,"Ion_Type%i",MaxTypes);484 if (!ParseForParameter(verbose,FileBuffer, (const char*)name, 1, 1, 1, int_type, &value[0], 1, critical)) {485 ELOG(0, "There are no atoms in the config file!" << endl);486 performCriticalExit();487 return;488 }489 490 FileBuffer->CurrentLine++; // skip to next line491 FileBuffer->MapIonTypesInBuffer(NoAtoms);492 for (int i=FileBuffer->CurrentLine; i<FileBuffer->NoLines;++i) {493 LOG(4, FileBuffer->buffer[ FileBuffer->LineMapping[i] ]);494 }495 496 map<int, atom *> AtomList[MaxTypes];497 map<int, atom *> LinearList;498 atom *neues = NULL;499 Vector tempVector;500 int _fixedion;501 502 typedef boost::tokenizer<boost::char_separator<char> >503 tokenizer;504 boost::char_separator<char> sep("\t ");505 ConvertTo<double> toDouble;506 ConvertTo<int> toInt;507 508 for (int i=0; i < MaxTypes; i++) {509 for(int j=0;j<No[i];j++) {510 int step = 0;511 std::stringstream keyword_stream;512 keyword_stream << "Ion_Type" << i+1 << "_" << j+1;513 const std::string keyword = keyword_stream.str();514 LOG(3, "INFO: Parsing for " << keyword << "." << std::endl);515 while (true) {516 const std::string line(FileBuffer->buffer[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ]);517 const std::string line_without_comment = line.substr(0,line.find("#"));518 tokenizer tokens(line_without_comment, sep);519 if (tokens.begin() != tokens.end()) {520 tokenizer::iterator tok_iter = tokens.begin();521 const std::string token = *tok_iter++;522 if (token == keyword) {523 LOG(3, "INFO: Found keyword " << keyword << " in line " << FileBuffer->CurrentLine << std::endl);524 if (step == 0) {525 neues = World::getInstance().createAtom();526 AtomList[i][j] = neues;527 LOG(4, "Filling LinearList [ (FileBuffer->LineMapping[" << FileBuffer->CurrentLine << "]) = " << FileBuffer->LineMapping[FileBuffer->CurrentLine] << " with " << neues << endl);528 LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues;529 neues->setType(elementhash[i]); // find element type530 } else531 neues = AtomList[i][j];532 533 // count tokens534 size_t tokens_size = 0;535 for (tokenizer::iterator tokiter = tokens.begin(); tokiter != tokens.end(); ++tokiter)536 ++tokens_size;537 LOG(3, "INFO: Line contains " << tokens_size << " tokens." << std::endl);538 // and parse539 tempVector.Zero();540 if (tokens_size >= 5) { // only AtomicPosition and FixedIon541 for (int i=0;i<NDIM;++i)542 tempVector[i] = toDouble(*tok_iter++);543 neues->setPositionAtStep(step, tempVector);544 _fixedion = toInt(*tok_iter++);545 neues->setFixedIon(_fixedion == 1);546 LOG(3, "INFO: Parsing AtomicPosition " << tempVector << " and FixedIon " << _fixedion << "." << std::endl);547 }548 tempVector.Zero();549 if (tokens_size >= 8) { // AtomicVelocity550 for (int i=0;i<NDIM;++i)551 tempVector[i] = toDouble(*tok_iter++);552 LOG(3, "INFO: Parsing AtomicVelocity " << tempVector << "." << std::endl);553 }554 neues->setAtomicVelocityAtStep(step, tempVector);555 tempVector.Zero();556 if (tokens_size >= 11) { // AtomicForce557 LOG(3, "INFO: Parsing AtomicForce" << std::endl);558 for (int i=0;i<NDIM;++i)559 tempVector[i] = toDouble(*tok_iter++);560 }561 neues->setAtomicForceAtStep(step, tempVector);562 std::stringstream output;563 output << "Parsed position of step " << (step+1) << ": ";564 output << neues->getPositionAtStep(step); // next step565 output << "\t";566 output << (neues->getFixedIon() ? "true" : "false");567 output << "\t";568 output << neues->getAtomicVelocityAtStep(step); // next step569 output << "\t";570 output << neues->getAtomicForceAtStep(step); // next step571 LOG(2, output.str());572 573 step++;574 } else {575 if ((repetition > step) || (repetition == -1))576 repetition = step;577 break;578 }579 }580 FileBuffer->CurrentLine++;581 }582 }583 }584 585 if (repetition <= 1) // if onyl one step, desactivate use of trajectories586 mol->MDSteps = 0;587 else {588 LOG(0, "Found " << repetition << " trajectory step(s).");589 mol->MDSteps = repetition;590 }591 592 // put atoms into the molecule in their original order593 for(map<int, atom*>::iterator runner = LinearList.begin(); runner != LinearList.end(); ++runner) {594 mol->AddAtom(runner->second);595 }596 }597 };598 599 /** Stores all elements of config structure from which they can be re-read.600 * \param *filename name of file601 * \param *periode pointer to a periodentafel class with all elements602 * \param *mol pointer to molecule containing all atoms of the molecule603 */604 bool config::Save(const char * const filename, const periodentafel * const periode, molecule * const mol) const605 {606 bool result = true;607 const RealSpaceMatrix &domain = World::getInstance().getDomain().getM();608 ThermoStatContainer *Thermostats = World::getInstance().getThermostats();609 ofstream * const output = new ofstream(filename, ios::out);610 if (output != NULL) {611 *output << "# ParallelCarParinello - main configuration file - created with molecuilder" << endl;612 *output << endl;613 *output << "mainname\t" << config::mainname << "\t# programm name (for runtime files)" << endl;614 *output << "defaultpath\t" << config::defaultpath << "\t# where to put files during runtime" << endl;615 *output << "pseudopotpath\t" << config::pseudopotpath << "\t# where to find pseudopotentials" << endl;616 *output << endl;617 *output << "ProcPEGamma\t" << config::ProcPEGamma << "\t# for parallel computing: share constants" << endl;618 *output << "ProcPEPsi\t" << config::ProcPEPsi << "\t# for parallel computing: share wave functions" << endl;619 *output << "DoOutVis\t" << config::DoOutVis << "\t# Output data for OpenDX" << endl;620 *output << "DoOutMes\t" << config::DoOutMes << "\t# Output data for measurements" << endl;621 *output << "DoOutOrbitals\t" << config::DoOutOrbitals << "\t# Output all Orbitals" << endl;622 *output << "DoOutCurr\t" << config::DoOutCurrent << "\t# Ouput current density for OpenDx" << endl;623 *output << "DoOutNICS\t" << config::DoOutNICS << "\t# Output Nucleus independent current shieldings" << endl;624 *output << "DoPerturbation\t" << config::DoPerturbation << "\t# Do perturbation calculate and determine susceptibility and shielding" << endl;625 *output << "DoFullCurrent\t" << config::DoFullCurrent << "\t# Do full perturbation" << endl;626 *output << "DoConstrainedMD\t" << config::DoConstrainedMD << "\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD" << endl;627 *output << "Thermostat\t" << Thermostats->activeThermostat->name() << "\t";628 *output << Thermostats->activeThermostat->writeParams();629 *output << "\t# Which Thermostat and its parameters to use in MD case." << endl;630 *output << "CommonWannier\t" << config::CommonWannier << "\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center" << endl;631 *output << "SawtoothStart\t" << config::SawtoothStart << "\t# Absolute value for smooth transition at cell border " << endl;632 *output << "VectorPlane\t" << config::VectorPlane << "\t# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot" << endl;633 *output << "VectorCut\t" << config::VectorCut << "\t# Cut plane axis value" << endl;634 *output << "AddGramSch\t" << config::UseAddGramSch << "\t# Additional GramSchmidtOrtogonalization to be safe" << endl;635 *output << "Seed\t\t" << config::Seed << "\t# initial value for random seed for Psi coefficients" << endl;636 *output << endl;637 *output << "MaxOuterStep\t" << config::MaxOuterStep << "\t# number of MolecularDynamics/Structure optimization steps" << endl;638 *output << "Deltat\t" << config::Deltat << "\t# time per MD step" << endl;639 *output << "OutVisStep\t" << config::OutVisStep << "\t# Output visual data every ...th step" << endl;640 *output << "OutSrcStep\t" << config::OutSrcStep << "\t# Output \"restart\" data every ..th step" << endl;641 *output << "TargetTemp\t" << Thermostats->TargetTemp << "\t# Target temperature" << endl;642 *output << "MaxPsiStep\t" << config::MaxPsiStep << "\t# number of Minimisation steps per state (0 - default)" << endl;643 *output << "EpsWannier\t" << config::EpsWannier << "\t# tolerance value for spread minimisation of orbitals" << endl;644 *output << endl;645 *output << "# Values specifying when to stop" << endl;646 *output << "MaxMinStep\t" << config::MaxMinStep << "\t# Maximum number of steps" << endl;647 *output << "RelEpsTotalE\t" << config::RelEpsTotalEnergy << "\t# relative change in total energy" << endl;648 *output << "RelEpsKineticE\t" << config::RelEpsKineticEnergy << "\t# relative change in kinetic energy" << endl;649 *output << "MaxMinStopStep\t" << config::MaxMinStopStep << "\t# check every ..th steps" << endl;650 *output << "MaxMinGapStopStep\t" << config::MaxMinGapStopStep << "\t# check every ..th steps" << endl;651 *output << endl;652 *output << "# Values specifying when to stop for INIT, otherwise same as above" << endl;653 *output << "MaxInitMinStep\t" << config::MaxInitMinStep << "\t# Maximum number of steps" << endl;654 *output << "InitRelEpsTotalE\t" << config::InitRelEpsTotalEnergy << "\t# relative change in total energy" << endl;655 *output << "InitRelEpsKineticE\t" << config::InitRelEpsKineticEnergy << "\t# relative change in kinetic energy" << endl;656 *output << "InitMaxMinStopStep\t" << config::InitMaxMinStopStep << "\t# check every ..th steps" << endl;657 *output << "InitMaxMinGapStopStep\t" << config::InitMaxMinGapStopStep << "\t# check every ..th steps" << endl;658 *output << endl;659 *output << "BoxLength\t\t\t# (Length of a unit cell)" << endl;660 *output << domain.at(0,0) << "\t" << endl;661 *output << domain.at(1,0) << "\t" << domain.at(1,1) << "\t" << endl;662 *output << domain.at(2,0) << "\t" << domain.at(2,1) << "\t" << domain.at(2,2) << "\t" << endl;663 // FIXME664 *output << endl;665 *output << "ECut\t\t" << config::ECut << "\t# energy cutoff for discretization in Hartrees" << endl;666 *output << "MaxLevel\t" << config::MaxLevel << "\t# number of different levels in the code, >=2" << endl;667 *output << "Level0Factor\t" << config::Lev0Factor << "\t# factor by which node number increases from S to 0 level" << endl;668 *output << "RiemannTensor\t" << config::RiemannTensor << "\t# (Use metric)" << endl;669 switch (config::RiemannTensor) {670 case 0: //UseNoRT671 break;672 case 1: // UseRT673 *output << "RiemannLevel\t" << config::RiemannLevel << "\t# Number of Riemann Levels" << endl;674 *output << "LevRFactor\t" << config::LevRFactor << "\t# factor by which node number increases from 0 to R level from" << endl;675 break;676 }677 *output << "PsiType\t\t" << config::PsiType << "\t# 0 - doubly occupied, 1 - SpinUp,SpinDown" << endl;678 // write out both types for easier changing afterwards679 // switch (PsiType) {680 // case 0:681 *output << "MaxPsiDouble\t" << config::MaxPsiDouble << "\t# here: specifying both maximum number of SpinUp- and -Down-states" << endl;682 // break;683 // case 1:684 *output << "PsiMaxNoUp\t" << config::PsiMaxNoUp << "\t# here: specifying maximum number of SpinUp-states" << endl;685 *output << "PsiMaxNoDown\t" << config::PsiMaxNoDown << "\t# here: specifying maximum number of SpinDown-states" << endl;686 // break;687 // }688 *output << "AddPsis\t\t" << config::AddPsis << "\t# Additional unoccupied Psis for bandgap determination" << endl;689 *output << endl;690 *output << "RCut\t\t" << config::RCut << "\t# R-cut for the ewald summation" << endl;691 *output << "StructOpt\t" << config::StructOpt << "\t# Do structure optimization beforehand" << endl;692 *output << "IsAngstroem\t" << config::IsAngstroem << "\t# 0 - Bohr, 1 - Angstroem" << endl;693 *output << "RelativeCoord\t" << config::RelativeCoord << "\t# whether ion coordinates are relative (1) or absolute (0)" << endl;694 *output << "MaxTypes\t" << mol->getElementCount() << "\t# maximum number of different ion types" << endl;695 *output << endl;696 result = result && mol->Checkout(output);697 if (mol->MDSteps <=1 )698 result = result && mol->Output(output);699 else700 result = result && mol->OutputTrajectories(output);701 output->close();702 output->clear();703 delete(output);704 return result;705 } else {706 ELOG(1, "Cannot open output file:" << filename);707 return false;708 }709 };710 711 /** Stores all elements in a MPQC input file.712 * Note that this format cannot be parsed again.713 * \param *filename name of file (without ".in" suffix!)714 * \param *mol pointer to molecule containing all atoms of the molecule715 */716 bool config::SaveMPQC(const char * const filename, const molecule * const mol) const717 {718 Vector *center = NULL;719 ofstream *output = NULL;720 721 // first without hessian722 {723 stringstream * const fname = new stringstream;;724 *fname << filename << ".in";725 output = new ofstream(fname->str().c_str(), ios::out);726 if (output == NULL) {727 ELOG(1, "Cannot open mpqc output file:" << fname);728 delete(fname);729 return false;730 }731 *output << "% Created by MoleCuilder" << endl;732 *output << "mpqc: (" << endl;733 *output << "\tsavestate = no" << endl;734 *output << "\tdo_gradient = yes" << endl;735 *output << "\tmole<MBPT2>: (" << endl;736 *output << "\t\tmaxiter = 200" << endl;737 *output << "\t\tbasis = $:basis" << endl;738 *output << "\t\tmolecule = $:molecule" << endl;739 *output << "\t\treference<CLHF>: (" << endl;740 *output << "\t\t\tbasis = $:basis" << endl;741 *output << "\t\t\tmolecule = $:molecule" << endl;742 *output << "\t\t)" << endl;743 *output << "\t)" << endl;744 *output << ")" << endl;745 *output << "molecule<Molecule>: (" << endl;746 *output << "\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl;747 *output << "\t{ atoms geometry } = {" << endl;748 center = mol->DetermineCenterOfAll();749 // output of atoms750 for(molecule::const_iterator iter = mol->begin(); iter!=mol->end();++iter){751 (*iter)->OutputMPQCLine(output,center);752 }753 delete(center);754 *output << "\t}" << endl;755 *output << ")" << endl;756 *output << "basis<GaussianBasisSet>: (" << endl;757 *output << "\tname = \"3-21G\"" << endl;758 *output << "\tmolecule = $:molecule" << endl;759 *output << ")" << endl;760 output->close();761 delete(output);762 delete(fname);763 }764 765 // second with hessian766 {767 stringstream * const fname = new stringstream;768 *fname << filename << ".hess.in";769 output = new ofstream(fname->str().c_str(), ios::out);770 if (output == NULL) {771 ELOG(1, "Cannot open mpqc hessian output file:" << fname);772 delete(fname);773 return false;774 }775 *output << "% Created by MoleCuilder" << endl;776 *output << "mpqc: (" << endl;777 *output << "\tsavestate = no" << endl;778 *output << "\tdo_gradient = yes" << endl;779 *output << "\tmole<CLHF>: (" << endl;780 *output << "\t\tmaxiter = 200" << endl;781 *output << "\t\tbasis = $:basis" << endl;782 *output << "\t\tmolecule = $:molecule" << endl;783 *output << "\t)" << endl;784 *output << "\tfreq<MolecularFrequencies>: (" << endl;785 *output << "\t\tmolecule=$:molecule" << endl;786 *output << "\t)" << endl;787 *output << ")" << endl;788 *output << "molecule<Molecule>: (" << endl;789 *output << "\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl;790 *output << "\t{ atoms geometry } = {" << endl;791 center = mol->DetermineCenterOfAll();792 // output of atoms793 for(molecule::const_iterator iter = mol->begin(); iter!=mol->end();++iter){794 (*iter)->OutputMPQCLine(output,center);795 }796 delete(center);797 *output << "\t}" << endl;798 *output << ")" << endl;799 *output << "basis<GaussianBasisSet>: (" << endl;800 *output << "\tname = \"3-21G\"" << endl;801 *output << "\tmolecule = $:molecule" << endl;802 *output << ")" << endl;803 output->close();804 delete(output);805 delete(fname);806 }807 808 return true;809 };810 811 /** Stores all atoms from all molecules in a PDB input file.812 * Note that this format cannot be parsed again.813 * \param *filename name of file (without ".in" suffix!)814 * \param *MolList pointer to MoleculeListClass containing all atoms815 */816 bool config::SavePDB(const char * const filename, const MoleculeListClass * const MolList) const817 {818 int AtomNo = -1;819 int MolNo = 0;820 FILE *f = NULL;821 822 char name[MAXSTRINGSIZE];823 strncpy(name, filename, MAXSTRINGSIZE-1);824 strncat(name, ".pdb", MAXSTRINGSIZE-(strlen(name)+1));825 f = fopen(name, "w" );826 if (f == NULL) {827 ELOG(1, "Cannot open pdb output file:" << name);828 return false;829 }830 fprintf(f, "# Created by MoleCuilder\n");831 832 for (MoleculeList::const_iterator MolRunner = MolList->ListOfMolecules.begin(); MolRunner != MolList->ListOfMolecules.end(); MolRunner++) {833 int *elementNo = new int[MAX_ELEMENTS];834 for (int i=0;i<MAX_ELEMENTS;i++)835 elementNo[i] = 0;836 AtomNo = 0;837 for (molecule::const_iterator iter = (*MolRunner)->begin(); iter != (*MolRunner)->end(); ++iter) {838 sprintf(name, "%2s%2d",(*iter)->getType()->getSymbol().c_str(), elementNo[(*iter)->getType()->getAtomicNumber()]);839 elementNo[(*iter)->getType()->getAtomicNumber()] = (elementNo[(*iter)->getType()->getAtomicNumber()]+1) % 100; // confine to two digits840 fprintf(f,841 "ATOM %6u %-4s %4s%c%4u %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%2s\n",842 (*iter)->getNr(), /* atom serial number */843 name, /* atom name */844 (*MolRunner)->name, /* residue name */845 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */846 MolNo, /* residue sequence number */847 (*iter)->at(0), /* position X in Angstroem */848 (*iter)->at(1), /* position Y in Angstroem */849 (*iter)->at(2), /* position Z in Angstroem */850 (double)(*iter)->getType()->getValence(), /* occupancy */851 (double)(*iter)->getType()->getNoValenceOrbitals(), /* temperature factor */852 "0", /* segment identifier */853 (*iter)->getType()->getSymbol().c_str(), /* element symbol */854 "0"); /* charge */855 AtomNo++;856 }857 delete[](elementNo);858 MolNo++;859 }860 fclose(f);861 862 return true;863 };864 865 /** Stores all atoms in a PDB input file.866 * Note that this format cannot be parsed again.867 * \param *filename name of file (without ".in" suffix!)868 * \param *mol pointer to molecule869 */870 bool config::SavePDB(const char * const filename, const molecule * const mol) const871 {872 int AtomNo = -1;873 FILE *f = NULL;874 875 int *elementNo = new int[MAX_ELEMENTS];876 for (int i=0;i<MAX_ELEMENTS;i++)877 elementNo[i] = 0;878 char name[MAXSTRINGSIZE];879 strncpy(name, filename, MAXSTRINGSIZE-1);880 strncat(name, ".pdb", MAXSTRINGSIZE-(strlen(name)+1));881 f = fopen(name, "w" );882 if (f == NULL) {883 ELOG(1, "Cannot open pdb output file:" << name);884 delete[](elementNo);885 return false;886 }887 fprintf(f, "# Created by MoleCuilder\n");888 889 AtomNo = 0;890 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {891 sprintf(name, "%2s%2d",(*iter)->getType()->getSymbol().c_str(), elementNo[(*iter)->getType()->getAtomicNumber()]);892 elementNo[(*iter)->getType()->getAtomicNumber()] = (elementNo[(*iter)->getType()->getAtomicNumber()]+1) % 100; // confine to two digits893 fprintf(f,894 "ATOM %6u %-4s %4s%c%4u %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%2s\n",895 (*iter)->getNr(), /* atom serial number */896 name, /* atom name */897 mol->name, /* residue name */898 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */899 0, /* residue sequence number */900 (*iter)->at(0), /* position X in Angstroem */901 (*iter)->at(1), /* position Y in Angstroem */902 (*iter)->at(2), /* position Z in Angstroem */903 (double)(*iter)->getType()->getValence(), /* occupancy */904 (double)(*iter)->getType()->getNoValenceOrbitals(), /* temperature factor */905 "0", /* segment identifier */906 (*iter)->getType()->getSymbol().c_str(), /* element symbol */907 "0"); /* charge */908 AtomNo++;909 }910 fclose(f);911 delete[](elementNo);912 913 return true;914 };915 916 /** Stores all atoms in a TREMOLO data input file.917 * Note that this format cannot be parsed again.918 * Note that TREMOLO does not like Id starting at 0, but at 1. Atoms with Id 0 are discarded!919 * \param *filename name of file (without ".in" suffix!)920 * \param *mol pointer to molecule921 */922 bool config::SaveTREMOLO(const char * const filename, const molecule * const mol) const923 {924 ofstream *output = NULL;925 stringstream * const fname = new stringstream;926 927 *fname << filename << ".data";928 output = new ofstream(fname->str().c_str(), ios::out);929 if (output == NULL) {930 ELOG(1, "Cannot open tremolo output file:" << fname);931 delete(fname);932 return false;933 }934 935 // scan maximum number of neighbours936 int MaxNeighbours = 0;937 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {938 const int count = (*iter)->getListOfBonds().size();939 if (MaxNeighbours < count)940 MaxNeighbours = count;941 }942 *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl;943 944 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {945 *output << (*iter)->getNr() << "\t";946 *output << (*iter)->getName() << "\t";947 *output << mol->name << "\t";948 *output << 0 << "\t";949 *output << (*iter)->at(0) << "\t" << (*iter)->at(1) << "\t" << (*iter)->at(2) << "\t";950 *output << static_cast<double>((*iter)->getType()->getValence()) << "\t";951 *output << (*iter)->getType()->getSymbol() << "\t";952 const BondList& ListOfBonds = (*iter)->getListOfBonds();953 for (BondList::const_iterator runner = ListOfBonds.begin();954 runner != ListOfBonds.end();955 runner++) {956 *output << (*runner)->GetOtherAtom(*iter)->getNr() << "\t";957 }958 for(int i = ListOfBonds.size(); i < MaxNeighbours; i++)959 *output << "-\t";960 *output << endl;961 }962 output->flush();963 output->close();964 delete(output);965 delete(fname);966 967 return true;968 };969 970 /** Stores all atoms from all molecules in a TREMOLO data input file.971 * Note that this format cannot be parsed again.972 * Note that TREMOLO does not like Id starting at 0, but at 1. Atoms with Id 0 are discarded!973 * \param *filename name of file (without ".in" suffix!)974 * \param *MolList pointer to MoleculeListClass containing all atoms975 */976 bool config::SaveTREMOLO(const char * const filename, const MoleculeListClass * const MolList) const977 {978 Info FunctionInfo(__func__);979 ofstream *output = NULL;980 stringstream * const fname = new stringstream;981 982 *fname << filename << ".data";983 output = new ofstream(fname->str().c_str(), ios::out);984 if (output == NULL) {985 ELOG(1, "Cannot open tremolo output file:" << fname);986 delete(fname);987 return false;988 }989 990 // scan maximum number of neighbours991 int MaxNeighbours = 0;992 for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {993 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {994 const int count = (*iter)->getListOfBonds().size();995 if (MaxNeighbours < count)996 MaxNeighbours = count;997 }998 }999 *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl;1000 1001 // create global to local id map1002 map<int, int> LocalNotoGlobalNoMap;1003 {1004 unsigned int MolCounter = 0;1005 int AtomNo = 1;1006 for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {1007 for(molecule::iterator AtomRunner = (*MolWalker)->begin(); AtomRunner != (*MolWalker)->end(); ++AtomRunner) {1008 LocalNotoGlobalNoMap.insert( pair<int,int>((*AtomRunner)->getId(), AtomNo++) );1009 }1010 MolCounter++;1011 }1012 ASSERT(MolCounter == MolList->ListOfMolecules.size(), "SaveTREMOLO: LocalNotoGlobalNoMap[] has not been correctly initialized for each molecule");1013 }1014 1015 // write the file1016 {1017 int MolCounter = 0;1018 int AtomNo = 0;1019 for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {1020 for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {1021 *output << LocalNotoGlobalNoMap[ (*iter)->getId() ] << "\t";1022 *output << (*iter)->getName() << "\t";1023 *output << (*MolWalker)->name << "\t";1024 *output << MolCounter+1 << "\t";1025 *output << (*iter)->at(0) << "\t" << (*iter)->at(1) << "\t" << (*iter)->at(2) << "\t";1026 *output << (double)(*iter)->getType()->getValence() << "\t";1027 *output << (*iter)->getType()->getSymbol() << "\t";1028 const BondList& ListOfBonds = (*iter)->getListOfBonds();1029 for (BondList::const_iterator runner = ListOfBonds.begin();1030 runner != ListOfBonds.end();1031 runner++) {1032 *output << LocalNotoGlobalNoMap[ (*runner)->GetOtherAtom((*iter))->getId() ] << "\t";1033 }1034 for(int i = ListOfBonds.size(); i < MaxNeighbours; i++)1035 *output << "-\t";1036 *output << endl;1037 AtomNo++;1038 }1039 MolCounter++;1040 }1041 }1042 1043 // store & free1044 output->flush();1045 output->close();1046 delete(output);1047 delete(fname);1048 1049 return true;1050 };1051 1052 1053 /** Tries given filename or standard on saving the config file.1054 * \param *ConfigFileName name of file1055 * \param *periode pointer to periodentafel structure with all the elements1056 * \param *molecules list of molecules structure with all the atoms and coordinates1057 */1058 void config::SaveAll(char *ConfigFileName, periodentafel *periode, MoleculeListClass *molecules)1059 {1060 char filename[MAXSTRINGSIZE];1061 ofstream output;1062 molecule *mol = NULL;1063 1064 // first save as PDB data1065 if (ConfigFileName != NULL)1066 strcpy(filename, ConfigFileName);1067 if (output == NULL)1068 strcpy(filename,"main_pcp_linux");1069 if (SavePDB(filename, molecules))1070 LOG(0, "Saving as pdb input done.");1071 else1072 LOG(0, "Saving as pdb input failed.");1073 1074 // then save as tremolo data file1075 if (ConfigFileName != NULL)1076 strcpy(filename, ConfigFileName);1077 if (output == NULL)1078 strcpy(filename,"main_pcp_linux");1079 if (SaveTREMOLO(filename, molecules))1080 LOG(0, "Saving as tremolo data input done.");1081 else1082 LOG(0, "Saving as tremolo data input failed.");1083 1084 // translate each to its center and merge all molecules in MoleculeListClass into this molecule1085 int N = molecules->ListOfMolecules.size();1086 if (N != 1) { // don't do anything in case of only one molecule (shifts mol ids otherwise)1087 int *src = new int[N];1088 N=0;1089 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {1090 src[N++] = (*ListRunner)->IndexNr;1091 }1092 mol = World::getInstance().createMolecule();1093 mol->SetNameFromFilename(ConfigFileName);1094 //mol->CalculateOrbitals(*this);1095 delete[](src);1096 } else {1097 if (!molecules->ListOfMolecules.empty()) {1098 mol = *(molecules->ListOfMolecules.begin());1099 mol->doCountAtoms();1100 //mol->CalculateOrbitals(*this);1101 } else {1102 ELOG(1, "There are no molecules to save!");1103 }1104 }1105 1106 LOG(0, "Storing configuration ... ");1107 // get correct valence orbitals1108 if (ConfigFileName != NULL) { // test the file name1109 strcpy(filename, ConfigFileName);1110 output.open(filename, ios::trunc);1111 } else if (strlen(configname) != 0) {1112 strcpy(filename, configname);1113 output.open(configname, ios::trunc);1114 } else {1115 strcpy(filename, DEFAULTCONFIG);1116 output.open(DEFAULTCONFIG, ios::trunc);1117 }1118 output.close();1119 output.clear();1120 if (Save(filename, periode, mol))1121 LOG(0, "Saving of config file done.");1122 else1123 LOG(0, "Saving of config file failed.");1124 1125 // and save to xyz file1126 if (ConfigFileName != NULL) {1127 strcpy(filename, ConfigFileName);1128 strcat(filename, ".xyz");1129 output.open(filename, ios::trunc);1130 }1131 if (output == NULL) {1132 strcpy(filename,"main_pcp_linux");1133 strcat(filename, ".xyz");1134 output.open(filename, ios::trunc);1135 }1136 if (mol->MDSteps <= 1) {1137 if (mol->OutputXYZ(&output))1138 LOG(0, "Saving of XYZ file done.");1139 else1140 LOG(0, "Saving of XYZ file failed.");1141 } else {1142 if (mol->OutputTrajectoriesXYZ(&output))1143 LOG(0, "Saving of XYZ file done.");1144 else1145 LOG(0, "Saving of XYZ file failed.");1146 }1147 output.close();1148 output.clear();1149 1150 // and save as MPQC configuration1151 if (ConfigFileName != NULL)1152 strcpy(filename, ConfigFileName);1153 if (output == NULL)1154 strcpy(filename,"main_pcp_linux");1155 if (SaveMPQC(filename, mol))1156 LOG(0, "Saving as mpqc input done.");1157 else1158 LOG(0, "Saving as mpqc input failed.");1159 1160 // don't destroy molecule as it contains all our atoms1161 //World::getInstance().destroyMolecule(mol);1162 };1163 1164 /** Reads parameter from a parsed file.1165 * The file is either parsed for a certain keyword or if null is given for1166 * the value in row yth and column xth. If the keyword was necessity#critical,1167 * then an error is thrown and the programme aborted.1168 * \warning value is modified (both in contents and position)!1169 * \param verbose 1 - print found value to stderr, 0 - don't1170 * \param *file file to be parsed1171 * \param name Name of value in file (at least 3 chars!)1172 * \param sequential 1 - do not reset file pointer to begin of file, 0 - set to beginning1173 * (if file is sequentially parsed this can be way faster! However, beware of multiple values per line, as whole line is read -1174 * best approach: 0 0 0 1 (not resetted only on last value of line) - and of yth, which is now1175 * counted from this unresetted position!)1176 * \param xth Which among a number of parameters it is (in grid case it's row number as grid is read as a whole!)1177 * \param yth In grid case specifying column number, otherwise the yth \a name matching line1178 * \param type Type of the Parameter to be read1179 * \param value address of the value to be read (must have been allocated)1180 * \param repetition determines, if the keyword appears multiply in the config file, which repetition shall be parsed, i.e. 1 if not multiply1181 * \param critical necessity of this keyword being specified (optional, critical)1182 * \return 1 - found, 0 - not found1183 * \note Routine is taken from the pcp project and hack-a-slack adapted to C++1184 */1185 int ParseForParameter(const int verbose, ifstream * const file, const char * const name, const int sequential, const int xth, const int yth, const int type, void * value, const int repetition, const int critical) {1186 int i = 0;1187 int j = 0; // loop variables1188 int length = 0;1189 int maxlength = -1;1190 long file_position = file->tellg(); // mark current position1191 char *dummy1 = NULL;1192 char *dummy = NULL;1193 char free_dummy[MAXSTRINGSIZE]; // pointers in the line that is read in per step1194 dummy1 = free_dummy;1195 1196 //fprintf(stderr,"Parsing for %s\n",name);1197 if (repetition == 0)1198 //Error(SomeError, "ParseForParameter(): argument repetition must not be 0!");1199 return 0;1200 1201 int line = 0; // marks line where parameter was found1202 int found = (type >= grid) ? 0 : (-yth + 1); // marks if yth parameter name was found1203 while((found != repetition)) {1204 dummy1 = dummy = free_dummy;1205 do {1206 file->getline(dummy1, 256); // Read the whole line1207 if (file->eof()) {1208 if ((critical) && (found == 0)) {1209 //Error(InitReading, name);1210 fprintf(stderr,"Error:InitReading, critical %s not found\n", name);1211 exit(255);1212 } else {1213 //if (!sequential)1214 file->clear();1215 file->seekg(file_position, ios::beg); // rewind to start position1216 return 0;1217 }1218 }1219 line++;1220 } while (dummy != NULL && dummy1 != NULL && ((dummy1[0] == '#') || (dummy1[0] == '\0'))); // skip commentary and empty lines1221 1222 // C++ getline removes newline at end, thus re-add1223 if ((dummy1 != NULL) && (strchr(dummy1,'\n') == NULL)) {1224 i = strlen(dummy1);1225 dummy1[i] = '\n';1226 dummy1[i+1] = '\0';1227 }1228 //fprintf(stderr,"line %i ends at %i, newline at %i\n", line, strlen(dummy1), strchr(dummy1,'\n')-free_dummy);1229 1230 if (dummy1 == NULL) {1231 if (verbose) fprintf(stderr,"Error reading line %i\n",line);1232 } else {1233 //fprintf(stderr,"Now parsing the line %i: %s\n", line, dummy1);1234 }1235 // Seek for possible end of keyword on line if given ...1236 if (name != NULL) {1237 dummy = strchr(dummy1,'\t'); // set dummy on first tab or space which ever's nearer1238 if (dummy == NULL) {1239 dummy = strchr(dummy1, ' '); // if not found seek for space1240 while ((dummy != NULL) && ((*dummy == '\t') || (*dummy == ' '))) // skip some more tabs and spaces if necessary1241 dummy++;1242 }1243 if (dummy == NULL) {1244 dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword)1245 //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name);1246 //Error(FileOpenParams, NULL);1247 } else {1248 //fprintf(stderr,"found tab at %i\n",(char *)dummy-(char *)dummy1);1249 }1250 } else dummy = dummy1;1251 // ... and check if it is the keyword!1252 //fprintf(stderr,"name %p, dummy %i/%c, dummy1 %i/%c, strlen(name) %i\n", &name, dummy, *dummy, dummy1, *dummy1, strlen(name));1253 if ((name == NULL) || (((dummy-dummy1 >= 3) && (strncmp(dummy1, name, strlen(name)) == 0)) && ((unsigned int)(dummy-dummy1) == strlen(name)))) {1254 found++; // found the parameter!1255 //fprintf(stderr,"found %s at line %i between %i and %i\n", name, line, dummy1, dummy);1256 1257 if (found == repetition) {1258 for (i=0;i<xth;i++) { // i = rows1259 if (type >= grid) {1260 // grid structure means that grid starts on the next line, not right after keyword1261 dummy1 = dummy = free_dummy;1262 do {1263 file->getline(dummy1, 256); // Read the whole line, skip commentary and empty ones1264 if (file->eof()) {1265 if ((critical) && (found == 0)) {1266 //Error(InitReading, name);1267 fprintf(stderr,"Error:InitReading, critical %s not found\n", name);1268 exit(255);1269 } else {1270 //if (!sequential)1271 file->clear();1272 file->seekg(file_position, ios::beg); // rewind to start position1273 return 0;1274 }1275 }1276 line++;1277 } while ((dummy1[0] == '#') || (dummy1[0] == '\n'));1278 if (dummy1 == NULL){1279 if (verbose) fprintf(stderr,"Error reading line %i\n", line);1280 } else {1281 //fprintf(stderr,"Reading next line %i: %s\n", line, dummy1);1282 }1283 } else { // simple int, strings or doubles start in the same line1284 while ((*dummy == '\t') || (*dummy == ' ')) // skip interjacent tabs and spaces1285 dummy++;1286 }1287 // C++ getline removes newline at end, thus re-add1288 if ((dummy1 != NULL) && (strchr(dummy1,'\n') == NULL)) {1289 j = strlen(dummy1);1290 dummy1[j] = '\n';1291 dummy1[j+1] = '\0';1292 }1293 1294 int start = (type >= grid) ? 0 : yth-1 ;1295 for (j=start;j<yth;j++) { // j = columns1296 // check for lower triangular area and upper triangular area1297 if ( ((i > j) && (type == upper_trigrid)) || ((j > i) && (type == lower_trigrid))) {1298 *((double *)value) = 0.0;1299 fprintf(stderr,"%f\t",*((double *)value));1300 value = (void *)((long)value + sizeof(double));1301 //value += sizeof(double);1302 } else {1303 // otherwise we must skip all interjacent tabs and spaces and find next value1304 dummy1 = dummy;1305 dummy = strchr(dummy1, '\t'); // seek for tab or space1306 if (dummy == NULL)1307 dummy = strchr(dummy1, ' '); // if not found seek for space1308 if (dummy == NULL) { // if still zero returned ...1309 dummy = strchr(dummy1, '\n'); // ... at line end then1310 if ((j < yth-1) && (type < 4)) { // check if xth value or not yet1311 if (critical) {1312 if (verbose) fprintf(stderr,"Error: EoL at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name);1313 //return 0;1314 exit(255);1315 //Error(FileOpenParams, NULL);1316 } else {1317 //if (!sequential)1318 file->clear();1319 file->seekg(file_position, ios::beg); // rewind to start position1320 return 0;1321 }1322 }1323 } else {1324 //fprintf(stderr,"found tab at %i\n",(char *)dummy-(char *)free_dummy);1325 }1326 if (*dummy1 == '#') {1327 // found comment, skipping rest of line1328 //if (verbose) fprintf(stderr,"Error: '#' at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name);1329 if (!sequential) { // here we need it!1330 file->seekg(file_position, ios::beg); // rewind to start position1331 }1332 return 0;1333 }1334 //fprintf(stderr,"value from %i to %i\n",(char *)dummy1-(char *)free_dummy,(char *)dummy-(char *)free_dummy);1335 switch(type) {1336 case (row_int):1337 *((int *)value) = atoi(dummy1);1338 if ((verbose) && (i==0) && (j==0)) fprintf(stderr,"%s = ", name);1339 if (verbose) fprintf(stderr,"%i\t",*((int *)value));1340 value = (void *)((long)value + sizeof(int));1341 //value += sizeof(int);1342 break;1343 case(row_double):1344 case(grid):1345 case(lower_trigrid):1346 case(upper_trigrid):1347 *((double *)value) = atof(dummy1);1348 if ((verbose) && (i==0) && (j==0)) fprintf(stderr,"%s = ", name);1349 if (verbose) fprintf(stderr,"%lg\t",*((double *)value));1350 value = (void *)((long)value + sizeof(double));1351 //value += sizeof(double);1352 break;1353 case(double_type):1354 *((double *)value) = atof(dummy1);1355 if ((verbose) && (i == xth-1)) fprintf(stderr,"%s = %lg\n", name, *((double *) value));1356 //value += sizeof(double);1357 break;1358 case(int_type):1359 *((int *)value) = atoi(dummy1);1360 if ((verbose) && (i == xth-1)) fprintf(stderr,"%s = %i\n", name, *((int *) value));1361 //value += sizeof(int);1362 break;1363 default:1364 case(string_type):1365 if (value != NULL) {1366 //if (maxlength == -1) maxlength = strlen((char *)value); // get maximum size of string array1367 maxlength = MAXSTRINGSIZE;1368 length = maxlength > (dummy-dummy1) ? (dummy-dummy1) : maxlength; // cap at maximum1369 strncpy((char *)value, dummy1, length); // copy as much1370 ((char *)value)[length] = '\0'; // and set end marker1371 if ((verbose) && (i == xth-1)) fprintf(stderr,"%s is '%s' (%i chars)\n",name,((char *) value), length);1372 //value += sizeof(char);1373 } else {1374 }1375 break;1376 }1377 }1378 while (*dummy == '\t')1379 dummy++;1380 }1381 }1382 }1383 }1384 }1385 if ((type >= row_int) && (verbose))1386 fprintf(stderr,"\n");1387 if (!sequential) {1388 file->clear();1389 file->seekg(file_position, ios::beg); // rewind to start position1390 }1391 //fprintf(stderr, "End of Parsing\n\n");1392 1393 return (found); // true if found, false if not1394 }1395 1396 1397 /** Reads parameter from a parsed file.1398 * The file is either parsed for a certain keyword or if null is given for1399 * the value in row yth and column xth. If the keyword was necessity#critical,1400 * then an error is thrown and the programme aborted.1401 * \warning value is modified (both in contents and position)!1402 * \param verbose 1 - print found value to stderr, 0 - don't1403 * \param *FileBuffer pointer to buffer structure1404 * \param name Name of value in file (at least 3 chars!)1405 * \param sequential 1 - do not reset file pointer to begin of file, 0 - set to beginning1406 * (if file is sequentially parsed this can be way faster! However, beware of multiple values per line, as whole line is read -1407 * best approach: 0 0 0 1 (not resetted only on last value of line) - and of yth, which is now1408 * counted from this unresetted position!)1409 * \param xth Which among a number of parameters it is (in grid case it's row number as grid is read as a whole!)1410 * \param yth In grid case specifying column number, otherwise the yth \a name matching line1411 * \param type Type of the Parameter to be read1412 * \param value address of the value to be read (must have been allocated)1413 * \param repetition determines, if the keyword appears multiply in the config file, which repetition shall be parsed, i.e. 1 if not multiply1414 * \param critical necessity of this keyword being specified (optional, critical)1415 * \return 1 - found, 0 - not found1416 * \note Routine is taken from the pcp project and hack-a-slack adapted to C++1417 */1418 int ParseForParameter(const int verbose, struct ConfigFileBuffer * const FileBuffer, const char * const name, const int sequential, const int xth, const int yth, const int type, void * value, const int repetition, const int critical) {1419 int i = 0;1420 int j = 0; // loop variables1421 int length = 0;1422 int maxlength = -1;1423 int OldCurrentLine = FileBuffer->CurrentLine;1424 char *dummy1 = NULL;1425 char *dummy = NULL; // pointers in the line that is read in per step1426 char *free_dummy = NULL;1427 1428 if (verbose) fprintf(stderr,"Begin of Parsing for %s\n",name);1429 if (repetition == 0)1430 //Error(SomeError, "ParseForParameter(): argument repetition must not be 0!");1431 return 0;1432 1433 int found = (type >= grid) ? 0 : (-yth + 1); // marks if yth parameter name was found1434 while((found != repetition)) {1435 dummy1 = dummy = NULL;1436 do {1437 if (FileBuffer->CurrentLine < FileBuffer->NoLines)1438 free_dummy = dummy1 = FileBuffer->buffer[ FileBuffer->LineMapping[FileBuffer->CurrentLine++] ];1439 if (FileBuffer->CurrentLine >= FileBuffer->NoLines) {1440 if ((critical) && (found == 0)) {1441 //Error(InitReading, name);1442 fprintf(stderr,"Error:InitReading, critical %s not found\n", name);1443 return 0;1444 } else {1445 //fprintf(stdout,"Rewinding to OldCurrentLine due to search till end of file.\n");1446 FileBuffer->CurrentLine = OldCurrentLine; // rewind to start position1447 return 0;1448 }1449 }1450 if (dummy1 == NULL) {1451 if (verbose) fprintf(stderr,"Error reading line %i\n",FileBuffer->CurrentLine);1452 } else {1453 if (verbose) fprintf(stderr,"Now parsing the line %i: %s\n", FileBuffer->CurrentLine, dummy1);1454 }1455 //FileBuffer->CurrentLine++;1456 } while (dummy1 != NULL && ((dummy1[0] == '#') || (dummy1[0] == '\0'))); // skip commentary and empty lines1457 1458 // Seek for possible end of keyword on line if given ...1459 if (name != NULL) {1460 dummy = strchr(dummy1,'\t'); // set dummy on first tab or space which ever's nearer1461 if (dummy == NULL) {1462 dummy = strchr(dummy1, ' '); // if not found seek for space1463 while ((dummy != NULL) && ((*dummy == '\t') || (*dummy == ' '))) // skip some more tabs and spaces if necessary1464 dummy++;1465 }1466 if (dummy == NULL) {1467 dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword)1468 //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name);1469 //Error(FileOpenParams, NULL);1470 } else {1471 if (verbose) fprintf(stderr,"found tab at line %i at position %li\n",FileBuffer->CurrentLine, (char *)dummy-(char *)dummy1);1472 }1473 } else dummy = dummy1;1474 // ... and check if it is the keyword!1475 //fprintf(stderr,"name %p, dummy %i/%c, dummy1 %i/%c, strlen(name) %i\n", &name, dummy, *dummy, dummy1, *dummy1, strlen(name));1476 if ((name == NULL) || (((dummy-dummy1 >= 3) && (strncmp(dummy1, name, strlen(name)) == 0)) && ((unsigned int)(dummy-dummy1) == strlen(name)))) {1477 found++; // found the parameter!1478 if (verbose) fprintf(stderr,"found %s at line %i between %li and %li\n", name, FileBuffer->CurrentLine, (unsigned long)dummy1, (unsigned long)dummy);1479 1480 if (found == repetition) {1481 for (i=0;i<xth;i++) { // i = rows1482 if (type >= grid) {1483 // grid structure means that grid starts on the next line, not right after keyword1484 dummy1 = dummy = NULL;1485 do {1486 dummy1 = FileBuffer->buffer[ FileBuffer->LineMapping[ FileBuffer->CurrentLine++] ];1487 if (FileBuffer->CurrentLine >= FileBuffer->NoLines) {1488 if ((critical) && (found == 0)) {1489 //Error(InitReading, name);1490 fprintf(stderr,"Error:InitReading, critical %s not found\n", name);1491 exit(255);1492 } else {1493 //fprintf(stdout,"Rewinding to OldCurrentLine due to search till end of line.\n");1494 FileBuffer->CurrentLine = OldCurrentLine; // rewind to start position1495 return 0;1496 }1497 }1498 if (dummy1 == NULL) {1499 if (verbose) fprintf(stderr,"Error reading line %i\n", FileBuffer->CurrentLine);1500 } else {1501 if (verbose) fprintf(stderr,"Reading next line %i: %s\n", FileBuffer->CurrentLine, dummy1);1502 }1503 //FileBuffer->CurrentLine++;1504 } while ((dummy1 != NULL) && ((dummy1[0] == '#') || (dummy1[0] == '\n')));1505 dummy = dummy1;1506 } else { // simple int, strings or doubles start in the same line1507 while ((*dummy == '\t') || (*dummy == ' ')) // skip interjacent tabs and spaces1508 dummy++;1509 }1510 1511 for (j=((type >= grid) ? 0 : yth-1);j<yth;j++) { // j = columns1512 // check for lower triangular area and upper triangular area1513 if ( ((i > j) && (type == upper_trigrid)) || ((j > i) && (type == lower_trigrid))) {1514 *((double *)value) = 0.0;1515 fprintf(stderr,"%f\t",*((double *)value));1516 value = (void *)((long)value + sizeof(double));1517 //value += sizeof(double);1518 } else {1519 // otherwise we must skip all interjacent tabs and spaces and find next value1520 dummy1 = dummy;1521 dummy = strchr(dummy1, '\t'); // seek for tab or space1522 if (dummy == NULL)1523 dummy = strchr(dummy1, ' '); // if not found seek for space1524 if (dummy == NULL) { // if still zero returned ...1525 dummy = strchr(dummy1, '\n'); // ... at line end then1526 if ((j < yth-1) && (type < 4)) { // check if xth value or not yet1527 if (critical) {1528 if (verbose) fprintf(stderr,"Error: EoL at %i and still missing %i value(s) for parameter %s\n", FileBuffer->CurrentLine, yth-j, name);1529 //return 0;1530 exit(255);1531 //Error(FileOpenParams, NULL);1532 } else {1533 if (!sequential) { // here we need it!1534 //fprintf(stdout,"Rewinding to OldCurrentLine due to end of line and sequential %d.\n", sequential);1535 FileBuffer->CurrentLine = OldCurrentLine; // rewind to start position1536 }1537 return 0;1538 }1539 }1540 } else {1541 if (verbose) fprintf(stderr,"found tab at line %i at position %li\n",FileBuffer->CurrentLine, (char *)dummy-(char *)free_dummy);1542 }1543 if (*dummy1 == '#') {1544 // found comment, skipping rest of line1545 //if (verbose) fprintf(stderr,"Error: '#' at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name);1546 if (!sequential) { // here we need it!1547 //fprintf(stdout,"Rewinding to OldCurrentLine due to comment and sequential %d.\n", sequential);1548 FileBuffer->CurrentLine = OldCurrentLine; // rewind to start position1549 }1550 return 0;1551 }1552 if (verbose) fprintf(stderr,"value from %li to %li\n",(char *)dummy1-(char *)free_dummy,(char *)dummy-(char *)free_dummy);1553 switch(type) {1554 case (row_int):1555 *((int *)value) = atoi(dummy1);1556 if ((verbose) && (i==0) && (j==0)) fprintf(stderr,"%s = ", name);1557 if (verbose) fprintf(stderr,"%i\t",*((int *)value));1558 value = (void *)((long)value + sizeof(int));1559 //value += sizeof(int);1560 break;1561 case(row_double):1562 case(grid):1563 case(lower_trigrid):1564 case(upper_trigrid):1565 *((double *)value) = atof(dummy1);1566 if ((verbose) && (i==0) && (j==0)) fprintf(stderr,"%s = ", name);1567 if (verbose) fprintf(stderr,"%lg\t",*((double *)value));1568 value = (void *)((long)value + sizeof(double));1569 //value += sizeof(double);1570 break;1571 case(double_type):1572 *((double *)value) = atof(dummy1);1573 if ((verbose) && (i == xth-1)) fprintf(stderr,"%s = %lg\n", name, *((double *) value));1574 //value += sizeof(double);1575 break;1576 case(int_type):1577 *((int *)value) = atoi(dummy1);1578 if ((verbose) && (i == xth-1)) fprintf(stderr,"%s = %i\n", name, *((int *) value));1579 //value += sizeof(int);1580 break;1581 default:1582 case(string_type):1583 if (value != NULL) {1584 //if (maxlength == -1) maxlength = strlen((char *)value); // get maximum size of string array1585 maxlength = MAXSTRINGSIZE;1586 length = maxlength > (dummy-dummy1) ? (dummy-dummy1) : maxlength; // cap at maximum1587 strncpy((char *)value, dummy1, length); // copy as much1588 ((char *)value)[length] = '\0'; // and set end marker1589 if ((verbose) && (i == xth-1)) fprintf(stderr,"%s is '%s' (%i chars)\n",name,((char *) value), length);1590 //value += sizeof(char);1591 } else {1592 }1593 break;1594 }1595 }1596 while (*dummy == '\t')1597 dummy++;1598 }1599 }1600 }1601 }1602 }1603 if ((type >= row_int) && (verbose)) fprintf(stderr,"\n");1604 if (!sequential) {1605 //fprintf(stdout,"Rewinding to OldCurrentLine due to sequential %d.\n", sequential);1606 FileBuffer->CurrentLine = OldCurrentLine; // rewind to start position1607 }1608 if (verbose) fprintf(stderr, "End of Parsing for %s\n\n",name);1609 1610 return (found); // true if found, false if not1611 }1612 1613 /** Reading of Thermostat related values from parameter file.1614 * \param *fb file buffer containing the config file1615 */1616 void config::ParseThermostats(class ConfigFileBuffer * const fb)1617 {1618 char * const thermo = new char[12];1619 const int verbose = 0;1620 ThermoStatContainer *Thermostats = World::getInstance().getThermostats();1621 1622 // read desired Thermostat from file along with needed additional parameters1623 if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {1624 Thermostats->makeActive(thermo,fb);1625 } else {1626 if ((Thermostats->TargetTemp != 0))1627 LOG(2, "No thermostat chosen despite finite temperature MD, falling back to None.");1628 Thermostats->chooseNone();1629 }1630 delete[](thermo);1631 };1632 -
src/config.hpp
r47d041 r41a467 9 9 #define CONFIG_HPP_ 10 10 11 using namespace std;12 13 /*********************************************** includes ***********************************/14 15 11 // include config.h 16 12 #ifdef HAVE_CONFIG_H … … 18 14 #endif 19 15 20 #include <string>21 22 /****************************************** forward declarations *****************************/23 24 class ConfigFileBuffer;25 class molecule;26 class MoleculeListClass;27 class periodentafel;28 29 /********************************************** declarations *******************************/30 31 16 /** The config file. 32 * The class contains all parameters that control a dft run also functions to load and save.17 * The class contains some general parameters. 33 18 */ 34 19 class config { 35 20 public: 21 config(); 22 ~config(); 36 23 37 int PsiType; 38 int MaxPsiDouble; 39 int PsiMaxNoUp; 40 int PsiMaxNoDown; 41 int MaxMinStopStep; 42 int InitMaxMinStopStep; 43 int ProcPEGamma; 44 int ProcPEPsi; 45 char *configname; 24 char *databasepath; 25 char *defaultpath; 46 26 bool FastParsing; 27 int IsAngstroem; 47 28 double Deltat; 48 29 49 char *databasepath; 50 51 int DoConstrainedMD; 52 int MaxOuterStep; 53 54 private: 55 char *mainname; 56 char *defaultpath; 57 char *pseudopotpath; 58 59 int DoOutVis; 60 int DoOutMes; 61 int DoOutNICS; 62 int DoOutOrbitals; 63 int DoOutCurrent; 64 int DoFullCurrent; 65 int DoPerturbation; 66 int DoWannier; 67 int CommonWannier; 68 double SawtoothStart; 69 int VectorPlane; 70 double VectorCut; 71 int UseAddGramSch; 72 int Seed; 73 74 int OutVisStep; 75 int OutSrcStep; 76 int MaxPsiStep; 77 double EpsWannier; 78 79 int MaxMinStep; 80 double RelEpsTotalEnergy; 81 double RelEpsKineticEnergy; 82 int MaxMinGapStopStep; 83 int MaxInitMinStep; 84 double InitRelEpsTotalEnergy; 85 double InitRelEpsKineticEnergy; 86 int InitMaxMinGapStopStep; 87 88 //double BoxLength[NDIM*NDIM]; 89 90 double ECut; 91 int MaxLevel; 92 int RiemannTensor; 93 int LevRFactor; 94 int RiemannLevel; 95 int Lev0Factor; 96 int RTActualUse; 97 int AddPsis; 98 99 double RCut; 100 int StructOpt; 101 int IsAngstroem; 102 int RelativeCoord; 103 int MaxTypes; 30 bool GetIsAngstroem() const; 31 }; 104 32 105 33 106 public:107 config();108 ~config();109 110 int TestSyntax(const char * const filename, const periodentafel * const periode) const;111 bool Save(const char * const filename, const periodentafel * const periode, molecule * const mol) const;112 bool SaveMPQC(const char * const filename, const molecule * const mol) const;113 bool SavePDB(const char * const filename, const MoleculeListClass * const MolList) const;114 bool SavePDB(const char * const filename, const molecule * const mol) const;115 bool SaveTREMOLO(const char * const filename, const molecule * const mol) const;116 bool SaveTREMOLO(const char * const filename, const MoleculeListClass * const MolList) const;117 118 void SaveAll(char *ConfigFileName, periodentafel *periode, MoleculeListClass *molecules);119 120 void Edit();121 bool GetIsAngstroem() const;122 char *GetDefaultPath() const;123 void SetDefaultPath(const char * const path);124 void ParseThermostats(class ConfigFileBuffer * const fb);125 };126 127 int ParseForParameter(const int verbose, ifstream * const file, const char * const name, const int sequential, const int xth, const int yth, const int type, void * value, const int repetition, const int critical);128 int ParseForParameter(const int verbose, struct ConfigFileBuffer * const FileBuffer, const char * const name, const int sequential, const int xth, const int yth, const int type, void * value, const int repetition, const int critical);129 void LoadMolecule(molecule * const &mol, struct ConfigFileBuffer * const &FileBuffer, const periodentafel * const periode, const bool FastParsing);130 void PrepareFileBuffer(const char * const filename, struct ConfigFileBuffer *&FileBuffer);131 132 34 #endif /* CONFIG_HPP_ */
Note:
See TracChangeset
for help on using the changeset viewer.