lab-cosmo / chemiscope

An interactive structure/property explorer for materials and molecules
http://chemiscope.org
BSD 3-Clause "New" or "Revised" License
121 stars 29 forks source link

Non-spherical particles in the structure viewer #275

Closed rosecers closed 9 months ago

rosecers commented 1 year ago

Putting this in here to bug my student @Arthur-lin1027, along with a transcript between @Luthaf and myself.

[11:19 AM] guillaume With 3Dmol, you could use https://3dmol.csb.pitt.edu/doc/GLShape.html#addCustom, manually constructing the ellipsoid shape [11:20 AM] jsmol can do this natively, you could resurect the old renderer based on it and dynamically switch between 3Dmol and jsmol if the structure has ellipsoids to render [11:20 AM] If you want to add this to chemiscope, could you open an issue to discuss changes to the data format to add required ellispoid information to the input?

@Luthaf I have done the thing

For the record, the data format changes are minimal, we can save the necessary information into the ase frame and add a function that changes that data (e.g. ellipsoid semi-axes and orientations) into isosurface data within the chemiscope backend. I would suggest a particle-type flag in the frame info/arrays that triggers an isosurface construction. Thoughts?

Luthaf commented 1 year ago

For the record, the data format changes are minimal, we can save the necessary information into the ase frame and add a function that changes that data (e.g. ellipsoid semi-axes and orientations) into isosurface data within the chemiscope backend. I would suggest a particle-type flag in the frame info/arrays that triggers an isosurface construction. Thoughts?

How does this look like in the chemiscope JSON format?

rosecers commented 1 year ago

I think we could put in some particle-level list that defines {"semiaxes": {"target": "atom", "values": Nx3 matrix}, "orientations" {"target": "atom", "values": Nx4 quaternion list}}, and then write a chemiscope backend that converts this into the isosurface data type for 3dmol.

For the record, the data format changes are minimal, we can save the necessary information into the ase frame and add a function that changes that data (e.g. ellipsoid semi-axes and orientations) into isosurface data within the chemiscope backend. I would suggest a particle-type flag in the frame info/arrays that triggers an isosurface construction. Thoughts?

How does this look like in the chemiscope JSON format?

Luthaf commented 1 year ago

I would put the data inside the structures object instead of the properties. Something like

{"structures": [
    {
        "size": 42,
        "names": ["H", "O", "C", "C", ...],
        "x": [0, 1.5, 5.2, ...],
        "y": [5.7, 7, -2.4, ...],
        "z": [8.1, 2.9, -1.3, ...],
        "cell": [10, 0, 0, 0, 10, 0, 0, 0, 10],
        // new data
        "orientation": [[1, 2, 3, 2], [1, 1, 1, 0], [-2, 1, 0, 1], ...],
        "semiaxes": [[1, 2, 3], [1, 1, 1], [-2, 1, 0], ...]
    },
]}

This data also feels quite specific to ellipses, right? For other kinds of shapes, would we need the same data?

Something more explicit like below could also be nice

{"structures": [
    {
        "size": 42,
        "names": ["H", "O", "C", "C", ...],
        "x": [0, 1.5, 5.2, ...],
        "y": [5.7, 7, -2.4, ...],
        "z": [8.1, 2.9, -1.3, ...],
        "cell": [10, 0, 0, 0, 10, 0, 0, 0, 10],
        // new data
        "shapes": [
            {"kind": "ellipsoid", "orientation": [1, 2, 3, 2], "semiaxes": [1, 2, 3]},
            {"kind": "sphere"}, // this would be the default if not provided
            {"kind": "ellipsoid", "orientation": [1, 2, -1, 2], "semiaxes": [1, 2, 3]},
            {"kind": "ellipsoid", "orientation": [1, 0, 0, 2], "semiaxes": [1, 0, -1]},
            ...
        ]
    },
]}

this would enable other kinds of shapes, and multiple types of shapes in the same dataset.

ceriottm commented 1 year ago

Very much like the idea - we could even hijack it to visualize arrows

On Fri, 14 Apr 2023 at 12:22, Guillaume Fraux @.***> wrote:

I would put the data inside the structures object instead of the properties. Something like

{"structures": [ { "size": 42, "names": ["H", "O", "C", "C", ...], "x": [0, 1.5, 5.2, ...], "y": [5.7, 7, -2.4, ...], "z": [8.1, 2.9, -1.3, ...], "cell": [10, 0, 0, 0, 10, 0, 0, 0, 10], // new data "orientation": [[1, 2, 3, 2], [1, 1, 1, 0], [-2, 1, 0, 1], ...], "semiaxes": [[1, 2, 3], [1, 1, 1], [-2, 1, 0], ...] }, ]}

This data also feels quite specific to ellipses, right? For other kinds of shapes, would we need the same data?

Something more explicit like below could also be nice

{"structures": [ { "size": 42, "names": ["H", "O", "C", "C", ...], "x": [0, 1.5, 5.2, ...], "y": [5.7, 7, -2.4, ...], "z": [8.1, 2.9, -1.3, ...], "cell": [10, 0, 0, 0, 10, 0, 0, 0, 10], // new data "shapes": [ {"kind": "ellipsoid", "orientation": [1, 2, 3, 2], "semiaxes": [1, 2, 3]}, {"kind": "sphere"}, // this would be the default if not provided {"kind": "ellipsoid", "orientation": [1, 2, -1, 2], "semiaxes": [1, 2, 3]}, {"kind": "ellipsoid", "orientation": [1, 0, 0, 2], "semiaxes": [1, 0, -1]}, ... ] }, ]}

this would enable other kinds of shapes, and multiple types of shapes in the same dataset.

— Reply to this email directly, view it on GitHub https://github.com/lab-cosmo/chemiscope/issues/275#issuecomment-1508288247, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIREZ6QMBS664IFTG4BTALXBEQMXANCNFSM6AAAAAAW4KJ5AI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

rosecers commented 1 year ago

Actively working on this, will let you know when we make progress...

ceriottm commented 9 months ago

I think we can now mark this as mission accomplished!