A VMD script for auto-changing color and style

By Cun Zhang | April 4, 2011

VMD is a great MD tool for the pre- and post-processing of MD simulations which supports scripting.
Your can write your script(e.g. test.tcl), then run it with "vmd -e test.tcl" in bash console
or "source test.tcl" in vmd console. So it's easy and convenient
when you do similar processings with vmd.

Here is a script which I used to observe some details in my MD simulation.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#author: cunzhang (apzc2529@tom.com)
#homepage: http://edwardpku.com/cun/
# load file
mol load lammpstrj ini.lammpstrj xtc dump.xtc  
 
## set different names for color
[atomselect top "residue 0 and type 1"] set name 0
[atomselect top "residue 1 and type 1"] set name 1
[atomselect top "type 2"] set name H
[atomselect top "residue 2 and type 1"] set name 3
[atomselect top "((residue 1 and x**2+y**2>120 and y< -6 and x<-7) or (x<-17)) and type 1" frame 0] set name 4
 
## change the color of background and Atoms
color Display Background iceblue
color Name 0 green
color Name 1 pink
#color Name 2 blue
color Name 3 green
color Name 4 red
 
## change atom styles.
mol addrep 0
mol modselect 1 0 "name 4"
mol modstyle 1 0 dynamicbonds 1.6 0.3 50

Topics: Uncategorized | No Comments »

Protected: 想和你去吹吹风

By Cun Zhang | April 3, 2011

This post is password protected. To view it please enter your password below:


Topics: Uncategorized | Enter your password to view comments.

A MPI4PY Example

By Cun Zhang | March 20, 2011

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python
from mpi4py import MPI
 
comm=MPI.COMM_WORLD
 
size=comm.Get_size()
rank=comm.Get_rank()
if rank==0:
    result=0
    x=range(1,151)
else:
    x=None
 
x=comm.bcast(x,root=0)
 
N=len(x)/size
 
low=rank*N
high=low+N
myresult=0
result=[]
for i in range(low,high):
    myresult+=x[i]
 
result=comm.reduce(myresult,root=0)
 
if rank == 0:
    for i in range(size*N,len(x)):
        result=result+x[i]
    print result,sum(x)
 
MPI.Finalize()

Topics: Uncategorized | No Comments »

Python Ctypes Example

By Cun Zhang | March 29, 2010

  1. Write the C code
  2. I write a c source file named exam.c as follows:

     #include <stdio .h>
     #include <math .h>
     
    long int sum1(int I,int J){
    	int i,j;
    	long int s=0;
    	for(i=1;i< =I;i=i+1){
    		for(j=1;j<=J;j=j+1){
    			s=s+i+j;
    		}
    	}
    	return s;
    }
    void sum2(int I,int J,long int *s){
    	int i,j;
    	*s=0;
    	for(i=1;i<=I;i=i+1){
    		for(j=1;j<=J;j=j+1){
    			*s=*s+i+j;
    		}
    	}
    	return;
    }
    void main(){
    	int i=10000;
    	long int s1,s2;
    	sum2(i,i,&s2);
    	printf("%ld\n",s2);
    }
  3. Compile c code into share library
  4. cunzhang@Debian:~$ gcc -c -fPIC exam.c
    cunzhang@Debian:~$ gcc -shared exam.o -o exam.so
  5. call c function in python
  6. cunzhang@Debian:~$python exam.py
    cunzhang@Debian:~$ cat exam.py
    ?View Code PYTHON
    #!/usr/bin/python
    from ctypes import *
    exam=CDLL('/home/cunzhang/exam.so')
    I=c_long(10000)
    S=c_long()
    exam.sum1.restype=c_long
    x=exam.sum1(I,I)
    exam.sum2(I,I,byref(S))
    print x,S.value

Topics: Uncategorized | 1 Comment »

Prevent xscreensaver from blanking when watching movies

By Cun Zhang | January 15, 2010


How do I prevent xscreensaver from blanking the screen when
I'm watching movies on my computer?

If you are using a recent version of
MPlayer, put this
in your ~/.mplayer/config file:

If you're using something other than MPlayer:

If you are the author of movie-playing software:

From: http://www.jwz.org/xscreensaver/faq.html

Topics: Uncategorized | No Comments »

« Older Entries