Skip to content

refactor(md): inline PLUMED data preparation in MD step - #8323

Open
19hello wants to merge 1 commit into
deepmodeling:developfrom
19hello:refactor/inline-plumed-md-adapter
Open

19hello wants to merge 1 commit into
deepmodeling:developfrom
19hello:refactor/inline-plumed-md-adapter

Conversation

@19hello

@19hello 19hello commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Reminder

  • I have read AGENTS.md and docs/developers_guide/agent_governance.md.
  • I have linked an issue or explained why this PR does not need one.
  • I have added adequate unit tests and/or case tests, or explained why not.
  • I have listed the exact verification commands run and their results.
  • I have described user-visible behavior changes, including INPUT parameter changes.
  • I have explained core-module impact for ESolver, HSolver, ElecState, Hamilt, Operator, Psi, or other source/ changes.
  • I have requested any needed governance exception below.

Linked Issue

No issue is needed for this small, behavior-preserving cleanup of code introduced by #8057.

Unit Tests and/or Case Tests for my changes

  • Commands run:
    • cmake --build build_parallel_md1_current --target md -j4 — passed.
    • cmake --build build_parallel_md1_current --target MODULE_MD_run -j4 — passed.
    • ctest --test-dir build_parallel_md1_current -R '^MODULE_MD_run$' --output-on-failure — passed, 1/1 test.
    • git diff --cached --check — passed.
    • python3 tools/03_code_analysis/agent_governance_check.py --staged — passed with test-evidence and documentation-review warnings.
  • No new test was added because this change only moves the existing data preparation and force write-back code into its sole call site, preserving the order and unit conversions. The existing MD run unit test was rebuilt and run.
  • Checks not run, with reason: a PLUMED-enabled MD case was not available in the configured local build (ENABLE_PLUMED=OFF).

What's changed?

  • Inline four single-use PLUMED data adapter functions into run_plumed_step in source/source_md/run_md.cpp.
  • Combine position and force collection over the same owned-atom list. Preserve Bohr conversion, row-major cell layout, and force write-back after plumed.move.
  • No user-visible behavior or INPUT parameter changes.

Governance Notes

  • INPUT/docs changes: none; interfaces and behavior are unchanged, so no documentation update is needed.
  • Core module impact: limited to source/source_md/run_md.cpp; no changes to ESolver, HSolver, ElecState, Hamilt, Operator, or Psi.
  • Exceptions requested: none.

@ABACUS-PR-BOT ABACUS-PR-BOT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The inlined adapter preserves the prior packing, unit conversions and call order by static inspection. No build or runtime test was run in this review; PLUMED-enabled behavior remains unverified.

collect_plumed_cell(mdcell, plumed_cell);
std::vector<LocalAtom>& atoms = mdcell.owned_atoms();
const double lat0 = mdcell.lat0();
plumed_positions.resize(atoms.size());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking: The cited MODULE_MD_run tests cover cell preparation and output cadence without calling md_line, so they do not exercise these buffer conversions or force write-back. A focused adapter test with distinct atoms, a non-unit lat0, an off-diagonal cell and a known bias-force update would protect this boundary; an enabled PLUMED case or a controlled test double could exercise it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants