20 Aralık 2009 Pazar

Random Number Generator in OpenMP

Few days ago I have started to learn OpenMP api. Before using it in my research project I started with "Hello World" type examples. OpenMP basically is a set of compiler directives which can be used to parallelize your code. Instead of message passing between cpu's OpenMP uses shared memory architecture. Every core in a multicore cpu uses same memory and if your job doesn't require huge amount of cpus OpenMP is a good choice. Detailed information can be obtained at OpenMP web site.
I have started reading the book by Chandra et al. To practice I wrote a simple program that uses Monte Carlo integration technique. In this technique, to calculate integral of a function in a given interval you evaluate that function at randomly selected points in this interval. Average value of the function values times length of the interval gives the integral.
After writing my code using OpenMP directives I compiled it with -openmp option using Intel Fortran Compiler. After running the code I observed that program runs much slower in parallel version. At first I thought that I am making a mistake with OpenMP. I checked again and again found nothing. As a final effort I google " random number openmp slow" that was my last hope.
Then I found that OpenMP runs intrinsic random number function of fortran slower in parallel. The reason of this behavior explained here. Simply, intrinsic random_number function has a variable with "saved" attribute. Because of that every thread that calls this function should wait each other. The only solution for this problem is to use your own parallel random number generator. Hopefully they posted a solution at referred web site. They also supplied a parallel random number generator written in F90, this code can be downloaded here. However there are few bugs in this code. I have cleaned those bugs and added some features to this code. My version can be downloaded here.

while I was trying to learn OpenMP api

17 Kasım 2009 Salı

LAMMPS Howto's : How to simulate non-orthogonal systems in LAMMPS?

Primitive vectors of diamond crystal is:
A1=0, 1/2 , 1/2
A2=1/2 , 0 , 1/2
A3=1/2 , 1/2 , 0
To simulate triclinic systems in lammps lets check LAMMPS manual first:
If the xy xz yz line does not appear, LAMMPS will set up an axis-aligned (orthogonal) simulation box. If the line does appear, LAMMPS creates a non-orthogonal simulation domain shaped as a parallelepiped with triclinic symmetry. See the region prism command for a description of how the extent of the parallelepiped is defined. The parallelepiped has its "origin" at (xlo,ylo,zlo) and 3 edge vectors starting from the origin given by a = (xhi-xlo,0,0); b = (xy,yhi-ylo,0); c = (xz,yz,zhi-zlo). Note that if your simulation will tilt the box, e.g. via the fix deform command, the simulation box must be triclinic, even if the tilt factors are initially 0.0.

So what we need is a set of primitive vectors with first one is aligned with -x axis , second one is at xy plane.
If we apply a rotation for the primitive vectors of diamond to align A1 to X axis and A2 to xy plane our rotated primitive vectors will be:
A1=1/2, 0 , 0
A2=1/2 , sqrt(3)/2 , 0
A3=1/2 , sqrt(3)/6 , sqrt(2/3)
and basis points are:
B1=0 , 0 , 0
B2= 1/4 A1 + 1/4 A2 + 1/4 A3
If we set lattice constant to 5.43 A for Silicon
we will have the following data file for lammps:
Note that
For Lsi stands for lattice constant of Silicon
xhi-xlo=Lsi/sqrt(2)
yhi-ylo=Lsi*sqrt(3/2)*1/2
zhi-zlo=Lsi/sqrt(3)
and tilting factors are:
xy=xz=Lsi/(2*sqrt(2))
yz=Lsi*1/6*sqrt(3/2)


2 atoms
6 atom types

0 3.83959 xlo xhi
0 3.32518 ylo yhi
0 3.1350 zlo zhi
1.91979 1.91979 1.1084 xy xz yz
Masses

1 12.0000
2 1.0080
3 15.9990
4 14.0000
5 14.0000
6 28.0000

Atoms

1 6 0 0.0 0.0 0.0
2 6 0 1.91979 1.10839 0.78375

This data file is prepared to use ReaxFFsio with LAMMPS. However LAMMPS distribution does not contain Si parameters. Older distribution does. You may use those too.
Dundar Yilmaz.

25 Haziran 2009 Perşembe

13 Haziran 2009 Cumartesi

Also Known As : BilkentAsistan

Bilkent'teki asistanlik gorevim bitti. Temmuz ayindan itibaren Texas A&M University de post doc olarak baslicam.
bilkentasistan.blogspot.com adresindeki blogum tamupostdoc.blogspot.com olarak da devam edicek...