Skip to content

Commit f11a40a

Browse files
siuwuncheungjeanlucf22dreamer2368
authored
Testing ROM MVP MD (#338)
* 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 <[email protected]> * 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) * Timer * Update MVP with mixing (#339) * use tolerance to terminate iterations * tune verbosity * Updates * use setupPotentials * Setup potentials again * setupRhoc is done within setupPotentials * Avoid setPositions * Rescaling ROM ion density * Relax threshold * Increase tolerance for testROMIonDensity --------- Co-authored-by: Jean-Luc Fattebert <[email protected]> Co-authored-by: Seung Whan Chung <[email protected]>
1 parent 704c952 commit f11a40a

26 files changed

+290
-104
lines changed

examples/PinnedH2O/job.basis_1_50

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ setenv OMP_NUM_THREADS 1
1010

1111
set ncpus = 8
1212

13-
set maindir = /p/lustre2/cheung26/mgmol-20250219
13+
set maindir = /p/lustre2/cheung26/mgmol
1414

1515
setenv LD_LIBRARY_PATH ${maindir}/build_quartz/libROM/build/lib:$LD_LIBRARY_PATH
1616

examples/PinnedH2O/job.offline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ setenv OMP_NUM_THREADS 1
1010

1111
set ncpus = 8
1212

13-
set maindir = /p/lustre2/cheung26/mgmol-20250219
13+
set maindir = /p/lustre2/cheung26/mgmol
1414

1515
setenv LD_LIBRARY_PATH ${maindir}/build_quartz/libROM/build/lib:$LD_LIBRARY_PATH
1616

examples/PinnedH2O/job.ref

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ setenv OMP_NUM_THREADS 1
1111
set ncpus = 8
1212
set case = 2
1313

14-
set maindir = /p/lustre2/cheung26/mgmol-20250219
14+
set maindir = /p/lustre2/cheung26/mgmol
1515

1616
setenv LD_LIBRARY_PATH ${maindir}/build_quartz/libROM/build/lib:$LD_LIBRARY_PATH
1717

examples/PinnedH2O/job.rom

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ setenv OMP_NUM_THREADS 1
1010

1111
set ncpus = 8
1212

13-
set maindir = /p/lustre2/cheung26/mgmol-20250219
13+
set maindir = /p/lustre2/cheung26/mgmol
1414

1515
setenv LD_LIBRARY_PATH ${maindir}/build_quartz/libROM/build/lib:$LD_LIBRARY_PATH
1616

examples/PinnedH2O/job.rom_3DOF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ setenv OMP_NUM_THREADS 1
1111
set ncpus = 8
1212
set case = 2
1313

14-
set maindir = /p/lustre2/cheung26/mgmol-20250219
14+
set maindir = /p/lustre2/cheung26/mgmol
1515

1616
setenv LD_LIBRARY_PATH ${maindir}/build_quartz/libROM/build/lib:$LD_LIBRARY_PATH
1717

examples/PinnedH2O/mgmol_rom_3DOF_test1.cfg

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
verbosity=1
1+
verbosity=2
22
xcFunctional=PBE
33
FDtype=4th
44
[Mesh]
@@ -34,7 +34,9 @@ initial_width=2.
3434
nempty=30
3535
[DensityMatrix]
3636
solver=MVP
37-
nb_inner_it=100
37+
nb_inner_it=20
38+
mixing=0.8
39+
tol=1.e-8
3840
[Restart]
3941
output_level=4
4042
[ROM]

examples/PinnedH2O/mgmol_rom_3DOF_test2.cfg

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
verbosity=1
1+
verbosity=2
22
xcFunctional=PBE
33
FDtype=4th
44
[Mesh]
@@ -30,7 +30,9 @@ initial_width=2.
3030
nempty=30
3131
[DensityMatrix]
3232
solver=MVP
33-
nb_inner_it=100
33+
nb_inner_it=20
34+
mixing=0.8
35+
tol=1.e-8
3436
[Restart]
3537
output_level=4
3638
[ROM]

src/Control.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ 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;
227228
if (DMEigensolver() == DMEigensolverType::Eigensolver)
228229
{
229230
os << " Density matrix computation algorithm = "
@@ -439,7 +440,7 @@ void Control::sync(void)
439440
memset(&int_buffer[0], 0, size_int_buffer * sizeof(int));
440441
}
441442

442-
const short size_float_buffer = 43;
443+
const short size_float_buffer = 44;
443444
float* float_buffer = new float[size_float_buffer];
444445
if (mype_ == 0)
445446
{
@@ -485,6 +486,7 @@ void Control::sync(void)
485486
float_buffer[40] = threshold_eigenvalue_gram_quench_;
486487
float_buffer[41] = pair_mlwf_distance_threshold_;
487488
float_buffer[42] = e0_;
489+
float_buffer[43] = dm_tol;
488490
}
489491
else
490492
{
@@ -680,6 +682,7 @@ void Control::sync(void)
680682
threshold_eigenvalue_gram_quench_ = float_buffer[40];
681683
pair_mlwf_distance_threshold_ = float_buffer[41];
682684
e0_ = float_buffer[42];
685+
dm_tol = float_buffer[43];
683686
max_electronic_steps_loose_ = max_electronic_steps;
684687

685688
delete[] short_buffer;
@@ -699,8 +702,8 @@ void Control::setDefaultValues()
699702

700703
void Control::adjust()
701704
{
702-
// change dm_mix default to 1. if not using Davidson
703-
if (it_algo_type_ != 2 && dm_mix < 0.) dm_mix = 1.;
705+
// change dm_mix default to 1. if not using Davidson or MVP
706+
if ((it_algo_type_ != 2 && DM_solver_ != 1) && dm_mix < 0.) dm_mix = 1.;
704707

705708
if (nel_ - 2 * numst == 0)
706709
{
@@ -1720,6 +1723,7 @@ void Control::setOptions(const boost::program_options::variables_map& vm)
17201723
lrs_extrapolation = 10;
17211724

17221725
dm_mix = vm["DensityMatrix.mixing"].as<float>();
1726+
dm_tol = vm["DensityMatrix.tol"].as<float>();
17231727
dm_inner_steps = vm["DensityMatrix.nb_inner_it"].as<short>();
17241728
dm_use_old_ = vm["DensityMatrix.use_old"].as<bool>() ? 1 : 0;
17251729
str = vm["DensityMatrix.algo"].as<std::string>();
@@ -1739,8 +1743,6 @@ void Control::setOptions(const boost::program_options::variables_map& vm)
17391743
else
17401744
dm_algo_ = 2;
17411745

1742-
dm_tol = vm["DensityMatrix.tol"].as<float>();
1743-
17441746
str = vm["DensityMatrix.solver"].as<std::string>();
17451747
if (str.compare("Mixing") == 0) DM_solver_ = 0;
17461748
if (str.compare("MVP") == 0) DM_solver_ = 1;

src/Ions.cc

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,22 +1315,6 @@ void Ions::setLocalForces(
13151315
{
13161316
if (ion->compareName(*s))
13171317
{
1318-
//std::cout << "Ion found: " << ion->name() << std::endl;
1319-
//std::cout << "Ion force: (" << *it << ", " << *(it + 1) << ", " << *(it + 2) << ")" << std::endl;
1320-
//std::cout << "names: ";
1321-
//for (int i = 0; i < names.size(); i++)
1322-
//{
1323-
// std::cout << names[i];
1324-
// if (i == forces.size() - 1) std::cout << std::endl;
1325-
// else std::cout << ", ";
1326-
//}
1327-
//std::cout << "forces: ";
1328-
//for (int i = 0; i < forces.size(); i++)
1329-
//{
1330-
// std::cout << forces[i];
1331-
// if (i == forces.size() - 1) std::cout << ")" << std::endl;
1332-
// else std::cout << ", ";
1333-
//}
13341318
ion->set_force(0, *it);
13351319
ion->set_force(1, *(it + 1));
13361320
ion->set_force(2, *(it + 2));
@@ -1364,9 +1348,6 @@ void Ions::setLocalForces(
13641348
double d = std::sqrt(d2);
13651349
if (d < tol)
13661350
{
1367-
std::cout << "Ion found: " << ion->name() << std::endl;
1368-
std::cout << "Ion position:( " << *cit << ", " << *(cit + 1) << ", " << *(cit + 2) << ")" << std::endl;
1369-
std::cout << "Ion force: (" << *fit << ", " << *(fit + 1) << ", " << *(fit + 2) << ")" << std::endl;
13701351
ion->set_force(0, *fit);
13711352
ion->set_force(1, *(fit + 1));
13721353
ion->set_force(2, *(fit + 2));

src/MGmol.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ extern Timer md_moveVnuc_tm;
102102
extern Timer md_updateMasks_tm;
103103
extern Timer md_extrapolateOrbitals_tm;
104104
extern Timer md_updateRhoAndPot_tm;
105+
extern Timer md_updateDMandEnergy_tm;
105106
extern Timer quench_tm;
106107
extern Timer ions_setupInteractingIons_tm;
107108
extern Timer ions_setup_tm;
@@ -928,6 +929,7 @@ void MGmol<OrbitalsType>::printTimers()
928929
init_nuc_tm_.print(os_);
929930
md_updateMasks_tm.print(os_);
930931
md_extrapolateOrbitals_tm.print(os_);
932+
md_updateDMandEnergy_tm.print(os_);
931933
quench_tm.print(os_);
932934
evnl_tm_.print(os_);
933935
ions_setupInteractingIons_tm.print(os_);

0 commit comments

Comments
 (0)