I apologize if this is a repeated question, however I cannot find any posts with exactly what I need so I felt it was appropriate to ask. I am currently analyzing molecular dynamics data, and would like to bin the supercell I am using in NxNxN parts. The cell shape is triclinic, or in other words it is a parallelepiped where the 3 main side lengths and 3 main angles are all different. Following this post here, I was able to figure out how to construct an image of my original cell. However, I am struggling to properly subdivide the original cell. My main issue actually is that there are small translations of the subcells that cause them to be misaligned from each other as well as misaligned relative to themselves
I have almost made everything correct with this following code:
def subdivide_cell(origin, a, b, c, n):
subdivisions = []
for i in range(n):
for j in range(n):
for k in range(n):
sub_origin = origin + np.array([i * a / n, j * b / n, k * c / n])
sub_a = a / n
sub_b = b / n
sub_c = c / n
subdivisions.append((sub_origin, sub_a, sub_b, sub_c))
return subdivisions
I also will attach the output figure I get in a couple orientations so it is clear how the subcells are misaligned. Any insight on how to figure the rest of this problem out is welcome!
enter image description here
enter image description here