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
473 bool hasQSGWRotation() const { return qsgw_rotation_.size() > 0; }
474
477 const Eigen::MatrixXd &getQSGWRotation() const { return qsgw_rotation_; }
478
480 void setQSGWRotation(const Eigen::MatrixXd &U) { qsgw_rotation_ = U; }
481
483 bool hasBSETriplets() const {
484 return (BSE_triplet_.eigenvectors().cols() > 0) ? true : false;
485 }
486
488 const tools::EigenSystem &BSETriplets() const { return BSE_triplet_; }
489
492
493 // access to singlet energies and wave function coefficients
494
496 bool hasBSESinglets() const {
497 return (BSE_singlet_.eigenvectors().cols() > 0) ? true : false;
498 }
499
501 const tools::EigenSystem &BSESinglets() const { return BSE_singlet_; }
502
505
506 // access to BSE energies with dynamical screening
509 return (BSE_singlet_energies_dynamic_.size() > 0) ? true : false;
510 }
511
513 const Eigen::VectorXd &BSESinglets_dynamic() const {
515 }
516
518 Eigen::VectorXd &BSESinglets_dynamic() {
520 }
521
524 return (BSE_triplet_energies_dynamic_.size() > 0) ? true : false;
525 }
526
528 const Eigen::VectorXd &BSETriplets_dynamic() const {
530 }
531
533 Eigen::VectorXd &BSETriplets_dynamic() {
535 }
536
537 // access to transition dipole moments
538
540 bool hasTransitionDipoles() const {
541 return (transition_dipoles_.size() > 0) ? true : false;
542 }
543
545 const std::vector<Eigen::Vector3d> &TransitionDipoles() const {
546 return transition_dipoles_;
547 }
548
551 Eigen::VectorXd Oscillatorstrengths() const;
552
554 Eigen::VectorXd Oscillatorstrengths(const QMStateType &type) const;
555
557 Eigen::Vector3d CalcElDipole(const QMState &state) const;
558
559 // Calculates full electron density for state or transition density, if you
560 // want to calculate only the density contribution of hole or electron use
561 // DensityMatrixExcitedState
564 Eigen::MatrixXd DensityMatrixFull(const QMState &state) const;
567 Eigen::MatrixXd DensityMatrixWithoutGS(const QMState &state) const;
568
569 // functions for calculating density matrices
571 Eigen::MatrixXd DensityMatrixGroundState() const;
573 std::array<Eigen::MatrixXd, 2> DensityMatrixExcitedState(
574 const QMState &state) const;
576 Eigen::MatrixXd DensityMatrixQuasiParticle(const QMState &state) const;
578 Eigen::MatrixXd DensityMatrixKSstate(const QMState &state) const;
580 Eigen::MatrixXd CalculateQParticleAORepresentation() const;
582 double getTotalStateEnergy(const QMState &state) const; // Hartree
584 double getExcitedStateEnergy(const QMState &state) const; // Hartree
585
588 void OrderMOsbyEnergy();
589
598
601
604 void PrepareDimerGuess(const Orbitals &orbitalsA, const Orbitals &orbitalsB);
605
631 void PrepareDimerGuessMixedSpin(const Orbitals &orbitalsA,
632 const Orbitals &orbitalsB);
633
637
640
642 void WriteToCpt(const std::string &filename) const;
643
645 void ReadFromCpt(const std::string &filename);
646
648 void WriteToCpt(CheckpointWriter &w) const;
656
659 bool GetFlagUseHqpOffdiag() const { return use_Hqp_offdiag_; };
662 void SetFlagUseHqpOffdiag(bool flag) { use_Hqp_offdiag_ = flag; };
663
667 bool isQSGW() const { return is_qsgw_; };
668 void setQSGW(bool flag) { is_qsgw_ = flag; };
669
671 const Eigen::MatrixXd &getLMOs() const { return lmos_; };
673 void setLMOs(const Eigen::MatrixXd &matrix) { lmos_ = matrix; }
674
676 const Eigen::VectorXd &getLMOs_energies() const { return lmos_energies_; };
678 void setLMOs_energies(const Eigen::VectorXd &energies) {
679 lmos_energies_ = energies;
680 }
681
685 void setNumofActiveElectrons(const Index active_electrons) {
686 active_electrons_ = active_electrons;
687 }
688
690 const Eigen::MatrixXd &getInactiveDensity() const { return inactivedensity_; }
692 void setInactiveDensity(Eigen::MatrixXd inactivedensity) {
693 inactivedensity_ = inactivedensity;
694 }
695
696 /************************************
697 * Extensions spin DFT
698 *************************************/
700 bool hasUnrestrictedOrbitals() const { return hasBetaMOs(); }
701
704 return total_spin_ > 1 && !hasUnrestrictedOrbitals();
705 }
706
710 return total_spin_ > 1 && hasUnrestrictedOrbitals();
711 }
712
714 std::array<Eigen::MatrixXd, 2> DensityMatrixGroundStateSpinResolved() const;
715
716 /************************************
717 * Extensions spin GW
718 *************************************/
720 return (rpa_inputenergies_alpha_.size() > 0);
721 }
723 return (rpa_inputenergies_beta_.size() > 0);
724 }
725 const Eigen::VectorXd &RPAInputEnergiesAlpha() const {
727 }
728 const Eigen::VectorXd &RPAInputEnergiesBeta() const {
730 }
731 Eigen::VectorXd &RPAInputEnergiesAlpha() { return rpa_inputenergies_alpha_; }
732 Eigen::VectorXd &RPAInputEnergiesBeta() { return rpa_inputenergies_beta_; }
733
734 bool hasQPpertAlpha() const { return (QPpert_energies_alpha_.size() > 0); }
735 bool hasQPpertBeta() const { return (QPpert_energies_beta_.size() > 0); }
736 const Eigen::MatrixXd &QPpertEnergiesAlpha() const {
738 }
739 const Eigen::MatrixXd &QPpertEnergiesBeta() const {
741 }
742 Eigen::MatrixXd &QPpertEnergiesAlpha() { return QPpert_energies_alpha_; }
743 Eigen::MatrixXd &QPpertEnergiesBeta() { return QPpert_energies_beta_; }
744
745 bool hasQPdiagAlpha() const {
746 return (QPdiag_alpha_.eigenvalues().size() > 0);
747 }
748 bool hasQPdiagBeta() const { return (QPdiag_beta_.eigenvalues().size() > 0); }
750 const tools::EigenSystem &QPdiagBeta() const { return QPdiag_beta_; }
753
757 bool hasBSEUKS() const {
758 return (BSE_uks_.eigenvectors().cols() > 0) ? true : false;
759 }
760 const tools::EigenSystem &BSEUKS() const { return BSE_uks_; }
762
763 bool hasBSEUKS_dynamic() const {
764 return (BSE_uks_energies_dynamic_.size() > 0) ? true : false;
765 }
766 const Eigen::VectorXd &BSEUKS_dynamic() const {
768 }
769 Eigen::VectorXd &BSEUKS_dynamic() { return BSE_uks_energies_dynamic_; }
770
771 private:
772 std::array<Eigen::MatrixXd, 3> CalcFreeTransition_Dipoles() const;
773
774 // returns indeces of a re-sorted vector of energies from lowest to highest
775 std::vector<Index> SortEnergies();
776
777 // Same as SortEnergies, but for the ALPHA channel specifically -- unlike
778 // SortEnergies (which throws for hasUnrestrictedOrbitals()==true), this
779 // and SortEnergiesBeta below are meant to be called ON an unrestricted
780 // system, one channel at a time. Used by OrderMOsbyEnergyAlpha.
781 std::vector<Index> SortEnergiesAlpha();
782
783 // Same as SortEnergiesAlpha, but sorting mos_beta_.eigenvalues() instead.
784 // Used by OrderMOsbyEnergyBeta.
785 std::vector<Index> SortEnergiesBeta();
786
787 void WriteToCpt(CheckpointFile &f) const;
788
790 Eigen::MatrixXd TransitionDensityMatrix(const QMState &state) const;
791 std::array<Eigen::MatrixXd, 2> DensityMatrixExcitedState_R(
792 const QMState &state) const;
793 std::array<Eigen::MatrixXd, 2> DensityMatrixExcitedState_AR(
794 const QMState &state) const;
795 Eigen::MatrixXd CalcAuxMat_cc(const Eigen::VectorXd &coeffs) const;
796 Eigen::MatrixXd CalcAuxMat_vv(const Eigen::VectorXd &coeffs) const;
797
802 std::string ECP_ = "";
804
805 std::string CalcType_ = "NoEmbedding";
806
809 Eigen::MatrixXd occupations_;
810
812
813 Eigen::MatrixXd lmos_;
814 Eigen::VectorXd lmos_energies_;
816 Eigen::MatrixXd inactivedensity_;
817 Eigen::MatrixXd expandedMOs_;
818
820
823
824 double qm_energy_ = 0;
825 // Natoms x 3, Hartree/Bohr; empty (rows()==0) means "not computed",
826 // matching the pattern of qm_energy_'s hasQMEnergy() check above but
827 // via emptiness rather than a sentinel value, since 0.0 is a
828 // legitimate force value on any individual component in a way it isn't
829 // for a total energy.
830 Eigen::MatrixXd forces_;
831
834
835 // new variables for GW-BSE storage
838
848
849 double ScaHFX_ = 0;
850
851 std::string functionalname_ = "";
852 std::string grid_quality_ = "";
853 std::string qm_package_ = "";
854
855 Eigen::VectorXd rpa_inputenergies_;
856 // perturbative quasiparticle energies
857 Eigen::VectorXd QPpert_energies_;
858
859 // quasiparticle energies and coefficients after diagonalization
861 Eigen::MatrixXd qsgw_rotation_;
863
865 std::vector<Eigen::Vector3d> transition_dipoles_;
867
868 // singlet and triplet energies after perturbative dynamical screening
871
872 bool use_Hqp_offdiag_ = false;
873 bool is_qsgw_ = false; // true if QP data comes from a QSGW calculation
874
875 // Spin-GW additions
877 Eigen::VectorXd rpa_inputenergies_beta_;
878
879 Eigen::MatrixXd QPpert_energies_alpha_;
880 Eigen::MatrixXd QPpert_energies_beta_;
881
884
887
888 // Version 2: adds BSE energies after perturbative dynamical screening
889 // Version 3: changed shell ordering
890 // Version 4: added vxc grid quality
891 // Version 5: added the dft and aux basisset
892 // Version 6: added spin in dft
893 // Version 9: added is_qsgw flag
894 static constexpr int orbitals_version() { return 9; }
895};
896
897} // namespace xtp
898} // namespace votca
899
900#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:882
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
bool hasQSGWRotation() const
Return whether a QSGW rotation matrix is available.
Definition orbitals.h:473
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:766
void setCalculationType(std::string CalcType)
Store the calculation-type tag used by downstream workflows.
Definition orbitals.h:240
Eigen::VectorXd & RPAInputEnergiesBeta()
Definition orbitals.h:732
const tools::EigenSystem & BSETriplets() const
Return read-only access to triplet BSE eigenpairs.
Definition orbitals.h:488
bool GetFlagUseHqpOffdiag() const
Definition orbitals.h:659
Index getNumOfActiveElectrons()
Return the number of electrons assigned to the active region.
Definition orbitals.h:683
Index number_beta_electrons_
Definition orbitals.h:801
void CalcCoupledTransition_Dipoles()
Definition orbitals.cc:760
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:809
bool hasQPpertAlpha() const
Definition orbitals.h:734
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:855
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:743
Eigen::VectorXd BSE_uks_energies_dynamic_
Definition orbitals.h:886
Eigen::MatrixXd TransitionDensityMatrix(const QMState &state) const
Definition orbitals.cc:316
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:508
void setInactiveDensity(Eigen::MatrixXd inactivedensity)
Store the inactive-region density matrix used in embedding workflows.
Definition orbitals.h:692
Eigen::VectorXd & BSEUKS_dynamic()
Definition orbitals.h:769
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:250
bool hasForces() const
Report whether nuclear forces have been stored.
Definition orbitals.h:301
Eigen::MatrixXd & QPpertEnergiesAlpha()
Definition orbitals.h:742
std::array< Eigen::MatrixXd, 2 > DensityMatrixExcitedState_R(const QMState &state) const
Definition orbitals.cc:535
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:685
bool hasUnrestrictedOrbitals() const
Report whether separate beta-spin orbitals are present.
Definition orbitals.h:700
Eigen::VectorXd lmos_energies_
Definition orbitals.h:814
const tools::EigenSystem & BSESinglets() const
Return read-only access to singlet BSE eigenpairs.
Definition orbitals.h:501
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:518
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:864
tools::EigenSystem QPdiag_beta_
Definition orbitals.h:883
void OrderMOsbyEnergyBeta()
Same as OrderMOsbyEnergyAlpha, but for the BETA channel (mos_beta_).
Definition orbitals.cc:933
void PrepareDimerGuess(const Orbitals &orbitalsA, const Orbitals &orbitalsB)
Guess for a dimer based on monomer orbitals.
Definition orbitals.cc:952
Eigen::MatrixXd qsgw_rotation_
Definition orbitals.h:861
bool hasNumberOfLevelsBeta() const
Definition orbitals.h:116
tools::EigenSystem mos_beta_
Definition orbitals.h:808
tools::EigenSystem & QPdiagAlpha()
Definition orbitals.h:751
std::string grid_quality_
Definition orbitals.h:852
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:496
double getTotalStateEnergy(const QMState &state) const
Return the absolute total energy of the requested state in Hartree.
Definition orbitals.cc:676
Eigen::VectorXd BSE_triplet_energies_dynamic_
Definition orbitals.h:870
bool hasQPpertBeta() const
Definition orbitals.h:735
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:1214
std::array< Eigen::MatrixXd, 2 > DensityMatrixGroundStateSpinResolved() const
Definition orbitals.cc:1380
Eigen::MatrixXd QPpert_energies_beta_
Definition orbitals.h:880
void WriteBasisSetsToCpt(CheckpointWriter &w) const
Definition orbitals.cc:1118
tools::EigenSystem & QPdiagBeta()
Definition orbitals.h:752
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:703
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:491
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:816
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:678
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:742
void setLMOs(const Eigen::MatrixXd &matrix)
Store localized molecular orbitals.
Definition orbitals.h:673
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:830
const Eigen::MatrixXd & QPpertEnergiesBeta() const
Definition orbitals.h:739
Eigen::MatrixXd CalcAuxMat_cc(const Eigen::VectorXd &coeffs) const
Definition orbitals.cc:584
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:817
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:667
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:760
Eigen::VectorXd & RPAInputEnergies()
Return writable access to the RPA input energies.
Definition orbitals.h:446
Eigen::VectorXd Oscillatorstrengths() const
Definition orbitals.cc:643
std::vector< Eigen::Vector3d > transition_dipoles_
Definition orbitals.h:865
const tools::EigenSystem & QPdiagAlpha() const
Definition orbitals.h:749
static constexpr int orbitals_version()
Definition orbitals.h:894
std::string functionalname_
Definition orbitals.h:851
Eigen::MatrixXd lmos_
Definition orbitals.h:813
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:540
const Eigen::MatrixXd & getLMOs() const
Return localized molecular orbitals, if available.
Definition orbitals.h:671
Eigen::MatrixXd CalcAuxMat_vv(const Eigen::VectorXd &coeffs) const
Definition orbitals.cc:578
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:1032
void SetupAuxBasis(std::string aux_basis_name)
Definition orbitals.cc:108
std::string qm_package_
Definition orbitals.h:853
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:866
Index getRPAmax() const
Return the upper RPA orbital index.
Definition orbitals.h:395
bool hasBSEUKS() const
Definition orbitals.h:757
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 & getQSGWRotation() const
Definition orbitals.h:477
const Eigen::MatrixXd & getInactiveDensity() const
Return the inactive-region density matrix used in embedding workflows.
Definition orbitals.h:690
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:590
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:685
bool isUnrestrictedOpenShell() const
Definition orbitals.h:709
tools::EigenSystem & BSESinglets()
Return writable access to singlet BSE eigenpairs.
Definition orbitals.h:504
void setForces(const Eigen::MatrixXd &forces)
Definition orbitals.h:309
bool hasRPAInputEnergiesBeta() const
Definition orbitals.h:722
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:545
Index occupied_levels_beta_
Definition orbitals.h:799
Orbitals()
Construct an empty orbital container with default metadata.
Definition orbitals.cc:46
tools::EigenSystem mos_
Definition orbitals.h:807
void OrderMOsbyEnergyAlpha()
Definition orbitals.cc:921
tools::EigenSystem QPdiag_
Definition orbitals.h:860
Eigen::VectorXd rpa_inputenergies_beta_
Definition orbitals.h:877
const Eigen::MatrixXd & QPpertEnergiesAlpha() const
Definition orbitals.h:736
bool hasBSETriplets() const
Report whether triplet BSE eigenpairs are available.
Definition orbitals.h:483
void setQSGW(bool flag)
Definition orbitals.h:668
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:523
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:265
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:911
void setQSGWRotation(const Eigen::MatrixXd &U)
Store the QSGW rotation matrix U produced by GW::CalculateQSGW.
Definition orbitals.h:480
const Eigen::VectorXd & RPAInputEnergies() const
Return read-only access to the RPA input energies.
Definition orbitals.h:443
Eigen::VectorXd & RPAInputEnergiesAlpha()
Definition orbitals.h:731
Eigen::MatrixXd QPpert_energies_alpha_
Definition orbitals.h:879
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:869
Index getGWAmin() const
Return the lower GW orbital index.
Definition orbitals.h:375
bool hasRPAInputEnergiesAlpha() const
Definition orbitals.h:719
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:528
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:533
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:805
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:811
const std::string & getXCFunctionalName() const
Return the exchange-correlation functional label.
Definition orbitals.h:280
Eigen::VectorXd rpa_inputenergies_alpha_
Definition orbitals.h:876
bool hasQPdiagBeta() const
Definition orbitals.h:748
std::vector< Index > SortEnergiesAlpha()
Definition orbitals.cc:899
Index getGWAmax() const
Return the upper GW orbital index.
Definition orbitals.h:378
void SetFlagUseHqpOffdiag(bool flag)
Definition orbitals.h:662
void ReadFromCpt(const std::string &filename)
Read the orbital container from a checkpoint file on disk.
Definition orbitals.cc:1201
void setEmbeddedMOs(tools::EigenSystem &system)
Store molecular orbitals obtained from an embedding calculation.
Definition orbitals.h:58
tools::EigenSystem BSE_uks_
Definition orbitals.h:885
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:750
void setChargeAndSpin(Index charge, Index spin)
Definition orbitals.h:246
const Eigen::VectorXd & RPAInputEnergiesBeta() const
Definition orbitals.h:728
Eigen::VectorXd QPpert_energies_
Definition orbitals.h:857
void WriteToCpt(const std::string &filename) const
Write the orbital container to a checkpoint file on disk.
Definition orbitals.cc:1105
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:725
tools::EigenSystem & BSEUKS()
Definition orbitals.h:761
std::array< Eigen::MatrixXd, 2 > DensityMatrixExcitedState(const QMState &state) const
Build separate hole and electron AO densities for an excited state.
Definition orbitals.cc:413
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:513
std::string ECP_
Definition orbitals.h:802
Index number_alpha_electrons_
Definition orbitals.h:800
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:288
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:676
QMMolecule atoms_
Definition orbitals.h:819
bool hasQPdiagAlpha() const
Definition orbitals.h:745
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:763
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