crystaltoolkit icon indicating copy to clipboard operation
crystaltoolkit copied to clipboard

[Feature Request]: Documentation for use of Crystal Toolkit in Python Notebooks beyond just structure

Open Masonavic opened this issue 11 months ago • 3 comments

Problem

Crystal Toolkit integrates nicely with pymatgen to display structural data automatically.

However, there's no documentation for if I wanted to display structural data along with other 3D data types, like say volumetric or isosurface data. How do I do this?

For reference, charge density data previews on the Materials Project clearly shows 3D structures that include volumetric data.

Proposed Solution

Provide clear examples for how to render chgcar or other types of volumetric data within notebooks like Jupyter or Colab.

Alternatives

No response

Masonavic avatar Mar 09 '25 20:03 Masonavic

Excellent suggestion @Masonavic! Documentation is quite lacking at the moment. I hope to improve this situation soon.

In the meantime, if you comfortable with Python, I recommend taking a look at this file:

https://github.com/materialsproject/crystaltoolkit/blob/main/crystal_toolkit/renderables/volumetric.py

mkhorton avatar Mar 10 '25 06:03 mkhorton

Hi, thanks! Yeah I've seen the API for crystal_toolkit.renderables.volumetric, my question is how to use that with chgcar data within a Python notebook environment like Colab?

This works great for a pymatgen structure-class object, where I just call it within a code block, and Crystal Toolkit will render that nicely as output. So I can do that for the .structure element within a chgcar object, but how do I also render the volumetric data in the same output? Is there an additional method I have to call for the output to display both the structure and the volumetric data?

In other words: If I call crystal_toolkit.renderables.volumetric.get_isosurface_scene() on a chgcar object within a notebook, I just get the raw array data. How do I get this to render the full scene with both the structure and the volumetric data?

Basically, how to do this example from the Materials Project site, which isn't documented?

Masonavic avatar Mar 10 '25 16:03 Masonavic

@mkhorton Thank you for developing this amazing crystal structure visualization tool. I, too, have faced difficulties when trying to visualize CHGCAR files in the Materials Studio style. Would it be possible for you to provide a simple code that visualizes the charge density along with the structure? Thanks in advance.

Jonathan-park17 avatar Jun 19 '25 04:06 Jonathan-park17