Polyhedra-style aesthetic: indigo metal SBUs
Browse files- visualize.py +16 -15
visualize.py
CHANGED
|
@@ -251,44 +251,45 @@ def create_3d_visualization(
|
|
| 251 |
view = py3Dmol.view(width=width, height=height)
|
| 252 |
view.addModel(cif_str, 'cif')
|
| 253 |
|
| 254 |
-
#
|
| 255 |
-
#
|
| 256 |
-
#
|
| 257 |
-
#
|
| 258 |
-
|
|
|
|
|
|
|
| 259 |
|
| 260 |
# Determine which elements are present in the structure
|
| 261 |
elements_present = set(str(site.specie) for site in structure)
|
| 262 |
metals_present = sorted(elements_present & _METAL_ELEMENTS)
|
| 263 |
nonmetals_present = sorted(elements_present - _METAL_ELEMENTS)
|
| 264 |
|
| 265 |
-
#
|
| 266 |
-
# CIF models from interatomic distances; the stick style draws those bonds.
|
| 267 |
view.setStyle(
|
| 268 |
{},
|
| 269 |
{
|
| 270 |
-
'sphere': {'radius': 0.28, **
|
| 271 |
-
'stick': {'radius': 0.12, **
|
| 272 |
},
|
| 273 |
)
|
| 274 |
|
| 275 |
-
# Metal
|
| 276 |
if metals_present:
|
| 277 |
view.setStyle(
|
| 278 |
{'elem': metals_present},
|
| 279 |
{
|
| 280 |
-
'sphere': {'radius': 0.
|
| 281 |
-
'stick': {'radius': 0.
|
| 282 |
},
|
| 283 |
)
|
| 284 |
|
| 285 |
-
# Hydrogens:
|
| 286 |
if 'H' in nonmetals_present:
|
| 287 |
view.setStyle(
|
| 288 |
{'elem': 'H'},
|
| 289 |
{
|
| 290 |
-
'sphere': {'radius': 0.
|
| 291 |
-
'stick': {'radius': 0.
|
| 292 |
},
|
| 293 |
)
|
| 294 |
|
|
|
|
| 251 |
view = py3Dmol.view(width=width, height=height)
|
| 252 |
view.addModel(cif_str, 'cif')
|
| 253 |
|
| 254 |
+
# Polyhedra-style aesthetic: metals as bold blue spheres (the SBU centers),
|
| 255 |
+
# other atoms as smaller spheres in soft gray shades. Inspired by iRASPA /
|
| 256 |
+
# crystal-toolkit visualisation conventions where metal SBUs are blue
|
| 257 |
+
# polyhedra and the linker network sits behind in muted tones.
|
| 258 |
+
metal_style = {'color': '#1e3a8a'} # deep indigo for metal SBUs
|
| 259 |
+
nonmetal_style = {'colorscheme': 'Jmol'} # standard chemistry colors
|
| 260 |
+
bfactor_style = nonmetal_style # name retained for downstream code paths
|
| 261 |
|
| 262 |
# Determine which elements are present in the structure
|
| 263 |
elements_present = set(str(site.specie) for site in structure)
|
| 264 |
metals_present = sorted(elements_present & _METAL_ELEMENTS)
|
| 265 |
nonmetals_present = sorted(elements_present - _METAL_ELEMENTS)
|
| 266 |
|
| 267 |
+
# Default: ball-and-stick with Jmol coloring for non-metal framework atoms
|
|
|
|
| 268 |
view.setStyle(
|
| 269 |
{},
|
| 270 |
{
|
| 271 |
+
'sphere': {'radius': 0.28, **nonmetal_style},
|
| 272 |
+
'stick': {'radius': 0.12, **nonmetal_style},
|
| 273 |
},
|
| 274 |
)
|
| 275 |
|
| 276 |
+
# Metal SBU centers: large indigo spheres to visually mark the polyhedra
|
| 277 |
if metals_present:
|
| 278 |
view.setStyle(
|
| 279 |
{'elem': metals_present},
|
| 280 |
{
|
| 281 |
+
'sphere': {'radius': 0.85, **metal_style},
|
| 282 |
+
'stick': {'radius': 0.16, **metal_style},
|
| 283 |
},
|
| 284 |
)
|
| 285 |
|
| 286 |
+
# Hydrogens: tiny spheres so they do not dominate the view
|
| 287 |
if 'H' in nonmetals_present:
|
| 288 |
view.setStyle(
|
| 289 |
{'elem': 'H'},
|
| 290 |
{
|
| 291 |
+
'sphere': {'radius': 0.14, **nonmetal_style},
|
| 292 |
+
'stick': {'radius': 0.06, **nonmetal_style},
|
| 293 |
},
|
| 294 |
)
|
| 295 |
|