Skip to content

Reset BFGS history after cell changes#7507

Open
19hello wants to merge 2 commits into
deepmodeling:developfrom
19hello:fix-bfgs-reset-after-cell-change
Open

Reset BFGS history after cell changes#7507
19hello wants to merge 2 commits into
deepmodeling:developfrom
19hello:fix-bfgs-reset-after-cell-change

Conversation

@19hello

@19hello 19hello commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Reminder

  • Have you linked an issue with this pull request?
  • Have you added adequate unit tests and/or case tests for your pull request?
  • Have you noticed possible changes of behavior below or in the linked issue?
  • Have you explained the changes of codes in core modules of ESolver, HSolver, ElecState, Hamilt, Operator or Psi? (ignore if not applicable)

Linked Issue

Fix #...

Unit Tests and/or Case Tests for my changes

  • A unit test is added for each new feature or bug fix.

What's changed?

  • Example: My changes might affect the performance of the application under certain conditions, and I have tested the impact on various scenarios...

Any changes of core modules? (ignore if not applicable)

  • Example: I have added a new virtual function in the esolver base class in order to ...

Copilot AI review requested due to automatic review settings June 22, 2026 08:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to improve the robustness of cell-relax workflows by resetting ionic BFGS-related optimizer history whenever the unit cell changes, avoiding reuse of stale quasi-Newton state across discontinuous cell updates.

Changes:

  • Call a new Ions_Move_Methods::reset_after_cell_change() hook after cell updates in IonCellOptimizer::relax_step().
  • Add reset APIs to ionic optimizers (Ions_Move_BFGS::reset(), Ions_Move_BFGS2::reset()) and wire them through Ions_Move_Methods.
  • Clear common convergence/iteration/energy-tracking state in Ions_Move_Methods when a reset is triggered.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
source/source_relax/relax_nsync.cpp Triggers ionic optimizer reset after a cell change during cell-relax.
source/source_relax/ions_move_methods.h Declares the new reset_after_cell_change() API.
source/source_relax/ions_move_methods.cpp Implements reset logic and logging for BFGS-related methods.
source/source_relax/ions_move_bfgs.h Declares Ions_Move_BFGS::reset().
source/source_relax/ions_move_bfgs.cpp Implements BFGS state/history reset behavior.
source/source_relax/ions_move_bfgs2.h Declares Ions_Move_BFGS2::reset().
source/source_relax/ions_move_bfgs2.cpp Implements traditional BFGS2 “reinitialize on next step” reset behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +122 to +127
else if (method == "cg_bfgs")
{
reset_common_state();
this->bfgs.reset();
ofs << " Reset ionic BFGS history after cell change." << std::endl;
}
Comment on lines +99 to +105
void Ions_Move_Methods::reset_after_cell_change(const std::vector<std::string>& relax_method, std::ofstream& ofs)
{
ModuleBase::TITLE("Ions_Move_Methods", "reset_after_cell_change");

if (relax_method.empty())
{
return;
@19hello 19hello force-pushed the fix-bfgs-reset-after-cell-change branch from 287755e to 26fc7b7 Compare June 22, 2026 08:46
@mohanchen mohanchen added Bugs Bugs that only solvable with sufficient knowledge of DFT Refactor Refactor ABACUS codes labels Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugs Bugs that only solvable with sufficient knowledge of DFT Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants