source: src/Parser/MpqcParser.cpp@ 6f5dfe

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 6f5dfe was 0dc86e2, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Removed unused AtomNo parameter in atom::OutputMPQCLine()

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