gabrielelanaro / chemview

The new generation molecular viewer for IPython notebook
GNU Lesser General Public License v2.1
81 stars 17 forks source link

Bond rendering issue #16

Closed jameskermode closed 9 years ago

jameskermode commented 9 years ago

Hi, thanks for releasing chemview, it's a very neat tool. We've been developing an interface between it and the Atomic Simulation Environment (ASE) as part of our materials science toolkit matscipy, and have come across some issues rendering bonds.

Here's are a couple of screenshots to show what I mean, before and after zooming out, and the self-contained code used to setup the MolecularViewer. I've taken care only to include bonds which are fully within the simulation cell, so it's not a boundary wrapping issue.

Any suggestions of what might be going on?

image

image

import numpy as np
from chemview import enable_notebook
from chemview import MolecularViewer, RepresentationViewer
enable_notebook()

positions = np.array(
      [[ 0.    ,  0.    ,  0.    ],
       [ 1.3575,  1.3575,  1.3575],
       [ 0.    ,  2.715 ,  2.715 ],
       [ 1.3575,  4.0725,  4.0725],
       [ 2.715 ,  0.    ,  2.715 ],
       [ 4.0725,  1.3575,  4.0725],
       [ 2.715 ,  2.715 ,  0.    ],
       [ 4.0725,  4.0725,  1.3575],
       [ 0.    ,  0.    ,  5.43  ],
       [ 1.3575,  1.3575,  6.7875],
       [ 0.    ,  2.715 ,  8.145 ],
       [ 1.3575,  4.0725,  9.5025],
       [ 2.715 ,  0.    ,  8.145 ],
       [ 4.0725,  1.3575,  9.5025],
       [ 2.715 ,  2.715 ,  5.43  ],
       [ 4.0725,  4.0725,  6.7875],
       [ 5.43  ,  0.    ,  0.    ],
       [ 6.7875,  1.3575,  1.3575],
       [ 5.43  ,  2.715 ,  2.715 ],
       [ 6.7875,  4.0725,  4.0725],
       [ 8.145 ,  0.    ,  2.715 ],
       [ 9.5025,  1.3575,  4.0725],
       [ 8.145 ,  2.715 ,  0.    ],
       [ 9.5025,  4.0725,  1.3575],
       [ 5.43  ,  0.    ,  5.43  ],
       [ 6.7875,  1.3575,  6.7875],
       [ 5.43  ,  2.715 ,  8.145 ],
       [ 6.7875,  4.0725,  9.5025],
       [ 8.145 ,  0.    ,  8.145 ],
       [ 9.5025,  1.3575,  9.5025],
       [ 8.145 ,  2.715 ,  5.43  ],
       [ 9.5025,  4.0725,  6.7875]])

topology = {'atom_types': 
               ['Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si',
                'Si'],
 'bonds': [(0, 1),
           (1, 6),
           (1, 4),
           (1, 2),
           (2, 3),
           (3, 14),
           (4, 5),
           (5, 18),
           (5, 24),
           (5, 14),
           (6, 7),
           (7, 18),
           (8, 9),
           (9, 14),
           (9, 12),
           (9, 10),
           (10, 11),
           (12, 13),
           (13, 26),
           (14, 15),
           (15, 26),
           (16, 17),
           (17, 22),
           (17, 20),
           (17, 18),
           (18, 19),
           (19, 30),
           (20, 21),
           (21, 30),
           (22, 23),
           (24, 25),
           (25, 30),
           (25, 28),
           (25, 26),
           (26, 27),
           (28, 29),
           (30, 31)]}

mv = MolecularViewer(positions/10,
                     topology=topology)
mv.ball_and_sticks()
mv
gabrielelanaro commented 9 years ago

Hi thanks for the complete bug report. It looks like it renders fine with wireframe so I would exclude there's any problem with the input.

Those "plates" look like cylinder caps, I'll take a look tomorrow to see what's going on with the bond renderer.

gabrielelanaro commented 9 years ago

The radii weren't pushed correctly to the frontend. It's fixed in latest master

jameskermode commented 9 years ago

Brilliant, thanks for the fast response!