diff --git a/README.md b/README.md index aed0fa5..f466c59 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,10 @@ See `?bulk` and `?rattle!` for more information. ## Contributions -The current version of the package is essentially a copy-paste of a subset of functionality from an older package that is no longer developed. Contributions to expand the capabilities, improve the implementation, or entirely replace it are very welcome. Some packages that contain overlapping functionalities that could replace or add to `AtomsBuilder.jl` include +The current version of the package is essentially a copy-paste of a subset of functionality from an older package that is no longer developed. I needed this functionality to starting moving over my workflow to the AtomsBase eco-system. Contributions to expand the capabilities, improve the implementation, or entirely replace it are very welcome. There are most certainly more general and more elegant implementations available than what I provide. Some packages that contain overlapping functionalities that could replace or add to `AtomsBuilder.jl` include * [`Electrum.jl`](https://github.com/brainandforce/Electrum.jl) * [`AtomsToolbox.jl`](https://github.com/rashidrafeek/AtomsToolbox.jl) +* [`SimpleCrystals.jl`](https://github.com/ejmeitz/SimpleCrystals.jl) +* [`Packmol.jl`](https://github.com/m3g/Packmol.jl) +* [`ASEconvert.jl`](https://github.com/mfherbst/ASEconvert.jl) + diff --git a/src/utils.jl b/src/utils.jl index e241962..964ca70 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -28,6 +28,27 @@ _set_position(x::Atom, 𝐫) = Atom(; position = 𝐫, atomic_number = x.atomic_number, atomic_symbol = x.atomic_symbol) +function _get_positions(at::FlexibleSystem) + [ x.position for x in at.particles ] +end + +function _set_positions(at::FlexibleSystem, + X::AbstractVector{SVector{3, T}}) where {T} + particles = [ _set_position(at.particles[i], X[i]) + for i in 1:length(at) ] + return FlexibleSystem(particles, at.bounding_box, at.boundary_conditions) +end + +function _get_atomic_numbers(at::FlexibleSystem) + [ x.atomic_number for x in at.particles ] +end + +function _set_atomic_numbers(at::FlexibleSystem, Z::AbstractVector{<: Integer}) + particles = [ Atom(Z[i], x.position, x.velocity) + for (i, x) in enumerate(at.particles) ] + return FlexibleSystem(particles, at.bounding_box, at.boundary_conditions) +end + """ ```