Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
15f939b
feat(lr): add Gamma auxiliary-TDA NACV and ETF output
Shane-Sayoko Nov 15, 2026
089ae3e
refactor(lr): move NAC orchestration out of ESolver
Shane-Sayoko Nov 16, 2026
e17d52e
refactor(nac): isolate NACV implementation from upstream LR paths
Shane-Sayoko Nov 16, 2026
3ac3626
perf(nac): reuse geometry-local response and force intermediates
Shane-Sayoko Nov 16, 2026
7086943
docs(lr): clarify lr_grad_thr is limited to NAC CG response
Shane-Sayoko Nov 17, 2026
306e463
test(lr): cover NACV model results, coupled response and state output
Shane-Sayoko Nov 17, 2026
70881f6
Fix(io): include NACV registrations in serial input tests
Shane-Sayoko Nov 17, 2026
1d7c47f
Merge branch 'develop' into abacus-nacv
Shane-Sayoko Nov 17, 2026
4994bfb
Fix(ase): use ScaLAPACK in calculator smoke tests
Shane-Sayoko Nov 17, 2026
0885ecd
refactor: consolidate analytic NACV into two source-header pairs
Shane-Sayoko Nov 17, 2026
0db7ee1
Fix(lr): address analytic NACV review findings
Shane-Sayoko Nov 17, 2026
ece3b3a
Merge branch 'develop' into abacus-nacv
Shane-Sayoko Nov 18, 2026
b32d1fa
Fix(test): serialize NACV tests that share scratch files
Shane-Sayoko Nov 18, 2026
e376311
Refactor(lr): share XC name resolution with NACV
Shane-Sayoko Nov 23, 2026
6cabb92
Refactor(lr): separate NACV response and AO contractions
Shane-Sayoko Nov 23, 2026
0b7303a
Refactor(lr): own fixed-geometry NACV force data in LR_Force
Shane-Sayoko Nov 23, 2026
f530999
Merge develop into abacus-nacv and reuse LR test configuration
Shane-Sayoko Nov 24, 2026
e4cc67b
Fix(lr): link split NACV objects and time cached force preparation
Shane-Sayoko Nov 24, 2026
8fef772
Merge upstream develop into abacus-nacv
Shane-Sayoko Nov 24, 2026
be849c2
Test(io): run NAC input cases in the serial reader suite
Shane-Sayoko Nov 24, 2026
06fd30b
Test(lr): use the suite timeout for NACV regressions
Shane-Sayoko Nov 26, 2026
4174ec2
Refactor(lr): spell out NAC types and simplify CTest resources
Shane-Sayoko Nov 26, 2026
7a1b501
Merge upstream develop and retain both serial input test suites
Shane-Sayoko Nov 26, 2026
2011d1d
Style: apply cmake-format to build and test registrations
Shane-Sayoko Nov 26, 2026
636ae68
Merge develop into abacus-nacv and restore 2x2 factorization coverage
Shane-Sayoko Nov 29, 2026
be44f95
Fix NACV orbital contractions in builds without LibRI
Shane-Sayoko Nov 29, 2026
40ced17
Fix(lr): reject singlet NAC requests for scalar triplet roots
Shane-Sayoko Nov 30, 2026
9b1c748
Merge branch 'develop' into abacus-nacv
Shane-Sayoko Nov 30, 2026
6cf1be7
Merge develop and port NACV integration to LR::Core
Shane-Sayoko Nov 30, 2026
defbc36
Merge branch 'develop' into abacus-nacv
Shane-Sayoko Nov 30, 2026
c740af4
Merge branch 'develop' into abacus-nacv
Shane-Sayoko Nov 30, 2026
2858a21
Refactor(lr): name NAC geometry and channel energy arguments
Shane-Sayoko Dec 1, 2026
166bbc6
Merge official develop into abacus-nacv
Shane-Sayoko Dec 1, 2026
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
1 change: 1 addition & 0 deletions docs/advanced/elec_properties/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Electronic Properties and Outputs
density_matrix
position_matrix
Berry_phase
nacv
142 changes: 142 additions & 0 deletions docs/advanced/elec_properties/nacv.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# Analytic auxiliary-TDA derivative couplings

The real Gamma-point `ks-lr` solver can calculate analytic nuclear derivative
couplings between the ground state and a TDA excited state, or between two TDA
excited states. These couplings differentiate the spin-adapted or collinear
unrestricted auxiliary determinant expansion built from the canonical
Kohn–Sham orbitals and normalized
TDA amplitudes. They are not full quadratic-response TDDFT couplings.

## Input and scope

Enable the force-response infrastructure with `cal_force 1`, solve the required
roots with `lr_nstates`, and request ascending surface pairs, for example:

