Skip to content

Commit e3ea1e6

Browse files
19hellopre-commit-ci-lite[bot]
authored andcommitted
Implement a new BFGS optimizer, used for geometry relaxation (deepmodeling#5467)
* bfgs * bfgs1 * Update bfgs method * bfgs_trad * new bfgs method * new bfgs_trad method * new bfgs_trad * bfgs_trad2 * bfgs_trad * bfgs_trad * bfgs_trad * bfgs_trad * bfgs_trad * bfgs_trad * bfgs_trad * bfgs_trad * bfgs_trad * bfgs_trad * Use force_ev_thr to judge optimization * remove 108_PW_RE_MB_NEW * Add determine whether an atom is movable code and modify the value of relax_bfgs_rmax to 0.2 * [pre-commit.ci lite] apply automatic fixes * bfgs_trad --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 47e64c4 commit e3ea1e6

File tree

21 files changed

+791
-21
lines changed

21 files changed

+791
-21
lines changed

source/Makefile.Objects

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,8 @@ OBJS_RELAXATION=bfgs_basic.o\
430430
relax_old.o\
431431
relax.o\
432432
line_search.o\
433+
bfgs.o\
434+
433435

434436
OBJS_SURCHEM=surchem.o\
435437
H_correction_pw.o\

source/module_io/read_input_item_relax.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ void ReadInput::item_relax()
1212
item.annotation = "cg; bfgs; sd; cg; cg_bfgs;";
1313
read_sync_string(input.relax_method);
1414
item.check_value = [](const Input_Item& item, const Parameter& para) {
15-
const std::vector<std::string> relax_methods = {"cg", "bfgs", "sd", "cg_bfgs"};
16-
if (std::find(relax_methods.begin(), relax_methods.end(), para.input.relax_method) == relax_methods.end())
15+
const std::vector<std::string> relax_methods = {"cg", "bfgs", "sd", "cg_bfgs","bfgs_trad"};
16+
if (std::find(relax_methods.begin(),relax_methods.end(), para.input.relax_method)==relax_methods.end())
1717
{
1818
const std::string warningstr = nofound_str(relax_methods, "relax_method");
1919
ModuleBase::WARNING_QUIT("ReadInput", warningstr);

source/module_parameter/input_parameter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ struct Input_para
163163
double press3 = 0;
164164
double relax_bfgs_w1 = 0.01; ///< wolfe condition 1
165165
double relax_bfgs_w2 = 0.5; ///< wolfe condition 2
166-
double relax_bfgs_rmax = 0.8; ///< trust radius max
166+
double relax_bfgs_rmax = 0.2; ///< trust radius max
167167
double relax_bfgs_rmin = 1e-05; ///< trust radius min
168168
double relax_bfgs_init = 0.5; ///< initial move
169169
std::string fixed_axes = "None"; ///< which axes are fixed

source/module_relax/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ add_library(
66

77
relax_new/relax.cpp
88
relax_new/line_search.cpp
9-
9+
10+
relax_old/bfgs.cpp
1011
relax_old/relax_old.cpp
1112
relax_old/bfgs_basic.cpp
1213
relax_old/ions_move_basic.cpp
@@ -27,5 +28,6 @@ if(BUILD_TESTING)
2728
if(ENABLE_MPI)
2829
add_subdirectory(relax_new/test)
2930
add_subdirectory(relax_old/test)
30-
endif()
31+
endif()
32+
3133
endif()

source/module_relax/relax_driver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void Relax_Driver::relax_driver(ModuleESolver::ESolver* p_esolver, UnitCell& uce
1414
ModuleBase::TITLE("Ions", "opt_ions");
1515
ModuleBase::timer::tick("Ions", "opt_ions");
1616

17-
if (PARAM.inp.calculation == "relax" || PARAM.inp.calculation == "cell-relax")
17+
if (PARAM.inp.calculation == "relax" || PARAM.inp.calculation == "cell-relax" )
1818
{
1919
if (!PARAM.inp.relax_new)
2020
{
@@ -25,7 +25,7 @@ void Relax_Driver::relax_driver(ModuleESolver::ESolver* p_esolver, UnitCell& uce
2525
rl.init_relax(ucell.nat);
2626
}
2727
}
28-
28+
2929
this->istep = 1;
3030
int force_step = 1; // pengfei Li 2018-05-14
3131
int stress_step = 1;
@@ -90,7 +90,7 @@ void Relax_Driver::relax_driver(ModuleESolver::ESolver* p_esolver, UnitCell& uce
9090
stress,
9191
force_step,
9292
stress_step); // pengfei Li 2018-05-14
93-
}
93+
}
9494
// print structure
9595
// changelog 20240509
9696
// because I move out the dependence on GlobalV from UnitCell::print_stru_file

source/module_relax/relax_driver.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "module_esolver/esolver_ks.h"
77
#include "relax_new/relax.h"
88
#include "relax_old/relax_old.h"
9-
9+
#include "relax_old/bfgs.h"
1010
class Relax_Driver
1111
{
1212

@@ -27,6 +27,10 @@ class Relax_Driver
2727

2828
// old relaxation method
2929
Relax_old rl_old;
30+
31+
BFGS bfgs_trad;
32+
33+
3034
};
3135

3236
#endif

source/module_relax/relax_new/test/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ AddTest(
1414

1515
AddTest(
1616
TARGET relax_new_relax
17-
SOURCES relax_test.cpp ../relax.cpp ../line_search.cpp ../../../module_base/tool_quit.cpp ../../../module_base/global_variable.cpp ../../../module_base/global_file.cpp ../../../module_base/memory.cpp ../../../module_base/timer.cpp
17+
SOURCES relax_test.cpp ../relax.cpp ../line_search.cpp ../../../module_base/tool_quit.cpp ../../../module_base/global_variable.cpp ../../../module_base/global_file.cpp ../../../module_base/memory.cpp ../../../module_base/timer.cpp
1818
../../../module_base/matrix3.cpp ../../../module_base/intarray.cpp ../../../module_base/tool_title.cpp
1919
../../../module_base/global_function.cpp ../../../module_base/complexmatrix.cpp ../../../module_base/matrix.cpp
2020
../../../module_base/complexarray.cpp ../../../module_base/tool_quit.cpp ../../../module_base/realarray.cpp ../../../module_base/blas_connector.cpp
2121
LIBS parameter ${math_libs}
22-
)
22+
)
23+

0 commit comments

Comments
 (0)