source: src/Parser/MpqcParser.cpp@ 1434c9

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 1434c9 was d6b8e1, checked in by Frederik Heber <heber@…>, 15 years ago

FIX: center calculation was missing in order to pass testsuite cases.

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