```text
esolver_type ks-lr
gamma_only 1
cal_force 1
lr_nstates 3
lr_nac_pairs 0 1 1 2
```

Surface zero denotes the ground state. Excited-state indices are one-based.
The default empty `lr_nac_pairs` disables NAC calculations. When `lr_nstates`
is automatic (nonpositive), requested surfaces are checked against the resolved
number of LR roots before any state is accessed. For the default closed-shell singlet, the pair list is the only
NAC-specific input needed. To tighten the default CG response tolerance of
`1e-6` Ry or raise the limit of 100 iterations, specify, for example:

```text
lr_grad_thr 1e-10
lr_grad_maxiter 800
```

These controls apply to NAC CG orbital response. A direct response solver
such as `lr_grad_solver lapack` ignores them.
If the recursive CG residual converges before the explicitly reapplied residual,
the solver retains its accumulated solution and restarts a correction equation
with the true residual. All correction updates count toward the same limit;
this does not relax the requested accuracy.

Use one real Gamma point, `kpar 1` and `vh_in_h 1`. Hartree-disabled debugging
configurations are rejected because NAC orbital response includes the Hartree kernel. For a nonmagnetic closed-shell reference,
a run with `nspin 1` can request NACs only when `lr_target_spin singlet` (the
default). Setting `lr_target_spin triplet` solves only triplet roots, so the
default singlet NAC request cannot be evaluated. To calculate closed-shell
triplet NACs, use `nspin 2` and `lr_nac_spin triplet`.
For an unrestricted reference, use `nspin 2` and `lr_nac_spin updown`. The latter
uses both alpha and beta orbital spaces at fixed reference M_S; it does not
project onto a pure total-spin eigenstate or enable spin-flip couplings.
Both spin channels must have nonempty occupied and virtual spaces.
An explicitly unrestricted nonmagnetic reference (`lr_unrestricted true`)
uses the same `updown` channel.
The occupied bands must be fully occupied and the virtual bands empty, up to
floating-point roundoff. Fractional occupations, including a thermally smeared
frontier or an odd-electron spin-summed reference, are rejected: the required
occupation-response terms are not part of this auxiliary-determinant model.
The occupied and virtual LR windows must include every occupied and virtual
orbital of the basis: `nocc + nvirt = nbasis` separately in each spin channel.
Zero-padding a truncated amplitude window does not restore the omitted orbital response. Noncollinear/SOC,
spin-flip couplings, general complex k points, DFT+U and pseudopotentials with
nonlinear
core corrections are outside this implementation's scope. Ground–triplet
couplings vanish for a closed-shell spin-adapted reference with a spin-free
Hamiltonian; this zero rule does not apply to the unrestricted `updown` channel.
Ordinary ground-state support
for a functional does not by itself imply that its LR kernel, third XC
derivatives and analytic NAC response are available or verified.
The NAC evaluator rejects unavailable ground-state and LR response combinations,
including a meta-GGA reference with an unrelated available LR kernel. The
resolved reference and response names are checked once at the NAC batch entry,
after the KS/LR reference is available. Ground-state aliases
are resolved before selecting the ground-state response
kernel; use the corresponding canonical name for `xc_kernel`.

## Definition, units and output

For normalized real auxiliary electronic states, the raw coupling is
`d_AB = <Phi_A | d/dR | Phi_B>`. The ETF form removes the antisymmetric
moving-atomic-orbital connection, `d_ETF = d_raw - d_AO`. Reversing the state pair
changes the sign of all three vectors. It leaves the gap-weighted numerators
unchanged because the energy gap also changes sign.

Records are written to the existing running log on its writer rank; this
feature does not create a separate output file for every pair. The existing log
keeps its enclosing solver's lifecycle. The separate-file controls
`out_app_flag` and `out_freq_ion` do not create or select NAC files: the requested
records appear in the running log at every solved LR geometry.
Each `NACV_BEGIN` record contains the one-based geometry index, bra and ket
surfaces, spin label, resolved-gap flag and signed energy gap in Hartree.
Each `NACV_COMPONENT` contains the zero-based atom and Cartesian-axis indices,
then raw, ETF and AO vectors in bohr^-1, followed by raw and ETF numerators in
Hartree/bohr. `NACV_END` terminates the pair record. The public C++ result stores
energies in Ry and numerators in Ry/bohr.

`LR_EIGENPAIR` records give the geometry, spin, excited-state index, excitation
energy and independently reapplied operator-residual norm, in Hartree. A gap
is resolved only when its magnitude exceeds the sum of the two certified
residual norms and a floating-point roundoff bound. For an unresolved gap,
the finite numerators remain available and the divided vectors are zero with
the resolved flag false. These zeros must not be interpreted as physical zero
couplings. No artificial gap clipping is applied.

