Skip to content

Commit

Permalink
uk->us (JuliaMolSim#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoine-levitt authored Apr 28, 2020
1 parent c49daaa commit 4d54626
Show file tree
Hide file tree
Showing 50 changed files with 110 additions and 110 deletions.
2 changes: 1 addition & 1 deletion codegen/xc_fallback/lda_c_vwn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# LDA correlation according to Vosko Wilk,and Nusair, (DOI 10.1139/p80-159)
#
# This version generates the "standard" parametrisation, where a Pade approximation of a
# This version generates the "standard" parametrization, where a Pade approximation of a
# numerical diffusion Monte-Carlo simulation is used.

as_rational(x) = nsimplify(Sym(x))
Expand Down
2 changes: 1 addition & 1 deletion examples/Silicon_Graphite.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"metadata": {},
"outputs": [],
"source": [
"# Discretise the model\n",
"# Discretize the model\n",
"basis = PlaneWaveBasis(model, Ecut, kgrid=kgrid);"
]
},
Expand Down
6 changes: 3 additions & 3 deletions examples/cohen_bergstresser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ Si = ElementCohenBergstresser(:Si)
lattice = Si.lattice_constant / 2 .* [[0 1 1.]; [1 0 1.]; [1 1 0.]]
atoms = [Si => [ones(3)/8, -ones(3)/8]]

# Model, discretisation and Hamiltonian
# Model, discretization and Hamiltonian
model = Model(Matrix{T}(lattice); atoms=atoms, terms=[Kinetic(), AtomicLocal()])
basis = PlaneWaveBasis(model, Ecut)

# Diagonalise (at the Gamma point) to find Fermi level used in Cohen-Bergstresser,
# Diagonalize (at the Gamma point) to find Fermi level used in Cohen-Bergstresser,
# then compute the bands
ham = Hamiltonian(basis)
eigres = diagonalise_all_kblocks(DFTK.lobpcg_hyper, ham, 6)
eigres = diagonalize_all_kblocks(DFTK.lobpcg_hyper, ham, 6)
εF = find_fermi_level(basis, eigres.λ)

ρ0 = guess_density(basis) # Just dummy, has no meaning in this model
Expand Down
2 changes: 1 addition & 1 deletion examples/gross_pitaevskii.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ terms = [Kinetic(),
PowerNonlinearity(C, α),
]
model = Model(lattice; n_electrons=n_electrons, terms=terms,
spin_polarisation=:spinless) # "spinless fermions"
spin_polarization=:spinless) # "spinless fermions"
basis = PlaneWaveBasis(model, Ecut)

scfres = direct_minimization(basis, x_tol=1e-8, f_tol=-1, g_tol=-1)
Expand Down
2 changes: 1 addition & 1 deletion examples/gross_pitaevskii_2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ terms = [Kinetic(),
Magnetic(Apot),
]
model = Model(lattice; n_electrons=n_electrons,
terms=terms, spin_polarisation=:spinless) # "spinless fermions"
terms=terms, spin_polarization=:spinless) # "spinless fermions"
basis = PlaneWaveBasis(model, Ecut)

n_bands_scf = model.n_electrons
Expand Down
2 changes: 1 addition & 1 deletion examples/magnesium_pbe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pystruct.make_supercell(supercell)
lattice = load_lattice(pystruct)
atoms = [Mg => [s.frac_coords for s in pystruct.sites]]

# Setup PBE model with Methfessel-Paxton smearing and its discretisation
# Setup PBE model with Methfessel-Paxton smearing and its discretization
model = model_DFT(lattice, atoms, [:gga_x_pbe, :gga_c_pbe];
temperature=Tsmear,
smearing=DFTK.Smearing.MethfesselPaxton1())
Expand Down
2 changes: 1 addition & 1 deletion examples/silicon_lda_arbitrary_floattype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lattice = a / 2 .* [[0 1 1.]; [1 0 1.]; [1 1 0.]]
Si = ElementPsp(:Si, psp=load_psp(:Si, functional="lda"))
atoms = [Si => [ones(3)/8, -ones(3)/8]]

