source: src/Parser/MpqcParser.cpp@ a7a087

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
Last change on this file since a7a087 was bf3817, checked in by Frederik Heber <heber@…>, 15 years ago

Added ifdef HAVE_CONFIG and config.h include to each and every cpp file.

  • is now topmost in front of MemDebug.hpp (and any other).
  • Property mode set to 100644
File size: 4.6 KB
Line 
1/*
2 * MpqcParser.cpp
3 *
4 * Created on: 12.06.2010
5 * Author: heber
6 */
7
8// include config.h
9#ifdef HAVE_CONFIG_H
10#include <config.h>
11#endif
12
13#include "Helpers/MemDebug.hpp"
14
15#include "MpqcParser.hpp"
16
17#include "atom.hpp"
18#include "config.hpp"
19#include "element.hpp"
20#include "Helpers/Log.hpp"
21#include "Helpers/Verbose.hpp"
22#include "LinearAlgebra/Vector.hpp"
23#include "periodentafel.hpp"
24#include "World.hpp"
25
26
27/** Constructor of MpqcParser.
28 *
29 */
30MpqcParser::MpqcParser() : HessianPresent(false)
31{}
32
33/** Destructor of MpqcParser.
34 *
35 */
36MpqcParser::~MpqcParser()
37{}
38
39/** Load an MPQC config file into the World.
40 * \param *file input stream
41 */
42void MpqcParser::load(istream *file)
43{
44 DoeLog(0) && (Log() << Verbose(0) << "Not yet implemented" << endl) ;
45}
46
47void MpqcParser::save(ostream *file)
48{
49 DoLog(0) && (Log() << Verbose(0) << "Saving changes to MPQC ." << std::endl);
50
51 if (HessianPresent)
52 saveHessian(file);
53 else
54 saveSimple(file);
55}
56
57/** Saves all atoms and data into a MPQC config file without hessian.
58 * \param *file output stream
59 */
60void MpqcParser::saveSimple(ostream *file)
61{
62 int AtomNo = 0;
63 Vector center;
64 vector<atom *> allatoms = World::getInstance().getAllAtoms();
65
66 // calculate center
67 for (vector<atom *>::iterator runner = allatoms.begin();runner != allatoms.end(); ++runner)
68 center += (*runner)->getPosition();
69 center.Scale(1./allatoms.size());
70
71 // first without hessian
72 if (file->fail()) {
73 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc output file." << endl);
74 } else {
75 *file << "% Created by MoleCuilder" << endl;
76 *file << "mpqc: (" << endl;
77 *file << "\tsavestate = no" << endl;
78 *file << "\tdo_gradient = yes" << endl;
79 *file << "\tmole<MBPT2>: (" << endl;
80 *file << "\t\tmaxiter = 200" << endl;
81 *file << "\t\tbasis = $:basis" << endl;
82 *file << "\t\tmolecule = $:molecule" << endl;
83 *file << "\t\treference<CLHF>: (" << endl;
84 *file << "\t\t\tbasis = $:basis" << endl;
85 *file << "\t\t\tmolecule = $:molecule" << endl;
86 *file << "\t\t)" << endl;
87 *file << "\t)" << endl;
88 *file << ")" << endl;
89 *file << "molecule<Molecule>: (" << endl;
90 *file << "\tunit = " << (World::getInstance().getConfig()->GetIsAngstroem() ? "angstrom" : "bohr" ) << endl;
91 *file << "\t{ atoms geometry } = {" << endl;
92 // output of atoms
93 for (vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
94 (*AtomRunner)->OutputMPQCLine(file, &center, &AtomNo);
95 }
96 *file << "\t}" << endl;
97 *file << ")" << endl;
98 *file << "basis<GaussianBasisSet>: (" << endl;
99 *file << "\tname = \"" << World::getInstance().getConfig()->basis << "\"" << endl;
100 *file << "\tmolecule = $:molecule" << endl;
101 *file << ")" << endl;
102 }
103}
104
105/** Saves all atoms and data into a MPQC config file with hessian.
106 * \param *file output stream
107 */
108void MpqcParser::saveHessian(ostream *file)
109{
110 int AtomNo = 0;
111 Vector center;
112 vector<atom *> allatoms = World::getInstance().getAllAtoms();
113
114 // calculate center
115 for (vector<atom *>::iterator runner = allatoms.begin();runner != allatoms.end(); ++runner)
116 center += (*runner)->getPosition();
117 center.Scale(1./allatoms.size());
118
119 // with hessian
120 if (file->fail()) {
121 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc output file." << endl);
122 } else {
123 *file << "% Created by MoleCuilder" << endl;
124 *file << "mpqc: (" << endl;
125 *file << "\tsavestate = no" << endl;
126 *file << "\tdo_gradient = yes" << endl;
127 *file << "\tmole<CLHF>: (" << endl;
128 *file << "\t\tmaxiter = 200" << endl;
129 *file << "\t\tbasis = $:basis" << endl;
130 *file << "\t\tmolecule = $:molecule" << endl;
131 *file << "\t)" << endl;
132 *file << "\tfreq<MolecularFrequencies>: (" << endl;
133 *file << "\t\tmolecule=$:molecule" << endl;
134 *file << "\t)" << endl;
135 *file << ")" << endl;
136 *file << "molecule<Molecule>: (" << endl;
137 *file << "\tunit = " << (World::getInstance().getConfig()->GetIsAngstroem() ? "angstrom" : "bohr" ) << endl;
138 *file << "\t{ atoms geometry } = {" << endl;
139 // output of atoms
140 for (vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
141 (*AtomRunner)->OutputMPQCLine(file, &center, &AtomNo);
142 }
143 *file << "\t}" << endl;
144 *file << ")" << endl;
145 *file << "basis<GaussianBasisSet>: (" << endl;
146 *file << "\tname = \"" << World::getInstance().getConfig()->basis << "\"" << endl;
147 *file << "\tmolecule = $:molecule" << endl;
148 *file << ")" << endl;
149 }
150}
151
152/** Sets whether hessian is desired or not
153 * \param hessian statement
154 */
155void MpqcParser::setHessian(bool hessian)
156{
157 HessianPresent = hessian;
158}
Note: See TracBrowser for help on using the repository browser.