From 36f810cfd5d0338a7c53066c13f6456f15bbb69e Mon Sep 17 00:00:00 2001
From: YuLiu
Date: Sat, 3 Jul 2021 11:46:10 +0800
Subject: [PATCH 1/2] Move cal_nelec to charge.cpp
---
ABACUS.develop/source/input_conv.cpp | 2 +-
.../source/module_cell/unitcell_pseudo.cpp | 5 +-
.../source/module_cell/unitcell_pseudo.h | 4 +-
ABACUS.develop/source/run_lcao.cpp | 3 +
ABACUS.develop/source/run_pw.cpp | 3 +
ABACUS.develop/source/src_io/berryphase.cpp | 2 +-
.../source/src_io/epsilon0_vasp.cpp | 2 +-
.../source/src_io/istate_charge.cpp | 4 +-
.../source/src_io/istate_envelope.cpp | 4 +-
ABACUS.develop/source/src_io/optical.cpp | 2 +-
.../source/src_io/read_cell_pseudopots.cpp | 2 +-
ABACUS.develop/source/src_pw/charge.cpp | 114 +++++++++++++++++-
ABACUS.develop/source/src_pw/charge.h | 4 +
.../source/src_pw/charge_broyden.cpp | 4 +-
ABACUS.develop/source/src_pw/electrons.cpp | 4 +-
ABACUS.develop/source/src_pw/magnetism.cpp | 12 +-
ABACUS.develop/source/src_pw/occupy.cpp | 6 +-
ABACUS.develop/source/src_pw/sto_elec.cpp | 10 +-
ABACUS.develop/source/src_pw/sto_iter.cpp | 6 +-
.../source/src_pw/threshold_elec.cpp | 6 +-
.../tests/127_PW_15_PK_AF/result.ref | 6 +-
.../tests/150_PW_15_CR_VDW3/result.ref | 2 +-
22 files changed, 163 insertions(+), 44 deletions(-)
diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp
index 1c83346ac0..74fdd9979f 100644
--- a/ABACUS.develop/source/input_conv.cpp
+++ b/ABACUS.develop/source/input_conv.cpp
@@ -37,7 +37,7 @@ void Input_Conv::Convert(void)
global_pseudo_type = INPUT.pseudo_type;
ucell.latName = INPUT.latname;
ucell.ntype = INPUT.ntype;
- ucell.nelec = INPUT.nelec;
+ CHR.nelec = INPUT.nelec;
// ucell.lmaxmax = INPUT.lmaxmax;
NBANDS = INPUT.nbands;
diff --git a/ABACUS.develop/source/module_cell/unitcell_pseudo.cpp b/ABACUS.develop/source/module_cell/unitcell_pseudo.cpp
index b366c47b9c..5dadb02f07 100644
--- a/ABACUS.develop/source/module_cell/unitcell_pseudo.cpp
+++ b/ABACUS.develop/source/module_cell/unitcell_pseudo.cpp
@@ -287,7 +287,7 @@ void UnitCell_pseudo::setup_cell(
this->cal_nwfc();
// setup NBANDS
- this->cal_nelec();
+ //this->cal_nelec();
this->cal_meshx();
@@ -307,6 +307,7 @@ void UnitCell_pseudo::setup_cell(
// calculate total number of electrons (nelec) and default
// number of bands (NBANDS).
//=========================================================
+/*
#include "../src_pw/occupy.h"
void UnitCell_pseudo::cal_nelec(void)
{
@@ -408,7 +409,7 @@ void UnitCell_pseudo::cal_nelec(void)
OUT(ofs_running,"NBANDS",NBANDS);
return;
-}
+}*/
//===========================================
// calculate the total number of local basis
diff --git a/ABACUS.develop/source/module_cell/unitcell_pseudo.h b/ABACUS.develop/source/module_cell/unitcell_pseudo.h
index c06de38fe3..6c9ec77d98 100644
--- a/ABACUS.develop/source/module_cell/unitcell_pseudo.h
+++ b/ABACUS.develop/source/module_cell/unitcell_pseudo.h
@@ -23,7 +23,7 @@ class UnitCell_pseudo : public UnitCell
int nmax;
int nmax_total;//mohan add 2009-09-10
int lmax_ppwf;
- double nelec;
+ //double nelec;
public: // member functions
UnitCell_pseudo();
@@ -49,7 +49,7 @@ class UnitCell_pseudo : public UnitCell
// cal_meshx : calculate max number of mesh points in pp file
//================================================================
void cal_nwfc();
- void cal_nelec();
+ //void cal_nelec();
void cal_meshx();
void cal_natomwfc();
void print_unitcell_pseudo(const string &fn);
diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp
index a04bfb415a..c1fdc6dd1a 100644
--- a/ABACUS.develop/source/run_lcao.cpp
+++ b/ABACUS.develop/source/run_lcao.cpp
@@ -24,6 +24,9 @@ void Run_lcao::lcao_line(void)
// cell relaxation. b) put NLOCAL and NBANDS as input parameters
ucell.setup_cell( global_pseudo_dir, out, global_atom_card, ofs_running);
+ // setup NBANDS
+ CHR.cal_nelec(); //Yu Liu move here 2021-07-03
+
// mohan add 2010-09-06
// Yu Liu move here 2021-06-27
// because the number of element type
diff --git a/ABACUS.develop/source/run_pw.cpp b/ABACUS.develop/source/run_pw.cpp
index 7742f0157c..7f8fd90c28 100644
--- a/ABACUS.develop/source/run_pw.cpp
+++ b/ABACUS.develop/source/run_pw.cpp
@@ -25,6 +25,9 @@ void Run_pw::plane_wave_line(void)
ucell.setup_cell( global_pseudo_dir, out, global_atom_card, ofs_running);
//ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running, NLOCAL, NBANDS);
+ // setup NBANDS
+ CHR.cal_nelec(); //Yu Liu move here 2021-07-03
+
// mohan add 2010-09-06
// Yu Liu move here 2021-06-27
// because the number of element type
diff --git a/ABACUS.develop/source/src_io/berryphase.cpp b/ABACUS.develop/source/src_io/berryphase.cpp
index e2d77f22ba..de0fd6bd88 100644
--- a/ABACUS.develop/source/src_io/berryphase.cpp
+++ b/ABACUS.develop/source/src_io/berryphase.cpp
@@ -14,7 +14,7 @@ berryphase::~berryphase()
void berryphase::get_occupation_bands()
{
- double occupied_bands = static_cast(ucell.nelec/DEGSPIN);
+ double occupied_bands = static_cast(CHR.nelec/DEGSPIN);
if( (occupied_bands - std::floor(occupied_bands)) > 0.0 )
{
occupied_bands = std::floor(occupied_bands) + 1.0;
diff --git a/ABACUS.develop/source/src_io/epsilon0_vasp.cpp b/ABACUS.develop/source/src_io/epsilon0_vasp.cpp
index ca5edc99ac..95d7940ef2 100644
--- a/ABACUS.develop/source/src_io/epsilon0_vasp.cpp
+++ b/ABACUS.develop/source/src_io/epsilon0_vasp.cpp
@@ -37,7 +37,7 @@ void Epsilon0_vasp::cal_epsilon0()
cout << "nomega = "<(ucell.nelec/DEGSPIN);
+ double occupied_bands = static_cast(CHR.nelec/DEGSPIN);
if( (occupied_bands - std::floor(occupied_bands)) > 0.0 )
{
occupied_bands = std::floor(occupied_bands) + 1.0;
diff --git a/ABACUS.develop/source/src_io/istate_charge.cpp b/ABACUS.develop/source/src_io/istate_charge.cpp
index 5e6d1c2a80..1fa6af9007 100644
--- a/ABACUS.develop/source/src_io/istate_charge.cpp
+++ b/ABACUS.develop/source/src_io/istate_charge.cpp
@@ -39,13 +39,13 @@ void IState_Charge::begin(void)
// (1.2) read in LOWF_GAMMA.dat
OUT(ofs_running,"LOWF.allocate_flag",LOWF.get_allocate_flag());
- cout << " number of electrons = " << ucell.nelec << endl;
+ cout << " number of electrons = " << CHR.nelec << endl;
// mohan update 2011-03-21
// if ucell is odd, it's correct,
// if ucell is even, it's also correct.
// +1.0e-8 in case like (2.999999999+1)/2
- fermi_band = static_cast( (ucell.nelec+1)/2 + 1.0e-8 ) ;
+ fermi_band = static_cast( (CHR.nelec+1)/2 + 1.0e-8 ) ;
cout << " number of occupied bands = " << fermi_band << endl;
if(mode == 1)
diff --git a/ABACUS.develop/source/src_io/istate_envelope.cpp b/ABACUS.develop/source/src_io/istate_envelope.cpp
index b156770f04..0dc95d192c 100644
--- a/ABACUS.develop/source/src_io/istate_envelope.cpp
+++ b/ABACUS.develop/source/src_io/istate_envelope.cpp
@@ -31,11 +31,11 @@ void IState_Envelope::begin(void)
// if ucell is odd, it's correct,
// if ucell is even, it's also correct.
// +1.0e-8 in case like (2.999999999+1)/2
- int fermi_band = static_cast( (ucell.nelec+1)/2 + 1.0e-8 ) ;
+ int fermi_band = static_cast( (CHR.nelec+1)/2 + 1.0e-8 ) ;
int bands_below = NBANDS_ISTATE;
int bands_above = NBANDS_ISTATE;
- cout << " number of electrons = " << ucell.nelec << endl;
+ cout << " number of electrons = " << CHR.nelec << endl;
cout << " number of occupied bands = " << fermi_band << endl;
cout << " plot band decomposed charge density below fermi surface with "
<< bands_below << " bands." << endl;
diff --git a/ABACUS.develop/source/src_io/optical.cpp b/ABACUS.develop/source/src_io/optical.cpp
index 810125c6a3..fa59e3c1df 100644
--- a/ABACUS.develop/source/src_io/optical.cpp
+++ b/ABACUS.develop/source/src_io/optical.cpp
@@ -57,7 +57,7 @@ void Optical::cal_epsilon2(const int &nbands)
double range = maxe - mine;
int np = int(range / de) + 1;
- int n_occ = static_cast( (ucell.nelec+1)/2 + 1.0e-8 );
+ int n_occ = static_cast( (CHR.nelec+1)/2 + 1.0e-8 );
cout << " n_occ = " << n_occ << endl;
cout << " nbands = " << opt_nbands << endl;
diff --git a/ABACUS.develop/source/src_io/read_cell_pseudopots.cpp b/ABACUS.develop/source/src_io/read_cell_pseudopots.cpp
index c9e5266eed..83585246c1 100644
--- a/ABACUS.develop/source/src_io/read_cell_pseudopots.cpp
+++ b/ABACUS.develop/source/src_io/read_cell_pseudopots.cpp
@@ -133,7 +133,7 @@ void UnitCell_pseudo::bcast_unitcell_pseudo(void)
Parallel_Common::bcast_int( natomwfc );
Parallel_Common::bcast_int( lmax );
Parallel_Common::bcast_int( lmax_ppwf );
- Parallel_Common::bcast_double( nelec );
+ Parallel_Common::bcast_double( CHR.nelec );
bcast_unitcell();
}
diff --git a/ABACUS.develop/source/src_pw/charge.cpp b/ABACUS.develop/source/src_pw/charge.cpp
index 319c434c7a..dd3aa415d3 100644
--- a/ABACUS.develop/source/src_pw/charge.cpp
+++ b/ABACUS.develop/source/src_pw/charge.cpp
@@ -150,7 +150,7 @@ void Charge::renormalize_rho(void)
const double sr = this->sum_rho();
ofs_warning << setprecision(15);
OUT(ofs_warning,"charge before normalized",sr);
- const double normalize_factor = ucell.nelec / sr;
+ const double normalize_factor = nelec / sr;
for(int is=0; isallocate_rho_final_scf = true;
return;
}
+
+
+//=========================================================
+// calculate total number of electrons (nelec) and default
+// number of bands (NBANDS).
+//=========================================================
+#include "occupy.h"
+void Charge::cal_nelec(void)
+{
+ TITLE("UnitCell_pseudo","cal_nelec");
+ //=======================================================
+ // calculate the total number of electrons in the system
+ // if nelec <>0; use input number (setup.f90)
+ //=======================================================
+
+ ofs_running << "\n SETUP THE ELECTRONS NUMBER" << endl;
+
+ if (nelec == 0)
+ {
+ for (int it = 0; it < ucell.ntype;it++)
+ {
+ stringstream ss1, ss2;
+ ss1 << "electron number of element " << ucell.atoms[it].label;
+ const int nelec_it = ucell.atoms[it].zv * ucell.atoms[it].na;
+ nelec += nelec_it;
+ ss2 << "total electron number of element " << ucell.atoms[it].label;
+
+ OUT(ofs_running,ss1.str(),ucell.atoms[it].zv);
+ OUT(ofs_running,ss2.str(),nelec_it);
+ }
+ }
+
+ //OUT(ofs_running,"Total nelec",nelec);
+
+ //=======================================
+ // calculate number of bands (setup.f90)
+ //=======================================
+ double occupied_bands = static_cast(nelec/DEGSPIN);
+
+ if( (occupied_bands - std::floor(occupied_bands)) > 0.0 )
+ {
+ occupied_bands = std::floor(occupied_bands) + 1.0; //mohan fix 2012-04-16
+ }
+
+ OUT(ofs_running,"occupied bands",occupied_bands);
+
+ // mohan add 2010-09-04
+ //cout << "nbands(ucell) = " < num. of occupied bands");
+ }
+ }
+
+ if ( CALCULATION!="scf-sto" && CALCULATION!="relax-sto" && CALCULATION!="md-sto" ) //qianrui 2021-2-20
+ {
+ if(NBANDS == 0)
+ {
+ if(NSPIN == 1)
+ {
+ int nbands1 = static_cast(occupied_bands) + 10;
+ int nbands2 = static_cast(1.2 * occupied_bands);
+ NBANDS = max(nbands1, nbands2);
+ }
+ else if (NSPIN ==2 || NSPIN == 4)
+ {
+ int nbands3 = nelec + 20;
+ int nbands4 = 1.2 * nelec;
+ NBANDS = max(nbands3, nbands4);
+ }
+ AUTO_SET("NBANDS",NBANDS);
+ }
+ //else if ( CALCULATION=="scf" || CALCULATION=="md" || CALCULATION=="relax") //pengfei 2014-10-13
+ else
+ {
+ if(NBANDS < occupied_bands) WARNING_QUIT("unitcell","Too few bands!");
+ if(NBANDS < mag.get_nelup() )
+ {
+ OUT(ofs_running,"nelup",mag.get_nelup());
+ WARNING_QUIT("unitcell","Too few spin up bands!");
+ }
+ if(NBANDS < mag.get_neldw() )
+ {
+ WARNING_QUIT("unitcell","Too few spin down bands!");
+ }
+ }
+ }
+
+ // mohan update 2021-02-19
+ // mohan add 2011-01-5
+ if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw")
+ {
+ if( NBANDS > NLOCAL )
+ {
+ WARNING_QUIT("UnitCell_pseudo::cal_nwfc","NLOCAL < NBANDS");
+ }
+ else
+ {
+ OUT(ofs_running,"NLOCAL",NLOCAL);
+ OUT(ofs_running,"NBANDS",NBANDS);
+ }
+ }
+
+ OUT(ofs_running,"NBANDS",NBANDS);
+ return;
+}
\ No newline at end of file
diff --git a/ABACUS.develop/source/src_pw/charge.h b/ABACUS.develop/source/src_pw/charge.h
index d9cf5ded6f..968f0363b8 100644
--- a/ABACUS.develop/source/src_pw/charge.h
+++ b/ABACUS.develop/source/src_pw/charge.h
@@ -17,6 +17,7 @@ class Charge
//==========================================================
// MEMBER VARIABLES :
+// NAME : total number of electrons
// NAME : rho (nspin,ncxyz), the charge density in real space
// NAME : rho_save (nspin,ncxyz), for charge mixing
// NAME : rhog, charge density in G space
@@ -25,6 +26,7 @@ class Charge
// NAME : rhog_core [ngm], the core charge in reciprocal space
//==========================================================
+ double nelec;
double** rho;
double** rho_save;
@@ -47,6 +49,8 @@ class Charge
void set_rho_core(const ComplexMatrix &structure_factor);
+ void cal_nelec(); //calculate total number of electrons YuLiu 2021-07-03
+
void sum_band(void);
void renormalize_rho(void);
diff --git a/ABACUS.develop/source/src_pw/charge_broyden.cpp b/ABACUS.develop/source/src_pw/charge_broyden.cpp
index f84e6b6ab9..035e4d11b1 100644
--- a/ABACUS.develop/source/src_pw/charge_broyden.cpp
+++ b/ABACUS.develop/source/src_pw/charge_broyden.cpp
@@ -117,11 +117,11 @@ void Charge_Broyden::mix_rho
}
Parallel_Reduce::reduce_double_pool( dr22 );
- assert( ucell.nelec != 0);
+ assert( nelec != 0);
assert( ucell.omega > 0);
assert( pw.ncxyz > 0);
dr22 *= ucell.omega / static_cast( pw.ncxyz );
- dr22 /= ucell.nelec;
+ dr22 /= nelec;
if(test_charge)ofs_running << " dr2 from real space grid is " << dr22 << endl;
// mohan add 2011-01-22
diff --git a/ABACUS.develop/source/src_pw/electrons.cpp b/ABACUS.develop/source/src_pw/electrons.cpp
index 38f9143832..32f93d3250 100644
--- a/ABACUS.develop/source/src_pw/electrons.cpp
+++ b/ABACUS.develop/source/src_pw/electrons.cpp
@@ -254,7 +254,7 @@ void Electrons::self_consistent(const int &istep)
// if 'dr2 < ETHR * nelec' happen,
// in other word, 'dr2 < diago_error'
// we update ETHR.
- diago_error = ETHR*std::max(1.0, ucell.nelec);
+ diago_error = ETHR*std::max(1.0, CHR.nelec);
}
// if converged is achieved, or the self-consistent error(dr2)
@@ -283,7 +283,7 @@ void Electrons::self_consistent(const int &istep)
// update ETHR.
ofs_running << " Origin ETHR = " << ETHR << endl;
- ETHR = 0.1 * dr2 / ucell.nelec;
+ ETHR = 0.1 * dr2 / CHR.nelec;
ofs_running << " New ETHR = " << ETHR << endl;
//goto first_iter_again;
goto scf_step;
diff --git a/ABACUS.develop/source/src_pw/magnetism.cpp b/ABACUS.develop/source/src_pw/magnetism.cpp
index d2c464ce33..0881826736 100644
--- a/ABACUS.develop/source/src_pw/magnetism.cpp
+++ b/ABACUS.develop/source/src_pw/magnetism.cpp
@@ -51,7 +51,7 @@ void Magnetism::compute_magnetization()
}
else
{
- OUT(ofs_running,"nelec",ucell.nelec);
+ OUT(ofs_running,"nelec",CHR.nelec);
}
// cout << "\n tot_mag = " << setprecision(6) << this->tot_magnetization << " Bohr mag/cell" << endl;
@@ -90,11 +90,11 @@ double Magnetism::get_nelup(void)
//===============================================================
// this type of electrons are used as "fixed" magnetization.
//===============================================================
- nelup = 0.5 * ucell.nelec + 0.5 * tot_magnetization;
+ nelup = 0.5 * CHR.nelec + 0.5 * tot_magnetization;
}
else
{
- nelup = 0.5 * ucell.nelec;
+ nelup = 0.5 * CHR.nelec;
}
return nelup;
@@ -104,7 +104,7 @@ double Magnetism::get_nelup(void)
// double nelup = 0.0;
// for(int i=0; iupdate_ethr(iter);
if(FINAL_SCF && iter==1)
{
- ETHR = 1.0e-4/ucell.nelec; //smaller ETHR than KS-DFT
+ ETHR = 1.0e-4/CHR.nelec; //smaller ETHR than KS-DFT
}
else
{
if (iter == 2)
{
- ETHR = 1.0e-4/ucell.nelec;
+ ETHR = 1.0e-4/CHR.nelec;
}
- ETHR = std::min( ETHR, 0.1*dr2/ std::max(1.0, ucell.nelec));
+ ETHR = std::min( ETHR, 0.1*dr2/ std::max(1.0, CHR.nelec));
}
@@ -229,7 +229,7 @@ void Stochastic_Elec::scf_stochastic(const int &istep)
// if 'dr2 < ETHR * nelec' happen,
// in other word, 'dr2 < diago_error'
// we update ETHR.
- diago_error = ETHR*std::max(1.0, ucell.nelec);
+ diago_error = ETHR*std::max(1.0, CHR.nelec);
}
// if converged is achieved, or the self-consistent error(dr2)
@@ -266,7 +266,7 @@ void Stochastic_Elec::scf_stochastic(const int &istep)
// update ETHR.
ofs_running << " Origin ETHR = " << ETHR << endl;
- ETHR = dr2 / ucell.nelec;
+ ETHR = dr2 / CHR.nelec;
ofs_running << " New ETHR = " << ETHR << endl;
// goto first_iter_again;
}
diff --git a/ABACUS.develop/source/src_pw/sto_iter.cpp b/ABACUS.develop/source/src_pw/sto_iter.cpp
index 750425d529..b4f2962c2b 100644
--- a/ABACUS.develop/source/src_pw/sto_iter.cpp
+++ b/ABACUS.develop/source/src_pw/sto_iter.cpp
@@ -25,7 +25,7 @@ void Stochastic_Iter::init(int &dim, int& chetype)
nchip = STO_WF.nchip;
stotype = STO_WF.stotype;
//wait for init
- targetne = ucell.nelec;
+ targetne = CHR.nelec;
stoche.init( dim, chetype );
stohchi.init();
stohchi.get_GRA_index();
@@ -153,13 +153,13 @@ void Stochastic_Iter::itermu(int &iter)
if(iter == 1)
{
dmu = 2;
- th_ne = 0.1 * DRHO2 * ucell.nelec;
+ th_ne = 0.1 * DRHO2 * CHR.nelec;
cout<<"th_ne "<
+ $
+ $
+ $
+ $
+ $
+)
+target_link_libraries(${ABACUS_BIN_NAME}
+ -lgfortran
+ -lm
+ ELPA::ELPA
+ FFTW3::FFTW3
+ ScaLAPACK::ScaLAPACK
+ BLAS::BLAS
+ MPI::MPI_CXX
+ OpenMP::OpenMP_CXX
+ Threads::Threads
+)
+
+install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${ABACUS_BIN_NAME}
+ TYPE BIN
+ DESTINATION ${CMAKE_INSTALL_BINDIR}
+ RENAME ${PROJECT_NAME}
+)
+
+set(ABACUS_TEST_DIR ${ABACUS_DIR}/tests)
+
+enable_testing()
+
+find_program(BASH bash)
+
+add_test(
+ NAME integrated_test
+ COMMAND ${BASH} Autotest.sh
+ WORKING_DIRECTORY ${ABACUS_TEST_DIR}
+)
diff --git a/ABACUS.develop/tests/Autotest.sh b/ABACUS.develop/tests/Autotest.sh
index c1848d3ad9..00ba19d5df 100755
--- a/ABACUS.develop/tests/Autotest.sh
+++ b/ABACUS.develop/tests/Autotest.sh
@@ -1,10 +1,33 @@
#!/bin/bash
+# ABACUS executable path
+abacus=ABACUS
+# number of cores
+np=2
# threshold with unit: eV
-threshold="0.0000001"
+threshold=0.0000001
+# check accuracy
+ca=8
+# regex of case name
+case="^[^#].*_PW_.*$"
+
+while getopts a:n:t:c:r: flag
+do
+ case "${flag}" in
+ a) abacus=${OPTARG};;
+ n) np=${OPTARG};;
+ t) threshold=${OPTARG};;
+ c) ca=${OPTARG};;
+ r) case=${OPTARG};;
+ esac
+done
echo "-----AUTO TESTS OF ABACUS ------"
-echo "test accuracy is $threshold eV."
+echo "ABACUS path: $abacus";
+echo "Number of cores: $np";
+echo "Test accuracy: $threshold eV."
+echo "Check accuaracy: $ca"
+echo "Test cases: $case"
echo "--------------------------------"
echo ""
@@ -38,13 +61,14 @@ check_out(){
#--------------------------------------------------
# calculated value
#--------------------------------------------------
- cal=`grep "$key" $outfile | awk '{printf "%.'$CA'f\n",$2}'`
+ cal=`grep "$key" $outfile | awk '{printf "%.'$ca'f\n",$2}'`
#--------------------------------------------------
# reference value
#--------------------------------------------------
- ref=`grep "$key" result.ref | awk '{printf "%.'$CA'f\n",$2}'`
+ ref=`grep "$key" result.ref | awk '{printf "%.'$ca'f\n",$2}'`
+
#--------------------------------------------------
# computed the deviation between the calculated
# and reference value
@@ -53,7 +77,7 @@ check_out(){
deviation1=`awk 'BEGIN {x='$ref';y='$cal';printf "%.'$CA'f\n",y-x}'`
if [ $key == "totaltimeref" ]; then
-# echo "time=$cal ref=$ref"
+ # echo "time=$cal ref=$ref"
break
fi
@@ -82,49 +106,32 @@ check_out(){
# the file name that contains all of the tests
#---------------------------------------------
-test -e general_info || echo "plese write the file list_of_tests"
-test -e general_info || exit 0
-which $ABACUS_PATH || echo "Error! ABACUS path was wrong!!"
-which $ABACUS_PATH || exit 0
-CA=`grep CHECKACCURACY general_info | awk '{printf $2}'`
-# NP=`grep NUMBEROFPROCESS general_info | awk '{printf $2}'`
-
-grep -w TESTDIR general_info | awk '{print $2}' > testdir.txt
-list=`grep list_of_tests general_info|sed -e 's/[^ ]* //'`
-if [ -z "$list" ]
-then
-#echo "do no thing"
-testdir=`cat testdir.txt`
-else
-#echo $list
-value_line=(` echo $list | head -n1 `)
-
-colume=`echo ${#value_line[@]}`
-for (( col=0 ; col<$colume ; col++ ));do
- value=`echo ${value_line[$col]}`
- grep $value testdir.txt > testdir.dat
- mv testdir.dat testdir.txt
-done
-testdir=`cat testdir.txt`
-fi
-rm testdir.txt
+test -e CASES || echo "Plese specify tests"
+test -e CASES || exit 0
+which $abacus || echo "Error! ABACUS path was wrong!!"
+which $abacus || exit 0
+
+testdir=`cat CASES | grep -E $case`
for dir in $testdir; do
-cd $dir
- echo "$dir ($NP cores)"
+ cd $dir
+ echo "$dir ($np cores)"
+ TIMEFORMAT='Time elapsed: %R seconds'
#parallel test
- mpirun -np $NP $ABACUS_PATH > log.txt
- test -d OUT.autotest || echo "Some errors happened in ABACUS!"
- test -d OUT.autotest || exit 0
-
- if test -z $1
- then
- ../tools/catch_properties.sh result.out
- check_out result.out
- else
- ../tools/catch_properties.sh result.ref
- fi
+ time {
+ mpirun -np $np $abacus > log.txt
+ test -d OUT.autotest || echo "Some errors happened in ABACUS!"
+ test -d OUT.autotest || exit 0
+
+ if test -z $1
+ then
+ ../tools/catch_properties.sh result.out
+ check_out result.out
+ else
+ ../tools/catch_properties.sh result.ref
+ fi
+ }
echo ""
-cd ../
+ cd ../
done
diff --git a/ABACUS.develop/tests/CASES b/ABACUS.develop/tests/CASES
new file mode 100644
index 0000000000..6c5bd144d9
--- /dev/null
+++ b/ABACUS.develop/tests/CASES
@@ -0,0 +1,67 @@
+101_PW_15_pseudopots
+101_PW_OU_pseudopots
+101_PW_VW_pseudopots
+101_PW_15_f_pseudopots
+101_PW_upf201_pseudopots
+# 102_PW_DA_davidson
+# 103_PW_15_CS_CF
+# 103_PW_OU_CS_CF
+# 103_PW_CF_CS_S1_smallg
+104_PW_AF_magnetic
+104_PW_FM_magnetic
+# 105_PW_FD_smearing
+105_PW_FX_smearing
+105_PW_M2_smearing
+# 105_PW_GA_smearing
+105_PW_MP_smearing
+105_PW_MV_smearing
+106_PW_BD_chargemixing
+106_PW_KK_chargemixing
+106_PW_PK_chargemixing
+106_PW_PL_chargemixing
+106_PW_PU_chargemixing
+107_PW_OB_outputbands
+# 107_PW_OD_outputdos
+108_PW_RE
+108_PW_RE_MB
+108_PW_RE_MG
+# 109_PW_CR
+110_PW_SY_symmetry
+111_PW_elec_add
+111_PW_elec_minus
+111_PW_S2_elec_add
+111_PW_S2_elec_minus
+# 107_PW_OB_outputdos
+# 114_PW_15_BD
+# 125_PW_15_PK_PU_AF
+# 127_PW_15_PK_AF
+# 133_PW_DJ_PK
+# 135_PW_15_PK
+# 140_PW_15_SO
+
+201_NO_KP_15_CF_CS_Si
+201_NO_KP_DJ_CF_CS_GaAs
+201_NO_KP_DJ_Si
+202_NO_KP_HP_hpseps
+204_NO_KP_FM
+204_NO_KP_AFM
+207_NO_KP_OB
+207_NO_KP_OD
+208_NO_KP_CF_RE
+208_NO_KP_CS_CR
+220_NO_KP_MD_NVErestart
+220_NO_KP_MD_NVTrestart
+220_NO_KP_MD_FIRE
+# 230_NO_KP_MD_TD
+240_NO_KP_15_SO
+
+301_NO_GO_15_CF_CS
+301_NO_GO_DJ_Si
+# 303_NO_GO_HP_15
+304_NO_GO_AF
+304_NO_GO_FM
+307_NO_GO_OH
+345_NO_GO_BS
+
+401_NP_KP_sp
+401_NP_KP_spd
diff --git a/ABACUS.develop/tests/README b/ABACUS.develop/tests/README
deleted file mode 100644
index 6a0494553b..0000000000
--- a/ABACUS.develop/tests/README
+++ /dev/null
@@ -1,72 +0,0 @@
-1, modify file general_info
-
-2, try this script for autotest:
-./Autotest.sh > check.txt
-
-3, if want to focus on No. xxx example, such as 101_PW_OU_PL:
-cd 101_PW_OU_PL
-./../run_debug.sh $parameter
-# you can choose $parameter among "" (empty), debug or ref
-# 'ref': generate result.ref file
-
-
-NOTES:
-****Purpose for this autotest package is:
-1, cover all functions and application scenarios
-2, autotest script to check if the version is correct.
- (reference result calculated by one core and saved in result.ref)
- (user can change NUMBEROFPROCESS value in general_info to test by multi cores)
-3, if there is any bug occurs, rename the bug example path to mark it please.
-
-#######################
-##################
-101_PW_CG_OU_PL
-102_PW_DA_OU_PL
-103_PW_CG_OU_PL
-105_PW_FD_smearing
-105_PW_FX_smearing
-105_PW_M2_smearing
-105_PW_MP_smearing
-105_PW_MV_smearing
-106_PW_OU_BD_chargemixing
-106_PW_OU_KK_chargemixing
-106_PW_OU_PK_chargemixing
-106_PW_OU_PL_chargemixing
-106_PW_OU_PU_chargemixing
-114_PW_CG_15_BD
-121_PW_CG_DJ_PK_CS_CF
-122_PW_CG_15_PK_CS_CF
-123_PW_CG_15_PK_RE_CF
-124_PW_CG_15_PK_CR_CS
-125_PW_CG_15_PK_PU_AF
-128_PW_OU_OB
-129_PW_OU_OD
-133_PW_CG_DJ_PK
-134_PW_CG_DJ_PK
-135_PW_CG_15_PK
-201_NO_GE_15_GO_PK
-202_NO_GE_15_KP_PK
-203_NO_HP_15_GO_PK
-204_NO_HP_15_KP_PK
-205_NO_GE_DJ_GO_PK
-206_NO_GE_DJ_KP_PK
-207_NO_GE_DJ_GO_PK
-208_NO_GE_DJ_KP_PK
-209_NO_GE_15_OB
-210_NO_GE_15_OD
-211_NO_GE_OU_GO_PL_FM
-212_NO_GE_OU_KP_PL_FM
-213_NO_GE_15_GO_PK_FM
-214_NO_GE_15_GO_PK_AF
-215_NO_GE_15_GO_CS_CF
-216_NO_GE_15_KP_CS_CF
-217_NO_GE_DJ_GO_CS_CF
-218_NO_GE_DJ_KP_CS_CF
-219_NO_GE_15_KP_RE_CF
-220_NO_GE_15_KP_CR_CS
-221_NO_GE_OU_KP_AF
-222_NO_GE_15_GO_MD_TD
-223_NO_GE_15_KP_MD_TD
-224_NO_GE_15_GO_BS
-225_NO_GE_15_SO
-226_NO_GE_15_PK_FM
diff --git a/ABACUS.develop/tests/README.md b/ABACUS.develop/tests/README.md
new file mode 100644
index 0000000000..b17a6ab553
--- /dev/null
+++ b/ABACUS.develop/tests/README.md
@@ -0,0 +1,129 @@
+1, modify file general_info
+
+2, try this script for autotest:
+./Autotest.sh > check.txt
+
+3, if want to focus on No. xxx example, such as 101_PW_OU_PL:
+cd 101_PW_OU_PL
+./../run_debug.sh $parameter
+# you can choose $parameter among "" (empty), debug or ref
+# 'ref': generate result.ref file
+
+
+NOTES:
+****Purpose for this autotest package is:
+1, cover all functions and application scenarios
+2, autotest script to check if the version is correct.
+ (reference result calculated by one core and saved in result.ref)
+ (user can change NUMBEROFPROCESS value in general_info to test by multi cores)
+3, if there is any bug occurs, rename the bug example path to mark it please.
+
+#######################
+##################
+
+"simple" scripts
+
+-------------------------------------------------------------
+0-99 Structure Tests (Bravis Lattices, symmetry analysis)
+
+
+-------------------------------------------------------------
+100-200 PW basic properties
+
+100-110: pseudopotentials
+(1) Semiconductor (Si), UPF1.0 (s,p,d,f)
+(2) UPF2.0 (s,p,d,f)
+(3) dojo (s,p,d)
+
+110-120: smearing methods
+(1) Metals
+(2)
+
+120-130: charge mixing
+(1) Metals, Charge Mixing Methods,
+(2) Surfaces, Charge Mixing Methods
+
+130-140: diagonalization methods
+(1) CG (number of bands/trial wave functions)
+(2) Davidson
+
+140-150: force tests
+* test every components of forces
+* small displacements .vs. large displacements
+
+150-160: stress tests
+
+160-170: ion relaxatoin
+
+170-180: cell relaxation
+
+180-190: md simulations
+
+-------------------------------------------------------------
+200-300 LCAO basic properties
+
+_PW plain wave bases
+_NO numerical atoms orbitals bases
+_NP expand numerical atoms orbitals in plane-wave basis
+
+_OU old upf pseudopotential file
+_15 SG15 pseudopotential file
+_VW vwr pseudopotential file
+_DJ DOJO pseudopotential file
+
+_FD smearing method Fermi-dirac
+_FX smearing method: Fixed occupations
+_M2 smearing method: mp2
+_MP smearing method: Methfessel-Paxton (MP)
+_MV smearing method: Marzari-Vanderbilt
+_SG smearing method: Gaussian
+
+_SY turn on symmetry
+_CG cg diagonalization method
+_DA david diagonalization method
+
+_S1 one spin channel
+_S2 two spin channels
+_S4 four spin channels
+
+_GE genelpa diagonalization method
+_HP hpseps diagonalization method
+_SC scalapack diagonalization method
+
+_RE relax calculation
+_CR cell-relax calculation
+_CF calculate and output force
+_CS calculate and output stress
+_MD molecular dynamics
+_TD TDDFT: time dependent DFT
+
+_OH output Halmitonian matrix
+_OB output bands file
+_OD output DOS file
+_OW output wave functions
+_OC output charge density
+
+_GO gamma_only method
+_KP all K-Points method
+
+_FM ferromagnetic nspin=2
+_AF anti-ferromagnetic nspin=2 anti initial magnetism
+
+_PU DFT plus U
+_BS bsse
+
+_PL mixing_type plain mixing
+_KK mixing_type kerker mixing
+_PU mixing_type pulay mixing
+_PK mixing_type pulay-kerker mixing
+_BD mixing_type broyden mixing
+
+_SO spin orbit coupling (SOC)
+_NB set NBANDS without default
+
+_XX EXX
+_VD VDW (both d2 or d3)
+
+_MG move ions method: cg
+_MF move ions method: FIRE
+_MB move ions method: bfgs
diff --git a/ABACUS.develop/tests/SCOPE b/ABACUS.develop/tests/SCOPE
deleted file mode 100644
index a6179cf8a6..0000000000
--- a/ABACUS.develop/tests/SCOPE
+++ /dev/null
@@ -1,41 +0,0 @@
-"simple" scripts
-
--------------------------------------------------------------
-0-99 Structure Tests (Bravis Lattices, symmetry analysis)
-
-
--------------------------------------------------------------
-100-200 PW basic properties
-
-100-110: pseudopotentials
-(1) Semiconductor (Si), UPF1.0 (s,p,d,f)
-(2) UPF2.0 (s,p,d,f)
-(3) dojo (s,p,d)
-
-110-120: smearing methods
-(1) Metals
-(2)
-
-120-130: charge mixing
-(1) Metals, Charge Mixing Methods,
-(2) Surfaces, Charge Mixing Methods
-
-130-140: diagonalization methods
-(1) CG (number of bands/trial wave functions)
-(2) Davidson
-
-140-150: force tests
-* test every components of forces
-* small displacements .vs. large displacements
-
-150-160: stress tests
-
-160-170: ion relaxatoin
-
-170-180: cell relaxation
-
-180-190: md simulations
-
--------------------------------------------------------------
-200-300 LCAO basic properties
-
diff --git a/Dockerfile b/Dockerfile
index fa889476b2..8aa3d94711 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,7 +1,5 @@
FROM debian:buster-slim
-LABEL org.opencontainers.image.source https://github.com/darelbeida/abacus-develop
-
RUN apt-get update && apt-get install -y --no-install-recommends git gfortran libboost-dev libssl-dev make ssh vim wget \
&& apt-get install -y --no-install-recommends mpich libmpich-dev
@@ -45,4 +43,6 @@ RUN cd /tmp \
&& cp -r cereal/include /usr/local \
&& rm -rf cereal
+RUN apt-get install -y bc
+
ENV LD_LIBRARY_PATH /usr/local/lib
diff --git a/README.md b/README.md
index 6f410cf465..12cb3b780d 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,15 @@
-
+
-
+
-[](https://github.com/deepmodeling/abacus-develop/actions/workflows/container.yml) [](https://github.com/deepmodeling/abacus-develop/actions/workflows/test.yml)
+
+
+
+
+
+
+
+
WELCOME TO THE "ABACUS" PROGRAM!
diff --git a/entrypoint.sh b/entrypoint.sh
index 507fe7b7b1..bf2febcbbc 100644
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -2,6 +2,5 @@ cd ABACUS.develop
cmake -B build cmake
cmake --build build -j4
cmake --install build
-cd tests
-ABACUS_PATH=ABACUS NP=2 bash Autotest.sh
-bash clean.sh
+cd build
+ctest --verbose