Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renaming of excited states dipoles #2541

Merged
merged 5 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 0 additions & 14 deletions doc/sphinxman/source/glossary_psivariables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,6 @@ PSI Variables by Alpha
energy [Eh] and correlation correction components [Eh] for the compound
method requested through cbs().

.. psivar:: CCname ROOT n Da
CCname ROOT n (h) Da
CCname ROOT n Da - h TRANSITION

Alpha spin block of the density matrix the requested coupled cluster level of theory and root *n* (number starts at GS = 0).
Conventions for root indexing and whether h refers to transition or root irrep are as in :ref:`sec:psivarnotes`.

.. psivar:: CCname ROOT n Db
CCname ROOT n (h) Db
CCname ROOT n Db - h TRANSITION

Beta spin block of the density matrix the requested coupled cluster level of theory and root *n* (number starts at GS = 0).
Conventions for root indexing and whether h refers to transition or root irrep are as in :ref:`sec:psivarnotes`.

.. psivar:: CCname ROOT n DIPOLE
CCname ROOT n (h) DIPOLE
CCname ROOT n DIPOLE - h TRANSITION
Expand Down
4 changes: 2 additions & 2 deletions psi4/driver/procrouting/proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3209,10 +3209,10 @@ def run_cc_property(name, **kwargs):
f"CC ROOT {total_idx} {{}} - {trans_h_lbl} TRANSITION",
f"{title} ROOT {i} ({root_h_lbl}) {{}}", f"CC ROOT {i} ({root_h_lbl}) {{}}"}
oe.set_names(set_of_names)
Da = ccwfn.variable(root_title + " Da")
Da = ccwfn.get_alpha_density(root_title + " Da")
oe.set_Da_so(Da)
if not ccwfn.same_a_b_dens():
Db = ccwfn.variable(root_title + " Db")
Db = ccwfn.get_beta_density(root_title + " Db")
oe.set_Db_so(Db)
oe.compute()

Expand Down
4 changes: 3 additions & 1 deletion psi4/src/export_wavefunction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,9 @@ void export_wavefunction(py::module& m) {
.def("set_PCM", &Wavefunction::set_PCM, "Set the PCM object")
.def("get_PCM", &Wavefunction::get_PCM, "Get the PCM object")
#endif
.def("PCM_enabled", &Wavefunction::PCM_enabled, "Whether running a PCM calculation");
.def("PCM_enabled", &Wavefunction::PCM_enabled, "Whether running a PCM calculation")
.def("get_alpha_density", [](Wavefunction& wfn, std::string name) {return wfn.Da_map_[name] ;}, "Experimental!")
.def("get_beta_density", [](Wavefunction& wfn, std::string name) {return wfn.Db_map_[name] ;}, "Experimental!");

py::class_<scf::HF, std::shared_ptr<scf::HF>, Wavefunction>(m, "HF", "docstring")
.def("compute_fvpi", &scf::HF::compute_fvpi, "Update number of frozen virtuals")
Expand Down
12 changes: 3 additions & 9 deletions psi4/src/psi4/cc/ccdensity/ccdensity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ PsiReturnType ccdensity(std::shared_ptr<ccenergy::CCEnergyWavefunction> ref_wfn,
auto ref_Da_so = ref_wfn->Da();
ref_Da_so->copy(Pa_so);
} else {
array_saver_state(*ref_wfn, &(rho_params[i]), "Da", Pa_so);
density_saver(*ref_wfn, &(rho_params[i]), "Da", Pa_so);
}
} else {
auto Pa_so = linalg::triplet(ref_wfn->Ca(), Pa_x, ref_wfn->Ca(), false, false, true);
Expand All @@ -406,19 +406,13 @@ PsiReturnType ccdensity(std::shared_ptr<ccenergy::CCEnergyWavefunction> ref_wfn,
ref_Da_so->copy(Pa_so);
ref_Db_so->copy(Pb_so);
} else {
array_saver_state(*ref_wfn, &(rho_params[i]), "Da", Pa_so);
array_saver_state(*ref_wfn, &(rho_params[i]), "Db", Pb_so);
density_saver(*ref_wfn, &(rho_params[i]), "Da", Pa_so);
density_saver(*ref_wfn, &(rho_params[i]), "Db", Pb_so);
}
}

// For psivar scraper

