Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic Wannier.jl integration #899

Merged
merged 34 commits into from
Dec 12, 2023
Merged

Conversation

Technici4n
Copy link
Contributor

This PR adds basic Wannier.jl integration. The communication happens via the Wannier90 files at the moment; this is not the fastest, but it required the least amount of code. I split the Wannier code across wannier_shared.jl, wannier90.jl and wannier.jl, the last 2 requiring the relevant package.

I also refactored the initial projection code, to make the choice of the initial projections more flexible. Hopefully that can be extended in the future to project onto atomic orbitals without changing the API again.

Following the recommendation in one of the #854 comments, I updated the example to mention Wannier.jl first.

@Technici4n
Copy link
Contributor Author

Junfeng pushed a 0.3.2 Wannier update, unfortunately this requires Julia 1.8.4 at least. Is it acceptable to update Julia to 1.8, at least for testing? (I have 1.9 on my machine and did not catch this issue...)

@mfherbst
Copy link
Member

Yes #905. This was in the pipeline for other PRs as well.

@Technici4n
Copy link
Contributor Author

I added hydrogenic projections as an initial guess, because I wanted to try using them. The code was mostly adapted from #854 so I added a co-author note. On the basic example in DFTK, we go from 45 to 17 function calls for the optimization in the Wannierization procedure.

src/DFTK.jl Show resolved Hide resolved
@Technici4n
Copy link
Contributor Author

Technici4n commented Nov 21, 2023

@mfherbst CI is passing (except for nightly due to a @main macro conflict inside of Wannier). Does codecov need fixing too?

@Technici4n
Copy link
Contributor Author

Merge conflicts addressed. :)

Copy link
Member

@mfherbst mfherbst left a comment

Choose a reason for hiding this comment

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

Pretty nice and sorry that it took me so long to reply.

src/DFTK.jl Show resolved Hide resolved
src/common/hydrogenic.jl Outdated Show resolved Hide resolved
src/external/stubs.jl Outdated Show resolved Hide resolved
src/external/wannier.jl Outdated Show resolved Hide resolved
src/external/wannier_shared.jl Outdated Show resolved Hide resolved
src/external/wannier_shared.jl Outdated Show resolved Hide resolved
src/external/wannier_shared.jl Outdated Show resolved Hide resolved
src/external/wannier_shared.jl Outdated Show resolved Hide resolved
src/external/wannier_shared.jl Outdated Show resolved Hide resolved
src/external/wannier90.jl Outdated Show resolved Hide resolved
examples/wannier.jl Outdated Show resolved Hide resolved
@Technici4n
Copy link
Contributor Author

All comments addressed, and I moved the Wannier.jl and Wannier90 integrations to extensions as discussed earlier. We have to wait for another Wannier bump due to the Spglib bump (qiaojunfeng/Wannier.jl#35).

Copy link
Member

@mfherbst mfherbst left a comment

Choose a reason for hiding this comment

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

Small nits, otherwise ok. But definitely not the fastest code ... there are a few type instabilities and some smaller things where performance could be gained, but probably ok for now.

Project.toml Show resolved Hide resolved
examples/wannier.jl Outdated Show resolved Hide resolved
ext/DFTKWannier90Ext.jl Show resolved Hide resolved
ext/DFTKWannierExt.jl Show resolved Hide resolved
src/DFTK.jl Outdated Show resolved Hide resolved
src/external/wannier_shared.jl Outdated Show resolved Hide resolved
"""
A p-like initial guess, using the difference of two Gaussians with different centers.
"""
function opposite_gaussians_projection(center1::AbstractVector, center2::AbstractVector)
Copy link
Member

Choose a reason for hiding this comment

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

You don't like the idea of directly calling it plike and slike ? I'm not sure myself, but wanted to argue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not too sure myself. If you already know that you want a plike orbital you probably want to use HydrogenicWannierProjection anyway (or even the pswfc from the PSP in the future).

Copy link
Member

Choose a reason for hiding this comment

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

yes, that's true. Good point. OTOH this makes it questionable why this function even exists in the main code. Might be good to include in the example to show how custom projectors could be made. Maybe it's better put there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just removed it. I don't think that encouraging custom projectors is particularly a good idea, in principle it shouldn't be needed and the interface is still experimental. (I was using opposite_gaussians_projection before the hydrogenic guess was implemented, now it can be useful for comparison against the hydrogenic guess but that doesn't need to be in the mainline code).

Copy link
Member

Choose a reason for hiding this comment

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

(I was using opposite_gaussians_projection before the hydrogenic guess was implemented, now it can be useful for comparison against the hydrogenic guess but that doesn't need to be in the mainline code).

Yes, but it would be good to keep the idea documented in the wannier example. That's what I meant. Sorry if I was not clear.

src/external/wannier_shared.jl Outdated Show resolved Hide resolved
src/external/wannier_shared.jl Outdated Show resolved Hide resolved
src/external/wannier_shared.jl Outdated Show resolved Hide resolved
examples/wannier.jl Outdated Show resolved Hide resolved
examples/wannier.jl Show resolved Hide resolved
@mfherbst mfherbst merged commit d48e5ef into JuliaMolSim:master Dec 12, 2023
6 of 8 checks passed
@Technici4n Technici4n deleted the wannierjl branch December 12, 2023 16:04
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