diff --git a/src/atoms.jl b/src/atoms.jl index 67c5bb4..fd3115c 100644 --- a/src/atoms.jl +++ b/src/atoms.jl @@ -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]) diff --git a/src/interface.jl b/src/interface.jl index fc54c5f..fd687ae 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -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 @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index f7af318..4f95e11 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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"