38 throw std::runtime_error(
40 " must always be region 0. Currently only one qm region is possible.");
53 if (prop.
exists(
"statetracker")) {
60 throw std::runtime_error(
61 "No statetracker options for excited states found");
67 if (prop.
exists(
"statetracker")) {
74 throw std::runtime_error(
"No statetracker options for KS states found");
79 prop.
get(
"grid_for_potential").
as<std::string>();
87 if (prop.
get(
"dftpackage.xtpdft.dft_in_dft.activeatoms")
100 double Echange =
E_hist_.getDiff();
103 double Dmax =
Dmat_hist_.getDiff().cwiseAbs().maxCoeff();
104 std::string info =
"not converged";
105 bool converged =
false;
111 <<
" Region:" << this->
identify() <<
" " << this->
getId() <<
" is "
112 << info <<
" deltaE=" << Echange <<
" RMS Dmat=" << Dchange
113 <<
" MaxDmat=" << Dmax << std::flush;
121 std::accumulate(interact_energies.begin(), interact_energies.end(), 0.0);
124 <<
" Calculated interaction potentials with other regions. E[hrt]= "
125 << e_ext << std::flush;
146 if (!Logfile_parse) {
148 errormsg_ =
"Parsing DFT logfile failed.";
152 if (!Orbfile_parse) {
154 errormsg_ =
"Parsing DFT orbfile failed.";
158 if (
orb_.isOpenShell()) {
159 throw std::runtime_error(
160 "MO localization not implemented for open-shell systems");
167 if (
orb_.isOpenShell()) {
168 throw std::runtime_error(
169 "DFT-in-DFT not implemented for open-shell systems");
172 std::unique_ptr<QMPackage> xtpdft =
174 xtpdft->setLog(&
log_);
183 xtpdft->setCharge(
charge);
185 std::vector<double> energies = std::vector<double>(regions.size(), 0.0);
186 for (std::unique_ptr<Region>& reg : regions) {
187 Index id = reg->getId();
188 if (
id == this->
getId()) {
195 <<
TimeStamp() <<
" Evaluating interaction between "
197 << reg->identify() <<
" " << reg->getId() << std::flush;
198 if (reg->identify() == Staticdummy.
identify()) {
200 xtpdft->AddRegion(*staticregion);
201 }
else if (reg->identify() == Polardummy.
identify()) {
203 xtpdft->AddRegion(*polarregion);
205 throw std::runtime_error(
206 "Interaction of regions with types:" + this->
identify() +
" and " +
207 reg->identify() +
" not implemented");
211 e_ext = std::accumulate(interact_energies.begin(), interact_energies.end(),
215 <<
" Calculated interaction potentials with other regions. E[hrt]= "
216 << e_ext << std::flush;
218 xtpdft->WriteInputFile(
orb_);
219 bool active_run = xtpdft->RunActiveRegion();
221 throw std::runtime_error(
"\n DFT in DFT embedding failed. Stopping!");
223 Logfile_parse = xtpdft->ParseLogFile(
orb_);
224 if (!Logfile_parse) {
225 throw std::runtime_error(
"\n Parsing DFT logfile failed. Stopping!");
230 double energy =
orb_.getDFTTotalEnergy();
236 energy +=
orb_.getExcitedStateEnergy(state);
239 energy -=
orb_.getExcitedStateEnergy(state);
244 if (
orb_.isOpenShell()) {
245 throw std::runtime_error(
"GWBSE not implemented for open-shell systems");
248 Index active_electrons =
orb_.getNumOfActiveElectrons();
250 orb_.setNumberOfAlphaElectrons(active_electrons);
251 orb_.setNumberOfOccupiedLevels(active_electrons / 2);
259 energy +=
orb_.getExcitedStateEnergy(state);
263 energy +=
orb_.getExcitedStateEnergy(state);
266 energy -=
orb_.getExcitedStateEnergy(state);
272 if (
orb_.getCalculationType() ==
"Truncated") {
273 orb_.MOs().eigenvectors() =
orb_.getTruncMOsFullBasis();
274 orb_.QMAtoms().clearAtoms();
275 orb_.QMAtoms() = originalmol;
276 orb_.SetupDftBasis(
orb_.getDftBasis().Name());
277 orb_.SetupAuxBasis(
orb_.getAuxBasis().Name());
286 if (
orb_.QMAtoms().size() == 0) {
287 orb_.QMAtoms() = mol;
289 orb_.QMAtoms().AddContainer(mol);
299 nuccharge += a.getNuccharge();
302 Index electrons =
orb_.getNumberOfAlphaElectrons();
303 if (
orb_.isOpenShell()) {
304 electrons +=
orb_.getNumberOfBetaElectrons();
309 charge = double(nuccharge - electrons);
336 std::string dft_package_name =
dftoptions_.get(
"name").as<std::string>();
351 throw std::runtime_error(
352 "QMRegion-QMRegion interaction is not implemented yet.");
371#pragma omp parallel for
372 for (
Index i = 0; i <
Index(segments.size()); ++i) {
378 std::vector<PolarSegment>& segments)
const {
390 Eigen::MatrixXd dmat =
orb_.DensityMatrixFull(state);
394 double N_comp = dmat.cwiseProduct(overlap.
Matrix()).sum();
395 if (std::abs(Ngrid - N_comp) > 0.001) {
398 <<
"WARNING: Calculated Densities at Numerical Grid, Number of "
400 << Ngrid <<
" is far away from the the real value " << N_comp
401 <<
", you should increase the accuracy of the integration grid."
404#pragma omp parallel for
405 for (
Index i = 0; i <
Index(segments.size()); ++i) {
428 orb_.WriteBasisSetsToCpt(v);
446 r(state,
"initial_state");
450 orb_.ReadFromCpt(rr);
451 orb_.ReadBasisSetsFromCpt(rr);
void WriteContainer(T &container)
Container to hold Basisfunctions for all atoms.
void Fill(const AOBasis &aobasis) final
const Eigen::MatrixXd & Matrix() const
void push_back(const T &atom)
CheckpointReader openChild(const std::string &childName) const
CheckpointWriter openChild(const std::string &childName) const
Eigen::Vector3d IntegrateField(const Eigen::Vector3d &rvector) const
double IntegrateDensity(const Eigen::MatrixXd &density_matrix)
Electronic excitations from GW-BSE.
void Initialize(tools::Property &options)
void setLogger(Logger *pLog)
void computePML(Orbitals &orbitals)
std::string identify() const override
Class to represent Atom/Site in electrostatic+polarization.
void AppendResult(tools::Property &prop) const override
StateTracker statetracker_
hist< Eigen::MatrixXd > Dmat_hist_
std::string grid_accuracy_for_ext_interaction_
std::string identify() const override
void AddNucleiFields(std::vector< PolarSegment > &segments, const StaticSegment &seg) const
std::unique_ptr< QMPackage > qmpackage_
void push_back(const QMMolecule &mol)
void WriteToCpt(CheckpointWriter &w) const override
double InteractwithStaticRegion(const StaticRegion ®ion) override
double InteractwithPolarRegion(const PolarRegion ®ion) override
QMRegion(Index id, Logger &log, std::string workdir)
void WritePDB(csg::PDBWriter &writer) const override
void ReadFromCpt(CheckpointReader &r) override
bool Converged() const override
void Evaluate(std::vector< std::unique_ptr< Region > > ®ions) override
tools::Property localize_options_
double InteractwithQMRegion(const QMRegion ®ion) override
void ApplyQMFieldToPolarSegments(std::vector< PolarSegment > &segments) const
void Initialize(const tools::Property &prop) override
double charge() const override
tools::Property dftoptions_
tools::Property gwbseoptions_
bool isSingleParticleState() const
Identifier for QMstates. Strings like S1 are converted into enum +zero indexed int.
const QMStateType & Type() const
std::vector< double > ApplyInfluenceOfOtherRegions(std::vector< std::unique_ptr< Region > > ®ions)
std::string identify() const override
Class to represent Atom/Site in electrostatic.
Timestamp returns the current time as a string Example: cout << TimeStamp()
void GridSetup(const std::string &type, const QMMolecule &atoms, const AOBasis &basis)
Mediates interaction between polar and static sites.
#define XTP_LOG(level, log)
Charge transport classes.
ClassicalSegment< PolarSite > PolarSegment
ClassicalSegment< StaticSite > StaticSegment
base class for all analysis tools