zerothi / sisl

Electronic structure Python package for post analysis and large scale tight-binding DFT/NEGF calculations
https://zerothi.github.io/sisl
Mozilla Public License 2.0
181 stars 58 forks source link

Tile geometry by parts #330

Closed pfebrer closed 3 years ago

pfebrer commented 3 years ago

Do you think it makes sense to have an extra argument in the tile method which are breakpoints?

I.e. given that initial atoms are [0, 1, 2, 3, 4], a normal tile would return a geometry like [0, 1, 2, 3, 4, 0 , 1, 2, 3, 4], but I would like to have [0, 1, 0, 1, 2, 3, 4, 3, 4]. This is because I'd like to tile a system that I'm using as a device in transiesta where [0,1] and [3,4] are my electrodes.

Otherwise I think the best option is:

elec1_geom = geom.sub(elec1)
elec2_geom = geom.sub(elec2)
scattering_geom = geom.sub(~(elec1 | elec2))

tiled_geom = elec1_geom.tile(2,0) + scattering_geom.tile(2,0) + elec2_geom.tile(2,0)

Isn't it?

zerothi commented 3 years ago

Hmmm... Could be useful but also very tricky. I think there are some use-cases, but it is also very difficult to make it work in all cases.

Consider if you don't want some atoms to be tiled (to make a bigger surface with the same scattering region).

Isn't it easier to use repeat then sub with the correct indices?

pfebrer commented 3 years ago

I agree it may be too tricky to think about everything.

Isn't it easier to use repeat then sub with the correct indices?

You mean using sub as a way to reorder the atoms right? I didn't think about this. Although if elec1 and elec2 are categories you first need to get the indices, so probably you need more code.

Anyway, either of the options is not too bad. And I ended up simply using repeat :smile:

zerothi commented 3 years ago

You mean using sub as a way to reorder the atoms ...

Yes! :)

Anyway, either of the options is not too bad. And I ended up simply using repeat

repeat is nice, however, it does have a performance penalty when using bloch expansions. You should prefer tiling in all cases! :)