Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a new BFGS optimizer, used for geometry relaxation #5467

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ OBJS_RELAXATION=bfgs_basic.o\
relax_old.o\
relax.o\
line_search.o\
bfgs.o\


OBJS_SURCHEM=surchem.o\
H_correction_pw.o\
Expand Down
4 changes: 2 additions & 2 deletions source/module_io/read_input_item_relax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ void ReadInput::item_relax()
item.annotation = "cg; bfgs; sd; cg; cg_bfgs;";
read_sync_string(input.relax_method);
item.check_value = [](const Input_Item& item, const Parameter& para) {
const std::vector<std::string> relax_methods = {"cg", "bfgs", "sd", "cg_bfgs"};
if (std::find(relax_methods.begin(), relax_methods.end(), para.input.relax_method) == relax_methods.end())
const std::vector<std::string> relax_methods = {"cg", "bfgs", "sd", "cg_bfgs","bfgs_trad"};
kirk0830 marked this conversation as resolved.
Show resolved Hide resolved
if (std::find(relax_methods.begin(),relax_methods.end(), para.input.relax_method)==relax_methods.end())
{
const std::string warningstr = nofound_str(relax_methods, "relax_method");
ModuleBase::WARNING_QUIT("ReadInput", warningstr);
Expand Down
6 changes: 4 additions & 2 deletions source/module_relax/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ add_library(

relax_new/relax.cpp
relax_new/line_search.cpp


relax_old/bfgs.cpp
relax_old/relax_old.cpp
relax_old/bfgs_basic.cpp
relax_old/ions_move_basic.cpp
Expand All @@ -27,5 +28,6 @@ if(BUILD_TESTING)
if(ENABLE_MPI)
add_subdirectory(relax_new/test)
add_subdirectory(relax_old/test)
endif()
endif()

endif()
6 changes: 3 additions & 3 deletions source/module_relax/relax_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void Relax_Driver::relax_driver(ModuleESolver::ESolver* p_esolver)
ModuleBase::TITLE("Ions", "opt_ions");
ModuleBase::timer::tick("Ions", "opt_ions");

if (PARAM.inp.calculation == "relax" || PARAM.inp.calculation == "cell-relax")
if (PARAM.inp.calculation == "relax" || PARAM.inp.calculation == "cell-relax" )
{
if (!PARAM.inp.relax_new)
{
Expand All @@ -25,7 +25,7 @@ void Relax_Driver::relax_driver(ModuleESolver::ESolver* p_esolver)
rl.init_relax(GlobalC::ucell.nat);
}
}

this->istep = 1;
int force_step = 1; // pengfei Li 2018-05-14
int stress_step = 1;
Expand Down Expand Up @@ -90,7 +90,7 @@ void Relax_Driver::relax_driver(ModuleESolver::ESolver* p_esolver)
stress,
force_step,
stress_step); // pengfei Li 2018-05-14
}
}
// print structure
// changelog 20240509
// because I move out the dependence on GlobalV from UnitCell::print_stru_file
Expand Down
6 changes: 5 additions & 1 deletion source/module_relax/relax_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "module_esolver/esolver_ks.h"
#include "relax_new/relax.h"
#include "relax_old/relax_old.h"

#include "relax_old/bfgs.h"
class Relax_Driver
{

Expand All @@ -26,6 +26,10 @@ class Relax_Driver

// old relaxation method
Relax_old rl_old;

BFGS bfgs_trad;


};

#endif
5 changes: 3 additions & 2 deletions source/module_relax/relax_new/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ AddTest(

AddTest(
TARGET relax_new_relax
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
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
../../../module_base/matrix3.cpp ../../../module_base/intarray.cpp ../../../module_base/tool_title.cpp
../../../module_base/global_function.cpp ../../../module_base/complexmatrix.cpp ../../../module_base/matrix.cpp
../../../module_base/complexarray.cpp ../../../module_base/tool_quit.cpp ../../../module_base/realarray.cpp ../../../module_base/blas_connector.cpp
LIBS parameter ${math_libs}
)
)

Loading
Loading