Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mfherbst committed Nov 30, 2024
1 parent ce14127 commit e0d5e82
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
10 changes: 5 additions & 5 deletions docs/src/ecosystem/atomsbase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ scfres = self_consistent_field(basis, tol=1e-8);

# ### Reading a system using AtomsIO
#
# Read a file using [AtomsIO](https://github.com/mfherbst/AtomsIO.jl),
# which directly yields an AbstractSystem.
#
using AtomsIO
system = load_system("Si.extxyz");

## Read a file using [AtomsIO](https://github.com/mfherbst/AtomsIO.jl),
## which directly yields an AbstractSystem.
system = load_system("Si.extxyz")

## Now run the LDA calculation:
# Run the LDA calculation:
pseudopotentials = Dict(:Si => "hgh/lda/si-q4")
model = model_DFT(system; pseudopotentials, functionals=LDA(), temperature=1e-3)
basis = PlaneWaveBasis(model; Ecut=15, kgrid=[4, 4, 4])
Expand Down
2 changes: 1 addition & 1 deletion docs/src/ecosystem/input_output.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ save_scfres("iron_afm.jld2", scfres)
# (Cleanup files generated by this notebook.)
rm.(["iron_afm.vts", "iron_afm.jld2",
"iron_afm.json", "iron_afm_energies.json", "iron_afm_scfres.json",
"iron_afm_bands.json"])
"iron_afm_bands.json"]);
4 changes: 2 additions & 2 deletions examples/pseudopotentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ using Plots
# package. See [the documentation of PseudoPotentialData](https://juliamolsim.github.io/PseudoPotentialData.jl/stable/)
# for the list of available pseudopotential families.

pseudopotentials_upf = PseudoFamily("dojo.nc.sr.lda.v0_4_1.oncvpsp3.standard.upf")
pseudopotentials_upf = PseudoFamily("dojo.nc.sr.lda.v0_4_1.oncvpsp3.standard.upf");

# Such a `PseudoFamily` object acts like a dictionary from an element symbol
# to a pseudopotential file. They can be directly employed to select the
Expand All @@ -59,7 +59,7 @@ pseudopotentials_upf = PseudoFamily("dojo.nc.sr.lda.v0_4_1.oncvpsp3.standard.upf
# a plain
# `Dict` to map from atomic symbols to the employed pseudopotential file.
# This we employ in combination with the HGH-type pseudopotentials:
pseudopotentials_hgh = Dict(:Si => "hgh/lda/si-q4.hgh")
pseudopotentials_hgh = Dict(:Si => "hgh/lda/si-q4.hgh");

# First, we'll take a look at the energy cutoff convergence of these two pseudopotentials.
# For both pseudos, a reference energy is calculated with a cutoff of 140 Hartree, and
Expand Down
8 changes: 4 additions & 4 deletions src/elements.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ local_potential_real(el::ElementCoulomb, r::Real) = -el.Z / r
struct ElementPsp <: Element
Z::Int # Nuclear charge
symbol::Symbol # Element symbol
mass # Atomic mass
psp # Pseudopotential data structure
mass # Atomic mass
end
function Base.show(io::IO, el::ElementPsp)
pspid = isempty(el.psp.identifier) ? "custom" : el.psp.identifier
if el.mass == atomic_mass(el)
print(io, "ElementPsp($(el.symbol); psp=\"$pspid\")")
print(io, "ElementPsp($(el.symbol), \"$pspid\")")
else
print(io, "ElementPsp($(el.symbol); psp=\"$pspid\", mass=\"$(el.mass)\")")
print(io, "ElementPsp($(el.symbol), \"$pspid\"; mass=\"$(el.mass)\")")
end
end

Expand Down Expand Up @@ -130,7 +130,7 @@ function ElementPsp(symbol::Symbol, family::AbstractDict; mass=element(symbol).a
end
function ElementPsp(symbol::Symbol, psp; mass=element(symbol).atomic_mass)
Z = periodic_table[symbol].number
ElementPsp(Z, symbol, mass, psp)
ElementPsp(Z, symbol, psp, mass)
end
ElementPsp(symbol::Symbol, psp::Nothing; kwargs...) = ElementCoulomb(symbol; kwargs...)
ElementPsp(key, psp; kwargs...) = ElementPsp(Symbol(periodic_table[key].symbol), psp; kwargs...)
Expand Down
15 changes: 14 additions & 1 deletion src/external/atoms_calculators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,20 @@ end
AtomsCalculators.energy_unit(::DFTKCalculator) = u"hartree"
AtomsCalculators.length_unit(::DFTKCalculator) = u"bohr"

# TODO DFTKCalculator needs a custom show function (both brief and detailed)
function Base.show(io::IO, calc::DFTKCalculator)
fields = String[]
for key in (:functionals, :pseudopotentials, :temperature, :smearing)
if haskey(calc.params.model_kwargs, key)
push!(fields, "$key=$(getproperty(calc.params.model_kwargs, key))")
end
end
for key in (:Ecut, :kgrid)
if haskey(calc.params.basis_kwargs, key)
push!(fields, "$key=$(getproperty(calc.params.basis_kwargs, key))")
end
end
print(io, "DFTKCalculator($(join(fields, ", ")))")
end

"""
Construct a [AtomsCalculators](https://github.com/JuliaMolSim/AtomsCalculators.jl)
Expand Down

0 comments on commit e0d5e82

Please sign in to comment.