Skip to content

Use iteration methods in basis_vectors, MetricTensor & cellparameters #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/lattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ function Lattice(a, b, c, α, β, γ)
return Lattice(a1, a2, a3)
end

function basis_vectors(lattice::Lattice)
data = lattice.data
return data[:, 1], data[:, 2], data[:, 3]
end
basis_vectors(lattice::Lattice) = lattice[:, 1], lattice[:, 2], lattice[:, 3]

centering(::Bravais{A,B}) where {A,B} = B()

Expand Down
6 changes: 2 additions & 4 deletions src/metric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ end
MetricTensor(m::AbstractMatrix) = MetricTensor(SHermitianCompact{3}(m))
function MetricTensor(𝐚::AbstractVector, 𝐛::AbstractVector, 𝐜::AbstractVector)
vecs = (𝐚, 𝐛, 𝐜)
return MetricTensor([dot(vecs[i], vecs[j]) for i in 1:3, j in 1:3])
return MetricTensor([dot(vᵢ, vⱼ) for vᵢ in vecs, vⱼ in vecs])
end
function MetricTensor(a, b, c, α, β, γ)
g₁₂ = a * b * cos(γ)
Expand All @@ -21,9 +21,7 @@ end
Lattice(g::MetricTensor) = Lattice(cellparameters(g))

function cellparameters(g::MetricTensor)
data = g.data
a², b², c², ab, ac, bc =
data[1, 1], data[2, 2], data[3, 3], data[1, 2], data[1, 3], data[2, 3]
a², b², c², ab, ac, bc = g[1, 1], g[2, 2], g[3, 3], g[1, 2], g[1, 3], g[2, 3]
a, b, c = map(sqrt, (a², b², c²))
γ, β, α = acos(ab / (a * b)), acos(ac / (a * c)), acos(bc / (b * c))
return a, b, c, α, β, γ
Expand Down