@@ -28,6 +28,7 @@ def get_site_scene(
28
28
# connected_sites_to_draw,
29
29
connected_sites_not_drawn : list [ConnectedSite ] = None ,
30
30
hide_incomplete_edges : bool = False ,
31
+ site_idx : int | None = 0 ,
31
32
incomplete_edge_length_scale : float | None = 1.0 ,
32
33
connected_sites_colors : list [str ] | None = None ,
33
34
connected_sites_not_drawn_colors : list [str ] | None = None ,
@@ -36,24 +37,27 @@ def get_site_scene(
36
37
explicitly_calculate_polyhedra_hull : bool = False ,
37
38
bond_radius : float = 0.1 ,
38
39
draw_magmoms : bool = True ,
40
+ show_atom_idx : bool = False ,
41
+ show_atom_coord : bool = True ,
42
+ show_bond_order : bool = True ,
43
+ show_bond_length : bool = False ,
44
+ visualize_bond_orders : bool = False ,
39
45
magmom_scale : float = 1.0 ,
40
46
legend : Legend | None = None ,
41
47
) -> Scene :
42
48
"""
43
-
44
49
Args:
45
50
connected_sites:
46
51
connected_sites_not_drawn:
47
52
hide_incomplete_edges:
53
+ site_idx:
48
54
incomplete_edge_length_scale:
49
55
connected_sites_colors:
50
56
connected_sites_not_drawn_colors:
51
57
origin:
52
58
explicitly_calculate_polyhedra_hull:
53
59
legend:
54
-
55
60
Returns:
56
-
57
61
"""
58
62
59
63
atoms = []
@@ -74,7 +78,6 @@ def get_site_scene(
74
78
max_radius = float (min (radii ))
75
79
76
80
for sp , occu in self .species .items ():
77
-
78
81
if isinstance (sp , DummySpecie ):
79
82
80
83
cube = Cubes (
@@ -101,7 +104,12 @@ def get_site_scene(
101
104
name = str (sp )
102
105
if occu != 1.0 :
103
106
name += f" ({ occu } % occupancy)"
104
- name += f" ({ position [0 ]:.3f} , { position [1 ]:.3f} , { position [2 ]:.3f} )"
107
+
108
+ if show_atom_coord :
109
+ name += f" ({ position [0 ]:.3f} , { position [1 ]:.3f} , { position [2 ]:.3f} )"
110
+
111
+ if show_atom_idx :
112
+ name += "\n " + "index:" + str (site_idx )
105
113
106
114
if self .properties :
107
115
for k , v in self .properties .items ():
@@ -157,9 +165,20 @@ def get_site_scene(
157
165
# TODO: can cause a bug if all vertices almost co-planar
158
166
# necessary to include center site in case it's outside polyhedra
159
167
all_positions = [self .coords ]
168
+ name_cyl = " "
160
169
161
170
for idx , connected_site in enumerate (connected_sites ):
162
171
172
+ if show_bond_order :
173
+ if connected_site .weight is not None :
174
+ name_cyl = "bond order:" + str (f"{ connected_site .weight :.2f} " )
175
+
176
+ if show_bond_length :
177
+ if connected_site .dist is not None :
178
+ name_cyl += (
179
+ "\n " + "bond length:" + str (f"{ connected_site .dist :.3f} " )
180
+ )
181
+
163
182
connected_position = connected_site .site .coords
164
183
bond_midpoint = np .add (position , connected_position ) / 2
165
184
@@ -168,12 +187,47 @@ def get_site_scene(
168
187
else :
169
188
color = site_color
170
189
171
- cylinder = Cylinders (
172
- positionPairs = [[position , bond_midpoint .tolist ()]],
173
- color = color ,
174
- radius = bond_radius ,
175
- )
176
- bonds .append (cylinder )
190
+ if visualize_bond_orders :
191
+ cylinders = []
192
+
193
+ if connected_site .weight is not None :
194
+
195
+ if connected_site .weight > 1 :
196
+ trans_vector = 0.0
197
+ for _bond in range (connected_site .weight ):
198
+ pos_r_1 = [i + trans_vector for i in position ]
199
+ pos_r_2 = [i + trans_vector for i in bond_midpoint .tolist ()]
200
+ cylinders .append (
201
+ Cylinders (
202
+ positionPairs = [[pos_r_1 , pos_r_2 ]],
203
+ color = color ,
204
+ radius = bond_radius / 2 ,
205
+ clickable = True ,
206
+ tooltip = name_cyl ,
207
+ )
208
+ )
209
+ trans_vector = trans_vector + 0.25 * max_radius
210
+ for cylinder in cylinders :
211
+ bonds .append (cylinder )
212
+ else :
213
+ cylinder = Cylinders (
214
+ positionPairs = [[position , bond_midpoint .tolist ()]],
215
+ color = color ,
216
+ radius = bond_radius ,
217
+ clickable = True ,
218
+ tooltip = name_cyl ,
219
+ )
220
+ bonds .append (cylinder )
221
+
222
+ else :
223
+ cylinder = Cylinders (
224
+ positionPairs = [[position , bond_midpoint .tolist ()]],
225
+ color = color ,
226
+ radius = bond_radius ,
227
+ clickable = True ,
228
+ tooltip = name_cyl ,
229
+ )
230
+ bonds .append (cylinder )
177
231
all_positions .append (connected_position .tolist ())
178
232
179
233
if connected_sites_not_drawn and not hide_incomplete_edges :
0 commit comments