source: src/Parser/MpqcParser.cpp@ 9784cf

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 9784cf was bd2390, checked in by Frederik Heber <heber@…>, 14 years ago

BUGFIX: new boost::filesystem led to non-parsing of files.

  • BUGFIX: MapOfActions::TypeMap is not only important for set/queryCurrentValue but also for CommandLineParser.
    • CommandLineDialog::FileCommandLineQuery::handle() expects boost::filesystem::path
    • new validate for boost::filesystem::path
    • AddOptionsToParser was missing case for enum File
    • no enum File in TypeEnumMap
  • BUGFIX: InputAction
    • now setting prefix for all parsers even if filename nor present
    • now always setting name of last inserted molecule in World::getInstance().getMolecules()
    • not returning Action::failure when not present, only when not has_filename()
  • BUGFIX: PdbParser and TremoloParser were not inserting, but only creating a new molecule
  • BUGFIX: TremoloParser::load() nad no ASSET(false) as it's not implemented.
  • BUGFIX: as molId of 0 may occur, PdbParser::save() prints -1 for homeless atoms now
  • TESTFIX: Simple_configuration/2/test.pdb has molnr of 0 instead of former 1 (see above)
  • 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 // TODO: MpqcParser::load implementation
52 ASSERT(false, "Not implemented yet");
53}
54
55void MpqcParser::save(ostream *file)
56{
57 DoLog(0) && (Log() << Verbose(0) << "Saving changes to MPQC ." << std::endl);
58
59 if (HessianPresent)
60 saveHessian(file);
61 else
62 saveSimple(file);
63}
64
65/** Saves all atoms and data into a MPQC config file without hessian.
66 * \param *file output stream
67 */
68void MpqcParser::saveSimple(ostream *file)
69{
70 Vector center;
71 vector<atom *> allatoms = World::getInstance().getAllAtoms();
72
73 // calculate center
74 for (vector<atom *>::iterator runner = allatoms.begin();runner != allatoms.end(); ++runner)
75 center += (*runner)->getPosition();
76 center.Scale(1./allatoms.size());
77
78 // first without hessian
79 if (file->fail()) {
80 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc output file." << endl);
81 } else {
82 *file << "% Created by MoleCuilder" << endl;
83 *file << "mpqc: (" << endl;
84 *file << "\tsavestate = no" << endl;
85 *file << "\tdo_gradient = yes" << endl;
86 *file << "\tmole<MBPT2>: (" << endl;
87 *file << "\t\tmaxiter = 200" << endl;
88 *file << "\t\tbasis = $:basis" << endl;
89 *file << "\t\tmolecule = $:molecule" << endl;
90 *file << "\t\treference<CLHF>: (" << endl;
91 *file << "\t\t\tbasis = $:basis" << endl;
92 *file << "\t\t\tmolecule = $:molecule" << endl;
93 *file << "\t\t)" << endl;
94 *file << "\t)" << endl;
95 *file << ")" << endl;
96 *file << "molecule<Molecule>: (" << endl;
97 *file << "\tunit = " << (World::getInstance().getConfig()->GetIsAngstroem() ? "angstrom" : "bohr" ) << endl;
98 *file << "\t{ atoms geometry } = {" << endl;
99 // output of atoms
100 for (vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
101 (*AtomRunner)->OutputMPQCLine(file, &center);
102 }
103 *file << "\t}" << endl;
104 *file << ")" << endl;
105 *file << "basis<GaussianBasisSet>: (" << endl;
106 *file << "\tname = \"" << World::getInstance().getConfig()->basis << "\"" << endl;
107 *file << "\tmolecule = $:molecule" << endl;
108 *file << ")" << endl;
109 }
110}
111
112/** Saves all atoms and data into a MPQC config file with hessian.
113 * \param *file output stream
114 */
115void MpqcParser::saveHessian(ostream *file)
116{
117 Vector center;
118 vector<atom *> allatoms = World::getInstance().getAllAtoms();
119
120 // calculate center
121 for (vector<atom *>::iterator runner = allatoms.begin();runner != allatoms.end(); ++runner)
122 center += (*runner)->getPosition();
123 center.Scale(1./allatoms.size());
124
125 // with hessian
126 if (file->fail()) {
127 DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc output file." << endl);
128 } else {
129 *file << "% Created by MoleCuilder" << endl;
130 *file << "mpqc: (" << endl;
131 *file << "\tsavestate = no" << endl;
132 *file << "\tdo_gradient = yes" << endl;
133 *file << "\tmole<CLHF>: (" << endl;
134 *file << "\t\tmaxiter = 200" << endl;
135 *file << "\t\tbasis = $:basis" << endl;
136 *file << "\t\tmolecule = $:molecule" << endl;
137 *file << "\t)" << endl;
138 *file << "\tfreq<MolecularFrequencies>: (" << endl;
139 *file << "\t\tmolecule=$:molecule" << endl;
140 *file << "\t)" << endl;
141 *file << ")" << endl;
142 *file << "molecule<Molecule>: (" << endl;
143 *file << "\tunit = " << (World::getInstance().getConfig()->GetIsAngstroem() ? "angstrom" : "bohr" ) << endl;
144 *file << "\t{ atoms geometry } = {" << endl;
145 // output of atoms
146 for (vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
147 (*AtomRunner)->OutputMPQCLine(file, &center);
148 }
149 *file << "\t}" << endl;
150 *file << ")" << endl;
151 *file << "basis<GaussianBasisSet>: (" << endl;
152 *file << "\tname = \"" << World::getInstance().getConfig()->basis << "\"" << endl;
153 *file << "\tmolecule = $:molecule" << endl;
154 *file << ")" << endl;
155 }
156}
157
158/** Sets whether hessian is desired or not
159 * \param hessian statement
160 */
161void MpqcParser::setHessian(bool hessian)
162{
163 HessianPresent = hessian;
164}
Note: See TracBrowser for help on using the repository browser.