source: src/Parser/MpqcParser.cpp@ 3f9eba

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 3f9eba was ad011c, checked in by Frederik Heber <heber@…>, 14 years ago

CodePatterns places all includes now in subfolder CodePatterns/.

  • change all includes accordingly.
  • this was necessary as Helpers and Patterns are not very distinctive names for include folders. Already now, we had a conflict between Helpers from CodePatterns and Helpers from this project.
  • changed compilation test in ax_codepatterns.m4 when changing CodePatterns includes.
  • Property mode set to 100644
File size: 5.1 KB
RevLine 
[bcf653]1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
[43dad6]8/*
9 * MpqcParser.cpp
10 *
11 * Created on: 12.06.2010
12 * Author: heber
13 */
14
[bf3817]15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
[ad011c]20#include "CodePatterns/MemDebug.hpp"
[bbbad5]21
[1b2d30]22#include "MpqcParser.hpp"
23
24#include "atom.hpp"
25#include "config.hpp"
26#include "element.hpp"
[ad011c]27#include "CodePatterns/Log.hpp"
28#include "CodePatterns/Verbose.hpp"
[e97a44]29#include "LinearAlgebra/Vector.hpp"
30#include "periodentafel.hpp"
[1b2d30]31#include "World.hpp"
32
33
34/** Constructor of MpqcParser.
35 *
36 */
[2fd80b5]37MpqcParser::MpqcParser() : HessianPresent(false)
[97b825]38{}
[1b2d30]39
40/** Destructor of MpqcParser.
41 *
42 */
[97b825]43MpqcParser::~MpqcParser()
44{}
[1b2d30]45
46/** Load an MPQC config file into the World.
47 * \param *file input stream
48 */
49void MpqcParser::load(istream *file)
50{
[bd2390]51 // TODO: MpqcParser::load implementation
52 ASSERT(false, "Not implemented yet");
[1b2d30]53}
54
[73916f]55/**
56 * Saves the \a atoms into as a MPQC file.
57 *
58 * \param file where to save the state
59 * \param atoms atoms to store
60 */
61void MpqcParser::save(ostream *file, const std::vector<atom *> &atoms)
[1b2d30]62{
[e97a44]63 DoLog(0) && (Log() << Verbose(0) << "Saving changes to MPQC ." << std::endl);
64
[1b2d30]65 if (HessianPresent)
[73916f]66 saveHessian(file, atoms);
[1b2d30]67 else
[73916f]68 saveSimple(file, atoms);
[1b2d30]69}
70
71/** Saves all atoms and data into a MPQC config file without hessian.
72 * \param *file output stream
[73916f]73 * \param atoms atoms to store
[1b2d30]74 */
[73916f]75void MpqcParser::saveSimple(ostream *file, const std::vector<atom *> &atoms)
[1b2d30]76{
77 Vector center;
78 vector<atom *> allatoms = World::getInstance().getAllAtoms();
79
[d6b8e1]80 // calculate center
81 for (vector<atom *>::iterator runner = allatoms.begin();runner != allatoms.end(); ++runner)
[d74077]82 center += (*runner)->getPosition();
[d6b8e1]83 center.Scale(1./allatoms.size());
84
[1b2d30]85 // first without hessian
86 if (file->fail()) {
87 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc output file." << endl);
88 } else {
89 *file << "% Created by MoleCuilder" << endl;
90 *file << "mpqc: (" << endl;
91 *file << "\tsavestate = no" << endl;
92 *file << "\tdo_gradient = yes" << endl;
93 *file << "\tmole<MBPT2>: (" << endl;
94 *file << "\t\tmaxiter = 200" << endl;
95 *file << "\t\tbasis = $:basis" << endl;
96 *file << "\t\tmolecule = $:molecule" << endl;
97 *file << "\t\treference<CLHF>: (" << endl;
98 *file << "\t\t\tbasis = $:basis" << endl;
99 *file << "\t\t\tmolecule = $:molecule" << endl;
100 *file << "\t\t)" << endl;
101 *file << "\t)" << endl;
102 *file << ")" << endl;
103 *file << "molecule<Molecule>: (" << endl;
104 *file << "\tunit = " << (World::getInstance().getConfig()->GetIsAngstroem() ? "angstrom" : "bohr" ) << endl;
105 *file << "\t{ atoms geometry } = {" << endl;
106 // output of atoms
107 for (vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
[0dc86e2]108 (*AtomRunner)->OutputMPQCLine(file, &center);
[1b2d30]109 }
110 *file << "\t}" << endl;
111 *file << ")" << endl;
112 *file << "basis<GaussianBasisSet>: (" << endl;
113 *file << "\tname = \"" << World::getInstance().getConfig()->basis << "\"" << endl;
114 *file << "\tmolecule = $:molecule" << endl;
115 *file << ")" << endl;
116 }
117}
118
119/** Saves all atoms and data into a MPQC config file with hessian.
120 * \param *file output stream
[73916f]121 * \param atoms atoms to store
[1b2d30]122 */
[73916f]123void MpqcParser::saveHessian(ostream *file, const std::vector<atom *> &atoms)
[1b2d30]124{
125 Vector center;
126 vector<atom *> allatoms = World::getInstance().getAllAtoms();
127
[d6b8e1]128 // calculate center
129 for (vector<atom *>::iterator runner = allatoms.begin();runner != allatoms.end(); ++runner)
[d74077]130 center += (*runner)->getPosition();
[d6b8e1]131 center.Scale(1./allatoms.size());
132
[1b2d30]133 // with hessian
134 if (file->fail()) {
135 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc output file." << endl);
136 } else {
137 *file << "% Created by MoleCuilder" << endl;
138 *file << "mpqc: (" << endl;
139 *file << "\tsavestate = no" << endl;
140 *file << "\tdo_gradient = yes" << endl;
141 *file << "\tmole<CLHF>: (" << endl;
142 *file << "\t\tmaxiter = 200" << endl;
143 *file << "\t\tbasis = $:basis" << endl;
144 *file << "\t\tmolecule = $:molecule" << endl;
145 *file << "\t)" << endl;
146 *file << "\tfreq<MolecularFrequencies>: (" << endl;
147 *file << "\t\tmolecule=$:molecule" << endl;
148 *file << "\t)" << endl;
149 *file << ")" << endl;
150 *file << "molecule<Molecule>: (" << endl;
151 *file << "\tunit = " << (World::getInstance().getConfig()->GetIsAngstroem() ? "angstrom" : "bohr" ) << endl;
152 *file << "\t{ atoms geometry } = {" << endl;
153 // output of atoms
154 for (vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
[0dc86e2]155 (*AtomRunner)->OutputMPQCLine(file, &center);
[1b2d30]156 }
157 *file << "\t}" << endl;
158 *file << ")" << endl;
159 *file << "basis<GaussianBasisSet>: (" << endl;
160 *file << "\tname = \"" << World::getInstance().getConfig()->basis << "\"" << endl;
161 *file << "\tmolecule = $:molecule" << endl;
162 *file << ")" << endl;
163 }
164}
165
166/** Sets whether hessian is desired or not
167 * \param hessian statement
168 */
169void MpqcParser::setHessian(bool hessian)
170{
171 HessianPresent = hessian;
172}
Note: See TracBrowser for help on using the repository browser.