Skip to main content

creates smooth gifs of rotating molecules

Project description

molgif

create smooth gifs of rotating molecules

Examples

Automatically rotate molecule for better view

import molgif
import ase.build

# load in molecule (ase.Atoms object)
molecule = ase.build.molecule('biphenyl')

# specify save path
save_path = 'biphenyl.gif'

# create rotating gif with rot_gif function
molgif.rot_gif(molecule, save_path, auto_rotate=True)

Adjust loop time and FPS

# time to complete one rotation (seconds)
loop_time = 2

# frames per second
fps = 60

molgif.rot_gif(molecule, save_path, auto_rotate=True,
               loop_time=loop_time, fps=fps)

Turn off bonds and scale atomic sizes

molgif.rot_gif(molecule, save_path, auto_rotate=True,
               add_bonds=False, scale=0.9)

Visualize charges and include a colorbar

import random

# random charges [-1, 1]
chgs = [-1 + 2 * random.random() for i in molecule]

molecule.set_initial_charges(chgs)

molgif.rot_gif(molecule, save_path, auto_rotate=True,
               use_charges=True)

Specify color of each atom

# can be a string for one color or a list of custom colors
rainbow = ['red', 'orange', 'yellow', 'green', 'blue', 'violet'] * 4

# list much match number of atoms
rainbow = rainbow[:len(molecule)]

molgif.rot_gif(molecule, save_path, auto_rotate=True,
               colors=rainbow)

Switch rotation direction and adjust bond widths

# counterclockwise (ccw) or clockwise
# based on top-down perspective
direction = 'cw'

# specify bond width in Angstrom
bond_width = 0.4

molgif.rot_gif(molecule, save_path, auto_rotate=True,
               direction=direction, bond_width=bond_width)

Requirements

  • ase
  • matplotlib
  • ImageMagick (command line tools must be installed)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

molgif-0.0.5.tar.gz (7.0 kB view details)

Uploaded Source

File details

Details for the file molgif-0.0.5.tar.gz.

File metadata

  • Download URL: molgif-0.0.5.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for molgif-0.0.5.tar.gz
Algorithm Hash digest
SHA256 96db8465b70c77447e69d19eb82bf52b6631204bb56990ff5b01003e72ef039f
MD5 af95c804cdb38f7ac225f78958da96ab
BLAKE2b-256 945664a5104c228e69f05049625c0a3ccf0a2e68c9a4dfb7ca263b734da89225

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page