def abs_to_rel_f(vector, cell, pbc):
"""
Converts a position vector in absolut coordinates to relative coordinates
for a film system.
"""
# TODO this currently only works if the z-coordinate is the one with no pbc
# Therefore if a structure with x non pbc is given this should also work.
# maybe write a 'tranform film to fleur_film routine'?
if len(vector) == 3:
if pbc[2] == False:
# leave z coordinate absolut
# convert only x and y.
postionR = np.array(vector)
postionR_f = np.array(postionR[:2])
cell_np = np.array(cell)
cell_np = np.array(cell_np[0:2, 0:2])
inv_cell_np = np.linalg.inv(cell_np)
new_xy = [i for i in np.matmul(postionR_f, inv_cell_np)]#np.matmul(inv_cell_np, postionR_f)]
new_rel_pos_f = [new_xy[0], new_xy[1], postionR[2]]
return new_rel_pos_f
else:
print 'FLEUR can not handle this type of film coordinate'
else:
return False
评论列表
文章目录