From fb3a6ae27e05ab57949b4f6e4949c4f4509560b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Teemu=20J=C3=A4rvinen?= Date: Tue, 10 Sep 2024 19:18:35 -0700 Subject: [PATCH] AtomsBase v0.4 support --- Project.toml | 4 ++-- src/atoms.jl | 13 +++++-------- test/test_atomsbase.jl | 4 ++-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Project.toml b/Project.toml index 828c60f..43a9419 100644 --- a/Project.toml +++ b/Project.toml @@ -34,11 +34,11 @@ ZipFile = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea" [compat] ACEbase = "0.4" AlgebraicMultigrid = "0.5, 0.6" -AtomsBase = "0.3" +AtomsBase = "0.4" Calculus = "0.5" CommonSubexpressions = "0.2, 0.3" DataDeps = "0.7" -ExtXYZ = "0.1" +ExtXYZ = "0.2" ForwardDiff = "0.10" FunctionWrappers = "1" Interpolations = "0.13, 0.14, 0.15" diff --git a/src/atoms.jl b/src/atoms.jl index bb30409..ff955bf 100644 --- a/src/atoms.jl +++ b/src/atoms.jl @@ -96,11 +96,11 @@ function Atoms(sys::AtomsBase.AbstractSystem) M = [ ustrip(u"u", AtomsBase.atomic_mass(sys,i) ) for i in 1:length(sys) ] Z = [ (AtomicNumber ∘ AtomsBase.atomic_number)(sys,i) for i in 1:length(sys) ] cell = map( x -> ustrip.(u"Å", x), sys[:bounding_box]) - pbc = map( x -> x == AtomsBase.Periodic ? true : false , AtomsBase.boundary_conditions(sys)) + pbc = JVec(AtomsBase.periodicity(sys)) data = Dict{Any,JData{eltype(M)}}( String(key)=>JData(sys[key]) for key in keys(sys) - if !( key in (:bounding_box, :boundary_conditions) ) + if !( key in (:bounding_box, :periodicity) ) ) - return JuLIP.Atoms(X, M .* V, M, Z, hcat(cell...)', pbc; data=data) + return JuLIP.Atoms(X, M .* V, M, Z, hcat(cell...)', pbc, nothing; data=data) end @@ -112,14 +112,11 @@ function AtomsBase.FlexibleSystem(sys::Atoms) v = (sys.P[i] ./ sys.M[i]) * sqrt(u"eV/u") AtomsBase.Atom(s, r, v; atomic_mass=m) end - pbc = map( sys.pbc ) do a - a ? AtomsBase.Periodic() : AtomsBase.DirichletZero() - end - cell = [ c * u"Å" for c in eachrow(sys.cell) ] + cell = Tuple( c * u"Å" for c in eachrow(sys.cell) ) data = Dict( Symbol(key)=>val.data for (key,val) in sys.data ) - return AtomsBase.FlexibleSystem(atoms, cell, pbc; data...) + return AtomsBase.FlexibleSystem(atoms, cell, sys.pbc; data...) end Base.convert(::Type{Atoms}, a::AtomsBase.AbstractSystem) = Atoms(a) diff --git a/test/test_atomsbase.jl b/test/test_atomsbase.jl index 8600479..7ba1ba0 100644 --- a/test/test_atomsbase.jl +++ b/test/test_atomsbase.jl @@ -50,8 +50,8 @@ hh = FlexibleSystem(a) a1 = AtomsBase.Atom( :Ti, [1.4175416,1.3076719,2.0027419]u"Å" ) a2 = AtomsBase.Atom( :Al, [-0.0784151, -0.17961, -0.0164296]u"Å" ) -cell = [ [2.65283, 0.0, 0.0]u"Å", [0.0, 2.65283, 0.0273594]u"Å", [0.0, 0.0, 3.82503]u"Å" ] -pbc = [Periodic(), Periodic(), Periodic()] +cell = ( [2.65283, 0.0, 0.0]u"Å", [0.0, 2.65283, 0.0273594]u"Å", [0.0, 0.0, 3.82503]u"Å" ) +pbc = (true, true, true) ab = FlexibleSystem([a1,a2], cell, pbc)