Skip to content

Commit

Permalink
Add system level property definitions removed in AtomsBase 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
rashidrafeek committed Dec 7, 2024
1 parent 493696e commit ba88d15
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
10 changes: 8 additions & 2 deletions src/AtomsToolbox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ module AtomsToolbox

using Distances: Distances, pairwise, euclidean, peuclidean,
Euclidean, PeriodicEuclidean
using AtomsBase: AbstractSystem,
using AtomsBase: AtomsBase,
AbstractSystem,
FastSystem,
FlexibleSystem,
Atom,
Expand All @@ -12,13 +13,18 @@ using AtomsBase: AbstractSystem,
atomic_symbol,
atomic_mass,
cell_vectors,
periodicity
periodicity,
species
using Unitful: Unitful, ustrip, @u_str, unit
import Graphs
using LinearAlgebra: LinearAlgebra, , det, norm, lu, ×
using StaticArrays: StaticMatrix, Size
import Base: angle, sort # To extend for AbstractSystem

# Some type piracy to deal with other packages
# Should be upstreamed or removed eventually
include("piracy.jl")

# Constants
include("constants.jl")

Expand Down
11 changes: 0 additions & 11 deletions src/getters.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
# Workaround for Unitful StaticMatrix not working.
# See: https://github.com/PainterQubits/Unitful.jl/issues/538
function Base.inv(x::StaticMatrix{N,M,T}) where {N,M,T <: Unitful.AbstractQuantity}
m = inv(ustrip.(x))
iq = eltype(m)
reinterpret(
Unitful.Quantity{iq, inv(Unitful.dimension(T)), typeof(inv(unit(T)))},
m
)
end

# Functions to find shortest distance accounting for PBC, from pymatgen.
include("pbc_utils.jl")

Expand Down
15 changes: 15 additions & 0 deletions src/piracy.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Workaround for Unitful StaticMatrix not working.
# See: https://github.com/PainterQubits/Unitful.jl/issues/538
function Base.inv(x::StaticMatrix{N,M,T}) where {N,M,T <: Unitful.AbstractQuantity}
m = inv(ustrip.(x))
iq = eltype(m)
reinterpret(
Unitful.Quantity{iq, inv(Unitful.dimension(T)), typeof(inv(unit(T)))},
m
)
end

# These were removed in the AtomsBase 0.4 update
Base.position(sys::AbstractSystem) = position.(sys, :)
AtomsBase.atomic_symbol(sys::AbstractSystem) = atomic_symbol.(species(sys, :))
AtomsBase.atomic_number(sys::AbstractSystem) = atomic_number.(species(sys, :))

0 comments on commit ba88d15

Please sign in to comment.