Skip to content

Commit

Permalink
Collection of some documentation extensions and bugfixes (#873)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfherbst authored Aug 15, 2023
1 parent fa74cb7 commit b1f7a57
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 7 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.6.9
current_version = 0.6.10
commit = True
tag = False

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DFTK"
uuid = "acf6eb54-70d9-11e9-0013-234b7a5f5337"
authors = ["Michael F. Herbst <[email protected]>", "Antoine Levitt <[email protected]>"]
version = "0.6.9"
version = "0.6.10"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down
4 changes: 4 additions & 0 deletions examples/custom_potential.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ function DFTK.local_potential_fourier(el::CustomPotential, q::Real)
-el.α * exp(- (q * el.L)^2 / 2)
end

# !!! tip "Gaussian potentials and DFTK"
# DFTK already implements `CustomPotential` in form of the [`DFTK.ElementGaussian`](@ref),
# so this explicit re-implementation is only provided for demonstration purposes.

# We set up the lattice. For a 1D case we supply two zero lattice vectors
a = 10
lattice = a .* [[1 0 0.]; [0 0 0]; [0 0 0]];
Expand Down
8 changes: 6 additions & 2 deletions examples/pseudopotentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ using LazyArtifacts
import Main: @artifact_str # hide

# Here, we will use a Perdew-Wang LDA PSP from [PseudoDojo](http://www.pseudo-dojo.org/),
# which is available in the JuliaMolSim
# [PseudoLibrary](https://github.com/JuliaMolSim/PseudoLibrary).
# which is available in the
# [JuliaMolSim PseudoLibrary](https://github.com/JuliaMolSim/PseudoLibrary).
# Directories in PseudoLibrary correspond to artifacts that you can load using `artifact`
# strings which evaluate to a filepath on your local machine where the artifact has been
# downloaded.
#
# !!! note "Using the PseudoLibrary in your own calculations"
# Instructions for using the [PseudoLibrary](https://github.com/JuliaMolSim/PseudoLibrary)
# in your own calculations can be found in its documentation.

# We load the HGH and UPF PSPs using `load_psp`, which determines the
# file format using the file extension. The `artifact` string literal resolves to the
Expand Down
4 changes: 2 additions & 2 deletions src/eigen/diag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ function diagonalize_all_kblocks(eigensolver, ham::Hamiltonian, nev_per_kpoint::
@assert size(ψguessk) == (n_Gk, nev_per_kpoint)

prec = nothing
!isnothing(prec_type) && (prec = prec_type(ham.basis, kpt))
results[ik] = eigensolver(ham.blocks[ik], ψguessk;
!isnothing(prec_type) && (prec = prec_type(ham[ik]))
results[ik] = eigensolver(ham[ik], ψguessk;
prec, tol, miniter, maxiter, n_conv_check)

# Update progress bar if desired
Expand Down
6 changes: 5 additions & 1 deletion src/eigen/preconditioners.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ precondprep!(P, X) = P # This API is also used in Optim.jl
No preconditioning
"""
struct PreconditionerNone end
PreconditionerNone(basis, kpt) = I
PreconditionerNone(::PlaneWaveBasis, ::Kpoint) = I
PreconditionerNone(::HamiltonianBlock) = I

"""
(simplified version of) Tetter-Payne-Allan preconditioning
Expand All @@ -41,6 +42,9 @@ function PreconditionerTPA(basis::PlaneWaveBasis{T}, kpt::Kpoint; default_shift=
kin = kinetic_energy(kinetic_term, basis.Ecut, Gplusk_vectors_cart(basis, kpt))
PreconditionerTPA{T}(basis, kpt, kin, nothing, default_shift)
end
function PreconditionerTPA(ham::HamiltonianBlock; kwargs...)
PreconditionerTPA(ham.basis, ham.kpoint)
end

@views function ldiv!(Y, P::PreconditionerTPA, R)
if P.mean_kin === nothing
Expand Down
1 change: 1 addition & 0 deletions src/scf/nbands_algorithm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function determine_n_bands(bands::AdaptiveBands, occupation::AbstractVector,

# Determine number of bands to be computed
n_bands_compute_ε = maximum(eigenvalues) do εk
n_bands_converge > length(εk) && return length(εk) + 1
something(findlast(εnk -> εnk εk[n_bands_converge] + bands.gap_min, εk),
length(εk) + 1)
end
Expand Down

2 comments on commit b1f7a57

@mfherbst
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/89680

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.10 -m "<description of version>" b1f7a5720d2905b14162804ee722122c0768382a
git push origin v0.6.10

Please sign in to comment.