From 1d5a6665887d651e8aef34cdaed997367ede1364 Mon Sep 17 00:00:00 2001 From: Rachel Kurchin Date: Mon, 16 Jan 2023 13:58:17 -0500 Subject: [PATCH] get atomic numbers and masses from symbols Signed-off-by: Rachel Kurchin --- src/fast_system.jl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/fast_system.jl b/src/fast_system.jl index 8cf91f2..3ead127 100644 --- a/src/fast_system.jl +++ b/src/fast_system.jl @@ -12,7 +12,17 @@ struct FastSystem{D, L <: Unitful.Length, M <: Unitful.Mass} <: AbstractSystem{D atomic_masses::Vector{M} end -# Constructor to fetch the types +# Constructor to fetch the types and numbers/masses +function FastSystem(box, boundary_conditions, positions, atomic_symbols) + elements = element.(atomic_symbols) + atomic_numbers = getproperty.(elements, :number) + atomic_masses = getproperty.(elements, :atomic_mass) + FastSystem{length(box),eltype(eltype(positions)),eltype(atomic_masses)}( + box, boundary_conditions, positions, atomic_symbols, atomic_numbers, atomic_masses + ) +end + +# constructor to fetch the types where numbers/masses are explicitly provided function FastSystem(box, boundary_conditions, positions, atomic_symbols, atomic_numbers, atomic_masses) FastSystem{length(box),eltype(eltype(positions)),eltype(atomic_masses)}( box, boundary_conditions, positions, atomic_symbols, atomic_numbers, atomic_masses