Reset BFGS history after cell changes#7507
Open
19hello wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
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 inIonCellOptimizer::relax_step(). - Add reset APIs to ionic optimizers (
Ions_Move_BFGS::reset(),Ions_Move_BFGS2::reset()) and wire them throughIons_Move_Methods. - Clear common convergence/iteration/energy-tracking state in
Ions_Move_Methodswhen 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; |
287755e to
26fc7b7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reminder
Linked Issue
Fix #...
Unit Tests and/or Case Tests for my changes
What's changed?
Any changes of core modules? (ignore if not applicable)