Skip to content

Commit

Permalink
Merge pull request #145 from ejmeitz/patch-1
Browse files Browse the repository at this point in the history
Fix fieldnames bug in AtomsBase interface
  • Loading branch information
jgreener64 authored Jul 21, 2023
2 parents 58d3390 + 5a672de commit 2aae85c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ NearestNeighbors = "0.4"
PeriodicTable = "1.1"
Reexport = "1"
Requires = "1"
SimpleCrystals = "0.1.3"
SimpleCrystals = "0.1.6"
StaticArrays = "1.5.17"
Unitful = "1"
UnitfulChainRules = "0.1.2"
Expand Down
8 changes: 4 additions & 4 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -635,12 +635,12 @@ function System(crystal::Crystal{D};
k=Unitful.k,
force_units=u"kJ * mol^-1 * nm^-1",
energy_units=u"kJ * mol^-1") where D
atoms = [Atom(index=i, charge=a.charge, mass=a.mass) for (i, a) in enumerate(crystal.atoms)]
atoms_data = [AtomData(element=String(a.sym)) for a in crystal.atoms]
atoms = [Atom(index=i, charge=charge(a), mass=atomic_mass(a)) for (i, a) in enumerate(crystal.atoms)]
atoms_data = [AtomData(element=String(atomic_symbol(a))) for a in crystal.atoms]
coords = SimpleCrystals.position(crystal, :)

# Build bounding box
side_lengths = norm.(eachrow(bounding_box(crystal)))
side_lengths = norm.(bounding_box(crystal))
if any(typeof(crystal.lattice.crystal_family) .<: [CubicLattice, OrthorhombicLattice, TetragonalLattice])
boundary = CubicBoundary(side_lengths...)
elseif any(typeof(crystal.lattice.crystal_family) .<: [SquareLattice, RectangularLattice])
Expand Down Expand Up @@ -961,7 +961,7 @@ Base.eachindex(s::Union{System, ReplicaSystem}) = Base.OneTo(length(s))
AtomsBase.species_type(s::Union{System, ReplicaSystem}) = typeof(s[1])
AtomsBase.atomkeys(s::Union{System, ReplicaSystem}) = (:position, :velocity, :atomic_mass, :atomic_number, :charge)
AtomsBase.hasatomkey(s::Union{System, ReplicaSystem}, x::Symbol) = x in atomkeys(s)
AtomsBase.keys(sys::Union{System, ReplicaSystem}) = fieldnames(sys)
AtomsBase.keys(sys::Union{System, ReplicaSystem}) = fieldnames(typeof(sys))
AtomsBase.haskey(sys::Union{System, ReplicaSystem}, x::Symbol) = hasfield(typeof(sys), x)
Base.getindex(sys::Union{System, ReplicaSystem}, x::Symbol) =
hasfield(typeof(sys), x) ? getfield(sys, x) : KeyError("no field `$x`, allowed keys are $(keys(sys))")
Expand Down

0 comments on commit 2aae85c

Please sign in to comment.