add the self-consistent loop code in the main program
fix a bug in definition of W, Gam, Pi and Chi about space variables