Quantcast
Viewing all articles
Browse latest Browse all 41

How can the units of the "AtomCoordinates" in a Molecule be changed while keeping the resulting MoleculePlot3D consistent?

Mathematica provides the Molecule function that can be visualized with MoleculePlot3D since version 12.0. Before, importing "XYZ" files would produce a Graphics3D object immediately. In this object, the coordinates of the atom were given in picometers, but not as Quantity. Changing the units here necessitated also fiddling with the Spheres and Cylinders used for the plot, which made it rather unfeasible.

Now, a Molecule has "AtomCoordinates" which are given as QuantityArray with the unit "Angstroms". Since ModifyMolecule with "TransformAtomCoordinates" allows applying any function receiving and returning a QuantityArray, I was hopeful that a UnitConvert would work. Sadly, that seems not to be the case.Firstly,

MoleculeModify[  Molecule["Benzene"], {"TransformAtomCoordinates",    UnitConvert[#, "Picometers"] &}]["AtomCoordinates"]Out[]="QuantityArray[Dimensions:{12,3},Units:Angstroms]

i.e. the units seem unchanged.Plotting the molecule as

Show[MoleculePlot3D[  MoleculeModify[   Molecule["Benzene"], {"TransformAtomCoordinates",     UnitConvert[#, "Picometers"] &}], PlotTheme -> "BallAndStick"],  Axes -> True]

where the correct plot

Image may be NSFW.
Clik here to view.
Correct Molecule Plot in Angstroms

becomes

Image may be NSFW.
Clik here to view.
Wrong Molecule Plot Picometers

reveals that the coordinates are indeed changed in some way, but the theme cannot keep up. I guess the data gets changed, but the unit information itself gets overwritten again after the transformation?

Can anything be done in this case? Different from the old XYZ plot, it seems even harder to access the internals of a Molecule to change how it is plotted, but maybe there is an option that is either undocumented or which I missed.


Viewing all articles
Browse latest Browse all 41

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>