Skip to content

Commit

Permalink
treat rin for ace1
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Ortner committed Sep 20, 2024
1 parent ec34a73 commit 4406009
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/ace1_compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,19 @@ function _get_all_rcut(kwargs; _rcut = kwargs[:rcut])
end


function _rin0cuts_rcut(zlist, cutoffs::Dict)
function _rin0cuts_rcut(zlist, cutoffs::Dict, kwargs = nothing)
function _get_r0(zi, zj)
if kwargs == nothing
return DefaultHypers.bond_len(zi, zj)
elseif kwargs[:r0] == :bondlen
return DefaultHypers.bond_len(zi, zj)
elseif kwargs[:r0] isa Number
return kwargs[:r0]
end
error("Cannot determine r0($zi, $zj) from the arguments provided.")
end
function rin0cut(zi, zj)
r0 = DefaultHypers.bond_len(zi, zj)
r0 = _get_r0(zi, zj)
rin, rcut = cutoffs[zi, zj]
return (rin = rin, r0 = r0, rcut = rcut)
end
Expand All @@ -166,18 +176,23 @@ function _rin0cuts_rcut(zlist, cutoffs::Dict)
end


function _ace1_rin0cuts(kwargs; rcutkey = :rcut)
function _ace1_rin0cuts(kwargs; rcutkey = :rcut, rinkey = :rin)
elements = _get_elements(kwargs)
rcut = _get_all_rcut(kwargs; _rcut = kwargs[rcutkey])
if kwargs[:rin] isa Number
rin = kwargs[:rin]
else
error("Cannot read rin; please provide a number of file an issue if a more general mechanism is needed.")
end
if rcut isa Number
cutoffs = Dict([ (s1, s2) => (0.0, rcut) for s1 in elements, s2 in elements]...)
cutoffs = Dict([ (s1, s2) => (rin, rcut) for s1 in elements, s2 in elements]...)
else
cutoffs = Dict([ (s1, s2) => (0.0, rcut[(s1, s2)]) for s1 in elements, s2 in elements]...)
cutoffs = Dict([ (s1, s2) => (rin, rcut[(s1, s2)]) for s1 in elements, s2 in elements]...)
end
# rcut = maximum(values(rcut)) # multitransform wants a single cutoff.

# construct the rin0cut structures
rin0cuts = _rin0cuts_rcut(elements, cutoffs)
rin0cuts = _rin0cuts_rcut(elements, cutoffs, kwargs)
end


Expand Down

0 comments on commit 4406009

Please sign in to comment.