diff --git a/Project.toml b/Project.toml index e1d14c98eb..d18021aada 100644 --- a/Project.toml +++ b/Project.toml @@ -72,8 +72,8 @@ DFTKWriteVTKExt = "WriteVTK" [compat] AbstractFFTs = "1" Artifacts = "1" -AtomsBase = "0.3.1" -AtomsCalculators = "0.1" +AtomsBase = "0.4" +AtomsCalculators = "0.2" Brillouin = "0.5.14" CUDA = "5" ChainRulesCore = "1.15" diff --git a/src/Model.jl b/src/Model.jl index 04e0128e9f..26b914b0e4 100644 --- a/src/Model.jl +++ b/src/Model.jl @@ -3,7 +3,7 @@ # A physical specification of a model. # Contains the geometry information, but no discretization parameters. # The exact model used is defined by the list of terms. -struct Model{T <: Real, VT <: Real} +struct Model{T <: Real, VT <: Real} <: AbstractSystem{3} # T is the default type to express data, VT the corresponding bare value type (i.e. not dual) # Human-readable name for the model (like LDA, PBE, ...) diff --git a/src/external/atomsbase.jl b/src/external/atomsbase.jl index 3197d1ab1b..aa7343581d 100644 --- a/src/external/atomsbase.jl +++ b/src/external/atomsbase.jl @@ -1,6 +1,14 @@ using AtomsBase # Key functionality to integrate DFTK and AtomsBase +# implement AtomsBase interface directly on `Model` object +Base.length(m::Model) = length(m.atoms) +Base.getindex(m::Model, i) = m.atoms[i] +position(m::Model, i) = DFTK.vector_red_to_cart(m, m.positions[i]) * u"a0_au" +mass(m::Model, i) = m[i].mass +species(m::Model, i) = m[i].symbol +cell(m::Model) = PeriodicCell((m.lattice[:,1], m.lattice[:,2], m.lattice[:,3]), (true, true, true)) + function parse_system(system::AbstractSystem{D}) where {D} if !all(periodicity(system)) error("DFTK only supports calculations with periodic boundary conditions.")