Skip to content

Commit f249eee

Browse files
Started TREXIO wfn IO, not fully tested
1 parent a9a0208 commit f249eee

File tree

4 files changed

+44
-4
lines changed

4 files changed

+44
-4
lines changed

include/macis/asci/determinant_search.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ std::vector<wfn_t<N>> asci_search(
603603
dist_quickselect(scores.begin(), scores.end(), top_k_elements, comm,
604604
std::greater<double>{}, std::equal_to<double>{});
605605

606-
logger->info(" * Kth Score Pivot = {.2e}", kth_score);
606+
logger->info(" * Kth Score Pivot = {:.2e}", kth_score);
607607
// Partition local pairs into less / eq batches
608608
auto [g_begin, e_begin, l_begin, _end] = leg_partition(
609609
asci_pairs.begin(), asci_pairs.end(), kth_score,

include/macis/util/trexio.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@ class TREXIOFile {
3838
double read_nucleus_repulsion() const;
3939
void read_mo_1e_int_core_hamiltonian(double* h) const;
4040
void read_mo_2e_int_eri(double* V) const;
41+
int64_t read_determinant_num() const;
42+
int32_t get_determinant_int64_num() const;
43+
void read_determinant_list(int64_t ndet, int64_t* dets, int64_t ioff = 0) const;
4144

4245
void write_mo_num(int64_t nmo);
4346
void write_nucleus_repulsion(double E);
4447
void write_mo_1e_int_core_hamiltonian(const double* h);
4548
void write_mo_2e_int_eri(const double* V);
49+
void write_determinant_list(int64_t ndet, const int64_t* dets, int64_t ioff = 0);
4650

4751
};
4852

src/macis/trexio.cxx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,28 @@ void TREXIOFile::read_mo_2e_int_eri(double* V) const {
100100
}
101101

102102

103+
int64_t TREXIOFile::read_determinant_num() const {
104+
int64_t ndet;
105+
auto rc = trexio_read_determinant_num_64(file_handle_, &ndet);
106+
if(rc != TREXIO_SUCCESS) TREXIO_EXCEPTION(rc);
107+
return ndet;
108+
}
109+
110+
int32_t TREXIOFile::get_determinant_int64_num() const {
111+
int32_t n64;
112+
auto rc = trexio_get_int64_num(file_handle_, &n64);
113+
if(rc != TREXIO_SUCCESS) TREXIO_EXCEPTION(rc);
114+
return n64;
115+
}
116+
117+
void TREXIOFile::read_determinant_list(int64_t ndet, int64_t* dets, int64_t ioff) const {
118+
int64_t icount = ndet;
119+
auto rc = trexio_read_determinant_list(file_handle_, ioff, &icount, dets);
120+
if(rc != TREXIO_SUCCESS) TREXIO_EXCEPTION(rc);
121+
}
122+
123+
124+
103125

104126

105127

@@ -143,4 +165,10 @@ void TREXIOFile::write_mo_2e_int_eri(const double* V) {
143165
if(rc != TREXIO_SUCCESS) TREXIO_EXCEPTION(rc);
144166
}
145167

168+
void TREXIOFile::write_determinant_list(int64_t ndet, const int64_t* dets, int64_t ioff) {
169+
int64_t icount = ndet;
170+
auto rc = trexio_write_determinant_list(file_handle_, ioff, icount, dets);
171+
if(rc != TREXIO_SUCCESS) TREXIO_EXCEPTION(rc);
172+
}
173+
146174
}

tests/standalone_driver.cxx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ int main(int argc, char** argv) {
195195
macis::ASCISettings asci_settings;
196196
std::string asci_wfn_fname, asci_wfn_out_fname;
197197
double asci_E0 = 0.0;
198-
bool compute_asci_E0 = true;
198+
bool compute_asci_E0 = true, pt2 = true;
199199
OPT_KEYWORD("ASCI.NTDETS_MAX", asci_settings.ntdets_max, size_t);
200200
OPT_KEYWORD("ASCI.NTDETS_MIN", asci_settings.ntdets_min, size_t);
201201
OPT_KEYWORD("ASCI.NCDETS_MAX", asci_settings.ncdets_max, size_t);
@@ -216,6 +216,7 @@ int main(int argc, char** argv) {
216216
asci_E0 = input.getData<double>("ASCI.E0_WFN");
217217
compute_asci_E0 = false;
218218
}
219+
OPT_KEYWORD("ASCI.PT2", pt2, bool);
219220

220221
bool mp2_guess = false;
221222
OPT_KEYWORD("MCSCF.MP2_GUESS", mp2_guess, bool);
@@ -307,10 +308,8 @@ int main(int argc, char** argv) {
307308
std::vector<double> active_ordm(n_active * n_active);
308309
std::vector<double> active_trdm(active_ordm.size() * active_ordm.size());
309310

310-
bool pt2 = true;
311311
double E0 = 0;
312312
double EPT2 = 0;
313-
314313
// CI
315314
if(job == Job::CI) {
316315
using generator_t = macis::SortedDoubleLoopHamiltonianGenerator<wfn_type>;
@@ -401,7 +400,16 @@ int main(int argc, char** argv) {
401400

402401
if(asci_wfn_out_fname.size() and !world_rank) {
403402
console->info("Writing ASCI Wavefunction to {}", asci_wfn_out_fname);
403+
//if(reference_data_format == "TREXIO") {
404+
// console->info(" * Format TREXIO");
405+
// macis::TREXIOFile trexio_file(asci_wfn_out_fname, 'w', TREXIO_HDF5);
406+
// trexio_file.write_mo_num(nwfn_bits/2); // Trick TREXIO
407+
// trexio_file.write_determinant_list(dets.size(),
408+
// reinterpret_cast<int64_t*>(dets.data()));
409+
//} else {
410+
console->info(" * Format TEXT");
404411
macis::write_wavefunction(asci_wfn_out_fname, n_active, dets, C);
412+
//}
405413
}
406414

407415
// Dump Hamiltonian

0 commit comments

Comments
 (0)