nglviewer / nglview

Jupyter widget to interactively view molecular structures and trajectories
http://nglviewer.org/nglview/latest/
Other
821 stars 135 forks source link

Visualizing molecular orbitals from .cube files #1027

Closed scottwsides closed 1 year ago

scottwsides commented 2 years ago

Sorry for asking this question if its been answered somewhere already, I have found .cube examples but none of them seem to work for my case. Before providing more detail... am I missing a cache of examples of this sort somewhere? I'm dumping a .cube file from NWChem with

dplot
TITLE HOMO
vectors n2.movecs
LimitXYZ
-3.0 3.0 10
-3.0 3.0 10
-3.0 3.0 10
spin total gaussian
output chargedensity.cube end task dplot

This step seems to work fine. I found a few examples of visualizing surfaces... one of them is

view.add_component('water_den.cube', color="red") view.component_0.add_surface(isolevelType="value", isolevel=0.002)

with my .cube file and nothing appears. Is this example the correct one?

hainm commented 2 years ago

Dear @scottwsides, please see the example here: https://github.com/nglviewer/nglview/issues/998

scottwsides commented 2 years ago

thats the first thing I saw and it didn't work at all. I'll double check my setup and try to find what I'm doing wrong.

More generally, its just hard to find docs on the options in the functions... and the pydoc strings all just show '**kargs' that don't have any detailed info. Any tips?

hainm commented 2 years ago

More generally, its just hard to find docs on the options in the functions... and the pydoc strings all just show '**kargs' that don't have any detailed info. Any tips?

view.add_surface(**kwargs) means specifying NGL options:

snapshot2

hainm commented 2 years ago

hats the first thing I saw and it didn't work at all. I'll double check my setup and try to find what I'm doing wrong.

Can you try with NGL's cube files first? https://github.com/nglviewer/ngl/tree/master/data

scottwsides commented 2 years ago

Sure... I'll try those. Also.. I'll try the viewer. However I actually use embedded in jupyterlab notebook. But... I can use this to introspect methods. Thanks!

hainm commented 2 years ago

However I actually use embedded in jupyterlab notebook.

um may be you are getting the same issue here: https://github.com/nglviewer/nglview/issues/975

scottwsides commented 2 years ago

Perhaps... I'll check it out.

scottwsides commented 2 years ago

The benzene-homo.cube file complained about negative coordinates not being allowed. I can see a simple charge density with my .cube files.... but not molecular orbitals. I think I'm not setting the NWChem dplot options correctly so I'll keep looking. Your example above still doesnt viz for any file... I have to replace view[1].add_surface --> view.compoent_1.add_surface to get anything to viz.

scottwsides commented 2 years ago

So copying .cube file to /tmp seems to let detailed MO info get plotted. But this is very cumbersome... has this 'current file directory' been fixed?

hainm commented 2 years ago

has this 'current file directory' been fixed?

@scottwsides unfortunately I don't know how to fix it.

scottwsides commented 2 years ago

Understood... I've got a workaround, but it is odd. Cheers,