Tuesday, July 24, 2012

How to install Numpy and Scipy in Ubuntu without root right

During my research working, I need to install 'matplot' in Ipython; however, the newest version of matplot requires latest version of Numpy and Scipy. Since I am using the university computer, Ubuntu 10.10, and Numpy and Scipy is very old. So I try to manage to update the later version of Numpy and Scipy.

  1. Numpy install:

  2. Here we basically follow the instruction of the instruction on the webpage"http://www.hongliangjie.com/2012/04/01/install-numpy-and-scipy-on-centos-without-root-privilege/"

    Notice that here you have to install LAPAC and BLAS correctly before you install NUmpy. You can find some instruction about LAPAC and BLAS installation also from the link above.
  1. Scipy install:
       Installation of Scipy is a little bit tricky. First, I failed because I cannot manage to change the installation directory. Then with the help of Michael yesterday, he did it.
  • Copy the 'site.cfg' to the untared directory file folder of scipy, say in my case 'scipy-0.10.1'. 
  • You have to make sure in which directory installed your python library. This is why I failed before. Michael somehow is experienced to that, and he find it out. So open the site.cfg and change the lines under '[Default]':
        [DEFAULT]
      library_dirs = /usr/lib
      include_dirs = /usr/include
      src_dirs = [BLAS]:[LAPACK]
  •  Under the folder of 'scipy-0.10.1' in your terminal, you have to make sure to build with either gfortran or g77 complier, in my case I use gfortran, so you type:
       python setup.py build --fcomplier=gfortran
  •  Then you can install scipy in your local computer:
        python setup.py install --home=~

Monday, July 23, 2012

Python: multiple sorted with keys

Today I encounter a problem of sorting an array or a list twice, first by index key1, then by index key2.

More specificlly:

ththings  = [("animal", "bear"), ("vehicle", "school bus"),("animal", "duck"), ("plant", "cactus"), ("vehicle", "speed boat")]

And I want it first be arranged by the first index alphabetically, and then within each class, i.e. 'animal', 'vehicle', 'plant', the second index also should be arranged alphabetically like:
[('animal', 'bear'),
 ('animal', 'duck'),
 ('plant', 'cactus'),
 ('vehicle', 'school bus'),
 ('vehicle', 'speed boat')]

The solution to this problem is to use sorted() function twice, but the tricky thing is that, we must sorted the by the second index inside the sorting of the first index:

c = sorted((sorted(things, key=lambda x: x[1])), key=lambda x:x[0])

where x[1] refers to the 2nd column of the array 'things'.

Wednesday, July 18, 2012

How do I install numpy without root right under Ubuntu

Today I tried to install numpy latest version 1.6.2 on my university computer, with Ubuntu 10.10


  • check the version of your numpy using ipython:
     import numpy
     numpy.__version__


  • download the latest numpy install package: tar -xvf numpy-1.6.2.tar.gz

-- to be continue soon

Thursday, July 12, 2012

nanoscale views: Graphene, part II

nanoscale views: Graphene, part II: One reason that graphene has comparatively remarkable conduction properties is its band structure, and in particular the idea that single-pa...

Monday, July 9, 2012

Good Quantum Number

Now we are going to review a basic concept, i.e. 'Good quantum number'.

From "http://theworldofsmall.blogspot.nl/2009/01/what-are-good-coordinates.html", I quote:

In classical mechanics, we can assign any number of variables to specify the state of a system. For example, for a free particle, its position, momentum, etc,. can be known and can be assigned simultaneously to specify the state of the free particle. But the story of quantum mechanics is different. If the position of a particle at some instant is correctly known, its momentum will be highly/maximally uncertain. This means, we can't assign both the position and momentum to specify the quantum mechanical state of the particle simultaneously. In this sense, the quantities (observables) which can be assigned simultaneously to a quantum system at any time to specify its state at that time are called the good quantum mumbers of the system. A set of good quantum numbers is also called a complete set of commuting observables (C.S.C.O.). These coordiantes commute each other, which means that their measurements can be made simultaneously.

From wikipedia:

In quantum mechanics, given a particular Hamiltonian H and an operator O with corresponding eigenvalues and eigenvectors given by O|q_j\rangle=q_j|q_j\rangle then the physical quantities q_j are said to be "good quantum numbers" if every eigenvector |q_j\rangle remains an eigenvector of O with the same eigenvalue as time evolves.
Hence, if: O|q_j\rangle=O\sum_k c_k(0) |e_k\rangle = q_j |q_j\rangle
then we require
O\sum_k c_k(0) \exp(-i e_k t/\hbar)\,|e_k\rangle=q_j\sum_k c_k(0) \exp(-i e_k t/\hbar)\,|e_k\rangle
for all eigenvectors |q_j\rangle in order to call q a good quantum number.
A necessary and sufficient condition for q to be good is that O commute with the Hamiltonian H. Proof:
Assume [O,\,H]=0. If |\psi_0\rangle is an eigenvector of O, then we have (by definition) that O |\psi_0\rangle=q_j | \psi_0\rangle, and so :
O|\psi_t\rangle=O\,T(t)\,|\psi_0\rangle
=O e^{-itH/\hbar}|\psi_0\rangle
= O \sum_{n=0}^{\infty} \frac{1}{n!} (-i H t/\hbar)^{n} |\psi_0\rangle
= \sum_{n=0}^{\infty} \frac{1}{n!} (-i H t/\hbar)^{n}  O |\psi_0\rangle
 =q_j |\psi_t\rangle
It can be said that a good classical analogue is that good quantum numbers are the equivalent of conserved quantities in classical mechanics, as their values do not change over time.In non-relativistic treatment,l and s are good quantum numbers but in relativistic quantum mechanics they are no longer good quantum numbers as L and S do not commute with H(in Dirac theory). J=L+S is a good quantum number in relativistic quantum mechanics as J commutes with H.
 

Thursday, July 5, 2012

This is the first Blog text file in my Google blogger. The aim of this blog is to keep record as much as possible the things that happens during my daily life, research and study, and both rational thinking, argumentation, or emotional feelings.

But among all these, the first import aim is of this blog is to serve as a manuscript of my study and research. I once have a Notebook which I write everything what I have done, what I have learned during the my research and study. However, I find that the paper based the notebook is not continent enough. Some time I need to keep tracking of some information I have written before. Since it is only organized by date, so I find it hard to searching the information. By using the blog here, I wish I can use different labels and classify each blog so that it could be easy for me to search information.

Right now, I have thought about several categories:

Research and study: daily/weekly report (mainly on summarized what I have learned today), tomorrow/next week's plan

Life's thinking: emotional thinking and expressing, rational argument, feeling about life

And on the other hand, these categories can also have different labels, such as: Linux tech, Mathematica tech, Research project Problems and solving, Courses problem set and solutions, Latex learning, Journal paper reading and summarized, Booking reading summarized, etc.