Skip to content

Commit

Permalink
remove implementation error dispatches
Browse files Browse the repository at this point in the history
Signed-off-by: Rachel Kurchin <[email protected]>
  • Loading branch information
rkurchin committed Nov 19, 2021
1 parent b3b7a45 commit a149162
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/atoms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ end
StaticAtom(position, element) = StaticAtom{length(position)}(position, element)
position(atom::StaticAtom) = atom.position
species(atom::StaticAtom) = atom.element
velocity(::StaticAtom) = missing

function StaticAtom(position, symbol::Union{Integer,AbstractString,Symbol,AbstractVector})
StaticAtom(position, elements[symbol])
Expand Down
16 changes: 7 additions & 9 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ import Base.position
export AbstractSystem
export BoundaryCondition, DirichletZero, Periodic
export species, position, velocity
export bounding_box, boundary_conditions, is_periodic, n_dimensions
export bounding_box, boundary_conditions, periodicity, n_dimensions

"""
velocity(p)
Return the velocity of a particle `p`.
"""
velocity(p)::Union{Unitful.Velocity,Missing} = missing
function velocity end

"""
position(p)
Return the position of a particle `p`.
"""
position(p)::Unitful.Length = error("Implement me")
function position end

"""
species(p)
Return the species of a particle `p`.
"""
species(p) = error("Implement me")
function species end

#
# Identifier for boundary conditions per dimension
Expand All @@ -50,18 +50,16 @@ abstract type AbstractSystem{D,S} end
Return a vector of length `D` of vectors of length `D` that describe the "box" in which the system `sys` is defined.
"""
(bounding_box(::AbstractSystem{D})::SVector{D,SVector{D,<:Unitful.Length}}) where {D} =
error("Implement me")
function bounding_box end

"""
boundary_conditions(sys::AbstractSystem{D})
Return a vector of length `D` of `BoundaryCondition` objects, one for each direction described by `bounding_box(sys)`.
"""
(boundary_conditions(::AbstractSystem{D})::SVector{D,BoundaryCondition}) where {D} =
error("Implement me")
function boundary_conditions end

is_periodic(sys::AbstractSystem) = [isa(bc, Periodic) for bc in boundary_conditions(sys)]
periodicity(sys::AbstractSystem) = [isa(bc, Periodic) for bc in boundary_conditions(sys)]

# Note: Can't use ndims, because that is ndims(sys) == 1 (because of indexing interface)
n_dimensions(::AbstractSystem{D}) where {D} = D
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ using PeriodicTable
@testset "System" begin
@test bounding_box(aos) == [[1, 0, 0], [0, 1, 0], [0, 0, 1]]u"m"
@test boundary_conditions(aos) == [Periodic(), Periodic(), DirichletZero()]
@test is_periodic(aos) == [1, 1, 0]
@test periodicity(aos) == [1, 1, 0]
@test n_dimensions(aos) == 3
@test position(aos) == [[0.25, 0.25, 0.25], [0.75, 0.75, 0.75]]u"m"
@test position(aos, 1) == [0.25, 0.25, 0.25]u"m"
Expand Down

2 comments on commit a149162

@rkurchin
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/49053

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" a14916246753efbdd5975dc4c1e17167eb68e59c
git push origin v0.1.0

Please sign in to comment.