5
$\begingroup$

$\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"]]

acetone and chloroform

$\endgroup$
14
$\begingroup$

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}
  ]
 ]

manipulate

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.

$\endgroup$
  • 1
    $\begingroup$ +1 Very nice! Now this is the first step to do genetic manipulation completely inside Mma :D $\endgroup$ – Dr. belisarius Apr 7 '13 at 21:05
  • $\begingroup$ wow, excellent work. This is exactly what I was looking for. $\endgroup$ – olliepower Apr 7 '13 at 23:59
7
$\begingroup$

Here is a less impressive take on the question.

positionsA = 
   ChemicalData["Acetone", "AtomPositions"] /. {x_, y_, z_} -> {x + 400, y + 400, z + 400};
positionsC = ChemicalData["Chloroform", "AtomPositions"];
{atomsA, atomsC} = {ChemicalData["Acetone", "VertexTypes"], 
                     ChemicalData["Chloroform", "VertexTypes"]};
{colorsA, colorsC} = {Map[ColorData["Atoms", #] &, atomsA], 
                       Map[ColorData["Atoms", #] &, atomsC]};
{radiiA, radiiC} = {Map[ElementData[#, "VanDerWaalsRadius"] &, atomsA], 
                     Map[ElementData[#, "VanDerWaalsRadius"] &, atomsC]};
{molA, molC} = {Graphics3D[{Specularity[White, 40], 
                MapThread[{#1, Sphere[#2, #3]} &, {colorsA, positionsA, radiiA}]}], 
                 Graphics3D[{Specularity[White, 40], 
                MapThread[{#1, Sphere[#2, #3]} &, {colorsC, positionsC, radiiC}]}]};

Show[molA, molC, Lighting -> "Neutral"]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.