diff --git a/.gitignore b/.gitignore index b0eb208..ad9836b 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ Release/ cmake-build-debug/ cmake-build-release/ build/ +ebuild/ debug* build* .xlsx diff --git a/ci/reference_output/ch4.def2-tzvp.ccsd_t.json b/ci/reference_output/ch4.def2-tzvp.ccsd_t.json index 552e0b8..14ff9db 100644 --- a/ci/reference_output/ch4.def2-tzvp.ccsd_t.json +++ b/ci/reference_output/ch4.def2-tzvp.ccsd_t.json @@ -450,7 +450,6 @@ "convd": 1e-06, "diis_hist": 20, "AO_tilesize": 30, - "force_tilesize": "false", "scf_type": "unrestricted", "multiplicity": 3, "lambdas": [], diff --git a/ci/reference_output/co.cc-pvdz.gfccsd.json b/ci/reference_output/co.cc-pvdz.gfccsd.json index 665f334..120c625 100644 --- a/ci/reference_output/co.cc-pvdz.gfccsd.json +++ b/ci/reference_output/co.cc-pvdz.gfccsd.json @@ -507,7 +507,6 @@ "convd": 1e-11, "diis_hist": 10, "AO_tilesize": 30, - "force_tilesize": "false", "damp": 100, "debug": "false", "restart": "false", @@ -535,7 +534,6 @@ "CCSD": { "threshold": 1e-06, "tilesize": 40, - "force_tilesize": "false", "lshift": 0.0, "ndiis": 5, "readt": "false", diff --git a/ci/reference_output/cr2.def2-svp.scf.json b/ci/reference_output/cr2.def2-svp.scf.json index 6efd19f..9ed60c9 100644 --- a/ci/reference_output/cr2.def2-svp.scf.json +++ b/ci/reference_output/cr2.def2-svp.scf.json @@ -306,7 +306,6 @@ "convd": 1e-07, "diis_hist": 10, "AO_tilesize": 30, - "force_tilesize": "false", "damp": 100, "debug": "false", "restart": "false", diff --git a/ci/reference_output/h2o_ducc.cc-pvdz.ducc.json b/ci/reference_output/h2o_ducc.cc-pvdz.ducc.json index c30d0ed..8f3b8d2 100644 --- a/ci/reference_output/h2o_ducc.cc-pvdz.ducc.json +++ b/ci/reference_output/h2o_ducc.cc-pvdz.ducc.json @@ -249,7 +249,6 @@ "convd": 1e-08, "diis_hist": 10, "AO_tilesize": 30, - "force_tilesize": "false", "scf_type": "restricted", "multiplicity": 1, "lambdas": [], diff --git a/ci/reference_output/h2o_eom.cc-pvdz.eomccsd.json b/ci/reference_output/h2o_eom.cc-pvdz.eomccsd.json index 8792ece..17842d8 100644 --- a/ci/reference_output/h2o_eom.cc-pvdz.eomccsd.json +++ b/ci/reference_output/h2o_eom.cc-pvdz.eomccsd.json @@ -611,7 +611,6 @@ "convd": 1e-08, "diis_hist": 10, "AO_tilesize": 30, - "force_tilesize": "false", "scf_type": "restricted", "multiplicity": 1, "lambdas": [], diff --git a/ci/reference_output/ozone.sto-3g.rt-eomccsd.json b/ci/reference_output/ozone.sto-3g.rt-eomccsd.json index 589c5f7..32aff2f 100644 --- a/ci/reference_output/ozone.sto-3g.rt-eomccsd.json +++ b/ci/reference_output/ozone.sto-3g.rt-eomccsd.json @@ -116,7 +116,6 @@ "convd": 0.1, "diis_hist": 10, "AO_tilesize": 30, - "force_tilesize": "false", "scf_type": "unrestricted", "multiplicity": 2 }, diff --git a/ci/reference_output/ubiquitin_dgrtl/ubiquitin_dgrtl.6-31g.ccsd_t.json b/ci/reference_output/ubiquitin_dgrtl/ubiquitin_dgrtl.6-31g.ccsd_t.json index cd2d5ac..51569d6 100644 --- a/ci/reference_output/ubiquitin_dgrtl/ubiquitin_dgrtl.6-31g.ccsd_t.json +++ b/ci/reference_output/ubiquitin_dgrtl/ubiquitin_dgrtl.6-31g.ccsd_t.json @@ -303,7 +303,6 @@ "convd": 1e-07, "diis_hist": 12, "AO_tilesize": 30, - "force_tilesize": "false", "scf_type": "restricted", "multiplicity": 1, "lambdas": [], diff --git a/ci/reference_output/ubiquitin_dgrtl/ubiquitin_dgrtl.cc-pvdz.ccsd_t.json b/ci/reference_output/ubiquitin_dgrtl/ubiquitin_dgrtl.cc-pvdz.ccsd_t.json index 57e2f9b..d67a719 100644 --- a/ci/reference_output/ubiquitin_dgrtl/ubiquitin_dgrtl.cc-pvdz.ccsd_t.json +++ b/ci/reference_output/ubiquitin_dgrtl/ubiquitin_dgrtl.cc-pvdz.ccsd_t.json @@ -295,7 +295,6 @@ "convd": 1e-07, "diis_hist": 12, "AO_tilesize": 37, - "force_tilesize": "false", "scf_type": "restricted", "multiplicity": 1, "lambdas": [], diff --git a/ci/reference_output/ubiquitin_dgrtl/ubiquitin_dgrtl.sto-3g.ccsd_t.json b/ci/reference_output/ubiquitin_dgrtl/ubiquitin_dgrtl.sto-3g.ccsd_t.json index 8dd7387..f4a19ef 100644 --- a/ci/reference_output/ubiquitin_dgrtl/ubiquitin_dgrtl.sto-3g.ccsd_t.json +++ b/ci/reference_output/ubiquitin_dgrtl/ubiquitin_dgrtl.sto-3g.ccsd_t.json @@ -435,7 +435,6 @@ "convd": 1e-09, "diis_hist": 12, "AO_tilesize": 30, - "force_tilesize": "false", "scf_type": "restricted", "multiplicity": 1 }, diff --git a/ci/reference_output/uracil.cc-pvdz.ccsd_t.json b/ci/reference_output/uracil.cc-pvdz.ccsd_t.json index da12468..0860cea 100644 --- a/ci/reference_output/uracil.cc-pvdz.ccsd_t.json +++ b/ci/reference_output/uracil.cc-pvdz.ccsd_t.json @@ -320,7 +320,6 @@ "convd": 1e-7, "diis_hist": 10, "AO_tilesize": 30, - "force_tilesize": "false", "scf_type": "restricted", "multiplicity": 1 }, diff --git a/docs/schema/input_schema.json b/docs/schema/input_schema.json index e3982e1..7c40fe3 100644 --- a/docs/schema/input_schema.json +++ b/docs/schema/input_schema.json @@ -93,9 +93,6 @@ "diis_hist": { "type": "number" }, - "force_tilesize": { - "type": "boolean" - }, "tilesize": { "type": "number" }, @@ -287,9 +284,6 @@ "threshold": { "type": "number" }, - "force_tilesize": { - "type": "boolean" - }, "tilesize": { "type": "number" }, diff --git a/docs/user_guide/basic_options.rst b/docs/user_guide/basic_options.rst index 12a3c95..a1b146d 100644 --- a/docs/user_guide/basic_options.rst +++ b/docs/user_guide/basic_options.rst @@ -52,7 +52,7 @@ Some common options supported are as follows: :file_prefix: A string indicating the prefix for the name of the workspace folder where the results of a run are stored. It also forms the prefix for the files written to the workspace folder. The *default prefix* is the name of the input file without the *.json* extension. -:output_dir: A string indicating the path to the directory where the where the results of a run are stored. If not provided, the default is the current working directory. +:output_dir: A string indicating the path to an existing directory where the where the results of a run are stored. If not provided, the default is the current working directory. .. _Basis: diff --git a/docs/user_guide/coupledcluster.rst b/docs/user_guide/coupledcluster.rst index 44affe9..e30f2c6 100644 --- a/docs/user_guide/coupledcluster.rst +++ b/docs/user_guide/coupledcluster.rst @@ -19,7 +19,6 @@ The following CCSD options are supported. The remaining CC methods (CC2, Lambda, "CC": { "threshold": 1e-6, - "force_tilesize": false, "tilesize": 50, "lshift": 0, "ndiis": 5, @@ -45,11 +44,14 @@ The following CCSD options are supported. The remaining CC methods (CC2, Lambda, } } + :threshold: ``[default=1e-6]`` Specifies the convergence threshold of iterative solutions of amplitude equations. The threshold refers to the norm of residual, namely, the deviation from the amplitude equations. -:force_tilesize: ``[default=false]`` +:tilesize: ``[default=40]`` The tilesize for the MO or MSO space. An integer value that is automatically set unless specified explicitly by the user. It is recommended to let the CC module determine this value automatically. + + .. warning:: -:tilesize: ``[default=40]`` The tilesize for the MO or MSO space. An integer value that is automatically set. If **force_tilesize=true**, the value specified by the user is respected. It is recommended to let the CC module automatically determine this value. + The automatically determined tilesize may vary depending on node count and the number of processes per node. When restarting a calculation with different node counts, the user is expected to explicitly set the tilesize to match the value used in the initial run. :lshift: ``[default=0]`` The level shift option that increases small orbital energy differences used in calculating the updates for cluster amplitudes. When calculating ground states with multi-configurational character or if convergence is slow, one may need to specify a typical values for lshift between 0.3 and 0.5. diff --git a/docs/user_guide/scf.rst b/docs/user_guide/scf.rst index 60730a7..0d52ab0 100644 --- a/docs/user_guide/scf.rst +++ b/docs/user_guide/scf.rst @@ -28,7 +28,6 @@ The values listed below are the defaults where few options are automatically adj "conve": 1e-8, "convd": 1e-7, "diis_hist": 10, - "force_tilesize": false, "tilesize": 30, "damp": 100, "nnodes": 1, @@ -97,10 +96,8 @@ The values listed below are the defaults where few options are automatically adj :diis_hist: ``[default=10]`` Specifies the number of DIIS history entries to store for the fock and error matrices. -:force_tilesize: ``[default=false]`` - -:tilesize: The tilesize for the AO dimension. An integer value that is automatically set to ``ceil(Nbf * 0.05)``. If **force_tilesize=true**, - the value specified by the user is respected. It is recommended to let the SCF module automatically determine this value. +:tilesize: The tilesize for the AO dimension. An integer value that is automatically set to ``ceil(Nbf * 0.05)`` + if the user has not explicitly set it. It is recommended to let the SCF module automatically determine this value. :damp: damping (mixing) factor for the density matrix where :math:`0 \leq \alpha \leq 100`. Specifies the percentage of the current iterations density mixed with the previous iterations density. ``default=100`` indicates no damping. diff --git a/exachem/cc/cc2/cc2_canonical.cpp b/exachem/cc/cc2/cc2_canonical.cpp index b31228f..55091ec 100644 --- a/exachem/cc/cc2/cc2_canonical.cpp +++ b/exachem/cc/cc2/cc2_canonical.cpp @@ -281,7 +281,7 @@ cc2_v2_driver(ChemEnv& chem_env, ExecutionContext& ec, const TiledIndexSpace& MO } chem_env.cc_context.cc2_correlation_energy = energy; - chem_env.cc_context.cc2_total_energy = chem_env.hf_energy + energy; + chem_env.cc_context.cc2_total_energy = chem_env.scf_context.hf_energy + energy; if(ec.pg().rank() == 0) { sys_data.results["output"]["CC2"]["n_iterations"] = niter + 1; @@ -304,15 +304,15 @@ void cc2_canonical_driver(ExecutionContext& ec, ChemEnv& chem_env) { scf(ec, chem_env); - double hf_energy = chem_env.hf_energy; + double hf_energy = chem_env.scf_context.hf_energy; libint2::BasisSet shells = chem_env.shells; - Tensor C_AO = chem_env.C_AO; - Tensor C_beta_AO = chem_env.C_beta_AO; - Tensor F_AO = chem_env.F_AO; - Tensor F_beta_AO = chem_env.F_beta_AO; - TiledIndexSpace AO_opt = chem_env.AO_opt; - std::vector shell_tile_map = chem_env.shell_tile_map; - bool scf_conv = chem_env.no_scf; + Tensor C_AO = chem_env.scf_context.C_AO; + Tensor C_beta_AO = chem_env.scf_context.C_beta_AO; + Tensor F_AO = chem_env.scf_context.F_AO; + Tensor F_beta_AO = chem_env.scf_context.F_beta_AO; + TiledIndexSpace AO_opt = chem_env.is_context.AO_opt; + std::vector shell_tile_map = chem_env.scf_context.shell_tile_map; + bool scf_conv = chem_env.scf_context.no_scf; SystemData& sys_data = chem_env.sys_data; CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; diff --git a/exachem/cc/cc2/cd_cc2.cpp b/exachem/cc/cc2/cd_cc2.cpp index b55b38c..75bf6c8 100644 --- a/exachem/cc/cc2/cd_cc2.cpp +++ b/exachem/cc/cc2/cd_cc2.cpp @@ -13,58 +13,37 @@ namespace fs = std::filesystem; namespace exachem::cc2 { void cd_cc2_driver(ExecutionContext& ec, ChemEnv& chem_env) { - using T = double; - + using T = double; auto rank = ec.pg().rank(); - scf::scf_driver(ec, chem_env); - - double hf_energy = chem_env.hf_energy; - libint2::BasisSet shells = chem_env.shells; - Tensor C_AO = chem_env.C_AO; - Tensor C_beta_AO = chem_env.C_beta_AO; - Tensor F_AO = chem_env.F_AO; - Tensor F_beta_AO = chem_env.F_beta_AO; - TiledIndexSpace AO_opt = chem_env.AO_opt; - TiledIndexSpace AO_tis = chem_env.AO_tis; - std::vector shell_tile_map = chem_env.shell_tile_map; - bool scf_conv = chem_env.no_scf; - - SystemData sys_data = chem_env.sys_data; - CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; - auto debug = ccsd_options.debug; - if(rank == 0) ccsd_options.print(); + cholesky_2e::cholesky_2e_driver(ec, chem_env); - if(rank == 0) - cout << endl << "#occupied, #virtual = " << sys_data.nocc << ", " << sys_data.nvir << endl; + const bool is_rhf = chem_env.sys_data.is_restricted; - auto [MO, total_orbitals] = cholesky_2e::setupMOIS(ec, chem_env); + std::string files_prefix = chem_env.get_files_prefix(); - std::string out_fp = chem_env.workspace_dir; - std::string files_dir = out_fp + chem_env.ioptions.scf_options.scf_type + "/cc2"; - std::string files_prefix = /*out_fp;*/ files_dir + "/" + sys_data.output_file_prefix; - std::string f1file = files_prefix + ".f1_mo"; - std::string t1file = files_prefix + ".t1amp"; - std::string t2file = files_prefix + ".t2amp"; - std::string v2file = files_prefix + ".cholv2"; - std::string cholfile = files_prefix + ".cholcount"; - std::string ccsdstatus = files_prefix + ".ccsdstatus"; - - const bool is_rhf = sys_data.is_restricted; + CDContext& cd_context = chem_env.cd_context; + CCContext& cc_context = chem_env.cc_context; + cc_context.init_filenames(files_prefix); + CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; - bool ccsd_restart = ccsd_options.readt || ((fs::exists(t1file) && fs::exists(t2file) && - fs::exists(f1file) && fs::exists(v2file))); + auto debug = ccsd_options.debug; + bool scf_conv = chem_env.scf_context.no_scf; + std::string t1file = cc_context.t1file; + std::string t2file = cc_context.t2file; + const std::string ccsdstatus = cc_context.ccsdstatus; - // deallocates F_AO, C_AO - auto [cholVpr, d_f1, lcao, chol_count, max_cvecs, CI] = - exachem::cholesky_2e::cholesky_2e_driver(chem_env, ec, MO, AO_opt, C_AO, F_AO, C_beta_AO, - F_beta_AO, shells, shell_tile_map, ccsd_restart, - cholfile); - free_tensors(lcao); + bool ccsd_restart = ccsd_options.readt || + ((fs::exists(t1file) && fs::exists(t2file) && fs::exists(cd_context.f1file) && + fs::exists(cd_context.v2file))); if(ccsd_options.writev) ccsd_options.writet = true; - TiledIndexSpace N = MO("all"); + TiledIndexSpace& MO = chem_env.is_context.MSO; + TiledIndexSpace& CI = chem_env.is_context.CI; + TiledIndexSpace N = MO("all"); + Tensor d_f1 = chem_env.cd_context.d_f1; + Tensor cholVpr = chem_env.cd_context.cholV2; std::vector p_evl_sorted; Tensor d_r1, d_r2, d_t1, d_t2; @@ -78,31 +57,13 @@ void cd_cc2_driver(ExecutionContext& ec, ChemEnv& chem_env) { ec, MO, d_f1, ccsd_options.ndiis, ccsd_restart && fs::exists(ccsdstatus) && scf_conv); if(ccsd_restart) { - read_from_disk(d_f1, f1file); if(fs::exists(t1file) && fs::exists(t2file)) { read_from_disk(d_t1, t1file); read_from_disk(d_t2, t2file); } - read_from_disk(cholVpr, v2file); - ec.pg().barrier(); p_evl_sorted = tamm::diagonal(d_f1); } - else if(ccsd_options.writet) { - // fs::remove_all(files_dir); - if(!fs::exists(files_dir)) fs::create_directories(files_dir); - - write_to_disk(d_f1, f1file); - write_to_disk(cholVpr, v2file); - - if(rank == 0) { - std::ofstream out(cholfile, std::ios::out); - if(!out) cerr << "Error opening file " << cholfile << endl; - out << chol_count << std::endl; - out.close(); - } - } - if(rank == 0 && debug) { print_vector(p_evl_sorted, files_prefix + ".eigen_values.txt"); cout << "Eigen values written to file: " << files_prefix + ".eigen_values.txt" << endl << endl; @@ -114,7 +75,7 @@ void cd_cc2_driver(ExecutionContext& ec, ChemEnv& chem_env) { ccsd_restart = ccsd_restart && fs::exists(ccsdstatus) && scf_conv; - std::string fullV2file = files_prefix + ".fullV2"; + std::string fullV2file = cd_context.fullV2file; t1file = files_prefix + ".fullT1amp"; t2file = files_prefix + ".fullT2amp"; @@ -145,7 +106,7 @@ void cd_cc2_driver(ExecutionContext& ec, ChemEnv& chem_env) { } } - ccsd_stats(ec, hf_energy, residual, corr_energy, ccsd_options.threshold); + ccsd_stats(ec, chem_env.scf_context.hf_energy, residual, corr_energy, ccsd_options.threshold); if(ccsd_options.writet && !fs::exists(ccsdstatus)) { // write_to_disk(d_t1,t1file); diff --git a/exachem/cc/cc2/cd_cc2_cs.cpp b/exachem/cc/cc2/cd_cc2_cs.cpp index 94790ed..9fcce7f 100644 --- a/exachem/cc/cc2/cd_cc2_cs.cpp +++ b/exachem/cc/cc2/cd_cc2_cs.cpp @@ -537,7 +537,7 @@ std::tuple cc2_cs::cd_cc2_cs_driver( } chem_env.cc_context.cc2_correlation_energy = energy; - chem_env.cc_context.cc2_total_energy = chem_env.hf_energy + energy; + chem_env.cc_context.cc2_total_energy = chem_env.scf_context.hf_energy + energy; if(ec.pg().rank() == 0) { sys_data.results["output"]["CC2"]["n_iterations"] = niter + 1; diff --git a/exachem/cc/cc2/cd_cc2_os.cpp b/exachem/cc/cc2/cd_cc2_os.cpp index 002642a..d706315 100644 --- a/exachem/cc/cc2/cd_cc2_os.cpp +++ b/exachem/cc/cc2/cd_cc2_os.cpp @@ -719,7 +719,7 @@ std::tuple cc2_os::cd_cc2_os_driver( } chem_env.cc_context.cc2_correlation_energy = energy; - chem_env.cc_context.cc2_total_energy = chem_env.hf_energy + energy; + chem_env.cc_context.cc2_total_energy = chem_env.scf_context.hf_energy + energy; if(ec.pg().rank() == 0) { sys_data.results["output"]["CC2"]["n_iterations"] = niter + 1; diff --git a/exachem/cc/ccsd/cd_ccsd.cpp b/exachem/cc/ccsd/cd_ccsd.cpp index 1d3f225..ff25934 100644 --- a/exachem/cc/ccsd/cd_ccsd.cpp +++ b/exachem/cc/ccsd/cd_ccsd.cpp @@ -14,58 +14,37 @@ namespace fs = std::filesystem; void exachem::cc::ccsd::cd_ccsd(ExecutionContext& ec, ChemEnv& chem_env) { - using T = double; - + using T = double; auto rank = ec.pg().rank(); - scf::scf_driver(ec, chem_env); - - double hf_energy = chem_env.hf_energy; - libint2::BasisSet shells = chem_env.shells; - Tensor C_AO = chem_env.C_AO; - Tensor C_beta_AO = chem_env.C_beta_AO; - Tensor F_AO = chem_env.F_AO; - Tensor F_beta_AO = chem_env.F_beta_AO; - TiledIndexSpace AO_opt = chem_env.AO_opt; - TiledIndexSpace AO_tis = chem_env.AO_tis; - std::vector shell_tile_map = chem_env.shell_tile_map; - bool scf_conv = chem_env.no_scf; - - SystemData& sys_data = chem_env.sys_data; - // CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; - CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; - auto debug = ccsd_options.debug; - if(rank == 0) ccsd_options.print(); - - if(rank == 0) - cout << endl << "#occupied, #virtual = " << sys_data.nocc << ", " << sys_data.nvir << endl; + cholesky_2e::cholesky_2e_driver(ec, chem_env); - auto [MO, total_orbitals] = cholesky_2e::setupMOIS(ec, chem_env); + const bool is_rhf = chem_env.sys_data.is_restricted; - std::string out_fp = chem_env.workspace_dir; - std::string files_dir = out_fp + chem_env.ioptions.scf_options.scf_type; - std::string files_prefix = /*out_fp;*/ files_dir + "/" + sys_data.output_file_prefix; - std::string f1file = files_prefix + ".f1_mo"; - std::string t1file = files_prefix + ".t1amp"; - std::string t2file = files_prefix + ".t2amp"; - std::string v2file = files_prefix + ".cholv2"; - std::string cholfile = files_prefix + ".cholcount"; - std::string ccsdstatus = files_prefix + ".ccsdstatus"; + std::string files_prefix = chem_env.get_files_prefix(); - const bool is_rhf = sys_data.is_restricted; + CDContext& cd_context = chem_env.cd_context; + CCContext& cc_context = chem_env.cc_context; + cc_context.init_filenames(files_prefix); + CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; - bool ccsd_restart = ccsd_options.readt || ((fs::exists(t1file) && fs::exists(t2file) && - fs::exists(f1file) && fs::exists(v2file))); + auto debug = ccsd_options.debug; + bool scf_conv = chem_env.scf_context.no_scf; + std::string t1file = cc_context.t1file; + std::string t2file = cc_context.t2file; + const std::string ccsdstatus = cc_context.ccsdstatus; - // deallocates F_AO, C_AO - auto [cholVpr, d_f1, lcao, chol_count, max_cvecs, CI] = - cholesky_2e::cholesky_2e_driver(chem_env, ec, MO, AO_opt, C_AO, F_AO, C_beta_AO, F_beta_AO, - shells, shell_tile_map, ccsd_restart, cholfile); - free_tensors(lcao); + bool ccsd_restart = ccsd_options.readt || + ((fs::exists(t1file) && fs::exists(t2file) && fs::exists(cd_context.f1file) && + fs::exists(cd_context.v2file))); if(ccsd_options.writev) ccsd_options.writet = true; - TiledIndexSpace N = MO("all"); + TiledIndexSpace& MO = chem_env.is_context.MSO; + TiledIndexSpace& CI = chem_env.is_context.CI; + TiledIndexSpace N = MO("all"); + Tensor d_f1 = chem_env.cd_context.d_f1; + Tensor cholVpr = chem_env.cd_context.cholV2; std::vector p_evl_sorted; Tensor d_r1, d_r2, d_t1, d_t2; @@ -79,31 +58,13 @@ void exachem::cc::ccsd::cd_ccsd(ExecutionContext& ec, ChemEnv& chem_env) { ec, MO, d_f1, ccsd_options.ndiis, ccsd_restart && fs::exists(ccsdstatus) && scf_conv); if(ccsd_restart) { - read_from_disk(d_f1, f1file); if(fs::exists(t1file) && fs::exists(t2file)) { read_from_disk(d_t1, t1file); read_from_disk(d_t2, t2file); } - read_from_disk(cholVpr, v2file); - ec.pg().barrier(); p_evl_sorted = tamm::diagonal(d_f1); } - else if(ccsd_options.writet) { - // fs::remove_all(files_dir); - if(!fs::exists(files_dir)) fs::create_directories(files_dir); - - write_to_disk(d_f1, f1file); - write_to_disk(cholVpr, v2file); - - if(rank == 0) { - std::ofstream out(cholfile, std::ios::out); - if(!out) cerr << "Error opening file " << cholfile << endl; - out << chol_count << std::endl; - out.close(); - } - } - if(rank == 0 && debug) { print_vector(p_evl_sorted, files_prefix + ".eigen_values.txt"); cout << "Eigen values written to file: " << files_prefix + ".eigen_values.txt" << endl << endl; @@ -115,7 +76,7 @@ void exachem::cc::ccsd::cd_ccsd(ExecutionContext& ec, ChemEnv& chem_env) { ccsd_restart = ccsd_restart && fs::exists(ccsdstatus) && scf_conv; - std::string fullV2file = files_prefix + ".fullV2"; + std::string fullV2file = cd_context.fullV2file; t1file = files_prefix + ".fullT1amp"; t2file = files_prefix + ".fullT2amp"; @@ -146,7 +107,7 @@ void exachem::cc::ccsd::cd_ccsd(ExecutionContext& ec, ChemEnv& chem_env) { } } - ccsd_stats(ec, hf_energy, residual, corr_energy, ccsd_options.threshold); + ccsd_stats(ec, chem_env.scf_context.hf_energy, residual, corr_energy, ccsd_options.threshold); if(ccsd_options.writet && !fs::exists(ccsdstatus)) { // write_to_disk(d_t1,t1file); diff --git a/exachem/cc/ccsd/cd_ccsd_cs_ann.cpp b/exachem/cc/ccsd/cd_ccsd_cs_ann.cpp index 7e8fcaf..c4edb71 100644 --- a/exachem/cc/ccsd/cd_ccsd_cs_ann.cpp +++ b/exachem/cc/ccsd/cd_ccsd_cs_ann.cpp @@ -822,7 +822,7 @@ std::tuple exachem::cc::ccsd::cd_ccsd_cs_driver( } chem_env.cc_context.ccsd_correlation_energy = energy; - chem_env.cc_context.ccsd_total_energy = chem_env.hf_energy + energy; + chem_env.cc_context.ccsd_total_energy = chem_env.scf_context.hf_energy + energy; auto cc_t2 = std::chrono::high_resolution_clock::now(); double ccsd_time = diff --git a/exachem/cc/ccsd/cd_ccsd_os_ann.cpp b/exachem/cc/ccsd/cd_ccsd_os_ann.cpp index d39dd4a..b7d21ea 100644 --- a/exachem/cc/ccsd/cd_ccsd_os_ann.cpp +++ b/exachem/cc/ccsd/cd_ccsd_os_ann.cpp @@ -1165,7 +1165,7 @@ cd_ccsd_os_driver(ChemEnv& chem_env, ExecutionContext& ec, const TiledIndexSpace } chem_env.cc_context.ccsd_correlation_energy = energy; - chem_env.cc_context.ccsd_total_energy = chem_env.hf_energy + energy; + chem_env.cc_context.ccsd_total_energy = chem_env.scf_context.hf_energy + energy; auto cc_t2 = std::chrono::high_resolution_clock::now(); double ccsd_time = diff --git a/exachem/cc/ccsd_t/ccsd_t.cpp b/exachem/cc/ccsd_t/ccsd_t.cpp index 8a8d86a..8832ee7 100644 --- a/exachem/cc/ccsd_t/ccsd_t.cpp +++ b/exachem/cc/ccsd_t/ccsd_t.cpp @@ -23,32 +23,24 @@ double genTime = 0; double ccsd_t_data_per_rank = 0; // in GB void exachem::cc::ccsd_t::ccsd_t_driver(ExecutionContext& ec, ChemEnv& chem_env) { - using T = double; - + using T = double; auto rank = ec.pg().rank(); - scf::scf_driver(ec, chem_env); - - double hf_energy = chem_env.hf_energy; - libint2::BasisSet shells = chem_env.shells; - Tensor C_AO = chem_env.C_AO; - Tensor C_beta_AO = chem_env.C_beta_AO; - Tensor F_AO = chem_env.F_AO; - Tensor F_beta_AO = chem_env.F_beta_AO; - TiledIndexSpace AO_opt = chem_env.AO_opt; - TiledIndexSpace AO_tis = chem_env.AO_tis; - std::vector shell_tile_map = chem_env.shell_tile_map; - bool scf_conv = chem_env.no_scf; + cholesky_2e::cholesky_2e_driver(ec, chem_env); SystemData& sys_data = chem_env.sys_data; + const bool is_rhf = sys_data.is_restricted; + + std::string files_prefix = chem_env.get_files_prefix(); + + CDContext& cd_context = chem_env.cd_context; + CCContext& cc_context = chem_env.cc_context; + cc_context.init_filenames(files_prefix); + // CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; const int ccsdt_tilesize = ccsd_options.ccsdt_tilesize; - sys_data.freeze_atomic = chem_env.ioptions.ccsd_options.freeze_atomic; - sys_data.n_frozen_core = chem_env.get_nfcore(); - sys_data.n_frozen_virtual = chem_env.ioptions.ccsd_options.freeze_virtual; - #if defined(USE_CUDA) || defined(USE_HIP) || defined(USE_DPCPP) std::string t_errmsg = check_memory_req(ccsdt_tilesize, sys_data.nbf); if(!t_errmsg.empty()) tamm_terminate(t_errmsg); @@ -90,50 +82,38 @@ void exachem::cc::ccsd_t::ccsd_t_driver(ExecutionContext& ec, ChemEnv& chem_env) auto debug = ccsd_options.debug; bool skip_ccsd = ccsd_options.skip_ccsd; + bool scf_conv = chem_env.scf_context.no_scf; + if(rank == 0) ccsd_options.print(); if(rank == 0) cout << endl << "#occupied, #virtual = " << sys_data.nocc << ", " << sys_data.nvir << endl; - auto [MO, total_orbitals] = cholesky_2e::setupMOIS(ec, chem_env); + std::string t1file = cc_context.t1file; + std::string t2file = cc_context.t2file; + const std::string ccsdstatus = cc_context.ccsdstatus; - std::string out_fp = chem_env.workspace_dir; - std::string files_dir = out_fp + chem_env.ioptions.scf_options.scf_type; - std::string files_prefix = /*out_fp;*/ files_dir + "/" + sys_data.output_file_prefix; - std::string f1file = files_prefix + ".f1_mo"; - std::string t1file = files_prefix + ".t1amp"; - std::string t2file = files_prefix + ".t2amp"; - std::string v2file = files_prefix + ".cholv2"; - std::string cholfile = files_prefix + ".cholcount"; - std::string ccsdstatus = files_prefix + ".ccsdstatus"; + bool ccsd_restart = ccsd_options.readt || + ((fs::exists(t1file) && fs::exists(t2file) && fs::exists(cd_context.f1file) && + fs::exists(cd_context.v2file))); - const bool is_rhf = sys_data.is_restricted; - bool computeTData = ccsd_options.computeTData; - - bool ccsd_restart = ccsd_options.readt || ((fs::exists(t1file) && fs::exists(t2file) && - fs::exists(f1file) && fs::exists(v2file))); + bool computeTData = ccsd_options.computeTData; ExecutionHW ex_hw = ec.exhw(); - TiledIndexSpace N = MO("all"); - - Tensor cholVpr, d_t1, d_t2, d_f1, lcao; - TAMM_SIZE chol_count; - tamm::Tile max_cvecs; - TiledIndexSpace CI; + TiledIndexSpace& MO = chem_env.is_context.MSO; + TiledIndexSpace& CI = chem_env.is_context.CI; + TiledIndexSpace N = MO("all"); + Tensor d_f1 = chem_env.cd_context.d_f1; + Tensor cholVpr = chem_env.cd_context.cholV2; + Tensor d_t1, d_t2; std::vector p_evl_sorted; double residual = 0, corr_energy = 0; Tensor dt1_full, dt2_full; + double& hf_energy = chem_env.scf_context.hf_energy; if(!skip_ccsd) { - // deallocates F_AO, C_AO - std::tie(cholVpr, d_f1, lcao, chol_count, max_cvecs, CI) = - exachem::cholesky_2e::cholesky_2e_driver(chem_env, ec, MO, AO_opt, C_AO, F_AO, C_beta_AO, - F_beta_AO, shells, shell_tile_map, ccsd_restart, - cholfile); - free_tensors(lcao); - if(ccsd_options.writev) ccsd_options.writet = true; Tensor d_r1, d_r2; @@ -147,31 +127,13 @@ void exachem::cc::ccsd_t::ccsd_t_driver(ExecutionContext& ec, ChemEnv& chem_env) ec, MO, d_f1, ccsd_options.ndiis, ccsd_restart && fs::exists(ccsdstatus) && scf_conv); if(ccsd_restart) { - read_from_disk(d_f1, f1file); if(fs::exists(t1file) && fs::exists(t2file)) { read_from_disk(d_t1, t1file); read_from_disk(d_t2, t2file); } - read_from_disk(cholVpr, v2file); - ec.pg().barrier(); p_evl_sorted = tamm::diagonal(d_f1); } - else if(ccsd_options.writet) { - // fs::remove_all(files_dir); - if(!fs::exists(files_dir)) fs::create_directories(files_dir); - - write_to_disk(d_f1, f1file); - write_to_disk(cholVpr, v2file); - - if(rank == 0) { - std::ofstream out(cholfile, std::ios::out); - if(!out) cerr << "Error opening file " << cholfile << endl; - out << chol_count << std::endl; - out.close(); - } - } - if(rank == 0 && debug) { print_vector(p_evl_sorted, files_prefix + ".eigen_values.txt"); cout << "Eigen values written to file: " << files_prefix + ".eigen_values.txt" << endl @@ -427,7 +389,7 @@ void exachem::cc::ccsd_t::ccsd_t_driver(ExecutionContext& ec, ChemEnv& chem_env) Tensor::allocate(&ec, t_d_t1, t_d_t2); if(skip_ccsd || !computeTData) v2tensors.allocate(ec, MO1); - bool ccsd_t_restart = fs::exists(t1file) && fs::exists(t2file) && fs::exists(f1file) && + bool ccsd_t_restart = fs::exists(t1file) && fs::exists(t2file) && fs::exists(cd_context.f1file) && v2tensors.exist_on_disk(files_prefix); if(!ccsd_t_restart && !skip_ccsd) { @@ -524,7 +486,6 @@ void exachem::cc::ccsd_t::ccsd_t_driver(ExecutionContext& ec, ChemEnv& chem_env) energy1 = ec.pg().reduce(&energy1, ReduceOp::sum, 0); energy2 = ec.pg().reduce(&energy2, ReduceOp::sum, 0); - CCContext& cc_context = chem_env.cc_context; cc_context.ccsd_st_correction_energy = energy1; cc_context.ccsd_st_correlation_energy = corr_energy + energy1; cc_context.ccsd_st_total_energy = hf_energy + corr_energy + energy1; diff --git a/exachem/cc/ducc/ducc_driver.cpp b/exachem/cc/ducc/ducc_driver.cpp index 1e942c2..84f37d4 100644 --- a/exachem/cc/ducc/ducc_driver.cpp +++ b/exachem/cc/ducc/ducc_driver.cpp @@ -16,63 +16,36 @@ namespace fs = std::filesystem; namespace exachem::cc::ducc { void ducc_driver(ExecutionContext& ec, ChemEnv& chem_env) { - using T = double; - + using T = double; auto rank = ec.pg().rank(); - scf::scf_driver(ec, chem_env); + cholesky_2e::cholesky_2e_driver(ec, chem_env); - double hf_energy = chem_env.hf_energy; - libint2::BasisSet shells = chem_env.shells; - Tensor C_AO = chem_env.C_AO; - Tensor C_beta_AO = chem_env.C_beta_AO; - Tensor F_AO = chem_env.F_AO; - Tensor F_beta_AO = chem_env.F_beta_AO; - TiledIndexSpace AO_opt = chem_env.AO_opt; - TiledIndexSpace AO_tis = chem_env.AO_tis; - std::vector shell_tile_map = chem_env.shell_tile_map; - bool scf_conv = chem_env.no_scf; + const bool is_rhf = chem_env.sys_data.is_restricted; + std::string files_prefix = chem_env.get_files_prefix(); - SystemData& sys_data = chem_env.sys_data; + CDContext& cd_context = chem_env.cd_context; + CCContext& cc_context = chem_env.cc_context; + cc_context.init_filenames(files_prefix); CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; - auto debug = ccsd_options.debug; - if(rank == 0) ccsd_options.print(); - - if(rank == 0) - cout << endl << "#occupied, #virtual = " << sys_data.nocc << ", " << sys_data.nvir << endl; - - const int nactv = ccsd_options.nactive; - - const bool is_rhf = sys_data.is_restricted; - - // TODO: Implement check for UHF - if(nactv > sys_data.n_vir_alpha && is_rhf) tamm_terminate("[DUCC ERROR]: nactive > n_vir_alpha"); - - auto [MO, total_orbitals] = cholesky_2e::setupMOIS(ec, chem_env, false, nactv); - - std::string out_fp = chem_env.workspace_dir; - std::string files_dir = out_fp + chem_env.ioptions.scf_options.scf_type; - std::string files_prefix = /*out_fp;*/ files_dir + "/" + sys_data.output_file_prefix; - std::string f1file = files_prefix + ".f1_mo"; - std::string t1file = files_prefix + ".t1amp"; - std::string t2file = files_prefix + ".t2amp"; - std::string v2file = files_prefix + ".cholv2"; - std::string cholfile = files_prefix + ".cholcount"; - std::string ccsdstatus = files_prefix + ".ccsdstatus"; - bool ccsd_restart = ccsd_options.readt || ((fs::exists(t1file) && fs::exists(t2file) && - fs::exists(f1file) && fs::exists(v2file))); + auto debug = ccsd_options.debug; + bool scf_conv = chem_env.scf_context.no_scf; + std::string t1file = cc_context.t1file; + std::string t2file = cc_context.t2file; + const std::string ccsdstatus = cc_context.ccsdstatus; - // deallocates F_AO, C_AO - auto [cholVpr, d_f1, lcao, chol_count, max_cvecs, CI] = - exachem::cholesky_2e::cholesky_2e_driver(chem_env, ec, MO, AO_opt, C_AO, F_AO, C_beta_AO, - F_beta_AO, shells, shell_tile_map, ccsd_restart, - cholfile); - free_tensors(lcao); + bool ccsd_restart = ccsd_options.readt || + ((fs::exists(t1file) && fs::exists(t2file) && fs::exists(cd_context.f1file) && + fs::exists(cd_context.v2file))); - // if(ccsd_options.writev) ccsd_options.writet = true; + if(ccsd_options.writev) ccsd_options.writet = true; - TiledIndexSpace N = MO("all"); + TiledIndexSpace& MO = chem_env.is_context.MSO; + TiledIndexSpace& CI = chem_env.is_context.CI; + TiledIndexSpace N = MO("all"); + Tensor d_f1 = chem_env.cd_context.d_f1; + Tensor cholVpr = chem_env.cd_context.cholV2; std::vector p_evl_sorted; Tensor d_r1, d_r2, d_t1, d_t2; @@ -86,31 +59,13 @@ void ducc_driver(ExecutionContext& ec, ChemEnv& chem_env) { ec, MO, d_f1, ccsd_options.ndiis, ccsd_restart && fs::exists(ccsdstatus) && scf_conv); if(ccsd_restart) { - read_from_disk(d_f1, f1file); if(fs::exists(t1file) && fs::exists(t2file)) { read_from_disk(d_t1, t1file); read_from_disk(d_t2, t2file); } - read_from_disk(cholVpr, v2file); - ec.pg().barrier(); p_evl_sorted = tamm::diagonal(d_f1); } - else if(ccsd_options.writet) { - // fs::remove_all(files_dir); - if(!fs::exists(files_dir)) fs::create_directories(files_dir); - - write_to_disk(d_f1, f1file); - write_to_disk(cholVpr, v2file); - - if(rank == 0) { - std::ofstream out(cholfile, std::ios::out); - if(!out) cerr << "Error opening file " << cholfile << endl; - out << chol_count << std::endl; - out.close(); - } - } - if(rank == 0 && debug) { print_vector(p_evl_sorted, files_prefix + ".eigen_values.txt"); cout << "Eigen values written to file: " << files_prefix + ".eigen_values.txt" << endl << endl; @@ -124,7 +79,7 @@ void ducc_driver(ExecutionContext& ec, ChemEnv& chem_env) { ccsd_restart = ccsd_restart && fs::exists(ccsdstatus) && scf_conv; - std::string fullV2file = files_prefix + ".fullV2"; + std::string fullV2file = cd_context.fullV2file; // t1file = files_prefix+".fullT1amp"; // t2file = files_prefix+".fullT2amp"; @@ -158,7 +113,7 @@ void ducc_driver(ExecutionContext& ec, ChemEnv& chem_env) { d_t2 = dt2_full; // need full T1,T2 } - ccsd_stats(ec, hf_energy, residual, corr_energy, ccsd_options.threshold); + ccsd_stats(ec, chem_env.scf_context.hf_energy, residual, corr_energy, ccsd_options.threshold); if(ccsd_options.writet && !fs::exists(ccsdstatus)) { // write_to_disk(d_t1,t1file); @@ -204,7 +159,7 @@ void ducc_driver(ExecutionContext& ec, ChemEnv& chem_env) { free_tensors(cholVpr); - DUCC_T_CCSD_Driver(chem_env, ec, MO, d_t1, d_t2, d_f1, v2tensors, nactv, ex_hw); + DUCC_T_CCSD_Driver(chem_env, ec, MO, d_t1, d_t2, d_f1, v2tensors, ccsd_options.nactive, ex_hw); v2tensors.deallocate(); free_tensors(d_t1, d_t2, d_f1); diff --git a/exachem/cc/eom/eomccsd_driver.cpp b/exachem/cc/eom/eomccsd_driver.cpp index 415d0e2..70d51b5 100644 --- a/exachem/cc/eom/eomccsd_driver.cpp +++ b/exachem/cc/eom/eomccsd_driver.cpp @@ -12,54 +12,37 @@ void exachem::cc::eom::eom_ccsd_driver(ExecutionContext& ec, ChemEnv& chem_env) using T = double; auto rank = ec.pg().rank(); - scf::scf_driver(ec, chem_env); - - double hf_energy = chem_env.hf_energy; - libint2::BasisSet shells = chem_env.shells; - Tensor C_AO = chem_env.C_AO; - Tensor C_beta_AO = chem_env.C_beta_AO; - Tensor F_AO = chem_env.F_AO; - Tensor F_beta_AO = chem_env.F_beta_AO; - TiledIndexSpace AO_opt = chem_env.AO_opt; - TiledIndexSpace AO_tis = chem_env.AO_tis; - std::vector shell_tile_map = chem_env.shell_tile_map; - bool scf_conv = chem_env.no_scf; - SystemData& sys_data = chem_env.sys_data; - // CCSDOptions ccsd_options = chem_env.ioptions.ccsd_options; - CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; - auto debug = ccsd_options.debug; - if(rank == 0) ccsd_options.print(); - - if(rank == 0) - cout << endl << "#occupied, #virtual = " << sys_data.nocc << ", " << sys_data.nvir << endl; + cholesky_2e::cholesky_2e_driver(ec, chem_env); - auto [MO, total_orbitals] = cholesky_2e::setupMOIS(ec, chem_env); + SystemData& sys_data = chem_env.sys_data; + const bool is_rhf = sys_data.is_restricted; - std::string out_fp = chem_env.workspace_dir; - std::string files_dir = out_fp + chem_env.ioptions.scf_options.scf_type; - std::string files_prefix = /*out_fp;*/ files_dir + "/" + sys_data.output_file_prefix; - std::string f1file = files_prefix + ".f1_mo"; - std::string t1file = files_prefix + ".t1amp"; - std::string t2file = files_prefix + ".t2amp"; - std::string v2file = files_prefix + ".cholv2"; - std::string cholfile = files_prefix + ".cholcount"; - std::string ccsdstatus = files_prefix + ".ccsdstatus"; + std::string files_dir = chem_env.get_files_dir(); + std::string files_prefix = chem_env.get_files_prefix(); - const bool is_rhf = sys_data.is_restricted; + CDContext& cd_context = chem_env.cd_context; + CCContext& cc_context = chem_env.cc_context; + cc_context.init_filenames(files_prefix); + CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; - bool ccsd_restart = ccsd_options.readt || ((fs::exists(t1file) && fs::exists(t2file) && - fs::exists(f1file) && fs::exists(v2file))); + auto debug = ccsd_options.debug; + bool scf_conv = chem_env.scf_context.no_scf; + std::string t1file = cc_context.t1file; + std::string t2file = cc_context.t2file; + const std::string ccsdstatus = cc_context.ccsdstatus; - // deallocates F_AO, C_AO - auto [cholVpr, d_f1, lcao, chol_count, max_cvecs, CI] = - cholesky_2e::cholesky_2e_driver(chem_env, ec, MO, AO_opt, C_AO, F_AO, C_beta_AO, F_beta_AO, - shells, shell_tile_map, ccsd_restart, cholfile); - free_tensors(lcao); + bool ccsd_restart = ccsd_options.readt || + ((fs::exists(t1file) && fs::exists(t2file) && fs::exists(cd_context.f1file) && + fs::exists(cd_context.v2file))); // if(ccsd_options.writev) ccsd_options.writet = true; - TiledIndexSpace N = MO("all"); + TiledIndexSpace& MO = chem_env.is_context.MSO; + TiledIndexSpace& CI = chem_env.is_context.CI; + TiledIndexSpace N = MO("all"); + Tensor d_f1 = chem_env.cd_context.d_f1; + Tensor cholVpr = chem_env.cd_context.cholV2; std::vector p_evl_sorted; Tensor d_r1, d_r2, d_t1, d_t2; @@ -73,31 +56,13 @@ void exachem::cc::eom::eom_ccsd_driver(ExecutionContext& ec, ChemEnv& chem_env) ec, MO, d_f1, ccsd_options.ndiis, ccsd_restart && fs::exists(ccsdstatus) && scf_conv); if(ccsd_restart) { - read_from_disk(d_f1, f1file); if(fs::exists(t1file) && fs::exists(t2file)) { read_from_disk(d_t1, t1file); read_from_disk(d_t2, t2file); } - read_from_disk(cholVpr, v2file); - ec.pg().barrier(); p_evl_sorted = tamm::diagonal(d_f1); } - else if(ccsd_options.writet) { - // fs::remove_all(files_dir); - if(!fs::exists(files_dir)) fs::create_directories(files_dir); - - write_to_disk(d_f1, f1file); - write_to_disk(cholVpr, v2file); - - if(rank == 0) { - std::ofstream out(cholfile, std::ios::out); - if(!out) cerr << "Error opening file " << cholfile << endl; - out << chol_count << std::endl; - out.close(); - } - } - if(rank == 0 && debug) { print_vector(p_evl_sorted, files_prefix + ".eigen_values.txt"); cout << "Eigen values written to file: " << files_prefix + ".eigen_values.txt" << endl << endl; @@ -109,7 +74,7 @@ void exachem::cc::eom::eom_ccsd_driver(ExecutionContext& ec, ChemEnv& chem_env) ccsd_restart = ccsd_restart && fs::exists(ccsdstatus) && scf_conv; - std::string fullV2file = files_prefix + ".fullV2"; + std::string fullV2file = cd_context.fullV2file; // t1file = files_prefix+".fullT1amp"; // t2file = files_prefix+".fullT2amp"; @@ -143,7 +108,7 @@ void exachem::cc::eom::eom_ccsd_driver(ExecutionContext& ec, ChemEnv& chem_env) d_t2 = dt2_full; // need full T1,T2 } - ccsd_stats(ec, hf_energy, residual, corr_energy, ccsd_options.threshold); + ccsd_stats(ec, chem_env.scf_context.hf_energy, residual, corr_energy, ccsd_options.threshold); if(ccsd_options.writet && !fs::exists(ccsdstatus)) { // write_to_disk(d_t1,t1file); diff --git a/exachem/cc/gfcc/gfccsd_driver.cpp b/exachem/cc/gfcc/gfccsd_driver.cpp index 2a95e48..62ae729 100644 --- a/exachem/cc/gfcc/gfccsd_driver.cpp +++ b/exachem/cc/gfcc/gfccsd_driver.cpp @@ -2517,20 +2517,13 @@ void gfccsd_driver(ExecutionContext& ec, ChemEnv& chem_env) { auto restart_time_start = std::chrono::high_resolution_clock::now(); - scf::scf_driver(ec, chem_env); + // force writet on + chem_env.ioptions.ccsd_options.writet = true; + chem_env.ioptions.ccsd_options.computeTData = true; - SystemData& sys_data = chem_env.sys_data; + cholesky_2e::cholesky_2e_driver(ec, chem_env); - double hf_energy = chem_env.hf_energy; - libint2::BasisSet shells = chem_env.shells; - Tensor C_AO = chem_env.C_AO; - Tensor C_beta_AO = chem_env.C_beta_AO; - Tensor F_AO = chem_env.F_AO; - Tensor F_beta_AO = chem_env.F_beta_AO; - TiledIndexSpace AO_opt = chem_env.AO_opt; - TiledIndexSpace AO_tis = chem_env.AO_tis; - std::vector shell_tile_map = chem_env.shell_tile_map; - bool scf_conv = chem_env.no_scf; + SystemData& sys_data = chem_env.sys_data; int nsranks = sys_data.nbf / 15; if(nsranks < 1) nsranks = 1; @@ -2559,46 +2552,35 @@ void gfccsd_driver(ExecutionContext& ec, ChemEnv& chem_env) { Scheduler sub_sch{*sub_ec}; - // force writet on - chem_env.ioptions.ccsd_options.writet = true; - chem_env.ioptions.ccsd_options.computeTData = true; - - CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; - auto debug = ccsd_options.debug; - if(rank == 0) ccsd_options.print(); + const bool is_rhf = chem_env.sys_data.is_restricted; - if(rank == 0) - cout << endl << "#occupied, #virtual = " << sys_data.nocc << ", " << sys_data.nvir << endl; + std::string files_dir = chem_env.get_files_dir(); + std::string files_prefix = chem_env.get_files_prefix(); - auto [MO, total_orbitals] = cholesky_2e::setupMOIS(ec, chem_env); - - std::string out_fp = chem_env.workspace_dir; - std::string files_dir = out_fp + chem_env.ioptions.scf_options.scf_type; - std::string files_prefix = /*out_fp;*/ files_dir + "/" + sys_data.output_file_prefix; - std::string f1file = files_prefix + ".f1_mo"; - std::string t1file = files_prefix + ".t1amp"; - std::string t2file = files_prefix + ".t2amp"; - std::string v2file = files_prefix + ".cholv2"; - std::string cholfile = files_prefix + ".cholcount"; - std::string ccsdstatus = files_prefix + ".ccsdstatus"; - - const bool is_rhf = sys_data.is_restricted; + CDContext& cd_context = chem_env.cd_context; + CCContext& cc_context = chem_env.cc_context; + cc_context.init_filenames(files_prefix); + CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; - bool ccsd_restart = ccsd_options.readt || ((fs::exists(t1file) && fs::exists(t2file) && - fs::exists(f1file) && fs::exists(v2file))); + auto debug = ccsd_options.debug; + bool scf_conv = chem_env.scf_context.no_scf; + std::string t1file = cc_context.t1file; + std::string t2file = cc_context.t2file; + const std::string ccsdstatus = cc_context.ccsdstatus; - // deallocates F_AO, C_AO - auto [cholVpr, d_f1, lcao, chol_count, max_cvecs, CI] = - exachem::cholesky_2e::cholesky_2e_driver(chem_env, ec, MO, AO_opt, C_AO, F_AO, C_beta_AO, - F_beta_AO, shells, shell_tile_map, ccsd_restart, - cholfile); - free_tensors(lcao); - total_orbitals = sys_data.nmo; + bool ccsd_restart = ccsd_options.readt || + ((fs::exists(t1file) && fs::exists(t2file) && fs::exists(cd_context.f1file) && + fs::exists(cd_context.v2file))); - // if(ccsd_options.writev) ccsd_options.writet = true; + if(ccsd_options.writev) ccsd_options.writet = true; - TiledIndexSpace N = MO("all"); + TiledIndexSpace& MO = chem_env.is_context.MSO; + TiledIndexSpace& CI = chem_env.is_context.CI; + TiledIndexSpace N = MO("all"); + Tensor d_f1 = chem_env.cd_context.d_f1; + Tensor cholVpr = chem_env.cd_context.cholV2; + TAMM_SIZE total_orbitals = sys_data.nmo; std::vector p_evl_sorted; Tensor d_r1, d_r2, d_t1, d_t2; std::vector> d_r1s, d_r2s, d_t1s, d_t2s; @@ -2611,31 +2593,13 @@ void gfccsd_driver(ExecutionContext& ec, ChemEnv& chem_env) { ec, MO, d_f1, ccsd_options.ndiis, ccsd_restart && fs::exists(ccsdstatus) && scf_conv); if(ccsd_restart) { - read_from_disk(d_f1, f1file); if(fs::exists(t1file) && fs::exists(t2file)) { read_from_disk(d_t1, t1file); read_from_disk(d_t2, t2file); } - read_from_disk(cholVpr, v2file); - ec.pg().barrier(); p_evl_sorted = tamm::diagonal(d_f1); } - else if(ccsd_options.writet) { - // fs::remove_all(files_dir); - if(!fs::exists(files_dir)) fs::create_directories(files_dir); - - write_to_disk(d_f1, f1file); - write_to_disk(cholVpr, v2file); - - if(rank == 0) { - std::ofstream out(cholfile, std::ios::out); - if(!out) cerr << "Error opening file " << cholfile << endl; - out << chol_count << std::endl; - out.close(); - } - } - if(rank == 0 && debug) { print_vector(p_evl_sorted, files_prefix + ".eigen_values.txt"); cout << "Eigen values written to file: " << files_prefix + ".eigen_values.txt" << endl << endl; @@ -2711,7 +2675,7 @@ void gfccsd_driver(ExecutionContext& ec, ChemEnv& chem_env) { d_t2 = dt2_full; // GFCC uses full T1,T2 } - ccsd_stats(ec, hf_energy, residual, corr_energy, ccsd_options.threshold); + ccsd_stats(ec, chem_env.scf_context.hf_energy, residual, corr_energy, ccsd_options.threshold); if(ccsd_options.writet && !fs::exists(ccsdstatus)) { // write_to_disk(d_t1,t1file); diff --git a/exachem/cc/lambda/ccsd_lambda_driver.cpp b/exachem/cc/lambda/ccsd_lambda_driver.cpp index 6047b78..85bf28a 100644 --- a/exachem/cc/lambda/ccsd_lambda_driver.cpp +++ b/exachem/cc/lambda/ccsd_lambda_driver.cpp @@ -27,59 +27,40 @@ Tensor compute_2rdm(std::vector&, std::string, Scheduler&, TiledIndexSpa Tensor, Tensor, Tensor); void exachem::cc::ccsd_lambda::ccsd_lambda_driver(ExecutionContext& ec, ChemEnv& chem_env) { - using T = double; - // using namespace termcolor; + using T = double; auto rank = ec.pg().rank(); - scf::scf_driver(ec, chem_env); - - double hf_energy = chem_env.hf_energy; - libint2::BasisSet shells = chem_env.shells; - Tensor C_AO = chem_env.C_AO; - Tensor C_beta_AO = chem_env.C_beta_AO; - Tensor F_AO = chem_env.F_AO; - Tensor F_beta_AO = chem_env.F_beta_AO; - TiledIndexSpace AO_opt = chem_env.AO_opt; - TiledIndexSpace AO_tis = chem_env.AO_tis; - std::vector shell_tile_map = chem_env.shell_tile_map; - bool scf_conv = chem_env.no_scf; + chem_env.cd_context.keep_movecs_so = true; + cholesky_2e::cholesky_2e_driver(ec, chem_env); SystemData& sys_data = chem_env.sys_data; - // CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; - CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; - auto debug = ccsd_options.debug; - if(rank == 0) ccsd_options.print(); - - if(rank == 0) - cout << endl << "#occupied, #virtual = " << sys_data.nocc << ", " << sys_data.nvir << endl; + const bool is_rhf = sys_data.is_restricted; - auto [MO, total_orbitals] = cholesky_2e::setupMOIS(ec, chem_env); + std::string files_dir = chem_env.get_files_dir(); + std::string files_prefix = chem_env.get_files_prefix(); - const bool is_rhf = sys_data.is_restricted; - - std::string out_fp = chem_env.workspace_dir; - std::string files_dir = out_fp + chem_env.ioptions.scf_options.scf_type; - std::string files_prefix = /*out_fp;*/ files_dir + "/" + sys_data.output_file_prefix; - std::string f1file = files_prefix + ".f1_mo"; - std::string t1file = files_prefix + ".t1amp"; - std::string t2file = files_prefix + ".t2amp"; - std::string v2file = files_prefix + ".cholv2"; - std::string cholfile = files_prefix + ".cholcount"; - std::string ccsdstatus = files_prefix + ".ccsdstatus"; - - // const bool is_rhf = sys_data.is_restricted; + CDContext& cd_context = chem_env.cd_context; + CCContext& cc_context = chem_env.cc_context; + cc_context.init_filenames(files_prefix); + CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; - bool ccsd_restart = ccsd_options.readt || ((fs::exists(t1file) && fs::exists(t2file) && - fs::exists(f1file) && fs::exists(v2file))); + auto debug = ccsd_options.debug; + bool scf_conv = chem_env.scf_context.no_scf; + std::string t1file = cc_context.t1file; + std::string t2file = cc_context.t2file; + const std::string ccsdstatus = cc_context.ccsdstatus; - // deallocates F_AO, C_AO - auto [cholVpr, d_f1, lcao, chol_count, max_cvecs, CI] = - cholesky_2e::cholesky_2e_driver(chem_env, ec, MO, AO_opt, C_AO, F_AO, C_beta_AO, F_beta_AO, - shells, shell_tile_map, ccsd_restart, cholfile); + bool ccsd_restart = ccsd_options.readt || + ((fs::exists(t1file) && fs::exists(t2file) && fs::exists(cd_context.f1file) && + fs::exists(cd_context.v2file))); - // if(ccsd_options.writev) ccsd_options.writet = true; + if(ccsd_options.writev) ccsd_options.writet = true; - TiledIndexSpace N = MO("all"); + TiledIndexSpace& MO = chem_env.is_context.MSO; + TiledIndexSpace& CI = chem_env.is_context.CI; + TiledIndexSpace N = MO("all"); + Tensor d_f1 = chem_env.cd_context.d_f1; + Tensor cholVpr = chem_env.cd_context.cholV2; std::vector p_evl_sorted; Tensor d_r1, d_r2, d_t1, d_t2; @@ -93,31 +74,13 @@ void exachem::cc::ccsd_lambda::ccsd_lambda_driver(ExecutionContext& ec, ChemEnv& ec, MO, d_f1, ccsd_options.ndiis, ccsd_restart && fs::exists(ccsdstatus) && scf_conv); if(ccsd_restart) { - read_from_disk(d_f1, f1file); if(fs::exists(t1file) && fs::exists(t2file)) { read_from_disk(d_t1, t1file); read_from_disk(d_t2, t2file); } - read_from_disk(cholVpr, v2file); - ec.pg().barrier(); p_evl_sorted = tamm::diagonal(d_f1); } - else if(ccsd_options.writet) { - // fs::remove_all(files_dir); - if(!fs::exists(files_dir)) fs::create_directories(files_dir); - - write_to_disk(d_f1, f1file); - write_to_disk(cholVpr, v2file); - - if(rank == 0) { - std::ofstream out(cholfile, std::ios::out); - if(!out) cerr << "Error opening file " << cholfile << endl; - out << chol_count << std::endl; - out.close(); - } - } - if(rank == 0 && debug) { print_vector(p_evl_sorted, files_prefix + ".eigen_values.txt"); cout << "Eigen values written to file: " << files_prefix + ".eigen_values.txt" << endl << endl; @@ -131,7 +94,7 @@ void exachem::cc::ccsd_lambda::ccsd_lambda_driver(ExecutionContext& ec, ChemEnv& ccsd_restart = ccsd_restart && fs::exists(ccsdstatus) && scf_conv; - std::string fullV2file = files_prefix + ".fullV2"; + std::string fullV2file = cd_context.fullV2file; // t1file = files_prefix+".fullT1amp"; // t2file = files_prefix+".fullT2amp"; @@ -165,7 +128,7 @@ void exachem::cc::ccsd_lambda::ccsd_lambda_driver(ExecutionContext& ec, ChemEnv& d_t2 = dt2_full; // need full T1,T2 } - ccsd_stats(ec, hf_energy, residual, corr_energy, ccsd_options.threshold); + ccsd_stats(ec, chem_env.scf_context.hf_energy, residual, corr_energy, ccsd_options.threshold); if(ccsd_options.writet && !fs::exists(ccsdstatus)) { // write_to_disk(d_t1,t1file); @@ -244,6 +207,8 @@ void exachem::cc::ccsd_lambda::ccsd_lambda_driver(ExecutionContext& ec, ChemEnv& cc_t1 = std::chrono::high_resolution_clock::now(); + TiledIndexSpace& AO_opt = chem_env.is_context.AO_opt; + Tensor DipX_ao{AO_opt, AO_opt}; Tensor DipY_ao{AO_opt, AO_opt}; Tensor DipZ_ao{AO_opt, AO_opt}; @@ -263,13 +228,13 @@ void exachem::cc::ccsd_lambda::ccsd_lambda_driver(ExecutionContext& ec, ChemEnv& scf::SCFVars spvars; scf::SCFCompute scf_compute; - scf_compute.compute_shellpair_list(ec, shells, spvars); + scf_compute.compute_shellpair_list(ec, chem_env.shells, spvars); std::tie(spvars.shell_tile_map, spvars.AO_tiles, spvars.AO_opttiles) = - scf_compute.compute_AO_tiles(ec, chem_env, shells); + scf_compute.compute_AO_tiles(ec, chem_env, chem_env.shells); auto atoms = chem_env.atoms; scf::SCFGuess scf_guess; - scf_guess.compute_dipole_ints(ec, spvars, DipX_ao, DipY_ao, DipZ_ao, atoms, shells, + scf_guess.compute_dipole_ints(ec, spvars, DipX_ao, DipY_ao, DipZ_ao, atoms, chem_env.shells, libint2::Operator::emultipole1); auto [mu, nu, ku] = AO_opt.labels<3>("all"); @@ -277,6 +242,8 @@ void exachem::cc::ccsd_lambda::ccsd_lambda_driver(ExecutionContext& ec, ChemEnv& auto [h1, h2, h3, h4] = MO.labels<4>("occ"); auto [p1, p2, p3, p4] = MO.labels<4>("virt"); + Tensor lcao = chem_env.cd_context.movecs_so; + // AO2MO transormation Tensor lcao_t{mo1, mu}; Tensor tmp1{nu, mo2}; diff --git a/exachem/cc/lambda/ccsd_natural_orbitals.cpp b/exachem/cc/lambda/ccsd_natural_orbitals.cpp index fc8418f..354401a 100644 --- a/exachem/cc/lambda/ccsd_natural_orbitals.cpp +++ b/exachem/cc/lambda/ccsd_natural_orbitals.cpp @@ -142,7 +142,7 @@ void ccsd_natural_orbitals(ChemEnv& chem_env, std::vector& cc_rdm, std::str //################################################################################ // TRANSFORM C AND FORM DENSITY FOR NATURAL ORBITAL BASIS //################################################################################ - Tensor C_alpha_AO2{mu, chem_env.AO_ortho}; + Tensor C_alpha_AO2{mu, chem_env.is_context.AO_ortho}; Tensor C_alpha_AOMO{mu, pa}; Tensor C_alpha_NO_AOMO{mu, pa}; Tensor alpha_density{mu, nu}; diff --git a/exachem/cc/rteom/rt_eom_cd_ccsd.cpp b/exachem/cc/rteom/rt_eom_cd_ccsd.cpp index 85aaa18..f1aeef2 100644 --- a/exachem/cc/rteom/rt_eom_cd_ccsd.cpp +++ b/exachem/cc/rteom/rt_eom_cd_ccsd.cpp @@ -714,6 +714,7 @@ void rt_eom_cd_ccsd(ChemEnv& chem_env, ExecutionContext& ec, const TiledIndexSpa TiledIndexSpace cv3d_utis{ mo_ut, range(sys_data.nmo - sys_data.n_vir_beta, sys_data.nmo - sys_data.n_vir_beta + 1)}; auto [c1, c2] = cv3d_utis.labels<2>("all"); + // clang-format off sch (d_f1_ut(h1,h2) += -1.0 * cv3d_ut(h1,h2,cind) * cv3d_ut(c1,c2,cind)) @@ -981,77 +982,34 @@ void rt_eom_cd_ccsd_driver(ExecutionContext& ec, ChemEnv& chem_env) { using T = double; using ComplexTensor = Tensor; - auto rank = ec.pg().rank(); + auto rank = ec.pg().rank(); + SystemData& sys_data = chem_env.sys_data; - scf::scf_driver(ec, chem_env); + cholesky_2e::cholesky_2e_driver(ec, chem_env); - libint2::BasisSet shells = chem_env.shells; - Tensor C_AO = chem_env.C_AO; - Tensor C_beta_AO = chem_env.C_beta_AO; - Tensor F_AO = chem_env.F_AO; - Tensor F_beta_AO = chem_env.F_beta_AO; - TiledIndexSpace AO_opt = chem_env.AO_opt; - std::vector shell_tile_map = chem_env.shell_tile_map; + std::string files_dir = chem_env.get_files_dir(); + std::string files_prefix = chem_env.get_files_prefix(); - SystemData& sys_data = chem_env.sys_data; + CDContext& cd_context = chem_env.cd_context; + CCContext& cc_context = chem_env.cc_context; + cc_context.init_filenames(files_prefix); CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; - // CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; - auto debug = ccsd_options.debug; - if(rank == 0) ccsd_options.print(); - if(rank == 0) - cout << endl << "#occupied, #virtual = " << sys_data.nocc << ", " << sys_data.nvir << endl; - - auto [MO, total_orbitals] = cholesky_2e::setupMOIS(ec, chem_env); + auto debug = ccsd_options.debug; - std::string out_fp = chem_env.workspace_dir; - std::string files_dir = out_fp + chem_env.ioptions.scf_options.scf_type; - std::string files_prefix = /*out_fp;*/ files_dir + "/" + sys_data.output_file_prefix; - std::string f1file = files_prefix + ".f1_mo"; - // std::string t1file = files_prefix+".t1amp"; - // std::string t2file = files_prefix+".t2amp"; - std::string v2file = files_prefix + ".cholv2"; - std::string cholfile = files_prefix + ".cholcount"; - std::string ccsdstatus = files_prefix + ".ccsdstatus"; + TiledIndexSpace& MO = chem_env.is_context.MSO; + TiledIndexSpace& CI = chem_env.is_context.CI; + TiledIndexSpace N = MO("all"); + Tensor d_f1 = cd_context.d_f1; + Tensor cholVpr = cd_context.cholV2; const bool is_rhf = sys_data.is_restricted; if(is_rhf) tamm_terminate("RHF not supported"); - bool cc_restart = ccsd_options.readt || (fs::exists(f1file) && fs::exists(v2file)); - - // deallocates F_AO, C_AO - auto [cholVpr, d_f1, lcao, chol_count, max_cvecs, CI] = - exachem::cholesky_2e::cholesky_2e_driver(chem_env, ec, MO, AO_opt, C_AO, F_AO, C_beta_AO, - F_beta_AO, shells, shell_tile_map, cc_restart, - cholfile); - free_tensors(lcao); - - TiledIndexSpace N = MO("all"); - + bool cc_restart = ccsd_options.readt || + (fs::exists(cd_context.f1file) && fs::exists(cd_context.v2file)); Scheduler sch{ec}; - if(cc_restart) { - read_from_disk(d_f1, f1file); - read_from_disk(cholVpr, v2file); - ec.pg().barrier(); - // p_evl_sorted = tamm::diagonal(d_f1); - } - - else if(ccsd_options.writet) { - // fs::remove_all(files_dir); - if(!fs::exists(files_dir)) fs::create_directories(files_dir); - - write_to_disk(d_f1, f1file); - write_to_disk(cholVpr, v2file); - - if(rank == 0) { - std::ofstream out(cholfile, std::ios::out); - if(!out) cerr << "Error opening file " << cholfile << endl; - out << chol_count << std::endl; - out.close(); - } - } - ComplexTensor d_f1_c{{d_f1.tiled_index_spaces()}, {1, 1}}; ComplexTensor cholVpr_c{{cholVpr.tiled_index_spaces()}, {1, 1}}; sch.allocate(cholVpr_c, d_f1_c)(d_f1_c() = d_f1())(cholVpr_c() = cholVpr()) diff --git a/exachem/cholesky/cholesky_2e.cpp b/exachem/cholesky/cholesky_2e.cpp index 6b1793c..bc567e8 100644 --- a/exachem/cholesky/cholesky_2e.cpp +++ b/exachem/cholesky/cholesky_2e.cpp @@ -77,15 +77,18 @@ std::tuple setup_mo_red(ExecutionContext& ec, ChemEn const int rank = ec.pg().rank().value(); auto ccsd_options = chem_env.ioptions.ccsd_options; + const std::string jkey = "tilesize"; + const bool user_ts = chem_env.jinput["CC"].contains(jkey) ? true : false; + Tile tce_tile = ccsd_options.tilesize; if(!triples) { - if(!ccsd_options.force_tilesize && ec.has_gpu()) { + if(!user_ts && ec.has_gpu()) { tce_tile = static_cast(sys_data.nbf / 10); if(tce_tile < 50) tce_tile = 50; // 50 is the default tilesize else if(tce_tile > 140) tce_tile = 140; // 140 is the max tilesize if(rank == 0) std::cout << std::endl - << "Resetting tilesize for the MO space to: " << tce_tile << std::endl; + << "**** Resetting tilesize for the MO space to: " << tce_tile << std::endl; } } else tce_tile = ccsd_options.ccsdt_tilesize; @@ -125,17 +128,23 @@ std::tuple setupMOIS(ExecutionContext& ec, ChemEnv& Tile tce_tile = ccsd_options.tilesize; bool balance_tiles = ccsd_options.balance_tiles; + + const std::string jkey = "tilesize"; + const bool user_ts = chem_env.jinput["CC"].contains(jkey) ? true : false; + if(!triples) { - if(!ccsd_options.force_tilesize && ec.has_gpu()) { + if(!user_ts && ec.has_gpu()) { tce_tile = get_ts_recommendation(ec, chem_env); if(rank == 0) std::cout << std::endl - << "Resetting tilesize for the MSO space to: " << tce_tile << std::endl; + << "**** Resetting tilesize for the MSO space to: " << tce_tile << std::endl; } + chem_env.is_context.mso_tilesize = tce_tile; } else { - balance_tiles = false; - tce_tile = ccsd_options.ccsdt_tilesize; + balance_tiles = false; + tce_tile = ccsd_options.ccsdt_tilesize; + chem_env.is_context.mso_tilesize_triples = tce_tile; } TAMM_SIZE nmo = sys_data.nmo; @@ -325,15 +334,21 @@ Matrix reshape_mo_matrix(ChemEnv& chem_env, Matrix& emat, bool is_lcao) { } template -Tensor cholesky_2e(ChemEnv& chem_env, ExecutionContext& ec, TiledIndexSpace& tMO, - TiledIndexSpace& tAO, TAMM_SIZE& chol_count, - const TAMM_GA_SIZE max_cvecs, libint2::BasisSet& shells, - Tensor& lcao, bool is_mso) { +void cholesky_2e(ExecutionContext& ec, ChemEnv& chem_env) { + TiledIndexSpace& tMO = chem_env.is_context.MSO; + TiledIndexSpace& tAO = chem_env.is_context.AO_opt; + + libint2::BasisSet& shells = chem_env.shells; + Tensor& lcao = chem_env.cd_context.movecs_so; + bool is_mso = chem_env.cd_context.is_mso; + using libint2::Atom; using libint2::Engine; using libint2::Operator; using libint2::Shell; + const int max_cvecs = chem_env.cd_context.max_cvecs; + SystemData& sys_data = chem_env.sys_data; const auto cd_options = chem_env.ioptions.cd_options; const auto write_cv = cd_options.write_cv; @@ -1090,12 +1105,9 @@ Tensor cholesky_2e(ChemEnv& chem_env, ExecutionContext& ec, TiledInd cout << std::string(45, '-') << endl; } - chol_count = count; - return CholVpr_tamm; + chem_env.cd_context.num_chol_vecs = count; + chem_env.cd_context.cholV2 = CholVpr_tamm; } -template Tensor cholesky_2e(ChemEnv& chem_env, ExecutionContext& ec, TiledIndexSpace& tMO, - TiledIndexSpace& tAO, TAMM_SIZE& chol_count, - const TAMM_GA_SIZE max_cvecs, libint2::BasisSet& shells, - Tensor& lcao, bool is_mso); +template void cholesky_2e(ExecutionContext& ec, ChemEnv& chem_env); } // namespace exachem::cholesky_2e diff --git a/exachem/cholesky/cholesky_2e.hpp b/exachem/cholesky/cholesky_2e.hpp index 400854b..f5fc427 100644 --- a/exachem/cholesky/cholesky_2e.hpp +++ b/exachem/cholesky/cholesky_2e.hpp @@ -38,9 +38,6 @@ void update_sysdata(ExecutionContext& ec, ChemEnv& chem_env, TiledIndexSpace& MO // reshape F/lcao after freezing Matrix reshape_mo_matrix(ChemEnv& chem_env, Matrix& emat, bool is_lcao = false); -template -Tensor cholesky_2e(ChemEnv& chem_env, ExecutionContext& ec, TiledIndexSpace& tMO, - TiledIndexSpace& tAO, TAMM_SIZE& chol_count, - const TAMM_GA_SIZE max_cvecs, libint2::BasisSet& shells, - Tensor& lcao, bool is_mso = true); +template +void cholesky_2e(ExecutionContext& ec, ChemEnv& chem_env); } // namespace exachem::cholesky_2e diff --git a/exachem/cholesky/cholesky_2e_driver.cpp b/exachem/cholesky/cholesky_2e_driver.cpp index c96b3d4..b5d21e5 100644 --- a/exachem/cholesky/cholesky_2e_driver.cpp +++ b/exachem/cholesky/cholesky_2e_driver.cpp @@ -7,118 +7,142 @@ */ #include "exachem/cholesky/cholesky_2e_driver.hpp" +#include "exachem/common/context/cd_context.hpp" +#include "exachem/common/context/is_context.hpp" using namespace exachem::scf; -void exachem::cholesky_2e::cholesky_decomp_2e(ExecutionContext& ec, ChemEnv& chem_env) { +void exachem::cholesky_2e::cholesky_2e_driver(ExecutionContext& ec, ChemEnv& chem_env) { using T = double; - auto rank = ec.pg().rank(); + if(!chem_env.scf_context.scf_converged) scf::scf_driver(ec, chem_env); - scf::scf_driver(ec, chem_env); + libint2::BasisSet& shells = chem_env.shells; + Tensor C_AO = chem_env.scf_context.C_AO; + Tensor C_beta_AO = chem_env.scf_context.C_beta_AO; + Tensor F_AO = chem_env.scf_context.F_AO; + Tensor F_beta_AO = chem_env.scf_context.F_beta_AO; - libint2::BasisSet shells = chem_env.shells; - Tensor C_AO = chem_env.C_AO; - Tensor C_beta_AO = chem_env.C_beta_AO; - Tensor F_AO = chem_env.F_AO; - Tensor F_beta_AO = chem_env.F_beta_AO; - TiledIndexSpace AO_opt = chem_env.AO_opt; - TiledIndexSpace AO_tis = chem_env.AO_tis; - std::vector shell_tile_map = chem_env.shell_tile_map; + TiledIndexSpace& AO = chem_env.is_context.AO_opt; - SystemData sys_data = chem_env.sys_data; - CCSDOptions ccsd_options = chem_env.ioptions.ccsd_options; - if(rank == 0) ccsd_options.print(); + CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; - if(rank == 0) - cout << endl << "#occupied, #virtual = " << sys_data.nocc << ", " << sys_data.nvir << endl; - - auto [MO, total_orbitals] = cholesky_2e::setupMOIS(ec, chem_env); - - std::string out_fp = chem_env.workspace_dir; - std::string files_dir = out_fp + chem_env.ioptions.scf_options.scf_type; - std::string files_prefix = /*out_fp;*/ files_dir + "/" + sys_data.output_file_prefix; - std::string f1file = files_prefix + ".f1_mo"; - std::string v2file = files_prefix + ".cholv2"; - std::string cholfile = files_prefix + ".cholcount"; - - bool cd_restart = fs::exists(f1file) && fs::exists(v2file) && fs::exists(cholfile); + std::cout << std::defaultfloat; + auto rank = ec.pg().rank(); + SystemData& sys_data = chem_env.sys_data; + CDOptions cd_options = chem_env.ioptions.cd_options; - // deallocates F_AO, C_AO - auto [cholVpr, d_f1, lcao, chol_count, max_cvecs, CI] = - cholesky_2e::cholesky_2e_driver(chem_env, ec, MO, AO_opt, C_AO, F_AO, C_beta_AO, F_beta_AO, - shells, shell_tile_map, cd_restart, cholfile); - free_tensors(lcao); + if(rank == 0) { + // ccsd_options.print(); + cd_options.print(); + std::cout << std::endl + << "- #occupied, #virtual = " << sys_data.nocc << ", " << sys_data.nvir << std::endl; + } - if(!cd_restart && ccsd_options.writet) { - if(!fs::exists(files_dir)) fs::create_directories(files_dir); + std::string files_dir = chem_env.get_files_dir(); + std::string files_prefix = chem_env.get_files_prefix(); + + CDContext& cd_context = chem_env.cd_context; + cd_context.init_filenames(files_prefix); + + const std::string cholfile = cd_context.cv_count_file; + bool is_dlpno = cd_context.is_dlpno; + bool is_mso = cd_context.is_mso; + + // TODO: MO here is MSO, rename MO to MSO + TiledIndexSpace MO; + TAMM_SIZE total_orbitals; + if(ccsd_options.nactive > 0) { + // Only DUCC uses this right now + std::tie(MO, total_orbitals) = + cholesky_2e::setupMOIS(ec, chem_env, false, ccsd_options.nactive); + // TODO: Implement check for UHF + if(ccsd_options.nactive > sys_data.n_vir_alpha && sys_data.is_restricted) + tamm_terminate("[DUCC ERROR]: nactive > n_vir_alpha"); + } + else std::tie(MO, total_orbitals) = cholesky_2e::setupMOIS(ec, chem_env); + chem_env.is_context.MSO = MO; - write_to_disk(d_f1, f1file); - write_to_disk(cholVpr, v2file); + if(ccsd_options.skip_ccsd) { + Tensor::deallocate(C_AO, F_AO); + if(sys_data.is_unrestricted) Tensor::deallocate(C_beta_AO, F_beta_AO); + return; + } - if(rank == 0) { - std::ofstream out(cholfile, std::ios::out); - if(!out) cerr << "Error opening file " << cholfile << endl; - out << chol_count << std::endl; - out.close(); + bool& readv2 = cd_context.readv2; + readv2 = ccsd_options.readt || (fs::exists(cd_context.f1file) && fs::exists(cd_context.v2file)); + + if(readv2) { + // if(chem_env.run_context.contains("mso_tilesize")) + const int orig_ts = chem_env.run_context["mso_tilesize"]; + if(orig_ts != chem_env.is_context.mso_tilesize) { + std::string err_msg = + "\n[ERROR] Restarting a calculation requires the MO tilesize to be the same\n"; + err_msg += " - current tilesize (" + std::to_string(chem_env.is_context.mso_tilesize); + err_msg += ") does not match the original tilesize (" + std::to_string(orig_ts) + ")"; + tamm_terminate(err_msg); + } + } + else { + chem_env.run_context["mso_tilesize"] = chem_env.is_context.mso_tilesize; + if(chem_env.ioptions.task_options.ccsd_t) { + // not used currently, triples can be restarted with a different tilesize. + chem_env.run_context["mso_tilesize_triples"] = chem_env.is_context.mso_tilesize_triples; } + chem_env.write_run_context(); // write here as well in case a run gets killed midway. } - free_tensors(d_f1, cholVpr); - - ec.flush_and_sync(); - // delete ec; -} // End of cholesky_decomp_2e - -template -std::tuple, Tensor, Tensor, TAMM_SIZE, tamm::Tile, TiledIndexSpace> -exachem::cholesky_2e::cholesky_2e_driver(ChemEnv& chem_env, ExecutionContext& ec, - TiledIndexSpace& MO, TiledIndexSpace& AO, Tensor C_AO, - Tensor F_AO, Tensor C_beta_AO, Tensor F_beta_AO, - libint2::BasisSet& shells, - std::vector& shell_tile_map, bool readv2, - std::string cholfile, bool is_dlpno, bool is_mso) { - SystemData& sys_data = chem_env.sys_data; - CDOptions cd_options = chem_env.ioptions.cd_options; - auto diagtol = cd_options.diagtol; // tolerance for the max. diagonal + if(rank == 0) { + std::cout << std::endl + << "- Tilesize for the MSO space: " << chem_env.is_context.mso_tilesize << std::endl; + } + + auto diagtol = cd_options.diagtol; // tolerance for the max. diagonal cd_options.max_cvecs_factor = 2 * std::abs(std::log10(diagtol)); // TODO - tamm::Tile max_cvecs = cd_options.max_cvecs_factor * sys_data.nbf; + cd_context.max_cvecs = cd_options.max_cvecs_factor * sys_data.nbf; - std::cout << std::defaultfloat; - auto rank = ec.pg().rank(); - if(rank == 0) cd_options.print(); + int& chol_count = cd_context.num_chol_vecs; TiledIndexSpace N = MO("all"); - Tensor d_f1{{N, N}, {1, 1}}; - Tensor lcao{AO, N}; - Tensor::allocate(&ec, d_f1, lcao); + cd_context.d_f1 = Tensor{{N, N}, {1, 1}}; + cd_context.movecs_so = Tensor{AO, N}; + Tensor& movecs_so = cd_context.movecs_so; + Tensor::allocate(&ec, cd_context.d_f1, movecs_so); - auto hf_t1 = std::chrono::high_resolution_clock::now(); - TAMM_SIZE chol_count = 0; + auto hf_t1 = std::chrono::high_resolution_clock::now(); // std::tie(V2) = - Tensor cholVpr; - auto itile_size = chem_env.ioptions.cd_options.itilesize; + Tensor& cholVpr = cd_context.cholV2; + auto itile_size = cd_options.itilesize; - sys_data.freeze_atomic = chem_env.ioptions.ccsd_options.freeze_atomic; + sys_data.freeze_atomic = ccsd_options.freeze_atomic; sys_data.n_frozen_core = chem_env.get_nfcore(); - sys_data.n_frozen_virtual = chem_env.ioptions.ccsd_options.freeze_virtual; + sys_data.n_frozen_virtual = ccsd_options.freeze_virtual; bool do_freeze = sys_data.n_frozen_core > 0 || sys_data.n_frozen_virtual > 0; - std::string out_fp = chem_env.workspace_dir; - std::string files_dir = out_fp + chem_env.ioptions.scf_options.scf_type; - std::string lcaofile = files_dir + "/" + sys_data.output_file_prefix + ".lcao"; - auto skip_cd = cd_options.skip_cd; if(!readv2 && !skip_cd.first) { - exachem::cholesky_2e::two_index_transform(chem_env, ec, C_AO, F_AO, C_beta_AO, F_beta_AO, d_f1, - shells, lcao, is_dlpno || !is_mso); - if(!is_dlpno) - cholVpr = exachem::cholesky_2e::cholesky_2e(chem_env, ec, MO, AO, chol_count, max_cvecs, - shells, lcao, is_mso); - write_to_disk(lcao, lcaofile); + exachem::cholesky_2e::two_index_transform(chem_env, ec, C_AO, F_AO, C_beta_AO, F_beta_AO, + cd_context.d_f1, shells, movecs_so, + is_dlpno || !is_mso); + if(!is_dlpno) exachem::cholesky_2e::cholesky_2e(ec, chem_env); + write_to_disk(movecs_so, cd_context.movecs_so_file); + + if(ccsd_options.writet) { + if(!fs::exists(files_dir)) fs::create_directories(files_dir); + + write_to_disk(cd_context.d_f1, cd_context.f1file); + write_to_disk(cholVpr, cd_context.v2file); + + if(rank == 0) { + std::ofstream out(cholfile, std::ios::out); + if(!out) cerr << "Error opening file " << cholfile << std::endl; + out << chol_count << std::endl; + out.close(); + } + } } else { if(!skip_cd.first) { @@ -144,14 +168,23 @@ exachem::cholesky_2e::cholesky_2e_driver(ChemEnv& chem_env, ExecutionContext& ec IndexSpace chol_is{range(0, chol_count)}; TiledIndexSpace CI{chol_is, static_cast(itile_size)}; + chem_env.is_context.CI = CI; TiledIndexSpace N = MO("all"); cholVpr = {{N, N, CI}, {SpinPosition::upper, SpinPosition::lower, SpinPosition::ignore}}; if(!is_dlpno) Tensor::allocate(&ec, cholVpr); // Scheduler{ec}(cholVpr()=0).execute(); - if(!skip_cd.first) read_from_disk(lcao, lcaofile); + if(!skip_cd.first) read_from_disk(movecs_so, cd_context.movecs_so_file); + + if(readv2) { + read_from_disk(cd_context.d_f1, cd_context.f1file); + read_from_disk(cholVpr, cd_context.v2file); + ec.pg().barrier(); + } } + if(!cd_context.keep_movecs_so) free_tensors(movecs_so); + auto hf_t2 = std::chrono::high_resolution_clock::now(); double cholesky_2e_time = std::chrono::duration_cast>((hf_t2 - hf_t1)).count(); @@ -167,8 +200,9 @@ exachem::cholesky_2e::cholesky_2e_driver(ChemEnv& chem_env, ExecutionContext& ec IndexSpace chol_is{range(0, chol_count)}; TiledIndexSpace CI{chol_is, static_cast(itile_size)}; + chem_env.is_context.CI = CI; - chem_env.cd_context.num_chol_vectors = chol_count; + // cd_context.num_chol_vecs = chol_count; sys_data.results["output"]["CD"]["n_cholesky_vectors"] = chol_count; sys_data.results["output"]["CD"]["diagtol"] = chem_env.ioptions.cd_options.diagtol; @@ -180,13 +214,14 @@ exachem::cholesky_2e::cholesky_2e_driver(ChemEnv& chem_env, ExecutionContext& ec Tensor d_f1_new{{N_eff, N_eff}, {1, 1}}; Tensor::allocate(&ec, d_f1_new); if(rank == 0) { - Matrix f1_eig = tamm_to_eigen_matrix(d_f1); + Matrix f1_eig = tamm_to_eigen_matrix(cd_context.d_f1); Matrix f1_new_eig = exachem::cholesky_2e::reshape_mo_matrix(chem_env, f1_eig); eigen_to_tamm_tensor(d_f1_new, f1_new_eig); f1_new_eig.resize(0, 0); } - Tensor::deallocate(d_f1); - d_f1 = d_f1_new; + Tensor::deallocate(cd_context.d_f1); + cd_context.d_f1 = d_f1_new; + chem_env.is_context.MSO = MO; } if(!readv2 && chem_env.ioptions.scf_options.mos_txt) { @@ -203,41 +238,30 @@ exachem::cholesky_2e::cholesky_2e_driver(ChemEnv& chem_env, ExecutionContext& ec Tensor tmp{MO, AO}; // clang-format off sch.allocate(tmp) - (tmp(mo1,nu) = lcao(mu,mo1) * hcore(mu,nu)) - (hcore_mo(mo1,mo2) = tmp(mo1,nu) * lcao(nu,mo2)) + (tmp(mo1,nu) = movecs_so(mu,mo1) * hcore(mu,nu)) + (hcore_mo(mo1,mo2) = tmp(mo1,nu) * movecs_so(nu,mo2)) .deallocate(tmp,hcore).execute(); // clang-format on ExecutionContext ec_dense{ec.pg(), DistributionKind::dense, MemoryManagerKind::ga}; std::string mop_dir = files_dir + "/mos_txt/"; - std::string mofprefix = mop_dir + out_fp; + std::string mofprefix = mop_dir + chem_env.workspace_dir; if(!fs::exists(mop_dir)) fs::create_directories(mop_dir); - Tensor d_v2 = setupV2(ec, MO, CI, cholVpr, chol_count); - Tensor d_f1_dense = to_dense_tensor(ec_dense, d_f1); - Tensor lcao_dense = to_dense_tensor(ec_dense, lcao); - Tensor d_v2_dense = to_dense_tensor(ec_dense, d_v2); - Tensor hcore_dense = to_dense_tensor(ec_dense, hcore_mo); + Tensor d_v2 = setupV2(ec, MO, CI, cholVpr, chol_count); + Tensor d_f1_dense = to_dense_tensor(ec_dense, cd_context.d_f1); + Tensor movecs_so_dense = to_dense_tensor(ec_dense, movecs_so); + Tensor d_v2_dense = to_dense_tensor(ec_dense, d_v2); + Tensor hcore_dense = to_dense_tensor(ec_dense, hcore_mo); Tensor::deallocate(hcore_mo, d_v2); print_dense_tensor(d_v2_dense, mofprefix + ".v2_mo"); - print_dense_tensor(lcao_dense, mofprefix + ".ao2mo"); + print_dense_tensor(movecs_so_dense, mofprefix + ".movecs_so"); print_dense_tensor(d_f1_dense, mofprefix + ".fock_mo"); print_dense_tensor(hcore_dense, mofprefix + ".hcore_mo"); - Tensor::deallocate(hcore_dense, d_f1_dense, lcao_dense, d_v2_dense); + Tensor::deallocate(hcore_dense, d_f1_dense, movecs_so_dense, d_v2_dense); } - return std::make_tuple(cholVpr, d_f1, lcao, chol_count, max_cvecs, CI); } // END of cholesky_2e_driver - -using T = double; - -template std::tuple, Tensor, Tensor, TAMM_SIZE, tamm::Tile, TiledIndexSpace> -exachem::cholesky_2e::cholesky_2e_driver(ChemEnv& chem_env, ExecutionContext& ec, - TiledIndexSpace& MO, TiledIndexSpace& AO, - Tensor C_AO, Tensor F_AO, Tensor C_beta_AO, - Tensor F_beta_AO, libint2::BasisSet& shells, - std::vector& shell_tile_map, bool readv2, - std::string cholfile, bool is_dlpno, bool is_mso); diff --git a/exachem/cholesky/cholesky_2e_driver.hpp b/exachem/cholesky/cholesky_2e_driver.hpp index 319037c..aa6aa29 100644 --- a/exachem/cholesky/cholesky_2e_driver.hpp +++ b/exachem/cholesky/cholesky_2e_driver.hpp @@ -15,14 +15,6 @@ namespace exachem::cholesky_2e { -template -std::tuple, Tensor, Tensor, TAMM_SIZE, tamm::Tile, TiledIndexSpace> -cholesky_2e_driver(ChemEnv& chem_env, ExecutionContext& ec, TiledIndexSpace& MO, - TiledIndexSpace& AO, Tensor C_AO, Tensor F_AO, Tensor C_beta_AO, - Tensor F_beta_AO, libint2::BasisSet& shells, - std::vector& shell_tile_map, bool readv2 = false, - std::string cholfile = "", bool is_dlpno = false, bool is_mso = true); - -void cholesky_decomp_2e(ExecutionContext& ec, ChemEnv& chem_env); +void cholesky_2e_driver(ExecutionContext& ec, ChemEnv& chem_env); } // namespace exachem::cholesky_2e diff --git a/exachem/common/chemenv.cpp b/exachem/common/chemenv.cpp index bc270b9..5d667ad 100644 --- a/exachem/common/chemenv.cpp +++ b/exachem/common/chemenv.cpp @@ -26,6 +26,37 @@ int ChemEnv::get_nfcore() { return ioptions.ccsd_options.freeze_core; } +void ChemEnv::read_run_context() { + std::string files_prefix = get_files_prefix(); + std::string json_file = files_prefix + ".runcontext.json"; + bool json_exists = std::filesystem::exists(json_file); + if(json_exists) { + std::ifstream jread(json_file); + jread >> run_context; + } + // else { + // std::string err_msg = "\n[ERROR] " + json_file + " does not exist!" + // tamm_terminate(err_msg); + // } +} + +void ChemEnv::write_run_context() { + std::string files_dir = get_files_dir(); + if(!fs::exists(files_dir)) fs::create_directories(files_dir); + std::string files_prefix = get_files_prefix(); + std::string json_file = files_prefix + ".runcontext.json"; + bool json_exists = std::filesystem::exists(json_file); + if(json_exists) { + // std::ifstream jread(json_file); + // jread >> run_context; + std::filesystem::remove(json_file); + } + + // std::cout << std::endl << std::endl << run_context.dump() << std::endl; + std::ofstream res_file(json_file); + res_file << std::setw(2) << run_context << std::endl; +} + void ChemEnv::write_sinfo() { std::string basis = ioptions.scf_options.basis; @@ -75,23 +106,22 @@ void ChemEnv::write_json_data(const std::string cmodule) { results["input"]["common"] = jinput["common"]; // SCF options - results["input"]["SCF"]["charge"] = scf.charge; - results["input"]["SCF"]["multiplicity"] = scf.multiplicity; - results["input"]["SCF"]["lshift"] = scf.lshift; - results["input"]["SCF"]["tol_int"] = scf.tol_int; - results["input"]["SCF"]["tol_sch"] = scf.tol_sch; - results["input"]["SCF"]["tol_lindep"] = scf.tol_lindep; - results["input"]["SCF"]["conve"] = scf.conve; - results["input"]["SCF"]["convd"] = scf.convd; - results["input"]["SCF"]["diis_hist"] = scf.diis_hist; - results["input"]["SCF"]["AO_tilesize"] = scf.AO_tilesize; - results["input"]["SCF"]["force_tilesize"] = str_bool(scf.force_tilesize); - results["input"]["SCF"]["damp"] = scf.damp; - results["input"]["SCF"]["debug"] = str_bool(scf.debug); - results["input"]["SCF"]["restart"] = str_bool(scf.restart); - results["input"]["SCF"]["noscf"] = str_bool(scf.noscf); - results["input"]["SCF"]["scf_type"] = scf.scf_type; - results["input"]["SCF"]["direct_df"] = str_bool(scf.direct_df); + results["input"]["SCF"]["charge"] = scf.charge; + results["input"]["SCF"]["multiplicity"] = scf.multiplicity; + results["input"]["SCF"]["lshift"] = scf.lshift; + results["input"]["SCF"]["tol_int"] = scf.tol_int; + results["input"]["SCF"]["tol_sch"] = scf.tol_sch; + results["input"]["SCF"]["tol_lindep"] = scf.tol_lindep; + results["input"]["SCF"]["conve"] = scf.conve; + results["input"]["SCF"]["convd"] = scf.convd; + results["input"]["SCF"]["diis_hist"] = scf.diis_hist; + results["input"]["SCF"]["AO_tilesize"] = scf.AO_tilesize; + results["input"]["SCF"]["damp"] = scf.damp; + results["input"]["SCF"]["debug"] = str_bool(scf.debug); + results["input"]["SCF"]["restart"] = str_bool(scf.restart); + results["input"]["SCF"]["noscf"] = str_bool(scf.noscf); + results["input"]["SCF"]["scf_type"] = scf.scf_type; + results["input"]["SCF"]["direct_df"] = str_bool(scf.direct_df); if(!scf.dfbasis.empty()) results["input"]["SCF"]["dfAO_tilesize"] = scf.dfAO_tilesize; if(!scf.xc_type.empty() || scf.snK) { @@ -139,18 +169,17 @@ void ChemEnv::write_json_data(const std::string cmodule) { if(cmodule == "CCSD") { // CCSD options - results["input"][cmodule]["tilesize"] = ccsd.tilesize; - results["input"][cmodule]["force_tilesize"] = str_bool(ccsd.force_tilesize); - results["input"][cmodule]["lshift"] = ccsd.lshift; - results["input"][cmodule]["ndiis"] = ccsd.ndiis; - results["input"][cmodule]["readt"] = str_bool(ccsd.readt); - results["input"][cmodule]["writet"] = str_bool(ccsd.writet); - results["input"][cmodule]["writet_iter"] = ccsd.writet_iter; - results["input"][cmodule]["ccsd_maxiter"] = ccsd.ccsd_maxiter; - results["input"][cmodule]["nactive"] = ccsd.nactive; - results["input"][cmodule]["debug"] = ccsd.debug; - results["input"][cmodule]["profile_ccsd"] = ccsd.profile_ccsd; - results["input"][cmodule]["balance_tiles"] = str_bool(ccsd.balance_tiles); + results["input"][cmodule]["tilesize"] = ccsd.tilesize; + results["input"][cmodule]["lshift"] = ccsd.lshift; + results["input"][cmodule]["ndiis"] = ccsd.ndiis; + results["input"][cmodule]["readt"] = str_bool(ccsd.readt); + results["input"][cmodule]["writet"] = str_bool(ccsd.writet); + results["input"][cmodule]["writet_iter"] = ccsd.writet_iter; + results["input"][cmodule]["ccsd_maxiter"] = ccsd.ccsd_maxiter; + results["input"][cmodule]["nactive"] = ccsd.nactive; + results["input"][cmodule]["debug"] = ccsd.debug; + results["input"][cmodule]["profile_ccsd"] = ccsd.profile_ccsd; + results["input"][cmodule]["balance_tiles"] = str_bool(ccsd.balance_tiles); results["input"][cmodule]["freeze"]["atomic"] = ccsd.freeze_atomic; results["input"][cmodule]["freeze"]["core"] = ccsd.freeze_core; diff --git a/exachem/common/chemenv.hpp b/exachem/common/chemenv.hpp index 5509eb8..99d9700 100644 --- a/exachem/common/chemenv.hpp +++ b/exachem/common/chemenv.hpp @@ -14,6 +14,8 @@ // #include "libint2_includes.hpp" #include "exachem/common/context/cc_context.hpp" #include "exachem/common/context/cd_context.hpp" +#include "exachem/common/context/is_context.hpp" +#include "exachem/common/context/scf_context.hpp" #include "exachem/common/txt_utils.hpp" #include "tamm/tamm.hpp" @@ -36,46 +38,37 @@ class ChemEnv { SystemData sys_data; ECOptions ioptions; ECBasis ec_basis; + json run_context; std::vector atoms; std::vector ec_atoms; - - double hf_energy{0.0}; - libint2::BasisSet shells; - std::vector shell_tile_map; - tamm::Tensor C_AO; - tamm::Tensor F_AO; - tamm::Tensor C_beta_AO; - tamm::Tensor F_beta_AO; - TiledIndexSpace AO_opt; - TiledIndexSpace AO_tis; - TiledIndexSpace AO_ortho; - bool no_scf; + libint2::BasisSet shells; std::string workspace_dir{}; - CDContext cd_context; - CCContext cc_context; + SCFContext scf_context; + CDContext cd_context; + CCContext cc_context; + ISContext is_context; // IndexSpaces + void read_run_context(); + void write_run_context(); void write_json_data(const std::string cmodule); Matrix compute_shellblock_norm(const libint2::BasisSet& obs, const Matrix& A); - void update(double hf_energy, libint2::BasisSet shells, std::vector shell_tile_map, - tamm::Tensor C_AO, tamm::Tensor F_AO, - tamm::Tensor C_beta_AO, tamm::Tensor F_beta_AO, - TiledIndexSpace AO_opt, TiledIndexSpace AO_tis, TiledIndexSpace AO_ortho, - bool no_scf) { - this->hf_energy = hf_energy; - this->shells = shells; - this->shell_tile_map = shell_tile_map; - this->C_AO = C_AO; - this->F_AO = F_AO; - this->C_beta_AO = C_beta_AO; - this->F_beta_AO = F_beta_AO; - this->AO_opt = AO_opt; - this->AO_tis = AO_tis; - this->AO_ortho = AO_ortho; - this->no_scf = no_scf; + std::string get_files_dir(std::string scf_type = "") { + if(scf_type.empty()) scf_type = ioptions.scf_options.scf_type; + const std::string files_dir = workspace_dir + scf_type; + return files_dir; + } + + std::string get_files_prefix(std::string scf_type = "") { + if(scf_type.empty()) scf_type = ioptions.scf_options.scf_type; + + const std::string out_fp = workspace_dir; + const std::string files_dir = out_fp + scf_type; + const std::string files_prefix = files_dir + "/" + sys_data.output_file_prefix; + return files_prefix; } }; diff --git a/exachem/common/common.cmake b/exachem/common/common.cmake index b470ac1..a075f1d 100644 --- a/exachem/common/common.cmake +++ b/exachem/common/common.cmake @@ -14,8 +14,10 @@ set(COMMON_INCLUDES ${COMMON_SRCDIR}/ec_dplot.hpp ${COMMON_SRCDIR}/ec_molden.hpp ${COMMON_SRCDIR}/libint2_includes.hpp + ${COMMON_SRCDIR}/context/is_context.hpp ${COMMON_SRCDIR}/context/cd_context.hpp ${COMMON_SRCDIR}/context/cc_context.hpp + ${COMMON_SRCDIR}/context/scf_context.hpp ${COMMON_SRCDIR}/options/parse_options.hpp ${COMMON_SRCDIR}/options/parse_common_options.hpp ${COMMON_SRCDIR}/options/parse_scf_options.hpp diff --git a/exachem/common/context/cc_context.hpp b/exachem/common/context/cc_context.hpp index a59eac2..4aaff34 100644 --- a/exachem/common/context/cc_context.hpp +++ b/exachem/common/context/cc_context.hpp @@ -31,4 +31,25 @@ class CCContext { double ccsd_st_correction_energy{0}; double ccsd_st_correlation_energy{0}; double ccsd_st_total_energy{0}; + + // tensor files + std::string t1file; + std::string t2file; + std::string t2_11file; + std::string t2_21file; + std::string t2_12file; + std::string t2_22file; + std::string ccsdstatus; + + void init_filenames(std::string files_prefix) { + this->t1file = files_prefix + ".t1amp"; + this->t2file = files_prefix + ".t2amp"; + + this->t2_11file = files_prefix + ".t2_11amp"; + this->t2_21file = files_prefix + ".t2_21amp"; + this->t2_12file = files_prefix + ".t2_12amp"; + this->t2_22file = files_prefix + ".t2_22amp"; + + this->ccsdstatus = files_prefix + ".ccsdstatus"; + } }; \ No newline at end of file diff --git a/exachem/common/context/cd_context.hpp b/exachem/common/context/cd_context.hpp index ca0a51e..86ddd80 100644 --- a/exachem/common/context/cd_context.hpp +++ b/exachem/common/context/cd_context.hpp @@ -7,11 +7,38 @@ */ #pragma once -// #include "tamm/tamm.hpp" +#include "tamm/tamm.hpp" class CDContext { public: CDContext() = default; - int num_chol_vectors{0}; + int num_chol_vecs{0}; + int max_cvecs{0}; + Tensor movecs_so; // spin-orbital movecs + Tensor d_f1; // Fock in MO + Tensor cholV2; // 2e ints in MO + Tensor d_v2; // full V2 in MO + + std::string movecs_so_file; + std::string f1file; + std::string v2file; + std::string cv_count_file; + std::string fullV2file; + + bool readv2 = false; + bool is_dlpno = false; + bool is_mso = true; + + bool keep_movecs_so{false}; + + void init_filenames(std::string files_prefix) { + this->f1file = files_prefix + ".f1_mo"; + this->v2file = files_prefix + ".cholv2"; + this->fullV2file = files_prefix + ".fullV2"; + this->cv_count_file = files_prefix + ".cholcount"; + this->movecs_so_file = files_prefix + ".movecs_so"; + } + + void read_movecs_so() { tamm::read_from_disk(movecs_so, movecs_so_file); } }; \ No newline at end of file diff --git a/exachem/common/context/is_context.hpp b/exachem/common/context/is_context.hpp new file mode 100644 index 0000000..c60fec3 --- /dev/null +++ b/exachem/common/context/is_context.hpp @@ -0,0 +1,27 @@ +/* + * ExaChem: Open Source Exascale Computational Chemistry Software. + * + * Copyright 2023-2024 Pacific Northwest National Laboratory, Battelle Memorial Institute. + * + * See LICENSE.txt for details + */ + +#pragma once +#include "tamm/tamm.hpp" + +class ISContext { +public: + ISContext() = default; + + TiledIndexSpace AO_opt; // large tilesize based + TiledIndexSpace AO_tis; // shell tiles + TiledIndexSpace AO_ortho; // opt for Northo dim + TiledIndexSpace MO; + TiledIndexSpace MSO; // MSO used in all CC methods + TiledIndexSpace CI; // cholesky vectors space + + int ao_tilesize{30}; + int dfao_tilesize{30}; + int mso_tilesize{40}; + int mso_tilesize_triples{40}; +}; \ No newline at end of file diff --git a/exachem/common/context/scf_context.hpp b/exachem/common/context/scf_context.hpp new file mode 100644 index 0000000..b29dfe7 --- /dev/null +++ b/exachem/common/context/scf_context.hpp @@ -0,0 +1,39 @@ +/* + * ExaChem: Open Source Exascale Computational Chemistry Software. + * + * Copyright 2023-2024 Pacific Northwest National Laboratory, Battelle Memorial Institute. + * + * See LICENSE.txt for details + */ + +#pragma once +#include "tamm/tamm.hpp" + +class SCFContext { +public: + SCFContext() = default; + + using TensorType = double; + double hf_energy{0.0}; + std::vector shell_tile_map; + tamm::Tensor C_AO; + tamm::Tensor F_AO; + tamm::Tensor C_beta_AO; + tamm::Tensor F_beta_AO; + bool no_scf; + bool do_df; + + bool scf_converged{false}; + + void update(double hf_energy, std::vector shell_tile_map, tamm::Tensor C_AO, + tamm::Tensor F_AO, tamm::Tensor C_beta_AO, + tamm::Tensor F_beta_AO, bool no_scf) { + this->hf_energy = hf_energy; + this->shell_tile_map = shell_tile_map; + this->C_AO = C_AO; + this->F_AO = F_AO; + this->C_beta_AO = C_beta_AO; + this->F_beta_AO = F_beta_AO; + this->no_scf = no_scf; + } +}; \ No newline at end of file diff --git a/exachem/common/options/input_options.cpp b/exachem/common/options/input_options.cpp index e5e8da3..9186635 100644 --- a/exachem/common/options/input_options.cpp +++ b/exachem/common/options/input_options.cpp @@ -225,7 +225,6 @@ void CommonOptions::print() { void CCSDOptions::initialize() { threshold = 1e-6; - force_tilesize = false; tilesize = 40; ndiis = 5; lshift = 0; diff --git a/exachem/common/options/input_options.hpp b/exachem/common/options/input_options.hpp index f382418..a73ed46 100644 --- a/exachem/common/options/input_options.hpp +++ b/exachem/common/options/input_options.hpp @@ -54,7 +54,6 @@ class SCFOptions: public CommonOptions { bool restart{false}; // Read movecs from disk bool noscf{false}; // only recompute energy from movecs bool sad{true}; - bool force_tilesize{false}; bool direct_df{false}; bool snK{false}; int restart_size{2000}; // read/write orthogonalizer, schwarz, etc matrices when N>=restart_size @@ -106,7 +105,6 @@ class CCSDOptions: public CommonOptions { CCSDOptions(): CommonOptions() { initialize(); } int tilesize; - bool force_tilesize; int ndiis; int writet_iter; bool readt, writet, writev, gf_restart, gf_ip, gf_ea, gf_os, gf_cs, gf_itriples, gf_profile, diff --git a/exachem/common/options/parse_ccsd_options.cpp b/exachem/common/options/parse_ccsd_options.cpp index 23ea412..9bb8657 100644 --- a/exachem/common/options/parse_ccsd_options.cpp +++ b/exachem/common/options/parse_ccsd_options.cpp @@ -22,7 +22,7 @@ void ParseCCSDOptions::parse_check(json& jinput) { // clang-format off const std::vector valid_cc{ "CCSD(T)", "DLPNO", "EOMCCSD", "RT-EOMCC", "GFCCSD", - "comments", "threshold", "force_tilesize", "tilesize", "computeTData", + "comments", "threshold", "tilesize", "computeTData", "lshift", "ndiis", "ccsd_maxiter", "freeze", "PRINT", "readt", "writet", "writev", "writet_iter", "debug", "nactive", "profile_ccsd", "balance_tiles", "ext_data_path"}; @@ -51,7 +51,6 @@ void ParseCCSDOptions::parse(ChemEnv& chem_env) { parse_option(cc_options.writet_iter, jcc, "writet_iter"); parse_option(cc_options.balance_tiles, jcc, "balance_tiles"); parse_option(cc_options.profile_ccsd, jcc, "profile_ccsd"); - parse_option(cc_options.force_tilesize, jcc, "force_tilesize"); parse_option(cc_options.ext_data_path, jcc, "ext_data_path"); parse_option(cc_options.computeTData, jcc, "computeTData"); diff --git a/exachem/common/options/parse_scf_options.cpp b/exachem/common/options/parse_scf_options.cpp index 7ab5233..832e54a 100644 --- a/exachem/common/options/parse_scf_options.cpp +++ b/exachem/common/options/parse_scf_options.cpp @@ -21,7 +21,7 @@ void ParseSCFOptions::operator()(ChemEnv& chem_env) { void ParseSCFOptions::parse_check(json& jinput) { // clang-format off const std::vector valid_scf{"charge", "multiplicity", "lshift", "tol_int", "tol_sch", - "tol_lindep", "conve", "convd", "diis_hist","force_tilesize","tilesize","df_tilesize", + "tol_lindep", "conve", "convd", "diis_hist","tilesize","df_tilesize", "damp","writem","nnodes","restart","noscf", "molden", "moldenfile", "guess", "debug","scf_type", "n_lindep","restart_size","scalapack_nb", "scalapack_np_row", "scalapack_np_col", "ext_data_path", "PRINT", @@ -57,7 +57,6 @@ void ParseSCFOptions::parse(ChemEnv& chem_env) { parse_option(scf_options.conve, jscf, "conve"); parse_option(scf_options.convd, jscf, "convd"); parse_option(scf_options.diis_hist, jscf, "diis_hist"); - parse_option(scf_options.force_tilesize, jscf, "force_tilesize"); parse_option(scf_options.AO_tilesize, jscf, "tilesize"); parse_option(scf_options.dfAO_tilesize, jscf, "df_tilesize"); parse_option(scf_options.damp, jscf, "damp"); diff --git a/exachem/fci/fci.cpp b/exachem/fci/fci.cpp index 98bfd4b..45509f1 100644 --- a/exachem/fci/fci.cpp +++ b/exachem/fci/fci.cpp @@ -63,69 +63,21 @@ std::string generate_fcidump(ChemEnv& chem_env, ExecutionContext& ec, const Tile } void fci_driver(ExecutionContext& ec, ChemEnv& chem_env) { - using T = double; - + using T = double; auto rank = ec.pg().rank(); - scf::scf_driver(ec, chem_env); - - // double hf_energy = chem_env.hf_energy; - libint2::BasisSet shells = chem_env.shells; - Tensor C_AO = chem_env.C_AO; - Tensor C_beta_AO = chem_env.C_beta_AO; - Tensor F_AO = chem_env.F_AO; - Tensor F_beta_AO = chem_env.F_beta_AO; - TiledIndexSpace AO_opt = chem_env.AO_opt; - TiledIndexSpace AO_tis = chem_env.AO_tis; - std::vector shell_tile_map = chem_env.shell_tile_map; - - SystemData sys_data = chem_env.sys_data; - CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; - if(rank == 0) ccsd_options.print(); - - if(rank == 0) - cout << endl << "#occupied, #virtual = " << sys_data.nocc << ", " << sys_data.nvir << endl; - - auto [MO, total_orbitals] = cholesky_2e::setupMOIS(ec, chem_env); + cholesky_2e::cholesky_2e_driver(ec, chem_env); - std::string out_fp = chem_env.workspace_dir; - std::string files_dir = out_fp + chem_env.ioptions.scf_options.scf_type; - std::string files_prefix = /*out_fp;*/ files_dir + "/" + sys_data.output_file_prefix; - std::string f1file = files_prefix + ".f1_mo"; - std::string v2file = files_prefix + ".cholv2"; - std::string cholfile = files_prefix + ".cholcount"; - - ExecutionHW ex_hw = ec.exhw(); + std::string files_prefix = chem_env.get_files_prefix(); - bool ccsd_restart = ccsd_options.readt || (fs::exists(f1file) && fs::exists(v2file)); + CDContext& cd_context = chem_env.cd_context; + chem_env.cc_context.init_filenames(files_prefix); - // deallocates F_AO, C_AO - auto [cholVpr, d_f1, lcao, chol_count, max_cvecs, CI] = - cholesky_2e::cholesky_2e_driver(chem_env, ec, MO, AO_opt, C_AO, F_AO, C_beta_AO, F_beta_AO, - shells, shell_tile_map, ccsd_restart, cholfile); - - TiledIndexSpace N = MO("all"); - - if(ccsd_restart) { - read_from_disk(d_f1, f1file); - read_from_disk(cholVpr, v2file); - ec.pg().barrier(); - } - - else if(ccsd_options.writet) { - // fs::remove_all(files_dir); - if(!fs::exists(files_dir)) fs::create_directories(files_dir); - - write_to_disk(d_f1, f1file); - write_to_disk(cholVpr, v2file); - - if(rank == 0) { - std::ofstream out(cholfile, std::ios::out); - if(!out) cerr << "Error opening file " << cholfile << endl; - out << chol_count << std::endl; - out.close(); - } - } + TiledIndexSpace& MO = chem_env.is_context.MSO; + TiledIndexSpace& CI = chem_env.is_context.CI; + TiledIndexSpace N = MO("all"); + Tensor d_f1 = cd_context.d_f1; + Tensor cholVpr = cd_context.cholV2; ec.pg().barrier(); @@ -135,6 +87,8 @@ void fci_driver(ExecutionContext& ec, ChemEnv& chem_env) { Tensor full_v2{N, N, N, N}; Tensor::allocate(&ec, full_v2); + ExecutionHW ex_hw = ec.exhw(); + // clang-format off Scheduler sch{ec}; sch(full_v2(p, r, q, s) = cholVpr(p, r, cindex) * cholVpr(q, s, cindex)).execute(ex_hw); @@ -142,6 +96,8 @@ void fci_driver(ExecutionContext& ec, ChemEnv& chem_env) { free_tensors(cholVpr); + Tensor lcao = cd_context.movecs_so; + files_prefix = generate_fcidump(chem_env, ec, MO, lcao, d_f1, full_v2, ex_hw); #if defined(USE_MACIS) if(options_map.task_options.fci) diff --git a/exachem/mp2/cd_mp2.cpp b/exachem/mp2/cd_mp2.cpp index 44ca061..a213dea 100644 --- a/exachem/mp2/cd_mp2.cpp +++ b/exachem/mp2/cd_mp2.cpp @@ -14,72 +14,22 @@ namespace exachem::mp2 { void cd_mp2(ExecutionContext& ec, ChemEnv& chem_env) { - namespace fs = std::filesystem; - using T = double; - + using T = double; auto rank = ec.pg().rank(); - scf::scf_driver(ec, chem_env); - SystemData sys_data = chem_env.sys_data; - - libint2::BasisSet shells = chem_env.shells; - Tensor C_AO = chem_env.C_AO; - Tensor C_beta_AO = chem_env.C_beta_AO; - Tensor F_AO = chem_env.F_AO; - Tensor F_beta_AO = chem_env.F_beta_AO; - TiledIndexSpace AO_opt = chem_env.AO_opt; - std::vector shell_tile_map = chem_env.shell_tile_map; + cholesky_2e::cholesky_2e_driver(ec, chem_env); - CCSDOptions& ccsd_options = chem_env.ioptions.ccsd_options; - if(rank == 0) ccsd_options.print(); + Scheduler sch{ec}; - if(rank == 0) - std::cout << std::endl - << "#occupied, #virtual = " << sys_data.nocc << ", " << sys_data.nvir << std::endl; + SystemData sys_data = chem_env.sys_data; + TiledIndexSpace& MO = chem_env.is_context.MSO; + TiledIndexSpace& CI = chem_env.is_context.CI; - auto [MO, total_orbitals] = cholesky_2e::setupMOIS(ec, chem_env); + Tensor d_f1 = chem_env.cd_context.d_f1; + Tensor cholVpr = chem_env.cd_context.cholV2; const bool is_rhf = sys_data.is_restricted; - std::string out_fp = chem_env.workspace_dir; - std::string files_dir = out_fp + chem_env.ioptions.scf_options.scf_type; - std::string files_prefix = /*out_fp;*/ files_dir + "/" + sys_data.output_file_prefix; - std::string f1file = files_prefix + ".f1_mo"; - std::string t1file = files_prefix + ".t1amp"; - std::string t2file = files_prefix + ".t2amp"; - std::string v2file = files_prefix + ".cholv2"; - std::string cholfile = files_prefix + ".cholcount"; - std::string ccsdstatus = files_prefix + ".ccsdstatus"; - - bool mp2_restart = ccsd_options.readt || (fs::exists(f1file) && fs::exists(v2file)); - - // deallocates F_AO, C_AO - auto [cholVpr, d_f1, lcao, chol_count, max_cvecs, CI] = - cholesky_2e::cholesky_2e_driver(chem_env, ec, MO, AO_opt, C_AO, F_AO, C_beta_AO, F_beta_AO, - shells, shell_tile_map, mp2_restart, cholfile); - free_tensors(lcao); - - if(mp2_restart) { - read_from_disk(d_f1, f1file); - read_from_disk(cholVpr, v2file); - ec.pg().barrier(); - } - - else if(ccsd_options.writet) { - if(!fs::exists(files_dir)) fs::create_directories(files_dir); - - write_to_disk(d_f1, f1file); - write_to_disk(cholVpr, v2file); - - if(rank == 0) { - std::ofstream out(cholfile, std::ios::out); - if(!out) cerr << "Error opening file " << cholfile << std::endl; - out << chol_count << std::endl; - out.close(); - } - } - - Scheduler sch{ec}; // get Eigen values std::vector p_evl_sorted = tamm::diagonal(d_f1); // split into occupied and virtual parts diff --git a/exachem/scf/scf_compute.cpp b/exachem/scf/scf_compute.cpp index 837073f..0442bb7 100644 --- a/exachem/scf/scf_compute.cpp +++ b/exachem/scf/scf_compute.cpp @@ -248,13 +248,22 @@ std::tuple exachem::scf::SCFCompute::compute_NRE(const ExecutionCon return std::make_tuple(nelectron, enuc); } -void exachem::scf::SCFCompute::recompute_tilesize(tamm::Tile& tile_size, const int N, - const bool force_ts, const bool rank0) { - // heuristic to set tilesize to atleast 5% of nbf - if(tile_size < N * 0.05 && !force_ts) { +void exachem::scf::SCFCompute::recompute_tilesize(ExecutionContext& ec, ChemEnv& chem_env, + bool is_df) { + // heuristic to set tilesize to atleast 5% of nbf if user has not provided a tilesize + const auto N = is_df ? chem_env.sys_data.ndf : chem_env.shells.nbf(); + const std::string jkey = is_df ? "df_tilesize" : "tilesize"; + const bool user_ts = chem_env.jinput["SCF"].contains(jkey) ? true : false; + tamm::Tile& tile_size = is_df ? chem_env.ioptions.scf_options.dfAO_tilesize + : chem_env.ioptions.scf_options.AO_tilesize; + + if(tile_size < N * 0.05 && !user_ts) { tile_size = std::ceil(N * 0.05); - if(rank0) cout << "***** Reset tilesize to nbf*5% = " << tile_size << endl; + if(ec.print()) cout << "***** Reset tilesize to nbf*5% = " << tile_size << endl; } + + if(!is_df) chem_env.is_context.ao_tilesize = tile_size; + else chem_env.is_context.dfao_tilesize = tile_size; } std::tuple, std::vector, std::vector> diff --git a/exachem/scf/scf_compute.hpp b/exachem/scf/scf_compute.hpp index 665df87..69bd8e2 100644 --- a/exachem/scf/scf_compute.hpp +++ b/exachem/scf/scf_compute.hpp @@ -40,8 +40,7 @@ class SCFCompute { compute_AO_tiles(const ExecutionContext& ec, ChemEnv& chem_env, libint2::BasisSet& shells, const bool is_df = false); - void recompute_tilesize(tamm::Tile& tile_size, const int N, const bool force_ts, - const bool rank0); + void recompute_tilesize(ExecutionContext& ec, ChemEnv& chem_env, bool is_df = false); template void compute_sdens_to_cdens(const libint2::BasisSet& shells, Matrix& Spherical, Matrix& Cartesian, diff --git a/exachem/scf/scf_hartree_fock.cpp b/exachem/scf/scf_hartree_fock.cpp index 6cf4814..97040a3 100644 --- a/exachem/scf/scf_hartree_fock.cpp +++ b/exachem/scf/scf_hartree_fock.cpp @@ -55,7 +55,8 @@ void exachem::scf::SCFHartreeFock::initialize_variables(ExecutionContext& exc, C scf_vars.lshift = chem_env.ioptions.scf_options.lshift; if(!chem_env.ioptions.scf_options.dfbasis.empty()) do_density_fitting = true; - scf_vars.do_dens_fit = do_density_fitting; + scf_vars.do_dens_fit = do_density_fitting; + chem_env.scf_context.do_df = do_density_fitting; if(!do_density_fitting || scf_vars.direct_df || chem_env.sys_data.is_ks || chem_env.sys_data.do_snK) { @@ -431,8 +432,7 @@ void exachem::scf::SCFHartreeFock::setup_tiled_index_space(ExecutionContext& exc auto rank = exc.pg().rank(); const int N = chem_env.shells.nbf(); AO = {range(0, N)}; - scf_compute.recompute_tilesize(chem_env.ioptions.scf_options.AO_tilesize, N, - chem_env.ioptions.scf_options.force_tilesize, rank == 0); + scf_compute.recompute_tilesize(exc, chem_env); std::tie(scf_vars.shell_tile_map, scf_vars.AO_tiles, scf_vars.AO_opttiles) = scf_compute.compute_AO_tiles(exc, chem_env, chem_env.shells); scf_vars.tAO = {AO, scf_vars.AO_opttiles}; @@ -543,9 +543,7 @@ void exachem::scf::SCFHartreeFock::setup_density_fitting(ExecutionContext& exc, chem_env.sys_data.ndf = scf_vars.dfbs.nbf(); scf_vars.dfAO = IndexSpace{range(0, chem_env.sys_data.ndf)}; - scf_compute.recompute_tilesize(chem_env.ioptions.scf_options.dfAO_tilesize, - chem_env.sys_data.ndf, - chem_env.ioptions.scf_options.force_tilesize, rank == 0); + scf_compute.recompute_tilesize(exc, chem_env, true); std::tie(scf_vars.df_shell_tile_map, scf_vars.dfAO_tiles, scf_vars.dfAO_opttiles) = scf_compute.compute_AO_tiles(exc, chem_env, scf_vars.dfbs, true); @@ -1283,7 +1281,12 @@ void exachem::scf::SCFHartreeFock::scf_hf(ExecutionContext& exc, ChemEnv& chem_e update_movecs(exc, chem_env); - chem_env.update(ehf, chem_env.shells, scf_vars.shell_tile_map, C_alpha_tamm, Fa_global, - C_beta_tamm, Fb_global, scf_vars.tAO, scf_vars.tAOt, tAO_ortho, - chem_env.ioptions.scf_options.noscf); + chem_env.is_context.AO_opt = scf_vars.tAO; + chem_env.is_context.AO_tis = scf_vars.tAOt; + chem_env.is_context.AO_ortho = tAO_ortho; + + chem_env.scf_context.scf_converged = true; + + chem_env.scf_context.update(ehf, scf_vars.shell_tile_map, C_alpha_tamm, Fa_global, C_beta_tamm, + Fb_global, chem_env.ioptions.scf_options.noscf); } // END of scf_hf(ExecutionContext& exc, ChemEnv& chem_env) diff --git a/exachem/scf/scf_restart.cpp b/exachem/scf/scf_restart.cpp index 63e8d8d..e58c8a0 100644 --- a/exachem/scf/scf_restart.cpp +++ b/exachem/scf/scf_restart.cpp @@ -14,7 +14,26 @@ void exachem::scf::SCFRestart::operator()(const ExecutionContext& ec, ChemEnv& c std::string files_prefix) { bool restart = chem_env.ioptions.scf_options.restart || chem_env.ioptions.scf_options.noscf; - if(!restart) return; + // if(!restart) return; + + if(restart) { + const int orig_ts = chem_env.run_context["ao_tilesize"]; + if(orig_ts != chem_env.is_context.ao_tilesize) { + std::string err_msg = + "\n[ERROR] Restarting a calculation requires the AO tilesize to be the same\n"; + err_msg += " - current tilesize (" + std::to_string(chem_env.is_context.ao_tilesize); + err_msg += ") does not match the original tilesize (" + std::to_string(orig_ts) + ")"; + tamm_terminate(err_msg); + } + } + else { + chem_env.run_context["ao_tilesize"] = chem_env.is_context.ao_tilesize; + if(chem_env.scf_context.do_df) + chem_env.run_context["dfao_tilesize"] = chem_env.is_context.dfao_tilesize; + chem_env.write_run_context(); // write here as well in case we kill an SCF run midway + return; + } + const auto rank = ec.pg().rank(); const bool is_uhf = (chem_env.sys_data.is_unrestricted); diff --git a/exachem/task/ec_task.cpp b/exachem/task/ec_task.cpp index c62fa29..aa9f7e9 100644 --- a/exachem/task/ec_task.cpp +++ b/exachem/task/ec_task.cpp @@ -10,10 +10,7 @@ namespace exachem::task { -void execute_task(ExecutionContext& ec, ChemEnv& chem_env, std::string ec_arg2) { - const auto task = chem_env.ioptions.task_options; - const auto input_file = chem_env.input_file; - +void print_geometry(ExecutionContext& ec, ChemEnv& chem_env) { if(ec.print()) { std::cout << std::endl << std::string(60, '-') << std::endl; for(auto ecatom: chem_env.ec_atoms) { @@ -24,17 +21,25 @@ void execute_task(ExecutionContext& ec, ChemEnv& chem_env, std::string ec_arg2) << ecatom.atom.z << std::endl; } } +} + +void execute_task(ExecutionContext& ec, ChemEnv& chem_env, std::string ec_arg2) { + const auto task = chem_env.ioptions.task_options; + const auto input_file = chem_env.input_file; + + print_geometry(ec, chem_env); if(task.sinfo) chem_env.sinfo(); else if(task.scf) { scf::scf_driver(ec, chem_env); - Tensor::deallocate(chem_env.C_AO, chem_env.F_AO); + Tensor::deallocate(chem_env.scf_context.C_AO, chem_env.scf_context.F_AO); if(chem_env.sys_data.is_unrestricted) - Tensor::deallocate(chem_env.C_beta_AO, chem_env.F_beta_AO); + Tensor::deallocate(chem_env.scf_context.C_beta_AO, + chem_env.scf_context.F_beta_AO); } #if defined(ENABLE_CC) else if(task.mp2) mp2::cd_mp2(ec, chem_env); - else if(task.cd_2e) cholesky_2e::cholesky_decomp_2e(ec, chem_env); + else if(task.cd_2e) cholesky_2e::cholesky_2e_driver(ec, chem_env); else if(task.ccsd) { cc::ccsd::cd_ccsd(ec, chem_env); } else if(task.ccsd_t) cc::ccsd_t::ccsd_t_driver(ec, chem_env); else if(task.cc2) cc2::cd_cc2_driver(ec, chem_env); @@ -51,7 +56,7 @@ void execute_task(ExecutionContext& ec, ChemEnv& chem_env, std::string ec_arg2) else tamm_terminate( - "[ERROR] Unsupported task specified (or) code for the specified task is not built"); + "\n[ERROR] Unsupported task specified (or) code for the specified task is not built"); } } // namespace exachem::task diff --git a/exachem/task/ec_task.hpp b/exachem/task/ec_task.hpp index f94be1e..59eab50 100644 --- a/exachem/task/ec_task.hpp +++ b/exachem/task/ec_task.hpp @@ -35,5 +35,6 @@ using namespace exachem; #endif namespace exachem::task { +void print_geometry(ExecutionContext& ec, ChemEnv& chem_env); void execute_task(ExecutionContext& ec, ChemEnv& chem_env, std::string ec_arg2); -} +} // namespace exachem::task diff --git a/inputs/aminoprop.json b/inputs/aminoprop.json new file mode 100644 index 0000000..d82bed4 --- /dev/null +++ b/inputs/aminoprop.json @@ -0,0 +1,91 @@ + +{ + "geometry": { + "coordinates": [ + "H 0.00000000 0.00000000 0.00000000", + "C 0.00000000 1.09163906 0.00000000", + "C 1.26822472 1.80690645 0.00000000", + "N -1.33404678 3.10992888 0.00000000", + "O 1.39279087 3.03379031 0.00000000", + "H -0.48254004 3.66582880 0.00000000", + "H -2.24599052 3.54003736 0.00000000", + "C -1.19931821 1.76513995 0.00000000", + "H 2.18220599 1.16371496 0.00000000", + "H -2.14055701 1.20128576 0.00000000" + ], + + "units": "angstrom" + }, + + + "common": { + "maxiter": 100 + }, + + "basis": { + "basisset": "aug-cc-pvdz", + "df_basisset": "", + "atom_basis": { + "O": "aug-cc-pvdz", + "C": "aug-cc-pvdz", + "N": "aug-cc-pvdz", + "H": "aug-cc-pvdz" + } + }, + + "SCF": { + "charge": 0, + "multiplicity": 1, + "lshift": 0, + "conve": 1e-9, + "convd": 1e-8, + "diis_hist": 10, + "writem": 10, + "restart": false, + "noscf": false, + "scf_type": "restricted", + "debug": false, + "qed_omegas" : [0.293995], + "qed_volumes": [], + "qed_lambdas": [0.1], + "qed_polvecs": [[1.0, 0.0, 0.0]] + }, + + "CD": { + "debug": false, + "diagtol": 1e-12, + "itilesize": 1000 + }, + + "CC": { + "threshold": 1e-8, + "lshift": 0.0, + "ndiis": 5, + "ccsd_maxiter": 100, + "nactive": 0, + "freeze":{ + "atomic":false, + "core": 0, + "virtual": 0 + }, + + + "readt": false, + "writet": false, + "writet_iter": 5, + + "CCSD(T)": { + "cache_size": 8, + "skip_ccsd": false, + "ccsdt_tilesize": 32 + } + }, + + "TASK": { + "scf": false, + "ccsd": true, + "ccsd_t": false + } + +} + diff --git a/inputs/c20_fullerene.json b/inputs/c20_fullerene.json index 5fa4304..c42f846 100644 --- a/inputs/c20_fullerene.json +++ b/inputs/c20_fullerene.json @@ -31,11 +31,9 @@ "maxiter": 50 }, "SCF": { - "tol_lindep": 1e-05, "conve": 1e-10, "convd": 1e-09, - "diis_hist": 10, - "tilesize": 30 + "diis_hist": 10 }, "CD": { "diagtol": 1e-06 diff --git a/inputs/c240.json b/inputs/c240.json index c965daf..55f6ca6 100644 --- a/inputs/c240.json +++ b/inputs/c240.json @@ -248,7 +248,6 @@ "basisset": "sto-3g" }, "SCF": { - "tilesize": 30, "restart": false }, "TASK": { diff --git a/inputs/c2h4.json b/inputs/c2h4.json index e42984f..5213fa9 100644 --- a/inputs/c2h4.json +++ b/inputs/c2h4.json @@ -14,7 +14,6 @@ "basisset": "sto-3g" }, "SCF": { - "tilesize": 30, "restart": false }, "TASK": { diff --git a/inputs/c60.json b/inputs/c60.json index db2594a..189a7f4 100644 --- a/inputs/c60.json +++ b/inputs/c60.json @@ -74,8 +74,7 @@ "tol_lindep": 1e-06, "conve": 1e-06, "convd": 1e-05, - "diis_hist": 10, - "tilesize": 30 + "diis_hist": 10 }, "CD": { "diagtol": 1e-08, diff --git a/inputs/c60h20.json b/inputs/c60h20.json index eaab22e..b7e3233 100644 --- a/inputs/c60h20.json +++ b/inputs/c60h20.json @@ -104,8 +104,6 @@ "ndiis": 6, "writet": true, "writet_iter": 2, - "force_tilesize": true, - "tilesize": 90, "GFCCSD": { "gf_ip": false, "gf_ea": true, diff --git a/inputs/caffeine.json b/inputs/caffeine.json index ef9b44f..bf092df 100644 --- a/inputs/caffeine.json +++ b/inputs/caffeine.json @@ -61,4 +61,4 @@ "ccsd": false, "ccsd_t": false } -} +} \ No newline at end of file diff --git a/inputs/ch2.json b/inputs/ch2.json index a2057bc..62eff8f 100644 --- a/inputs/ch2.json +++ b/inputs/ch2.json @@ -18,7 +18,6 @@ "conve": 1e-12, "convd": 1e-11, "diis_hist": 10, - "tilesize": 30, "restart": false, "noscf":false }, diff --git a/inputs/ch4.json b/inputs/ch4.json index 9f1d107..dbe1380 100644 --- a/inputs/ch4.json +++ b/inputs/ch4.json @@ -23,9 +23,7 @@ "charge": 0, "multiplicity": 1, "scf_type": "restricted", - "writem": 10, - "force_tilesize": false, - "tilesize": 30 + "writem": 10 }, "CD": { "diagtol": 1e-12, diff --git a/inputs/ci/co.json b/inputs/ci/co.json index 617b0ef..38801c5 100644 --- a/inputs/ci/co.json +++ b/inputs/ci/co.json @@ -16,8 +16,7 @@ "tol_lindep": 1e-06, "conve": 1e-12, "convd": 1e-11, - "diis_hist": 10, - "tilesize": 30 + "diis_hist": 10 }, "CD": { "diagtol": 1e-08 diff --git a/inputs/ci/cr2.json b/inputs/ci/cr2.json index c4f5175..bc29a4b 100644 --- a/inputs/ci/cr2.json +++ b/inputs/ci/cr2.json @@ -18,7 +18,6 @@ "conve": 1e-09, "convd": 1e-07, "diis_hist": 10, - "tilesize": 30, "lshift": 0.1, "DFT": { "xc_type": ["PBE"] diff --git a/inputs/ci/h2o_ducc.json b/inputs/ci/h2o_ducc.json index 174765a..9ab54e8 100644 --- a/inputs/ci/h2o_ducc.json +++ b/inputs/ci/h2o_ducc.json @@ -22,9 +22,7 @@ "charge": 0, "multiplicity": 1, "scf_type": "restricted", - "writem": 10, - "force_tilesize": false, - "tilesize": 30 + "writem": 10 }, "CD": { "diagtol": 1e-12, diff --git a/inputs/ci/h2o_eom.json b/inputs/ci/h2o_eom.json index 90767dc..d562f1f 100644 --- a/inputs/ci/h2o_eom.json +++ b/inputs/ci/h2o_eom.json @@ -22,9 +22,7 @@ "charge": 0, "multiplicity": 1, "scf_type": "restricted", - "writem": 10, - "force_tilesize": false, - "tilesize": 30 + "writem": 10 }, "CD": { "diagtol": 1e-12, diff --git a/inputs/ci/h2o_qed.json b/inputs/ci/h2o_qed.json new file mode 100644 index 0000000..bf02c3c --- /dev/null +++ b/inputs/ci/h2o_qed.json @@ -0,0 +1,51 @@ +{ + "geometry": { + "coordinates": [ + "O 0.000000000000 0.000000000000 -0.065655108083", + "H 0.000000000000 -0.757365949175 0.520997104927", + "H 0.000000000000 0.757365949175 0.520997104927" + ], + "units": "angstrom" + }, + "basis": { + "basisset": "cc-pvtz" + }, + "common": { + "maxiter": 100 + }, + "SCF": { + "charge": 0, + "multiplicity": 1, + "lshift": 0, + "tol_int": 1e-20, + "tol_lindep": 1e-5, + "conve": 1e-9, + "convd": 1e-8, + "diis_hist": 10, + "scf_type": "restricted", + "writem": 10, + "qed_omegas" : [0.11024], + "qed_volumes": [], + "qed_lambdas": [0.1], + "qed_polvecs": [[0.0, 0.0, 1.0]] + }, + "CD": { + "diagtol": 1e-12 + }, + "CC": { + "threshold": 1e-10, + "ndiis": 5, + "writet": false, + "ccsd_maxiter": 100, + "CCSD(T)": { + "ccsdt_tilesize": 28 + }, + "debug": false + }, + "TASK": { + "mp2": false, + "cd_2e": false, + "ccsd": true, + "ccsd_t": false + } +} diff --git a/inputs/ci/lih.json b/inputs/ci/lih.json index 7d8d732..e1784b4 100644 --- a/inputs/ci/lih.json +++ b/inputs/ci/lih.json @@ -17,8 +17,7 @@ "tol_lindep": 1e-06, "conve": 1e-12, "convd": 1e-11, - "diis_hist": 10, - "tilesize": 30 + "diis_hist": 10 }, "CD": { "diagtol": 1e-08 diff --git a/inputs/ci/ozone.json b/inputs/ci/ozone.json index 386fdd8..7225b98 100644 --- a/inputs/ci/ozone.json +++ b/inputs/ci/ozone.json @@ -11,7 +11,6 @@ "basisset": "sto-3g" }, "SCF": { - "tilesize": 30, "restart": false, "conve": 1e-9, "convd": 1e-8, diff --git a/inputs/ci/ozone_td.json b/inputs/ci/ozone_td.json index a43eedb..198c804 100644 --- a/inputs/ci/ozone_td.json +++ b/inputs/ci/ozone_td.json @@ -14,7 +14,6 @@ "file_prefix": "ozone" }, "SCF": { - "tilesize": 30, "restart": false, "conve": 1e-1, "convd": 1e-1, diff --git a/inputs/co.json b/inputs/co.json index e86343d..fb9baea 100644 --- a/inputs/co.json +++ b/inputs/co.json @@ -16,8 +16,7 @@ "tol_lindep": 1e-06, "conve": 1e-10, "convd": 1e-09, - "diis_hist": 10, - "tilesize": 30 + "diis_hist": 10 }, "CD": { "diagtol": 1e-08 diff --git a/inputs/cytosine.json b/inputs/cytosine.json index 0ba5877..d326bf0 100644 --- a/inputs/cytosine.json +++ b/inputs/cytosine.json @@ -26,8 +26,7 @@ "SCF": { "conve": 1e-06, "convd": 1e-05, - "diis_hist": 10, - "tilesize": 50 + "diis_hist": 10 }, "CD": { "diagtol": 1e-06, diff --git a/inputs/disilane.json b/inputs/disilane.json index b2c1240..287fb9b 100644 --- a/inputs/disilane.json +++ b/inputs/disilane.json @@ -16,7 +16,6 @@ "basisset": "cc-pvdz" }, "SCF": { - "tilesize": 30, "restart": false }, "TASK": { diff --git a/inputs/dlpno/ubiquitin_dgrtl_dlpno.json b/inputs/dlpno/ubiquitin_dgrtl_dlpno.json index 9acab92..7ad85da 100644 --- a/inputs/dlpno/ubiquitin_dgrtl_dlpno.json +++ b/inputs/dlpno/ubiquitin_dgrtl_dlpno.json @@ -94,7 +94,6 @@ "conve": 1e-10, "convd": 1e-09, "diis_hist": 12, - "tilesize": 30, "charge": 1, "restart": false, "noscf": false @@ -129,4 +128,4 @@ "dlpno_ccsd": [true,""] } } - + \ No newline at end of file diff --git a/inputs/esca.json b/inputs/esca.json index ad8a502..7b5d9fb 100644 --- a/inputs/esca.json +++ b/inputs/esca.json @@ -40,8 +40,7 @@ "charge": 0, "multiplicity": 1, "scf_type": "restricted", - "writem": 10, - "tilesize": 30 + "writem": 10 }, "CD": { "diagtol": 1e-6, diff --git a/inputs/example.json b/inputs/example.json index 7fbfd56..6369e55 100644 --- a/inputs/example.json +++ b/inputs/example.json @@ -49,7 +49,6 @@ "conve": 1e-8, "convd": 1e-7, "diis_hist": 10, - "force_tilesize": false, "tilesize": 30, "df_tilesize": 50, "damp": 100, @@ -131,8 +130,6 @@ "CC": { "threshold": 1e-6, - "force_tilesize": false, - "tilesize": 50, "lshift": 0, "ndiis": 5, "ccsd_maxiter": 50, @@ -165,6 +162,22 @@ "skip_ccsd": false, "ccsdt_tilesize": 40 }, + + "DLPNO": { + "localize": false, + "skip_dlpno": false, + "df_basisset": "", + "max_pnos": 1, + "keep_npairs": 1, + "TCutPNO": 0, + "TCutEN": 0.97, + "TCutPre": -1.0, + "TCutPairs": 0.0, + "TCutDO": 1e-2, + "TCutDOij": 1e-5, + "TCutDOPre": 3e-2, + "doubles_opt_eqns": [] + }, "EOMCCSD": { "eom_nroots": 1, @@ -265,7 +278,9 @@ "ccsd_lambda": false, "eom_ccsd": false, "rteom_ccsd": false, - "gfccsd": false + "gfccsd": false, + "dlpno_ccsd": [false,"standalone"], + "dlpno_ccsd_t": [false,"standalone"] } } diff --git a/inputs/f2.json b/inputs/f2.json index e437d01..17fbf0c 100644 --- a/inputs/f2.json +++ b/inputs/f2.json @@ -10,7 +10,6 @@ "basisset": "sto-3g" }, "SCF": { - "tilesize": 30, "restart": false }, "TASK": { diff --git a/inputs/ferrocene.json b/inputs/ferrocene.json index 18ce00a..f2f4f6e 100644 --- a/inputs/ferrocene.json +++ b/inputs/ferrocene.json @@ -40,8 +40,7 @@ "multiplicity": 1, "scf_type": "restricted", "writem": 10, - "restart": false, - "tilesize": 30 + "restart": false }, "CD": { "diagtol": 1e-12, @@ -97,4 +96,4 @@ "ccsd": false, "ccsd_t": false } -} +} \ No newline at end of file diff --git a/inputs/guanine_cytosine_2bp.json b/inputs/guanine_cytosine_2bp.json index 940c3ed..9501c55 100644 --- a/inputs/guanine_cytosine_2bp.json +++ b/inputs/guanine_cytosine_2bp.json @@ -69,11 +69,9 @@ "maxiter": 100 }, "SCF": { - "tol_lindep": 1e-05, "conve": 1e-08, "convd": 1e-06, - "diis_hist": 12, - "tilesize": 30 + "diis_hist": 12 }, "CD": { "diagtol": 1e-06, diff --git a/inputs/guanine_cytosine_3bp.json b/inputs/guanine_cytosine_3bp.json index 25db8e2..b549957 100644 --- a/inputs/guanine_cytosine_3bp.json +++ b/inputs/guanine_cytosine_3bp.json @@ -100,8 +100,7 @@ "SCF": { "conve": 1e-06, "convd": 1e-05, - "diis_hist": 10, - "tilesize": 30 + "diis_hist": 10 }, "CD": { "diagtol": 1e-06, diff --git a/inputs/guanine_cytosine_bp.json b/inputs/guanine_cytosine_bp.json index ad5b353..a607841 100644 --- a/inputs/guanine_cytosine_bp.json +++ b/inputs/guanine_cytosine_bp.json @@ -44,8 +44,7 @@ "conve": 1e-10, "convd": 1e-09, "diis_hist": 12, - "writem": 50, - "tilesize": 30 + "writem": 10 }, "CD": { "diagtol": 1e-06, diff --git a/inputs/h10.json b/inputs/h10.json index 785bcc8..b215ac4 100644 --- a/inputs/h10.json +++ b/inputs/h10.json @@ -18,7 +18,6 @@ "basisset": "cc-pvtz" }, "SCF": { - "tilesize": 30, "restart": false }, "CD": { diff --git a/inputs/h2.json b/inputs/h2.json index cf9d096..70e7372 100644 --- a/inputs/h2.json +++ b/inputs/h2.json @@ -13,11 +13,9 @@ "maxiter": 50 }, "SCF": { - "tol_lindep": 1e-06, "conve": 1e-12, "convd": 1e-11, - "diis_hist": 10, - "tilesize": 30 + "diis_hist": 10 }, "CD": { "diagtol": 1e-08 diff --git a/inputs/h2o.json b/inputs/h2o.json index 1f08f3c..18c1764 100644 --- a/inputs/h2o.json +++ b/inputs/h2o.json @@ -21,9 +21,7 @@ "charge": 0, "multiplicity": 1, "scf_type": "restricted", - "writem": 10, - "force_tilesize": false, - "tilesize": 30 + "writem": 10 }, "CD": { "diagtol": 1e-12, diff --git a/inputs/h8.json b/inputs/h8.json index 6d05968..bc688dd 100644 --- a/inputs/h8.json +++ b/inputs/h8.json @@ -19,11 +19,9 @@ "maxiter": 50 }, "SCF": { - "tol_lindep": 0.0001, "conve": 1e-10, "convd": 1e-09, - "diis_hist": 10, - "tilesize": 30 + "diis_hist": 10 }, "CD": { "diagtol": 1e-06 diff --git a/inputs/he.json b/inputs/he.json index b3325f9..e99f5ac 100644 --- a/inputs/he.json +++ b/inputs/he.json @@ -9,11 +9,9 @@ "basisset": "cc-pvdz" }, "SCF": { - "tol_lindep": 1e-06, "conve": 1e-10, "convd": 1e-09, - "diis_hist": 10, - "tilesize": 30 + "diis_hist": 10 }, "TASK": { "scf": true, diff --git a/inputs/lih.json b/inputs/lih.json index 8d21e98..492740b 100644 --- a/inputs/lih.json +++ b/inputs/lih.json @@ -13,11 +13,9 @@ "maxiter": 50 }, "SCF": { - "tol_lindep": 1e-06, "conve": 1e-12, "convd": 1e-11, - "diis_hist": 10, - "tilesize": 30 + "diis_hist": 10 }, "CD": { "diagtol": 1e-08 diff --git a/inputs/n2.json b/inputs/n2.json index e233a70..f59113d 100644 --- a/inputs/n2.json +++ b/inputs/n2.json @@ -10,7 +10,6 @@ "basisset": "sto-3g" }, "SCF": { - "tilesize": 30, "restart": false }, "TASK": { diff --git a/inputs/nh3.json b/inputs/nh3.json index ded3bd2..4bcf9cc 100644 --- a/inputs/nh3.json +++ b/inputs/nh3.json @@ -15,16 +15,13 @@ "maxiter": 100 }, "SCF": { - "tol_lindep": 1e-06, "conve": 1e-7, "convd": 1e-6, "diis_hist": 20, "charge": 0, "multiplicity": 1, "scf_type": "restricted", - "writem": 10, - "force_tilesize": false, - "tilesize": 30 + "writem": 10 }, "CD": { "diagtol": 1e-12, diff --git a/inputs/nitrobenzene.json b/inputs/nitrobenzene.json new file mode 100644 index 0000000..651ec5b --- /dev/null +++ b/inputs/nitrobenzene.json @@ -0,0 +1,41 @@ +{ + "geometry": { + "coordinates": [ + "C 0.02949981 1.33972592 0.06817723", + "C 1.43483278 1.28667967 0.00635313", + "C 2.11179024 0.05106117 -0.00544138", + "C 1.44506636 -1.13720058 0.03116583", + "C -0.68793171 0.16822220 0.10995314", + "H -0.47126997 2.29839666 0.07811355", + "H 2.02732783 2.19651728 -0.03220624", + "H 1.98966526 -2.07643217 0.02318494", + "H -1.77163480 0.18040547 0.15819632", + "N 3.58635895 0.05097292 -0.06745286", + "O 4.14711759 -1.05966097 -0.08807849", + "O 4.14497859 1.16390951 -0.09010823", + "C -0.02361177 -1.14582791 0.08353483", + "H -0.43674996 -1.87247364 0.78889576", + "Br -0.53591638 -1.86972195 -1.74078671" + ], + "units": "angstrom" + }, + "basis": { + "basisset": "cc-pvqz" + }, + "SCF": { + "charge": 0, + "multiplicity": 1, + "conve": 1e-8, + "convd": 1e-7, + "scf_type": "restricted" + }, + "CC": { + "threshold": 1e-06, + "lshift": 0.0, + "ccsd_maxiter": 100 + }, + "TASK": { + "scf": true, + "ccsd": false + } +} diff --git a/inputs/ozone.json b/inputs/ozone.json index 621e053..9056168 100644 --- a/inputs/ozone.json +++ b/inputs/ozone.json @@ -11,7 +11,6 @@ "basisset": "sto-3g" }, "SCF": { - "tilesize": 30, "restart": false }, "CD": { diff --git a/inputs/pnitroanilne.json b/inputs/pnitroanilne.json new file mode 100644 index 0000000..374dbdf --- /dev/null +++ b/inputs/pnitroanilne.json @@ -0,0 +1,92 @@ + +{ + "geometry": { + "coordinates": [ + "N -2.15746458 0.00000000 0.00000000", + "C -0.70321472 0.00000000 0.00000000", + "C -0.01145721 1.21693110 0.00000000", + "H -0.56773625 2.14697503 0.00000000", + "C 1.37482052 1.21656683 0.00000000", + "H 1.91425302 2.16055505 0.00000000", + "C 2.09546989 0.00000000 0.00000000", + "N 3.46611936 0.00000000 0.00000000", + "H 3.99010150 0.86140500 0.00000000", + "H 3.99010150 -0.86140500 0.00000000", + "C 1.37482052 -1.21656683 0.00000000", + "H 1.91425302 -2.16055505 0.00000000", + "C -0.01145721 -1.21693110 0.00000000", + "H -0.56773625 -2.14697503 0.00000000", + "O -2.73965974 1.09143620 0.00000000", + "O -2.73965974 -1.09143620 0.00000000" + ], + "units": "angstrom" + }, + + "common": { + "maxiter": 50, + "debug": false + }, + + "basis": { + "basisset": "aug-cc-pvqz", + "df_basisset": "", + "atom_basis": { + "O": "aug-cc-pvqz", + "C": "aug-cc-pvqz", + "N": "aug-cc-pvqz", + "H": "aug-cc-pvqz" + } + }, + + "SCF": { + "charge": 0, + "multiplicity": 1, + "lshift": 0, + "tol_lindep": 1e-5, + "conve": 1e-12, + "convd": 1e-11, + "diis_hist": 10, + "writem": 10, + "restart": false, + "noscf": false, + "scf_type": "restricted", + "debug": false, + "qed_omegas" : [0.177867], + "qed_volumes": [], + "qed_lambdas": [0.1], + "qed_polvecs": [[0.0, 0.0, 1.0]] + }, + + "CD": { + "debug": false, + "diagtol": 1e-6 + }, + + "CC": { + "threshold": 1e-8, + "lshift": 0.0, + "ndiis": 5, + "ccsd_maxiter": 100, + "nactive": 0, + "freeze":{ + "atomic":false, + "core": 0, + "virtual": 0 + }, + + "readt": false, + "writet": true, + "writet_iter": 5, + + "debug": false, + "profile_ccsd": false, + "balance_tiles": true + }, + + "TASK": { + "scf": false, + "ccsd": true + } + +} + diff --git a/inputs/radon/radon1_hs.json b/inputs/radon/radon1_hs.json index a5842ae..df50ea0 100644 --- a/inputs/radon/radon1_hs.json +++ b/inputs/radon/radon1_hs.json @@ -34,7 +34,6 @@ "maxiter": 200 }, "SCF": { - "tilesize": 30, "restart": false, "diis_hist": 10, "tol_lindep": 1e-06, diff --git a/inputs/radon/radon1_ls.json b/inputs/radon/radon1_ls.json index c59d4de..e04df05 100644 --- a/inputs/radon/radon1_ls.json +++ b/inputs/radon/radon1_ls.json @@ -34,7 +34,6 @@ "maxiter": 200 }, "SCF": { - "tilesize": 30, "restart": false, "diis_hist": 10, "tol_lindep": 1e-06, diff --git a/inputs/radon/radon2_hs.json b/inputs/radon/radon2_hs.json index 6842cd2..1f7c957 100644 --- a/inputs/radon/radon2_hs.json +++ b/inputs/radon/radon2_hs.json @@ -52,7 +52,6 @@ "maxiter": 200 }, "SCF": { - "tilesize": 30, "restart": false, "diis_hist": 10, "tol_lindep": 1e-06, diff --git a/inputs/radon/radon2_ls.json b/inputs/radon/radon2_ls.json index ef2e3a7..4aa6386 100644 --- a/inputs/radon/radon2_ls.json +++ b/inputs/radon/radon2_ls.json @@ -53,7 +53,6 @@ }, "SCF": { - "tilesize": 30, "restart": false, "diis_hist": 10, "tol_lindep": 1e-06, diff --git a/inputs/radon/radon3_hs.json b/inputs/radon/radon3_hs.json index eeb9b68..1af0948 100644 --- a/inputs/radon/radon3_hs.json +++ b/inputs/radon/radon3_hs.json @@ -64,7 +64,6 @@ "maxiter": 200 }, "SCF": { - "tilesize": 30, "restart": false, "diis_hist": 10, "tol_lindep": 1e-06, @@ -83,8 +82,6 @@ "readt": false, "writet": true, "ndiis": 5, - "force_tilesize": true, - "tilesize": 60, "CCSD(T)": { "skip_ccsd": false, "ccsdt_tilesize": 40 diff --git a/inputs/radon/radon3_ls.json b/inputs/radon/radon3_ls.json index 12aff4a..46fdd22 100644 --- a/inputs/radon/radon3_ls.json +++ b/inputs/radon/radon3_ls.json @@ -64,7 +64,6 @@ "maxiter": 200 }, "SCF": { - "tilesize": 30, "restart": false, "diis_hist": 10, "tol_lindep": 1e-06, @@ -83,8 +82,6 @@ "readt": false, "writet": true, "ndiis": 5, - "force_tilesize": true, - "tilesize": 60, "CCSD(T)": { "skip_ccsd": false, "ccsdt_tilesize": 40 diff --git a/inputs/radon/radon4_hs.json b/inputs/radon/radon4_hs.json index 399c189..dfc5d2d 100644 --- a/inputs/radon/radon4_hs.json +++ b/inputs/radon/radon4_hs.json @@ -65,7 +65,6 @@ "maxiter": 200 }, "SCF": { - "tilesize": 30, "restart": false, "diis_hist": 10, "tol_lindep": 1e-06, @@ -84,8 +83,6 @@ "readt": false, "writet": true, "ndiis": 4, - "force_tilesize": true, - "tilesize": 60, "CCSD(T)": { "skip_ccsd": false, "ccsdt_tilesize": 40 diff --git a/inputs/radon/radon4_ls.json b/inputs/radon/radon4_ls.json index 0b39bf0..9f239c6 100644 --- a/inputs/radon/radon4_ls.json +++ b/inputs/radon/radon4_ls.json @@ -65,7 +65,6 @@ "maxiter": 200 }, "SCF": { - "tilesize": 30, "restart": false, "diis_hist": 10, "tol_lindep": 1e-06, @@ -84,8 +83,6 @@ "readt": false, "writet": true, "ndiis": 4, - "force_tilesize": true, - "tilesize": 60, "CCSD(T)": { "skip_ccsd": false, "ccsdt_tilesize": 40 diff --git a/inputs/rteom/esca.json b/inputs/rteom/esca.json index bcaa165..2f4d4a4 100644 --- a/inputs/rteom/esca.json +++ b/inputs/rteom/esca.json @@ -32,9 +32,7 @@ "charge": 0, "multiplicity": 1, "scf_type": "restricted", - "writem": 10, - "force_tilesize": false, - "tilesize": 30 + "writem": 10 }, "CD": { "diagtol": 1e-12, diff --git a/inputs/siosi/siosi3.json b/inputs/siosi/siosi3.json index dad006e..8825edc 100644 --- a/inputs/siosi/siosi3.json +++ b/inputs/siosi/siosi3.json @@ -41,7 +41,6 @@ "basisset": "6-31g*" }, "SCF": { - "tilesize": 30, "restart": false }, "TASK": { diff --git a/inputs/siosi/siosi4.json b/inputs/siosi/siosi4.json index dad006e..8825edc 100644 --- a/inputs/siosi/siosi4.json +++ b/inputs/siosi/siosi4.json @@ -41,7 +41,6 @@ "basisset": "6-31g*" }, "SCF": { - "tilesize": 30, "restart": false }, "TASK": { diff --git a/inputs/siosi/siosi5.json b/inputs/siosi/siosi5.json index aa5dcf0..a435423 100644 --- a/inputs/siosi/siosi5.json +++ b/inputs/siosi/siosi5.json @@ -101,7 +101,6 @@ "basisset": "6-31g*" }, "SCF": { - "tilesize": 30, "restart": false }, "TASK": { diff --git a/inputs/siosi/siosi6.json b/inputs/siosi/siosi6.json index a43e63f..65b4a38 100644 --- a/inputs/siosi/siosi6.json +++ b/inputs/siosi/siosi6.json @@ -133,7 +133,6 @@ "basisset": "6-31g*" }, "SCF": { - "tilesize": 30, "restart": false }, "TASK": { diff --git a/inputs/siosi/siosi7.json b/inputs/siosi/siosi7.json index 4358f08..f3cafa8 100644 --- a/inputs/siosi/siosi7.json +++ b/inputs/siosi/siosi7.json @@ -297,7 +297,6 @@ "basisset": "6-31g*" }, "SCF": { - "tilesize": 30, "restart": false }, "TASK": { diff --git a/inputs/siosi/siosi8.json b/inputs/siosi/siosi8.json index 92ce7ad..bc66a88 100644 --- a/inputs/siosi/siosi8.json +++ b/inputs/siosi/siosi8.json @@ -541,7 +541,6 @@ "basisset": "6-31g*" }, "SCF": { - "tilesize": 30, "restart": false }, "TASK": { diff --git a/inputs/ubiquitin_dgrtl.json b/inputs/ubiquitin_dgrtl.json index 545d87c..aaaed84 100644 --- a/inputs/ubiquitin_dgrtl.json +++ b/inputs/ubiquitin_dgrtl.json @@ -94,7 +94,6 @@ "conve": 1e-10, "convd": 1e-09, "diis_hist": 12, - "tilesize": 30, "charge": 1, "restart": false, "noscf": false diff --git a/inputs/ubiquitin_full.json b/inputs/ubiquitin_full.json index 6feadb9..051d617 100644 --- a/inputs/ubiquitin_full.json +++ b/inputs/ubiquitin_full.json @@ -1236,17 +1236,13 @@ "units": "angstrom" }, "basis": { - "basisset": "sto-3g" + "basisset": "cc-pvdz" }, "SCF": { - "tilesize": 30, "restart": false }, "TASK": { "scf": true, - "mp2": false, - "cd_2e": false, - "ccsd": false, - "ccsd_t": false - } + "mp2": false + } } diff --git a/inputs/uracil/uracil4.json b/inputs/uracil/uracil4.json index 85c4c59..d98c535 100644 --- a/inputs/uracil/uracil4.json +++ b/inputs/uracil/uracil4.json @@ -56,7 +56,6 @@ "basisset": "sto-3g" }, "SCF": { - "tilesize": 30, "restart": false }, "TASK": { diff --git a/inputs/uracil/uracil5.json b/inputs/uracil/uracil5.json index f8c8fac..90e76ca 100644 --- a/inputs/uracil/uracil5.json +++ b/inputs/uracil/uracil5.json @@ -68,7 +68,6 @@ "basisset": "sto-3g" }, "SCF": { - "tilesize": 30, "restart": false }, "TASK": { diff --git a/inputs/uracil/uracil_dimer.json b/inputs/uracil/uracil_dimer.json index e77517f..b9444b7 100644 --- a/inputs/uracil/uracil_dimer.json +++ b/inputs/uracil/uracil_dimer.json @@ -32,7 +32,6 @@ "basisset": "sto-3g" }, "SCF": { - "tilesize": 30, "restart": false }, "TASK": { diff --git a/inputs/uracil/uracil_trimer.json b/inputs/uracil/uracil_trimer.json index 6f1a0ba..a055f00 100644 --- a/inputs/uracil/uracil_trimer.json +++ b/inputs/uracil/uracil_trimer.json @@ -44,7 +44,6 @@ "basisset": "sto-3g" }, "SCF": { - "tilesize": 30, "restart": false }, "TASK": { diff --git a/inputs/water/w102.json b/inputs/water/w102.json index f91a3bc..c7db14a 100644 --- a/inputs/water/w102.json +++ b/inputs/water/w102.json @@ -321,9 +321,8 @@ "convd": 1e-08, "diis_hist": 12, "writem": 50, - "tilesize": 30, "restart": false, - "noscf": true + "noscf": false }, "CD": { "diagtol": 1e-06, diff --git a/inputs/water/w53.json b/inputs/water/w53.json index 55cea5b..14fbf98 100644 --- a/inputs/water/w53.json +++ b/inputs/water/w53.json @@ -174,7 +174,6 @@ "convd": 1e-08, "diis_hist": 12, "writem": 50, - "tilesize": 30, "restart": false, "noscf": false }, diff --git a/methods/ExaChem.cpp b/methods/ExaChem.cpp index 9880a37..7b3e4dc 100644 --- a/methods/ExaChem.cpp +++ b/methods/ExaChem.cpp @@ -87,9 +87,13 @@ int main(int argc, char* argv[]) { output_dir += "/"; const auto test_file = output_dir + "ec_test_file.tmp"; std::ofstream ofs(test_file); - if(!ofs) - tamm_terminate("Path provided as output_dir [" + - chem_env.ioptions.common_options.output_dir + "] is not writable!"); + if(!ofs) { + tamm_terminate("[ERROR] Path provided as output_dir [" + + chem_env.ioptions.common_options.output_dir + + "] is not writable (or) does not exist"); + } + ofs.close(); + fs::remove(test_file); } chem_env.sys_data.output_file_prefix = @@ -163,8 +167,12 @@ int main(int argc, char* argv[]) { chem_env.shells = chem_env.ec_basis.shells; chem_env.sys_data.has_ecp = chem_env.ec_basis.has_ecp; + chem_env.read_run_context(); + exachem::task::execute_task(ec, chem_env, ec_arg2); + chem_env.write_run_context(); + } // loop over input files ec.flush_and_sync();