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

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 6d858c was 2fd80b5, checked in by Frederik Heber <heber@…>, 15 years ago

FIXES: ParserUnitTest was broken

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