Skip to content

Add seed parameter to LAMMPS run configuration#570

Merged
jan-janssen merged 1 commit intomainfrom
langevin_seed_correction
Oct 29, 2025
Merged

Add seed parameter to LAMMPS run configuration#570
jan-janssen merged 1 commit intomainfrom
langevin_seed_correction

Conversation

@prabhath-c
Copy link
Copy Markdown
Contributor

@prabhath-c prabhath-c commented Oct 22, 2025

Langevin uses two seeds. One for initialising velocities and one for the fix itself. The seed for the fix should be present even when disable_initial_velocity is set to True

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced random seed initialization in Langevin molecular dynamics calculations to ensure consistent behavior and improved reproducibility of simulation results across different velocity initialization configurations.

Langevin uses two seeds. One for initialising velocities and one for the fix itself. The seed for the fix should be present even when `disable_initial_velocity` is set to `True`
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 22, 2025

Walkthrough

A single-line parameter addition to the LAMMPS template rendering in the Langevin molecular dynamics calculation function, passing the seed parameter when initial velocity is enabled to maintain consistency across initialization code paths.

Changes

Cohort / File(s) Summary
Langevin MD template rendering
atomistics/calculators/lammps/libcalculator.py
Added seed parameter to template rendering call in calc_molecular_dynamics_langevin_with_lammpslib when initial velocity is not disabled

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • pyiron/atomistics#517: Modifies LAMMPS input template construction for velocity initialization, including the Langevin MD pathway.

Poem

🐰 A seed sown in Langevin's dance,
Where velocities spin in entropy's trance,
Consistency blooms when parameters align—
One little fix makes the initialization shine! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Add seed parameter to LAMMPS run configuration" accurately describes the main change in the pull request. The raw summary confirms that the modification involves passing the seed parameter to the template in the Langevin MD function, and the PR objectives clarify that this is about ensuring the seed parameter is properly included in the LAMMPS run configuration. The title is concise, specific, and directly conveys the primary change without vague or noise-filled language, allowing a teammate to understand the core purpose when scanning commit history.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch langevin_seed_correction

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
atomistics/calculators/lammps/libcalculator.py (1)

439-439: LGTM! Seed correctly added for Langevin fix.

The addition of seed=seed ensures the Langevin thermostat fix receives a seed even when initial velocity initialization is disabled, which aligns with the PR objective.

Minor: Consider consistent parameter ordering.

For readability, consider matching the parameter order between the two branches. In the if block (line 418), seed comes after timestep, but here it comes before. While functionally equivalent for keyword arguments, consistency aids maintainability.

Apply this diff to align parameter order:

         input_template = Template(init_str).render(
             thermo=thermo,
             temp=Tstart,
             Tstart=Tstart,
             Tstop=Tstop,
             Tdamp=Tdamp,
-            seed=seed,
             timestep=timestep,
+            seed=seed,
         )
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60572fc and 5554504.

📒 Files selected for processing (1)
  • atomistics/calculators/lammps/libcalculator.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: unittest_grace
  • GitHub Check: unittest_matrix (ubuntu-latest, 3.14)
  • GitHub Check: unittest_matrix (ubuntu-latest, 3.11)
  • GitHub Check: unittest_matrix (ubuntu-latest, 3.13)
  • GitHub Check: unittest_matrix (ubuntu-latest, 3.12)
  • GitHub Check: unittest_old
  • GitHub Check: unittest_sphinxdft
  • GitHub Check: unittest_matrix (windows-latest, 3.14)
  • GitHub Check: unittest_matrix (macos-latest, 3.14)
  • GitHub Check: unittest_gpaw
  • GitHub Check: unittest_qe
  • GitHub Check: unittest_siesta
  • GitHub Check: unittest_mace
  • GitHub Check: notebooks
  • GitHub Check: minimal
  • GitHub Check: coverage

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.46%. Comparing base (60572fc) to head (5554504).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #570   +/-   ##
=======================================
  Coverage   85.46%   85.46%           
=======================================
  Files          43       43           
  Lines        2545     2545           
=======================================
  Hits         2175     2175           
  Misses        370      370           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Tstart=Tstart,
Tstop=Tstop,
Tdamp=Tdamp,
seed=seed,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I though the seed is only used in LAMMPS_VELOCITY, as the LAMMPS_VELOCITY is not included in the else part it should not be necessary here. Or am I missing something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So, using the disable_initial_velocity = True, without a seed, causes LAMMPS to throw an error:
ERROR: Illegal fix langevin command (src/fix_langevin.cpp:59).

On the LAMMPS documentation for the fix langevin, the command mentions a seed, that is independent of the seed for the velocities:
fix ID group-ID langevin Tstart Tstop damp seed keyword values ...

Also, in commands.py, the fix langevin command asks for a seed too:
LAMMPS_LANGEVIN = "fix ensemble all langevin {{Tstart}} {{Tstop}} {{Tdamp}} {{seed}}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

@jan-janssen jan-janssen left a comment

Choose a reason for hiding this comment

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

Looks good to me

@jan-janssen jan-janssen merged commit ed4928b into main Oct 29, 2025
50 of 51 checks passed
@jan-janssen jan-janssen deleted the langevin_seed_correction branch October 29, 2025 10:03
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