sisl
sisl copied to clipboard
sisl.viz Grid plot uses Grid.geometry instead of Grid.lattice
Describe the bug
The problem occurs when the lattice is different from the Geometry.lattice
.
Reproducable code
lattice = H.geometry.lattice.untile(3, 0)
grid = sisl.Grid(0.2, geometry=H.geometry, lattice=lattice)
grid.plot()
I didn't know it was even legal to pass both a geometry and a lattice to Grid :sweat_smile:
I don't know if I should fix this or keep it in mind for the sisl.viz
PR. My plan is to work on that during August so that I can finally finish it and merge it to make sisl.viz
developeable again.
We can wait, but perhaps it would be nice if we could raise an error if users do this? I.e. if the lattice is different from the geometry.lattice
, where could I add this?
What is the error exactly? Is it that when you use plot_geom=True
you get the lattice of the geometry?
If I do grid.plot()
it shows the lengths as though it was the geometry.lattice
but it should show the grid.lattice
, i.e. the values are correct, but it gets stretched and axis are wrong. I wanted to raise an error in the code if they are in-commensurate.
Ah ok, you can raise the error here:
https://github.com/zerothi/sisl/blob/1ef16ed437174d84c510f6872f01f0613ffcbe9a/src/sisl/viz/plots/grid.py#L539-L545
Using self.grid
or grid
. But does different lattices make sense for other sisl
functionalities?
Ah ok, you can raise the error here:
https://github.com/zerothi/sisl/blob/1ef16ed437174d84c510f6872f01f0613ffcbe9a/src/sisl/viz/plots/grid.py#L539-L545
Using
self.grid
orgrid
. But does different lattices make sense for othersisl
functionalities?
Yes, when you do grid.sub()
or expand densities to grids, then a different lattice is nice (consider graphene -> square grid)
I see, yes it makes sense :+1: