@@ -29,8 +29,12 @@ from ψ and Λ is the set of Rayleigh coefficients ψk' * Hk * ψk at each k-poi
2929"""
3030@timing function apply_Ω (δψ, ψ, H:: Hamiltonian , Λ)
3131 δψ = proj_tangent (δψ, ψ)
32- Ωδψ = [H. blocks[ik] * δψk - δψk * Λ[ik] for (ik, δψk) in enumerate (δψ)]
33- proj_tangent! (Ωδψ, ψ)
32+ map (enumerate (δψ)) do (ik, δψk)
33+ Ωδψ = H. blocks[ik] * δψk
34+ mul! (Ωδψ, δψk, Λ[ik], - 1 , 1 )
35+ proj_tangent_kpt! (Ωδψ, ψ[ik])
36+ Ωδψ
37+ end
3438end
3539
3640"""
@@ -48,16 +52,18 @@ Compute the application of K defined at ψ to δψ. ρ is the density issued fro
4852 δψ = proj_tangent (δψ, ψ)
4953 δρ = compute_δρ (basis, ψ, δψ, occupation)
5054 δV = apply_kernel (basis, δρ; ρ)
55+ # normalize here so we can use unnormalized FFTs for extra speed
56+ δV .*= basis. fft_grid. ifft_normalization * basis. fft_grid. fft_normalization
5157
5258 ψnk_real = similar (G_vectors (basis), promote_type (T, eltype (ψ[1 ])))
5359 Kδψ = map (enumerate (ψ)) do (ik, ψk)
5460 kpt = basis. kpoints[ik]
5561 δVψk = similar (ψk)
5662
5763 for n = 1 : size (ψk, 2 )
58- ifft! (ψnk_real, basis, kpt, ψk[:, n])
64+ ifft! (ψnk_real, basis, kpt, ψk[:, n]; normalize = false )
5965 ψnk_real .*= δV[:, :, :, kpt. spin]
60- fft! (δVψk[:, n], basis, kpt, ψnk_real)
66+ fft! (δVψk[:, n], basis, kpt, ψnk_real; normalize = false )
6167 end
6268 δVψk
6369 end
0 commit comments