Skip to content

Commit

Permalink
Adds computation of EXX through snK
Browse files Browse the repository at this point in the history
  • Loading branch information
dmejiar authored and ajaypanyala committed May 14, 2024
1 parent 3591beb commit 355d17b
Show file tree
Hide file tree
Showing 18 changed files with 838 additions and 143 deletions.
97 changes: 89 additions & 8 deletions docs/user_guide/scf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,30 @@ The values listed below are the defaults where few options are automatically adj
"damp": 100,
"nnodes": 1,
"writem": 1,
"debug": false,
"restart": false,
"noscf": false,
"scf_type": "restricted",
"xc_type": [],
"xc_grid_type": "UltraFine",
"direct_df": false,
"debug": false,
"direct_df": false,
"DFT": {
"snK": false,
"xc_type": [],
"xc_grid_type": "UltraFine",
"xc_pruning_scheme": "Robust",
"xc_rad_quad": "MK",
"xc_weight_scheme": "SSF",
"xc_exec_space": "Host",
"xc_basis_tol": 1e-10,
"xc_batch_size": 512,
"xc_snK_etol": 1e-10,
"xc_snK_ktol": 1e-10,
"xc_lb_kernel": "Default",
"xc_mw_kernel": "Default",
"xc_int_kernel": "Default",
"xc_red_kernel": "Default",
"xc_lwd_kernel": "Default",
"xc_radang_size": [0, 0]
},
"guess": {
"atom_options":{
"Fe1": [1,2],
Expand Down Expand Up @@ -93,26 +110,90 @@ The values listed below are the defaults where few options are automatically adj

:noscf: ``[default=false]`` Computes only the SCF energy upon restart.

:debug: ``[default=false]`` enable verbose printing for debugging a calculation.

:scf_type: ``[default=restricted]`` The following values are supported

* :strong:`restricted`: for closed-shell restricted Hartree-Fock (RHF) calculation
* :strong:`unrestricted`: for spin-unrestricted Hartree-Fock (UHF) calculation

:direct_df: ``[default=false]`` Requests the direct computation of the density-fitted Coulomb contribution. Works only for pure Kohn-Sham fnctionals (no exact exchange) and with a provided ``df_basisset`` (see :ref:`Basis set options <Basis>`).

:snK: ``[default=false]`` Computes the exact exchange contribution using the seminumerical approach implemented in `GauXC`.

:xc_type: ``[default=[]]`` A list of strings specifying the exchange and correlation functionals for DFT calculations using `GauXC <https://github.com/wavefunction91/GauXC>`_.
The list of available functionals using the `builtin` backend can be found at the `ExchCXX <https://github.com/wavefunction91/ExchCXX>`_ repository.
The `Libxc` backend is restricted to the list of LDA and GGA functionals without range separation available at `Libxc <https://tddft.org/programs/libxc/functionals/libxc-6.2.2/>`_.
The `Libxc` backend is restricted to the list of functionals **without** range separation available at `Libxc <https://tddft.org/programs/libxc/functionals/libxc-6.2.2/>`_.

:xc_grid_type: ``[default=UltraFine]`` Specifies the quality of the numerical integration grid. The following values are supported

* :strong:`Fine`: 75 radial shells with 302 angular points per shell.
* :strong:`UltraFine`: 99 radial shells with 590 angular points per shell.
* :strong:`SuperFine`: 175 radial shells with 974 angular points per shell for first row elements and 250 radial shells with 974 Lebedev points per shell for the rest.
* :strong:`GM3`
* :strong:`GM5`

All **xc_grid_type** options use a `Mura-Knowles` radial quadrature, a `Lebedev-Laikov` angular quadrature, a `Laqua-Kussmann-Ochsenfeld` partitioning scheme, and a `Robust` pruning method.
:xc_pruning_scheme: ``[default=Robust]`` Specifies the `GauXC` pruning scheme. The following values are supported

:direct_df: ``[default=false]`` Requests the direct computation of the density-fitted Coulomb contribution. Works only for pure Kohn-Sham fnctionals (no exact exchange) and with a provided ``df_basisset`` (see :ref:`Basis set options <Basis>`).
* :strong:`Treutler`
* :strong:`Robust`
* :strong:`Unpruned`

:debug: ``[default=false]`` enable verbose printing for debugging a calculation.
:xc_rad_quad: ``[default=MK]`` Specifies the `GauXC` radial quadrature. The following values are supported

* :strong:`MK` Mura-Knowles radial quadrature.
* :strong:`TA` Treutler-Ahlrichs radial quadrature.
* :strong:`MHL` Murray-Handy-Laming radial quadrature.

:xc_weight_scheme: ``[default=SSF]`` Specifies the `GauXC` partitioning scheme. The following values are supported

* :strong:`SSF` Stratman-Scuseria-Frisch partitioning scheme.
* :strong:`Becke` Becke partitioning scheme.
* :strong:`LKO` Laqua-Kussmann-Ochsenfeld partitioning scheme.

:xc_exec_space: ``[default=Host]`` Specifies the `GauXC` execution space for the load balancer *and* integrator. The following values are supported

* :strong:`Host` Use the CPU execution space.
* :strong:`Device` Use the GPU execution space. Only meaningful when GPU support was enabled during compilation. By default, `TAMM` reserves up to 80% of the GPU memory and only 10% is made available to `GauXC`. The `TAMM_GPU_POOL` environment variable can be used to modify the percentage of GPU memory reserved for `TAMM` and `GauXC` (`90-TAMM_GPU_POOL`).

:xc_basis_tol: ``[default=1e-8]`` Specifies the `GauXC` basis tolerance.

:xc_batch_size: ``[default=2048]`` Specifies the `GauXC` batch size.

:xc_snK_etol: ``[default=1e-10]`` Specifies the `GauXC` snK energy tolerance. If `conve < xc_snK_etol`, the `xc_snK_etol` tolerance will be automatically set to the `conve` value.

:xc_snK_ktol: ``[default=1e-10]`` Specifies the `GauXC` K matrix tolerance. If `conve * 1e-2 < xc_snK_ktol`, the `xc_snK_ktol` tolerance will be automatically set to `conve * 1e-2`.

:xc_int_kernel: ``[default=Default]`` Specifies the `GauXC` Integrator Kernel.

* :strong:`Default` Uses `Replicated` or `Incore` for `Host` and `Device` execution spaces, respectively.
* :strong:`Replicated` Only available for the `Host` execution space.
* :strong:`Incore` Only available for the `Device` execution space.
* :strong:`ShellBatched` Only available for the `Device` execution space.

:xc_lwd_kernel: ``[default=Default]`` Specifies the `GauXC` Local Work Driver Kernel.

* :strong:`Default` Uses the `Reference` or `Scheme1` kernels for `Host` and `Device` execution spaces, respectively.
* :strong:`Reference` Only available for the `Host` execution space.
* :strong:`Scheme1` Only available for the `Device` execution space.
* :strong:`Scheme1-Cutlass` Only available for the `Device` execution space. `GauXC` must be compiled setting `GAUXC_ENABLE_CUTLASS=ON`.

:xc_red_kernel: ``[default=Default]`` Specifies the `GauXC` Reduction Kernel.

* :strong:`Default` Uses the `BasicMPI` reduction kernel.
* :strong:`BasicMPI`
* :strong:`NCCL` Only available for the `Device` execution space. `GauXC` must be compiled setting `GAUXC_ENABLE_NCCL=ON`.

:xc_lb_kernel: ``[default=Default]`` Specifies the `GauXC` Load Balancer Kernel.

* :strong:`Default` Uses the `Replicated` reduction kernel.
* :strong:`Replicated` Alias for `Replicated-Petite` in the `Host` execution space.
* :strong:`Replicated-Petite` Only available for the `Host` execution space.
* :strong:`Replicated-Fillin` Only available for the `Host` execution space.

:xc_mw_kernel: ``[default=Default]`` Specifies the `GauXC` Molecular Weights Kernel.

* :strong:`Default`

:nnodes: On a distributed machine, the number of processors for an SCF run is chosen by default depending on the problem size (i.e. number of basis functions **Nbf**).
If a larger number of processors than required are used, the SCF module automatically chooses a smaller subset of processors for the calculation.
Expand Down
2 changes: 2 additions & 0 deletions exachem/common/chemenv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ void ChemEnv::write_json_data(const std::string cmodule) {
results["input"]["SCF"]["polvecs"] = scf.qed_polvecs;
results["input"]["SCF"]["omegas"] = scf.qed_omegas;
results["input"]["SCF"]["volumes"] = scf.qed_volumes;
results["input"]["SCF"]["xc_type"] = scf.xc_type;
results["input"]["SCF"]["snK"] = scf.snK;

if(cmodule == "CD" || cmodule == "CCSD") {
// CD options
Expand Down
3 changes: 3 additions & 0 deletions exachem/common/initialize_system_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ void IniSystemData::initialize(ChemEnv& chem_env) {
chem_env.sys_data.is_ks = false;
chem_env.sys_data.is_qed = false;
chem_env.sys_data.do_qed = false;
chem_env.sys_data.do_snK = false;
chem_env.sys_data.freeze_atomic = false;

SCFOptions& scf_options = chem_env.ioptions.scf_options;
Expand All @@ -28,6 +29,8 @@ void IniSystemData::initialize(ChemEnv& chem_env) {
else tamm_terminate("ERROR: unrecognized scf_type [" + scf_options.scf_type + "] provided");
if(!scf_options.xc_type.empty()) { chem_env.sys_data.is_ks = true; }

if(scf_options.snK) { chem_env.sys_data.do_snK = true; }

if(!scf_options.qed_volumes.empty()) {
for(auto x: scf_options.qed_volumes) { scf_options.qed_lambdas.push_back(sqrt(1.0 / x)); }
}
Expand Down
82 changes: 53 additions & 29 deletions exachem/common/options/input_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,47 @@ void SCFOptions::print() {
std::cout << std::defaultfloat;
std::cout << std::endl << "SCF Options" << std::endl;
std::cout << "{" << std::endl;
std::cout << " charge = " << charge << std::endl;
std::cout << " multiplicity = " << multiplicity << std::endl;
std::cout << " level shift = " << lshift << std::endl;
std::cout << " tol_int = " << tol_int << std::endl;
std::cout << " tol_sch = " << tol_sch << std::endl;
std::cout << " tol_lindep = " << tol_lindep << std::endl;
std::cout << " conve = " << conve << std::endl;
std::cout << " convd = " << convd << std::endl;
std::cout << " diis_hist = " << diis_hist << std::endl;
std::cout << " AO_tilesize = " << AO_tilesize << std::endl;
std::cout << " writem = " << writem << std::endl;
std::cout << " damp = " << damp << std::endl;
std::cout << " n_lindep = " << n_lindep << std::endl;
std::cout << " charge = " << charge << std::endl;
std::cout << " multiplicity = " << multiplicity << std::endl;
std::cout << " level shift = " << lshift << std::endl;
std::cout << " tol_int = " << tol_int << std::endl;
std::cout << " tol_sch = " << tol_sch << std::endl;
std::cout << " tol_lindep = " << tol_lindep << std::endl;
std::cout << " conve = " << conve << std::endl;
std::cout << " convd = " << convd << std::endl;
std::cout << " diis_hist = " << diis_hist << std::endl;
std::cout << " AO_tilesize = " << AO_tilesize << std::endl;
std::cout << " writem = " << writem << std::endl;
std::cout << " damp = " << damp << std::endl;
std::cout << " n_lindep = " << n_lindep << std::endl;
if(!moldenfile.empty()) {
std::cout << " moldenfile = " << moldenfile << std::endl;
std::cout << " moldenfile = " << moldenfile << std::endl;
// std::cout << " n_lindep = " << n_lindep << std::endl;
}

std::cout << " scf_type = " << scf_type << std::endl;
std::cout << " scf_type = " << scf_type << std::endl;

// QED
if(!qed_omegas.empty()) {
std::cout << " qed_omegas = [";
std::cout << " qed_omegas = [";
for(auto x: qed_omegas) { std::cout << x << ","; }
std::cout << "\b]" << std::endl;
}

if(!qed_lambdas.empty()) {
std::cout << " qed_lambdas = [";
std::cout << " qed_lambdas = [";
for(auto x: qed_lambdas) { std::cout << x << ","; }
std::cout << "\b]" << std::endl;
}

if(!qed_volumes.empty()) {
std::cout << " qed_volumes = [";
std::cout << " qed_volumes = [";
for(auto x: qed_volumes) { std::cout << x << ","; }
std::cout << "\b]" << std::endl;
}

if(!qed_polvecs.empty()) {
std::cout << " qed_polvecs = [";
std::cout << " qed_polvecs = [";
for(auto x: qed_polvecs) {
std::cout << "[";
for(auto y: x) { std::cout << y << ","; }
Expand All @@ -53,22 +53,46 @@ void SCFOptions::print() {
std::cout << "\b]" << std::endl;
}

if(!xc_type.empty()) {
std::cout << " xc_type = [ ";
txt_utils::print_bool(" direct_df ", direct_df);

if(!xc_type.empty() || snK) {
std::cout << " DFT " << std::endl << " {" << std::endl;
std::cout << " xc_type = [ ";
for(auto xcfunc: xc_type) { std::cout << " \"" << xcfunc << "\","; }
std::cout << "\b ]" << std::endl;
std::cout << " xc_grid_type = " << xc_grid_type << std::endl;

std::cout << " xc_grid_type = " << xc_grid_type << std::endl;
std::cout << " xc_pruning_scheme = " << xc_pruning_scheme << std::endl;
std::cout << " xc_weight_scheme = " << xc_weight_scheme << std::endl;
std::cout << " xc_exec_space = " << xc_exec_space << std::endl;
std::cout << " xc_basis_tol = " << xc_basis_tol << std::endl;
std::cout << " xc_batch_size = " << xc_batch_size << std::endl;
std::cout << " xc_lb_kernel = " << xc_lb_kernel << std::endl;
std::cout << " xc_mw_kernel = " << xc_mw_kernel << std::endl;
std::cout << " xc_int_kernel = " << xc_int_kernel << std::endl;
std::cout << " xc_red_kernel = " << xc_red_kernel << std::endl;
std::cout << " xc_lwd_kernel = " << xc_lwd_kernel << std::endl;
if(xc_radang_size.first > 0 && xc_radang_size.second > 0) {
std::cout << " xc_radang_size = " << xc_radang_size.first << ", " << xc_radang_size.second
<< std::endl;
}
else { std::cout << " xc_rad_quad = " << xc_rad_quad << std::endl; }

txt_utils::print_bool(" snK ", snK);
std::cout << " xc_snK_etol = " << xc_snK_etol << std::endl;
std::cout << " xc_snK_ktol = " << xc_snK_ktol << std::endl;
std::cout << " }" << std::endl;
}

if(scalapack_np_row > 0 && scalapack_np_col > 0) {
std::cout << " scalapack_np_row = " << scalapack_np_row << std::endl;
std::cout << " scalapack_np_col = " << scalapack_np_col << std::endl;
if(scalapack_nb > 1) std::cout << " scalapack_nb = " << scalapack_nb << std::endl;
std::cout << " scalapack_np_row = " << scalapack_np_row << std::endl;
std::cout << " scalapack_np_col = " << scalapack_np_col << std::endl;
if(scalapack_nb > 1) std::cout << " scalapack_nb = " << scalapack_nb << std::endl;
}
std::cout << " restart_size = " << restart_size << std::endl;
txt_utils::print_bool(" restart ", restart);
txt_utils::print_bool(" debug ", debug);
if(restart) txt_utils::print_bool(" noscf ", noscf);
std::cout << " restart_size = " << restart_size << std::endl;
txt_utils::print_bool(" restart ", restart);
txt_utils::print_bool(" debug ", debug);
if(restart) txt_utils::print_bool(" noscf ", noscf);
// txt_utils::print_bool(" sad ", sad);
if(mulliken_analysis || mos_txt || mo_vectors_analysis.first) {
std::cout << " PRINT {" << std::endl;
Expand Down
27 changes: 21 additions & 6 deletions exachem/common/options/input_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,32 @@ class SCFOptions: public CommonOptions {
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
int scalapack_nb{256};
int nnodes{1};
int scalapack_np_row{0};
int scalapack_np_col{0};
std::string moldenfile{""};
int n_lindep{0};
int writem{1};
int damp{100}; // density mixing parameter
std::string scf_type{"restricted"};
std::string xc_grid_type{"UltraFine"};
std::string moldenfile{""};
int n_lindep{0};
int writem{1};
int damp{100}; // density mixing parameter
std::string scf_type{"restricted"};
std::string xc_grid_type{"UltraFine"};
std::string xc_pruning_scheme{"Robust"};
std::string xc_rad_quad{"MK"};
std::string xc_weight_scheme{"SSF"};
std::string xc_exec_space{"Host"};
std::string xc_lb_kernel{"Default"};
std::string xc_mw_kernel{"Default"};
std::string xc_int_kernel{"Default"};
std::string xc_red_kernel{"Default"};
std::string xc_lwd_kernel{"Default"};
std::pair<int, int> xc_radang_size{0, 0};
int xc_batch_size{2048};
double xc_basis_tol{1e-8};
double xc_snK_etol{1e-10};
double xc_snK_ktol{1e-10};

std::map<std::string, std::tuple<int, int>> guess_atom_options;

Expand Down
Loading

0 comments on commit 355d17b

Please sign in to comment.