Minimize Spillage Program Update Note.
Author : Mohan Chen
Email : mohan@mail.ustc.edu.cn
Locate : LQCC

Na-bcc 29 kpoints use 15 pools and 15 processors.
--------- CLASS NAME--------------- NAME ----- TIME(sec) -- CALLS ----- AVG ----- PER%
!                                  total        1052.41         1   1.1e+03     1e+02%
!         Metropolis      move_various_t          1e+03         5   2.1e+02        98%
!         Metropolis       move_one_step          1e+03      2000      0.51        98%
!           PW_Basis      (*)pdate_psi1d        6.1e+02    176005    0.0034        57%
!           PW_Basis          calculateS        2.8e+02    352010    0.0008        27%
!           PW_Basis        update_psi3d          1e+02    352010    0.0003       9.9%
!           PW_Basis           (*)get_sk             25    398506   6.2e-05       2.3%
!         Orthogonal               start             11         4       2.7         1%
!           PW_Basis       calculate_Jlq            9.8     45056   0.00022      0.93%
!           Spillage            TableOne            7.7         1       7.7      0.73%
!           PW_Basis     calculate_psi3d           0.32        90    0.0036      0.03%
!           PW_Basis     calculate_psi1d           0.23        45    0.0051     0.022%
!           ReadData            OverlapQ           0.11         1      0.11      0.01%
--------------------------------------------------------------------------------------
Start  Time : Sat Jun 19 00:00:06 2010
Finish Time : Sat Jun 19 00:24:25 2010
Problem:
1. Need to improve update_psi1d.
2. Sk,gk can be chosen to calculated once and stored.
which can be 'tested'
3. Calculate_Jlq can be improved.
4. Memory calculation should be available.
5. Output time after each level.
6. More detail output information for large system.
7. Efficient restart mode.
8. Chosen bands information should be output correctly.

VERSION 046
11-07-22 Output ORBITAL_PW_GK.dat in pw_basis.cpp.
11-07-22 Update some output information, the order of plane wave in MCSP
is the same as in ESP.

VERSION 045
11-02-21 Add new functions in read_INPUT.cpp, can read INPUTs now.
11-02-21 Add new variables in tools.cpp 

VERSION 044
10-08-06 Mohan Fix bug in SpillageStep, mz.lmax_type[it] -> LMAXALL,
because when using l < LMAXALL, we hope the program can go on running.
10-09-27 Mohan Fix bug in ReadData.cpp, the CARPOSX,Y,Z is useless.
10-10-15 Add a new parameter: START_KIN_TEM
11-02-19 Fix a bug, the id of elements should be numbrs, and the number
must > 0.

VERSION 043
10-07-21 Fix a bug in SpillageStep, about calculation of iw00.
10-07-22 Fix another bug during set iw00 in SpillageStep,
LMAXALL -> mz.lmax_type[it].

VERSION 042
10-07-12 Reorder tools.h 
10-07-13 Fix a bug, the Mkb and Mkb_used must be zero at first.
10-07-13 Fix a bug in out_orbital. the spillage in it is consistent with
spillage value in get_spillage now.

VERSION 041
10-06-18 Add some function in memory calculation.
10-06-18 Fix a bug in get_sk.
10-06-27 Using openmpi instead of mpich-1.2.7.
10-06-27 Fix a bug in MPI_Recv, the MPI_Status *ierror -> MPI_Status ierror.
10-06-27 Fix a bug in main.cpp, the MPI_Finalize should be added.

