Skip to content

Commit

Permalink
AtomsCalculators support (#56)
Browse files Browse the repository at this point in the history
* AtomsCalculators support

* add combinations
  • Loading branch information
tjjarvinen authored Nov 1, 2023
1 parent 2d6723e commit 32b8727
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ACE1 = "e3f9bc04-086e-409a-ba78-e9769fe067bb"
ACE1x = "5cc4c08c-8782-4a30-af6d-550b302e9707"
ACEbase = "14bae519-eb20-449c-a949-9c58ed33163e"
AtomsBase = "a963bdd2-2df7-4f54-a1ee-49d51e6be12a"
AtomsCalculators = "a3e0e189-c65a-42c1-833c-339540406eb1"
ChunkSplitters = "ae650224-84b6-46f8-82ea-d812ca08434e"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Folds = "41a02a25-b8f0-4f67-bc48-60067656b558"
Expand All @@ -34,6 +35,7 @@ ACE1x = "0.1.8"
ACEbase = "0.4.3"
ACEfit = "0.1.4"
AtomsBase = "0.3"
AtomsCalculators = "0.1.1"
ChunkSplitters = "2"
Folds = "0.2"
Molly = "0.15, 0.16, 0.17, 0.18"
Expand Down
2 changes: 2 additions & 0 deletions src/ACEmd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ACE1
import ACE1x
using ACEbase
@reexport using AtomsBase
using AtomsCalculators
using ChunkSplitters
using Folds
@reexport using Folds: ThreadedEx, SequentialEx, DistributedEx
Expand Down Expand Up @@ -36,6 +37,7 @@ include("structs.jl")
include("api.jl")
include("backend.jl")
include("utils.jl")
include("atoms_calculators.jl")
include("submodules/ASEhelper.jl")
include("submodules/IPIprotocol.jl")

Expand Down
39 changes: 39 additions & 0 deletions src/atoms_calculators.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@


AtomsCalculators.@generate_interface function AtomsCalculators.potential_energy(
system,
calculator::ACEmd.ACEpotential;
kwargs...
)
return ace_energy(calculator, system; kwargs...)
end



AtomsCalculators.@generate_interface function AtomsCalculators.forces(
system,
calculator::ACEmd.ACEpotential;
kwargs...
)
return ace_forces(calculator, system; kwargs...)
end



AtomsCalculators.@generate_interface function AtomsCalculators.virial(
system,
calculator::ACEmd.ACEpotential;
kwargs...
)
return ace_virial(calculator, system; kwargs...)
end


function AtomsCalculators.energy_forces(system, calculator::ACEpotential; kwargs...)
return ace_energy_forces(calculator, system; kwargs...)
end


function AtomsCalculators.energy_forces_virial(system, calculator::ACEpotential; kwargs...)
return ace_energy_forces_virial(calculator, system; kwargs...)
end
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ACE1 = "e3f9bc04-086e-409a-ba78-e9769fe067bb"
ACE1x = "5cc4c08c-8782-4a30-af6d-550b302e9707"
ACEfit = "ad31a8ef-59f5-4a01-b543-a85c2f73e95c"
AtomsBase = "a963bdd2-2df7-4f54-a1ee-49d51e6be12a"
AtomsCalculators = "a3e0e189-c65a-42c1-833c-339540406eb1"
ExtXYZ = "352459e4-ddd7-4360-8937-99dcb397b478"
Molly = "aa0f7f06-fcc0-5ec4-a7f3-a573f33f9c4c"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
Expand Down
11 changes: 11 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ using ACE1
using ACE1x
using ACEfit
using AtomsBase
using AtomsCalculators.AtomsCalculatorsTesting
using ExtXYZ
using Molly
using Unitful
Expand Down Expand Up @@ -211,4 +212,14 @@ end
@test size(a,1) != size(a1,1)
@test length(y) != length(y1)
@test length(w) != length(w1)
end


@testset "AtomsCalculators interface" begin
pot = load_ace_model(fname_ace)
data = ExtXYZ.load(fname_xyz)

test_potential_energy(data, pot)
test_forces(data, pot)
test_virial(data, pot)
end

0 comments on commit 32b8727

Please sign in to comment.