source: src/Parser/MpqcParser.cpp@ b5c53d

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 b5c53d was 97b825, checked in by Frederik Heber <heber@…>, 15 years ago

Shortened constructors [Meyers, "Effective C++" item 12]

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