Closed itsdfish closed 7 months ago
Thanks for reporting this. Can you reproduce it for a simpler explicit example rather than a random polytope of 1000 points ?
No problem. I might need some suggestions, as this is outside of my area of expertise. In the code above, tried to make a 1 X 1 square and a 1 X 1 X 1 cube. My understanding is that with a sufficient number of samples, the approximate volume would be 1 in each case. Would it be better to generate points along the perimeter instead?
You should get the correct volume if you give the 8 extreme vertices, does Polyhedra.volume
return 1 in this case ?
It appears to work correctly in this simple case:
Code
using Polyhedra
vertices = [[i, j, k] for i in 0:1 for j in 0:1 for k in 0:1]
verticies = permutedims(hcat(vertices...))
p = polyhedron(vrep(vertices))
vol = Polyhedra.volume(p)
Result
julia> vol = Polyhedra.volume(p)
1//1
@itsdfish @blegat I can produce an example with an error in the volume, but it is also possible to fix it using the library.
using SymmetryReduceBZ, Polyhedra
real_latvecs = [1 0; 0 1]
convention="ordinary"
atom_types=[0]
atom_pos = Array([0 0]')
coordinates = "Cartesian"
bzformat = "half-space"
makeprim=false
bz = SymmetryReduceBZ.Symmetry.calc_bz(real_latvecs,atom_types,atom_pos,coordinates,
bzformat,makeprim,convention) # the square [-0.5,-0.5]x[0.5,0.5]
p = polyhedron(bz, SymmetryReduceBZ.Symmetry.CDDLib.Library())
volume(p) # 2.0, incorrect
removehredundancy!(p)
volume(p) # 1.0, correct
@lxvm, thanks for the work around!
It seems the issue is the same as in [#249]: the function triangulation_indices()
returns redundant simplices. Removing duplicates as explained here yields the correct volume 1.0
.
Hi,
I asked about this issue on discourse, but did not receive a reply. I am opening this issue because the result from volume seems to be a bug unless I am missing something about the calculation. Here is a MWE:
Results
Code
Version Info