diff --git a/docs/src/ecosystem/atomsbase.jl b/docs/src/ecosystem/atomsbase.jl index e6adafcda1..7272d43696 100644 --- a/docs/src/ecosystem/atomsbase.jl +++ b/docs/src/ecosystem/atomsbase.jl @@ -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]) diff --git a/docs/src/ecosystem/input_output.jl b/docs/src/ecosystem/input_output.jl index 7e9341d787..0e465e4709 100644 --- a/docs/src/ecosystem/input_output.jl +++ b/docs/src/ecosystem/input_output.jl @@ -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"]); diff --git a/examples/pseudopotentials.jl b/examples/pseudopotentials.jl index a968bb978f..3132d4048b 100644 --- a/examples/pseudopotentials.jl +++ b/examples/pseudopotentials.jl @@ -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 @@ -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 diff --git a/src/elements.jl b/src/elements.jl index e17c3bc134..e5b702085b 100644 --- a/src/elements.jl +++ b/src/elements.jl @@ -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 @@ -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...) diff --git a/src/external/atoms_calculators.jl b/src/external/atoms_calculators.jl index d93e68ea50..618652399e 100644 --- a/src/external/atoms_calculators.jl +++ b/src/external/atoms_calculators.jl @@ -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)