diff --git a/prep/generate_casa.cc b/prep/generate_casa.cc new file mode 100644 index 0000000..2113b7f --- /dev/null +++ b/prep/generate_casa.cc @@ -0,0 +1,179 @@ +// +// SMITH3 - generates spin-free multireference electron correlation programs. +// Filename: main.cc +// Copyright (C) 2012 Toru Shiozaki +// +// Author: Toru Shiozaki +// Maintainer: Shiozaki group +// +// This file is part of the SMITH3 package. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "constants.h" +#include "tensor.h" +#include "diagram.h" +#include "equation.h" + +using namespace std; + +string theory = "CASA"; + +using namespace SMITH3::Prep; + +tuple>, vector>, vector>> create_proj() { + vector> lp, lt, ls, td; + array label = {{"c", "x", "a"}}; + + int cnt = 0; + for (auto& i : label) { + for (auto& j : label) { + for (auto& k : label) { + for (auto& l : label) { + // full CASPT2 + if ( + // all correct in this block + (l == "c" && k == "c" && j == "a" && i == "a") || // closed->virtual, closed->virtual + (l == "x" && k == "c" && j == "a" && i == "a") || // active->virtual, closed->virtual + (l == "x" && k == "x" && j == "a" && i == "a") || // active->virtual, active->virtual + (l == "c" && k == "c" && j == "x" && i == "a") || // closed->active, closed->virtual + (l == "c" && k == "c" && j == "x" && i == "x") || // closed->active, closed->active + (l == "x" && k == "c" && j == "x" && i == "x") || // active->active, closed->active + (l == "x" && k == "x" && j == "x" && i == "a") || // active->active, active->virtual + (l == "c" && k == "x" && j == "x" && i == "a") || (l == "x" && k == "c" && j == "x" && i == "a") // closed->active, active->virtual (or equiv) + ) { + stringstream ss; ss << cnt; + lp.push_back(shared_ptr(new Tensor(ss.str(), {l, k, j, i}))); + td.push_back(shared_ptr(new Tensor("t2dagger", ss.str(), {l, k, j, i}))); + lt.push_back(shared_ptr(new Tensor("t2", ss.str(), {j, i, l, k}))); + ++cnt; + } + } + } + } + } + + return tie(lp, lt, td); +}; + +int main() { + + // generate common header + cout << header() << endl; + + vector> proj_list, t_list, t_dagger; + tie(proj_list, t_list, t_dagger) = create_proj(); + + // make f and H tensors here + vector> f = {shared_ptr(new Tensor("f1", "0", {"c", "c"})), // closed, closed + shared_ptr(new Tensor("f1", "1", {"c", "x"})), // closed, active + shared_ptr(new Tensor("f1", "2", {"x", "c"})), // active, closed + shared_ptr(new Tensor("f1", "3", {"c", "a"})), // closed, virtual + shared_ptr(new Tensor("f1", "4", {"a", "c"})), // virtual, closed + shared_ptr(new Tensor("f1", "5", {"x", "a"})), // active, virtual + shared_ptr(new Tensor("f1", "6", {"a", "x"})), // virtual, active + shared_ptr(new Tensor("f1", "7", {"a", "a"})) // virtual, virtual + }; + + vector> hc = {shared_ptr(new Tensor("h1", "0", {"g", "g"}))}; + vector> H = {shared_ptr(new Tensor("v2", "0", {"g", "g", "g", "g"}))}; + vector> dum = {shared_ptr(new Tensor("proj", "e", {}))}; + vector> ex1b = {shared_ptr(new Tensor("1b", {"g", "g"}))}; + + vector> hca = {shared_ptr(new Tensor("h1", "1", {"x", "x"}))}; + vector> Ha = {shared_ptr(new Tensor("v2", "1", {"x", "x", "x", "x"}))}; + + cout << " string theory=\"" << theory << "\";" << endl; + cout << endl; + + for (auto& i : proj_list) cout << i->generate(); + for (auto& i : t_list) cout << i->generate(); + for (auto& i : f) cout << i->generate(); + for (auto& i : H) cout << i->generate(); + for (auto& i : hc) cout << i->generate(); + for (auto& i : dum) cout << i->generate(); + for (auto& i : t_dagger) cout << i->generate(); + for (auto& i : ex1b) cout << i->generate(); + for (auto& i : hca) cout << i->generate(); + for (auto& i : Ha) cout << i->generate(); + cout << endl; + + // residual equations // + // for all except active-active part + shared_ptr eq0(new Equation(theory, "ra", {dum, proj_list, f, t_list})); + + // For matching sectors: - * [E_L^(0) - E_N^(0)] due to the use of commutator to avoid 5RDM + // For unmatched sectors: - * E_L^(0), but these terms are zero so we can get away with just one constant "e0" + shared_ptr eq1(new Equation(theory, "rb", {dum, proj_list, t_list}, -1.0, "e0")); + eq0->merge(eq1); + + // for active part + shared_ptr eq0x(new Equation(theory, "rax", {dum, proj_list, hca, t_list})); + shared_ptr eq1x(new Equation(theory, "rbx", {dum, proj_list, Ha, t_list}, 0.5)); + eq0->merge(eq0x); + eq0->merge(eq1x); + + // - for matching sectors, to generate [F(A), T] (F(A) = H for active-active part, F for all others) + for (int i = 0; i != proj_list.size(); ++i) { + if (i == 3 || i == 4) continue; + stringstream ss, tt, uu; + ss << "rax_" << i; + tt << "rbx_" << i; + uu << "rcc_" << i; + shared_ptr eq0m(new Equation(theory, ss.str(), {dum, vector>{proj_list[i]}, vector>{t_list[i]}, hca}, -1.0)); + shared_ptr eq1m(new Equation(theory, tt.str(), {dum, vector>{proj_list[i]}, vector>{t_list[i]}, Ha}, -0.5)); + shared_ptr eq2m(new Equation(theory, uu.str(), {dum, vector>{proj_list[i]}, vector>{t_list[i]}, f}, -1.0)); + eq0->merge(eq0m); + eq0->merge(eq1m); + eq0->merge(eq2m); + } + shared_ptr eq0m(new Equation(theory, "rax_3", {dum, vector>{proj_list[3], proj_list[4]}, vector>{t_list[3], t_list[4]}, hca}, -1.0)); + shared_ptr eq1m(new Equation(theory, "rbx_3", {dum, vector>{proj_list[3], proj_list[4]}, vector>{t_list[3], t_list[4]}, Ha}, -0.5)); + shared_ptr eq2m(new Equation(theory, "rcc_3", {dum, vector>{proj_list[3], proj_list[4]}, vector>{t_list[3], t_list[4]}, f}, -1.0)); + eq0->merge(eq0m); + eq0->merge(eq1m); + eq0->merge(eq2m); + + eq0->set_tree_type("residual"); + cout << eq0->generate(); + + // energy equations // + // second order energy correction + // S = . will be added in bagel + shared_ptr eq3(new Equation(theory, "ec", {dum, proj_list, H}, 0.5)); + shared_ptr eq3a(new Equation(theory, "ed", {dum, proj_list, hc})); + eq3->merge(eq3a); + eq3->set_tree_type("residual", "source"); + cout << eq3->generate(); + + // done. generate the footer + cout << footer(eq0->tree_label(), eq3->tree_label()) << endl; + + return 0; +} + + diff --git a/prep/generate_main.cc b/prep/generate_main.cc index f9ad9ae..cb97ee5 100644 --- a/prep/generate_main.cc +++ b/prep/generate_main.cc @@ -42,7 +42,7 @@ using namespace std; //const string theory = "MP2"; -string theory = "CASPT2"; +string theory = "RelCASPT2"; using namespace SMITH3::Prep; @@ -57,7 +57,6 @@ tuple>, vector>, vector>, vector>, vector(new Tensor(ss.str(), {l, k, j, i}))); @@ -132,46 +130,15 @@ int main() { eq5->set_tree_type("residual", "norm"); cout << eq5->generate(); - // density matrix equations // - // one-body contribution d2 - shared_ptr eq6(new Equation(theory, "da", {dum, t_dagger, ex1b, t_list})); - eq6->set_tree_type("residual", "density"); + // source equations // + shared_ptr eq6(new Equation(theory, "sa", {dum, proj_list, hc})); + shared_ptr eq7(new Equation(theory, "sb", {dum, proj_list, H}, 0.5)); + eq6->merge(eq7); + eq6->set_tree_type("residual", "source"); cout << eq6->generate(); - // one-body contribution d1 - shared_ptr eq6a(new Equation(theory, "db", {dum, ex1b, t_list})); - eq6a->set_tree_type("residual", "density1"); - cout << eq6a->generate(); - - // two-body contribution D1 - shared_ptr eq7(new Equation(theory, "d2a", {dum, proj_list, t_list})); - eq7->set_tree_type("residual", "density2"); - cout << eq7->generate(); - - // cI derivative equations, dedci = dE/dcI // - // test hylleraas eqn: d/dc( <0|T^+fT|0> -e0<0|T^+T|0> +2<0|T^+h1|0> + 2<0|T^+V2|0>) => - // = 1/2(1/4 + 1/4<0|T^+fT|I>) - 1/2*(e0/4 + e0/4<0|T^+T|I>) + 2*1/2 (1/4 + 1/4<0|T^+V|I>) + 2*1/2 (1/4 + 1/4<0|T^+h1|I>) - // using bracket symmetry in some terms - shared_ptr eq4(new Equation(theory, "dedcia", {dum, t_dagger, f, t_list}, 2.0, make_pair(true, false))); -//shared_ptr eq4a(new Equation(theory, "dedcib", {dum, t_dagger, f, t_list}, 1.0, make_pair(false, true))); - shared_ptr eq4b(new Equation(theory, "dedcic", {dum, t_dagger, t_list}, -2.0, "e0", make_pair(true, false))); -//shared_ptr eq4c(new Equation(theory, "dedcid", {dum, t_dagger, t_list}, -1.0, "e0", make_pair(false, true))); - shared_ptr eq4d(new Equation(theory, "dedcie", {dum, t_dagger, H}, 1.0, make_pair(true, false))); - shared_ptr eq4e(new Equation(theory, "dedcif", {dum, t_dagger, H}, 1.0, make_pair(false, true))); - shared_ptr eq4f(new Equation(theory, "dedcig", {dum, t_dagger, hc}, 2.0, make_pair(true, false))); - shared_ptr eq4g(new Equation(theory, "dedcih", {dum, t_dagger, hc}, 2.0, make_pair(false, true))); -//eq4->merge(eq4a); - eq4->merge(eq4b); -//eq4->merge(eq4c); - eq4->merge(eq4d); - eq4->merge(eq4e); - eq4->merge(eq4f); - eq4->merge(eq4g); - eq4->set_tree_type("residual", "deci"); - cout << eq4->generate(); // done. generate the footer - cout << footer(eq0->tree_label(), eq3->tree_label(), eq5->tree_label(), eq6->tree_label(), eq6a->tree_label(), eq7->tree_label(), eq4->tree_label()) << endl; - + cout << footer(eq0->tree_label(), eq3->tree_label(), eq5->tree_label(), "", "", "", "", "", "", "", eq6->tree_label(), "") << endl; return 0; } diff --git a/prep/generate_relcasa.cc b/prep/generate_relcasa.cc new file mode 100644 index 0000000..888e1d0 --- /dev/null +++ b/prep/generate_relcasa.cc @@ -0,0 +1,179 @@ +// +// SMITH3 - generates spin-free multireference electron correlation programs. +// Filename: main.cc +// Copyright (C) 2012 Toru Shiozaki +// +// Author: Toru Shiozaki +// Maintainer: Shiozaki group +// +// This file is part of the SMITH3 package. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "constants.h" +#include "tensor.h" +#include "diagram.h" +#include "equation.h" + +using namespace std; + +string theory = "RelCASA"; + +using namespace SMITH3::Prep; + +tuple>, vector>, vector>> create_proj() { + vector> lp, lt, ls, td; + array label = {{"c", "x", "a"}}; + + int cnt = 0; + for (auto& i : label) { + for (auto& j : label) { + for (auto& k : label) { + for (auto& l : label) { + // full CASPT2 + if ( + // all correct in this block + (l == "c" && k == "c" && j == "a" && i == "a") || // closed->virtual, closed->virtual + (l == "x" && k == "c" && j == "a" && i == "a") || // active->virtual, closed->virtual + (l == "x" && k == "x" && j == "a" && i == "a") || // active->virtual, active->virtual + (l == "c" && k == "c" && j == "x" && i == "a") || // closed->active, closed->virtual + (l == "c" && k == "c" && j == "x" && i == "x") || // closed->active, closed->active + (l == "x" && k == "c" && j == "x" && i == "x") || // active->active, closed->active + (l == "x" && k == "x" && j == "x" && i == "a") || // active->active, active->virtual + (l == "c" && k == "x" && j == "x" && i == "a") || (l == "x" && k == "c" && j == "x" && i == "a") // closed->active, active->virtual (or equiv) + ) { + stringstream ss; ss << cnt; + lp.push_back(shared_ptr(new Tensor(ss.str(), {l, k, j, i}))); + td.push_back(shared_ptr(new Tensor("t2dagger", ss.str(), {l, k, j, i}))); + lt.push_back(shared_ptr(new Tensor("t2", ss.str(), {j, i, l, k}))); + ++cnt; + } + } + } + } + } + + return tie(lp, lt, td); +}; + +int main() { + + // generate common header + cout << header() << endl; + + vector> proj_list, t_list, t_dagger; + tie(proj_list, t_list, t_dagger) = create_proj(); + + // make f and H tensors here + vector> f = {shared_ptr(new Tensor("f1", "0", {"c", "c"})), // closed, closed + shared_ptr(new Tensor("f1", "1", {"c", "x"})), // closed, active + shared_ptr(new Tensor("f1", "2", {"x", "c"})), // active, closed + shared_ptr(new Tensor("f1", "3", {"c", "a"})), // closed, virtual + shared_ptr(new Tensor("f1", "4", {"a", "c"})), // virtual, closed + shared_ptr(new Tensor("f1", "5", {"x", "a"})), // active, virtual + shared_ptr(new Tensor("f1", "6", {"a", "x"})), // virtual, active + shared_ptr(new Tensor("f1", "7", {"a", "a"})) // virtual, virtual + }; + + vector> hc = {shared_ptr(new Tensor("h1", "0", {"g", "g"}))}; + vector> H = {shared_ptr(new Tensor("v2", "0", {"g", "g", "g", "g"}))}; + vector> dum = {shared_ptr(new Tensor("proj", "e", {}))}; + vector> ex1b = {shared_ptr(new Tensor("1b", {"g", "g"}))}; + + vector> hca = {shared_ptr(new Tensor("h1", "1", {"x", "x"}))}; + vector> Ha = {shared_ptr(new Tensor("v2", "1", {"x", "x", "x", "x"}))}; + + cout << " string theory=\"" << theory << "\";" << endl; + cout << endl; + + for (auto& i : proj_list) cout << i->generate(); + for (auto& i : t_list) cout << i->generate(); + for (auto& i : f) cout << i->generate(); + for (auto& i : H) cout << i->generate(); + for (auto& i : hc) cout << i->generate(); + for (auto& i : dum) cout << i->generate(); + for (auto& i : t_dagger) cout << i->generate(); + for (auto& i : ex1b) cout << i->generate(); + for (auto& i : hca) cout << i->generate(); + for (auto& i : Ha) cout << i->generate(); + cout << endl; + + // residual equations // + // for all except active-active part + shared_ptr eq0(new Equation(theory, "ra", {dum, proj_list, f, t_list})); + + // For matching sectors: - * [E_L^(0) - E_N^(0)] due to the use of commutator to avoid 5RDM + // For unmatched sectors: - * E_L^(0), but these terms are zero so we can get away with just one constant "e0" + shared_ptr eq1(new Equation(theory, "rb", {dum, proj_list, t_list}, -1.0, "e0")); + eq0->merge(eq1); + + // for active part + shared_ptr eq0x(new Equation(theory, "rax", {dum, proj_list, hca, t_list})); + shared_ptr eq1x(new Equation(theory, "rbx", {dum, proj_list, Ha, t_list}, 0.5)); + eq0->merge(eq0x); + eq0->merge(eq1x); + + // - for matching sectors, to generate [F(A), T] (F(A) = H for active-active part, F for all others) + for (int i = 0; i != proj_list.size(); ++i) { + if (i == 3 || i == 4) continue; + stringstream ss, tt, uu; + ss << "rax_" << i; + tt << "rbx_" << i; + uu << "rcc_" << i; + shared_ptr eq0m(new Equation(theory, ss.str(), {dum, vector>{proj_list[i]}, vector>{t_list[i]}, hca}, -1.0)); + shared_ptr eq1m(new Equation(theory, tt.str(), {dum, vector>{proj_list[i]}, vector>{t_list[i]}, Ha}, -0.5)); + shared_ptr eq2m(new Equation(theory, uu.str(), {dum, vector>{proj_list[i]}, vector>{t_list[i]}, f}, -1.0)); + eq0->merge(eq0m); + eq0->merge(eq1m); + eq0->merge(eq2m); + } + shared_ptr eq0m(new Equation(theory, "rax_3", {dum, vector>{proj_list[3], proj_list[4]}, vector>{t_list[3], t_list[4]}, hca}, -1.0)); + shared_ptr eq1m(new Equation(theory, "rbx_3", {dum, vector>{proj_list[3], proj_list[4]}, vector>{t_list[3], t_list[4]}, Ha}, -0.5)); + shared_ptr eq2m(new Equation(theory, "rcc_3", {dum, vector>{proj_list[3], proj_list[4]}, vector>{t_list[3], t_list[4]}, f}, -1.0)); + eq0->merge(eq0m); + eq0->merge(eq1m); + eq0->merge(eq2m); + + eq0->set_tree_type("residual"); + cout << eq0->generate(); + + // energy equations // + // second order energy correction + // S = . will be added in bagel + shared_ptr eq3(new Equation(theory, "ec", {dum, proj_list, H}, 0.5)); + shared_ptr eq3a(new Equation(theory, "ed", {dum, proj_list, hc})); + eq3->merge(eq3a); + eq3->set_tree_type("residual", "source"); + cout << eq3->generate(); + + // done. generate the footer + cout << footer(eq0->tree_label(), eq3->tree_label(), "") << endl; + + return 0; +} + + diff --git a/prep/generate_relcaspt2.cc b/prep/generate_relcaspt2.cc index e54a699..19b25bd 100644 --- a/prep/generate_relcaspt2.cc +++ b/prep/generate_relcaspt2.cc @@ -116,10 +116,12 @@ int main() { eq0->set_tree_type("residual"); cout << eq0->generate(); - // source equations // - shared_ptr eq3(new Equation(theory, "sb", {dum, proj_list, H}, 0.5)); - shared_ptr eq4(new Equation(theory, "sa", {dum, proj_list, hc})); - eq3->merge(eq4); + // energy equations // + // second order energy correction + // S = . will be added in bagel + shared_ptr eq3(new Equation(theory, "ec", {dum, proj_list, H}, 0.5)); + shared_ptr eq3a(new Equation(theory, "ed", {dum, proj_list, hc})); + eq3->merge(eq3a); eq3->set_tree_type("residual", "source"); cout << eq3->generate(); diff --git a/python/casa/gamma.py b/python/casa/gamma.py new file mode 100755 index 0000000..5159f59 --- /dev/null +++ b/python/casa/gamma.py @@ -0,0 +1,18 @@ +#!/usr/bin/python +import string +import os + +f = open('CASA_gamma.cc', 'r') +lines = f.read().split("\n") +f.close() + +os.remove("CASA_gamma.cc") + +f = open('CASA_gamma.cc', 'w') +f.write("\n".join(lines[:25])) +add1 = "\n#include \n#ifdef COMPILE_SMITH\n" +f.write(add1) +f.write("\n".join(lines[25:])) +add2 = "#endif\n" +f.write(add2) + diff --git a/python/casa/gen_split.py b/python/casa/gen_split.py new file mode 100755 index 0000000..fe95d02 --- /dev/null +++ b/python/casa/gen_split.py @@ -0,0 +1,82 @@ +#!/usr/bin/python +import string +import os + + +def header(n) : + return "//\n\ +// BAGEL - Brilliantly Advanced General Electronic Structure Library\n\ +// Filename: CASA_gen" + str(n) + ".cc\n\ +// Copyright (C) 2014 Toru Shiozaki\n\ +//\n\ +// Author: Toru Shiozaki \n\ +// Maintainer: Shiozaki group\n\ +//\n\ +// This file is part of the BAGEL package.\n\ +//\n\ +// This program is free software: you can redistribute it and/or modify\n\ +// it under the terms of the GNU General Public License as published by\n\ +// the Free Software Foundation, either version 3 of the License, or\n\ +// (at your option) any later version.\n\ +//\n\ +// This program is distributed in the hope that it will be useful,\n\ +// but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ +// GNU General Public License for more details.\n\ +//\n\ +// You should have received a copy of the GNU General Public License\n\ +// along with this program. If not, see .\n\ +//\n\ +\n\ +#include \n\ +#ifdef COMPILE_SMITH\n\ +\n\ +#include \n\ +\n\ +using namespace std;\n\ +using namespace bagel;\n\ +using namespace bagel::SMITH;\n\ +using namespace bagel::SMITH::CASA;\n\ +\n\ +" + +footer = "#endif\n" + +f = open('CASA_gen.cc', 'r') +lines = f.read().split("\n")[32:] + +tasks = [] +tmp = "" + +for line in lines: + if (line[0:4] == "Task"): + if (tmp != ""): + tasks.append(tmp) + tmp = "" + if (line != ""): + tmp += line + "\n" + if (line == "}"): + tmp += "\n" +tasks.append(tmp) + +tmp = "" +num = 0 +chunk = 50 +for i in range(len(tasks)): + if (num != 0 and num % chunk == 0): + n = num / chunk + fout = open("CASA_gen" + str(n) + ".cc", "w") + out = header(n) + tmp + footer + fout.write(out) + fout.close() + tmp = "" + num = num+1 + tmp = tmp + tasks[i]; + +n = (num-1) / chunk + 1 +fout = open("CASA_gen" + str(n) + ".cc", "w") +out = header(n) + tmp + footer +fout.write(out) +fout.close() + +os.remove("CASA_gen.cc") diff --git a/python/casa/header_split.py b/python/casa/header_split.py new file mode 100755 index 0000000..adf879e --- /dev/null +++ b/python/casa/header_split.py @@ -0,0 +1,131 @@ +#!/usr/bin/python +import string +import os + +def header(n) : + return "//\n\ +// BAGEL - Brilliantly Advanced General Electronic Structure Library\n\ +// Filename: CASA_tasks" + str(n) + ".h\n\ +// Copyright (C) 2014 Toru Shiozaki\n\ +//\n\ +// Author: Toru Shiozaki \n\ +// Maintainer: Shiozaki group\n\ +//\n\ +// This file is part of the BAGEL package.\n\ +//\n\ +// This program is free software: you can redistribute it and/or modify\n\ +// it under the terms of the GNU General Public License as published by\n\ +// the Free Software Foundation, either version 3 of the License, or\n\ +// (at your option) any later version.\n\ +//\n\ +// This program is distributed in the hope that it will be useful,\n\ +// but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ +// GNU General Public License for more details.\n\ +//\n\ +// You should have received a copy of the GNU General Public License\n\ +// along with this program. If not, see .\n\ +//\n\ +\n\ +#include \n\ +#ifdef COMPILE_SMITH\n\ +\n\ +#ifndef __SRC_SMITH_CASA_TASKS" + str(n) + "_H\n\ +#define __SRC_SMITH_CASA_TASKS" + str(n) + "_H\n\ +\n\ +#include \n\ +#include \n\ +#include \n\ +#include \n\ +#include \n\ +\n\ +namespace bagel {\n\ +namespace SMITH {\n\ +namespace CASA{\n\ +\n" + +footer = "\n}\n}\n}\n\ +#endif\n\ +#endif\n\ +\n" + + +header2 = "//\n\ +// BAGEL - Brilliantly Advanced General Electronic Structure Library\n\ +// Filename: CASA_tasks.h\n\ +// Copyright (C) 2014 Toru Shiozaki\n\ +//\n\ +// Author: Toru Shiozaki \n\ +// Maintainer: Shiozaki group\n\ +//\n\ +// This file is part of the BAGEL package.\n\ +//\n\ +// This program is free software: you can redistribute it and/or modify\n\ +// it under the terms of the GNU General Public License as published by\n\ +// the Free Software Foundation, either version 3 of the License, or\n\ +// (at your option) any later version.\n\ +//\n\ +// This program is distributed in the hope that it will be useful,\n\ +// but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ +// GNU General Public License for more details.\n\ +//\n\ +// You should have received a copy of the GNU General Public License\n\ +// along with this program. If not, see .\n\ +//\n\ +\n\ +#include \n\ +#ifdef COMPILE_SMITH\n\ +\n\ +#ifndef __SRC_SMITH_CASA_TASKS_H\n\ +#define __SRC_SMITH_CASA_TASKS_H\n\ +\n" + +footer2 = "\n#endif\n#endif\n\n" + +f = open('CASA_tasks.h', 'r') +lines = f.read().split("\n")[38:][:-6] + +tasks = [] +tmp = "" + +for line in lines: + if (len(line) >= 10 and line[0:10] == "class Task"): + if (tmp != ""): + tasks.append(tmp) + tmp = "" + if (line != ""): + tmp += line + "\n" + if (len(line) >= 2 and line == "};"): + tmp += "\n" +tasks.append(tmp) + +tmp = "" +num = 0 +chunk = 50 +for i in range(len(tasks)): + if (num != 0 and num % chunk == 0): + n = num / chunk + fout = open("CASA_tasks" + str(n) + ".h", "w") + out = header(n) + tmp + footer + fout.write(out) + fout.close() + tmp = "" + num = num+1 + tmp = tmp + tasks[i]; + +n = (num-1) / chunk + 1 +fout = open("CASA_tasks" + str(n) + ".h", "w") +out = header(n) + tmp + footer +fout.write(out) +fout.close() + +os.remove("CASA_tasks.h") +fout = open("CASA_tasks.h", "w") +out = header2 +for i in range(n+1): + if (i > 0): + out += "#include \n" +out += footer2 +fout.write(out) +fout.close() diff --git a/python/casa/make.sh b/python/casa/make.sh new file mode 100755 index 0000000..b79f8c3 --- /dev/null +++ b/python/casa/make.sh @@ -0,0 +1,11 @@ +#!/bin/sh +make -j +./prep/Prep > ../src/main.cc +make -j +rm -f CASA* +./SMITH3 +./header_split.py +./tasks_split.py +./gen_split.py +./queue_split.py +./gamma.py diff --git a/python/casa/queue_split.py b/python/casa/queue_split.py new file mode 100755 index 0000000..73f2694 --- /dev/null +++ b/python/casa/queue_split.py @@ -0,0 +1,80 @@ +#!/usr/bin/python +import string +import os +import re + + +def header(n) : + return "//\n\ +// BAGEL - Brilliantly Advanced General Electronic Structure Library\n\ +// Filename: CASA" + n + ".cc\n\ +// Copyright (C) 2014 Toru Shiozaki\n\ +//\n\ +// Author: Toru Shiozaki \n\ +// Maintainer: Shiozaki group\n\ +//\n\ +// This file is part of the BAGEL package.\n\ +//\n\ +// This program is free software: you can redistribute it and/or modify\n\ +// it under the terms of the GNU General Public License as published by\n\ +// the Free Software Foundation, either version 3 of the License, or\n\ +// (at your option) any later version.\n\ +//\n\ +// This program is distributed in the hope that it will be useful,\n\ +// but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ +// GNU General Public License for more details.\n\ +//\n\ +// You should have received a copy of the GNU General Public License\n\ +// along with this program. If not, see .\n\ +//\n\ +\n\ +#include \n\ +#ifdef COMPILE_SMITH\n\ +\n\ +\n\ +#include \n" + +def insert(): + return "#include \n" + +def header2(): + return "\n\ +using namespace std;\n\ +using namespace bagel;\n\ +using namespace bagel::SMITH;\n\ +\n\ +" + +footer = "#endif\n" + +f = open('CASA.cc', 'r') +lines = f.read().split("\n")[34:] + +tasks = [] +tmp = "" + +for line in lines: + if (len(line) >= 17 and (line[0:17] == "shared_ptr" or line[0:15] == "CASA::CASA::CAS")): + if (tmp != ""): + tasks.append(tmp) + tmp = "" + tmp += line + "\n" + if (line == "}"): + tmp += "\n" +tasks.append(tmp) + +p = re.compile('make_[a-z0-9]+q') +for task in tasks[0:-1]: + tag = p.search(task).group()[5:] + fout = open("CASA_" + tag + ".cc", "w") + out = header("_" + tag + "q") + insert() + header2() + task + footer + fout.write(out) + fout.close() + +os.remove("CASA.cc") + +fout = open("CASA.cc", "w") +out = header("") + header2() + tasks[len(tasks)-1] + footer +fout.write(out) +fout.close() diff --git a/python/casa/tasks_split.py b/python/casa/tasks_split.py new file mode 100755 index 0000000..9eb0e89 --- /dev/null +++ b/python/casa/tasks_split.py @@ -0,0 +1,85 @@ +#!/usr/bin/python +import string +import os +import re + + +def header(n) : + return "//\n\ +// BAGEL - Brilliantly Advanced General Electronic Structure Library\n\ +// Filename: CASA_tasks" + str(n) + ".cc\n\ +// Copyright (C) 2014 Toru Shiozaki\n\ +//\n\ +// Author: Toru Shiozaki \n\ +// Maintainer: Shiozaki group\n\ +//\n\ +// This file is part of the BAGEL package.\n\ +//\n\ +// This program is free software: you can redistribute it and/or modify\n\ +// it under the terms of the GNU General Public License as published by\n\ +// the Free Software Foundation, either version 3 of the License, or\n\ +// (at your option) any later version.\n\ +//\n\ +// This program is distributed in the hope that it will be useful,\n\ +// but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ +// GNU General Public License for more details.\n\ +//\n\ +// You should have received a copy of the GNU General Public License\n\ +// along with this program. If not, see .\n\ +//\n\ +\n\ +#include \n\ +#ifdef COMPILE_SMITH\n\ +\n\ +#include \n\ +\n\ +using namespace std;\n\ +using namespace bagel;\n\ +using namespace bagel::SMITH;\n\ +using namespace bagel::SMITH::CASA;\n\ +\n\ +" + +footer = "#endif\n" + +f = open('CASA_tasks.cc', 'r') +lines = f.read().split("\n")[32:] + +tasks = [] +tmp = "" + +for line in lines: + if (len(line) >= 9 and line[0:9] == "void Task"): + if (tmp != ""): + tasks.append(tmp) + tmp = "" + if (line != ""): + tmp += line + "\n" + if (line == "}"): + tmp += "\n" +tasks.append(tmp) + +p = re.compile('[0-9]+') +tmp = "" +num = 0 +chunk = 50 +n = 1 +for task in tasks: + num = int(p.search(task).group()) + if (num != 0 and num >= n*chunk): + fout = open("CASA_tasks" + str(n) + ".cc", "w") + out = header(n) + tmp + footer + fout.write(out) + fout.close() + tmp = "" + n = n+1 + tmp = tmp + task; + +n = (num-1) / chunk + 1 +fout = open("CASA_tasks" + str(n) + ".cc", "w") +out = header(n) + tmp + footer +fout.write(out) +fout.close() + +os.remove("CASA_tasks.cc") diff --git a/python/relcasa/gamma.py b/python/relcasa/gamma.py new file mode 100755 index 0000000..3fa1afe --- /dev/null +++ b/python/relcasa/gamma.py @@ -0,0 +1,18 @@ +#!/usr/bin/python +import string +import os + +f = open('RelCASA_gamma.cc', 'r') +lines = f.read().split("\n") +f.close() + +os.remove("RelCASA_gamma.cc") + +f = open('RelCASA_gamma.cc', 'w') +f.write("\n".join(lines[:25])) +add1 = "\n#include \n#ifdef COMPILE_SMITH\n" +f.write(add1) +f.write("\n".join(lines[25:])) +add2 = "#endif\n" +f.write(add2) + diff --git a/python/relcasa/gen_split.py b/python/relcasa/gen_split.py new file mode 100755 index 0000000..98e244c --- /dev/null +++ b/python/relcasa/gen_split.py @@ -0,0 +1,82 @@ +#!/usr/bin/python +import string +import os + + +def header(n) : + return "//\n\ +// BAGEL - Brilliantly Advanced General Electronic Structure Library\n\ +// Filename: RelCASA_gen" + str(n) + ".cc\n\ +// Copyright (C) 2014 Toru Shiozaki\n\ +//\n\ +// Author: Toru Shiozaki \n\ +// Maintainer: Shiozaki group\n\ +//\n\ +// This file is part of the BAGEL package.\n\ +//\n\ +// This program is free software: you can redistribute it and/or modify\n\ +// it under the terms of the GNU General Public License as published by\n\ +// the Free Software Foundation, either version 3 of the License, or\n\ +// (at your option) any later version.\n\ +//\n\ +// This program is distributed in the hope that it will be useful,\n\ +// but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ +// GNU General Public License for more details.\n\ +//\n\ +// You should have received a copy of the GNU General Public License\n\ +// along with this program. If not, see .\n\ +//\n\ +\n\ +#include \n\ +#ifdef COMPILE_SMITH\n\ +\n\ +#include \n\ +\n\ +using namespace std;\n\ +using namespace bagel;\n\ +using namespace bagel::SMITH;\n\ +using namespace bagel::SMITH::RelCASA;\n\ +\n\ +" + +footer = "#endif\n" + +f = open('RelCASA_gen.cc', 'r') +lines = f.read().split("\n")[32:] + +tasks = [] +tmp = "" + +for line in lines: + if (line[0:4] == "Task"): + if (tmp != ""): + tasks.append(tmp) + tmp = "" + if (line != ""): + tmp += line + "\n" + if (line == "}"): + tmp += "\n" +tasks.append(tmp) + +tmp = "" +num = 0 +chunk = 50 +for i in range(len(tasks)): + if (num != 0 and num % chunk == 0): + n = num / chunk + fout = open("RelCASA_gen" + str(n) + ".cc", "w") + out = header(n) + tmp + footer + fout.write(out) + fout.close() + tmp = "" + num = num+1 + tmp = tmp + tasks[i]; + +n = (num-1) / chunk + 1 +fout = open("RelCASA_gen" + str(n) + ".cc", "w") +out = header(n) + tmp + footer +fout.write(out) +fout.close() + +os.remove("RelCASA_gen.cc") diff --git a/python/relcasa/header_split.py b/python/relcasa/header_split.py new file mode 100755 index 0000000..5f96287 --- /dev/null +++ b/python/relcasa/header_split.py @@ -0,0 +1,131 @@ +#!/usr/bin/python +import string +import os + +def header(n) : + return "//\n\ +// BAGEL - Brilliantly Advanced General Electronic Structure Library\n\ +// Filename: RelCASA_tasks" + str(n) + ".h\n\ +// Copyright (C) 2014 Toru Shiozaki\n\ +//\n\ +// Author: Toru Shiozaki \n\ +// Maintainer: Shiozaki group\n\ +//\n\ +// This file is part of the BAGEL package.\n\ +//\n\ +// This program is free software: you can redistribute it and/or modify\n\ +// it under the terms of the GNU General Public License as published by\n\ +// the Free Software Foundation, either version 3 of the License, or\n\ +// (at your option) any later version.\n\ +//\n\ +// This program is distributed in the hope that it will be useful,\n\ +// but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ +// GNU General Public License for more details.\n\ +//\n\ +// You should have received a copy of the GNU General Public License\n\ +// along with this program. If not, see .\n\ +//\n\ +\n\ +#include \n\ +#ifdef COMPILE_SMITH\n\ +\n\ +#ifndef __SRC_SMITH_RelCASA_TASKS" + str(n) + "_H\n\ +#define __SRC_SMITH_RelCASA_TASKS" + str(n) + "_H\n\ +\n\ +#include \n\ +#include \n\ +#include \n\ +#include \n\ +#include \n\ +\n\ +namespace bagel {\n\ +namespace SMITH {\n\ +namespace RelCASA{\n\ +\n" + +footer = "\n}\n}\n}\n\ +#endif\n\ +#endif\n\ +\n" + + +header2 = "//\n\ +// BAGEL - Brilliantly Advanced General Electronic Structure Library\n\ +// Filename: RelCASA_tasks.h\n\ +// Copyright (C) 2014 Toru Shiozaki\n\ +//\n\ +// Author: Toru Shiozaki \n\ +// Maintainer: Shiozaki group\n\ +//\n\ +// This file is part of the BAGEL package.\n\ +//\n\ +// This program is free software: you can redistribute it and/or modify\n\ +// it under the terms of the GNU General Public License as published by\n\ +// the Free Software Foundation, either version 3 of the License, or\n\ +// (at your option) any later version.\n\ +//\n\ +// This program is distributed in the hope that it will be useful,\n\ +// but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ +// GNU General Public License for more details.\n\ +//\n\ +// You should have received a copy of the GNU General Public License\n\ +// along with this program. If not, see .\n\ +//\n\ +\n\ +#include \n\ +#ifdef COMPILE_SMITH\n\ +\n\ +#ifndef __SRC_SMITH_RelCASA_TASKS_H\n\ +#define __SRC_SMITH_RelCASA_TASKS_H\n\ +\n" + +footer2 = "\n#endif\n#endif\n\n" + +f = open('RelCASA_tasks.h', 'r') +lines = f.read().split("\n")[38:][:-6] + +tasks = [] +tmp = "" + +for line in lines: + if (len(line) >= 10 and line[0:10] == "class Task"): + if (tmp != ""): + tasks.append(tmp) + tmp = "" + if (line != ""): + tmp += line + "\n" + if (len(line) >= 2 and line == "};"): + tmp += "\n" +tasks.append(tmp) + +tmp = "" +num = 0 +chunk = 50 +for i in range(len(tasks)): + if (num != 0 and num % chunk == 0): + n = num / chunk + fout = open("RelCASA_tasks" + str(n) + ".h", "w") + out = header(n) + tmp + footer + fout.write(out) + fout.close() + tmp = "" + num = num+1 + tmp = tmp + tasks[i]; + +n = (num-1) / chunk + 1 +fout = open("RelCASA_tasks" + str(n) + ".h", "w") +out = header(n) + tmp + footer +fout.write(out) +fout.close() + +os.remove("RelCASA_tasks.h") +fout = open("RelCASA_tasks.h", "w") +out = header2 +for i in range(n+1): + if (i > 0): + out += "#include \n" +out += footer2 +fout.write(out) +fout.close() diff --git a/python/relcasa/make.sh b/python/relcasa/make.sh new file mode 100755 index 0000000..63c6c62 --- /dev/null +++ b/python/relcasa/make.sh @@ -0,0 +1,11 @@ +#!/bin/sh +make -j +./prep/Prep > ../src/main.cc +make -j +rm -f RelCASA* +./SMITH3 +./header_split.py +./tasks_split.py +./gen_split.py +./queue_split.py +./gamma.py diff --git a/python/relcasa/queue_split.py b/python/relcasa/queue_split.py new file mode 100755 index 0000000..2cec97c --- /dev/null +++ b/python/relcasa/queue_split.py @@ -0,0 +1,80 @@ +#!/usr/bin/python +import string +import os +import re + + +def header(n) : + return "//\n\ +// BAGEL - Brilliantly Advanced General Electronic Structure Library\n\ +// Filename: RelCASA" + n + ".cc\n\ +// Copyright (C) 2014 Toru Shiozaki\n\ +//\n\ +// Author: Toru Shiozaki \n\ +// Maintainer: Shiozaki group\n\ +//\n\ +// This file is part of the BAGEL package.\n\ +//\n\ +// This program is free software: you can redistribute it and/or modify\n\ +// it under the terms of the GNU General Public License as published by\n\ +// the Free Software Foundation, either version 3 of the License, or\n\ +// (at your option) any later version.\n\ +//\n\ +// This program is distributed in the hope that it will be useful,\n\ +// but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ +// GNU General Public License for more details.\n\ +//\n\ +// You should have received a copy of the GNU General Public License\n\ +// along with this program. If not, see .\n\ +//\n\ +\n\ +#include \n\ +#ifdef COMPILE_SMITH\n\ +\n\ +\n\ +#include \n" + +def insert(): + return "#include \n" + +def header2(): + return "\n\ +using namespace std;\n\ +using namespace bagel;\n\ +using namespace bagel::SMITH;\n\ +\n\ +" + +footer = "#endif\n" + +f = open('RelCASA.cc', 'r') +lines = f.read().split("\n")[34:] + +tasks = [] +tmp = "" + +for line in lines: + if (len(line) >= 17 and (line[0:17] == "shared_ptr" or line[0:17] == "RelCASA::RelCASA:")): + if (tmp != ""): + tasks.append(tmp) + tmp = "" + tmp += line + "\n" + if (line == "}"): + tmp += "\n" +tasks.append(tmp) + +p = re.compile('make_[a-z0-9]+q') +for task in tasks[0:-1]: + tag = p.search(task).group()[5:] + fout = open("RelCASA_" + tag + ".cc", "w") + out = header("_" + tag + "q") + insert() + header2() + task + footer + fout.write(out) + fout.close() + +os.remove("RelCASA.cc") + +fout = open("RelCASA.cc", "w") +out = header("") + header2() + tasks[len(tasks)-1] + footer +fout.write(out) +fout.close() diff --git a/python/relcasa/tasks_split.py b/python/relcasa/tasks_split.py new file mode 100755 index 0000000..7a0ba1d --- /dev/null +++ b/python/relcasa/tasks_split.py @@ -0,0 +1,85 @@ +#!/usr/bin/python +import string +import os +import re + + +def header(n) : + return "//\n\ +// BAGEL - Brilliantly Advanced General Electronic Structure Library\n\ +// Filename: RelCASA_tasks" + str(n) + ".cc\n\ +// Copyright (C) 2014 Toru Shiozaki\n\ +//\n\ +// Author: Toru Shiozaki \n\ +// Maintainer: Shiozaki group\n\ +//\n\ +// This file is part of the BAGEL package.\n\ +//\n\ +// This program is free software: you can redistribute it and/or modify\n\ +// it under the terms of the GNU General Public License as published by\n\ +// the Free Software Foundation, either version 3 of the License, or\n\ +// (at your option) any later version.\n\ +//\n\ +// This program is distributed in the hope that it will be useful,\n\ +// but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ +// GNU General Public License for more details.\n\ +//\n\ +// You should have received a copy of the GNU General Public License\n\ +// along with this program. If not, see .\n\ +//\n\ +\n\ +#include \n\ +#ifdef COMPILE_SMITH\n\ +\n\ +#include \n\ +\n\ +using namespace std;\n\ +using namespace bagel;\n\ +using namespace bagel::SMITH;\n\ +using namespace bagel::SMITH::RelCASA;\n\ +\n\ +" + +footer = "#endif\n" + +f = open('RelCASA_tasks.cc', 'r') +lines = f.read().split("\n")[32:] + +tasks = [] +tmp = "" + +for line in lines: + if (len(line) >= 9 and line[0:9] == "void Task"): + if (tmp != ""): + tasks.append(tmp) + tmp = "" + if (line != ""): + tmp += line + "\n" + if (line == "}"): + tmp += "\n" +tasks.append(tmp) + +p = re.compile('[0-9]+') +tmp = "" +num = 0 +chunk = 50 +n = 1 +for task in tasks: + num = int(p.search(task).group()) + if (num != 0 and num >= n*chunk): + fout = open("RelCASA_tasks" + str(n) + ".cc", "w") + out = header(n) + tmp + footer + fout.write(out) + fout.close() + tmp = "" + n = n+1 + tmp = tmp + task; + +n = (num-1) / chunk + 1 +fout = open("RelCASA_tasks" + str(n) + ".cc", "w") +out = header(n) + tmp + footer +fout.write(out) +fout.close() + +os.remove("RelCASA_tasks.cc") diff --git a/python/relcaspt2/gamma.py b/python/relcaspt2/gamma.py index 7d6fbb2..70b7f05 100755 --- a/python/relcaspt2/gamma.py +++ b/python/relcaspt2/gamma.py @@ -1,4 +1,4 @@ -#!/opt/local/bin/python +#!/usr/bin/python import string import os diff --git a/python/relcaspt2/gen_split.py b/python/relcaspt2/gen_split.py index bfa32c0..9aacb6d 100755 --- a/python/relcaspt2/gen_split.py +++ b/python/relcaspt2/gen_split.py @@ -1,4 +1,4 @@ -#!/opt/local/bin/python +#!/usr/bin/python import string import os diff --git a/python/relcaspt2/header_split.py b/python/relcaspt2/header_split.py index 3670b92..2f47b5d 100755 --- a/python/relcaspt2/header_split.py +++ b/python/relcaspt2/header_split.py @@ -1,4 +1,4 @@ -#!/opt/local/bin/python +#!/usr/bin/python import string import os diff --git a/python/relcaspt2/queue_split.py b/python/relcaspt2/queue_split.py index 24ca03a..c69ea7e 100755 --- a/python/relcaspt2/queue_split.py +++ b/python/relcaspt2/queue_split.py @@ -1,4 +1,4 @@ -#!/opt/local/bin/python +#!/usr/bin/python import string import os import re diff --git a/python/relcaspt2/tasks_split.py b/python/relcaspt2/tasks_split.py index 0cb4cd4..a5acc4e 100755 --- a/python/relcaspt2/tasks_split.py +++ b/python/relcaspt2/tasks_split.py @@ -1,4 +1,4 @@ -#!/opt/local/bin/python +#!/usr/bin/python import string import os import re diff --git a/src/constants.h b/src/constants.h index 3c1038b..1caea43 100644 --- a/src/constants.h +++ b/src/constants.h @@ -148,14 +148,16 @@ int count_distinct_tensors__(const std::vector& labels) { return out; } -#define _CASPT2 -#define _MULTI_DERIV +//#define _CASPT2 +//#define _CAS_A +//#define _MULTI_DERIV //#define _MRCI //#define _RELCASPT2 +#define _RELCAS_A //#define _RELMRCI -#if defined(_CASPT2) || defined(_MRCI) +#if defined(_CASPT2) || defined(_MRCI) || defined(_CAS_A) static const std::string DataType = "double"; -#elif defined(_RELCASPT2) || defined(_RELMRCI) +#elif defined(_RELCASPT2) || defined(_RELMRCI) || defined(_RELCAS_A) static const std::string DataType = "std::complex"; #else static_assert(false, "Please compile using make.sh"); diff --git a/src/diagram.cc b/src/diagram.cc index 954afa3..c16602a 100644 --- a/src/diagram.cc +++ b/src/diagram.cc @@ -258,7 +258,7 @@ bool Diagram::reduce_one_noactive(const int skip) { // all possible contraction pattern taken for *j (returned as a list). if (cnt + (*j)->num_nodagger() > skip) { tuple,shared_ptr> tmp = (*j)->contract(data, skip-cnt); - if ((closed && (*data.first)->label() == "c") || (!closed && (*data.first)->label() == "a")) { + if (((closed && (*data.first)->label() == "c") || (!closed && (*data.first)->label() == "a")) && get<0>(tmp) != 0.0) { fac_ *= get<0>(tmp); newspin = get<1>(tmp); oldspin = get<2>(tmp); diff --git a/src/forest.cc b/src/forest.cc index 4a06250..232ddf8 100644 --- a/src/forest.cc +++ b/src/forest.cc @@ -296,7 +296,7 @@ OutStream Forest::generate_algorithm() const { out.ee << " nall_.push_back(tmp2->copy());" << endl; out.ee << " }" << endl; } - if (forest_name_ == "CASPT2" || forest_name_ == "RelCASPT2") { + if (forest_name_ == "CASPT2" || forest_name_ == "RelCASPT2" || forest_name_ == "CASA" || forest_name_ == "RelCASA") { out.ee << " t2 = init_amplitude();" << endl; out.ee << " r = init_residual();" << endl; out.ee << " s = init_residual();" << endl; @@ -310,7 +310,7 @@ OutStream Forest::generate_algorithm() const { out.ee << "void " << forest_name_ << "::" << forest_name_ << "::solve() {" << endl; - if (forest_name_ == "CASPT2" || forest_name_ == "RelCASPT2") + if (forest_name_ == "CASPT2" || forest_name_ == "RelCASPT2" || forest_name_ == "CASA" || forest_name_ == "RelCASA") out.ee << caspt2_main_driver_(); else if (forest_name_ == "MRCI" || forest_name_ == "RelMRCI") out.ee << msmrci_main_driver_();