Skip to content

Commit

Permalink
Fix inv does not work for niggli_reduce & delaunay_reduce in Ju…
Browse files Browse the repository at this point in the history
…lia <= v1.9
  • Loading branch information
singularitti committed Aug 16, 2023
1 parent 39413bc commit 6260d5f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ function niggli_reduce(lattice::Lattice, symprec=1e-5)
end
function niggli_reduce(cell::Cell, symprec=1e-5)
lattice = Lattice(cell)
new_lattice = niggli_reduce(lattice, symprec)
# Keeping cartesian coordinates, see #106
recip = inv(new_lattice) * lattice
new_positions = [recip * position for position in cell.positions]
new_lattice = Matrix(niggli_reduce(lattice, symprec))
𝐏⁻¹ = inv(new_lattice) * Matrix(lattice) # Keep cartesian coordinates, see #106
new_positions = [𝐏⁻¹ * position for position in cell.positions]
return Cell(new_lattice, new_positions, cell.atoms)
end

Expand Down Expand Up @@ -73,9 +72,8 @@ function delaunay_reduce(lattice::Lattice, symprec=1e-5)
end
function delaunay_reduce(cell::Cell, symprec=1e-5)
lattice = Lattice(cell)
new_lattice = delaunay_reduce(lattice, symprec)
# Keeping cartesian coordinates, see #106
recip = inv(new_lattice) * lattice
new_positions = [recip * position for position in cell.positions]
new_lattice = Matrix(delaunay_reduce(lattice, symprec))
𝐏⁻¹ = inv(new_lattice) * Matrix(lattice) # Keep cartesian coordinates, see #106
new_positions = [𝐏⁻¹ * position for position in cell.positions]
return Cell(new_lattice, new_positions, cell.atoms)
end

0 comments on commit 6260d5f

Please sign in to comment.