Skip to content

Commit

Permalink
BUG FIXED: Passing wrong vector length to Band Lanczos. Also, include…
Browse files Browse the repository at this point in the history
…d core space determinants into the ASCI ranking (to allow for them to be substituted).
  • Loading branch information
CarlosMejZ committed Sep 11, 2023
1 parent a08ebf0 commit 5baea2e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
11 changes: 6 additions & 5 deletions include/macis/asci/determinant_search.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,12 +539,13 @@ std::vector<wfn_t<N>> asci_search(
// and keep only the duplicate with positive coefficient.
keep_only_largest_copy_asci_pairs(asci_pairs);

asci_pairs.erase(std::partition(asci_pairs.begin(), asci_pairs.end(),
[](const auto& p) { return p.rv < 0.0; }),
asci_pairs.end());
//asci_pairs.erase(std::partition(asci_pairs.begin(), asci_pairs.end(),
// [](const auto& p) { return p.rv < 0.0; }),
// asci_pairs.end());

// Only do top-K on (ndets_max - ncdets) b/c CDETS will be added later
const size_t top_k_elements = ndets_max - ncdets;
//const size_t top_k_elements = ndets_max - ncdets;
const size_t top_k_elements = ndets_max;

auto keep_large_en = clock_type::now();
duration_type keep_large_dur = keep_large_en - keep_large_st;
Expand Down Expand Up @@ -650,7 +651,7 @@ std::vector<wfn_t<N>> asci_search(
[](auto x) { return x.state; });

// Insert the CDETS back in
new_dets.insert(new_dets.end(), cdets_begin, cdets_end);
//new_dets.insert(new_dets.end(), cdets_begin, cdets_end);
new_dets.shrink_to_fit();

logger->info(" * New Dets Mem = {:.2e} GiB", to_gib(new_dets));
Expand Down
3 changes: 2 additions & 1 deletion include/macis/asci/grow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ auto asci_grow(ASCISettings asci_settings, MCSCFSettings mcscf_settings,
dur_t ai_dur = ai_en - ai_st;
logger->trace(" * ASCI_ITER_DUR = {:.2e} ms", ai_dur.count());
if(ndets_new > wfn.size())
throw std::runtime_error("Wavefunction didn't grow enough...");
logger->info("Wavefunction didn't grow enough...");
//throw std::runtime_error("Wavefunction didn't grow enough...");

logger->info(fmt_string, iter++, E, E - E0, wfn.size());
if(asci_settings.grow_with_rot and
Expand Down
1 change: 1 addition & 0 deletions include/macis/asci/iteration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ auto asci_iter(ASCISettings asci_settings, MCSCFSettings mcscf_settings,
X = std::move(X_local); // Serial
#endif

if(wfn.size() > 1) reorder_ci_on_coeff(wfn, X);
return std::make_tuple(E, wfn, X);
}

Expand Down
14 changes: 7 additions & 7 deletions include/macis/gf/bandlan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ void BandLan(const Functor &H, std::vector<Cont> &qs, std::vector<Cont> &bandH,
bandH[(it - 1) * nLanIts + it + nbands - 1];
true_indx[it + nbands] = next_indx;
if(std::abs(bandH[(it - 1) * nLanIts + it + nbands - 1]) < thres) {
std::cout
<< "BAND LANCZOS STOPPED PREMATURELY DUE TO SMALL NORM! NAMELY "
<< bandH[(it - 1) * nLanIts + it + nbands - 1]
<< ", STOPPED AT ITERATION: " << it << std::endl;
nLanIts = it;
bandH.resize(nLanIts * nLanIts);
break;
//std::cout
// << "BAND LANCZOS STOPPED PREMATURELY DUE TO SMALL NORM! NAMELY "
// << bandH[(it - 1) * nLanIts + it + nbands - 1]
// << ", STOPPED AT ITERATION: " << it << std::endl;
//nLanIts = it;
//bandH.resize(nLanIts * nLanIts);
//break;
blas::scal(N, 0., qs.data() + true_indx[it + nbands] * N, 1);
std::cout << "FOUND A ZERO VECTOR AT POSITION " << next_indx
<< std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/macis/gf/bandlan.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void BandResolvent(
std::cout << "BAND LANCZOS ...";
SparseMatrixOperator Hop(H);
int nbands = nvecs;
BandLan<double>(Hop, vecs, bandH, nLanIts, nbands, nvecs, 1.E-6, print);
BandLan<double>(Hop, vecs, bandH, nLanIts, nbands, len_vec, 1.E-6, print);
std::cout << "DONE! ";
if(print) {
std::ofstream ofile("BLH.dat", std::ios::out);
Expand Down
8 changes: 4 additions & 4 deletions tests/standalone_driver.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -347,15 +347,15 @@ int main(int argc, char** argv) {
OPT_KEYWORD("GF.SAVEGFMATS", gf_settings.saveGFmats, bool);
gf_settings.GF_orbs_basis = std::vector<int>(n_active, 0);
for(int i = 0; i < n_active; i++) gf_settings.GF_orbs_basis[i] = i;
gf_settings.GF_orbs_comp = std::vector<int>(2, 0);
for(int i = 0; i < 2; i++) gf_settings.GF_orbs_comp[i] = i;
gf_settings.GF_orbs_comp = std::vector<int>(n_active, 0);
for(int i = 0; i < n_active; i++) gf_settings.GF_orbs_comp[i] = i;
gf_settings.is_up_basis = std::vector<bool>(n_active, true);
gf_settings.is_up_comp = std::vector<bool>(2, true);
gf_settings.is_up_comp = std::vector<bool>(n_active, true);

// GF vector
std::vector<std::vector<std::complex<double>>> GF(
nws, std::vector<std::complex<double>>(
1, std::complex<double>(0., 0.)));
n_active * n_active, std::complex<double>(0., 0.)));

// Occupation numbers
std::vector<double> occs(n_active, 1.);
Expand Down

0 comments on commit 5baea2e

Please sign in to comment.