Installing MPB

I wanted to try MPB also, it’s a photonic bandgap simulator by MIT. So I downloaded the package and tried to install in my office workstation. The config stage couldn’t pass since it didn’t find the FFTW library, though I have one installed. It turns out that mine is fftw3 while MPB is not compatible with fftw3 yet. So I have to installed fftw2 into my local directory. The installation for fftw2 is pretty straightforward. Now I need to specify both fftw2, libctl and HDF5 location into the configure of MPB (you may want to refer to Meep installation also, it’s quite similar). This is what I typed to configure MPB.


./configure --prefix=/scratch/kurniawano/local LDFLAGS="-L/scratch/kurniawano/local/fftw2/lib -L/scratch/kurniawano/Download/hdf5/lib" CPPFLAGS="-I/scratch/kurniawano/local/fftw2/include -I/scratch/kurniawano/Download/hdf5/include" --with-libctl=/scratch/kurniawano/local/share/libctl

However, when I typed make, it gives me an error, from this page, I found out that the problem is that I am using HDF5 version 1.8, so I needed to pass through the option -DH5_USE_16_API=1 in the CPPFLAGS. After adding this, my installation works fine :)

Drude model in Meep

I tried to simulate metal with Drude-Lorentz model. However, the expression given in Meep docs for the Drude term is slightly different, check this page. In Meep the dispersion relation is given by

\epsilon(\omega) = \epsilon_\infty + \frac{\omega_D^2 \sigma_D}{\omega_D^2-\omega^2-\imath \omega \gamma_D} + \frac{\Omega_L^2 \sigma_L}{\Omega_L^2-\omega^2-\imath \omega \Gamma_L}

where as the usual Drude-Lorentz model is given by

\epsilon(\omega) = \epsilon_\infty - \frac{\omega_D^2 }{\omega^2+\imath \omega \gamma_D} - \frac{\Omega_L^2 \sigma_L}{(\omega^2-\Omega_L^2)+\imath \omega \Gamma_L}

The last term, Lorentz term, is of course the same. The drude term, however, is slightly different. In the Meep-discuss forum, the following suggestion was given.

  • Use a very small value for \omega_D, in this way, the \omega_D in the denominator of the Drude term can be ignored.
  • The sigma value is computed to give the right resonance frequency for the Drude term.

Viewing animated gif in Linux

I was trying out Meep and it outputs animated gif from several png files. To view the animated gif, simply type

animate filename.gif

that’s it :)

Meep: No Match

I encountered this error “Meep: No Match” when running the tutorial for file bend-flux.ctl, From the forum, it turns out that I need to add \ before the ? when typing no-bend? variable the shell. So the correct command line is:

$ meep no-bend\?=true bend-flux.ctl | tee bend0.out
$ meep bend-flux.ctl | tee bend.out

Installing Meep 1.1.1

I tried to install Meep 1.1.1 in my CentOS workstation. It turns out that it needs some more packages to be installed. First Meep requires guile and libctl, So after downloading them, I tried to install guile. But it failed since guile requires GNU MP (sigh). So I downloaded GNU MP 4.3.1 and did configure, make, make install. I successfully installed in in a local folder. Then in configure guile, I need to specify the location of the GNU MP as well as the libltdl, so I typed:

./configure --prefix=/scratch/kurniawano/local LDFLAGS="-L/scratch/kurniawano/local/lib/" CPPFLAGS="-I/usr/share/libtool/libltdl/ -I/scratch/kurniawano/local/include"

I also need to specify the gmp.h location using CPPFLAGS. Otherwise, I will get an error “At least GNU MP 4.1 is required, see README”. After that I successfully installed guile 1.8.7. Once this is done I configure libctl and specifying the location of guile using LDFLAGS in the configure command. libctl was successfully installed also :)

During configure, a warning message shows that I didn’t have hdf5.h in my system. So I downloaded hdf5 and included the header files in the CPPFLAGS when installing meep 1.1.1. Before installing hdf5, I need to install SZIP library first. The installation for SZIP library is pretty simple and no problem encountered. However, it requires me to rebuild libctl again. After I installed hdf5, meep configure gives no error. But when I did make, it gives me error undefined reference to some hdf5 libraries. The problem is that some interface has changed in hdf5 1.8.x version. In one of the forum, it was suggested to install h5utils version 1.11.1.

To overcome this problem, I installed h5utils version 1.12.1 from MIT website, and configure it as follows:

./configure --prefix=/scratch/kurniawano/local LDFLAGS="-L/scratch/kurniawano/Download/hdf5/lib -L/scratch/kurniawano/local/lib" CPPFLAGS="-I/scratch/kurniawano/Download/hdf5/include -I/scratch/kurniawano/local/include" LIBS="-lhdf5"

If you use the shared library, you need to add the hdf5/lib into your LD_LIBRARY_PATH to make the configure successful. Besides that to create png, jpg image from hdf5 output of Meep, you need to install libpng, libjpeg. Another library that is required by h5utils is matheval.

To configure meep 1.1.1, I typed:

./configure --prefix=/scratch/kurniawano/local LDFLAGS="-L/scratch/kurniawano/Download/hdf5/lib -L/scratch/kurniawano/local/lib" CPPFLAGS="-I/scratch/kurniawano/Download/hdf5/include" LIBS="-lhdf5" --with-libctl=/scratch/kurniawano/local/share/libctl

This configures fine, but when I run make, it gives me this error:


libtool: link: warning: library `/scratch/kurniawano/Download/hdf5/lib/libhdf5.l
a' was moved.
grep: /mnt/hdf/packages/szip/shared/encoder/Linux2.6-x86_64-gcc/lib/libsz.la: No
such file or directory
/bin/sed: can't read /mnt/hdf/packages/szip/shared/encoder/Linux2.6-x86_64-gcc/l
ib/libsz.la: No such file or directory
libtool: link: `/mnt/hdf/packages/szip/shared/encoder/Linux2.6-x86_64-gcc/lib/li
bsz.la' is not a valid libtool archive

though, I have installed szip library, it seems that hdf5 looks at a different location. So I needed to edit the libhdf5.la file under the hdf5/lib folder, and comment the line for dependency_libs then add the line for szip lib location:


# Libraries that this one depends upon.
#dependency_libs=' -L/mnt/hdf/packages/szip/shared/encoder/Linux2.6-x86_64-gcc/l
ib /mnt/hdf/packages/szip/shared/encoder/Linux2.6-x86_64-gcc/lib/libsz.la -lz -l
m'
dependency_libs='/scratch/kurniawano/local/lib/libsz.la -lz -lm'

After this, the make and make install runs fine.

If you want to build Meep with MPI enabled for parallel computation, add –with-mpi during the configure stage.

How to upload photos from IPhoto to Flickr

Someone has created a great plugin to easily export photos in your iPhoto album to Flickr. You can install it from this link:
http://www.dustin.li/Publish/Software/Entries/2007/12/26_Free_Flickr_eXport_iPhoto_Plugin.html

Simply install the dmg file, and then restart iPhoto. To export, click “File->Export”, choose the tab FFXporter, and upload your photos :)

Creating movies from multiple jpg picture files

In my research, I produced a number of figures of time sequences. And I wanted to create a movie from this multiple jpg files. I use mencoder to do this, to install type:

sudo apt-get install mencoder (if you are using debian based such as ubuntu)

Then to create the avi file, simply type:

mencoder mf://@list.txt -mf fps=5:type=jpg -ovc lavc vcodec=mpeg4 -o test.avi

where list.txt contains the list of jpg file name that I want to convert. Of course we can simply use mf://*.jpg, however since my jpg file name is like 50.jpg, 100.jpg, 150.jpg, the files are not put in the right order, it will start with files beginning with “1…” first. So I save the correct order by typing:

ls -rt -1 *.jpg > list.txt

this will save the jpg files sorted in time sequence in one column into the file list.txt.

Why the sky is blue

If you don’t know why the sky is blue, you may want to read up this article:
Blue Sky

It is interesting and shows some physics of absorption and emission of light in day to day things you can see.

Changing background and front color in plplot library

The default background color in plplot library is black while the frontcolor is red. To do this, use plscolbg and plcol0 function. The code in fortran is:


call plscolbg(255,255,255)
call plinit()
call plcol0(8)

Remember that plscolbg must be called before plinit. The above code change the background color to white (rgb=255,255,255) and the front color to brown (8, refer to manual).

Note also that changing the background color will affect the color map 1 which is used for plotting continuous data. The reason is that color map 1 range from blue to red passing through the background color (default).

Kubuntu 9.10 is shining

I have been using Ubuntu 9.04 since it just works. The previous version of Kubuntu is pretty difficult to use. When using ubuntu, everything just works, I can watch video streaming, plugin downloaded autmatically, etc, etc.

So recently I have upgraded to 9.10, and I am so impressed with KDE 4. At least now the wireless network manager is working, last time I have to use WICD to connect to wireless. I am tempted to switch back to Kubuntu. I will give it a try again. can’t wait to play around with it.