votca 2026-dev
Loading...
Searching...
No Matches
orb2diabat.cc
Go to the documentation of this file.
1/*
2 * Copyright 2009-2026 The VOTCA Development Team
3 * (http://www.votca.org)
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License")
6 *
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20// Standard includes
21#include <vector>
22
23// Local VOTCA includes
24#include "orb2diabat.h"
27#include "votca/xtp/orbitals.h"
28
29namespace votca {
30namespace xtp {
31
33 orbfile_ = job_name_ + ".orb";
34 spin_ = options.get(".spin").as<std::string>();
35 nstates_ = options.get(".nstates").as<Index>();
36}
37
39 log_.setReportLevel(Log::current_level);
40 log_.setMultithreading(true);
41 log_.setCommonPreface("\n... ...");
42
43 Orbitals orbitals;
44 XTP_LOG(Log::error, log_) << "Loading data from " << orbfile_ << std::flush;
45 orbitals.ReadFromCpt(orbfile_);
46
47 std::vector<QMStateType> types;
48 if (spin_ == "singlet" || spin_ == "all") {
49 types.push_back(QMStateType(QMStateType::Singlet));
50 }
51 if (spin_ == "triplet" || spin_ == "all") {
52 types.push_back(QMStateType(QMStateType::Triplet));
53 }
54
55 // MOs and amplitudes must come from the same orbital set: write the
56 // orbitals the BSE was solved in (QSGW-rotated orbitals for QSGW)
57 GaussianWriter fchk(log_);
58 fchk.UseBSEOrbitals(true);
59 fchk.WriteFile(job_name_, orbitals);
60 if (orbitals.isQSGW()) {
62 << "QSGW run: fchk contains the QSGW-rotated orbitals and QP energies"
63 << std::flush;
64 }
65
66 DiabatWriter writer;
67 for (const QMStateType& type : types) {
68 const std::string tag =
69 (type == QMStateType::Singlet) ? "singlet" : "triplet";
70 const std::string statefile = job_name_ + "_" + tag + ".diabat";
71 writer.WriteFile(statefile, orbitals, type, nstates_);
73 << "Wrote BSE " << tag << " states to " << statefile
74 << "\n Diabat input:\n $$statepack\n mofile = \"" << job_name_
75 << ".fchk\"\n statefile = \"" << statefile
76 << "\"\n state_index = 1..N\n $$" << std::flush;
77 }
78 return true;
79}
80
81} // namespace xtp
82} // namespace votca
class to manage program options with xml serialization functionality
Definition property.h:55
Property & get(const std::string &key)
get existing property
Definition property.cc:79
T as() const
return value as type
Definition property.h:283
Writes BSE excitations in the plain-text electronic-state format read by Diabat 2....
void WriteFile(const std::string &filename, const Orbitals &orbitals, QMStateType type, Index nstates=-1) const
void WriteFile(const std::string &basename, const Orbitals &orbitals, const QMState state=QMState(QMStateType::statetype::Gstate, 0, false), bool diff2gs=false) const
void UseBSEOrbitals(bool flag)
void ParseOptions(const tools::Property &options)
Definition orb2diabat.cc:32
Container for molecular orbitals and derived one-particle data.
Definition orbitals.h:47
bool isQSGW() const
Definition orbitals.h:685
void ReadFromCpt(const std::string &filename)
Read the orbital container from a checkpoint file on disk.
Definition orbitals.cc:1222
std::string job_name_
Definition qmtool.h:50
#define XTP_LOG(level, log)
Definition logger.h:40
Charge transport classes.
Definition ERIs.h:28
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26
static Level current_level
Definition globals.h:30