Skip to content

Combine relax_new with relax_old #6303

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

Merged
merged 29 commits into from
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2a79ecb
update bfgs method
19hello Dec 2, 2024
0b52719
update bfgs method and modify the parameter force in relax_step to be…
19hello Dec 2, 2024
f79ab76
update bfgs method and modify the parameter force in relax_step to be…
19hello Dec 2, 2024
808feb5
Introduce the differences between the two BFGS methods
19hello Dec 10, 2024
ebdac58
Add & in relax_step input parameters
19hello Dec 11, 2024
f3b9541
Merge branch 'develop' into updatebfgstrad
19hello Dec 13, 2024
31d81b4
Merge branch 'develop' into updatebfgstrad
19hello Dec 13, 2024
44b974b
fix confilct
19hello Dec 13, 2024
9ca9366
Merge branch 'updatebfgstrad' of https://github.com/19hello/myrepo in…
19hello Dec 13, 2024
093b2eb
add lbfgs method
19hello Feb 15, 2025
e2ada07
add lbfgs method
19hello Mar 7, 2025
c6b8458
add lbfgs
19hello Mar 11, 2025
279f99e
Merge branch 'develop' of https://github.com/deepmodeling/abacus-deve…
19hello Mar 12, 2025
caf7bcd
lbfgs0
19hello Mar 12, 2025
f4fefe4
addlbfgs
19hello Mar 12, 2025
a0197d8
add lbfgs method
19hello Mar 15, 2025
ca96d15
add lbfgs method
19hello Mar 15, 2025
c8b7066
Refactor the code and add comments
19hello Mar 19, 2025
b452a90
Modify comments
19hello Mar 20, 2025
53bc754
remove auto
19hello Mar 22, 2025
75605b6
remove auto
19hello Mar 22, 2025
280fef6
Merge branch 'develop' of https://github.com/deepmodeling/abacus-deve…
19hello Mar 22, 2025
8e25419
remove auto
19hello Mar 22, 2025
7ee2e48
remove auto
19hello Mar 22, 2025
87a201a
remove auto
19hello Mar 23, 2025
052af29
Merge branch 'develop' of https://github.com/deepmodeling/abacus-deve…
19hello Jun 15, 2025
e813593
combine relax_new with relax_old
19hello Jun 17, 2025
f3ff4e5
combine relax_new with relax_old
19hello Jun 18, 2025
a48bb09
combine relax_new with relax_old
19hello Jun 18, 2025
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
6 changes: 2 additions & 4 deletions source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ VPATH=./src_global:\
./module_hamilt_lcao/hamilt_lcaodft/operator_lcao:\
./module_hamilt_lcao/module_gint:\
./module_relax:\
./module_relax/relax_old:\
./module_relax/relax_new:\
./module_hamilt_general/module_vdw:\
./module_io:\
./module_io/json_output:\
Expand Down Expand Up @@ -449,8 +447,8 @@ OBJS_RELAXATION=bfgs_basic.o\
lattice_change_basic.o\
lattice_change_cg.o\
lattice_change_methods.o\
relax_old.o\
relax.o\
relax_nsync.o\
relax_sync.o\
bfgs.o\
lbfgs.o\
matrix_methods.o\
Expand Down
4 changes: 2 additions & 2 deletions source/module_io/input_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "module_hamilt_pw/hamilt_pwdft/global.h"
#include "module_io/berryphase.h"
#include "module_parameter/parameter.h"
#include "module_relax/relax_old/ions_move_basic.h"
#include "module_relax/relax_old/lattice_change_basic.h"
#include "module_relax/ions_move_basic.h"
#include "module_relax/lattice_change_basic.h"

#include <algorithm>

Expand Down
8 changes: 4 additions & 4 deletions source/module_io/test/for_testing_input_conv.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
#include "module_io/berryphase.h"
#include "module_io/restart.h"
#include "module_md/md_func.h"
#include "module_relax/relax_old/bfgs_basic.h"
#include "module_relax/relax_old/ions_move_basic.h"
#include "module_relax/relax_old/ions_move_cg.h"
#include "module_relax/relax_old/lattice_change_basic.h"
#include "module_relax/bfgs_basic.h"
#include "module_relax/ions_move_basic.h"
#include "module_relax/ions_move_cg.h"
#include "module_relax/lattice_change_basic.h"
#ifdef __PEXSI
#include "source_hsolver/module_pexsi/pexsi_solver.h"
#endif
Expand Down
33 changes: 16 additions & 17 deletions source/module_relax/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ add_library(

relax_driver.cpp

relax_new/relax.cpp
relax_new/line_search.cpp
relax_sync.cpp
line_search.cpp

relax_old/bfgs.cpp
relax_old/lbfgs.cpp
relax_old/relax_old.cpp
relax_old/bfgs_basic.cpp
relax_old/ions_move_basic.cpp
relax_old/ions_move_bfgs.cpp
relax_old/ions_move_cg.cpp
relax_old/ions_move_sd.cpp
relax_old/ions_move_methods.cpp
relax_old/lattice_change_basic.cpp
relax_old/lattice_change_cg.cpp
relax_old/lattice_change_methods.cpp
relax_old/matrix_methods.cpp
bfgs.cpp
lbfgs.cpp
relax_nsync.cpp
bfgs_basic.cpp
ions_move_basic.cpp
ions_move_bfgs.cpp
ions_move_cg.cpp
ions_move_sd.cpp
ions_move_methods.cpp
lattice_change_basic.cpp
lattice_change_cg.cpp
lattice_change_methods.cpp
matrix_methods.cpp
)

