About      Issues      Tutorials      Documentation </span>

Tutorial 1: Making a molecule

This notebook gets you started with MDT - you'll build a small molecule, visualize it, and run a basic calculation.

1. Import the toolkit

This cell loads the toolkit and its unit system. To execute a cell, click on it, then press shift + enter. (If you're new to the notebook environment, you may want to check out this helpful cheat sheet).

In [ ]:
import moldesign as mdt
import moldesign.units as u

Optional: configuration options

If you'd like to set some basic MDT configuration options, you can execute the following cell to create a GUI configuration editor:

In [ ]:

2. Read in a molecular structure

Let's get started by reading in a molecular structure file.

When you execute this cell, you'll use mdt.read function to parse an XYZ-format file to create an MDT molecule object named, appropriately enough, molecule:

In [ ]:
molecule = mdt.read('data/butane.xyz')

Jupyter notebooks will automatically print out the value of the last statement in any cell. When you evaluate a Molecule, as in the cell below, you'll get some quick summary data:

In [ ]:

3. Visualize it

MDT molecules have three built-in visualization methods - draw, draw2d, and draw3d. Try them out!

In [ ]:
viewer = molecule.draw()
viewer  # we tell Jupyter to draw the viewer by putting it on the last line of the cell

Try clicking on some of the atoms in the visualization you've just created.

Afterwards, you can retrieve a list of the Python objects representing the atoms you clicked on:

In [ ]:

4. Simulate it

So far, we've created a 3D molecular structure and visualized it right in the notebook.

If you sat through VSEPR theory in P. Chem, you might notice this molecule (butane) is looking decidedly non-optimal. Luckily, we can use simulation to predict a better structure.

We're specifically going to run a basic type of Quantum Chemistry calculation called "Hartree-Fock", which will give us information about the molecule's orbitals and energy.

In [ ]:
molecule.set_energy_model(mdt.models.RHF, basis='sto-3g')
properties = molecule.calculate()

In [ ]:
print('Energy: ', properties['potential_energy'])

In [ ]:

5. Minimize it

Next, an energy minimization - that is, we're going to move the atoms around in order to find a minimum energy conformation. This is a great way to start cleaning up the messy structure we started with. The calculation might take a second or two ...

In [ ]:
mintraj = molecule.minimize()

In [ ]:

6. Write it

In [ ]:

In [ ]:

7. Play with it

There are any number of directions to go from here. See how badly you can distort the geometry:

In [ ]:

In [ ]:

In [ ]: