Skip to main content

creates smooth gifs of rotating molecules

Project description

molgif

create smooth gifs of rotating molecules

Examples

Use auto_rotate to find the best viewing angle

import molgif
import ase.build

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

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

Add a legend

molgif.rot_gif(molecule, add_legend=True)

Specify the 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, colors=rainbow)

Use a dictionary to quickly color by atom type

# default colors will be used for types not specified
molgif.rot_gif(molecule, colors=dict(C='hotpink'),
               add_legend=True)

Anchor an atom to be at the center of rotation

# define index of atom to anchor
anchor = 3

colors = ['white'] * len(molecule)
colors[anchor] = '#0892d0'

molgif.rot_gif(molecule, colors=colors,
               anchor=anchor)

Adjust loop time and FPS

# loop_time = time to complete one rotation (seconds)
molgif.rot_gif(molecule, loop_time=2, fps=60)

Turn off bonds and scale atomic sizes

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

Change rotation axis

# switch between x, y (Default), or z
molgif.rot_gif(molecule, rot_axis='z')

Switch rotation direction

# counterclockwise (ccw)[Default] or clockwise (cw)
# based on rot_axis
# 'x': view from left
# 'y': view from top
# 'z': view into screen
molgif.rot_gif(molecule, direction='cw')

Visualize charges

import random

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

# manually set the colorbar range (optional)
cb_range = (-1, 1)

molecule.set_initial_charges(chgs)

molgif.rot_gif(molecule, use_charges=True,
               cb_range=cb_range)

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.1.7.tar.gz (11.2 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: molgif-0.1.7.tar.gz
  • Upload date:
  • Size: 11.2 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.1.7.tar.gz
Algorithm Hash digest
SHA256 cb837f9d737d22b6317edfa4164018a7d59aaf0b81cfe8752f55da38aa2cd321
MD5 e023543c40206f4711f5fa6a359e8ce2
BLAKE2b-256 86f4e1b058bfec2600dedc339c965cb84787503befa956a9c9a5965b2f858a54

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