Skip to content

Add NLCC support for phonon computations#1311

Open
Technici4n wants to merge 6 commits into
masterfrom
phonon-nlcc
Open

Add NLCC support for phonon computations#1311
Technici4n wants to merge 6 commits into
masterfrom
phonon-nlcc

Conversation

@Technici4n
Copy link
Copy Markdown
Collaborator

Cleaner than I expected. Nice framework that you built @epolack and @antoine-levitt, especially the automated testing!

@Technici4n
Copy link
Copy Markdown
Collaborator Author

I had to remove @inferred from a test unfortunately, but I just ran the full GPU (CUDA) test suite and it still works, so that shouldn't be a problem.

Copy link
Copy Markdown
Member

@antoine-levitt antoine-levitt left a comment

Choose a reason for hiding this comment

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

Haven't checked everything but looks reasonable!

Comment thread examples/phonons.jl Outdated
Comment thread src/postprocess/phonon.jl
in reduced coordinates:
```
dynmat[β, t, α, s] = ∂²E/∂u_sα(-q)∂u_tβ(q).
```
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

really not a fan of this interpretation, defining it as the derivative of the R -> F map seems much simpler to me...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That's basically what it is since dE/du is the force. But with an extra q dependency here. The main reason I put the formula there is to know in which order to write the dynmat entries, otherwise you can get the transpose by mistake.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

right but we don't use this notation elsewhere so maybe deltaF[alpha, s] = dynmat[] deltaR[]...? Any particular reason why it's beta alpha rather than alpha beta?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I put it in that order such that the RHS matches Baroni, and it also makes sense to me with Julia's column-major indexing to write it like that, no?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I mean it's usually xi = Aij xj, not xj = Aji xi

Comment thread src/postprocess/phonon.jl
for s = 1:n_atoms, α = 1:basis.model.n_dim
# Get δH ψ
δHψs_αs = compute_δHψ_αs(basis, ψ, α, s, q)
δHψs_αs = compute_δHψ_αs(basis, ψ, α, s, q; ρ)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We really need this state refactor business...

Comment thread src/terms/xc.jl
# however since the potential is real, we conjugate to obtain the -q term:
# δV = Kxc (∂ρ/∂u_sα(-q) + ∂ρcore/∂u_sα(-q))
# = conj( Kxc (∂ρ/∂u_sα( q) + ∂ρcore/∂u_sα( q)) )
δV_αs = conj.(apply_kernel(term, basis, δρs[α, s] + δρcores[α, s]; ρ, q))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Haven't followed the complete derivation but I'm scared by this line; the whole point of the explanation I gave in #1310 is that we never conjugate q stuff. Are you sure about this conj?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes 100% sure. It's also there in the local term, just hidden by Parseval's theorem. For a real function (the density is real) the conjugate should always be fine. You only get problems if you directly conjugate the psis since those are complex. I am not sure how DFPT works for spin orbit coupling or magnetic fields. Surely Dal Corso has some paper about it, but I haven't read it.

@Technici4n
Copy link
Copy Markdown
Collaborator Author

@antoine-levitt do you want to review this or should I ask Michael? :D

Copy link
Copy Markdown
Member

@antoine-levitt antoine-levitt left a comment

Choose a reason for hiding this comment

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

LGTM modulo the comments

Comment thread src/postprocess/phonon.jl
in reduced coordinates:
```
dynmat[β, t, α, s] = ∂²E/∂u_sα(-q)∂u_tβ(q).
```
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

right but we don't use this notation elsewhere so maybe deltaF[alpha, s] = dynmat[] deltaR[]...? Any particular reason why it's beta alpha rather than alpha beta?

Comment thread src/terms/xc.jl
# ∂E/∂u_tβ(q) = ∫ Vxc ∂ρcore/∂u_tβ(q)
# Differentiate again wrt. u_sα(-q) to get the dynamical matrix element:
# ∂²E/∂u_sα(-q)∂u_tβ(q) = ∫ Kxc (∂ρ/∂u_sα(-q) + ∂ρcore/∂u_sα(-q)) (∂ρcore/∂u_tβ(q))
# + ∫ Vxc ∂²ρcore/∂u_sα(-q)∂u_tβ(q)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm still not very comfortable with this d2E business, and it contrasts with the way everything else is written (as dR -> dF). Can't you write it like that?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is how Baroni writes it. I don't like to just use dF and dR as it doesn't make it clear which has q and which has -q. This derivation also directly matches the implementation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What I don't understand is what's up with the -q? The supercell mapping from dR to dF is cell-periodic, and therefore bloch theorem applies so a displacement dR_q e^iqx produces a force dF_q e^iqx, and we compute the mapping dR_q -> dF_q. No need to involve -q. Should we zoom to discuss?

Comment thread src/terms/xc.jl
function compute_δHψ_αs(term::TermXc, basis::PlaneWaveBasis, ψ, α, s, q; ρ)
isnothing(term.ρcore) && return nothing

# With an NLCC, an atom displacement triggers a change in the XC potential.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

that comment is not super helpful, just remove?

Comment thread src/density_methods.jl
# Pre-allocation of large arrays for GPU efficiency
Gs = G_vectors(basis)
ρ = to_device(basis.architecture, zeros(Complex{T}, length(Gs)))
Gqs = map(G -> G+q, G_vectors(basis))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we call those Gpk or something somewhere else?

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.

2 participants