Skip to content

Commit

Permalink
update support for InteratomicPotentials v0.2 (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrdegreeff authored Apr 27, 2022
1 parent e77e6a0 commit eeb1a56
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Brillouin = "0.5"
Conda = "1"
FFTW = "1"
ForwardDiff = "0.10"
InteratomicPotentials = "0.1"
InteratomicPotentials = "0.2"
Interpolations = "0.12, 0.13"
IterTools = "1"
IterativeSolvers = "0.8, 0.9"
Expand Down
6 changes: 3 additions & 3 deletions src/external/interatomicpotentials.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import InteratomicPotentials: ArbitraryPotential, energy_and_force
import InteratomicPotentials: NonTrainablePotential, energy_and_force

# Integration to use DFTK as an interatomic potential
# This is useful for AIMD simulations

Base.@kwdef struct DFTKPotential <: ArbitraryPotential
Base.@kwdef struct DFTKPotential <: NonTrainablePotential
functionals::Vector{Symbol} = [:gga_x_pbe, :gga_c_pbe] # default to model_PBE
model_kwargs::Dict{Symbol,Any} = Dict{Symbol,Any}()
basis_kwargs::Dict{Symbol,Any} = Dict{Symbol,Any}()
Expand All @@ -25,5 +25,5 @@ function energy_and_force(system::AbstractSystem, potential::DFTKPotential)
potential.scf_kwargs[] = scfres.ψ
potential.scf_kwargs[] = scfres.ρ

(; e=scfres.energies.total, f=compute_forces_cart(scfres))
(; e=scfres.energies.total * u"hartree", f=compute_forces_cart(scfres) * u"hartree/bohr")
end
4 changes: 2 additions & 2 deletions test/external/interatomicpotentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ using UnitfulAtomic
system = attach_psp(periodic_system(particles, box); functional="lda")

eandf = energy_and_force(system, potential)
@test eandf.e isa Float64
@test eandf.f isa AbstractVector{<:SVector{3,<:Float64}}
@test eandf.e isa Unitful.Energy
@test eandf.f isa AbstractVector{<:SVector{3,<:Unitful.Force}}

@test haskey(potential.scf_kwargs, )
@test haskey(potential.scf_kwargs, )
Expand Down

0 comments on commit eeb1a56

Please sign in to comment.