Skip to content

Hessian efficient#23

Open
mesonepigreco wants to merge 12 commits intomainfrom
hessian_efficient
Open

Hessian efficient#23
mesonepigreco wants to merge 12 commits intomainfrom
hessian_efficient

Conversation

@mesonepigreco
Copy link
Collaborator

We can use an efficient implementation of the Q-space Lanczos for computing the Hessian.
This is now implemented and working.

mesonepigreco and others added 9 commits March 18, 2026 09:09
Implement the Lanczos algorithm in q-space (Bloch basis) where momentum
conservation q1+q2=q_pert makes the 2-phonon sector block-diagonal,
reducing psi vector size and anharmonic computation cost by ~N_cell.

New files:
- Modules/QSpaceLanczos.py: Python class inheriting from DL.Lanczos with
  Hermitian Lanczos iteration, Bloch-transformed ensemble, q-pair mapping,
  and correct PG symmetry construction (Cartesian rotations from spglib
  fractional coords, manual atom permutation with lattice reduction)
- Modules/tdscha_qspace.jl: Julia extension for q-space ensemble averaging
  with separate D3/D4 functions and acoustic mode masking
- tests/test_qspace/test_qspace_lanczos.py: Test comparing q-space vs
  real-space Green functions (match within 2.4e-7 relative error)

Key fixes during development:
- Convert spglib rotations from crystal to Cartesian coords via M@R@M^{-1}
- Replace CC.symmetries.GetIRT (gives wrong atom permutations for some
  symmetries) with manual modular lattice reduction
- Include translation in Bloch phase: exp(-2πi q'·L) where L=Rτ+t-τ'
- Mask acoustic modes (ω<1e-6) in f_Y, f_psi, and chi factors

Also includes the translational projection optimization in DynamicalLanczos
(O(n^2) permutations instead of O(n^3) matmuls for gamma_only).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
New usage guide section covering the QSpaceLanczos workflow (perturbation
setup, mode looping, when to prefer q-space over real-space) and a new
API reference page with auto-generated docs via mkdocstrings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Computes the anharmonic phonon spectral function at the Brillouin zone
boundary (X point) for SnTe using the Q-space Lanczos algorithm with
the pre-existing test ensemble.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
which should solve the free energy Hessian in q space correctly.
Right now, it seems to work extremely well, except for 1 q point in the test, where none of the algorithms
seems to converge.
We need to investigate the issue.
We fixed a nasty hermitian conjugation in Q points not related to themselves by the inversion symmetries.
These q-points are not hermitian, so the Lanczos was failing in them due to a mismatch between row-major and column-major
transposition done in julia vs python.

This is fixed and now it seems to work properly.
Still an issue on IR prefactor and convergence of the bicg for that q != -q + G points is present to be fixed
(its is only a convergence issue, as by explicitly computing the full L matrix and inverting produces the correct result,
and also the standard Lanczos with no-mode-mixing produces the correct results).
@mesonepigreco mesonepigreco added this to the 1.7 milestone Mar 21, 2026
mesonepigreco and others added 3 commits March 21, 2026 12:05
Documents the q-space free energy Hessian with usage examples,
performance comparison table, and deep-dive on the algorithm
(static Liouvillian, q-space block diagonality, acoustic mode
handling, Hermiticity enforcement, symmetry reduction).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nd q-space Lanczos

This test verifies that the IR perturbation modulus matches exactly between
DynamicalLanczos and QSpaceLanczos after fixing the double mass scaling
and missing supercell factor in QSpaceLanczos.prepare_ir.

The test:
1. Creates ASR-satisfying effective charges (+I for first atom, -I for second)
2. Compares perturbation_modulus for all three polarization directions
3. Uses existing SnTe test data with 2×2×2 supercell
- Implemented prepare_raman() method in QSpaceLanczos with support for:
  - Polarized Raman (pol_vec_in, pol_vec_out)
  - Unpolarized Raman components (indices 0-6 with correct prefactors)
  - Mixed Raman tensor components

- Implemented prepare_unpolarized_raman() method for raw components
  without prefactors (matching parent class interface)

- Modified prepare_perturbation_q() to support add parameter for
  cumulative perturbations (needed for unpolarized Raman)

- Added comprehensive test test_raman_modulus.py that verifies:
  - Perturbation modulus consistency between real-space and q-space
    Lanczos for all polarized Raman components (xx, xy, yy, zz)
  - Consistency for all 7 unpolarized Raman components
  - Tests use dummy Raman tensor that satisfies translation invariance

- Fixed test setup to ensure Raman tensor is properly attached to
  ens.current_dyn (used by Lanczos constructor) rather than ens.dyn_0

All tests pass, confirming the q-space implementation matches the
real-space implementation for Raman perturbations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant