Archive for the ‘My work’ Category.

Animation with matplotlib

A demo program showing the way to make animation with matplotlib.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# A demo for animation with matplotlib
# Written by Ting Li (Dr.Ting.Li at gmail.com)
# 2010-09-10
# Ref: http://www.scipy.org/Cookbook/Matplotlib/Animations
import numpy as np
import time
import matplotlib
matplotlib.use('WXAgg') #before import pylab, choose the GUI backend
#It can also be done while calling this script from command line:
#>>> python animation.py -dWXAgg
#Other backends are: valid strings are ['ps', 'Qt4Agg', 'GTK', 'GTKAgg', 'svg',
# 'agg', 'cairo', 'MacOSX', 'GTKCairo', 'WXAgg', 'TkAgg', 'QtAgg', 'FltkAgg',
# 'pdf', 'CocoaAgg', 'emf', 'gdk', 'template', 'WX']
from pylab import *

ion() #a must, into interactive mode

 <a href="http://9rivers.linkka.com/2010/09/11/animation-with-matplotlib/#more-561" class="more-link"><small>Continue reading &#8216;Animation with matplotlib&#8217; &raquo;</small></a>

A Zotero style for ACS references with titles

Zotero, the must-have reference manager for scientists, supports various bibliography styles. This is benefited from the CSL (citation style language), which is an open XML standard for citations and bibliographies. Since Zotero is implemented as a Firefox addon, it naturally supports search and grab references from the internet, which is very convenient and better than some other stand-alone reference managers.

Zotero has a CSL editor. It can be invoked by entering “chrome://zotero/content/tools/csledit.xul” as the url in Firefox. Here has a step-by-step tutorial on how to create a new csl style. There is also a GUI program which can edit and create a CSL file, it is CSLedit.

Continue reading ‘A Zotero style for ACS references with titles’ »

Keyboard shortcut to insert euqations

I didn’t know this before I saw this post. The shortcut is ‘Alt+=’. That’s simple!

Uncompress tar to specific directory + Other tar/untar tricks

There is a ‘-C’ option allow you to do this. However, it can fail in some situation. There are also some posts online that report this option does not work. If you have that problem, maybe you could try the solution here.

Here is my experience, on Cygwin (I didn’t test this on other systems)

Continue reading ‘Uncompress tar to specific directory + Other tar/untar tricks’ »

Hide the command console window while running a GUI/Command line program on Windows

While running a command line program or some GUI initiated from command line on Windows, there is always a black console window on the screen. This sometime becomes annoying. For example, when you start the Eric Python IDE on Windows, normally you start it by calling a batch file “eric4.bat” which calls the actual eric4.py script sequentially. Since Eric4 is designed to be a GUI program, the black console window has no use but it is there. To prevent that or hide it, there are several ways.
Continue reading ‘Hide the command console window while running a GUI/Command line program on Windows’ »

Compile gromacs on Cygwin

Just some notes:
1. manually download and install fftw3. Do not use the cgywin package, or the path will not be recognized by Gromacs.
2. Needed Cygwin packages: lapack, gcc, g77, make and nasm. nasm is required for both fftw and Gromacs in order to compile the assembly codes.

A bash script to plot multiple files in old version of gnuplot

For gnuplot version older than 4.4, ‘plot for’ is not an option to plot multiple files. In order to make it work and easier, I wrote a BASH script to generate the gnuplot input for multiple file plotting. You are lucky too find this if you are still using old version of gnuplot. No need to use it for the lastest version.

1
2
3
4
5
6
7
8
9
#!/bin/bash
echo "#############################################"
echo -e "A bash script to generate gnuplot input.\n\
Author: Ting Li\n\
Email: Dr.Ting.Li@gmail.com\n\
Date: 05/05/2010"

echo "#############################################"

 <a href="http://9rivers.linkka.com/2010/05/06/a-bash-script-to-plot-multiple-files-in-old-version-of-gnuplot/#more-485" class="more-link"><small>Continue reading &#8216;A bash script to plot multiple files in old version of gnuplot&#8217; &raquo;</small></a>

Nonbond interactions in Materials Studio and unit conversion

1. by default, while using cff91, 1-2, 1-3 pairs are excluded. But 1-4 pair is considered as nonbond pairs. This is valid for both vdW and electrostatic interactions.

2. sixth power mixing rule is used for vdW.

3. kq1q2/r is used for electrostatic interaction, where k=(1.386e-4/1e-10/4184)=331.26195 and q1, q2 are electric charge, r in Angstrom.

van der Waals

Internal overflow compressing coordinates

I occasionally got this error while running some mpi programs. I could not find the exact reason. Even when I google it, it seems no relevant explanation of it. By investigating the codes with debugger, I notices some data in the memory are huge, when I correct them, the error information was gone too. Therefore I guess this error is related to the expression of illegal numbers. However, I would like to know more about it if someone can point out the exact reason.