fix center(atoms) polymorphism
Browse files- generation/Shells.jl +9 -5
generation/Shells.jl
CHANGED
|
@@ -7,7 +7,7 @@ using PeriodicTable
|
|
| 7 |
using Printf
|
| 8 |
|
| 9 |
"""Type of `GaussianBasis.BasisSet` parameters"""
|
| 10 |
-
const Basis = Tuple{
|
| 11 |
|
| 12 |
"""
|
| 13 |
atom([Z, [xyz]])
|
|
@@ -47,8 +47,14 @@ Move a vector of atoms to a desired barycenter.
|
|
| 47 |
|
| 48 |
All atoms are treated as mass 1.
|
| 49 |
"""
|
| 50 |
-
function center(atoms::Vector{
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
end
|
| 53 |
|
| 54 |
#--- Parse H atom once for all
|
|
@@ -65,5 +71,3 @@ end
|
|
| 65 |
Base.show(io::IO, ::MIME"text/plain", at::Atom) = begin
|
| 66 |
show(io, Molecules.string_repr(at))
|
| 67 |
end
|
| 68 |
-
|
| 69 |
-
|
|
|
|
| 7 |
using Printf
|
| 8 |
|
| 9 |
"""Type of `GaussianBasis.BasisSet` parameters"""
|
| 10 |
+
const Basis = Tuple{Vector{A}, Vector{S}} where {A<:Atom, S<:SphericalShell}
|
| 11 |
|
| 12 |
"""
|
| 13 |
atom([Z, [xyz]])
|
|
|
|
| 47 |
|
| 48 |
All atoms are treated as mass 1.
|
| 49 |
"""
|
| 50 |
+
function center(atoms::Vector{<:Atom}, offset::SVector{3, <:Real})
|
| 51 |
+
ctr = sum(a.xyz for a in atoms) / length(atoms)
|
| 52 |
+
map(atoms) do a
|
| 53 |
+
move(a, offset - ctr)
|
| 54 |
+
end
|
| 55 |
+
end
|
| 56 |
+
function center(atoms::Vector{<:Atom})
|
| 57 |
+
center(atoms, SVector{3, Float64}([0, 0, 0]))
|
| 58 |
end
|
| 59 |
|
| 60 |
#--- Parse H atom once for all
|
|
|
|
| 71 |
Base.show(io::IO, ::MIME"text/plain", at::Atom) = begin
|
| 72 |
show(io, Molecules.string_repr(at))
|
| 73 |
end
|
|
|
|
|
|