Back to draw-VTK

'draw'-VTK interface:
Molecules


Once you have opened a Maxima session, load package draw and then set global variable draw_renderer to vtk:

load("draw") $
draw_renderer: 'vtk $

We define here a short script for drawing molecules. The function has four arguments: the names of the atoms, together with their coordinates, the bonds to be plotted, the colors and radius of the atoms, and color and width of the bonds:

molecule(atoms, bonds, adesign, ldesign) :=
    block([col, siz],

        local(col, siz),
        for k in adesign do (
            col[first(k)]: second(k),
            siz[first(k)]: third(k)),
        
          [  /* bonds */
            color = first(ldesign),
            line_width = second(ldesign),
            line_type = tube,
            point_size = 0,
            points_joined = true,
            makelist(points(makelist(rest(atoms[k[m]]),
                                     m,1,length(k))),
                     k, bonds),
            points_joined = false,

            /* atoms */
            points_joined = false,
            point_type = sphere,
            makelist([color = col[first(k)],
                             point_size = siz[first(k)],
                             points([rest(k)])], k, atoms)]  )  $

And now let's play with it. This first example is the methane. See the syntax for the atoms, bonds, and atoms and bonds plotting styles. Coordinates are in Angstrom:

methane_atoms: [
    [O,0.000000,0.000000,0.000000],
    [H,0.000000,0.000000,1.089000],
    [H,1.026719,0.000000,-0.363000],
    [H,-0.513360,-0.889165,-0.363000],
    [H,-0.513360,0.889165,-0.363000]] $

methane_bonds: [[1,2], [1,3], [1,4], [1,5]] $

atoms_style: [[O,green,1], [H,white,1/2]] $

bonds_style: [red, 1/10] $

draw3d(molecule(methane_atoms, methane_bonds, atoms_style, bonds_style)) $
mol1

A molecule of water. We don't use bonds here (empty list), but atoms radii are now larger:

water_atoms: [
    [O,0.000000,  0.000000,  0.114079],
    [H,0.000000,  0.780362,  -0.456316],
    [H,0.000000,  -0.780362, -0.456316]  ] $
water_bonds: [] $
atoms_style: [[O,navy,2.4], [H,white,1.5]] $
bonds_style: [red, 0.1] $

draw3d(molecule(water_atoms, water_bonds, atoms_style, bonds_style) )$
mol2

Two atoms of methanol in a multiplot, with and without bonds:

methanol_atoms: [
    [C,0.7333,0.0115,0.0000],
    [O,-0.6955,-0.0656,0.0000],
    [H,1.0934,0.5490,0.9107],
    [H,1.0934,0.5490,-0.9107],
    [H,1.1599,-1.0124,0.0000],
    [H,-1.0408,0.8175,0.0000]  ] $
methanol_bonds: [[1,2], [1,3], [1,4], [1,5], [2,6]] $
atoms_style: [[C,green,1], [O,red,3/4], [H,white,1/2]] $
bonds_style: [blue, 0.18] $

draw(
    dimensions = [300, 600],
    gr3d(background_color = gray50,
             molecule(methanol_atoms, methanol_bonds, atoms_style, bonds_style)), 
    gr3d(background_color = orange,
            molecule(methanol_atoms, [], atoms_style, bonds_style)))$
mol3

Boron trifluoride and benzene in one plot:

/* Boron trifluoride */
boron_trifluoride_atoms: [
    [B,3.0,3.0,3.0],
    [F,4.33,3.0,3.0],
    [F,2.335,4.152,3.0],
    [F,2.335,1.848,3.0]  ] $
boron_trifluoride_links: [] $
boron_trifluoride_atoms_style: [[B,green,1], [F,cyan,1/2]] $
boron_trifluoride_links_style: [red, 0.2] $

/* Benzene */
benzene_atoms: [
    [C,0.00000,1.40272,0.00000],
    [H,0.00000,2.49029,0.00000],
    [C,-1.21479,0.70136,0.00000],
    [H,-2.15666,1.24515,0.00000],
    [C,-1.21479,-0.70136,0.00000],
    [H,-2.15666,-1.24515,0.00000],
    [C,0.00000,-1.40272,0.00000],
    [H,0.00000,-2.49029,0.00000],
    [C,1.21479,-0.70136,0.00000],
    [H,2.15666,-1.24515,0.00000],
    [C,1.21479,0.70136,0.00000],
    [H,2.15666,1.24515,0.00000] ] $
benzene_links: [[1,3,5,7,9,11,1], [1,2], [3,4],
                [5,6], [7,8], [9,10], [11,12]] $
benzene_atoms_style: [[C,orange,1], [H,white,1/2]] $
benzene_links_style: [red, 0.15] $

draw3d(
    molecule(benzene_atoms,
                    benzene_links, 
                    benzene_atoms_style, 
                    benzene_links_style),

    molecule(boron_trifluoride_atoms,
                    boron_trifluoride_links, 
                    boron_trifluoride_atoms_style, 
                    boron_trifluoride_links_style) )$
mol4

Caffeine. Here we plot a partial number of bonds:

caffeine_atoms: 
[[C, -1.799,   0.022,   0.602],
[N, -1.586,  -0.945,  -0.363],
[C, -2.731,  -1.654,  -0.954],
[C, -0.301,  -1.248,  -0.776],
[C,  0.789,  -0.574,  -0.214],
[C,  0.563,   0.404,   0.763],
[N, -0.728,   0.694,   1.163],
[C, -0.964,   1.720,   2.189],
[N,  1.752,   0.896,   1.139],
[C,  2.729,   0.287,   0.454],
[N,  2.158,  -0.638,  -0.400],
[C,  2.871,  -1.524,  -1.331],
[O, -0.101,  -2.186,  -1.712],
[O, -3.048,   0.309,   0.996],
[H,  3.786,   0.485,   0.553],
[H, -2.947,  -2.544,  -0.368],
[H, -2.491,  -1.941,  -1.976],
[H, -3.601,  -1.000,  -0.955],
[H, -1.088,   2.689,   1.711],
[H, -0.114,   1.756,   2.868],
[H, -1.864,   1.473,   2.748],
[H,  2.981,  -1.026,  -2.293],
[H,  2.305,  -2.444,  -1.462],
[H,  3.855,  -1.757,  -0.929]] $

caffeine_bonds: [
    [1,2], [1,7], [1,14],
    [2,3], [2,4],
/* [3,16], [3,17], [3,18],
    [4,5], [4,13],
    [5,6], [5,11],
    [6,7], [6,9],
    [7,8],
    [8,19], [8,20], [8,21], */
    [9,10],
    [10,11], [10,15],
    [11,12],
    [12,22], [12,23], [12,24]  ] $

atoms_style: [[C,green,1], [N,brown,1/2], [O,yellow,3/4], [H,black,1/3]] $
bonds_style: [cyan, 0.01] $

draw3d(
   axis_3d    = false, 
   molecule(caffeine_atoms, caffeine_bonds, atoms_style,bonds_style) )$
mol5

Nanotube. Screenshots from different positions:

nt_atoms: 
[[H,  3.7887837463,  1.2310504983,  -6.8241051525],
[H,  2.3415971110,  3.2229319842,  -6.8241051525],
[H,  -0.0000000327,  3.9837629956,  -6.8241051525],
[H,  -2.3415971639,  3.2229319458,  -6.8241051525],
[H,  -3.7887837665,  1.2310504361,  -6.8241051525],
[H,  -3.7887837463,  -1.2310504983,  -6.8241051525],
[H,  -2.3415971110,  -3.2229319842,  -6.8241051525],
[H,  0.0000000327,  -3.9837629956,  -6.8241051525],
[H,  2.3415971639,  -3.2229319458,  -6.8241051525],
[H,  3.7887837665,  -1.2310504361,  -6.8241051525],
[C,  3.8076800766,  1.2371902884,  -5.7281027302],
[C,  2.3532756853,  3.2390061631,  -5.7281027302],
[C,  -0.0000000329,  4.0036317732,  -5.7281027302],
[C,  -2.3532757385,  3.2390061244,  -5.7281027302],
[C,  -3.8076800969,  1.2371902259,  -5.7281027302],
[C,  -3.8076800766,  -1.2371902884,  -5.7281027302],
[C,  -2.3532756853,  -3.2390061631,  -5.7281027302],
[C,  0.0000000329,  -4.0036317732,  -5.7281027302],
[C,  2.3532757385,  -3.2390061244,  -5.7281027302],
[C,  3.8076800969,  -1.2371902259,  -5.7281027302],
[C,  3.9865457289,  0.0000000327,  -5.0377225142],
[C,  3.2251832243,  2.3432328135,  -5.0377225142],
[C,  1.2319103479,  3.7914303031,  -5.0377225142],
[C,  -1.2319104102,  3.7914302828,  -5.0377225142],
[C,  -3.2251832627,  2.3432327605,  -5.0377225142],
[C,  -3.9865457289,  -0.0000000327,  -5.0377225142],
[C,  -3.2251832243,  -2.3432328135,  -5.0377225142],
[C,  -1.2319103479,  -3.7914303031,  -5.0377225142],
[C,  1.2319104102,  -3.7914302828,  -5.0377225142],
[C,  3.2251832627,  -2.3432327605,  -5.0377225142],
[C,  3.9845747152,  0.0000000327,  -3.5890478179],
[C,  3.2235886408,  2.3420742807,  -3.5890478179],
[C,  1.2313012713,  3.7895557577,  -3.5890478179],
[C,  -1.2313013335,  3.7895557375,  -3.5890478179],
[C,  -3.2235886792,  2.3420742278,  -3.5890478179],
[C,  -3.9845747152,  -0.0000000327,  -3.5890478179],
[C,  -3.2235886408,  -2.3420742807,  -3.5890478179],
[C,  -1.2313012713,  -3.7895557577,  -3.5890478179],
[C,  1.2313013335,  -3.7895557375,  -3.5890478179],
[C,  3.2235886792,  -2.3420742278,  -3.5890478179],
[C,  3.7886931714,  1.2310210688,  -2.8732875320],
[C,  2.3415411327,  3.2228549367,  -2.8732875320],
[C,  -0.0000000327,  3.9836677596,  -2.8732875320],
[C,  -2.3415411856,  3.2228548982,  -2.8732875320],
[C,  -3.7886931916,  1.2310210066,  -2.8732875320],
[C,  -3.7886931714,  -1.2310210688,  -2.8732875320],
[C,  -2.3415411327,  -3.2228549367,  -2.8732875320],
[C,  0.0000000327,  -3.9836677596,  -2.8732875320],
[C,  2.3415411856,  -3.2228548982,  -2.8732875320],
[C,  3.7886931916,  -1.2310210066,  -2.8732875320],
[C,  3.7912985860,  1.2318676193,  -1.4355100990],
[C,  2.3431513674,  3.2250712347,  -1.4355100990],
[C,  -0.0000000327,  3.9864072546,  -1.4355100990],
[C,  -2.3431514204,  3.2250711962,  -1.4355100990],
[C,  -3.7912986062,  1.2318675571,  -1.4355100990],
[C,  -3.7912985860,  -1.2318676193,  -1.4355100990],
[C,  -2.3431513674,  -3.2250712347,  -1.4355100990],
[C,  0.0000000327,  -3.9864072546,  -1.4355100990],
[C,  2.3431514204,  -3.2250711962,  -1.4355100990],
[C,  3.7912986062,  -1.2318675571,  -1.4355100990],
[C,  3.9873938658,  0.0000000327,  -0.7180431612],
[C,  3.2258693815,  2.3437313359,  -0.7180431612],
[C,  1.2321724367,  3.7922369292,  -0.7180431612],
[C,  -1.2321724989,  3.7922369090,  -0.7180431612],
[C,  -3.2258694200,  2.3437312829,  -0.7180431612],
[C,  -3.9873938658,  -0.0000000327,  -0.7180431612],
[C,  -3.2258693815,  -2.3437313359,  -0.7180431612],
[C,  -1.2321724367,  -3.7922369292,  -0.7180431612],
[C,  1.2321724989,  -3.7922369090,  -0.7180431612],
[C,  3.2258694200,  -2.3437312829,  -0.7180431612],
[C,  3.9873938658,  0.0000000327,  0.7180431612],
[C,  3.2258693815,  2.3437313359,  0.7180431612],
[C,  1.2321724367,  3.7922369292,  0.7180431612],
[C,  -1.2321724989,  3.7922369090,  0.7180431612],
[C,  -3.2258694200,  2.3437312829,  0.7180431612],
[C,  -3.9873938658,  -0.0000000327,  0.7180431612],
[C,  -3.2258693815,  -2.3437313359,  0.7180431612],
[C,  -1.2321724367,  -3.7922369292,  0.7180431612],
[C,  1.2321724989,  -3.7922369090,  0.7180431612],
[C,  3.2258694200,  -2.3437312829,  0.7180431612],
[C,  3.7912985860,  1.2318676193,  1.4355100990],
[C,  2.3431513674,  3.2250712347,  1.4355100990],
[C,  -0.0000000327,  3.9864072546,  1.4355100990],
[C,  -2.3431514204,  3.2250711962,  1.4355100990],
[C,  -3.7912986062,  1.2318675571,  1.4355100990],
[C,  -3.7912985860,  -1.2318676193,  1.4355100990],
[C,  -2.3431513674,  -3.2250712347,  1.4355100990],
[C,  0.0000000327,  -3.9864072546,  1.4355100990],
[C,  2.3431514204,  -3.2250711962,  1.4355100990],
[C,  3.7912986062,  -1.2318675571,  1.4355100990],
[C,  3.7886931714,  1.2310210688,  2.8732875320],
[C,  2.3415411327,  3.2228549367,  2.8732875320],
[C,  -0.0000000327,  3.9836677596,  2.8732875320],
[C,  -2.3415411856,  3.2228548982,  2.8732875320],
[C,  -3.7886931916,  1.2310210066,  2.8732875320],
[C,  -3.7886931714,  -1.2310210688,  2.8732875320],
[C,  -2.3415411327,  -3.2228549367,  2.8732875320],
[C,  0.0000000327,  -3.9836677596,  2.8732875320],
[C,  2.3415411856,  -3.2228548982,  2.8732875320],
[C,  3.7886931916,  -1.2310210066,  2.8732875320],
[C,  3.9845747152,  0.0000000327,  3.5890478179],
[C,  3.2235886408,  2.3420742807,  3.5890478179],
[C,  1.2313012713,  3.7895557577,  3.5890478179],
[C,  -1.2313013335,  3.7895557375,  3.5890478179],
[C,  -3.2235886792,  2.3420742278,  3.5890478179],
[C,  -3.9845747152,  -0.0000000327,  3.5890478179],
[C,  -3.2235886408,  -2.3420742807,  3.5890478179],
[C,  -1.2313012713,  -3.7895557577,  3.5890478179],
[C,  1.2313013335,  -3.7895557375,  3.5890478179],
[C,  3.2235886792,  -2.3420742278,  3.5890478179],
[C,  3.9865457289,  0.0000000327,  5.0377225142],
[C,  3.2251832243,  2.3432328135,  5.0377225142],
[C,  1.2319103479,  3.7914303031,  5.0377225142],
[C,  -1.2319104102,  3.7914302828,  5.0377225142],
[C,  -3.2251832627,  2.3432327605,  5.0377225142],
[C,  -3.9865457289,  -0.0000000327,  5.0377225142],
[C,  -3.2251832243,  -2.3432328135,  5.0377225142],
[C,  -1.2319103479,  -3.7914303031,  5.0377225142],
[C,  1.2319104102,  -3.7914302828,  5.0377225142],
[C,  3.2251832627,  -2.3432327605,  5.0377225142],
[C,  3.8076800766,  1.2371902884,  5.7281027302],
[C,  2.3532756853,  3.2390061631,  5.7281027302],
[C,  -0.0000000329,  4.0036317732,  5.7281027302],
[C,  -2.3532757385,  3.2390061244,  5.7281027302],
[C,  -3.8076800969,  1.2371902259,  5.7281027302],
[C,  -3.8076800766,  -1.2371902884,  5.7281027302],
[C,  -2.3532756853,  -3.2390061631,  5.7281027302],
[C,  0.0000000329,  -4.0036317732,  5.7281027302],
[C,  2.3532757385,  -3.2390061244,  5.7281027302],
[C,  3.8076800969,  -1.2371902259,  5.7281027302],
[H,  3.7887837463,  1.2310504983,  6.8241051525],
[H,  2.3415971110,  3.2229319842,  6.8241051525],
[H,  -0.0000000327,  3.9837629956,  6.8241051525],
[H,  -2.3415971639,  3.2229319458,  6.8241051525],
[H,  -3.7887837665,  1.2310504361,  6.8241051525],
[H,  -3.7887837463,  -1.2310504983,  6.8241051525],
[H,  -2.3415971110,  -3.2229319842,  6.8241051525],
[H,  0.0000000327,  -3.9837629956,  6.8241051525],
[H,  2.3415971639,  -3.2229319458,  6.8241051525],
[H,  3.7887837665,  -1.2310504361,  6.8241051525]] $

bonds:  
[[1,11],[2,12],[3,13],[4,14],[5,15],[6,16],[7,17],[8,18],[9,19],[10,20],
[11,21],[11,22],[12,22],[12,23],[13,23],[13,24],[14,24],[14,25],[15,25],
[15,26],[16,26],[16,27],[17,27],[17,28],[18,28],[18,29],[19,29],[19,30],
[20,21],[20,30],[21,31],[22,32],[23,33],[24,34],[25,35],[26,36],[27,37],
[28,38],[29,39],[30,40],[31,41],[31,50],[32,41],[32,42],[33,42],[33,43],
[34,43],[34,44],[35,44],[35,45],[36,45],[36,46],[37,46],[37,47],[38,47],
[38,48],[39,48],[39,49],[40,49],[40,50],[41,51],[42,52],[43,53],[44,54],
[45,55],[46,56],[47,57],[48,58],[49,59],[50,60],[51,61],[51,62],[52,62],
[52,63],[53,63],[53,64],[54,64],[54,65],[55,65],[55,66],[56,66],[56,67],
[57,67],[57,68],[58,68],[58,69],[59,69],[59,70],[60,61],[60,70],[61,71],
[62,72],[63,73],[64,74],[65,75],[66,76],[67,77],[68,78],[69,79],[70,80],
[71,81],[71,90],[72,81],[72,82],[73,82],[73,83],[74,83],[74,84],[75,84],
[75,85],[76,85],[76,86],[77,86],[77,87],[78,87],[78,88],[79,88],[79,89],
[80,89],[80,90],[81,91],[82,92],[83,93],[84,94],[85,95],[86,96],[87,97],
[88,98],[89,99],[90,100],[91,101],[91,102],[92,102],[92,103],[93,103],
[93,104],[94,104],[94,105],[95,105],[95,106],[96,106],[96,107],[97,107],
[97,108],[98,108],[98,109],[99,109],[99,110],[100,101],[100,110],[101,111],
[102,112],[103,113],[104,114],[105,115],[106,116],[107,117],[108,118],
[109,119],[110,120],[111,121],[111,130],[112,121],[112,122],[113,122],
[113,123],[114,123],[114,124],[115,124],[115,125],[116,125],[116,126],
[117,126],[117,127],[118,127],[118,128],[119,128],[119,129],[120,129],
[120,130],[121,131],[122,132],[123,133],[124,134],[125,135],[126,136],
[127,137],[128,138],[129,139],[130,140]] $

atoms_style: [[C,green,1], [H,white,1/2]] $
bonds_style: [blue, 0.1] $

draw3d(molecule(nt_atoms, bonds, atoms_style, bonds_style) )$
mol6 mol7 mol8

© 2016, TecnoStats.