# Setup LDA model and discretisation
# Setup LDA model and discretization
model = model_DFT(Array{T}(lattice), atoms, [:lda_x, :lda_c_vwn])
basis = PlaneWaveBasis(model, Ecut, kgrid=kgrid)

Expand Down
2 changes: 1 addition & 1 deletion src/DFTK.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export lobpcg_hyper
export lobpcg_scipy
export lobpcg_itsolve
export diag_full
export diagonalise_all_kblocks
export diagonalize_all_kblocks
include("eigen/diag.jl")

export KerkerMixing
Expand Down
20 changes: 10 additions & 10 deletions src/Model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ struct Model{T <: Real}
# Electrons, occupation and smearing function
n_electrons::Int # not necessarily consistent with `atoms` field

# spin_polarisation values:
# :none No spin polarisation, αα and ββ density identical,
# spin_polarization values:
# :none No spin polarization, αα and ββ density identical,
# αβ and βα blocks zero
# :collinear Spin is polarised, but everywhere in the same direction.
# :collinear Spin is polarized, but everywhere in the same direction.
# αα ̸= ββ, αβ = βα = 0
# :full Generic magnetisation, non-uniform direction.
# :full Generic magnetization, non-uniform direction.
# αβ, βα, αα, ββ all nonzero, different
# :spinless No spin at all ("spinless fermions", "mathematicians' electrons").
# Difference with :none is that the occupations are 1 instead of 2
spin_polarisation::Symbol # :none, :collinear, :full, :spinless
spin_polarization::Symbol # :none, :collinear, :full, :spinless

# If temperature=0, no fractional occupations are used.
# If temperature is nonzero, the occupations are
Expand All @@ -43,7 +43,7 @@ struct Model{T <: Real}
end

function Model(lattice::AbstractMatrix{T}; n_electrons=nothing, atoms=[], terms=[], temperature=0.0,
smearing=nothing, spin_polarisation=:none) where {T <: Real}
smearing=nothing, spin_polarization=:none) where {T <: Real}
lattice = Mat3{T}(lattice)

if n_electrons === nothing
Expand Down Expand Up @@ -73,7 +73,7 @@ function Model(lattice::AbstractMatrix{T}; n_electrons=nothing, atoms=[], terms=
unit_cell_volume = abs(det(lattice[1:d, 1:d]))
recip_cell_volume = abs(det(recip_lattice[1:d, 1:d]))

@assert spin_polarisation in (:none, :collinear, :full, :spinless)
@assert spin_polarization in (:none, :collinear, :full, :spinless)

if smearing === nothing
@assert temperature >= 0
Expand All @@ -86,7 +86,7 @@ function Model(lattice::AbstractMatrix{T}; n_electrons=nothing, atoms=[], terms=
end

Model{T}(lattice, recip_lattice, unit_cell_volume, recip_cell_volume, d, n_electrons,
spin_polarisation, T(temperature), smearing, atoms, terms)
spin_polarization, T(temperature), smearing, atoms, terms)
end


Expand Down Expand Up @@ -130,8 +130,8 @@ end
Maximal occupation of a state (2 for non-spin-polarized electrons, 1 otherwise).
"""
function filled_occupation(model)
@assert model.spin_polarisation in (:none, :spinless)
if model.spin_polarisation == :none
@assert model.spin_polarization in (:none, :spinless)
if model.spin_polarization == :none
@assert model.n_electrons % 2 == 0
filled_occ = 2
else
Expand Down
10 changes: 5 additions & 5 deletions src/PlaneWaveBasis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ Base.show(io::IO, basis::PlaneWaveBasis) =
Base.eltype(basis::PlaneWaveBasis{T}) where {T} = T

function build_kpoints(model::Model{T}, fft_size, kcoords, Ecut) where T
model.spin_polarisation in (:none, :collinear, :spinless) || (
error("$(model.spin_polarisation) not implemented"))
model.spin_polarization in (:none, :collinear, :spinless) || (
error("$(model.spin_polarization) not implemented"))
spin = (:undefined,)
if model.spin_polarisation == :collinear
if model.spin_polarization == :collinear
spin = (:up, :down)
elseif model.spin_polarisation == :none
elseif model.spin_polarization == :none
spin = (:both, )
elseif model.spin_polarisation == :spinless
elseif model.spin_polarization == :spinless
spin = (:spinless, )
end

Expand Down
2 changes: 1 addition & 1 deletion src/densities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ end
"""
compute_density(basis::PlaneWaveBasis, ψ::AbstractVector, occupation::AbstractVector)
Compute the density for a wave function `ψ` discretised on the plane-wave grid `basis`,
Compute the density for a wave function `ψ` discretized on the plane-wave grid `basis`,
where the individual k-Points are occupied according to `occupation`. `ψ` should
be one coefficient matrix per k-Point.
"""
Expand Down
6 changes: 3 additions & 3 deletions src/eigen/diag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ that really does the work, operating on a single ``k``-Block.
`eigensolver` should support the API `eigensolver(A, X0; prec, tol, maxiter)`
`prec_type` should be a function that returns a preconditioner when called as `prec(ham, kpt)`
"""
function diagonalise_all_kblocks(eigensolver, ham::Hamiltonian, nev_per_kpoint::Int;
function diagonalize_all_kblocks(eigensolver, ham::Hamiltonian, nev_per_kpoint::Int;
guess=nothing,
prec_type=PreconditionerTPA, interpolate_kpoints=true,
tol=1e-6, miniter=1, maxiter=200, n_conv_check=nothing,
Expand All @@ -33,7 +33,7 @@ function diagonalise_all_kblocks(eigensolver, ham::Hamiltonian, nev_per_kpoint::
elseif interpolate_kpoints && ik > 1
# use information from previous kpoint
X0 = interpolate_kpoint(results[ik - 1].X, kpoints[ik - 1], kpoints[ik])
guessk = Matrix{T}(qr(X0).Q) # Re-orthogonalise and renormalise
guessk = Matrix{T}(qr(X0).Q) # Re-orthogonalize and renormalize
else
# random initial guess
qrres = qr(randn(T, length(G_vectors(kpoints[ik])), nev_per_kpoint))
Expand Down Expand Up @@ -62,7 +62,7 @@ end

@doc raw"""
Function to select a subset of eigenpairs on each ``k``-Point. Works on the
Tuple returned by `diagonalise_all_kblocks`.
Tuple returned by `diagonalize_all_kblocks`.
"""
function select_eigenpairs_all_kblocks(eigres, range)
merge(eigres, (λ=[λk[range] for λk in eigres.λ],
Expand Down
2 changes: 1 addition & 1 deletion src/eigen/lobpcg_hyper_impl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ end

import LinearAlgebra: cholesky
function cholesky(X::Union{Matrix{ComplexF16}, Hermitian{ComplexF16,Matrix{ComplexF16}}})
# Cholesky factorisation above may promote the type
# Cholesky factorization above may promote the type
# (e.g. Float16 is promoted to Float32. This undoes it)
# See https://github.com/JuliaLang/julia/issues/16446
U = cholesky(ComplexF32.(X)).U
Expand Down
2 changes: 1 addition & 1 deletion src/eigen/preconditioners.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ end
function PreconditionerTPA(basis::PlaneWaveBasis, kpt::Kpoint{T}; default_shift=1) where T
kin = Vector{T}([sum(abs2, basis.model.recip_lattice * (G + kpt.coordinate))
for G in G_vectors(kpt)] ./ 2)
@assert basis.model.spin_polarisation in (:none, :collinear, :spinless)
@assert basis.model.spin_polarization in (:none, :collinear, :spinless)
PreconditionerTPA{T}(basis, kpt, kin, nothing, default_shift)
end

Expand Down
4 changes: 2 additions & 2 deletions src/elements.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ function ElementCohenBergstresser(key; lattice_constant=nothing)
unit_cell_volume = det(lattice_constant / 2 .* [[0 1 1]; [1 0 1]; [1 1 0]])

# The form factors in the Cohen-Bergstresser paper Table 2 are
# with respect to normalised planewaves (i.e. not plain Fourier coefficients)
# and are already symmetrised into a sin-cos basis (see derivation p. 141)
# with respect to normalized planewaves (i.e. not plain Fourier coefficients)
# and are already symmetrized into a sin-cos basis (see derivation p. 141)
# => Scale by Ω / 2 to get them into the DFTK convention
V_sym = Dict(key => value * unit_cell_volume / 2
for (key, value) in pairs(data[symbol].form_factors))
Expand Down
26 changes: 13 additions & 13 deletions src/external/abinit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function run_abinit_scf(infile::PyObject, outdir)

# Adjust common infile settings:
infile.set_vars(
paral_kgb=0, # Parallelisation over k-Points and Bands
paral_kgb=0, # Parallelization over k-Points and Bands
iomode=3, # Use NetCDF output
istwfk="*1", # Needed for extracting the wave function later
)
Expand Down Expand Up @@ -81,14 +81,14 @@ function run_abinit_scf(model::Model, outdir;
tolvrs=tol, # General tolerance settings
)

# Spin-polarisation
if model.spin_polarisation == :spinless
error("spin_polarisation == spinless is not supported by abinit")
elseif model.spin_polarisation == :none
# Spin-polarization
if model.spin_polarization == :spinless
error("spin_polarization == spinless is not supported by abinit")
elseif model.spin_polarization == :none
infile.set_vars(nsppol=1, nspinor=1, nspden=1)
elseif model.spin_polarisation == :collinear
elseif model.spin_polarization == :collinear
infile.set_vars(nsppol=2, nspinor=1, nspden=2)
elseif model.spin_polarisation == :full
elseif model.spin_polarization == :full
infile.set_vars(nsppol=1, nspinor=2, nspden=4)
end

Expand Down Expand Up @@ -119,14 +119,14 @@ function run_abinit_scf(model::Model, outdir;
end
end

# Spin-polarisation
if model.spin_polarisation == :spinless
error("spin_polarisation == spinless is not supported by abinit")
elseif model.spin_polarisation == :none
# Spin-polarization
if model.spin_polarization == :spinless
error("spin_polarization == spinless is not supported by abinit")
elseif model.spin_polarization == :none
infile.set_vars(nsppol=1, nspinor=1, nspden=1)
elseif model.spin_polarisation == :collinear
elseif model.spin_polarization == :collinear
infile.set_vars(nsppol=2, nspinor=1, nspden=2)
elseif model.spin_polarisation == :full
elseif model.spin_polarization == :full
infile.set_vars(nsppol=1, nspinor=2, nspden=4)
end

Expand Down
2 changes: 1 addition & 1 deletion src/external/etsf_nanoquanta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct EtsfFolder
end

"""
Initialise a EtsfFolder from the path to the folder which contains
Initialize a EtsfFolder from the path to the folder which contains
the data in the ETSF Nanoquanta format.
"""
function EtsfFolder(folder::AbstractString)
Expand Down
4 changes: 2 additions & 2 deletions src/external/pymatgen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ function pymatgen_bandstructure(basis, λ, εF, klabels)
Spin = pyimport("pymatgen.electronic_structure.core").Spin
bandstructure = pyimport("pymatgen.electronic_structure.bandstructure")

# This assumes no spin polarisation
@assert basis.model.spin_polarisation in (:none, :spinless)
# This assumes no spin polarization
@assert basis.model.spin_polarization in (:none, :spinless)

eigenvals_spin_up = Matrix{eltype(λ[1])}(undef, length(λ[1]), length(basis.kpoints))
for (ik, λs) in enumerate(λ)
Expand Down
6 changes: 3 additions & 3 deletions src/fft.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import FFTW
Determine the minimal grid size for the cubic basis set to be able to
represent product of orbitals (with the default `supersampling=2`).
Optionally optimise the grid afterwards for the FFT procedure by
ensuring factorisation into small primes.
Optionally optimize the grid afterwards for the FFT procedure by
ensuring factorization into small primes.
The function will determine the smallest cube containing the wave vectors
``|G|^2/2 \leq E_\text{cut} ⋅ \text{supersampling}^2``.
Expand All @@ -25,7 +25,7 @@ function determine_grid_size(lattice::AbstractMatrix{T}, Ecut; supersampling=2,
end
end

# Optimise FFT grid size: Make sure the number factorises in small primes only
# Optimize FFT grid size: Make sure the number factorises in small primes only
if ensure_smallprimes
Vec3([nextprod([2, 3, 5], 2gs + 1) for gs in Gmax])
else
Expand Down
4 changes: 2 additions & 2 deletions src/fft_generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const GENERIC_FFT_LOADED = true

function next_working_fft_size(::Any, size)
# TODO FourierTransforms has a bug, which is triggered
# only in some factorisations, see
# only in some factorizations, see
# https://github.com/JuliaComputing/FourierTransforms.jl/issues/10
# To be safe we fall back to powers of two

Expand All @@ -22,7 +22,7 @@ function next_working_fft_size(::Any, size)
adjusted
end

# Generic fallback function, Float32 and Float64 specialisation in fft.jl
# Generic fallback function, Float32 and Float64 specialization in fft.jl
function build_fft_plans(T, fft_size)
tmp = Array{Complex{T}}(undef, fft_size...)

Expand Down
6 changes: 3 additions & 3 deletions src/interpolation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function interpolate_density(ρ_in::RealFourierArray, b_out::PlaneWaveBasis)
from_real(b_out, ρ_out)
end

# TODO Specialisation for the common case lattice_out = lattice_in
# TODO Specialization for the common case lattice_out = lattice_in
function interpolate_density(ρ_in::AbstractArray, grid_in, grid_out, lattice_in, lattice_out=lattice_in)
T = real(eltype(ρ_in))
@assert size(ρ_in) == grid_in
Expand Down Expand Up @@ -64,7 +64,7 @@ end

"""
Interpolate some data from one k-Point to another. The interpolation is fast, but not
necessarily exact or even normalised. Intended only to construct guesses for iterative
necessarily exact or even normalized. Intended only to construct guesses for iterative
solvers
"""
function interpolate_kpoint(data_in::AbstractVecOrMat, kpoint_in::Kpoint, kpoint_out::Kpoint)
Expand Down Expand Up @@ -102,7 +102,7 @@ function interpolate_blochwave(ψ_in, basis_in, basis_out)
# Get indices of the G vectors of the old basis inside the new basis.
idcs_out = index_G_vectors.(Ref(basis_out), G_vectors(basis_in.kpoints[ik]))

# Linearise the indices
# Linearize the indices
idcs_out = getindex.(Ref(LinearIndices(basis_out.fft_size)), idcs_out)

# Map to the indices of the corresponding G-vectors in G_vectors(kpt_out)
Expand Down
4 changes: 2 additions & 2 deletions src/occupation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end
Find the occupation and Fermi level.
"""
function find_occupation(basis::PlaneWaveBasis{T}, energies) where {T}
@assert basis.model.spin_polarisation in (:none, :spinless)
@assert basis.model.spin_polarization in (:none, :spinless)
model = basis.model
n_electrons = model.n_electrons
temperature = model.temperature
Expand Down Expand Up @@ -80,7 +80,7 @@ and zero temperature. This function is for DEBUG purposes only, and the
finite-temperature version with 0 temperature should be preferred.
"""
function find_occupation_bandgap(basis, energies)
@assert basis.model.spin_polarisation in (:none, :spinless)
@assert basis.model.spin_polarization in (:none, :spinless)
n_bands = length(energies[1])
@assert all(e -> length(e) == n_bands, energies)
n_electrons = basis.model.n_electrons
Expand Down
2 changes: 1 addition & 1 deletion src/postprocess/DOS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ function LDOS(ε, basis, eigenvalues, ψ; smearing=basis.model.smearing, T=basis

# Use compute_density routine to compute LDOS, using just the modified
# weights (as "occupations") at each kpoint. Note, that this automatically puts in the
# required symmetrisation with respect to kpoints and BZ symmetry
# required symmetrization with respect to kpoints and BZ symmetry
compute_density(basis, ψ, weights).real
end
Loading

0 comments on commit 4d54626

Please sign in to comment.