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 | */
|
---|
25 | MpqcParser::MpqcParser()
|
---|
26 | {
|
---|
27 |
|
---|
28 | }
|
---|
29 |
|
---|
30 | /** Destructor of MpqcParser.
|
---|
31 | *
|
---|
32 | */
|
---|
33 | MpqcParser::~MpqcParser() {
|
---|
34 |
|
---|
35 | }
|
---|
36 |
|
---|
37 | /** Load an MPQC config file into the World.
|
---|
38 | * \param *file input stream
|
---|
39 | */
|
---|
40 | void MpqcParser::load(istream *file)
|
---|
41 | {
|
---|
42 | DoeLog(0) && (Log() << Verbose(0) << "Not yet implemented" << endl) ;
|
---|
43 | }
|
---|
44 |
|
---|
45 | void 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 | */
|
---|
56 | void MpqcParser::saveSimple(ostream *file)
|
---|
57 | {
|
---|
58 | int AtomNo = 0;
|
---|
59 | Vector center;
|
---|
60 | vector<atom *> allatoms = World::getInstance().getAllAtoms();
|
---|
61 |
|
---|
62 | // first without hessian
|
---|
63 | if (file->fail()) {
|
---|
64 | DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc output file." << endl);
|
---|
65 | } else {
|
---|
66 | *file << "% Created by MoleCuilder" << endl;
|
---|
67 | *file << "mpqc: (" << endl;
|
---|
68 | *file << "\tsavestate = no" << endl;
|
---|
69 | *file << "\tdo_gradient = yes" << endl;
|
---|
70 | *file << "\tmole<MBPT2>: (" << endl;
|
---|
71 | *file << "\t\tmaxiter = 200" << endl;
|
---|
72 | *file << "\t\tbasis = $:basis" << endl;
|
---|
73 | *file << "\t\tmolecule = $:molecule" << endl;
|
---|
74 | *file << "\t\treference<CLHF>: (" << endl;
|
---|
75 | *file << "\t\t\tbasis = $:basis" << endl;
|
---|
76 | *file << "\t\t\tmolecule = $:molecule" << endl;
|
---|
77 | *file << "\t\t)" << endl;
|
---|
78 | *file << "\t)" << endl;
|
---|
79 | *file << ")" << endl;
|
---|
80 | *file << "molecule<Molecule>: (" << endl;
|
---|
81 | *file << "\tunit = " << (World::getInstance().getConfig()->GetIsAngstroem() ? "angstrom" : "bohr" ) << endl;
|
---|
82 | *file << "\t{ atoms geometry } = {" << endl;
|
---|
83 | // output of atoms
|
---|
84 | for (vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
|
---|
85 | (*AtomRunner)->OutputMPQCLine(file, ¢er, &AtomNo);
|
---|
86 | }
|
---|
87 | *file << "\t}" << endl;
|
---|
88 | *file << ")" << endl;
|
---|
89 | *file << "basis<GaussianBasisSet>: (" << endl;
|
---|
90 | *file << "\tname = \"" << World::getInstance().getConfig()->basis << "\"" << endl;
|
---|
91 | *file << "\tmolecule = $:molecule" << endl;
|
---|
92 | *file << ")" << endl;
|
---|
93 | }
|
---|
94 | }
|
---|
95 |
|
---|
96 | /** Saves all atoms and data into a MPQC config file with hessian.
|
---|
97 | * \param *file output stream
|
---|
98 | */
|
---|
99 | void MpqcParser::saveHessian(ostream *file)
|
---|
100 | {
|
---|
101 | int AtomNo = 0;
|
---|
102 | Vector center;
|
---|
103 | vector<atom *> allatoms = World::getInstance().getAllAtoms();
|
---|
104 |
|
---|
105 | // with hessian
|
---|
106 | if (file->fail()) {
|
---|
107 | DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc output file." << endl);
|
---|
108 | } else {
|
---|
109 | *file << "% Created by MoleCuilder" << endl;
|
---|
110 | *file << "mpqc: (" << endl;
|
---|
111 | *file << "\tsavestate = no" << endl;
|
---|
112 | *file << "\tdo_gradient = yes" << endl;
|
---|
113 | *file << "\tmole<CLHF>: (" << endl;
|
---|
114 | *file << "\t\tmaxiter = 200" << endl;
|
---|
115 | *file << "\t\tbasis = $:basis" << endl;
|
---|
116 | *file << "\t\tmolecule = $:molecule" << endl;
|
---|
117 | *file << "\t)" << endl;
|
---|
118 | *file << "\tfreq<MolecularFrequencies>: (" << endl;
|
---|
119 | *file << "\t\tmolecule=$:molecule" << endl;
|
---|
120 | *file << "\t)" << endl;
|
---|
121 | *file << ")" << endl;
|
---|
122 | *file << "molecule<Molecule>: (" << endl;
|
---|
123 | *file << "\tunit = " << (World::getInstance().getConfig()->GetIsAngstroem() ? "angstrom" : "bohr" ) << endl;
|
---|
124 | *file << "\t{ atoms geometry } = {" << endl;
|
---|
125 | // output of atoms
|
---|
126 | for (vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
|
---|
127 | (*AtomRunner)->OutputMPQCLine(file, ¢er, &AtomNo);
|
---|
128 | }
|
---|
129 | *file << "\t}" << endl;
|
---|
130 | *file << ")" << endl;
|
---|
131 | *file << "basis<GaussianBasisSet>: (" << endl;
|
---|
132 | *file << "\tname = \"" << World::getInstance().getConfig()->basis << "\"" << endl;
|
---|
133 | *file << "\tmolecule = $:molecule" << endl;
|
---|
134 | *file << ")" << endl;
|
---|
135 | }
|
---|
136 | }
|
---|
137 |
|
---|
138 | /** Sets whether hessian is desired or not
|
---|
139 | * \param hessian statement
|
---|
140 | */
|
---|
141 | void MpqcParser::setHessian(bool hessian)
|
---|
142 | {
|
---|
143 | HessianPresent = hessian;
|
---|
144 | }
|
---|