source: src/Parser/MpqcParser.cpp@ bbbad5

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 Candidate_v1.7.0 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 bbbad5 was bbbad5, checked in by Frederik Heber <heber@…>, 15 years ago

Added MemDebug.hpp to each and every .cpp file (were it was still missing).

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