When NAC output is enabled, existing excitation-energy and amplitude files retain
all nonzero coefficients at full double precision, including magnitudes at or below
`1e-10`. Successful writes are confirmed with their absolute paths in the running
log. An open, write, flush or close failure aborts the output operation.

## Numerical checks and interpretation

Independent finite differences should use the same pseudopotentials, orbital
basis, functional, full LR orbital window and converged electronic states.
Check at least two displacement sizes and verify their convergence. Electronic
phases and state identities must be consistent between geometries. Individual
couplings inside a degenerate manifold depend on the chosen state gauge;
state-by-state comparison without subspace alignment is not unique.

Raw coupling finite differences require electronic overlaps between displaced
geometries. An independent ETF check additionally differentiates the moving-AO
connection numerically and subtracts that numerical connection from the raw
finite difference. Subtracting the tested analytic AO term would not provide
an independent ETF reference. A rigid-translation sum is a useful additional
diagnostic but does not replace these componentwise checks.

Agreement with finite differences tests the implementation at the chosen
numerical settings. Convergence with respect to real-space grid cutoff,
orbital basis and excited-state representation is a separate accuracy question.
Near small gaps, tighter LR and orbital-response residuals may be needed before
reducing the finite-difference step size.

## HSE response and historical finite differences

The HSE response includes two changes from upstream
[PR #8329](https://github.com/deepmodeling/abacus-develop/pull/8329).
The ground-state orbital-response kernel first uses the original density-gradient
invariant σ and retries with a floor if its coefficients are nonfinite.
The LR gradient applies the chain rule to the clipped σ.

The MgO/HSE finite-difference comparison reported for the earlier NACV snapshot
predates the merge of these changes. Its 70/72 component checks and 36/36
step-size checks describe that calculation. A comparison for the current
implementation requires a new run with the same geometry, basis and displacements.
6 changes: 6 additions & 0 deletions source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ OBJS_IO=module_parameter/input_conv.o\
module_parameter/read_input_item_md.o\
module_parameter/read_inp_ofdft.o\
module_parameter/read_input_item_sdft.o\
module_parameter/nacv_input.o\
module_parameter/read_inp_tddft.o\
module_parameter/read_inp_bse.o\
module_parameter/read_inp_deepks.o\
Expand Down Expand Up @@ -1223,6 +1224,11 @@ OBJS_LR_GRAD=lr_force.o\
grad_jt.o\
gradient_output.o\
lr_grad_cs.o\
nacv.o\
nacv_ao.o\
nacv_response.o\
nacv_solver.o\
nacv_tools.o\
window_response.o\
window_response_math.o\
lr_grad_os.o\
Expand Down
78 changes: 78 additions & 0 deletions source/source_base/module_external/scalapack_connector.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,30 @@ extern "C"
void pzdotc_(int* n, std::complex<double>* dot, std::complex<double>* x, int* ix, int* jx, int* descx, int* incx,
std::complex<double>* y, int* iy, int* jy, int* descy, int* incy);

void pdgetrf_(
const int *m,
const int *n,
double *a,
const int *ia,
const int *ja,
const int *desca,
int *ipiv,
int *info);
void pdgetrs_(
const char *trans,
const int *n,
const int *nrhs,
const double *a,
const int *ia,
const int *ja,
const int *desca,
const int *ipiv,
double *b,
const int *ib,
const int *jb,
const int *descb,
int *info);

void pdpotrf_(char *uplo, int *n, double *a, int *ia, int *ja, int *desca, int *info);
// void pzpotrf_(char *uplo, int *n, double _Complex *a, int *ia, int *ja, int *desca, int *info);
void pzpotrf_(char *uplo, int *n, std::complex<double> *a, int *ia, int *ja, int *desca, int *info);
Expand Down Expand Up @@ -407,6 +431,60 @@ class ScalapackConnector
symm(side, uplo, m, n, alpha, a, desc, b, desc, beta, c, desc);
}

/** @brief Factor a real distributed matrix, retaining pivots for later RHS batches. */
static inline void getrf(
const int m,
const int n,
double *a,
const int ia,
const int ja,
const int *desca,
int *ipiv,
int *info)
{
pdgetrf_(
&m,
&n,
a,
&ia,
&ja,
desca,
ipiv,
info);
}

/** @brief Solve with a previously computed real distributed LU factorization. */
static inline void getrs(
const char trans,
const int n,
const int nrhs,
const double *a,
const int ia,
const int ja,
const int *desca,
const int *ipiv,
double *b,
const int ib,
const int jb,
const int *descb,
int *info)
{
pdgetrs_(
&trans,
&n,
&nrhs,
a,
&ia,
&ja,
desca,
ipiv,
b,
&ib,
&jb,
descb,
info);
}

