votca 2026-dev
Loading...
Searching...
No Matches
orbitals.h
Go to the documentation of this file.
1
2/*
3 * Copyright 2009-2023 The VOTCA Development Team
4 * (http://www.votca.org)
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License")
7 *
8 * You may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 */
20
21#pragma once
22#ifndef VOTCA_XTP_ORBITALS_H
23#define VOTCA_XTP_ORBITALS_H
24
25// VOTCA includes
26#include <votca/tools/globals.h>
28
29// Local VOTCA includes
30#include "aobasis.h"
31#include "checkpoint.h"
32#include "classicalsegment.h"
33#include "eigen.h"
34#include "qmmolecule.h"
35#include "qmstate.h"
36
37namespace votca {
38namespace xtp {
39
47class Orbitals {
48 public:
50 Orbitals();
51
53 bool hasBasisSetSize() const {
54 return (dftbasis_.AOBasisSize() > 0) ? true : false;
55 }
56
59
62
64 void setTruncMOsFullBasis(const Eigen::MatrixXd &expandedMOs) {
65 expandedMOs_ = expandedMOs;
66 }
67
69 const Eigen::MatrixXd getTruncMOsFullBasis() const { return expandedMOs_; }
70
72 Index getBasisSetSize() const { return dftbasis_.AOBasisSize(); }
73
78 }
79 return occupied_levels_;
80 }
81
83 Index getHomoAlpha() const { return getLumoAlpha() - 1; }
84
88 if (number_beta_electrons_ > 0) {
90 }
91
92 // Legacy restricted closed-shell fallback
93 if (!hasUnrestrictedOrbitals() && total_spin_ == 1) {
94 return occupied_levels_;
95 }
96
98 }
99
101 Index getHomoBeta() const { return getLumoBeta() - 1; }
102
103 // Current generic convention: use alpha frontier orbitals
105 Index getLumo() const { return getLumoAlpha(); }
107 Index getHomo() const { return getHomoAlpha(); }
108
109 // access to DFT number of levels, new, tested
111 bool hasNumberOfLevels() const {
112 return ((occupied_levels_ > 0) ? true : false);
113 }
114
117 return ((occupied_levels_beta_ > 0) ? true : false);
118 }
119
122 void setNumberOfOccupiedLevels(Index occupied_levels) {
123 occupied_levels_ = occupied_levels;
124
125 // Backward compatibility for legacy restricted/singlet workflows:
126 // many callers only set occupied_levels_ and expect a closed-shell density.
127 if (!hasUnrestrictedOrbitals() && total_spin_ == 1) {
128 number_alpha_electrons_ = occupied_levels;
129 number_beta_electrons_ = occupied_levels;
130 }
131 }
132
134 void setNumberOfOccupiedLevelsBeta(Index occupied_levels_beta) {
135 occupied_levels_beta_ = occupied_levels_beta;
136 }
137
140 number_alpha_electrons_ = electrons;
141 }
142
145 number_beta_electrons_ = electrons;
146 }
147
148 // access to DFT number of electrons, new, tested
151 return (number_alpha_electrons_ > 0) ? true : false;
152 }
153
155 return (number_beta_electrons_ > 0) ? true : false;
156 }
157
162
164 bool hasECPName() const { return (ECP_ != "") ? true : false; }
165
167 const std::string &getECPName() const { return ECP_; };
168
170 void setECPName(const std::string &ECP) { ECP_ = ECP; };
171
172 // access to QM package name, new, tested
173
175 bool hasQMpackage() const { return (!qm_package_.empty()); }
176
178 const std::string &getQMpackage() const { return qm_package_; }
179
181 void setQMpackage(const std::string &qmpackage) { qm_package_ = qmpackage; }
182
183 // access to DFT molecular orbital energies, new, tested
185 bool hasMOs() const { return (mos_.eigenvalues().size() > 0) ? true : false; }
187 bool hasBetaMOs() const {
188 return (mos_beta_.eigenvalues().size() > 0) ? true : false;
189 }
190
192 const tools::EigenSystem &MOs() const { return mos_; }
195
197 const Eigen::MatrixXd &Occupations() const { return occupations_; }
199 Eigen::MatrixXd &Occupations() { return occupations_; }
200
202 const tools::EigenSystem &MOs_beta() const { return mos_beta_; }
205
206 // determine (pseudo-)degeneracy of a DFT molecular orbital
209 std::vector<Index> CheckDegeneracy(Index level,
210 double energy_difference) const;
211
214 switch (type.Type()) {
216 return Index(BSE_singlet_.eigenvalues().size());
217 break;
219 return Index(BSE_triplet_.eigenvalues().size());
220 break;
222 return Index(mos_.eigenvalues().size());
223 break;
225 return Index(QPpert_energies_.size());
226 break;
228 return Index(QPdiag_.eigenvalues().size());
229 break;
231 return Index(BSE_uks_.eigenvalues().size());
232 break;
233 default:
234 return 1;
235 break;
236 }
237 }
238
240 void setCalculationType(std::string CalcType) { CalcType_ = CalcType; }
242 std::string getCalculationType() const { return CalcType_; }
243
246 void setChargeAndSpin(Index charge, Index spin) {
247 total_charge_ = charge;
248 total_spin_ = spin;
249 }
250
252 Index getSpin() const { return total_spin_; }
254 Index getCharge() const { return total_charge_; }
256 bool isOpenShell() const { return (total_spin_ > 1) ? true : false; }
257
259 bool hasQMAtoms() const { return (atoms_.size() > 0) ? true : false; }
260
262 const QMMolecule &QMAtoms() const { return atoms_; }
263
265 QMMolecule &QMAtoms() { return atoms_; }
266
268 void updateAtomPostion(Index atom_index, Eigen::Vector3d new_position) {
269 this->QMAtoms()[atom_index].setPos(new_position);
270 dftbasis_.UpdateShellPositions(this->QMAtoms());
271 auxbasis_.UpdateShellPositions(this->QMAtoms());
272 }
273
276 void setXCFunctionalName(std::string functionalname) {
277 functionalname_ = functionalname;
278 }
279
280 const std::string &getXCFunctionalName() const { return functionalname_; }
281
283 void setXCGrid(std::string grid) { grid_quality_ = grid; }
285 const std::string &getXCGrid() const { return grid_quality_; }
286
287 // access to QM total energy, new, tested
289 bool hasQMEnergy() const { return (qm_energy_ != 0.0) ? true : false; }
290
292 double getDFTTotalEnergy() const { return qm_energy_; }
293
295 void setQMEnergy(double qmenergy) { qm_energy_ = qmenergy; }
296
297 // access to nuclear forces (gradient of total energy w.r.t. nuclear
298 // coordinates), Natoms x 3, atomic units (Hartree/Bohr), consistent
299 // with QMAtom::pos_ being stored in Bohr.
301 bool hasForces() const { return forces_.rows() > 0; }
302
304 const Eigen::MatrixXd &getForces() const { return forces_; }
305
309 void setForces(const Eigen::MatrixXd &forces) { forces_ = forces; }
310
311 // access to DFT basis set name
313 bool hasDFTbasisName() const {
314 return (!dftbasis_.Name().empty()) ? true : false;
315 }
316
318 const std::string &getDFTbasisName() const { return dftbasis_.Name(); }
319
321 void SetupDftBasis(std::string basis_name);
322
325 void SetupAuxBasis(std::string aux_basis_name);
326
328 const AOBasis &getDftBasis() const {
329 if (dftbasis_.AOBasisSize() == 0) {
330 throw std::runtime_error(
331 "Requested the DFT basis, but no basis is present. Make sure "
332 "SetupDftBasis is called.");
333 } else {
334 return dftbasis_;
335 }
336 }
337
339 const AOBasis &getAuxBasis() const {
340 if (auxbasis_.AOBasisSize() == 0) {
341 throw std::runtime_error(
342 "Requested the Aux basis, but no basis is present. Make sure "
343 "SetupAuxBasis is called.");
344 } else {
345 return auxbasis_;
346 }
347 }
348
349 /*
350 * ======= GW-BSE related functions =======
351 */
352
353 // access to auxiliary basis set name
354
356 bool hasAuxbasisName() const {
357 return (!auxbasis_.Name().empty()) ? true : false;
358 }
359
361 const std::string getAuxbasisName() const { return auxbasis_.Name(); }
362
363 // access to list of indices used in GWA
364
366 bool hasGWAindices() const { return (qpmax_ > 0) ? true : false; }
367
369 void setGWindices(Index qpmin, Index qpmax) {
370 qpmin_ = qpmin;
371 qpmax_ = qpmax;
372 }
373
375 Index getGWAmin() const { return qpmin_; }
376
378 Index getGWAmax() const { return qpmax_; }
379
380 // access to list of indices used in RPA
381
383 bool hasRPAindices() const { return (rpamax_ > 0) ? true : false; }
384
386 void setRPAindices(Index rpamin, Index rpamax) {
387 rpamin_ = rpamin;
388 rpamax_ = rpamax;
389 }
390
392 Index getRPAmin() const { return rpamin_; }
393
395 Index getRPAmax() const { return rpamax_; }
396
397 // access to list of indices used in BSE
398
400 void setTDAApprox(bool usedTDA) { useTDA_ = usedTDA; }
402 bool getTDAApprox() const { return useTDA_; }
403
405 bool hasBSEindices() const { return (bse_cmax_ > 0) ? true : false; }
406
409 void setBSEindices(Index vmin, Index cmax) {
410 bse_vmin_ = vmin;
411 bse_vmax_ = getHomo();
412 bse_cmin_ = getLumo();
413 bse_cmax_ = cmax;
417 return;
418 }
419
421 Index getBSEvmin() const { return bse_vmin_; }
422
424 Index getBSEvmax() const { return bse_vmax_; }
425
427 Index getBSEcmin() const { return bse_cmin_; }
428
430 Index getBSEcmax() const { return bse_cmax_; }
431
433 double getScaHFX() const { return ScaHFX_; }
434
436 void setScaHFX(double ScaHFX) { ScaHFX_ = ScaHFX; }
437
438 // access to perturbative QP energies
440 bool hasRPAInputEnergies() const { return (rpa_inputenergies_.size() > 0); }
441
443 const Eigen::VectorXd &RPAInputEnergies() const { return rpa_inputenergies_; }
444
446 Eigen::VectorXd &RPAInputEnergies() { return rpa_inputenergies_; }
447
448 // access to RPA input energies energies
450 bool hasQPpert() const {
451 return (QPpert_energies_.size() > 0) ? true : false;
452 }
453
455 const Eigen::VectorXd &QPpertEnergies() const { return QPpert_energies_; }
456
458 Eigen::VectorXd &QPpertEnergies() { return QPpert_energies_; }
459
460 // access to diagonalized QP energies and wavefunctions
461
464 bool hasQPdiag() const {
465 return (QPdiag_.eigenvalues().size() > 0) ? true : false;
466 }
467
468 const tools::EigenSystem &QPdiag() const { return QPdiag_; }
471
475 Eigen::MatrixXd BSEOrbitals() const;
476
478 bool hasBSETriplets() const {
479 return (BSE_triplet_.eigenvectors().cols() > 0) ? true : false;
480 }
481
483 const tools::EigenSystem &BSETriplets() const { return BSE_triplet_; }
484
487
488 // access to singlet energies and wave function coefficients
489
491 bool hasBSESinglets() const {
492 return (BSE_singlet_.eigenvectors().cols() > 0) ? true : false;
493 }
494
496 const tools::EigenSystem &BSESinglets() const { return BSE_singlet_; }
497
500
501 // access to BSE energies with dynamical screening
504 return (BSE_singlet_energies_dynamic_.size() > 0) ? true : false;
505 }
506
508 const Eigen::VectorXd &BSESinglets_dynamic() const {
510 }
511
513 Eigen::VectorXd &BSESinglets_dynamic() {
515 }
516
519 return (BSE_triplet_energies_dynamic_.size() > 0) ? true : false;
520 }
521
523 const Eigen::VectorXd &BSETriplets_dynamic() const {
525 }
526
528 Eigen::VectorXd &BSETriplets_dynamic() {
530 }
531
532 // access to transition dipole moments
533
535 bool hasTransitionDipoles() const {
536 return (transition_dipoles_.size() > 0) ? true : false;
537 }
538
540 const std::vector<Eigen::Vector3d> &TransitionDipoles() const {
541 return transition_dipoles_;
542 }
543
546 Eigen::VectorXd Oscillatorstrengths() const;
547
549 Eigen::VectorXd Oscillatorstrengths(const QMStateType &type) const;
550
552 Eigen::Vector3d CalcElDipole(const QMState &state) const;
553
554 // Calculates full electron density for state or transition density, if you
555 // want to calculate only the density contribution of hole or electron use
556 // DensityMatrixExcitedState
559 Eigen::MatrixXd DensityMatrixFull(const QMState &state) const;
562 Eigen::MatrixXd DensityMatrixWithoutGS(const QMState &state) const;
563
564 // functions for calculating density matrices
566 Eigen::MatrixXd DensityMatrixGroundState() const;
568 std::array<Eigen::MatrixXd, 2> DensityMatrixExcitedState(
569 const QMState &state) const;
571 Eigen::MatrixXd DensityMatrixQuasiParticle(const QMState &state) const;
573 Eigen::MatrixXd DensityMatrixKSstate(const QMState &state) const;
575 Eigen::MatrixXd CalculateQParticleAORepresentation() const;
577 double getTotalStateEnergy(const QMState &state) const; // Hartree
579 double getExcitedStateEnergy(const QMState &state) const; // Hartree
580
583 void OrderMOsbyEnergy();
584
593
596
599 void PrepareDimerGuess(const Orbitals &orbitalsA, const Orbitals &orbitalsB);
600
626 void PrepareDimerGuessMixedSpin(const Orbitals &orbitalsA,
627 const Orbitals &orbitalsB);
628
632
635
637 void WriteToCpt(const std::string &filename) const;
638
640 void ReadFromCpt(const std::string &filename);
641
643 void WriteToCpt(CheckpointWriter &w) const;
651
654 bool GetFlagUseHqpOffdiag() const { return use_Hqp_offdiag_; };
657 void SetFlagUseHqpOffdiag(bool flag) { use_Hqp_offdiag_ = flag; };
658
662 bool isQSGW() const { return is_qsgw_; };
663 void setQSGW(bool flag) { is_qsgw_ = flag; };
664
666 const Eigen::MatrixXd &getLMOs() const { return lmos_; };
668 void setLMOs(const Eigen::MatrixXd &matrix) { lmos_ = matrix; }
669
671 const Eigen::VectorXd &getLMOs_energies() const { return lmos_energies_; };
673 void setLMOs_energies(const Eigen::VectorXd &energies) {
674 lmos_energies_ = energies;
675 }
676
680 void setNumofActiveElectrons(const Index active_electrons) {
681 active_electrons_ = active_electrons;
682 }
683
685 const Eigen::MatrixXd &getInactiveDensity() const { return inactivedensity_; }
687 void setInactiveDensity(Eigen::MatrixXd inactivedensity) {
688 inactivedensity_ = inactivedensity;
689 }
690
691 /************************************
692 * Extensions spin DFT
693 *************************************/
695 bool hasUnrestrictedOrbitals() const { return hasBetaMOs(); }
696
699 return total_spin_ > 1 && !hasUnrestrictedOrbitals();
700 }
701
705 return total_spin_ > 1 && hasUnrestrictedOrbitals();
706 }
707
709 std::array<Eigen::MatrixXd, 2> DensityMatrixGroundStateSpinResolved() const;
710
711 /************************************
712 * Extensions spin GW
713 *************************************/
715 return (rpa_inputenergies_alpha_.size() > 0);
716 }
718 return (rpa_inputenergies_beta_.size() > 0);
719 }
720 const Eigen::VectorXd &RPAInputEnergiesAlpha() const {
722 }
723 const Eigen::VectorXd &RPAInputEnergiesBeta() const {
725 }
726 Eigen::VectorXd &RPAInputEnergiesAlpha() { return rpa_inputenergies_alpha_; }
727 Eigen::VectorXd &RPAInputEnergiesBeta() { return rpa_inputenergies_beta_; }
728
729 bool hasQPpertAlpha() const { return (QPpert_energies_alpha_.size() > 0); }
730 bool hasQPpertBeta() const { return (QPpert_energies_beta_.size() > 0); }
731 const Eigen::MatrixXd &QPpertEnergiesAlpha() const {
733 }
734 const Eigen::MatrixXd &QPpertEnergiesBeta() const {
736 }
737 Eigen::MatrixXd &QPpertEnergiesAlpha() { return QPpert_energies_alpha_; }
738 Eigen::MatrixXd &QPpertEnergiesBeta() { return QPpert_energies_beta_; }
739
740 bool hasQPdiagAlpha() const {
741 return (QPdiag_alpha_.eigenvalues().size() > 0);
742 }
743 bool hasQPdiagBeta() const { return (QPdiag_beta_.eigenvalues().size() > 0); }
745 const tools::EigenSystem &QPdiagBeta() const { return QPdiag_beta_; }
748
752 bool hasBSEUKS() const {
753 return (BSE_uks_.eigenvectors().cols() > 0) ? true : false;
754 }
755 const tools::EigenSystem &BSEUKS() const { return BSE_uks_; }
757
758 bool hasBSEUKS_dynamic() const {
759 return (BSE_uks_energies_dynamic_.size() > 0) ? true : false;
760 }
761 const Eigen::VectorXd &BSEUKS_dynamic() const {
763 }
764 Eigen::VectorXd &BSEUKS_dynamic() { return BSE_uks_energies_dynamic_; }
765
766 private:
767 std::array<Eigen::MatrixXd, 3> CalcFreeTransition_Dipoles() const;
768
769 // returns indeces of a re-sorted vector of energies from lowest to highest
770 std::vector<Index> SortEnergies();
771
772 // Same as SortEnergies, but for the ALPHA channel specifically -- unlike
773 // SortEnergies (which throws for hasUnrestrictedOrbitals()==true), this
774 // and SortEnergiesBeta below are meant to be called ON an unrestricted
775 // system, one channel at a time. Used by OrderMOsbyEnergyAlpha.
776 std::vector<Index> SortEnergiesAlpha();
777
778 // Same as SortEnergiesAlpha, but sorting mos_beta_.eigenvalues() instead.
779 // Used by OrderMOsbyEnergyBeta.
780 std::vector<Index> SortEnergiesBeta();
781
782 void WriteToCpt(CheckpointFile &f) const;
783
785 Eigen::MatrixXd TransitionDensityMatrix(const QMState &state) const;
786 std::array<Eigen::MatrixXd, 2> DensityMatrixExcitedState_R(
787 const QMState &state) const;
788 std::array<Eigen::MatrixXd, 2> DensityMatrixExcitedState_AR(
789 const QMState &state) const;
790 Eigen::MatrixXd CalcAuxMat_cc(const Eigen::VectorXd &coeffs) const;
791 Eigen::MatrixXd CalcAuxMat_vv(const Eigen::VectorXd &coeffs) const;
792
797 std::string ECP_ = "";
799
800 std::string CalcType_ = "NoEmbedding";
801
804 Eigen::MatrixXd occupations_;
805
807
808 Eigen::MatrixXd lmos_;
809 Eigen::VectorXd lmos_energies_;
811 Eigen::MatrixXd inactivedensity_;
812 Eigen::MatrixXd expandedMOs_;
813
815
818
819 double qm_energy_ = 0;
820 // Natoms x 3, Hartree/Bohr; empty (rows()==0) means "not computed",
821 // matching the pattern of qm_energy_'s hasQMEnergy() check above but
822 // via emptiness rather than a sentinel value, since 0.0 is a
823 // legitimate force value on any individual component in a way it isn't
824 // for a total energy.
825 Eigen::MatrixXd forces_;
826
829
830 // new variables for GW-BSE storage
833
843
844 double ScaHFX_ = 0;
845
846 std::string functionalname_ = "";
847 std::string grid_quality_ = "";
848 std::string qm_package_ = "";
849
850 Eigen::VectorXd rpa_inputenergies_;
851 // perturbative quasiparticle energies
852 Eigen::VectorXd QPpert_energies_;
853
854 // quasiparticle energies and coefficients after diagonalization
856
858 std::vector<Eigen::Vector3d> transition_dipoles_;
860
861 // singlet and triplet energies after perturbative dynamical screening
864
865 bool use_Hqp_offdiag_ = false;
866 bool is_qsgw_ = false; // true if QP data comes from a QSGW calculation
867
868 // Spin-GW additions
870 Eigen::VectorXd rpa_inputenergies_beta_;
871
872 Eigen::MatrixXd QPpert_energies_alpha_;
873 Eigen::MatrixXd QPpert_energies_beta_;
874
877
880
881 // Version 2: adds BSE energies after perturbative dynamical screening
882 // Version 3: changed shell ordering
883 // Version 4: added vxc grid quality
884 // Version 5: added the dft and aux basisset
885 // Version 6: added spin in dft
886 // Version 9: added is_qsgw flag
887 static constexpr int orbitals_version() { return 9; }
888};
889
890} // namespace xtp
891} // namespace votca
892
893#endif // VOTCA_XTP_ORBITALS_H
Container to hold Basisfunctions for all atoms.
Definition aobasis.h:42
Container for molecular orbitals and derived one-particle data.
Definition orbitals.h:47
tools::EigenSystem QPdiag_alpha_
Definition orbitals.h:875
Index getBSEvmax() const
Return the highest valence orbital included in BSE.
Definition orbitals.h:424
const Eigen::MatrixXd getTruncMOsFullBasis() const
Return truncated active-region orbitals represented in the full AO basis.
Definition orbitals.h:69
void setScaHFX(double ScaHFX)
Store the fraction of exact exchange associated with the functional.
Definition orbitals.h:436
const Eigen::VectorXd & BSEUKS_dynamic() const
Definition orbitals.h:761
void setCalculationType(std::string CalcType)
Store the calculation-type tag used by downstream workflows.
Definition orbitals.h:240
Eigen::VectorXd & RPAInputEnergiesBeta()
Definition orbitals.h:727
const tools::EigenSystem & BSETriplets() const
Return read-only access to triplet BSE eigenpairs.
Definition orbitals.h:483
bool GetFlagUseHqpOffdiag() const
Definition orbitals.h:654
Index getNumOfActiveElectrons()
Return the number of electrons assigned to the active region.
Definition orbitals.h:678
Index number_beta_electrons_
Definition orbitals.h:796
void CalcCoupledTransition_Dipoles()
Definition orbitals.cc:774
bool hasQPdiag() const
Definition orbitals.h:464
Index getCharge() const
Return the stored total charge.
Definition orbitals.h:254
Eigen::MatrixXd occupations_
Definition orbitals.h:804
bool hasQPpertAlpha() const
Definition orbitals.h:729
Index getBSEcmin() const
Return the lowest conduction orbital included in BSE.
Definition orbitals.h:427
bool hasRPAindices() const
Report whether the RPA window has been defined.
Definition orbitals.h:383
Eigen::VectorXd rpa_inputenergies_
Definition orbitals.h:850
const tools::EigenSystem & QPdiag() const
Return read-only access to the diagonalized quasiparticle representation.
Definition orbitals.h:468
Index getHomo() const
Return the default HOMO index used by spin-agnostic callers.
Definition orbitals.h:107
Eigen::MatrixXd & QPpertEnergiesBeta()
Definition orbitals.h:738
Eigen::VectorXd BSE_uks_energies_dynamic_
Definition orbitals.h:879
Eigen::MatrixXd TransitionDensityMatrix(const QMState &state) const
Definition orbitals.cc:331
double getDFTTotalEnergy() const
Return the stored total DFT energy.
Definition orbitals.h:292
bool hasBSESinglets_dynamic() const
Report whether dynamically screened singlet BSE energies are available.
Definition orbitals.h:503
void setInactiveDensity(Eigen::MatrixXd inactivedensity)
Store the inactive-region density matrix used in embedding workflows.
Definition orbitals.h:687
Eigen::VectorXd & BSEUKS_dynamic()
Definition orbitals.h:764
bool hasBSEindices() const
Report whether the BSE valence/conduction window has been defined.
Definition orbitals.h:405
bool hasAuxbasisName() const
Report whether an auxiliary basis-set name has been stored.
Definition orbitals.h:356
Index getSpin() const
Return the stored spin multiplicity.
Definition orbitals.h:252
Eigen::MatrixXd CalculateQParticleAORepresentation() const
Transform quasiparticle amplitudes into the AO representation.
Definition orbitals.cc:265
bool hasForces() const
Report whether nuclear forces have been stored.
Definition orbitals.h:301
Eigen::MatrixXd & QPpertEnergiesAlpha()
Definition orbitals.h:737
std::array< Eigen::MatrixXd, 2 > DensityMatrixExcitedState_R(const QMState &state) const
Definition orbitals.cc:551
const tools::EigenSystem & MOs_beta() const
Return read-only access to beta-spin molecular orbitals.
Definition orbitals.h:202
void setNumofActiveElectrons(const Index active_electrons)
Store the number of electrons assigned to the active region.
Definition orbitals.h:680
bool hasUnrestrictedOrbitals() const
Report whether separate beta-spin orbitals are present.
Definition orbitals.h:695
Eigen::VectorXd lmos_energies_
Definition orbitals.h:809
const tools::EigenSystem & BSESinglets() const
Return read-only access to singlet BSE eigenpairs.
Definition orbitals.h:496
Index getBSEcmax() const
Return the highest conduction orbital included in BSE.
Definition orbitals.h:430
Eigen::VectorXd & BSESinglets_dynamic()
Return writable access to dynamically screened singlet BSE energies.
Definition orbitals.h:513
const Eigen::VectorXd & QPpertEnergies() const
Return read-only access to perturbative quasiparticle energies.
Definition orbitals.h:455
bool getTDAApprox() const
Return whether the Tamm-Dancoff approximation is enabled.
Definition orbitals.h:402
tools::EigenSystem BSE_singlet_
Definition orbitals.h:857
tools::EigenSystem QPdiag_beta_
Definition orbitals.h:876
void OrderMOsbyEnergyBeta()
Same as OrderMOsbyEnergyAlpha, but for the BETA channel (mos_beta_).
Definition orbitals.cc:947
void PrepareDimerGuess(const Orbitals &orbitalsA, const Orbitals &orbitalsB)
Guess for a dimer based on monomer orbitals.
Definition orbitals.cc:966
bool hasNumberOfLevelsBeta() const
Definition orbitals.h:116
tools::EigenSystem mos_beta_
Definition orbitals.h:803
tools::EigenSystem & QPdiagAlpha()
Definition orbitals.h:746
std::string grid_quality_
Definition orbitals.h:847
bool hasMOs() const
Report whether alpha/restricted molecular orbitals are available.
Definition orbitals.h:185
void setTruncMOsFullBasis(const Eigen::MatrixXd &expandedMOs)
Store truncated active-region orbitals expanded back to the full AO basis.
Definition orbitals.h:64
bool hasBSESinglets() const
Report whether singlet BSE eigenpairs are available.
Definition orbitals.h:491
double getTotalStateEnergy(const QMState &state) const
Return the absolute total energy of the requested state in Hartree.
Definition orbitals.cc:690
Eigen::VectorXd BSE_triplet_energies_dynamic_
Definition orbitals.h:863
bool hasQPpertBeta() const
Definition orbitals.h:730
const Eigen::MatrixXd & Occupations() const
Return the stored fractional occupation matrix.
Definition orbitals.h:197
void ReadBasisSetsFromCpt(CheckpointReader &r)
Deserialize attached AO basis sets from an already-open checkpoint reader.
Definition orbitals.cc:1228
std::array< Eigen::MatrixXd, 2 > DensityMatrixGroundStateSpinResolved() const
Definition orbitals.cc:1394
Eigen::MatrixXd QPpert_energies_beta_
Definition orbitals.h:873
void WriteBasisSetsToCpt(CheckpointWriter &w) const
Definition orbitals.cc:1132
tools::EigenSystem & QPdiagBeta()
Definition orbitals.h:747
bool hasRPAInputEnergies() const
Report whether RPA input energies are available.
Definition orbitals.h:440
bool isRestrictedOpenShell() const
Report whether the orbitals represent a restricted open-shell reference.
Definition orbitals.h:698
std::vector< Index > CheckDegeneracy(Index level, double energy_difference) const
Definition orbitals.cc:56
tools::EigenSystem & BSETriplets()
Return writable access to triplet BSE eigenpairs.
Definition orbitals.h:486
const AOBasis & getAuxBasis() const
Return the auxiliary AO basis, throwing if it has not been initialized.
Definition orbitals.h:339
Eigen::MatrixXd inactivedensity_
Definition orbitals.h:811
Index getNumberOfAlphaElectrons() const
Return the stored number of alpha electrons.
Definition orbitals.h:159
void setLMOs_energies(const Eigen::VectorXd &energies)
Store the energies associated with localized molecular orbitals.
Definition orbitals.h:673
std::string getCalculationType() const
Return the stored calculation-type tag.
Definition orbitals.h:242
bool hasQMAtoms() const
Report whether a molecular geometry has been stored.
Definition orbitals.h:259
std::array< Eigen::MatrixXd, 3 > CalcFreeTransition_Dipoles() const
Definition orbitals.cc:756
void setLMOs(const Eigen::MatrixXd &matrix)
Store localized molecular orbitals.
Definition orbitals.h:668
bool hasNumberOfBetaElectrons() const
Report whether the beta-electron count has been set explicitly.
Definition orbitals.h:154
const std::string & getQMpackage() const
Return the stored QM package name.
Definition orbitals.h:178
QMMolecule & QMAtoms()
Return writable access to the molecular geometry.
Definition orbitals.h:265
Eigen::MatrixXd forces_
Definition orbitals.h:825
const Eigen::MatrixXd & QPpertEnergiesBeta() const
Definition orbitals.h:734
Eigen::MatrixXd CalcAuxMat_cc(const Eigen::VectorXd &coeffs) const
Definition orbitals.cc:599
void setRPAindices(Index rpamin, Index rpamax)
Store the orbital window used in RPA calculations.
Definition orbitals.h:386
bool hasNumberOfLevels() const
Report whether the number of occupied spatial orbitals has been set.
Definition orbitals.h:111
Eigen::MatrixXd expandedMOs_
Definition orbitals.h:812
void setNumberOfAlphaElectrons(Index electrons)
Store the total number of alpha electrons.
Definition orbitals.h:139
Index getBSEvmin() const
Return the lowest valence orbital included in BSE.
Definition orbitals.h:421
bool isQSGW() const
Definition orbitals.h:662
void updateAtomPostion(Index atom_index, Eigen::Vector3d new_position)
Update one atomic position and keep attached AO basis shells synchronized.
Definition orbitals.h:268
const tools::EigenSystem & BSEUKS() const
Definition orbitals.h:755
Eigen::VectorXd & RPAInputEnergies()
Return writable access to the RPA input energies.
Definition orbitals.h:446
Eigen::VectorXd Oscillatorstrengths() const
Definition orbitals.cc:657
std::vector< Eigen::Vector3d > transition_dipoles_
Definition orbitals.h:858
const tools::EigenSystem & QPdiagAlpha() const
Definition orbitals.h:744
static constexpr int orbitals_version()
Definition orbitals.h:887
std::string functionalname_
Definition orbitals.h:846
Eigen::MatrixXd lmos_
Definition orbitals.h:808
Eigen::MatrixXd & Occupations()
Return writable access to the fractional occupation matrix.
Definition orbitals.h:199
Eigen::MatrixXd DensityMatrixWithoutGS(const QMState &state) const
Definition orbitals.cc:121
bool hasGWAindices() const
Report whether the GW quasiparticle window has been defined.
Definition orbitals.h:366
tools::EigenSystem & MOs()
Return writable access to alpha/restricted molecular orbitals.
Definition orbitals.h:194
bool hasQMEnergy() const
Report whether a total electronic energy has been stored.
Definition orbitals.h:289
Eigen::MatrixXd DensityMatrixFull(const QMState &state) const
Definition orbitals.cc:150
bool hasTransitionDipoles() const
Report whether transition dipole moments have been computed.
Definition orbitals.h:535
const Eigen::MatrixXd & getLMOs() const
Return localized molecular orbitals, if available.
Definition orbitals.h:666
Eigen::MatrixXd CalcAuxMat_vv(const Eigen::VectorXd &coeffs) const
Definition orbitals.cc:593
tools::EigenSystem & MOs_beta()
Return writable access to beta-spin molecular orbitals.
Definition orbitals.h:204
tools::EigenSystem & QPdiag()
Return writable access to the diagonalized quasiparticle representation.
Definition orbitals.h:470
void PrepareDimerGuessMixedSpin(const Orbitals &orbitalsA, const Orbitals &orbitalsB)
Guess for a dimer of two monomers with independently ARBITRARY charge and spin, built by combining ea...
Definition orbitals.cc:1046
void SetupAuxBasis(std::string aux_basis_name)
Definition orbitals.cc:108
std::string qm_package_
Definition orbitals.h:848
Index getLumoAlpha() const
Return the alpha-spin LUMO index inferred from the stored electron counts.
Definition orbitals.h:75
void setNumberOfBetaElectrons(Index electrons)
Store the total number of beta electrons.
Definition orbitals.h:144
tools::EigenSystem BSE_triplet_
Definition orbitals.h:859
Index getRPAmax() const
Return the upper RPA orbital index.
Definition orbitals.h:395
bool hasBSEUKS() const
Definition orbitals.h:752
void setBSEindices(Index vmin, Index cmax)
Definition orbitals.h:409
bool hasBasisSetSize() const
Report whether a DFT AO basis has already been attached.
Definition orbitals.h:53
const Eigen::MatrixXd & getInactiveDensity() const
Return the inactive-region density matrix used in embedding workflows.
Definition orbitals.h:685
void setGWindices(Index qpmin, Index qpmax)
Store the orbital window used in GW calculations.
Definition orbitals.h:369
std::vector< Index > SortEnergies()
Definition orbitals.cc:81
Index getHomoBeta() const
Return the beta-spin HOMO index.
Definition orbitals.h:101
std::array< Eigen::MatrixXd, 2 > DensityMatrixExcitedState_AR(const QMState &state) const
Definition orbitals.cc:605
bool hasQMpackage() const
Report whether the originating QM package name has been stored.
Definition orbitals.h:175
double getExcitedStateEnergy(const QMState &state) const
Return the excitation energy of the requested state in Hartree.
Definition orbitals.cc:699
bool isUnrestrictedOpenShell() const
Definition orbitals.h:704
tools::EigenSystem & BSESinglets()
Return writable access to singlet BSE eigenpairs.
Definition orbitals.h:499
void setForces(const Eigen::MatrixXd &forces)
Definition orbitals.h:309
bool hasRPAInputEnergiesBeta() const
Definition orbitals.h:717
void setECPName(const std::string &ECP)
Store the effective core potential label.
Definition orbitals.h:170
void setXCGrid(std::string grid)
Store the numerical XC grid quality label.
Definition orbitals.h:283
void setNumberOfOccupiedLevels(Index occupied_levels)
Definition orbitals.h:122
const std::vector< Eigen::Vector3d > & TransitionDipoles() const
Return the stored transition dipole moments.
Definition orbitals.h:540
Index occupied_levels_beta_
Definition orbitals.h:794
Orbitals()
Construct an empty orbital container with default metadata.
Definition orbitals.cc:46
tools::EigenSystem mos_
Definition orbitals.h:802
void OrderMOsbyEnergyAlpha()
Definition orbitals.cc:935
tools::EigenSystem QPdiag_
Definition orbitals.h:855
Eigen::VectorXd rpa_inputenergies_beta_
Definition orbitals.h:870
const Eigen::MatrixXd & QPpertEnergiesAlpha() const
Definition orbitals.h:731
bool hasBSETriplets() const
Report whether triplet BSE eigenpairs are available.
Definition orbitals.h:478
void setQSGW(bool flag)
Definition orbitals.h:663
Eigen::MatrixXd DensityMatrixKSstate(const QMState &state) const
Build the AO density matrix for a single KS orbital state.
Definition orbitals.cc:232
bool hasBSETriplets_dynamic() const
Report whether dynamically screened triplet BSE energies are available.
Definition orbitals.h:518
const std::string getAuxbasisName() const
Return the auxiliary basis-set name.
Definition orbitals.h:361
Eigen::MatrixXd DensityMatrixQuasiParticle(const QMState &state) const
Build the AO density matrix for a quasiparticle state.
Definition orbitals.cc:280
bool hasQPpert() const
Report whether perturbative quasiparticle energies are available.
Definition orbitals.h:450
double getScaHFX() const
Return the fraction of exact exchange associated with the functional.
Definition orbitals.h:433
Index getBasisSetSize() const
Return the number of AO basis functions in the DFT basis.
Definition orbitals.h:72
void setQMEnergy(double qmenergy)
Store the total DFT energy.
Definition orbitals.h:295
std::vector< Index > SortEnergiesBeta()
Definition orbitals.cc:925
const Eigen::VectorXd & RPAInputEnergies() const
Return read-only access to the RPA input energies.
Definition orbitals.h:443
Eigen::VectorXd & RPAInputEnergiesAlpha()
Definition orbitals.h:726
Eigen::MatrixXd QPpert_energies_alpha_
Definition orbitals.h:872
Eigen::MatrixXd BSEOrbitals() const
Definition orbitals.cc:250
const std::string & getXCGrid() const
Return the numerical XC grid quality label.
Definition orbitals.h:285
Eigen::VectorXd BSE_singlet_energies_dynamic_
Definition orbitals.h:862
Index getGWAmin() const
Return the lower GW orbital index.
Definition orbitals.h:375
bool hasRPAInputEnergiesAlpha() const
Definition orbitals.h:714
Eigen::VectorXd & QPpertEnergies()
Return writable access to perturbative quasiparticle energies.
Definition orbitals.h:458
bool hasECPName() const
Report whether an effective core potential label has been stored.
Definition orbitals.h:164
const Eigen::VectorXd & BSETriplets_dynamic() const
Return dynamically screened triplet BSE energies.
Definition orbitals.h:523
const tools::EigenSystem & MOs() const
Return read-only access to alpha/restricted molecular orbitals.
Definition orbitals.h:192
void setQMpackage(const std::string &qmpackage)
Store the name of the QM package that produced these orbitals.
Definition orbitals.h:181
Eigen::VectorXd & BSETriplets_dynamic()
Return writable access to dynamically screened triplet BSE energies.
Definition orbitals.h:528
Eigen::MatrixXd DensityMatrixGroundState() const
Build the ground-state AO density matrix from the stored orbitals.
Definition orbitals.cc:220
std::string CalcType_
Definition orbitals.h:800
Index getLumoBeta() const
Definition orbitals.h:87
const QMMolecule & QMAtoms() const
Return read-only access to the molecular geometry.
Definition orbitals.h:262
tools::EigenSystem mos_embedding_
Definition orbitals.h:806
const std::string & getXCFunctionalName() const
Return the exchange-correlation functional label.
Definition orbitals.h:280
Eigen::VectorXd rpa_inputenergies_alpha_
Definition orbitals.h:869
bool hasQPdiagBeta() const
Definition orbitals.h:743
std::vector< Index > SortEnergiesAlpha()
Definition orbitals.cc:913
Index getGWAmax() const
Return the upper GW orbital index.
Definition orbitals.h:378
void SetFlagUseHqpOffdiag(bool flag)
Definition orbitals.h:657
void ReadFromCpt(const std::string &filename)
Read the orbital container from a checkpoint file on disk.
Definition orbitals.cc:1215
void setEmbeddedMOs(tools::EigenSystem &system)
Store molecular orbitals obtained from an embedding calculation.
Definition orbitals.h:58
tools::EigenSystem BSE_uks_
Definition orbitals.h:878
void setNumberOfOccupiedLevelsBeta(Index occupied_levels_beta)
Store the number of occupied beta-spin orbitals.
Definition orbitals.h:134
const tools::EigenSystem & QPdiagBeta() const
Definition orbitals.h:745
void setChargeAndSpin(Index charge, Index spin)
Definition orbitals.h:246
const Eigen::VectorXd & RPAInputEnergiesBeta() const
Definition orbitals.h:723
Eigen::VectorXd QPpert_energies_
Definition orbitals.h:852
void WriteToCpt(const std::string &filename) const
Write the orbital container to a checkpoint file on disk.
Definition orbitals.cc:1119
bool hasDFTbasisName() const
Report whether a DFT basis-set name has been stored.
Definition orbitals.h:313
const std::string & getECPName() const
Return the effective core potential label.
Definition orbitals.h:167
const std::string & getDFTbasisName() const
Return the DFT basis-set name.
Definition orbitals.h:318
bool hasBetaMOs() const
Report whether beta-spin molecular orbitals are available.
Definition orbitals.h:187
void SetupDftBasis(std::string basis_name)
Build and attach the DFT AO basis from the stored molecular geometry.
Definition orbitals.cc:99
void setTDAApprox(bool usedTDA)
Enable or disable the Tamm-Dancoff approximation flag.
Definition orbitals.h:400
const Eigen::VectorXd & RPAInputEnergiesAlpha() const
Definition orbitals.h:720
tools::EigenSystem & BSEUKS()
Definition orbitals.h:756
std::array< Eigen::MatrixXd, 2 > DensityMatrixExcitedState(const QMState &state) const
Build separate hole and electron AO densities for an excited state.
Definition orbitals.cc:429
bool isOpenShell() const
Report whether the stored state corresponds to an open-shell system.
Definition orbitals.h:256
const Eigen::VectorXd & BSESinglets_dynamic() const
Return dynamically screened singlet BSE energies.
Definition orbitals.h:508
std::string ECP_
Definition orbitals.h:797
Index number_alpha_electrons_
Definition orbitals.h:795
const tools::EigenSystem & getEmbeddedMOs() const
Return molecular orbitals obtained from an embedding calculation.
Definition orbitals.h:61
Index NumberofStates(QMStateType type) const
Return the number of states available for the requested state family.
Definition orbitals.h:213
Index getRPAmin() const
Return the lower RPA orbital index.
Definition orbitals.h:392
const Eigen::MatrixXd & getForces() const
Return the stored nuclear forces (Natoms x 3, Hartree/Bohr).
Definition orbitals.h:304
Eigen::Vector3d CalcElDipole(const QMState &state) const
Compute the electronic dipole moment associated with a state density.
Definition orbitals.cc:303
Index getNumberOfBetaElectrons() const
Return the stored number of beta electrons.
Definition orbitals.h:161
Index getHomoAlpha() const
Return the alpha-spin HOMO index.
Definition orbitals.h:83
const AOBasis & getDftBasis() const
Return the DFT AO basis, throwing if it has not been initialized.
Definition orbitals.h:328
const Eigen::VectorXd & getLMOs_energies() const
Return the energies associated with localized molecular orbitals.
Definition orbitals.h:671
QMMolecule atoms_
Definition orbitals.h:814
bool hasQPdiagAlpha() const
Definition orbitals.h:740
bool hasNumberOfAlphaElectrons() const
Report whether the alpha-electron count has been set explicitly.
Definition orbitals.h:150
Index getLumo() const
Return the default LUMO index used by spin-agnostic callers.
Definition orbitals.h:105
bool hasBSEUKS_dynamic() const
Definition orbitals.h:758
void setXCFunctionalName(std::string functionalname)
Definition orbitals.h:276
statetype Type() const
Definition qmstate.h:53
Identifier for QMstates. Strings like S1 are converted into enum +zero indexed int.
Definition qmstate.h:135
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26