Skip to content

Add n_print_dump and n_print_thermo to control dump/thermo intervals independently#378

Open
jan-janssen wants to merge 1 commit into
mainfrom
feature/independent-print-intervals
Open

Add n_print_dump and n_print_thermo to control dump/thermo intervals independently#378
jan-janssen wants to merge 1 commit into
mainfrom
feature/independent-print-intervals

Conversation

@jan-janssen

@jan-janssen jan-janssen commented Jul 24, 2026

Copy link
Copy Markdown
Member

lammps_file_interface_function() previously derived both the dump-file write interval and the thermodynamic print interval from the single n_print key in calc_kwargs. These new optional parameters let callers override each independently, defaulting to the existing behavior when left unset.

Summary by CodeRabbit

  • New Features

    • Added independent controls for dump output intervals and thermo output intervals.
    • Supports configuring these intervals separately for molecular dynamics and minimization runs.
    • Thermo interval overrides are ignored in static mode, preserving existing behavior.
  • Tests

    • Added coverage for dump and thermo interval combinations across supported run modes.

…independently

lammps_file_interface_function previously derived both the dump-file
write interval and the thermodynamic print interval from the single
n_print key in calc_kwargs. These new optional parameters let callers
override each independently, defaulting to the existing behavior when
left unset.
@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.77%. Comparing base (dc0d21b) to head (a45d878).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #378   +/-   ##
=======================================
  Coverage   98.77%   98.77%           
=======================================
  Files          13       13           
  Lines        1223     1226    +3     
=======================================
+ Hits         1208     1211    +3     
  Misses         15       15           

☔ View full report in Codecov by Harness.
📢 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.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The compatibility interface now accepts separate dump and thermo intervals. MD input generation uses these values independently, while static mode keeps thermo output unchanged. Tests cover the new behavior across MD, minimize, and static execution modes.

Changes

Output interval overrides

Layer / File(s) Summary
Interval parameters and scheduling
src/lammpsparser/compatibility/file.py
lammps_file_interface_function adds n_print_dump and n_print_thermo; MD dump boundaries use the dump interval while thermo output uses the thermo override.
Generated input validation
tests/test_compatibility_file.py
Tests verify generated dumptime and thermotime values for MD, minimize, and static modes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding separate n_print_dump and n_print_thermo controls for dump and thermo intervals.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/independent-print-intervals

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
tests/test_compatibility_file.py (2)

755-778: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the independent final-dump decision.

These tests verify dumptime, but not the changed Line 211 behavior. Add a case with n_print=100, n_print_dump=50, n_ionic_steps=950, and dump_final_structure=True; the generated input should not contain write_dump because 950 is divisible by 50.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_compatibility_file.py` around lines 755 - 778, Extend
test_n_print_dump_override_md to use n_ionic_steps=950 and
dump_final_structure=True while keeping n_print=100 and n_print_dump=50, then
assert the generated lmp.in does not contain “write_dump”. Preserve the existing
dumptime and thermotime assertions.

762-762: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use dummy bindings for unused test outputs.

Ruff flags shell_output and parsed_output in all five new tests. Replace them with _ or underscore-prefixed names.

Proposed cleanup
-        shell_output, parsed_output, job_crashed = lammps_file_interface_function(
+        _, _, job_crashed = lammps_file_interface_function(

Also applies to: 787-787, 812-812, 836-836, 856-856

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_compatibility_file.py` at line 762, Update all five new test calls
to lammps_file_interface_function so unused shell_output and parsed_output
results use dummy bindings such as underscores or underscore-prefixed names,
while preserving job_crashed and the existing test behavior.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lammpsparser/compatibility/file.py`:
- Around line 125-129: Validate the effective dump interval selected by
dump_interval and n_print_thermo before generating the LAMMPS input: each must
be an integer greater than zero, rejecting zero, negative, and non-integer
values with a clear validation error. Apply the checks in the relevant
input-generation flow before the interval is used at the schedule calculation
around line 211, and add failure tests covering invalid values.

---

Nitpick comments:
In `@tests/test_compatibility_file.py`:
- Around line 755-778: Extend test_n_print_dump_override_md to use
n_ionic_steps=950 and dump_final_structure=True while keeping n_print=100 and
n_print_dump=50, then assert the generated lmp.in does not contain “write_dump”.
Preserve the existing dumptime and thermotime assertions.
- Line 762: Update all five new test calls to lammps_file_interface_function so
unused shell_output and parsed_output results use dummy bindings such as
underscores or underscore-prefixed names, while preserving job_crashed and the
existing test behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e3a00e55-efef-4ae8-8e0d-68684949c467

📥 Commits

Reviewing files that changed from the base of the PR and between dc0d21b and a45d878.

📒 Files selected for processing (2)
  • src/lammpsparser/compatibility/file.py
  • tests/test_compatibility_file.py

Comment on lines +125 to +129
dump_interval = (
n_print_dump if n_print_dump is not None else calc_kwargs.get("n_print", 1)
)
if n_print_thermo is not None:
calc_kwargs["n_print"] = n_print_thermo

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Reject invalid output intervals before generating the input.

n_print_dump=0 reaches Line 211 and causes ZeroDivisionError; non-positive or non-integer values can also generate invalid LAMMPS schedules. Validate the effective dump interval and n_print_thermo as positive integers, and add failure tests.

Proposed validation
     dump_interval = (
         n_print_dump if n_print_dump is not None else calc_kwargs.get("n_print", 1)
     )
+    if type(dump_interval) is not int or dump_interval <= 0:
+        raise ValueError("Dump interval must be a positive integer")
     if n_print_thermo is not None:
+        if type(n_print_thermo) is not int or n_print_thermo <= 0:
+            raise ValueError("Thermo interval must be a positive integer")
         calc_kwargs["n_print"] = n_print_thermo

Also applies to: 166-166, 211-211

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lammpsparser/compatibility/file.py` around lines 125 - 129, Validate the
effective dump interval selected by dump_interval and n_print_thermo before
generating the LAMMPS input: each must be an integer greater than zero,
rejecting zero, negative, and non-integer values with a clear validation error.
Apply the checks in the relevant input-generation flow before the interval is
used at the schedule calculation around line 211, and add failure tests covering
invalid values.

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.

1 participant