catenate commited on
Commit
cd8db27
·
verified ·
1 Parent(s): b9e275d

Polyhedra-style aesthetic: indigo metal SBUs

Browse files
Files changed (1) hide show
  1. 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
- # Element coloring: standard Jmol chemistry palette (Cu=copper, O=red, N=blue, C=gray, H=white).
255
- # The bfactor encodes attribution magnitude in the downloadable iRASPA CIF; the live 3D viewer
256
- # uses element colors for clarity (the per-atom attribution magnitudes are reported in the
257
- # "Top contributing atoms" strip below the viewer and in the Trustworthiness tab).
258
- bfactor_style = {'colorscheme': 'Jmol'}
 
 
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
- # Combined ball-and-stick representation. 3Dmol auto-computes bonds for
266
- # CIF models from interatomic distances; the stick style draws those bonds.
267
  view.setStyle(
268
  {},
269
  {
270
- 'sphere': {'radius': 0.28, **bfactor_style},
271
- 'stick': {'radius': 0.12, **bfactor_style},
272
  },
273
  )
274
 
275
- # Metal atoms: larger spheres to visually mark SBU centers
276
  if metals_present:
277
  view.setStyle(
278
  {'elem': metals_present},
279
  {
280
- 'sphere': {'radius': 0.55, **bfactor_style},
281
- 'stick': {'radius': 0.12, **bfactor_style},
282
  },
283
  )
284
 
285
- # Hydrogens: smaller spheres so they do not dominate the view
286
  if 'H' in nonmetals_present:
287
  view.setStyle(
288
  {'elem': 'H'},
289
  {
290
- 'sphere': {'radius': 0.16, **bfactor_style},
291
- 'stick': {'radius': 0.08, **bfactor_style},
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