@@ -293,14 +293,14 @@ Input parameters:
293293
294294 # compute total δρ
295295 # TODO Can be smarter here, e.g. use mixing to come up with initial guess.
296- ε = DielectricAdjoint (ham, ρ, ψ, occupation, εF, eigenvalues, occupation_threshold,
297- bandtolalg, maxiter_sternheimer, q)
296+ ε_adj = DielectricAdjoint (ham, ρ, ψ, occupation, εF, eigenvalues, occupation_threshold,
297+ bandtolalg, maxiter_sternheimer, q)
298298 precon = FunctionPreconditioner () do Pδρ, δρ
299299 Pδρ .= vec (mix_density (mixing, basis, reshape (δρ, size (ρ));
300300 ham, basis, ρin= ρ, εF, eigenvalues, ψ))
301301 end
302302 callback_inner (info) = callback (merge (info, (; runtime_ns= time_ns () - start_ns)))
303- info_gmres = inexact_gmres (ε , vec (δρ0);
303+ info_gmres = inexact_gmres (ε_adj , vec (δρ0);
304304 tol, precon, krylovdim, maxiter, s,
305305 callback= callback_inner, kwargs... )
306306 δρ = reshape (info_gmres. x, size (ρ))
@@ -333,7 +333,7 @@ Input parameters:
333333 Axinfos= [(; basis, tol= tol* factor_final, resfinal... )]))
334334
335335 (; resfinal. δψ, δρ, δHψ, δVind, δρ0, δeigenvalues, resfinal. δoccupation,
336- resfinal. δεF, ε , info_gmres)
336+ resfinal. δεF, ε_adj , info_gmres)
337337end
338338
339339function solve_ΩplusK_split (scfres:: NamedTuple , rhs; kwargs... )
@@ -363,26 +363,26 @@ end
363363
364364@doc raw """
365365Representation of the dielectric adjoint operator ``ε^† = (1 - χ_0 K)``.
366- This is the adjoint of the dielectric operator ``(1 - K χ_0)``.
366+ This is the adjoint of the dielectric operator ``ε = (1 - K χ_0)``.
367367"""
368368function DielectricAdjoint (scfres; bandtolalg= BandtolBalanced (scfres), q= zero (Vec3{Float64}), maxiter= 100 )
369369 DielectricAdjoint (scfres. ham, scfres. ρ, scfres. ψ, scfres. occupation, scfres. εF,
370370 scfres. eigenvalues, scfres. occupation_threshold, bandtolalg, maxiter, q)
371371end
372- @timing " DielectricAdjoint" function mul_approximate (ε :: DielectricAdjoint , δρ; rtol= 0.0 , kwargs... )
373- δρ = reshape (δρ, size (ε . ρ))
374- basis = ε . ham. basis
375- δV = apply_kernel (basis, δρ; ε . ρ, ε . q)
376- res = apply_χ0 (ε . ham, ε . ψ, ε . occupation, ε . εF, ε . eigenvalues, δV;
377- miniter= 1 , ε . occupation_threshold, tol= rtol* norm (δρ),
378- ε . bandtolalg, ε . q, ε . maxiter, kwargs... )
372+ @timing " DielectricAdjoint" function mul_approximate (ε_adj :: DielectricAdjoint , δρ; rtol= 0.0 , kwargs... )
373+ δρ = reshape (δρ, size (ε_adj . ρ))
374+ basis = ε_adj . ham. basis
375+ δV = apply_kernel (basis, δρ; ε_adj . ρ, ε_adj . q)
376+ res = apply_χ0 (ε_adj . ham, ε_adj . ψ, ε_adj . occupation, ε_adj . εF, ε_adj . eigenvalues, δV;
377+ miniter= 1 , ε_adj . occupation_threshold, tol= rtol* norm (δρ),
378+ ε_adj . bandtolalg, ε_adj . q, ε_adj . maxiter, kwargs... )
379379 χ0δV = res. δρ
380380 Ax = vec (δρ - χ0δV) # (1 - χ0 K) δρ
381381 (; Ax, info= (; rtol, basis, res... ))
382382end
383- function size (ε :: DielectricAdjoint , i:: Integer )
383+ function size (ε_adj :: DielectricAdjoint , i:: Integer )
384384 if 1 ≤ i ≤ 2
385- return prod (size (ε . ρ))
385+ return prod (size (ε_adj . ρ))
386386 else
387387 return one (i)
388388 end
0 commit comments