// Process::environment.globals["CCname ROOT n Da"]
// Process::environment.globals["CCname ROOT n Da - h TRANSITION"]
// Process::environment.globals["CCname ROOT n (h) Da"]
// Process::environment.globals["CCname ROOT n Db"]
// Process::environment.globals["CCname ROOT n Db - h TRANSITION"]
// Process::environment.globals["CCname ROOT n (h) Db"]
// Process::environment.globals["CCname ROOT n DIPOLE"]
// Process::environment.globals["CCname ROOT n DIPOLE - h TRANSITION"]
// Process::environment.globals["CCname ROOT n (h) DIPOLE"]
Expand Down
4 changes: 2 additions & 2 deletions psi4/src/psi4/cc/ccdensity/ccdensity.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ namespace ccdensity {
void scalar_saver_ground(ccenergy::CCEnergyWavefunction& wfn, struct TD_Params *S, const std::string suffix, double val);
// Save a scalar describing a excited->excited transition.
void scalar_saver_excited(ccenergy::CCEnergyWavefunction& wfn, struct TD_Params *S, struct TD_Params *U, const std::string suffix, double val);
// Save a scalar describing a single excited transition.
void array_saver_state(ccenergy::CCEnergyWavefunction& wfn, struct RHO_Params *S, const std::string suffix, SharedMatrix val);
// Save a density.
void density_saver(ccenergy::CCEnergyWavefunction& wfn, struct RHO_Params *S, const std::string suffix, SharedMatrix val);

}
}
Expand Down
14 changes: 10 additions & 4 deletions psi4/src/psi4/cc/ccdensity/wfn_saver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void scalar_saver_excited(ccenergy::CCEnergyWavefunction& wfn, struct TD_Params
}
}

void array_saver_state(ccenergy::CCEnergyWavefunction& wfn, struct RHO_Params *S, const std::string suffix, SharedMatrix val) {
void density_saver(ccenergy::CCEnergyWavefunction& wfn, struct RHO_Params *S, const std::string suffix, SharedMatrix val) {
auto target_sym = moinfo.sym ^ S->R_irr;
auto idx_num = S->R_root + static_cast<int>(S->R_irr == 0);
auto total_idx = wfn.total_indices[{idx_num, target_sym}];
Expand All @@ -103,13 +103,19 @@ void array_saver_state(ccenergy::CCEnergyWavefunction& wfn, struct RHO_Params *S
} else {
throw PSIEXCEPTION("Unknown wfn type");
}

if (suffix != "Da" and suffix != "Db") {
throw PSIEXCEPTION("Unknown spin type.");
}
std::map<std::string, SharedMatrix>& density_map = (suffix == "Da") ? wfn.Da_map_ : wfn.Db_map_;

for (const auto name: names) {
auto varname = name + " ROOT " + std::to_string(idx_num) + " (" + moinfo.labels[target_sym] + ") " + suffix;
wfn.set_array_variable(varname, val);
density_map[varname] = val;
varname = name + " ROOT " + std::to_string(total_idx) + " " + suffix;
wfn.set_array_variable(varname, val);
density_map[varname] = val;
varname = name + " ROOT " + std::to_string(total_idx) + " " + suffix + " - " + trans_irr_lbl + " TRANSITION";
wfn.set_array_variable(varname, val);
density_map[varname] = val;
}
}

Expand Down
12 changes: 11 additions & 1 deletion psi4/src/psi4/libmints/wavefunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ class PSI_API Wavefunction : public std::enable_shared_from_this<Wavefunction> {
SharedMatrix Da_;
/// Beta density matrix
SharedMatrix Db_;

/// Lagrangian matrix
SharedMatrix Lagrangian_;

Expand Down Expand Up @@ -735,6 +734,17 @@ class PSI_API Wavefunction : public std::enable_shared_from_this<Wavefunction> {
/// Get PCM object
std::shared_ptr<PCM> get_PCM() const;
bool PCM_enabled() const { return PCM_enabled_; }

/// The below members are experimental and are designed to hold densities when the
/// "current density" is ambiguous, e.g., non-orbital optimized methods and multi-
/// stage methods. ~ JPM - Apr. '22
/// This is public because `ccdensity` doesn't subclass wfn like it should, so we need
/// SOME way to let it get/set.
/// Vector of alpha density matrices
std::map<std::string, SharedMatrix> Da_map_;
/// Vector of beta density matrices
std::map<std::string, SharedMatrix> Db_map_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if Da_map_ and Db_map_ become the long-term holders, should probably add some of the key.upper() features of variables and arrays, but that's for the beyond experimental stage.


};

} // namespace psi
Expand Down