VERSION 040
10-06-18 Update timer.
10-06-18 Speed up orthogonal in Sq1q2 largely.
10-06-18 Add Way2iw in PW.
10-06-18 Add calculate_Jlq in PW.
10-06-18 Add calculate_Jlq_phi in PW.
10-06-18 Orthogonal is avalible for PW in both versions.
10-06-18 A small update about 'update_psi1d'.
10-06-18 Add unstable in SpillageStep.
10-06-18 Add reduce_int_all in parallel_reduce.
10-06-18 Refix the bug in spillagestep, about Mk and upbound.
10-06-18 Fix a bug in Out_Orbtial, about output spillage information.
10-06-18 Fix a 'very' serious bug in SpillageStep.
origin : Mk > spillage0 is not promised by every k point,
this is correct. Because spillage0 is also an average value
by sum_{ik,ib}. So I changed it to fill > spillage0.
I hope this is the final correct form!
10-06-18 Add parallel in Out_Orbital.
10-06-18 Delete two parallel about 'bcast c4' and 'unstable'.

VERSION 039
10-06-17 Change ylm to ylm[NKS], optimize speed.
10-06-17 Fix a bug in ReadData about USEPW.
10-06-17 Fix two bug in pw_basis::get_GVectors.
10-06-17 Fix a bug in ReadData about bcast.
10-06-17 KPAR is not readable in series version.
10-06-17 Add calculation of ig1, ig2, ig3 in pw_basic.
10-06-17 Add NMAXUSED and CALSPI in tools.
10-06-17 Add LMAXUSED. 
10-06-17 Fix a bug in series version, the CARKX,Y,Z.
10-06-17 Structure factor not needed to update unless
it or ia changed.
10-06-17 Add && istep==0 condition in Metropolis.
10-06-17 Fix a serious bug in init_QS_matrix, calculate_psi1d
and calculate_psi3d must consistent in it.

VERSION 038
10-06-14 Add cartesian k point coordiantes.
10-06-14 Add LAT0 and bcast it.
10-06-15 Add new pw_basis class.
10-06-15 Add new heapsort file.
10-06-15 Add ylm_real file.
10-06-15 Add inverse_matrix file.
10-06-16 Fix a bug, bcast CARPOSX,Y,Z.
10-06-16 Distribut plane wave using my own algorithm.
10-06-16 dekete ggpsi in pw_basis.
10-06-16 Add m in wayd in spillagestep.
10-06-16 Bcast C4 after each trial_C4.
10-06-16 Change psi3d to 3 dimension (ik,iw,ig)
10-06-16 Add make note operation.
10-06-17 Available for plwane wave calculation.
10-06-17 Orthogonal not avalable yet.
10-06-17 Speed not optimized yet.

VERSION 037
10-06-14 Bcast S data available.
10-06-14 Bcast parameters in Metropolis.
10-06-14 Bcast parameters in Coefficients.
10-06-14 Bcast parameters in MultiZeta.
10-06-14 Bcast weight.
10-06-14 K points parallel available!
10-06-14 If I delete Sq, use plane wave instead.

VERSION 036
10-06-14 Add mpi information in main.cpp
10-06-14 Fix a bug about KPAR bcast.
10-06-14 Bcast Q data available.

VERSION 035
10-06-12 Delete Damping.cpp.
10-06-12 Add common.h
10-06-12 Add parallel_kpoints class.
10-06-12 Add parallel_common namespace.
10-06-12 Add parallel_reduce namespace.
10-06-12 Add parallel_global namespace.
10-06-12 Add pw_complement.
10-06-12 Add make s and make p in Makefile. 
10-06-12 Add parallel_kpoints as a global class.
10-06-12 Add QUIT in tools.
10-06-12 Parallel enviroment is available.
10-06-12 First part of read_INPUT is done.
10-06-12 Add DESTROY().
10-06-12 Add LATVEC, NA, LABEL, ....
10-06-12 Add matrix3 and vector3.
10-06-12 Delete inputs class.
10-06-12 not available yet.

VERSION 034
10-05-02~10-06-12 Tests are good.
10-06-14 Fix a bug in SpillageStep, judge the upbound, the
condition should be weight * Mkb > upbound.

VERSION 033
10-05-02 Change the 'get_value' in SpillageValue to a more suitable name:
'cal_defined_value'. 
10-05-02 Add BANDS_CONTROL, BANDS_START, BANDS_END 3 variables in tools.
and used in get_spillage in SpillageStep.
10-05-02 Add Mkb and Mk in Step_Data.
10-05-02 Add ilevel in Multizeta.
10-05-02 Add output Mkb information in Out_Orbital.
10-05-02 Add Mkb_used in Step_Data.
10-05-02 Record Mkb in Metropolis.

VERSION 032
10-04-29 A bug fixed in SpillageStep, the S inverse matrix value can reach as
large as 1.0*e14, an the effective number in double precision is only 15. So 
this may artificially number in S inverse matrix which can cause the multiplication
between Q and S^{-1} incorrect. I ignore the incorrect value introduced by 
some sets of coefficients.

VERSION 031
10-04-19 Add 'zero' point in ouput psi.
10-04-21 Small modification of output information.

VERSION 030
10-04-17 The efficience of 'norm_c4' be improved.
10-04-17 The recalculation should start from file "ORBITAL_RESUTSL.txt".
10-04-17 Delete file ORBITAL_SAVE, replace ORBITAL_RESULTS.txt instead of ORBITAL.out.restart.
10-04-18 Change back c4 to c4^2 to calculate kinetic energy.

VERSION 029
10-04-14 Speedup 'get_ecut' about 30%. (can still be imptoved if we divide Psi)
10-04-14 Add a parameter 'OPTIMIZE_METHOD'.
10-04-15 Fix a bug, about the output mesh don't include the r=0 point.
10-04-16 Add PI in tools.cpp.
10-04-16 The kinetic energy is updated in Rydberg unit.
10-04-16 The kinetic energy is now |C|q^2*PI/rcut.
10-04-17 The kinetic energy have two equal formuals.
10-04-17 Fix a bug in norm_c4, the g(r) must be multiplied.

VERSION 028
10-04-13 Add more ecut judgement in 'Plot_Psi'.
10-04-14 Add a new method to minimize kinetic energy, calculate the Ecut.

VERSION 027
10-04-12 Output logmesh oritals for plot and for used.
10-04-12 Seperate the dr to minimize kinetic energy and ploting, add KINETIC_DR in tools.
10-04-13 Fix a bug about the normalization of logmesh in Plot_Psi.
10-04-13 Add 'establish ecut' in 'Plot_Psi' to establish the cutoff of each orbital.

VERSION 026
10-04-08 Delete write_c4, read_c4, write_c4_init in Coefficients class.
10-04-08 Rearrange the files, add src_tools dir and src_spillage dir.
10-04-11 Output the average spillage value.
10-04-11 Output C4 after each step.

VERSION 025
09-12-27 Divide output ORBITAL.MCSP to different element part.

VERSION 024
09-11-06 Fix a bug in Metropolis, about recalculate kinetic energy temperature.

VERSION 023
09-10-10 Add two-step kinetical energy minimization.
09-10-15 Update Metropolis.cpp.
09-10-16 Add accept_rate in Metropolis.cpp
09-10-31 Add auto adjust the accept_rate.
09-10-31 Add KINETIC_MAX in tools.h, which control the energy of orbital.

VERSION 022
09-09-26 Output COEFFICIENTS, PSI, PSI2 file.
09-09-26 Output oscillation, kinetic energy.

VERSION 021
09-09-11 Add Psi_Second class.

VERSION 020
09-08-27 Move ORBITAL.out filename to ORBITAL.out.txt
09-08-27 Modify Metropolis, 'ne > BLOCK_NE ' to 'ne >= BLOCK_NE'
09-08-27 Add RESTART in tools.h
09-08-27 Add state(string) in SpillageStep::TypeInformation.
09-08-28 Fix a bug in Coefficients.cpp, output_c4_name must be initialized in constructor.
09-08-28 Remove restart_c4 in read_INPUT.
09-08-28 Add class Damping in file Damping.cpp.
09-08-28 Add <FINISH> in Metropolis.
09-08-28 Add <SCHEME_VALUE> in tools.h

