Skip to content

Commit f4d43ba

Browse files
committed
add get_scene func for mg
1 parent 7e251c4 commit f4d43ba

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

crystal_toolkit/renderables/migration_graph.py

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from turtle import pos
2+
import numpy as np
3+
4+
from pymatgen.analysis.diffusion.neb.full_path_mapper import MigrationGraph
5+
from crystal_toolkit.core.scene import Scene, Cylinders
6+
7+
def get_migrationgraph_scene(
8+
self,
9+
) -> Scene:
10+
"""
11+
Creates CTK object to display hops from a MigrationGraph object
12+
Args:
13+
mg: MigrationGraph object with hops to be visualized
14+
15+
Returns:
16+
CTK scene object to be rendered
17+
"""
18+
19+
result_scene = self.structure.get_scene()
20+
hop_contents = []
21+
for one_hop in self.unique_hops.values():
22+
hop_cyl = Cylinders(positionPairs=[[list(one_hop["ipos_cart"]), list(one_hop["epos_cart"])]], radius=0.2, visible=True)
23+
hop_contents.append(hop_cyl)
24+
25+
result_scene.contents.append(
26+
Scene(name="hops", origin=result_scene.contents[0].origin, contents=hop_contents)
27+
)
28+
print(result_scene.contents[-1])
29+
return result_scene
30+
31+
MigrationGraph.get_scene = get_migrationgraph_scene

0 commit comments

Comments
 (0)