Skip to content

Commit

Permalink
cc2
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaypanyala committed Jul 28, 2023
1 parent fc2c651 commit 600709a
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 50 deletions.
5 changes: 4 additions & 1 deletion exachem/cc/cc2/cc2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ include(TargetMacros)

set(CC2_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/../exachem/cc/cc2)
set(CC2_SRCS
${CC2_SRCDIR}/cc2_canonical.cpp
${CC2_SRCDIR}/cd_cc2.cpp
${CC2_SRCDIR}/cd_cc2_cs.cpp
${CC2_SRCDIR}/cd_cc2_os.cpp
#${CC2_SRCDIR}/cc2_canonical.cpp
)

99 changes: 55 additions & 44 deletions exachem/cc/cc2/cc2_canonical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,49 +122,60 @@ void cc2_t2(Scheduler& sch, const TiledIndexSpace& MO, Tensor<T>& i0, const Tens

// clang-format off
sch.allocate(pp, hh, pphh, phhh, pphp, hphp, hphh, hhhh, hhhp)
(i0(a, b, i, j) = v2(a, b, i, j)) // V_(a, b, i, j) we follow <left out,right out || left in, right in> notation
(pp(b, c) = f1(b, c)) // +p(a/b)[f(b, c)+f(k, c)*t1(b, k)]*t2(a, c, i, j)
(pp(b, c) += f1(k, c) * t1(b, k))
(pphh(a, b, i, j) = pp(b, c) * t2(a, c, i, j))
(i0(a, b, i, j) += pphh(a, b, i, j))
(i0(a, b, i, j) += -1.0* pphh(b, a, i, j)) // p(a/b)
(hh(k, j) = f1(k, j)) // -p(i/j)[f(k, j)+ f(k, c)*t1(c, j)]*t2(a, b, i, k)
(hh(k, j) += f1(k, c) * t1(c, j))
(pphh(a, b, i, j) = hh(k, j) * t2(a, b, i, k))
(i0(a, b, i, j) += -1.0 * pphh(a, b, i, j))
(i0(a, b, i, j) += pphh(a, b, j, i))
(pphh(a, b, i, j) = v2(a, b, i, c) * t1(c, j))
(i0(a, b, i, j) += pphh(a, b, i, j) ) // p(i/j)v2(a, b, i, c)*t1(c, j))
(i0(a, b, i, j) += -1.0* pphh(a, b, j, i) )
(pphh(a, b, i, j) = v2(a, k, i, j) * t1(b, k))
(i0(a, b, i, j) += -1.0* pphh(a, b, i, j) ) // v2(a, k, i, j)&t1(b, k))
(i0(a, b, i, j) += pphh(b, a, i, j) ) // p(a/b)
(phhh(a, l, i, j) = v2(k, l, i, j) * t1(a, k)) // v2(k, l, i, j)*t1(a, k)*t1(b, l)
(i0(a, b, i, j) += phhh(a, l, i, j) * t1(b, l))
(pphp(a, b, i, d) = v2(a, b, c, d) * t1(c, i)) // v(a, b, c, d)*t1(c, i)*t1(d, j)
(i0(a, b, i, j) += pphp(a, b, i, d) * t1(d, j))
(phhh(a, k, i, j) = v2(a, k, i, c) * t1(c, j)) // -p(ij/ab) v2(a, k, i, c)*t1(c, j)*t1(b, k)
(pphh(a, b, i, j) = phhh(a, k, i, j) * t1(b, k))
(i0(a, b, i, j) += -1.0* pphh(a, b, i, j))
(i0(a, b, i, j) += 1.0* pphh(a, b, j, i)) // p(ij)
(i0(a, b, i, j) += 1.0* pphh(b, a, i, j)) // p(ab)
(i0(a, b, i, j) += -1.0* pphh(b, a, j, i)) // p(ij/ab)
(hphp(k, a, j, d) = v2(k, a, c, d) * t1(c, j)) //-p(ij/ab)v2(k, a, c, d)*t1(c, j)*t1(b, k)*t1(d, i)
(hphh(k, a, j, i) = hphp(k, a, j, d) * t1(d, i))
(pphh(a, b, i, j) = hphh(k, a, j, i) * t1(b, k))
(i0(a, b, i, j) += -1.0* pphh(a, b, i, j))
(i0(a, b, i, j) += 1.0* pphh(a, b, j, i))
(i0(a, b, i, j) += 1.0* pphh(b, a, i, j))
(i0(a, b, i, j) += -1.0* pphh(b, a, j, i))
(hhhh(k, l, i, j) = v2(k, l, c, j) * t1(c, i)) // p(ij)v2(k, l, c, j)*t1(c, i)*t1(a, k)*t1(b, l)
(phhh(a, l, i, j) = hhhh(k, l, i, j) * t1(a, k))
(pphh(a, b, i, j) = phhh(a, l, i, j) * t1(b, l))
(i0(a, b, i, j) += pphh(a, b, i, j))
(i0(a, b, i, j) += -1.0* pphh(a, b, j, i))
(hhhp(k, l, i, d) = v2(k, l, c, d) * t1(c, i)) // v2(k, l, c, d)*t1(c, i)*t1(d, j)*t1(a, k)*t1(b, l)
(hhhh(k, l, i, j) = hhhp(k, l, i, d) * t1(d, j))
(phhh(a, l, i, j) = hhhh(k, l, i, j) * t1(a, k))
(i0(a, b, i, j) += phhh(a, l, i, j) * t1(b, l))
// V_(a, b, i, j) we follow <left out,right out || left in, right in> notation
(i0(a, b, i, j) = v2(a, b, i, j))
(pphh(a, b, i, j) = f1(b, c) * t2(a, c, i, j))
// +p(a/b)[f(b, c)+f(k, c)*t1(b, k)]*t2(a, c, i, j)
(i0(a, b, i, j) += pphh(a, b, i, j))
(i0(a, b, i, j) +=-1.0* pphh(b, a, i, j))
(pp(b, c) = f1(k, c) * t1(b, k))
(pphh(a, b, i, j) = pp(b, c) * t2(a, c, i, j))
(i0(a, b, i, j) += -1.0* pphh(a, b, i, j))
(i0(a, b, i, j) += 1.0* pphh(b, a, i, j)) // p(a/b)
(pphh(a, b, i, j) = f1(k, j) * t2(a, b, i, k))
(i0(a, b, i, j) += -1.0* pphh(a, b, i, j))
// -p(i/j)[f(k, j)+ f(k, c)*t1(c, j)]*t2(a, b, i, k)
(i0(a, b, i, j) += 1.0* pphh(a, b, j, i))
(hh(k, j) = f1(k, c) * t1(c, j))
(pphh(a, b, i, j) = hh(k, j) * t2(a, b, i, k))
(i0(a, b, i, j) += -1.0 * pphh(a, b, i, j))
(i0(a, b, i, j) += pphh(a, b, j, i))
(pphh(a, b, i, j) = v2(a, b, i, c) * t1(c, j))
(i0(a, b, i, j) += pphh(a, b, i, j) ) // p(i/j)v2(a, b, i, c)*t1(c, j))
(i0(a, b, i, j) += -1.0* pphh(a, b, j, i) )
(pphh(a, b, i, j) = v2(a, k, i, j) * t1(b, k))
(i0(a, b, i, j) += -1.0* pphh(a, b, i, j) ) // v2(a, k, i, j)&t1(b, k))
(i0(a, b, i, j) += pphh(b, a, i, j) ) // p(a/b)
(phhh(a, l, i, j) = v2(k, l, i, j) * t1(a, k)) // v2(k, l, i, j)*t1(a, k)*t1(b, l)
(i0(a, b, i, j) += phhh(a, l, i, j) * t1(b, l))
(pphp(a, b, i, d) = v2(a, b, c, d) * t1(c, i))
// v(a, b, c, d)*t1(c, i)*t1(d, j)
(pphh(a, b, i, j) = pphp(a, b, i, d) * t1(d, j))
(i0(a, b, i, j) += pphh(a, b, i, j))
// -p(ij/ab) v2(a, k, i, c)*t1(c, j)*t1(b, k)
(phhh(a, k, i, j) = v2(a, k, i, c) * t1(c, j))
(pphh(a, b, i, j) = phhh(a, k, i, j) * t1(b, k))
(i0(a, b, i, j) += -1.0* pphh(a, b, i, j))
(i0(a, b, i, j) += 1.0* pphh(a, b, j, i)) // p(ij)
(i0(a, b, i, j) += 1.0* pphh(b, a, i, j)) // p(ab)
(i0(a, b, i, j) += -1.0* pphh(b, a, j, i)) // p(ij/ab)
//-p(ab)v2(k, a, c, d)*t1(c, j)*t1(b, k)*t1(d, i)
(hphp(k, a, j, d) = v2(k, a, c, d) * t1(c, j))
(hphh(k, a, j, i) = hphp(k, a, j, d) * t1(d, i))
(pphh(a, b, i, j) = hphh(k, a, j, i) * t1(b, k))
(i0(a, b, i, j) += -1.0* pphh(a, b, i, j))
(i0(a, b, i, j) += 1.0* pphh(b, a, i, j))
// p(ij)v2(k, l, c, j)*t1(c, i)*t1(a, k)*t1(b, l)
(hhhh(k, l, i, j) = v2(k, l, c, j) * t1(c, i))
(phhh(a, l, i, j) = hhhh(k, l, i, j) * t1(a, k))
(pphh(a, b, i, j) = phhh(a, l, i, j) * t1(b, l))
(i0(a, b, i, j) += pphh(a, b, i, j))
(i0(a, b, i, j) += -1.0* pphh(a, b, j, i))
// v2(k, l, c, d)*t1(c, i)*t1(d, j)*t1(a, k)*t1(b, l)
(hhhp(k, l, i, d) = v2(k, l, c, d) * t1(c, i))
(hhhh(k, l, i, j) = hhhp(k, l, i, d) * t1(d, j))
(phhh(a, l, i, j) = hhhh(k, l, i, j) * t1(a, k))
(i0(a, b, i, j) += phhh(a, l, i, j) * t1(b, l))
.deallocate(pp, hh, pphh, phhh, pphp, hphp, hphh, hhhh, hhhp);
// sch.execute();
// clang-format on
Expand Down Expand Up @@ -294,7 +305,7 @@ void cc2_canonical_driver(std::string filename, OptionsMap options_map) {
AO_tis, scf_conv] = hartree_fock_driver<T>(ec, filename, options_map);

CCSDOptions& ccsd_options = sys_data.options_map.ccsd_options;
bool debug = ccsd_options.debug;
auto debug = ccsd_options.debug;
if(rank == 0) ccsd_options.print();

if(rank == 0)
Expand Down
26 changes: 21 additions & 5 deletions methods/ExaChem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,25 @@ void rt_eom_cd_ccsd_driver(std::string filename, OptionsMap options_map);
#include "exachem/fci/fci.hpp"
#endif

void cc2_canonical_driver(std::string filename, OptionsMap options_map);
void cd_cc2_driver(std::string filename, OptionsMap options_map);
void ducc_driver(std::string filename, OptionsMap options_map);

int main(int argc, char* argv[]) {
tamm::initialize(argc, argv);

if(argc < 2) tamm_terminate("Please provide an input file!");

std::string filename = std::string(argv[1]);
std::string filename = fs::canonical(std::string(argv[1]));
std::ifstream testinput(filename);
if(!testinput) tamm_terminate("Input file provided [" + filename + "] does not exist!");

auto current_time = std::chrono::system_clock::now();
auto current_time_t = std::chrono::system_clock::to_time_t(current_time);
auto cur_local_time = localtime(&current_time_t);

const auto rank = ProcGroup::world_rank();
if(rank == 0) cout << endl << "Date: " << std::put_time(cur_local_time, "%c") << endl << endl;
const auto rank = ProcGroup::world_rank();
ProcGroup pg = ProcGroup::create_world_coll();
ExecutionContext ec{pg, DistributionKind::nw, MemoryManagerKind::ga};

// read geometry from a json file
json jinput;
Expand All @@ -48,6 +49,20 @@ int main(int argc, char* argv[]) {
if(options_map.options.output_file_prefix.empty())
options_map.options.output_file_prefix = getfilename(filename);

if(rank == 0) {
// TODO: tamm,ga,exachem git tags
cout << endl << "date: " << std::put_time(cur_local_time, "%c") << endl;
cout << "program: " << fs::canonical(argv[0]) << endl;
cout << "input: " << filename << endl;
cout << "nnodes: " << ec.nnodes() << ", ";
cout << "nproc: " << ec.nnodes() * ec.ppn() << endl;
cout << "prefix: " << options_map.options.output_file_prefix << endl << endl;
ec.print_mem_info();
cout << endl << endl;
cout << "Input file provided" << endl << std::string(20, '-') << endl;
std::cout << jinput.dump(2) << std::endl;
}

// if(rank == 0) {
// std::ofstream res_file(getfilename(filename)+".json");
// res_file << std::setw(2) << jinput << std::endl;
Expand All @@ -65,6 +80,7 @@ int main(int argc, char* argv[]) {
task.ccsd_lambda,
task.eom_ccsd,
task.fcidump,
task.rteom_cc2,
task.rteom_ccsd,
task.gfccsd,
task.dlpno_ccsd.first,
Expand All @@ -88,7 +104,7 @@ int main(int argc, char* argv[]) {
else if(task.cd_2e) cd_2e_driver(filename, options_map);
else if(task.ccsd) cd_ccsd(filename, options_map);
else if(task.ccsd_t) ccsd_t_driver(filename, options_map);
else if(task.cc2) cc2_canonical_driver(filename, options_map);
else if(task.cc2) cd_cc2_driver(filename, options_map);
else if(task.ccsd_lambda) ccsd_lambda_driver(filename, options_map);
else if(task.eom_ccsd) eom_ccsd_driver(filename, options_map);
else if(task.ducc) ducc_driver(filename, options_map);
Expand Down

0 comments on commit 600709a

Please sign in to comment.