VERSION 019
09-08-20 Update SpillageValue::get_value, providing 3 schemes now.
09-08-24 Fix a bug in input, if the file is not exit, warning and quit.
09-08-26 Add BLOCK_NE as global.
09-08-26 Add a parameter in SCAN_BEGIN function in tools.h

VERSION 018
09-07-23 Abandon input file: "INPUTs", instead we read in information from first "spillage.dat" file.
09-07-23 Add in INPUT::read_PW_QS, to read "INPUTs" information.
09-07-23 Delete "read_site" in read_INPUT.cpp
09-07-24 Change all energy units from "Hartree" to Rydberg.
09-07-24 Fix a bug in Calculate_C4, lmax<3 change to lmax<5

VERSION 017
09-07-12 Add average input in <OPTIMIZE>
09-07-12 Delete nchi in Coefficients, no used.
09-07-12 Delete 'm' member variable in way2Data, no used, furthermore, hard to define whene use average orbital.
09-07-12 Add average parameter in way2Data.
09-07-12 Add new function in SpillageStep.
09-07-12 Available for average orbital.

VERSION 016
09-05-23 Add reset_temperature in Metropolis
09-05-23 Add l_nchi in MultiZeta
09-06-09 Add value_each_step in SpillageValue.
09-06-09 Add nstep in read_INPUT file.
09-06-09 Output spillage value of each step in the output file.
09-06-14 Output "ORBITAL.MCSP" in Plot_Psi.cpp
09-06-14 Fix a bug in SpillageStep.cpp, assert(iw==nwfc)

VERSION 015***
09-05-22 Reconstruction of all program.

VERSION 014
09-05-13 Add two 'na' member and 'get_na()' function in read_INPUTs,
09-05-13 Input 'na' in CalculateSpillage Constructor
09-05-13 Fix a bug in allocate_index in CalculateSpillage, the iw2iw dimension must equal nwfc2 
09-05-14 Add WARNING_QUIT function in tools.cpp
09-05-14 Change name read_plot_c4 and read_cal_c4 in read_stuff
09-05-14 Delete iw_index in CalculateSpilalge, no used.
09-05-14 The sinv readin function return!

VERSION 013
09-05-02 Add spillage0 in ReadData class
09-05-02 Can correctly do double_zeta operation.
0.159% for GaAs(optimize separate) not much improved use 33Jl

VERSION 012
09-05-01 Add iw2iw in CalculateSpillage
09-05-01 Control write_c4 in CalculateSpillage
09-05-01 Add multi_zeta parameter in ReadData
09-05-01 Add test in some class
09-05-01 Available for combine double-zeta calculation.
0.21% for GaAs SZ
0.12% for GaAs DZ(optimized together)

VERSION 011
09-04-29 Add orthogonal flag in INPUT file.
09-04-29 Add Class Multi_zeta.
09-04-29 Add Qreal_readin and Qimag_readin in ReadData.
09-04-29 Available for seperate double-zeta calculation. But find a problem: The new set of bloch wave functions are not orthogonal.

VERSION 010
09-04-27 Open the gate for multi_zeta programming.

VERSION 009
09-04-27 Add class 'read_stuff', reduce the main program.
09-04-27 Add class 'MultiZeta', reduce the main program.

VERSION 008
09-04-26 Use ibz_kpoint to calculate spillage.
36000 steps/hour
09-04-26 Use new Lapack routine to calculate Inverse_Matrix
57000 steps/hour

VERSION 007
09-04-26 Add calss Inverse_Matrix
09-04-26 Accelarate using_zheev 
4000 steps/hour

VERSION 006
09-04-26 Use the hermit symmetry of S matrix
3400 steps/hour

VERSION 005
09-04-19 Unit, 
09-04-19 Can available for more than one stucture. 
09-04-19 Reduce goback time.
2400 steps/hour

VERSION 004
09-04-18 Can plot wave functions.
09-04-18 Speedup S update routine.

VERSION 003
09-04-17 Speedup Q update routine.

VERSION 002
09-04 Available for calculate spillage without plane wave basis.