if(ENABLE_COVERAGE)
Expand All @@ -28,8 +28,7 @@ endif()

if(BUILD_TESTING)
if(ENABLE_MPI)
add_subdirectory(relax_new/test)
add_subdirectory(relax_old/test)
add_subdirectory(test)
endif()

endif()
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ void Ions_Move_Methods::cal_movement(const int &istep,
const int &force_step,
const ModuleBase::matrix &f,
const double &etot,
UnitCell &ucell,
ModuleESolver::ESolver* p_esolver)
UnitCell &ucell)
{
ModuleBase::TITLE("Ions_Move_Methods", "init");

Expand Down Expand Up @@ -86,7 +85,7 @@ void Ions_Move_Methods::cal_movement(const int &istep,
}
else if(Ions_Move_Basic::relax_method == "lbfgs")
{
lbfgs.relax_step(f,ucell,etot,p_esolver);
lbfgs.relax_step(f,ucell,etot);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class Ions_Move_Methods
const int &force_step,
const ModuleBase::matrix &f,
const double &etot,
UnitCell &ucell,
ModuleESolver::ESolver* p_esolver);
UnitCell &ucell);

bool get_converged() const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ void LBFGS::allocate(const int _size) // initialize H0、H、pos0、force0、for
//l_search.init_line_search();
}

void LBFGS::relax_step(const ModuleBase::matrix _force,UnitCell& ucell,const double &etot,ModuleESolver::ESolver* p_esolver)
void LBFGS::relax_step(const ModuleBase::matrix _force,UnitCell& ucell,const double &etot)

{
get_pos(ucell,pos);
get_pos_taud(ucell,pos_taud);
solver=p_esolver;
//solver=p_esolver;
ucell.ionic_position_updated = true;
for(int i = 0; i < _force.nr; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class LBFGS
*/
void relax_step(const ModuleBase::matrix _force,
UnitCell& ucell,
const double &etot,
ModuleESolver::ESolver* p_esolver);
const double &etot);

private:
//LineSearch l_search;
Expand Down
3 changes: 1 addition & 2 deletions source/module_relax/relax_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ void Relax_Driver::relax_driver(ModuleESolver::ESolver* p_esolver, UnitCell& uce
force,
stress,
force_step,
stress_step,
p_esolver); // pengfei Li 2018-05-14
stress_step); // pengfei Li 2018-05-14
}
// print structure
// changelog 20240509
Expand Down
6 changes: 3 additions & 3 deletions source/module_relax/relax_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include "module_cell/unitcell.h"
#include "source_esolver/esolver.h"
#include "source_esolver/esolver_ks.h"
#include "relax_new/relax.h"
#include "relax_old/relax_old.h"
#include "relax_old/bfgs.h"
#include "relax_sync.h"
#include "relax_nsync.h"
#include "bfgs.h"
class Relax_Driver
{

Expand Down
25 changes: 0 additions & 25 deletions source/module_relax/relax_new/test/CMakeLists.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "relax_old.h"
#include "relax_nsync.h"

#include "module_base/global_function.h"
#include "module_base/global_variable.h"
Expand Down Expand Up @@ -28,8 +28,7 @@ bool Relax_old::relax_step(const int& istep,
ModuleBase::matrix force,
ModuleBase::matrix stress,
int& force_step,
int& stress_step,
ModuleESolver::ESolver* p_esolver)
int& stress_step)
{
ModuleBase::TITLE("Relax_old", "relax_step");

Expand All @@ -50,7 +49,7 @@ bool Relax_old::relax_step(const int& istep,
{
// do relax calculation and generate next structure
bool converged = false;
converged = this->do_relax(istep, force, energy, ucell, force_step,p_esolver);
converged = this->do_relax(istep, force, energy, ucell, force_step);
if (!converged)
{
ucell.ionic_position_updated = true;
Expand Down Expand Up @@ -130,11 +129,10 @@ bool Relax_old::do_relax(const int& istep,
const ModuleBase::matrix& ionic_force,
const double& total_energy,
UnitCell& ucell,
int& jstep,
ModuleESolver::ESolver* p_esolver)
int& jstep)
{
ModuleBase::TITLE("Relax_old", "do_relax");
IMM.cal_movement(istep, jstep, ionic_force, total_energy, ucell,p_esolver);
IMM.cal_movement(istep, jstep, ionic_force, total_energy, ucell);
++jstep;
return IMM.get_converged();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class Relax_old
ModuleBase::matrix force,
ModuleBase::matrix stress,
int& force_step,
int& stress_step,
ModuleESolver::ESolver* p_esolver);
int& stress_step);

private:
Ions_Move_Methods IMM;
Expand All @@ -31,8 +30,7 @@ class Relax_old
const ModuleBase::matrix& ionic_force,
const double& total_energy,
UnitCell& ucell,
int& jstep,
ModuleESolver::ESolver* p_esolver);
int& jstep);
bool do_cellrelax(const int& istep,
const int& stress_step,
const ModuleBase::matrix& stress,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "relax.h"
#include "relax_sync.h"


#include "module_base/matrix3.h"
Expand All @@ -8,7 +8,7 @@
#include "module_cell/print_cell.h"
#include "module_hamilt_pw/hamilt_pwdft/global.h"
#include "module_parameter/parameter.h"
#include "module_relax/relax_old/ions_move_basic.h"
#include "module_relax/ions_move_basic.h"

#include <cmath>

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
remove_definitions(-D__MPI)
remove_definitions(-D__LCAO)
remove_definitions(-D__MLALGO)
remove_definitions(-D__CUDA)
remove_definitions(-D__ROCM)

install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

AddTest(
TARGET relax_new_line_search
LIBS parameter
SOURCES line_search_test.cpp ../line_search.cpp ../../module_base/global_variable.cpp ../../module_base/global_file.cpp ../../module_base/global_function.cpp ../../module_base/memory.cpp ../../module_base/timer.cpp ../../module_base/tool_quit.cpp
)

AddTest(
TARGET relax_new_relax
SOURCES relax_test.cpp ../relax_sync.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_base.cpp ../../module_base/blas_connector_vector.cpp ../../module_base/blas_connector_matrix.cpp
../../module_cell/update_cell.cpp ../../module_cell/print_cell.cpp ../../module_cell/bcast_cell.cpp ../../module_io/output.cpp
LIBS parameter ${math_libs}
)

list(APPEND cell_source_files
../../../module_cell/update_cell.cpp
../../../module_cell/bcast_cell.cpp
../../../module_cell/print_cell.cpp
../../../module_io/output.cpp
../../module_cell/update_cell.cpp
../../module_cell/bcast_cell.cpp
../../module_cell/print_cell.cpp
../../module_io/output.cpp
)
AddTest(
TARGET lattice_change_methods_test
Expand All @@ -25,7 +47,7 @@ AddTest(
SOURCES lattice_change_cg_test.cpp
../lattice_change_cg.cpp
../lattice_change_basic.cpp
../../../module_io/orb_io.cpp
../../module_io/orb_io.cpp
)

AddTest(
Expand Down Expand Up @@ -54,7 +76,7 @@ AddTest(
../ions_move_bfgs.cpp
../ions_move_basic.cpp
../bfgs_basic.cpp
../../../module_io/orb_io.cpp
../../module_io/orb_io.cpp
${cell_source_files}
)

Expand All @@ -64,7 +86,7 @@ AddTest(
SOURCES ions_move_cg_test.cpp
../ions_move_cg.cpp
../ions_move_basic.cpp
../../../module_io/orb_io.cpp
../../module_io/orb_io.cpp
${cell_source_files}
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "module_relax/relax_old/ions_move_basic.h"
#include "module_relax/ions_move_basic.h"
#include "gmock/gmock.h"
#define private public
#include "module_parameter/parameter.h"
#undef private
#include "gtest/gtest.h"
#define private public
#define protected public
#include "module_relax/relax_old/bfgs_basic.h"
#include "module_relax/bfgs_basic.h"
#undef private
#undef protected
/************************************************
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <gtest/gtest.h>
#include "for_test.h"
#include "module_relax/relax_old/bfgs.h"
#include "module_relax/bfgs.h"
#include "module_cell/unitcell.h"
#include "module_base/matrix.h"
#include "module_relax/relax_old/ions_move_basic.h"
#include "module_relax/relax_old/matrix_methods.h"
#include "module_relax/ions_move_basic.h"
#include "module_relax/matrix_methods.h"

class BFGSTest : public ::testing::Test {
protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define private public
#include "module_parameter/parameter.h"
#undef private
#include "module_relax/relax_old/ions_move_basic.h"
#include "module_relax/ions_move_basic.h"
#include "for_test.h"

/************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#define private public
#define protected public
#include "module_parameter/parameter.h"
#include "module_relax/relax_old/ions_move_basic.h"
#include "module_relax/relax_old/ions_move_bfgs.h"
#include "module_relax/ions_move_basic.h"
#include "module_relax/ions_move_bfgs.h"
#undef private
#undef protected
/************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include "gmock/gmock.h"
#define private public
#include "module_parameter/parameter.h"
#include "module_relax/relax_old/ions_move_basic.h"
#include "module_relax/relax_old/ions_move_cg.h"
#include "module_relax/ions_move_basic.h"
#include "module_relax/ions_move_cg.h"
#undef private
/************************************************
* unit tests of class Ions_Move_CG
Expand Down
Loading
Loading