48 double energy_difference)
const {
50 throw std::runtime_error(
51 "Checking degeneracy not implemented for open-shell systems.");
53 std::vector<Index> result;
55 throw std::runtime_error(
56 "Level for degeneracy is higher than maximum level");
61 if (std::abs(
mos_.
eigenvalues()(i) - MOEnergyLevel) < energy_difference) {
67 result.push_back(level);
74 throw std::runtime_error(
75 "MO sorting not implemented for open-shell systems.");
77 std::vector<Index> index = std::vector<Index>(
mos_.
eigenvalues().size());
78 std::iota(index.begin(), index.end(), 0);
79 std::stable_sort(index.begin(), index.end(), [
this](
Index i1,
Index i2) {
80 return this->MOs().eigenvalues()[i1] < this->MOs().eigenvalues()[i2];
91 if (this->
QMAtoms().size() == 0) {
92 throw std::runtime_error(
"Can't setup AOBasis without atoms");
100 if (this->
QMAtoms().size() == 0) {
101 throw std::runtime_error(
"Can't setup Aux AOBasis without atoms");
104 bs.
Load(aux_basis_name);
114 throw std::runtime_error(
115 "DensityMatrixWithoutGS not implemented for open-shell systems.");
119 return DMAT[1] - DMAT[0];
130 throw std::runtime_error(
131 "DensityMatrixWithoutGS does not yet implement QMStateType:" +
151 result = result - DMAT[0] + DMAT[1];
172 " requires an openshell calculation");
175 throw std::runtime_error(
176 "DensityMatrixFull does not yet implement QMStateType:" +
185 throw std::runtime_error(
"Orbitals file does not contain MO coefficients");
188 Eigen::MatrixXd dmatGS = occstates * occstates.transpose();
190 Eigen::MatrixXd occstates_beta =
192 dmatGS += occstates_beta * occstates_beta.transpose();
201 throw std::runtime_error(
202 "DensityMatrixKSstate not implemented for open-shell systems.");
205 throw std::runtime_error(
"Orbitals file does not contain MO coefficients");
209 throw std::runtime_error(
"State:" + state.
ToString() +
210 " is not a Kohn Sham state");
213 Eigen::MatrixXd dmatKS = KSstate * KSstate.transpose();
219 throw std::runtime_error(
"Orbitals file does not contain QP coefficients");
229 throw std::runtime_error(
230 "DensityMatrixQuasiParticle not implemented for open-shell systems.");
233 throw std::runtime_error(
"State:" + state.
ToString() +
234 " is not a quasiparticle state");
243 Eigen::Vector3d nuclei_dip = Eigen::Vector3d::Zero();
246 nuclei_dip += (atom.getPos() -
atoms_.
getPos()) * atom.getNuccharge();
255 Eigen::Vector3d electronic_dip;
256 for (
Index i = 0; i < 3; ++i) {
257 electronic_dip(i) = dmat.cwiseProduct(dipole.
Matrix()[i]).sum();
259 return nuclei_dip - electronic_dip;
264 throw std::runtime_error(
265 "TransitionDensityMatrix not implemented for open-shell systems.");
268 throw std::runtime_error(
269 "Spin type not known for transition density matrix. Available only for "
273 if (BSECoefs.cols() < state.
StateIdx() + 1 || BSECoefs.rows() < 2) {
274 throw std::runtime_error(
"Orbitals object has no information about state:" +
288 Eigen::VectorXd coeffs = BSECoefs.col(state.
StateIdx());
293 coeffs *= std::sqrt(2.0);
296 Eigen::Map<const Eigen::MatrixXd> mat(coeffs.data(),
bse_ctotal_,
299 return occlevels * mat.transpose() * virtlevels.transpose();
305 throw std::runtime_error(
306 "DensityMatrixExcitedState not implemented for open-shell systems.");
310 std::array<Eigen::MatrixXd, 2> dmat_AR =
312 dmat[0] -= dmat_AR[0];
313 dmat[1] -= dmat_AR[1];
323 throw std::runtime_error(
324 "Spin type not known for density matrix. Available are singlet and "
331 if (BSECoefs.cols() < state.
StateIdx() + 1 || BSECoefs.rows() < 2) {
332 throw std::runtime_error(
"Orbitals object has no information about state:" +
347 Eigen::VectorXd coeffs = BSECoefs.col(state.
StateIdx());
349 std::array<Eigen::MatrixXd, 2> dmatEX;
351 Eigen::MatrixXd occlevels =
353 dmatEX[0] = occlevels *
CalcAuxMat_vv(coeffs) * occlevels.transpose();
356 Eigen::MatrixXd virtlevels =
358 dmatEX[1] = virtlevels *
CalcAuxMat_cc(coeffs) * virtlevels.transpose();
364 const Eigen::Map<const Eigen::MatrixXd> mat(coeffs.data(),
bse_ctotal_,
366 return mat.transpose() * mat;
370 const Eigen::Map<const Eigen::MatrixXd> mat(coeffs.data(),
bse_ctotal_,
372 return mat * mat.transpose();
379 throw std::runtime_error(
380 "Spin type not known for density matrix. Available are singlet and "
387 if (BSECoefs_AR.cols() < state.
StateIdx() + 1 || BSECoefs_AR.rows() < 2) {
388 throw std::runtime_error(
"Orbitals object has no information about state:" +
414 Eigen::VectorXd coeffs = BSECoefs_AR.col(state.
StateIdx());
416 std::array<Eigen::MatrixXd, 2> dmatAR;
417 Eigen::MatrixXd virtlevels =
419 dmatAR[0] = virtlevels *
CalcAuxMat_cc(coeffs) * virtlevels.transpose();
421 Eigen::MatrixXd occlevels =
423 dmatAR[1] = occlevels *
CalcAuxMat_vv(coeffs) * occlevels.transpose();
434 Eigen::VectorXd oscs = Eigen::VectorXd::Zero(size);
435 for (
Index i = 0; i < size; ++i) {
455 throw std::runtime_error(
456 "Total Energy does not exist for transition state");
461 throw std::runtime_error(
"Orbitals::getTotalEnergy You want " +
463 " which has not been calculated");
468 throw std::runtime_error(
"Orbitals::getTotalEnergy You want " +
470 " which has not been calculated");
475 throw std::runtime_error(
"Orbitals::getTotalEnergy You want " +
477 " which has not been calculated");
482 throw std::runtime_error(
"Orbitals::getTotalEnergy You want " +
484 " which has not been calculated");
489 throw std::runtime_error(
"Orbitals::getTotalEnergy You want " +
491 " which has not been calculated");
496 throw std::runtime_error(
497 "Orbitals::getTotalEnergy You want " + state.
ToString() +
498 " which is a LMO for virtual orbitals. Not implemented.");
502 throw std::runtime_error(
503 "GetTotalEnergy only knows states:singlet,triplet,KS,DQP,PQP,LMOs");
513 dft_dipole.
Fill(basis);
516 std::array<Eigen::MatrixXd, 3> interlevel_dipoles;
520 for (
Index i = 0; i < 3; i++) {
521 interlevel_dipoles[i] = empty.transpose() * dft_dipole.
Matrix()[i] * occ;
523 return interlevel_dipoles;
527 std::array<Eigen::MatrixXd, 3> interlevel_dipoles =
532 const double sqrt2 = std::sqrt(2.0);
533 for (
Index i_exc = 0; i_exc < numofstates; i_exc++) {
540 Eigen::Vector3d tdipole = Eigen::Vector3d::Zero();
541 for (
Index i = 0; i < 3; i++) {
542 tdipole[i] = mat.cwiseProduct(interlevel_dipoles[i]).sum();
556 for (
Index i = 0; i < size; ++i) {
559 for (
Index i = 0; i < size; ++i) {
581 mos_.
eigenvectors() = Eigen::MatrixXd::Zero(basisA + basisB, basisA + basisB);
586 throw std::runtime_error(
"Basissets of Orbitals A and B differ " +
592 throw std::runtime_error(
"ECPs of Orbitals A and B differ " +
715 r(version,
"version");
725 }
catch (std::runtime_error&
e) {
729 r(version,
"version");
749 std::array<Index, 49> votcaOrder_old = {
753 0, -1, 1, -2, 2, -3, 3,
754 0, -1, 1, -2, 2, -3, 3, -4, 4,
755 0, -1, 1, -2, 2, -3, 3, -4, 4,-5,5,
756 0, -1, 1, -2, 2, -3, 3, -4, 4,-5,5,-6,6
760 std::array<Index, 49> multiplier;
768 std::string dft_basis_name;
769 std::string aux_basis_name;
770 r(dft_basis_name,
"dftbasis");
771 r(aux_basis_name,
"auxbasis");
786 }
catch (std::runtime_error&
e) {
Container to hold Basisfunctions for all atoms.
void Fill(const BasisSet &bs, const QMMolecule &atoms)
void WriteToCpt(CheckpointWriter &w) const
void ReadFromCpt(CheckpointReader &r)
void setCenter(const Eigen::Vector3d &r)
const std::array< Eigen::MatrixXd, 3 > & Matrix() const
void Fill(const AOBasis &aobasis) final
virtual void WriteToCpt(CheckpointWriter &w) const
virtual void ReadFromCpt(CheckpointReader &r)
const Eigen::Vector3d & getPos() const
void Load(const std::string &name)
CheckpointReader getReader()
CheckpointWriter getWriter()
CheckpointReader openChild(const std::string &childName) const
CheckpointWriter openChild(const std::string &childName) const
void reorderOrbitals(Eigen::MatrixXd &moCoefficients, const AOBasis &basis)
container for molecular orbitals
Index number_beta_electrons_
void CalcCoupledTransition_Dipoles()
Eigen::MatrixXd occupations_
Eigen::VectorXd rpa_inputenergies_
void ReadBasisSetsFromCpt(CheckpointReader r)
Eigen::MatrixXd TransitionDensityMatrix(const QMState &state) const
double getDFTTotalEnergy() const
Eigen::MatrixXd CalculateQParticleAORepresentation() const
std::array< Eigen::MatrixXd, 2 > DensityMatrixExcitedState_R(const QMState &state) const
Eigen::VectorXd lmos_energies_
tools::EigenSystem BSE_singlet_
void PrepareDimerGuess(const Orbitals &orbitalsA, const Orbitals &orbitalsB)
Guess for a dimer based on monomer orbitals.
tools::EigenSystem mos_beta_
std::string grid_quality_
double getTotalStateEnergy(const QMState &state) const
Eigen::VectorXd BSE_triplet_energies_dynamic_
std::vector< Index > CheckDegeneracy(Index level, double energy_difference) const
Eigen::MatrixXd inactivedensity_
Index getNumberOfAlphaElectrons() const
std::string getCalculationType() const
std::array< Eigen::MatrixXd, 3 > CalcFreeTransition_Dipoles() const
Eigen::MatrixXd CalcAuxMat_cc(const Eigen::VectorXd &coeffs) const
Eigen::MatrixXd expandedMOs_
void setNumberOfAlphaElectrons(Index electrons)
Eigen::VectorXd Oscillatorstrengths() const
std::vector< Eigen::Vector3d > transition_dipoles_
static constexpr int orbitals_version()
std::string functionalname_
Eigen::MatrixXd DensityMatrixWithoutGS(const QMState &state) const
void WriteBasisSetsToCpt(CheckpointWriter w) const
Eigen::MatrixXd DensityMatrixFull(const QMState &state) const
Eigen::MatrixXd CalcAuxMat_vv(const Eigen::VectorXd &coeffs) const
void SetupAuxBasis(std::string aux_basis_name)
tools::EigenSystem BSE_triplet_
void setBSEindices(Index vmin, Index cmax)
const Eigen::MatrixXd & getInactiveDensity() const
std::vector< Index > SortEnergies()
std::array< Eigen::MatrixXd, 2 > DensityMatrixExcitedState_AR(const QMState &state) const
double getExcitedStateEnergy(const QMState &state) const
void setECPName(const std::string &ECP)
void setNumberOfOccupiedLevels(Index occupied_levels)
Index occupied_levels_beta_
tools::EigenSystem QPdiag_
Eigen::MatrixXd DensityMatrixKSstate(const QMState &state) const
Eigen::MatrixXd DensityMatrixQuasiParticle(const QMState &state) const
Index getBasisSetSize() const
Eigen::VectorXd BSE_singlet_energies_dynamic_
const tools::EigenSystem & MOs() const
Eigen::MatrixXd DensityMatrixGroundState() const
const QMMolecule & QMAtoms() const
tools::EigenSystem mos_embedding_
void ReadFromCpt(const std::string &filename)
Eigen::VectorXd QPpert_energies_
void WriteToCpt(const std::string &filename) const
const std::string & getECPName() const
const std::string & getDFTbasisName() const
void SetupDftBasis(std::string basis_name)
std::array< Eigen::MatrixXd, 2 > DensityMatrixExcitedState(const QMState &state) const
Index number_alpha_electrons_
Eigen::Vector3d CalcElDipole(const QMState &state) const
const AOBasis & getDftBasis() const
std::string ToLongString() const
Identifier for QMstates. Strings like S1 are converted into enum +zero indexed int.
std::string ToString() const
bool isTransition() const
const QMStateType & Type() const
base class for all analysis tools