Skip to content

Commit 81ab133

Browse files
siuwuncheungjeanlucf22dreamer2368
authored
Merge release (#351)
* Fix EnergyAndForces tests (#277) * have them work in debug mode too * Move factor 4pi out og linear solvers (#278) * Move some code into PoissonSolverFactory (#279) * Clean up class Potentials (#280) * Clean up class Ions, add test for it (#281) * Add test MD_MVP (#290) * Clean up code related to DM restart data (#292) * Write dm (#291) * Update use of DM in restart * Remove unused function in Control (#294) * Change symlink to restart in tests (#295) * enable tests when old link present * Extract number empty orbitals from restart file (#296) * Clean up MD_IonicStepper restart data write (#297) * Clean up code based on compiler warnings (#299) * Add getForces for evaluateDMandEnergyAndForces (#300) * Add check for compatibility MVP/Mehrstellen (#301) * Add support for Br atom (#302) * Clean up some HDFrestart functions (#303) * Fix and test restart single hdf5 file (#305) * Save Hartree potential for write in restart file (#306) * Speed-up recently added tests (#309) * simply use a smaller domain/mesh * Encapsulate some functions in Potentials (#310) * some functions were called at random places and confusing * Remove confusing 0 in naming restart files (#308) * use added integer only in case of fail/retry * Add functionalities for extra info in restart file (#312) * MPI abort (#313) * Fix error code used by MPI_Abort * Rho and VH restart (#311) * enable restart with consistent rho and VHartree --------- Co-authored-by: Seung Whan Chung <seung.chung@austin.utexas.edu> * Strenghten testIons (#315) * More clean up in class Potentials (#316) * remove some unused functions * make use of class MGmol_MPI * change some function names for clarity * fix some minor bug in iterative indexes * Misc code fixes (#317) * exposed by porting on new environment * Use unique restart filenames in test HDF5single (#318) * Swap ions in existing test (#319) * strengthen testing by swapping ions in testRestartEnergyAndForces * Code clean up (#320) * use more const * use initNuc() instead of moveVnuc() * remove incorrect assert * use MGmol_MPI in more cases * setup g_kbpsi_ inside initNuc() * rename initNuc() into setupPotentials() * Added functionalities to set local forces (#321) * Update mixed precision code (#322) * enable cmake build with mixed precision * enable use of BLIS * isolate blas3 loop rewrite in separate files * fix misc issues with mixed precision code * Clean up and fixes Ions (#326) * reset static index counter ion Ion when needed * simplify some loops * make Ions copy constructor private * Fixes for build without HDF5P (#324) * Fix testRhoVhRestart (#325) * Fix a few more issues with class Ions (#328) * Introduce new constructor for class Ions (#330) * modify various functions to use argument of type Ions instead of MGmol::ions_ * Add cleanup and MGmolInterface (#331) * Add function to set local forces (#333) * based on matching coordinates to local ions * Fix setLocalForces (#335) * Fix test WFEnergyAndForces (#336) * writing restart twice in same directory was failing * Add mixing option in MVP (#337) * Update MVP with mixing (#339) * use tolerance to terminate iterations * tune verbosity * Update DensityMatrix class (#342) * add extrapolation function * remove unused function * simplify use of iterative index * Fixing DM tolerance (#341) * Fix Density Matrix tolerance read --------- Co-authored-by: Jean-Luc Fattebert <fattebertj@ornl.gov> * Rm oversubscribe from CMakeLists.txt (#346) * already set in build script * Adapt to new environment on condo @ ORNL (#348) --------- Co-authored-by: Jean-Luc Fattebert <fattebertj@ornl.gov> Co-authored-by: Seung Whan Chung <seung.chung@austin.utexas.edu>
1 parent f11a40a commit 81ab133

27 files changed

Lines changed: 181 additions & 231 deletions

scripts/build_condo-mod.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
#Before compiling, load the following modules:
44
source scripts/modules.condo-mod
55

6-
# We need to define the cmake blas vendor option here to find the right one.
7-
BLAS_VENDOR=OpenBLAS
8-
96
MGMOL_ROOT=`pwd`
107

118
INSTALL_DIR=${MGMOL_ROOT}/install
@@ -15,16 +12,17 @@ BUILD_DIR=${MGMOL_ROOT}/build
1512
mkdir -p ${BUILD_DIR}
1613
cd ${BUILD_DIR}
1714

15+
SCALAPACK_DIR=/home/q8j/Software/ScaLapack/scalapack-2.2.2
16+
1817
# call cmake
1918
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \
2019
-DCMAKE_BUILD_TYPE=Release \
2120
-DCMAKE_CXX_COMPILER=mpiCC \
2221
-DCMAKE_Fortran_COMPILER=mpif77 \
23-
-DBLA_VENDOR=${BLAS_VENDOR} \
2422
-DMGMOL_USE_HDF5P=OFF \
2523
-DMGMOL_WITH_CLANG_FORMAT=ON \
2624
-DCMAKE_PREFIX_PATH=${HOME}/bin \
27-
-DSCALAPACK_LIBRARY="${SCALAPACK_DIR}/lib/libscalapack.a;/lib64/libgfortran.so.3" \
25+
-DSCALAPACK_LIBRARY="${SCALAPACK_DIR}/lib/libscalapack.a;/lib64/libgfortran.so.5" \
2826
-DMPIEXEC_EXECUTABLE=${OPENMPI_DIR}/bin/mpiexec \
2927
..
3028

scripts/build_condo.sh

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,30 @@
11
#/bin/bash
22
## An example script to build on ONRL condo systems (CADES).
3-
## This script assumes intel/ mkl libraries are being used.
43

54
#Before compiling, load the following modules:
65
source scripts/modules.condo
76

8-
# set some environment variables using loaded module path
9-
export SCALAPACK_ROOT=${MKLROOT}
10-
11-
# We need to define the cmake blas vendor option here to find the right one.
12-
BLAS_VENDOR=Intel10_64lp
13-
14-
# manually set the location of BLACS libraries for scalapack
15-
BLACS_LIB=${MKLROOT}/lib/intel64
16-
177
MGMOL_ROOT=`pwd`
188

19-
INSTALL_DIR=${MGMOL_ROOT}/mgmol_install
9+
INSTALL_DIR=${MGMOL_ROOT}/install
2010
mkdir -p ${INSTALL_DIR}
2111

2212
BUILD_DIR=${MGMOL_ROOT}/build
2313
mkdir -p ${BUILD_DIR}
2414
cd ${BUILD_DIR}
2515

16+
SCALAPACK_DIR=/home/q8j/Software/ScaLapack/scalapack-2.2.2
17+
2618
# call cmake
2719
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \
2820
-DCMAKE_BUILD_TYPE=Release \
2921
-DCMAKE_CXX_COMPILER=mpiCC \
3022
-DCMAKE_Fortran_COMPILER=mpif77 \
31-
-DHDF5_LIBRARIES=${HDF5_DIR}/lib/libhdf5.so \
32-
-DHDF5_HL_LIBRARIES=${HDF5_DIR}/lib/libhdf5_hl.so \
33-
-DHDF5_INCLUDE_DIRS=${HDF5_DIR}/include \
34-
-DBLA_VENDOR=${BLAS_VENDOR} \
23+
-DMGMOL_USE_HDF5P=OFF \
3524
-DMGMOL_WITH_CLANG_FORMAT=ON \
3625
-DCMAKE_PREFIX_PATH=${HOME}/bin \
26+
-DSCALAPACK_LIBRARY="${SCALAPACK_DIR}/lib/libscalapack.a;/lib64/libgfortran.so.5" \
3727
-DMPIEXEC_EXECUTABLE=${OPENMPI_DIR}/bin/mpiexec \
38-
-DSCALAPACK_BLACS_LIBRARY=${BLACS_LIB}/libmkl_blacs_openmpi_lp64.so \
3928
..
4029

4130
# call make install

scripts/modules.condo

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
module load PE-intel/3.0
2-
module load boost/1.67.0-pe3
3-
module load mkl
4-
module load hdf5_parallel/1.10.3
5-
module load cmake/3.18.4
1+
module load hdf5
2+
module load boost
3+
module load cmake
64
module load python
5+
module load openblas

scripts/modules.condo-mod

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
module load PE-gnu/3.0
2-
module load hdf5-parallel/1.8.20
1+
module load hdf5
32
module load boost
4-
module load cmake/3.20.3
5-
module load python/3.6.6
6-
module load openBLAS/0.2.19
7-
module load scalapack/2.0.2
3+
module load cmake
4+
module load python
5+
module load openblas

src/Control.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ void Control::print(std::ostream& os)
224224
<< conv_tol << std::endl;
225225
os << std::fixed;
226226
os << " Density matrix mixing = " << dm_mix << std::endl;
227-
os << std::setprecision(4) << std::scientific << " Density matrix tol = " << dm_tol << std::endl;
227+
os << std::setprecision(4) << std::scientific
228+
<< " Density matrix tol = " << dm_tol << std::endl;
228229
if (DMEigensolver() == DMEigensolverType::Eigensolver)
229230
{
230231
os << " Density matrix computation algorithm = "

src/DavidsonSolver.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ double DavidsonSolver<OrbitalsType, MatrixType>::evaluateDerivative(
206206
const double dbeta = 0.0001;
207207
*work2N_ = dm2Ninit;
208208
work2N_->axpy(dbeta, delta_dm);
209-
// proj_mat2N_->setDM(*work2N_,orbitals.getIterativeIndex());
210-
proj_mat2N_->setDM(*work2N_, -1);
209+
210+
proj_mat2N_->setDM(*work2N_);
211211
proj_mat2N_->computeOccupationsFromDM();
212212

213213
const double tsd0e = evalEntropy(proj_mat2N_.get(), false, os_);
@@ -250,7 +250,7 @@ void DavidsonSolver<OrbitalsType, MatrixType>::buildTarget2N_MVP(
250250
// if( onpe0 )os_<<"Compute X2N..."<<endl;
251251
proj_mat2N_->setHB2H();
252252

253-
proj_mat2N_->updateDM(orbitals_index);
253+
proj_mat2N_->updateDM();
254254

255255
target = proj_mat2N_->dm();
256256

@@ -584,7 +584,7 @@ int DavidsonSolver<OrbitalsType, MatrixType>::solve(
584584
//
585585
if (mmpi.PE0() && ct.verbose > 2)
586586
os_ << "Target energy..." << std::endl;
587-
proj_mat2N_->setDM(target, orbitals.getIterativeIndex());
587+
proj_mat2N_->setDM(target);
588588
proj_mat2N_->computeOccupationsFromDM();
589589
double nel = proj_mat2N_->getNel();
590590
if (mmpi.PE0() && ct.verbose > 2)
@@ -643,7 +643,7 @@ int DavidsonSolver<OrbitalsType, MatrixType>::solve(
643643
// update DM
644644
*work2N_ = dm2Ninit;
645645
work2N_->axpy(beta, delta_dm);
646-
proj_mat2N_->setDM(*work2N_, orbitals.getIterativeIndex());
646+
proj_mat2N_->setDM(*work2N_);
647647

648648
if (inner_it < ct.dm_inner_steps - 1)
649649
{
@@ -809,7 +809,7 @@ int DavidsonSolver<OrbitalsType, MatrixType>::solve(
809809
= dynamic_cast<ProjectedMatrices<MatrixType>*>(
810810
orbitals.getProjMatrices());
811811
assert(pmat);
812-
pmat->buildDM(new_occ, orbitals.getIterativeIndex());
812+
pmat->buildDM(new_occ);
813813

814814
if (retval == 0) break;
815815

src/DensityMatrix.cc

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222

2323
const double factor_kernel4dot = 10.;
2424

25-
#define PROCRUSTES 0
25+
#define MGMOL_DENSITYMATRIX_FAIL(X) \
26+
{ \
27+
std::cerr << "DensityMatrix failure:" << std::endl; \
28+
std::cerr << "Error Message: " << X << std::endl; \
29+
}
2630

2731
#define MGMOL_DENSITYMATRIX_FAIL(X) \
2832
{ \
@@ -36,7 +40,7 @@ const double factor_kernel4dot = 10.;
3640
template <class MatrixType>
3741
DensityMatrix<MatrixType>::DensityMatrix(const int ndim)
3842
: dim_(ndim),
39-
orbitals_index_(-1),
43+
update_index_(-1),
4044
occ_uptodate_(false),
4145
uniform_occ_(false),
4246
stripped_(false)
@@ -66,8 +70,8 @@ DensityMatrix<MatrixType>::~DensityMatrix()
6670
}
6771

6872
template <class MatrixType>
69-
void DensityMatrix<MatrixType>::build(const MatrixType& zmat,
70-
const std::vector<double>& occ, const int new_orbitals_index)
73+
void DensityMatrix<MatrixType>::build(
74+
const MatrixType& zmat, const std::vector<double>& occ)
7175
{
7276
#ifdef PRINT_OPERATIONS
7377
MGmol_MPI& mmpi = *(MGmol_MPI::instance());
@@ -98,32 +102,30 @@ void DensityMatrix<MatrixType>::build(const MatrixType& zmat,
98102
work_->symm('r', 'l', 1., gamma, zmat, 0.);
99103
kernel4dot_->gemm('n', 't', 1., *work_, zmat, 0.);
100104

101-
stripped_ = false;
102-
orbitals_index_ = new_orbitals_index;
105+
stripped_ = false;
106+
update_index_++;
103107
}
104108

105109
template <class MatrixType>
106-
void DensityMatrix<MatrixType>::build(
107-
const MatrixType& zmat, const int new_orbitals_index)
110+
void DensityMatrix<MatrixType>::build(const MatrixType& zmat)
108111
{
109-
build(zmat, occupation_, new_orbitals_index);
112+
build(zmat, occupation_);
110113
}
111114

112115
// build diagonal matrix
113116
template <class MatrixType>
114-
void DensityMatrix<MatrixType>::build(
115-
const std::vector<double>& occ, const int new_orbitals_index)
117+
void DensityMatrix<MatrixType>::build(const std::vector<double>& occ)
116118
{
117119
assert(dm_ != nullptr);
118120
assert(!occ.empty());
119121

120122
setOccupations(occ);
121123

122-
build(new_orbitals_index);
124+
build();
123125
}
124126

125127
template <class MatrixType>
126-
void DensityMatrix<MatrixType>::build(const int new_orbitals_index)
128+
void DensityMatrix<MatrixType>::build()
127129
{
128130
MGmol_MPI& mmpi = *(MGmol_MPI::instance());
129131
#ifdef PRINT_OPERATIONS
@@ -148,13 +150,12 @@ void DensityMatrix<MatrixType>::build(const int new_orbitals_index)
148150
* std::min(1., factor_kernel4dot * occupation_[i]));
149151
kernel4dot_->setDiagonal(w);
150152

151-
stripped_ = false;
152-
orbitals_index_ = new_orbitals_index;
153+
stripped_ = false;
154+
update_index_++;
153155
}
154156

155157
template <class MatrixType>
156-
void DensityMatrix<MatrixType>::setUniform(
157-
const double nel, const int new_orbitals_index)
158+
void DensityMatrix<MatrixType>::setUniform(const double nel)
158159
{
159160
assert(!occupation_.empty());
160161

@@ -171,22 +172,13 @@ void DensityMatrix<MatrixType>::setUniform(
171172

172173
uniform_occ_ = true;
173174

174-
build(occupation_, new_orbitals_index);
175-
}
176-
177-
template <class MatrixType>
178-
void DensityMatrix<MatrixType>::buildFromBlock(const MatrixType& block00)
179-
{
180-
dm_->clear();
181-
dm_->assign(block00, 0, 0);
182-
dm_->print(std::cout, 0, 0, 25, 25);
175+
build(occupation_);
183176
}
184177

185178
template <class MatrixType>
186179
void DensityMatrix<MatrixType>::rotate(
187180
const MatrixType& rotation_matrix, const bool flag_eigen)
188181
{
189-
190182
if (!flag_eigen)
191183
{
192184
MatrixType invU(rotation_matrix);
@@ -204,6 +196,8 @@ void DensityMatrix<MatrixType>::rotate(
204196
invU.getrs('n', tmp, ipiv);
205197

206198
*dm_ = tmp;
199+
200+
update_index_++;
207201
}
208202
}
209203

@@ -370,8 +364,7 @@ double DensityMatrix<MatrixType>::computeEntropy() const
370364
}
371365

372366
template <class MatrixType>
373-
void DensityMatrix<MatrixType>::setto2InvS(
374-
const MatrixType& invS, const int orbitals_index)
367+
void DensityMatrix<MatrixType>::setto2InvS(const MatrixType& invS)
375368
{
376369
*dm_ = invS;
377370
dm_->scal(orbital_occupation_);
@@ -382,8 +375,8 @@ void DensityMatrix<MatrixType>::setto2InvS(
382375
occupation_[st] = 1.;
383376
occ_uptodate_ = true;
384377
}
385-
uniform_occ_ = false;
386-
orbitals_index_ = orbitals_index;
378+
uniform_occ_ = false;
379+
update_index_++;
387380
}
388381

389382
template <class MatrixType>
@@ -400,8 +393,7 @@ void DensityMatrix<MatrixType>::stripS(const MatrixType& ls)
400393
}
401394

402395
template <class MatrixType>
403-
void DensityMatrix<MatrixType>::dressUpS(
404-
const MatrixType& ls, const int new_orbitals_index)
396+
void DensityMatrix<MatrixType>::dressUpS(const MatrixType& ls)
405397
{
406398
assert(stripped_);
407399

@@ -410,10 +402,11 @@ void DensityMatrix<MatrixType>::dressUpS(
410402
*dm_ = *work_;
411403
ls.trtrs('l', 't', 'n', *dm_);
412404

413-
orbitals_index_ = new_orbitals_index;
414-
occ_uptodate_ = false;
415-
uniform_occ_ = false;
416-
stripped_ = false;
405+
update_index_++;
406+
407+
occ_uptodate_ = false;
408+
uniform_occ_ = false;
409+
stripped_ = false;
417410
}
418411

419412
// dm_ -> u*dm_*u^T
@@ -424,6 +417,8 @@ void DensityMatrix<MatrixType>::transform(const MatrixType& u)
424417
{
425418
work_->gemm('n', 't', 1., *dm_, u, 0.);
426419
dm_->gemm('n', 'n', 1., u, *work_, 0.);
420+
421+
update_index_++;
427422
}
428423

429424
template <class MatrixType>
@@ -434,13 +429,21 @@ double DensityMatrix<MatrixType>::getExpectation(const MatrixType& A)
434429
}
435430

436431
template <class MatrixType>
437-
void DensityMatrix<MatrixType>::mix(
438-
const double mix, const MatrixType& matA, const int new_orbitals_index)
432+
void DensityMatrix<MatrixType>::mix(const double mix, const MatrixType& matA)
439433
{
440434
dm_->scal(1. - mix);
441-
442435
dm_->axpy(mix, matA);
443-
orbitals_index_ = new_orbitals_index;
436+
437+
update_index_++;
438+
}
439+
440+
template <class MatrixType>
441+
void DensityMatrix<MatrixType>::linearExtrapolate(const MatrixType& previous_dm)
442+
{
443+
dm_->scal(2.);
444+
dm_->axpy(-1., previous_dm);
445+
446+
update_index_++;
444447
}
445448

446449
template <class MatrixType>

0 commit comments

Comments
 (0)