Skip to content

Commit

Permalink
Merge pull request #3 from epolack/cell_to_supercell
Browse files Browse the repository at this point in the history
Cell to supercell
  • Loading branch information
LaurentVidal95 authored Oct 20, 2022
2 parents 1972d2f + 4529158 commit 40e81fd
Show file tree
Hide file tree
Showing 92 changed files with 1,427 additions and 910 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.5.8
current_version = 0.5.11
commit = True
tag = False

Expand Down
28 changes: 24 additions & 4 deletions CITATION.bib
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
% Extended abstract describing DFTK along with a short summary of its features
@article{DFTKjcon,
author = {Michael F. Herbst and Antoine Levitt and Eric Cancès},
author = {Herbst, Michael F. and Levitt, Antoine and Cancès, Eric},
doi = {10.21105/jcon.00069},
journal = {Proc. JuliaCon Conf.},
title = {DFTK: A Julian approach for simulating electrons in solids},
Expand All @@ -9,13 +9,33 @@ @article{DFTKjcon
year = {2021},
}

% Paper describing the calculation of response properties in DFTK.
% Used for forward-diff derivatives, `solve_ΩplusK_split` and `apply_χ0` functions.
@unpublished{ResponseCalculations,
author = {Cancès, Eric and Herbst, Michael F. and Kemlin, Gaspard and Levitt, Antoine and Stamm, Benjamin},
title = {Numerical Stability and Efficiency of Response Property Calculations in Density Functional Theory},
year = {Submitted},
note = {https://arxiv.org/abs/2210.04512},
}

% Paper describing the energy cutoff smearing method `BlowupCHV`
@unpublished{BlowupCHV,
author = {Cancès, Eric and Hassan, Muhammad and Vidal, Laurent Vidal},
title = {Modified-Operator Method for the Calculation of Band Diagrams of Crystalline Materials},
year = {Submitted},
note = {https://hal.archives-ouvertes.fr/hal-03794000/},
}

% Paper describing the adaptive damping strategy implemented by
% the scf_potential_mixing_adaptive function
@unpublished{AdaptiveDamping,
@article{AdaptiveDamping,
author = {Herbst, Michael F. and Levitt, Antoine},
doi = {10.1016/j.jcp.2022.111127},
journal = {Journal of Computational Physics},
title = {A robust and efficient line search for self-consistent field iterations},
year = {submitted},
note = {arXiv:2109.14018},
volume = {459},
pages = {111127},
year = {2022},
}

% Paper describing the HybridMixing, DielectricMixing and LdosMixing SCF preconditioners
Expand Down
27 changes: 27 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: 'DFTK: The Density-functional toolkit'
message: Cite this paper whenever you use DFTK.
type: software
authors:
- email: [email protected]
given-names: Michael F.
family-names: Herbst
affiliation: RWTH Aachen University
orcid: 'https://orcid.org/0000-0003-0378-7921'
- family-names: Levitt
given-names: Antoine
email: [email protected]
affiliation: Inria Paris
- given-names: Eric
family-names: Cancès
email: [email protected]
affiliation: 'CERMICS, Ecole des Ponts'
identifiers:
- type: doi
value: 10.21105/jcon.00069
description: Extended abstract describing the software
url: 'https://dftk.org'
license: MIT
13 changes: 7 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name = "DFTK"
uuid = "acf6eb54-70d9-11e9-0013-234b7a5f5337"
authors = ["Michael F. Herbst <[email protected]>", "Antoine Levitt <[email protected]>"]
version = "0.5.8"
version = "0.5.11"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
AtomsBase = "a963bdd2-2df7-4f54-a1ee-49d51e6be12a"
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
Brillouin = "23470ee3-d0df-4052-8b1a-8cbd6363e7f0"
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DftFunctionals = "6bd331d2-b28d-4fd3-880e-1a1c7f37947f"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
InteratomicPotentials = "a9efe35a-c65d-452d-b8a8-82646cd5cb04"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
Expand Down Expand Up @@ -48,21 +48,21 @@ spglib_jll = "ac4a9f1e-bdb2-5204-990c-47c8b2f70d4e"
[compat]
AbstractFFTs = "1"
AtomsBase = "0.2.2"
BlockArrays = "0.16.2"
Brillouin = "0.5 - 0.5.8" # Upper bound temporary until memory bug resolved.
Brillouin = "0.5.4"
ChainRulesCore = "1.15"
Conda = "1"
DftFunctionals = "0.2"
FFTW = "1"
ForwardDiff = "0.10"
GPUArraysCore = "0.1"
InteratomicPotentials = "0.2"
Interpolations = "0.12, 0.13, 0.14"
IterTools = "1"
IterativeSolvers = "0.8, 0.9"
Libxc = "0.3.9"
LineSearches = "7"
LinearMaps = "2, 3"
MPI = "0.19"
MPI = "0.19, 0.20"
NLsolve = "4"
Optim = "1"
OrderedCollections = "1"
Expand All @@ -84,6 +84,7 @@ spglib_jll = "1.15"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
DoubleFloats = "497a8b3b-efae-58df-a0af-a86822472b78"
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
Expand All @@ -101,4 +102,4 @@ WriteVTK = "64499a7a-5c06-52f2-abe2-ccb03c286192"
wannier90_jll = "c5400fa0-8d08-52c2-913f-1e3f656c1ce9"

[targets]
test = ["Test", "Aqua", "DoubleFloats", "FiniteDiff", "FiniteDifferences", "GenericLinearAlgebra", "IntervalArithmetic", "Plots", "Random", "KrylovKit", "Logging", "JLD2", "WriteVTK", "wannier90_jll", "QuadGK", "ComponentArrays"]
test = ["Test", "Aqua", "CUDA", "DoubleFloats", "FiniteDiff", "FiniteDifferences", "GenericLinearAlgebra", "IntervalArithmetic", "Plots", "Random", "KrylovKit", "Logging", "JLD2", "WriteVTK", "wannier90_jll", "QuadGK", "ComponentArrays"]
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

| **Documentation** | **Build Status** | **License** |
|:--------------------------------------------------------------------------------- |:----------------------------------------------- |:-------------------------------- |
| [![][docs-img]][docs-url] [![][ddocs-img]][ddocs-url] [![][slack-img]][slack-url] | [![][ci-img]][ci-url] [![][ccov-img]][ccov-url] | [![][license-img]][license-url] |
| [![][docs-img]][docs-url] [![][ddocs-img]][ddocs-url] [![][zulip-img]][zulip-url] | [![][ci-img]][ci-url] [![][ccov-img]][ccov-url] | [![][license-img]][license-url] |

[ddocs-img]: https://img.shields.io/badge/docs-dev-blue.svg
[ddocs-url]: https://docs.dftk.org/dev

[docs-img]: https://img.shields.io/badge/docs-stable-blue.svg
[docs-url]: https://docs.dftk.org/stable

[slack-img]: https://img.shields.io/badge/chat-on_slack-808493.svg?logo=slack
[slack-url]: https://join.slack.com/t/juliamolsim/shared_invite/zt-tc060co0-HgiKApazzsQzBHDlQ58A7g
[zulip-img]: https://img.shields.io/badge/chat-on_zulip-808493.svg?logo=zulip
[zulip-url]: https://juliamolsim.zulipchat.com/#narrow/stream/332493-dftk

[ci-img]: https://github.com/JuliaMolSim/DFTK.jl/workflows/CI/badge.svg?branch=master&event=push
[ci-url]: https://github.com/JuliaMolSim/DFTK.jl/actions
Expand Down Expand Up @@ -76,4 +76,4 @@ on github. If you want to contribute but are unsure where to start, take a look
at the list of issues tagged [good first issue](https://github.com/JuliaMolSim/DFTK.jl/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
(relatively easy tasks suitable for newcomers) or [help wanted](https://github.com/JuliaMolSim/DFTK.jl/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)
(more sizeable but well-defined and isolated).
Don't hesitate to ask for help, through github, email or the [JuliaMolSim slack][slack-url].
Don't hesitate to ask for help, through github, email or the [JuliaMolSim zulip chat][zulip-url].
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[deps]
AtomsBase = "a963bdd2-2df7-4f54-a1ee-49d51e6be12a"
Brillouin = "23470ee3-d0df-4052-8b1a-8cbd6363e7f0"
DFTK = "acf6eb54-70d9-11e9-0013-234b7a5f5337"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Expand Down
8 changes: 4 additions & 4 deletions docs/src/guide/tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ hcat(scfres.eigenvalues...)
# k-point because there are 4 occupied states in the system (4 valence
# electrons per silicon atom, two atoms per unit cell, and paired
# spins), and the eigensolver gives itself some breathing room by
# computing some extra states (see `n_ep_extra` argument to
# `self_consistent_field`). There are only 8 k-points (instead of
# 4x4x4) because symmetry has been used to reduce the amount of
# computations to just the irreducible k-points (see
# computing some extra states (see the `bands` argument to
# `self_consistent_field` as well as the [`AdaptiveBands`](@ref) documentation).
# There are only 8 k-points (instead of 4x4x4) because symmetry has been used to reduce the
# amount of computations to just the irreducible k-points (see
#md # [Crystal symmetries](@ref)
#nb # [Crystal symmetries](https://docs.dftk.org/stable/developer/symmetries/)
# for details).
Expand Down
29 changes: 28 additions & 1 deletion docs/src/publications.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,20 @@ The current DFTK reference paper to cite is

Additionally the following publications describe DFTK or one of its algorithms:

- E. Cancès, M. F. Herbst, G. Kemlin, A. Levitt and B. Stamm.
[*Numerical stability and efficiency of response property calculations in density functional theory*](https://arxiv.org/abs/2210.04512)
(Submitted).
[ArXiv:2210.04512](https://arxiv.org/abs/2210.04512).
([Supplementary material and computational scripts](https://github.com/gkemlin/response-calculations-metals)).

- E. Cancès, M. Hassan and L. Vidal.
[*Modified-Operator Method for the Calculation of Band Diagrams of Crystalline Materials.*](https://hal.archives-ouvertes.fr/hal-03794000)
(Submitted).
[hal-03794000](https://hal.archives-ouvertes.fr/hal-03794000).

- M. F. Herbst and A. Levitt.
[*A robust and efficient line search for self-consistent field iterations*](https://arxiv.org/abs/2109.14018)
(Submitted).
Journal of Computational Physics, **459**, 111127 (2022).
[ArXiv:2109.14018](https://arxiv.org/abs/2109.14018).
([Supplementary material and computational scripts](https://github.com/mfherbst/supporting-adaptive-damping/)).

Expand All @@ -41,12 +52,28 @@ Additionally the following publications describe DFTK or one of its algorithms:
The following publications report research employing DFTK as a core component.
Feel free to drop us a line if you want your work to be added here.

- J. Cazalis.
[*Dirac cones for a mean-field model of graphene*](https://arxiv.org/abs/2207.09893)
(Submitted).
[ArXiv:2207.09893](https://arxiv.org/abs/2207.09893).
([Computational script](https://github.com/JuliaMolSim/DFTK.jl/blob/f7fcc31c79436b2582ac1604d4ed8ac51a6fd3c8/examples/publications/2022_cazalis.jl)).

- E. Cancès, L. Garrigue, D. Gontier.
[*A simple derivation of moiré-scale continuous models for twisted bilayer graphene*](https://arxiv.org/abs/2206.05685)
(Submitted).
[ArXiv:2206.05685](https://arxiv.org/abs/2206.05685).

- E. Cancès, G. Dusson, G. Kemlin and A. Levitt.
[*Practical error bounds for properties in plane-wave electronic structure calculations*](https://arxiv.org/abs/2111.01470)
(Submitted).
[ArXiv:2111.01470](https://arxiv.org/abs/2111.01470).
([Supplementary material and computational scripts](https://github.com/gkemlin/paper-forces-estimator)).

- G. Dusson, I. Sigal and B. Stamm.
[*Analysis of the Feshbach-Schur method for the Fourier spectral discretizations of Schrödinger operators*](http://dx.doi.org/10.1090/mcom/3774)
Mathematics of Computation, **?**, ?? (2022).
[ArXiv:2008.10871](https://arxiv.org/abs/2008.10871).

- E. Cancès, G. Kemlin and A. Levitt.
[*Convergence analysis of direct minimization and self-consistent iterations*](https://doi.org/10.1137/20M1332864)
SIAM Journal on Matrix Analysis and Applications, **42**, 243 (2021).
Expand Down
4 changes: 2 additions & 2 deletions examples/cohen_bergstresser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ lattice = Si.lattice_constant / 2 .* [[0 1 1.]; [1 0 1.]; [1 1 0.]];

# Next we build the rather simple model and discretize it with moderate `Ecut`:
model = Model(lattice, atoms, positions; terms=[Kinetic(), AtomicLocal()])
basis = PlaneWaveBasis(model, Ecut=10.0, kgrid=(1, 1, 1));
basis = PlaneWaveBasis(model, Ecut=10.0, kgrid=(2, 2, 2));

# We diagonalise at the Gamma point to find a Fermi level …
ham = Hamiltonian(basis)
eigres = diagonalize_all_kblocks(DFTK.lobpcg_hyper, ham, 6)
εF = DFTK.compute_occupation(basis, eigres.λ; occupation_threshold=0).εF
εF = DFTK.compute_occupation(basis, eigres.λ).εF

# … and compute and plot 8 bands:
using Plots
Expand Down
20 changes: 7 additions & 13 deletions examples/energy_cutoff_smearing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@
using DFTK
using Statistics

a0 = 10.26 # Experimental lattice constant of silicon in bohr
a0 = 10.26 # Experimental lattice constant of silicon in bohr
a_list = range(a0 - 1/2, a0 + 1/2; length=20)

Ecut = 5 # very low Ecut to display big irregularities
kgrid = (2, 2, 2) # very sparse k-grid to fasten convergence
n_bands = 8 # Standard number of bands for silicon

function compute_ground_state_energy(a; Ecut, kgrid, kinetic_blowup, kwargs...)
lattice = a / 2 * [[0 1 1.];
[1 0 1.];
Expand All @@ -42,12 +38,12 @@ function compute_ground_state_energy(a; Ecut, kgrid, kinetic_blowup, kwargs...)
positions = [ones(3)/8, -ones(3)/8]
model = model_PBE(lattice, atoms, positions; kinetic_blowup)
basis = PlaneWaveBasis(model; Ecut, kgrid)
self_consistent_field(basis; kwargs...).energies.total
self_consistent_field(basis; callback=identity, kwargs...).energies.total
end

callback = info->nothing # set SCF to non verbose
E0_naive = compute_ground_state_energy.(a_list; kinetic_blowup=BlowupIdentity(),
Ecut, kgrid, n_bands, callback);
Ecut = 5 # Very low Ecut to display big irregularities
kgrid = (2, 2, 2) # Very sparse k-grid to speed up convergence
E0_naive = compute_ground_state_energy.(a_list; kinetic_blowup=BlowupIdentity(), Ecut, kgrid);

# To be compared with the same computation for a high `Ecut=100`. The naive approximation
# of the energy is shifted for the legibility of the plot.
Expand All @@ -74,8 +70,7 @@ plot!(p, a_list, E0_ref, label="Ecut=100", color=2)
# that is mathematically ensured to provide ``C^2`` regularity of the energy bands.

# Let us lauch the computation again with the modified kinetic term.
E0_modified = compute_ground_state_energy.(a_list; kinetic_blowup=BlowupCHV(),
Ecut, kgrid, n_bands, callback, );
E0_modified = compute_ground_state_energy.(a_list; kinetic_blowup=BlowupCHV(), Ecut, kgrid,);

# !!! note "Abinit energy cutoff smearing option"
# For the sake of completeness, DFTK also provides the blow-up function `BlowupAbinit`
Expand All @@ -93,8 +88,7 @@ E0_modified = compute_ground_state_energy.(a_list; kinetic_blowup=BlowupCHV(),
estimate_a0(E0_values) = a_list[findmin(E0_values)[2]]
a0_naive, a0_ref, a0_modified = estimate_a0.([E0_naive, E0_ref, E0_modified])

shift = mean(abs.(E0_modified .- E0_ref)) # again, shift for legibility of the plot

shift = mean(abs.(E0_modified .- E0_ref)) # Shift for legibility of the plot
plot!(p, a_list, E0_modified .- shift, label="Ecut=5 + BlowupCHV", color=3)
vline!(p, [a0], label="experimental a0", linestyle=:dash, linecolor=:black)
vline!(p, [a0_naive], label="a0 Ecut=5", linestyle=:dash, color=1)
Expand Down
28 changes: 4 additions & 24 deletions examples/graphene.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,7 @@ model = model_PBE(lattice, atoms, positions; temperature)
basis = PlaneWaveBasis(model; Ecut, kgrid)
scfres = self_consistent_field(basis)

## Choose the points of the band diagram, in reduced coordinates (in the (b1,b2) basis)
Γ = [0, 0, 0]
K = [ 1, 1, 0]/3
Kp = [-1, 2, 0]/3
M = (K + Kp)/2
kpath_coords = [Γ, K, M, Γ]
kpath_names = ["Γ", "K", "M", "Γ"]

## Build the path manually for now
kline_density = 20
function build_path(k1, k2)
target_Δk = 1/kline_density # the actual Δk is |k2-k1|/npt
npt = ceil(Int, norm(model.recip_lattice * (k2-k1)) / target_Δk)
[k1 + t * (k2-k1) for t in range(0, 1, length=npt)]
end
kcoords = []
for i = 1:length(kpath_coords)-1
append!(kcoords, build_path(kpath_coords[i], kpath_coords[i+1]))
end
klabels = Dict(zip(kpath_names, kpath_coords))

## Plot the bands
band_data = compute_bands(basis, kcoords; scfres.ρ)
DFTK.plot_band_data(band_data; scfres.εF, klabels)
## Construct 2D path through Brillouin zone
sgnum = 13 # Graphene space group number
kpath = irrfbz_path(model; dim=2, sgnum)
plot_bandstructure(scfres, kpath; kline_density=20)
31 changes: 5 additions & 26 deletions examples/publications/2022_cazalis.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Model of graphene confined to 2 spatial dimensions studied
# in the paper by Cazalis (arxiv, 2022, TODO add ref)
# in the paper by Cazalis (arxiv, 2022, https://arxiv.org/abs/2207.09893)
# The pure 3D Coulomb 1/|x| interaction is used, without pseudopotential.

using DFTK
Expand Down Expand Up @@ -59,30 +59,9 @@ basis = PlaneWaveBasis(model; Ecut, kgrid)
## Run SCF
scfres = self_consistent_field(basis, tol=1e-10)

## Choose the points of the band diagram, in reduced coordinates (in the (b1,b2) basis)
Γ = [0, 0, 0]
K = [ 1, 1, 0]/3
Kp = [-1, 2, 0]/3
M = (K + Kp)/2
kpath_coords = [Γ, K, M, Γ]
kpath_names = ["Γ", "K", "M", "Γ"]

## Build the path
kline_density = 20
function build_path(k1, k2)
target_Δk = 1/kline_density # the actual Δk is |k2-k1|/npt
npt = ceil(Int, norm(model.recip_lattice * (k2-k1)) / target_Δk)
[k1 + t * (k2-k1) for t in range(0, 1, length=npt)]
end
kcoords = []
for i = 1:length(kpath_coords)-1
append!(kcoords, build_path(kpath_coords[i], kpath_coords[i+1]))
end
klabels = Dict(kpath_names[i] => kpath_coords[i] for i=1:length(kpath_coords))

## Plot the bands
band_data = compute_bands(basis, kcoords; n_bands=5, scfres.ρ)
p = DFTK.plot_band_data(band_data; klabels, markersize=nothing)
## Plot bands
sgnum = 13 # Graphene space group number
p = plot_bandstructure(scfres, irrfbz_path(model; sgnum); n_bands=5)
Plots.hline!(p, [scfres.εF], label="", color="black")
Plots.ylims!(p, -Inf,Inf)
Plots.ylims!(p, (-Inf, Inf))
p
4 changes: 2 additions & 2 deletions examples/supercells.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ self_consistent_field(aluminium_setup(2); is_converged);

#-

self_consistent_field(aluminium_setup(4); is_converged, n_bands=30);
self_consistent_field(aluminium_setup(4); is_converged);

# When switching off explicitly the `LdosMixing`, by selecting `mixing=SimpleMixing()`,
# the performance of number of required SCF steps starts to increase as we increase
Expand All @@ -94,7 +94,7 @@ self_consistent_field(aluminium_setup(1); is_converged, mixing=SimpleMixing());

#-

self_consistent_field(aluminium_setup(4); is_converged, mixing=SimpleMixing(), n_bands=30);
self_consistent_field(aluminium_setup(4); is_converged, mixing=SimpleMixing());

# For completion let us note that the more traditional `mixing=KerkerMixing()`
# approach would also help in this particular setting to obtain a constant
Expand Down
Loading

0 comments on commit 40e81fd

Please sign in to comment.