$\require{mhchem}$I would like to take the acetone $\cf{((CH3)2CO)}$ and chloroform $\cf{(HCCl_3)}$ molecules that Mathematica's chemical data provides, and plot them together. I want to show how chloroform can hydrogen bond to acetone. Right now I have them plotted on top of each other :/
Show[ChemicalData["Chloroform", "MoleculePlot"],
ChemicalData["Acetone", "MoleculePlot"]]
Answer
A quick way of showing how the two structures can be positioned relative to each other in a single Graphics3D
is as follows:
With[{rMax = 500},
Manipulate[
Graphics3D[
{First@ChemicalData["Acetone", "MoleculePlot"],
GeometricTransformation[
First@ChemicalData["Chloroform", "MoleculePlot"],
Composition[
TranslationTransform[{displacementX, displacementY,
displacementZ}],
RotationTransform[
rotationAngle, {Cos[axisAzimuth] Sin[axisPolar],
Sin[axisAzimuth] Sin[axisPolar], Cos[axisPolar]}]]]},
PlotRange -> {{-rMax, rMax}, {-rMax, rMax}, {-rMax, rMax}}
],
{{displacementX, 0}, -rMax, rMax}, {{displacementY, 0}, -rMax,
rMax}, {{displacementZ, 0}, -rMax, rMax}, {rotationAngle, 0,
2 Pi},
{axisPolar, 0, 2 Pi}, {axisAzimuth, 0, 2 Pi}
]
]
The Manipulate
is just to let you do some manual re-positioning. You can eventually get better results by doing pre-calculated shifts and rotations based on the exact locations of the atoms. But I'm focusing here on the basic ingredients. For the display, this involves mainly the use of First
to extract the contents of the Graphics3D
of the molecule, then the translation and rotation using GeometricTransformation
with a Composition
of the former two operations.
The variable rMax
sets the plot range and the maximum displacement of the chloroform molecule relative to the acetone.
Comments
Post a Comment