Finite Square Potential Well

wrote a simple script to compute eigenvalues of a finite square potential well. Download at this page

Setting number of threads using OpenMP

We can set either in the code or through environment variable. If we use environtment variable, we simply type

$ setenv OMP_NUM_THREADS 6

where 6 is the number of cpus we want to use.

Custom Header/footer in Latex

Use “fancyhdr” package in latex to flexibly design your header and footer. Read the manual at:

http://www.ctan.org/tex-archive/macros/latex/contrib/fancyhdr/fancyhdr.pdf

Nice bibliographic tool for researchers

I found Zotero as a nice and easy to use bibliographic tool, it is integrated with firefox browser, and runs in a browser. To add a bibliographic, you simply click the icon at the address bar. Easy to use.

http://www.zotero.org/

Non-equilibrium Green’s Function (NEGF) Calculation for Optical Absorption

Below is the slide on the calculation of inter-subband optical transition using NEGF.

and the paper can be found here:

Kubuntu Jaunty 9.04 Hangs desktop not responding

After I upgraded to Kubuntu Jaunty, I experienced a random hangs or crash, I can move my mouse, but nothing respond if I click. It seems to be the problem of the intel driver. I followed the instruction given here, and adding UXA in xorg.conf helps to solve my problem:
http://ubuntuforums.org/showthread.php?p=7293212#post7293212

undefined reference to `vtable for

I got this error when I compile a class:
undefined reference to `vtable for Device’

it turns out that GCC requires every virtual function to be defined, so I need to add an inline {} just to satisfy this.

virtual void setGridSpc(double a){};

instead of

virtual void setGridSpc(double a);

Maintaining C++ Codes

Some Ground rules:
1. Keep class data members private.

2. About global name space:
- Avoid data with external linkage at file scope: put all global variables in a structure, class, namespace, etc. This is to avoid name collison.
- Avoid free functions at file scope in .h files, avoid free functions with external linkage in .c files.
- Avoid enumerations, typedefs, and constants at file scope in .h files.
- Avoid using preprocessor macros in .h files, except as include guards.
- Only classes, structures, unions, free operator functions should be declared at file scope in a .h file; only classes, structures, unions, and inline functions should be defined at file scope in a .h file.

3. Place a unique and predictable include guard around the contents of each header file.

4. Place a redundant include guard around each preprocessor include directive in every header file.

5. Documentation the interfaces so that they are usable by others; have at least one other developer review each interface.

6. Use a consistent method to highlight class data member, const, statics. E.g.  adding a prefix d_ to class data members, or s_ for static data, ALL CAPS for const.

7. Don’t use “using namespace” directive in header files. It forfeit the purpose of having namespaces.

taken from: Large Scale C++ Software Design by John Lakos, 1996. Thinking in C++, 2nd Edition.

Global Constants in C++

Declaring the global constants can polute the names available and create conflicts as the project grow larger. One solution is to declare it using a namespace.

globalconst.h

namespace GlobalConst{

const double PI=3.14;

};

and in your file, simply use

GlobalConst::PI

UPDATE: I have corrected the code, thanks

cannot reintegrate branch

I created a branch from another branch, and after I am ready to merge, I encounter this problem:

$ cd photon-branch; svn update

$ svn merge –reintegrate https://nanoes.svn.sourceforge.net/svnroot/nanoes/branches/photon-recursive/
svn: Cannot reintegrate from ‘https://nanoes.svn.sourceforge.net/svnroot/nanoes/branches/photon-recursive’ yet:
Some revisions have been merged under it that have not been merged into the reintegration target; merge them first, then retry.

It turns out to be a problem in subversion 1.5. I found a blog that speaks about this problem. And then, in one of the forum, someone gave a clear explanation on how to do it. So basically what I need to do is to go back to my other branch, in this case “photon-recursive”, and delete the merge info of the files except the “.” merge info.

$ cd photon-recursive

$ svn propget svn:merge info –depth=infinity

you will many list, the term before “-” is the file. You will find one for “.” and maybe some other files. Mine is like this:

. – /branches/photon-branch:115-181
src/parallel – /branches/photon-branch/src/parallel:115-181
/trunk/src/parallel:2
src/globalconst.h – /branches/photon-branch/src/globalconst.h:115-181
/trunk/src/globalconst.h:2-3
src/parallel/deviceinfo.h – /branches/photon-branch/src/parallel/deviceinfo.h:11
5-181
/trunk/src/parallel/deviceinfo.h:2-11
src/negf.cpp – /branches/photon-branch/src/negf.cpp:115-181
/trunk/src/negf.cpp:2-3
src/output – /branches/photon-branch/src/output:115-181
/trunk/src/output:2-4
src/deviceinfo.h – /branches/photon-branch/src/deviceinfo.h:115-181
/trunk/src/deviceinfo.h:2-11
src/main.cpp – /branches/photon-branch/src/main.cpp:115-181
/trunk/src/main.cpp:2-3
src/negf.h – /branches/photon-branch/src/negf.h:115-181
/trunk/src/negf.h:2-3
src/solvebias.cpp – /branches/photon-branch/src/solvebias.cpp:115-181
/trunk/src/solvebias.cpp:2-3
src/devrtd.cpp – /branches/photon-branch/src/devrtd.cpp:115-181
/trunk/src/devrtd.cpp:2-3
src/poisson.cpp – /branches/photon-branch/src/poisson.cpp:115-181
/trunk/src/poisson.cpp:2-3
src/itppmath.h – /branches/photon-branch/src/itppmath.h:115-181
/trunk/src/itppmath.h:2-3
src/solvebias.h – /branches/photon-branch/src/solvebias.h:115-181
/trunk/src/solvebias.h:2-3
src/Makefile – /branches/photon-branch/src/Makefile:115-181
/trunk/src/Makefile:2-3
src/finvhalff77h.f – /branches/photon-branch/src/finvhalff77h.f:115-181
/trunk/src/finvhalff77h.f:2-3
src/DevRTD.h – /branches/photon-branch/src/DevRTD.h:115-181
/trunk/src/DevRTD.h:2-3
src/finvhalf.cpp – /branches/photon-branch/src/finvhalf.cpp:115-181
/trunk/src/finvhalf.cpp:2-3
src/output.log – /branches/photon-branch/src/output.log:115-181
/trunk/src/output.log:2-4
src/poisson.h – /branches/photon-branch/src/poisson.h:115-181
/trunk/src/poisson.h:2-3

So now what I need to do is to delete the merge info from all other files except the “.” (root). To do this :

$ svn propdel svn:merge info ./src/globalconst.h

$ svn propdel svn:mergeinfo ./src/parallel/deviceinfo.h

Once it is done, it will only leave the merge info for “.”

$ svn propget svn:mergeinfo –depth=infinity
. – /branches/photon-branch:115-181

and we can commit

$ svn commit -m “Removed bogus merge info.”

After this, I went back to the main branch (in my case photon-branch) and do a merge –reintegrate. it turns out to solve the problem :)