static inline
void getrf(
const int M, const int N,
Expand Down
13 changes: 10 additions & 3 deletions source/source_esolver/esolver_lr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void ModuleESolver::ESolver_LR<T, TR>::runner(BaseCell &basecell, const int iste
ModuleBase::TITLE("ESolver_LR", "runner");
ModuleBase::timer::start("ESolver_LR", "runner");

const bool nac_requested = !this->inp_->lr_nac_pairs.empty();
if (this->ks_)
{
// `init_pot_groundstate` leaves the global XC type on the LR kernel, so put it back before
Expand All @@ -62,10 +63,10 @@ void ModuleESolver::ESolver_LR<T, TR>::runner(BaseCell &basecell, const int iste
XC_Functional::set_xc_type(ucell.atoms[0].ncpp.xc_func);
this->ks_->runner(ucell, istep);
this->conv_esolver = this->ks_->conv_esolver;
if (this->inp_->calculation == "relax" && !this->conv_esolver)
if ((this->inp_->calculation == "relax" || nac_requested) && !this->conv_esolver)
{
ModuleBase::WARNING_QUIT(
"ESolver_LR", "Excited-state relaxation requires a converged ground-state SCF; ionic step rejected");
"ESolver_LR", "LR forces and derivative couplings require a converged ground-state SCF; ionic step rejected");
}
this->lr_.relax.etot_gs = this->ks_->cal_energy();
if (!this->ks_initialized_)
Expand All @@ -84,7 +85,7 @@ void ModuleESolver::ESolver_LR<T, TR>::runner(BaseCell &basecell, const int iste
this->pelec->ekb.create(this->lr_.dim.nspin, this->lr_.dim.nstates);

// solve the TDA eigenproblem (or read its states back under `lr_solver = spectrum`)
this->lr_.solve(this->pelec->ekb.c, istep);
const std::vector<std::vector<double>> nac_residuals = this->lr_.solve(this->pelec->ekb.c, istep);

if (this->ks_ && this->inp_->cal_force && !this->lr_.relax.target.active())
{
Expand Down Expand Up @@ -127,6 +128,12 @@ void ModuleESolver::ESolver_LR<T, TR>::runner(BaseCell &basecell, const int iste
<< std::defaultfloat << std::endl;
}

if (nac_requested)
{
const int geometry_index = istep + 1;
this->lr_.run_nac(this->pelec->ekb, nac_residuals, geometry_index);
}

ModuleBase::timer::end("ESolver_LR", "runner");
return;
}
Expand Down
1 change: 1 addition & 0 deletions source/source_io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ add_library(
module_parameter/read_inp_ofdft.cpp
module_parameter/read_input_item_sdft.cpp
module_parameter/read_inp_tddft.cpp
module_parameter/nacv_input.cpp
module_parameter/read_inp_bse.cpp
module_parameter/read_inp_dfpt.cpp
module_parameter/read_inp_deepks.cpp
Expand Down
4 changes: 4 additions & 0 deletions source/source_io/module_parameter/input_parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,17 @@ struct Input_para
std::vector<double> ocp_kb = {}; ///< OCP kb values

// ============== #Parameters (10.lr-tddft) ===========================
std::vector<int> lr_nac_pairs; ///< Optional pairs with S0=0 and LR roots counted from one.
std::string lr_nac_spin = "singlet"; ///< Closed-shell spin manifold for NAC output.
int lr_nstates = 1; ///< the number of 2-particle states to be solved
int lr_target_state = 0; ///< which excited state the geometry relaxation follows (0-based)
std::string lr_target_spin = "singlet"; ///< nspin=1 LR channel, or relaxation target at nspin=2: singlet / triplet / updown
double lr_degen_thr
= 0.0; ///< max excitation-energy spread of a degenerate multiplet whose gradient matrix is computed (Ry); 0 disables
std::string lr_degen_mode = "state"; ///< what a relaxation follows when the target state sits in a degenerate multiplet: state / average
std::string lr_grad_solver = "cg"; ///< the linear solver of the Z-vector equation for LR-TDDFT gradients: cg / lapack / scalapack / scalapack_chol / elpa
double lr_grad_thr = 1e-6; ///< Absolute true CG response residual bound in Ry.
int lr_grad_maxiter = 100; ///< Maximum CG response updates;official compatibility default.
std::vector<std::string> lr_init_xc_kernel = {}; ///< The method to initalize the xc kernel
int nocc = -1; ///< the number of occupied orbitals to form the 2-particle basis
int nvirt = 1; ///< the number of virtual orbitals to form the 2-particle basis (nocc + nvirt <= nbands)
Expand Down
Loading
Loading