Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion source/source_io/module_ctrl/ctrl_scf_lcao.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "ctrl_scf_lcao.h" // use ctrl_scf_lcao()

#include "source_base/formatter.h"
#include "source_base/tool_quit.h" // use ModuleBase::WARNING_QUIT
#include "source_estate/elecstate_lcao.h" // use elecstate::ElecState
#include "source_hamilt/hamilt.h" // use Hamilt<T>
#include "source_lcao/hamilt_lcao.h" // use hamilt::HamiltLCAO<TK, TR>
Expand Down Expand Up @@ -55,7 +56,15 @@ void setup_exx_dh_params<double>(ModuleIO::WriteDHParams& dh_params, Exx_NAO<dou

template <typename TK>
void setup_exx_h_params(ModuleIO::WriteHParams& h_params, Exx_NAO<TK>& exx_nao)
{}
{
// Only the gamma-only (TK==double) specialization below actually writes V^EXX(R).
// This generic body is instantiated for the multi-k (TK==std::complex) path, where the
// EXX-H output is unsupported. Reject it explicitly here so the request cannot be silently
// dropped (the WARNING_QUIT inside write_h_exx is unreachable at multi-k).
ModuleBase::WARNING_QUIT("setup_exx_h_params",
"out_mat_h_exx is only supported for gamma-only: the V^EXX(R) "
"output is not available at multi-k. Use gamma_only.");
}

template <>
void setup_exx_h_params<double>(ModuleIO::WriteHParams& h_params, Exx_NAO<double>& exx_nao)
Expand Down
17 changes: 17 additions & 0 deletions source/source_io/module_dhs/write_dH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include "source_io/module_parameter/parameter.h"
#include "source_lcao/module_hcontainer/hcontainer_funcs.h"
#include "source_lcao/module_hcontainer/output_hcontainer.h"
#ifdef __EXX
#include "source_hamilt/module_xc/exx_info.h"
#endif

#include <algorithm>
#include <complex>
Expand Down Expand Up @@ -138,6 +141,20 @@ void write_dH_components(WriteDHParams& params)
"nspin=4 (noncollinear) yet; only nspin=1 and nspin=2.");
}

#ifdef __EXX
// The EXX interfaces carried by WriteDHParams are gamma-only (see write_dH.h): at multi-k
// dH^EXX would be the derivative with respect to every mirror atom, which this output is
// not meant for. Quit instead of writing a dH sum that silently omits the EXX term.
if (GlobalC::exx_info.info_global.cal_exx && !PARAM.globalv.gamma_only_local
&& (PARAM.inp.out_mat_dh[0] || PARAM.inp.out_mat_dh_exx[0]))
{
ModuleBase::WARNING_QUIT("write_dH_components",
"out_mat_dh (the dH sum) and out_mat_dh_exx are only supported for gamma-only when EXX is on. "
"Use gamma_only, or request the individual non-EXX terms (out_mat_dh_t, "
"out_mat_dh_vnl, out_mat_dh_vl, out_mat_dh_vh, out_mat_dh_vxc).");
}
#endif

GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
GlobalV::ofs_running << " | |" << std::endl;
GlobalV::ofs_running << " | #Print out dH/dR components# |" << std::endl;
Expand Down
11 changes: 9 additions & 2 deletions source/source_io/module_dhs/write_dH.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,15 @@ struct WriteDHParams
std::vector<const hamilt::HContainer<double>*> dmR;
const Charge* chg = nullptr; // ground-state charge for XC Hellmann-Feynman (FDM)
#ifdef __EXX
// gamma (TK==double) exx interfaces used by write_dH_exx; exactly one is set depending on
// GlobalC::exx_info.info_ri.real_number (exd: real Hexx, exc: complex Hexx).
// The gamma-only (TK==double) exx interfaces used by write_dH_exx.
// Deliberately NOT templated on TK, for two reasons:
// 1. Physics: at multi-k the derivative would be taken with respect to every mirror
// atom of the periodic images, which is not what this output is used for.
// 2. Cost: templating these pointers on TK would force WriteHParams, WriteDHParams and
// every free function taking them to become templates as well -- a large, purely
// mechanical change for a case nobody needs.
// Multi-k + EXX is therefore rejected up front (see write_dH_components)
// instead of silently producing output with the EXX term missing.
Exx_LRI_Interface<double, double>* exd = nullptr;
Exx_LRI_Interface<double, std::complex<double>>* exc = nullptr;
#endif
Expand Down
2 changes: 2 additions & 0 deletions source/source_io/module_hs/write_H_terms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ void write_h_exx(WriteHParams& params)
ModuleBase::TITLE("ModuleIO", "write_h_exx");
ModuleBase::timer::start("ModuleIO", "write_h_exx");

// Multi-k out_mat_h_exx is rejected upstream at the call site (setup_exx_h_params in
// ctrl_scf_lcao.cpp); this function is only reached on the gamma-only path.
const UnitCell& ucell = *params.ucell;
const Parallel_Orbitals& pv = *params.pv;
const K_Vectors& kv = *params.kv;
Expand Down
8 changes: 6 additions & 2 deletions source/source_io/module_hs/write_H_terms.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ struct WriteHParams
int nat = 0;
bool also_hR = false; // H(k) is always written; H(R) (CSR) only when this is true
#ifdef __EXX
// gamma (TK==double) exx interfaces used by write_h_exx; exactly one is set depending on
// GlobalC::exx_info.info_ri.real_number (exd: real Hexx, exc: complex Hexx).
// The gamma-only (TK==double) exx interfaces used by write_h_exx.
// Deliberately NOT templated on TK, because it would force WriteHParams, WriteDHParams and
// every free function taking them to become templates as well -- a large, purely
// mechanical change for a case nobody needs.
// Multi-k + EXX is therefore rejected up front (see write_h_exx)
// instead of silently producing output with the EXX term missing.
Exx_LRI_Interface<double, double>* exd = nullptr;
Exx_LRI_Interface<double, std::complex<double>>* exc = nullptr;
#endif
Expand Down
256 changes: 0 additions & 256 deletions source/source_lcao/module_operator_lcao/nonlocal_dh.hpp.bak

This file was deleted.

Loading