Skip to content

Feature&Fix: Correct implementation of length-gauge electric fields and ionic forces in RT-TDDFT​ (Useful information for fixed-bug version of rt-TDDFT) #6441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 15, 2025

Conversation

AsTonyshment
Copy link
Collaborator

@AsTonyshment AsTonyshment commented Aug 13, 2025

Description

This PR addresses a critical implementation error in length-gauge RT-TDDFT.

1. Critical Bug Fix

  • The original implementation incorrectly assumed cubic lattice symmetry (orthogonal axes with a=b=c). Calculations were accidentally correct only for cubic systems due to hidden simplifications in the coordinate transformations. Now it can properly handle arbitrary lattice vectors.
  • Correct calculation of ionic forces under multi-directional electric fields and arbitrary field combinations (e.g., simultaneous x+y+z directions with mixed Gaussian/Heaviside pulses).

2. Validation

  • Verified against non-cubic lattices and multi-directional field. A system of single He atom is used (since it is electrically neutral, the resultant force it experiences in an electric field should be zero). Results (fcs is the total force, and fefield_tddft is the ionic electric field force, the unit is eV/Å):
    截屏2025-08-13 下午8 33 18

3. Completely rewritten RT-TDDFT documentation

@ESROAMER
Copy link
Collaborator

ESROAMER commented Aug 14, 2025

The validation looks good. The result is proved to be internally consistent in the length gauge. But I still want to confirm the details about the direction of the electric field. Generally, we work with two types of coordinates: fractional(direct) coordinates and Cartesian coordinates, the latter always being orthogonal. The conversion between the two coordinate systems is given by:
$x_{c}=Ax_{d}$
where A denotes the matrix of lattice vectors. I noticed your changes at line 195 in H_TDDFT_pw.cpp. I suppose it assumes the electric field direction in INPUT parameters is in the direct coordinates, and here it's being converted to Cartesian coordinates? The vector potentials in the velocity gauge and the hybrid gauge don't involve additional directional transformations and align with the direction of $E(t)$. In the velocity gauge, the direction is actually determined by the interface of gradient, while in the hybrid gauge it's actually determined by the interface of r matrix. Both gauges treat the input electric field direction as being along the Cartesian coordinate system by default.(I'm not entirely certain.) Therefore, there might be inconsistencies in the default electric field directions across different gauges here.
I suggest we might need cross-gauge testing for verification, though these tests could certainly be conducted after this PR gets merged.

@AsTonyshment
Copy link
Collaborator Author

@ESROAMER Yes, this PR changed the direction of electric field in length gauge to Cartesian coordinates, which should be consistent with velocity gauge and hybrid gauge. Line 195 basically means projecting to the Cartesian x-axis:
$$\vec{E}_x\cdot \vec{r}=E\vec{e}_x\cdot (i \vec{a}+j \vec{b}+k \vec{c})=E(i a_x+j b_x+ k c_x)$$
where $\vec{a},\vec{b},\vec{c}$ are lattice vectors, and $(i,j,k)$ are lattice fractional coordinate of a space point $\vec{r}$. You can also see this in the change of the documentation of this PR, in which I made furthermore clarification:
image
But I think your suggestion is right, I will conduct a cross-gauge testing to make sure everything is right in the near future.

@ESROAMER
Copy link
Collaborator

I see, thanks for your clarification. I'll do some tests as well.

@mohanchen mohanchen added Bugs Bugs that only solvable with sufficient knowledge of DFT Refactor Refactor ABACUS codes Useful Information Useful information for others to learn/study labels Aug 15, 2025
@mohanchen mohanchen changed the title Feature&Fix: Correct implementation of length-gauge electric fields and ionic forces in RT-TDDFT​ Feature&Fix: Correct implementation of length-gauge electric fields and ionic forces in RT-TDDFT​ (Useful information for fixed-bug version of rt-TDDFT) Aug 15, 2025
@mohanchen mohanchen merged commit ba9276a into deepmodeling:develop Aug 15, 2025
14 checks passed
@AsTonyshment AsTonyshment deleted the fix_TDDFT_length_force branch August 16, 2025 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugs Bugs that only solvable with sufficient knowledge of DFT Refactor Refactor ABACUS codes Useful Information Useful information for others to learn/study
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants