Atom Structure
New atom structure SimpleAtom
is a bits type structure that aims to be a simple small structure.
The main advantage of SimpleAtom
over the default atom type of AtomsBase is that it is bitstype. The second advantage is that it does not have Dict
to hold custom data, thus making it a lot more smaller data structure.
Create SimpleAtoms
You can create SimpleAtom
in one of the following ways
julia> SimpleAtom(:H, [0.0, 0.0, 0.0]u"Å")
SimpleAtom(H, Z = 1, m = 1.008 u): position : [0,0,0]u"Å" species : H
julia> SimpleAtom( 1, [0.0, 0.0, 0.0]u"Å") # same as above
SimpleAtom(H, Z = 1, m = 1.008 u): position : [0,0,0]u"Å" species : H
julia> SimpleAtom(:O, [1.0, 0.0, 0.0]u"Å", [0.1, 0.0, 0.0]u"Å/s"; mass = 16.0u"u", charge = -1.0u"q")
SimpleAtom(O, Z = 8, m = 16.0 u): position : [1,0,0]u"Å" velocity : [0.1,0,0]u"Å s^-1" species : O charge : -1.602176634e-19 C
julia> SimpleAtom(ChemicalSpecies(:H), [0.0, 0.0, 0.0]u"Å")
SimpleAtom(H, Z = 1, m = 1.008 u): position : [0,0,0]u"Å" species : H
julia> SimpleAtom( :O => [1.0, 0.0, 0.0]u"Å" )
SimpleAtom(O, Z = 8, m = 15.999 u): position : [1,0,0]u"Å" species : O
You can add extra atomkeys to an existing atom, by creating a new SimpleAtom
and adding a keyword argument
sa = SimpleAtom(:H, [0.0, 0.0, 0.0]u"Å")
SimpleAtom(sa; charge = 1.0u"q" ) # add charge
Vector of SimpleAtoms
Vector os SimpleAtoms has basic AtomsBase interface implemented
julia> va = [ SimpleAtom(i, i * ones(3)u"Å") for i in 1:5 ]
5-element Vector{SimpleAtom{3, @NamedTuple{species::ChemicalSpecies, position::StaticArraysCore.SVector{3, Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}, Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}: SimpleAtom(H, [ 1, 1, 1]u"Å") SimpleAtom(He, [ 2, 2, 2]u"Å") SimpleAtom(Li, [ 3, 3, 3]u"Å") SimpleAtom(Be, [ 4, 4, 4]u"Å") SimpleAtom(B, [ 5, 5, 5]u"Å")
julia> species(va, 3)
Li
julia> position(va, 4)
3-element StaticArraysCore.SVector{3, Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}} with indices SOneTo(3): 4.0 Å 4.0 Å 4.0 Å
julia> mass(va, :)
5-element Vector{Quantity{Float64, 𝐌, Unitful.FreeUnits{(u,), 𝐌, nothing}}}: 1.008 u 4.002602 u 6.94 u 9.0121831 u 10.81 u
julia> hasatomkey(va, :velocity)
false
julia> cell(va)
IsolatedCell{3, Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}()