Skip to content

Feature: Support more options and features in the new script for RT-TDDFT absorption spectrum - #7464

Merged
mohanchen merged 3 commits into
deepmodeling:developfrom
AsTonyshment:update_abs_script
Jun 12, 2026
Merged

Feature: Support more options and features in the new script for RT-TDDFT absorption spectrum#7464
mohanchen merged 3 commits into
deepmodeling:developfrom
AsTonyshment:update_abs_script

Conversation

@AsTonyshment

Copy link
Copy Markdown
Collaborator

Great thanks to @ESROAMER for trying out the new script and providing highly practical suggestions!


What's changed?

1. Core Physics & Numerical Rigor Enhancements

  • Updated the FFT processing to follow standard physics conventions ($e^{i\omega t}$) by properly applying complex conjugation (np.conj) to the Fourier-transformed arrays.
  • Replaced implicit array divisions with explicit boolean masks to completely bypass NumPy complex ufunc masking bugs and prevent accidental NaN/Inf crashes during response function calculations.
  • Implemented a Fermi-Dirac-like tapering window function in the frequency domain to smoothly suppress high-energy optical responses to a designated vacuum baseline, eliminating edge divergences.
  • Expanded the Hilbert transform window with a $10\times$ padding factor to entirely eliminate periodic boundary wrap-around artifacts.

2. Robustness, Data Validation & Elastic Padding

  • Enforced a pre-execution length check on signal files. The script now early-halts with clean error messages if the available simulation steps are fewer than the requested --step_end, avoiding partial out-of-bound errors.
  • Added an automated elastic zero-padding mechanism for electric field profiles, accommodating minor line-count mismatches at the tail of the data cleanly.

3. CLI Architecture & Usability Overhaul

  • Separated the mixed choices into two orthogonal, highly flexible parameters: --response_source (dipole / current) and --spectrum_type (epsilon / sigma).
  • Programmed dynamic defaults for --signal_path based on the chosen --response_source (./OUT.ABACUS/dipole_s1.txt for dipole and ./OUT.ABACUS/current_tot.txt for current), minimizing user-end verbosity.
  • Added explicit argument overrides for visual boundary clipping via --ylim_energy and --ylim_wavelength.

4. Advanced Plotting & Structured Export

  • Designed a percentile-filtering logic (calculate_y_limits) coupled with a low-energy cutoff threshold ($0.2\text{ eV}$) to automatically ignore unphysical low-frequency divergences and produce clean plot scaling.
  • The script now automatically generates and saves individual specialized graphs—including time-series signals, full spectrum profiles (Mixed, Real-only, and Imaginary-only components for both Energy and Wavelength domains), and incident field Fourier mappings.
  • Data dumps are now properly segregated into distinct, cleanly headers-labeled real and imaginary coordinate text matrices ({type}_dat_real.txt and {type}_dat_imag.txt).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the RT‑TDDFT absorption-spectrum plotting workflow by expanding the CLI and making the absorption/response calculations more flexible (dipole vs current; epsilon vs sigma), while adding additional plotting/export features and more defensive data handling.

Changes:

  • Reworked the CLI to separate --response_source and --spectrum_type, with dynamic defaults for --signal_path and new plot viewport controls (--ylim_*, --*_range).
  • Updated response-function/KK processing logic (FFT convention handling, safer complex division strategy, Hilbert padding/tapering) and expanded the set of generated plots and exported datasets.
  • Removed the legacy dipole.py tool in favor of the consolidated script flow.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
tools/rt-tddft-tools/plot_absorption.py Major refactor: new CLI, revised spectrum computation, more robust I/O, expanded plotting and structured exports.
tools/rt-tddft-tools/dipole.py Deleted legacy implementation (functionality now covered by the updated plotting script).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/rt-tddft-tools/plot_absorption.py
Comment thread tools/rt-tddft-tools/plot_absorption.py
Comment thread tools/rt-tddft-tools/plot_absorption.py Outdated
Comment thread tools/rt-tddft-tools/plot_absorption.py
Comment thread tools/rt-tddft-tools/plot_absorption.py

@mohanchen mohanchen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for your contribution.

@mohanchen mohanchen added Refactor Refactor ABACUS codes Interfaces Interfaces with other packages labels Jun 12, 2026
@mohanchen
mohanchen merged commit 42184c5 into deepmodeling:develop Jun 12, 2026
15 checks passed
@AsTonyshment
AsTonyshment deleted the update_abs_script branch June 12, 2026 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Interfaces Interfaces with other packages Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants