-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #263 from ACEsuit/zbl
- Loading branch information
Showing
13 changed files
with
192 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
import AtomsCalculators | ||
import AtomsCalculatorsUtilities | ||
|
||
import AtomsCalculatorsUtilities.SitePotentials: SitePotential, | ||
cutoff_radius, eval_site, eval_grad_site, | ||
energy_unit, length_unit | ||
|
||
|
||
struct SitePotentialStack{TP} <: SitePotential | ||
pots::TP | ||
end | ||
|
||
function energy_unit(pot::SitePotentialStack) | ||
return energy_unit(pot.pots[1]) | ||
end | ||
|
||
function length_unit(pot::SitePotentialStack) | ||
return length_unit(pot.pots[1]) | ||
end | ||
|
||
function cutoff_radius(pot::SitePotentialStack) | ||
return maximum(cutoff_radius, pot.pots) | ||
end | ||
|
||
function eval_site(pot::SitePotentialStack, Rs, Zs, z0) | ||
return sum( eval_site(p, Rs, Zs, z0) for p in pot.pots ) | ||
end | ||
|
||
function eval_grad_site(pot::SitePotentialStack, Rs, Zs, z0) | ||
return eval_site(pot, Rs, Zs, z0), | ||
sum( eval_grad_site(p, Rs, Zs, z0)[2] for p in pot.pots ) | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
# using Pkg; Pkg.activate(joinpath(@__DIR__(), "..", "..")) | ||
## | ||
|
||
using Test | ||
using Polynomials4ML.Testing: print_tf, println_slim | ||
|
||
using ACEpotentials | ||
M = ACEpotentials.Models | ||
|
||
using Random, StaticArrays, LinearAlgebra, Unitful, EmpiricalPotentials | ||
using AtomsCalculatorsUtilities.SitePotentials: eval_site, eval_grad_site | ||
using AtomsBase | ||
## | ||
|
||
elements = [:C, :O, :H] | ||
E0s = Dict(:C => -rand(), :O => -rand(), :H => -rand()) | ||
rcut = 5.5u"Å" | ||
zbl = ZBL(rcut) | ||
V0 = M.OneBody(E0s) | ||
|
||
Vref1 = M._make_Vref(elements, E0s, false) | ||
Vref2 = M._make_Vref(elements, nothing, true, ustrip(rcut)) | ||
Vref3 = M._make_Vref(elements, E0s, true, ustrip(rcut)) | ||
|
||
zC = atomic_number(ChemicalSpecies(:C)) | ||
zO = atomic_number(ChemicalSpecies(:O)) | ||
zH = atomic_number(ChemicalSpecies(:H)) | ||
|
||
Rs0 = SVector{3, Float64}[] | ||
Zs0 = Int[] | ||
nZ = rand(3:5) | ||
Rs1 = randn(SVector{3, Float64}, nZ) | ||
Zs1 = rand([zC, zO, zH], nZ) | ||
|
||
## | ||
|
||
print_tf(@test (eval_site(zbl, Rs0, Zs0, zC) == 0.0 )) | ||
print_tf(@test (eval_site(zbl, Rs0, Zs0, zO) == 0.0 )) | ||
print_tf(@test (eval_site(zbl, Rs0, Zs0, zH) == 0.0 )) | ||
print_tf(@test (eval_site(V0, Rs0, Zs0, zC) == E0s[:C] )) | ||
print_tf(@test (eval_site(V0, Rs0, Zs0, zO) == E0s[:O] )) | ||
print_tf(@test (eval_site(V0, Rs0, Zs0, zH) == E0s[:H] )) | ||
println() | ||
|
||
## | ||
|
||
for (Rs, Zs) in [ (Rs0, Zs0), (Rs1, Zs1)], z in [zC, zO, zH] | ||
print_tf(@test ( eval_site(Vref1, Rs, Zs, z) == eval_site(V0, Rs, Zs, z) )) | ||
print_tf(@test ( eval_site(Vref2, Rs, Zs, z) == eval_site(zbl, Rs, Zs, z) )) | ||
print_tf(@test ( eval_site(Vref3, Rs, Zs, z) == eval_site(V0, Rs, Zs, z) + eval_site(zbl, Rs, Zs, z) )) | ||
print_tf(@test ( eval_grad_site(Vref1, Rs, Zs, z) == eval_grad_site(V0, Rs, Zs, z) )) | ||
print_tf(@test ( eval_grad_site(Vref2, Rs, Zs, z) == eval_grad_site(zbl, Rs, Zs, z) )) | ||
print_tf(@test ( eval_grad_site(Vref3, Rs, Zs, z)[2] == eval_grad_site(V0, Rs, Zs, z)[2] + eval_grad_site(zbl, Rs, Zs, z)[2] )) | ||
end | ||
println() | ||
|
||
## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters