Dynamic 3D Molecular Models with nVizx

Slava  Reshetnyak
Bary Wilson

In this notebook Mathematica is used to generate 3D models of molecules that can be manipulated in real time with nVizx.  

This easy and accurate tool for building dynamic 3D molecular models with Mathematica may be of interest to secondary school and undergraduate college educators and their students. Future versions of this notebook will incorporate moelcular vibration modeling for demonstration of molecular spectroscopy principles.  Future versions may also be of interest to physical chemists and others who use Mathematica and wish to visualize molecular structure and vibrational motion in three dimensions.

In the example shown here, the cisplatin molecule is generated in both stick and ball and spacefill models. Cisplatin was selected because it is a relatively simple molecule that illustrates the profound effect isomeric structure can have on biological activity. The cis isomer of diamminedichloroplatinum II (cisplatin) shown here is an effective anti-cancer agent. The trans isomer of the same compound has essentially no anti-cancer activity.

Previously published Mathematica notebooks such as (Demarco; 2000) and ( McClain; 1994) or graphics packages (Nordfors and Georgakopoulos; 1999)  allow construction and visualization of 3D  models of molecules and their vibrational modes.  Visualizations in these notebooks are either static or use Mathematica multi-frame animation. The present notebook allows real-time dynamic visualization of both ball and stick and space-filled molecular models using nVizx. 

In this example, the bond length and atom center co-ordinates data are from published .pdb files such as those at the NYU Molecular Library. ( .pdb is the 3D coordinate format of the Brookhaven Protein Data Base. This simple format can be opened and read by most web browsers and text editors. A copy of the .pdb file used in this model is included at the end of this notebook.)  Atomic radii for the elements are available at Webelements. 

To use this notebook for building dynamic 3D models of other molecules, copy the block for the first atom in the present molecule (*PT1*).  Then replace the the Location and Scale values in this block with those of a given atom in the new molecule. Continue the process, copying as many blocks as needed for the atoms in the new molecule and substituting the data for the new molecule until the new structure is complete. Be sure that each new atom has a unique number in the SpxSelect[SpxList[]] code line in each block. You can also replace the present RGB color values for those of the new atoms where needed.

The first two cells in the notebook initialize nVizx and the Mathematica Color Graphics package. The third cell generates a spacefill model of cysplatin in the nVizx window. The fourth cell generates a ball and stick model of cisplatin in the nVizx window.

Images of the resulting 3D models from the nVizx window are shown at the end of this notebook.  nVizx 3D models can be exported in the .obj format for use in other 3D applications.  2D images of the models can be exported in .bmp or .jpg formats for use in publication.  For a free trial download of nVizx go to www.splinex.com.

Start by initializing Splinex nVizx and the Mathematica Graphics Colors package.

<< Splinex`Spx`

<< Graphics`Colors`;

Spacefill Model of the Cysplatin Molecule

\(\(\(
\)\(\(nPoints = 50;\)

    \(SpxClear[];\)
 (*PT1*) 

    \(SpxSurface[
        Table[{Sin[θ]*Cos[φ], \ 
            Sin[θ]*Sin[φ], \ Cos[θ]}, {φ, 
            0, 2  π - \(2  π\)\/nPoints, \(2  π\)\/nPoints}, \ {θ, 0, π, π\/nPoints}], \ 
        ClosedV -> True];\)

    SpxSelect[\(SpxList[]\)[\([1]\)]]

    SpxSetTransform[Location -> {\(-0.142\), 0.141, 7.747}, \ 
      Scale -> {1.67, 1.67, 1.67}]

    SpxSetOptions[BoundBox -> False]

    \(SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 0]];\)

    SpxSetColors[
      SolidColor -> 
        RGBColor[1, \ 0, 
          1]]

 (*CL2*) 

    \(SpxSurface[
        Table[{Sin[θ]*Cos[φ]\ , \ 
            Sin[θ]*Sin[φ], \ Cos[θ]}, {φ, 
            0, 2  π - \(2  π\)\/nPoints, \(2  π\)\/nPoints}, \ {θ, 0, π, π\/nPoints}], \ 
        ClosedV -> True];\)

    SpxSelect[\(SpxList[]\)[\([2]\)]]

    SpxSetTransform[Location -> {\(-0.135\), \(-2.042\), 8.092}, \ 
      Scale -> {0.75, 0.75, 0.75}]

    SpxSetOptions[BoundBox -> False]

    \(SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 0]];\)

    SpxSetColors[
      SolidColor -> 
        Green]

 (*CL3*) 

    \(SpxSurface[
        Table[{Sin[θ]*Cos[φ]\ , \ 
            Sin[θ]*Sin[φ], \ Cos[θ]}, {φ, 
            0, 2  π - \(2  π\)\/nPoints, \(2  π\)\/nPoints}, \ {θ, 0, π, π\/nPoints}], \ 
        ClosedV -> True];\)

    SpxSelect[\(SpxList[]\)[\([3]\)]]

    SpxSetTransform[Location -> {2.064, 0.127, 7.615}, \ 
      Scale -> {0.75, 0.75, 0.75}]

    SpxSetOptions[BoundBox -> False]

    \(SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 0]];\)

    SpxSetColors[
      SolidColor -> 
        Green]

 (*N4*) 

    \(SpxSurface[
        Table[{Sin[θ]*Cos[φ]\ , \ 
            Sin[θ]*Sin[φ], \ Cos[θ]}, {φ, 
            0, 2  π - \(2  π\)\/nPoints, \(2  π\)\/nPoints}, \ {θ, 0, π, π\/nPoints}], \ 
        ClosedV -> True];\)

    SpxSelect[\(SpxList[]\)[\([4]\)]]

    SpxSetTransform[Location -> {\(-0.147\), 2.166, 7.427}, \ 
      Scale -> {0.64, 0.64, 0.64}]

    SpxSetOptions[BoundBox -> False]

    \(SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 0]];\)

    SpxSetColors[
      SolidColor -> 
        Blue]

 (*N5*) 

    \(SpxSurface[
        Table[{Sin[θ]*Cos[φ]\ , \ 
            Sin[θ]*Sin[φ], \ Cos[θ]}, {φ, 
            0, 2  π - \(2  π\)\/nPoints, \(2  π\)\/nPoints}, \ {θ, 0, π, π\/nPoints}], \ 
        ClosedV -> True];\)

    SpxSelect[\(SpxList[]\)[\([5]\)]]

    SpxSetTransform[Location -> {\(-2.188\), 0.154, 7.870}, \ 
      Scale -> {0.64, 0.64, 0.64}]

    SpxSetOptions[BoundBox -> False]

    \(SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 0]];\)

    SpxSetColors[
      SolidColor -> Blue]

 (*1  
        H4*) 

    \(SpxSurface[
        Table[{Sin[θ]*Cos[φ]\ , \ 
            Sin[θ]*Sin[φ], \ Cos[θ]}, {φ, 
            0, 2  π - \(2  π\)\/nPoints, \(2  π\)\/nPoints}, \ {θ, 0, π, π\/nPoints}], \ 
        ClosedV -> True];\)

    SpxSelect[\(SpxList[]\)[\([6]\)]]

    SpxSetTransform[Location -> {0.793, 2.489, 7.319}, \ 
      Scale -> {0.5, 0.5, 0.5}]

    SpxSetOptions[BoundBox -> False]

    \(SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 0]];\)

    SpxSetColors[
      SolidColor -> 
        RGBColor[1, 1, 1]]

 (*2  
        H4*) 

    \(SpxSurface[
        Table[{Sin[θ]*Cos[φ]\ , \ 
            Sin[θ]*Sin[φ], \ Cos[θ]}, {φ, 
            0, 2  π - \(2  π\)\/nPoints, \(2  π\)\/nPoints}, \ {θ, 0, π, π\/nPoints}], \ 
        ClosedV -> True];\)

    SpxSelect[\(SpxList[]\)[\([7]\)]]

    SpxSetTransform[Location -> {\(-0.570\), 2.625, 8.208}, \ 
      Scale -> {0.5, 0.5, 0.5}]

    SpxSetOptions[BoundBox -> False]

    \(SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 0]];\)

    SpxSetColors[
      SolidColor -> 
        RGBColor[1, 1, 1]]

 (*3  
        H4*) 

    \(SpxSurface[
        Table[{Sin[θ]*Cos[φ]\ , \ 
            Sin[θ]*Sin[φ], \ Cos[θ]}, {φ, 
            0, 2  π - \(2  π\)\/nPoints, \(2  π\)\/nPoints}, \ {θ, 0, π, π\/nPoints}], \ 
        ClosedV -> True];\)

    SpxSelect[\(SpxList[]\)[\([8]\)]]

    SpxSetTransform[Location -> {\(-0.668\), 2.370, 6.598}, \ 
      Scale -> {0.5, 0.5, 0.5}]

    SpxSetOptions[BoundBox -> False]

    \(SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 0]];\)

    SpxSetColors[
      SolidColor -> 
        RGBColor[1, 1, 1]]

 (*1  
        H5*) 

    \(SpxSurface[
        Table[{Sin[θ]*Cos[φ]\ , \ 
            Sin[θ]*Sin[φ], \ Cos[θ]}, {φ, 
            0, 2  π - \(2  π\)\/nPoints, \(2  π\)\/nPoints}, \ {θ, 0, π, π\/nPoints}], \ 
        ClosedV -> True];\)

    SpxSelect[\(SpxList[]\)[\([9]\)]]

    SpxSetTransform[Location -> {\(-2.464\), 0.303, 8.819}, \ 
      Scale -> {0.5, 0.5, 0.5}]

    SpxSetOptions[BoundBox -> False]

    \(SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 0]];\)

    SpxSetColors[
      SolidColor -> 
        RGBColor[1, 1, 1]]

 (*2  
        H5*) 

    \(SpxSurface[
        Table[{Sin[θ]*Cos[φ]\ , \ 
            Sin[θ]*Sin[φ], \ Cos[θ]}, {φ, 
            0, 2  π - \(2  π\)\/nPoints, \(2  π\)\/nPoints}, \ {θ, 0, π, π\/nPoints}], \ 
        ClosedV -> True];\)

    SpxSelect[\(SpxList[]\)[\([10]\)]]

    SpxSetTransform[Location -> {\(-2.546\), \(-0.724\), 7.552}, \ 
      Scale -> {0.5, 0.5, 0.5}]

    SpxSetOptions[BoundBox -> False]

    \(SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 0]];\)

    SpxSetColors[
      SolidColor -> 
        RGBColor[1, 1, 1]]

 (*3  
        H5*) 

    \(SpxSurface[
        Table[{Sin[θ]*Cos[φ]\ , \ 
            Sin[θ]*Sin[φ], \ Cos[θ]}, {φ, 
            0, 2  π - \(2  π\)\/nPoints, \(2  π\)\/nPoints}, \ {θ, 0, π, π\/nPoints}], \ 
        ClosedV -> True];\)

    SpxSelect[\(SpxList[]\)[\([11]\)]]

    \(SpxSetTransform[Location -> {\(-2.551\), 0.889, 7.298}, \ 
        Scale -> {0.5, 0.5, 0.5}];\)

    \(SpxSetOptions[BoundBox -> False];\)

    \(SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 0]];\)

    \(SpxSetColors[
        SolidColor -> RGBColor[1, 1, 1]];\)

    \(SpxSelect[SpxList[]];\)

    \)\)\)

Stick and Ball Model of the Cisplatin Molecule

SpxClear[];

      
SpxSurface[
        Table[{Sin[θ]*Cos[φ],  
            Sin[θ]*Sin[φ],  Cos[θ]}, {φ, 
            0, 2  π - ((2  π)/nPoints), ((2  π)/nPoints)},  {θ, 0, π, (π/nPoints)}],  
        ClosedV -> True];
SpxSelect[SpxList[][[1]]]
SpxSetTransform[Location -> {-0.142, 0.141, 7.747},  
      Scale -> {0.3, 0.3, 0.3}]
SpxSetOptions[BoundBox -> False]
SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 
          0]];
SpxSetColors[
      SolidColor -> 
        RGBColor[1,  0, 1]]


      
SpxSurface[
        Table[{Sin[θ]*Cos[φ] ,  
            Sin[θ]*Sin[φ],  Cos[θ]}, {φ, 
            0, 2  π - ((2  π)/nPoints), ((2  π)/nPoints)},  {θ, 0, π, (π/nPoints)}],  
        ClosedV -> True];
SpxSelect[SpxList[][[2]]]
SpxSetTransform[Location -> {-0.135, -2.042, 8.092},  
      Scale -> {0.3, 0.3, 0.3}]
SpxSetOptions[BoundBox -> False]
SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 
          0]];
SpxSetColors[
      SolidColor -> 
        Green]


      
SpxSurface[
        Table[{Sin[θ]*Cos[φ] ,  
            Sin[θ]*Sin[φ],  Cos[θ]}, {φ, 
            0, 2  π - ((2  π)/nPoints), ((2  π)/nPoints)},  {θ, 0, π, (π/nPoints)}],  
        ClosedV -> True];
SpxSelect[SpxList[][[3]]]
SpxSetTransform[Location -> {2.064, 0.127, 7.615},  
      Scale -> {0.3, 0.3, 0.3}]
SpxSetOptions[BoundBox -> False]
SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 
          0]];
SpxSetColors[
      SolidColor -> 
        Green]


      
SpxSurface[
        Table[{Sin[θ]*Cos[φ] ,  
            Sin[θ]*Sin[φ],  Cos[θ]}, {φ, 
            0, 2  π - ((2  π)/nPoints), ((2  π)/nPoints)},  {θ, 0, π, (π/nPoints)}],  
        ClosedV -> True];
SpxSelect[SpxList[][[4]]]
SpxSetTransform[Location -> {-0.147, 2.166, 7.427},  
      Scale -> {0.3, 0.3, 0.3}]
SpxSetOptions[BoundBox -> False]
SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 
          0]];
SpxSetColors[
      SolidColor -> 
        Blue]


      
SpxSurface[
        Table[{Sin[θ]*Cos[φ] ,  
            Sin[θ]*Sin[φ],  Cos[θ]}, {φ, 
            0, 2  π - ((2  π)/nPoints), ((2  π)/nPoints)},  {θ, 0, π, (π/nPoints)}],  
        ClosedV -> True];
SpxSelect[SpxList[][[5]]]
SpxSetTransform[Location -> {-2.188, 0.154, 7.870},  
      Scale -> {0.3, 0.3, 0.3}]
SpxSetOptions[BoundBox -> False]
SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 
          0]];
SpxSetColors[
      SolidColor -> 
        Blue]


      
SpxSurface[
        Table[{Sin[θ]*Cos[φ] ,  
            Sin[θ]*Sin[φ],  Cos[θ]}, {φ, 
            0, 2  π - ((2  π)/nPoints), ((2  π)/nPoints)},  {θ, 0, π, (π/nPoints)}],  
        ClosedV -> True];
SpxSelect[SpxList[][[6]]]
SpxSetTransform[Location -> {0.793, 2.489, 7.319},  
      Scale -> {0.3, 0.3, 0.3}]
SpxSetOptions[BoundBox -> False]
SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 
          0]];
SpxSetColors[
      SolidColor -> 
        RGBColor[1, 1, 1]]


      
SpxSurface[
        Table[{Sin[θ]*Cos[φ] ,  
            Sin[θ]*Sin[φ],  Cos[θ]}, {φ, 
            0, 2  π - ((2  π)/nPoints), ((2  π)/nPoints)},  {θ, 0, π, (π/nPoints)}],  
        ClosedV -> True];
SpxSelect[SpxList[][[7]]]
SpxSetTransform[Location -> {-0.570, 2.625, 8.208},  
      Scale -> {0.3, 0.3, 0.3}]
SpxSetOptions[BoundBox -> False]
SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 
          0]];
SpxSetColors[
      SolidColor -> 
        RGBColor[1, 1, 1]]

  
SpxSurface[
        Table[{Sin[θ]*Cos[φ] ,  
            Sin[θ]*Sin[φ],  Cos[θ]}, {φ, 
            0, 2  π - ((2  π)/nPoints), ((2  π)/nPoints)},  {θ, 0, π, (π/nPoints)}],  
        ClosedV -> True];
SpxSelect[SpxList[][[8]]]
SpxSetTransform[Location -> {-0.668, 2.370, 6.598},  
      Scale -> {0.3, 0.3, 0.3}]
SpxSetOptions[BoundBox -> False]
SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 
          0]];
SpxSetColors[
      SolidColor -> 
        RGBColor[1, 1, 1]]

  
SpxSurface[
        Table[{Sin[θ]*Cos[φ] ,  
            Sin[θ]*Sin[φ],  Cos[θ]}, {φ, 
            0, 2  π - ((2  π)/nPoints), ((2  π)/nPoints)},  {θ, 0, π, (π/nPoints)}],  
        ClosedV -> True];
SpxSelect[SpxList[][[9]]]
SpxSetTransform[Location -> {-2.464, 0.303, 8.819},  
      Scale -> {0.3, 0.3, 0.3}]
SpxSetOptions[BoundBox -> False]
SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 
          0]];
SpxSetColors[
      SolidColor -> 
        RGBColor[1, 1, 1]]

  
SpxSurface[
        Table[{Sin[θ]*Cos[φ] ,  
            Sin[θ]*Sin[φ],  Cos[θ]}, {φ, 
            0, 2  π - ((2  π)/nPoints), ((2  π)/nPoints)},  {θ, 0, π, (π/nPoints)}],  
        ClosedV -> True];
SpxSelect[SpxList[][[10]]]
SpxSetTransform[Location -> {-2.546, -0.724, 7.552},  
      Scale -> {0.3, 0.3, 0.3}]
SpxSetOptions[BoundBox -> False]
SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 
          0]];
SpxSetColors[
      SolidColor -> 
        RGBColor[1, 1, 1]]

  
SpxSurface[
        Table[{Sin[θ]*Cos[φ] ,  
            Sin[θ]*Sin[φ],  Cos[θ]}, {φ, 
            0, 2  π - ((2  π)/nPoints), ((2  π)/nPoints)},  {θ, 0, π, (π/nPoints)}],  
        ClosedV -> True];
SpxSelect[SpxList[][[11]]]
SpxSetTransform[Location -> {-2.551, 0.889, 7.298},  
        Scale -> {0.3, 0.3, 0.3}];
SpxSetOptions[BoundBox -> False];
SpxSetMethod[
        SplinexMethod["UPS", "Alpha", 
          0]];
SpxSetColors[
        SolidColor -> RGBColor[1, 1, 1]];
SpxShow[
        Graphics3D[PointSize[1], Thickness[0.5], 
          RGBColor[{0.8,  0.3, 0.5}], 
Line[{-0.142, 
              0.141, 7.747},  {-0.1385, -0.9505, 
              7.9195}], 
Line[{-0.142, 0.141, 
              7.747},  {0.961, 0.134, 
              7.681}], 
Line[{-0.142, 0.141, 
              7.747},  {-0.1445, 1.1535, 
              7.587}], 
Line[{-0.142, 0.141, 
              7.747},  {-1.165, 0.1475, 
              7.8085}], 
RGBColor[{0,  1, 
              0}], 
Line[{-0.135, -2.042, 
              8.092},  {-0.1385, -0.9505, 
              7.9195}], 
 
          Line[{2.064, 0.127, 7.615},  {0.961, 0.134, 
              7.681}], 
RGBColor[{0,  0, 
              1}], 
Line[{-0.147, 2.166, 
              7.427},  {-0.1445, 1.1535, 
              7.5871}], 
Line[{-0.147, 2.166, 
              7.427},  {0.323, 2.3275, 
              7.373}], 
Line[{-0.147, 2.166, 
              7.427},  {-0.3585, 2.3955, 
              7.8175}], 
Line[{-0.147, 2.166, 
              7.427},  {-0.4075, 2.268, 
              7.0125}], 
Line[{-2.188, 0.154, 
              7.870},  {-1.165, 0.1475, 
              7.8085}], 
Line[{-2.188, 0.154, 
              7.870},  {-2.326, 0.2285, 
              8.3445}], 
Line[{-2.188, 0.154, 
              7.870},  {-2.367, -0.285, 
              7.711}], 
Line[{-2.188, 0.154, 
              7.870},  {-2.3695, 0.5215, 
              7.584}], 
RGBColor[{1,  1, 
              1}], 
Line[{0.793, 2.489, 7.319},  {0.323, 
              2.3275, 7.373}], 
Line[{-0.570, 2.625, 
              8.208},  {-0.3585, 2.3955, 
              7.8175}], 
Line[{-0.668, 2.370, 
              6.598},  {-0.4075, 2.268, 
              7.0125}], 
Line[{-2.464, 0.303, 
              8.819},  {-2.326, 0.2285, 
              8.3445}], 
Line[{-2.546, -0.724, 
              7.552},  {-2.367, -0.285, 
              7.711}], 
Line[{-2.551, 0.889, 
              7.298},  {-2.3695, 0.5215, 7.584}],  Boxed -> False, 
          BackgroundColor -> 
            RGBColor[0, 0, 0]]];
SpxSelect[SpxList[]];

To give your models a black background in nVizx, click the Background color box in the nVizx SCENE PANEL, and the select black from the color palette.

Ball and Stick Model of the Anti-Cancer Drug Cisplatin

Spacefill Model of the Anti-Cancer Drug Cisplatin

The .pdb file coordinate data used to make the cisplatin model in this notebook is shown below.  In building this model, the 1.00 entries to the data table (last two entries in each row) were ignored.

ATOM 1 PT1 MOL A 1-0.142 0.141 7.747 1.00 1.00
ATOM 2 CL2 MOL A 1-0.135-2.042 8.092 1.00 1.00
ATOM 3 CL3 MOL A 1 2.064 0.127 7.615 1.00 1.00
ATOM 4 N4 MOL A 1-0.147 2.166 7.427 1.00 1.00
ATOM 5 N5 MOL A 1-2.188 0.154 7.870 1.00 1.00
ATOM 6 1H4 MOL A 1 0.793 2.489 7.319 1.00 1.00
ATOM 7 2H4 MOL A 1-0.570 2.625 8.208 1.00 1.00
ATOM 8 3H4 MOL A 1-0.668 2.370 6.598 1.00 1.00
ATOM 9 1H5 MOL A 1-2.464 0.303 8.819 1.00 1.00
ATOM 10 2H5 MOL A 1-2.546-0.724 7.552 1.00 1.00
ATOM 11 3H5 MOL A 1-2.551 0.889 7.298 1.00 1.00
TER

End of Dynamic  3D Molecular Modeling with nVizx

Copyright Splinex Technology,  
    Inc .  2005     All Rights Reserved

                              Mathematica is a registered trademark of Wolfram Research . 
                                 nVizx is a trademark of Splinex Technology Inc.