Skip to content

Commit

Permalink
Merge pull request #1 from cesmix-mit/dev
Browse files Browse the repository at this point in the history
update for InteratomicPotentials v0.2 compatibility
  • Loading branch information
jrdegreeff authored May 7, 2022
2 parents 0f848c4 + fc2ec2b commit 12e9957
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
Binary file removed .DS_Store
Binary file not shown.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.jl.cov
*.jl.*.cov
*.jl.mem

# generated docs
docs/build/
docs/src/generated/

Manifest.toml

# LAMMPS artifacts
log.lammps

# macOS
.DS_Store
4 changes: 2 additions & 2 deletions src/InteratomicBasisPotentials.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module InteratomicBasisPotentials

using InteratomicPotentials
using StaticArrays
using StaticArrays
using LinearAlgebra
using AtomsBase
using Unitful
Expand All @@ -19,5 +19,5 @@ export RPI, RPIParams, get_rpi # ACE

# Export Basis set evaluations
export evaluate_basis, evaluate_basis_d, evaluate_basis_v, evaluate_full
export energy_and_force, virial_stress

end # module
12 changes: 6 additions & 6 deletions src/basis_potentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ abstract type BasisParameters end
################################################################################
# InteratomicPotentials API implmentations for basis potentials
################################################################################
import InteratomicPotentials.energy_and_force
import InteratomicPotentials.virial_stress
function InteratomicPotentials.energy_and_force(A::AbstractSystem, p::BasisPotential)
import InteratomicPotentials: energy_and_force, virial_stress, ENERGY_UNIT, FORCE_UNIT

function energy_and_force(A::AbstractSystem, p::BasisPotential)
B, dB, _ = evaluate_full(A, p.basis_params)
e = sum(B) p.coefficients
f = [SVector{3}(di' * p.coefficients) for di in dB]
e = sum(B) p.coefficients * ENERGY_UNIT
f = [SVector{3}(di' * p.coefficients) for di in dB] * FORCE_UNIT
(; e, f)
end

function virial_stress(A::AbstractSystem, p::BasisPotential)
sum(SVector{6}(di p.coefficients) for di in evaluate_basis_v(A, p.basis_params))
sum(SVector{6}(di p.coefficients) for di in evaluate_basis_v(A, p.basis_params)) * ENERGY_UNIT
end
4 changes: 2 additions & 2 deletions test/SNAP/snap_test_single_element.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ end
@test sum(vB[3] - reshape(vA[:, 3], :, 6)) < 1e-5


@test isa(potential_energy(system, SNAP(ones(num_coeffs), snap) ), Float64)
@test isa(force(system, SNAP(ones(num_coeffs), snap)), AbstractVector{<:SVector{3,<:AbstractFloat}})
@test isa(potential_energy(system, SNAP(ones(num_coeffs), snap)), Unitful.Energy)
@test isa(force(system, SNAP(ones(num_coeffs), snap)), AbstractVector{<:SVector{3,<:Unitful.Force}})

0 comments on commit 12e9957

Please sign in to comment.