Skip to content

Commit

Permalink
Merge pull request #65 from ACEsuit/ase_calculator_update
Browse files Browse the repository at this point in the history
Update ASE calculator helper functions
  • Loading branch information
tjjarvinen committed May 6, 2024
2 parents 2a1b6e4 + 8c7865d commit 35ca166
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ACEmd"
uuid = "69e0c927-b120-467d-b2b3-5b6842148cf4"
authors = ["Teemu Järvinen <teemu.j.jarvinen@gmail.com> and contributors"]
version = "0.1.10"
version = "0.1.11"


[deps]
Expand Down
13 changes: 7 additions & 6 deletions src/submodules/ASEhelper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module ASEhelper

using ..ACEmd
using AtomsBase
using Distributed
using StaticArrays
using Unitful

Expand All @@ -20,7 +21,7 @@ function make_system(
pbc
)
atoms = [ Atom(Symbol(s), SVector(r...) *u"Å" ) for (s, r) in zip(atom_symbols, eachrow(positions)) ]
box = [ [cell[1], 0., 0.], [0., cell[2], 0.], [0., 0., cell[3]] ]u"Å"
box = collect( eachrow(Matrix(cell)*u"Å") )
periodic = [ x ? Periodic() : DirichletZero() for x in pbc ]
sys = FlexibleSystem(atoms, box, periodic)
return sys
Expand All @@ -34,7 +35,7 @@ function ase_energy(
pbc,
)
sys = make_system(atom_symbols, positions, cell, pbc)
e = ace_energy(potential, sys)
e = fetch( @spawn ace_energy(potential, sys) )
return ustrip(u"eV", e)
end

Expand All @@ -46,7 +47,7 @@ function ase_forces(
pbc,
)
sys = make_system(atom_symbols, positions, cell, pbc)
f = ace_forces(potential, sys)
f = fetch( @spawn ace_forces(potential, sys) )
fm = reinterpret(reshape, typeof(1.0*unit(f[1][1])), f)
return ustrip.(u"eV/Å", fm)' # we need transpose for python
end
Expand All @@ -59,7 +60,7 @@ function ase_virial(
pbc,
)
sys = make_system(atom_symbols, positions, cell, pbc)
v = ace_virial(potential, sys)
v = fetch( @spawn ace_virial(potential, sys) )
return ustrip.(u"eV", v)' # we need transpose for python
end

Expand All @@ -71,7 +72,7 @@ function ase_energy_forces_virial(
pbc,
)
sys = make_system(atom_symbols, positions, cell, pbc)
tmp = ace_energy_forces_virial(potential, sys)
tmp = fetch( @spawn ace_energy_forces_virial(potential, sys) )
f = tmp["forces"]
fm = reinterpret(reshape, typeof(1.0*unit(f[1][1])), f)
e = tmp["energy"]
Expand All @@ -80,4 +81,4 @@ function ase_energy_forces_virial(
end


end
end

0 comments on commit 35ca166

Please sign in to comment.