Skip to content

Commit 19573d0

Browse files
Chiu PeterChiu Peter
authored andcommitted
fix irregular bonding
1 parent 60753bc commit 19573d0

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

crystal_toolkit/components/phonon.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ def calc_animation_step(max_displacement: list, coef: int) -> list:
283283
# [mid_x_displacement, mid_y_displacement, mid_z_displacement]
284284
# ].
285285
contents1 = json_data["contents"][1]["contents"]
286+
286287
for cidx, content in enumerate(contents1):
287288
bond_animation = []
288289
assert len(content["_meta"]) == len(content["positionPairs"])
@@ -294,26 +295,17 @@ def calc_animation_step(max_displacement: list, coef: int) -> list:
294295

295296
u_to_middle_bond_animation = []
296297

297-
for frame_idx, coef in enumerate(DISPLACE_COEF):
298+
for coef in DISPLACE_COEF:
298299
# Calculate the midpoint displacement between atom u and v for each animation frame.
299-
middle_end_displacement = (
300-
np.add(
301-
*(
302-
[
303-
np.array(
304-
calc_animation_step(max_displacement, coef)
305-
)
306-
for max_displacement in max_displacements
307-
]
308-
)
309-
)
310-
/ 2
311-
)
300+
u_displacement, v_displacement = [
301+
np.array(calc_animation_step(max_displacement, coef))
302+
for max_displacement in max_displacements
303+
]
304+
middle_end_displacement = np.add(u_displacement, v_displacement) / 2
305+
312306
u_to_middle_bond_animation.append(
313307
[
314-
rdata["contents"][0]["contents"][atom_idx_pair[0]][
315-
"animate"
316-
][frame_idx], # u atom displacement
308+
u_displacement, # u atom displacement
317309
[
318310
round(dis, precision) for dis in middle_end_displacement
319311
], # middle point displacement

0 commit comments

Comments
 (0)