Skip to content

fix: #1096 - [M6-P3] Move diagnostics into repo and add charged coagulation integration tests#1100

Merged
Gorkowski merged 2 commits intouncscode:mainfrom
Gorkowski:issue-1096-adw-fae84b4c
Feb 25, 2026
Merged

fix: #1096 - [M6-P3] Move diagnostics into repo and add charged coagulation integration tests#1100
Gorkowski merged 2 commits intouncscode:mainfrom
Gorkowski:issue-1096-adw-fae84b4c

Conversation

@Gorkowski
Copy link
Collaborator

Target Branch: main

Fixes #1096 | Workflow: fae84b4c

Summary

Convert the charged coagulation diagnostics into real pytest coverage with conservation and physical-behavior assertions. Three end-to-end charged coagulation scenarios now assert mass/charge conservation and merger outcomes, and the kernel interpolation diagnostic now checks mixed-charge kernel accuracy instead of printing. This locks in regression protection for the charged coagulation changes from M6.

What Changed

Modified Components

  • particula/integration_tests/charged_coagulation_comparison_test.py � refactored into three parameterized scenarios (same-sign, neutral, opposite-sign with direct kernel) returning structured results, asserting merger counts, and enforcing mass/charge conservation.
  • particula/dynamics/coagulation/tests/kernel_interpolation_diagnostic_test.py � rewrote scenarios 4�6 to assert direct vs interpolated kernel values for repulsive, neutral, and attractive charge pairs with explicit tolerances (no print diagnostics).

Tests Added/Updated

  • particula/integration_tests/charged_coagulation_comparison_test.pytest_same_sign_ions_no_mergers, test_neutral_ions_brownian_baseline, test_opposite_sign_ions_direct_kernel.
  • particula/dynamics/coagulation/tests/kernel_interpolation_diagnostic_test.pytest_coag_same_sign_repulsive, test_coag_neutral_ions, test_coag_opposite_sign_attractive.

How It Works

  • Charged coagulation integration helper returns merger counts and conservation metrics; each scenario fixes seeds/particle counts and asserts the expected merger pattern (repulsive zeroes, Brownian baseline, direct-kernel attraction) plus rtol=1e-10 conservation.
  • Kernel interpolation diagnostic builds charge-aware kernel matrices, interpolates radius-only kernels, and compares to direct evaluations; assertions capture the repulsive suppression, neutral baseline alignment, and attractive enhancement with tight tolerances.

Implementation Notes

  • Same-sign scenario aligns ion charge with the calcite charge (-6) to match the fixture; issue text noted +6 but conservation/behavior are verified against the actual calcite charge used.
  • Opposite-sign case explicitly sets use_direct_kernel=True to avoid spurious same-sign mergers, per M6 acceptance.
  • Tolerances are tightened around the observed kernel scales (e.g., 1e-6 relative at ~1e-15 values) to keep the tests stable and warning-free under -Werror.

Testing

  • pytest particula/integration_tests/charged_coagulation_comparison_test.py -Werror -v
  • pytest particula/dynamics/coagulation/tests/kernel_interpolation_diagnostic_test.py -Werror -v
  • pytest (full suite)

Convert charged coagulation and kernel interpolation diagnostics into
asserted pytest scenarios. Add conservation checks, kernel comparisons,
and direct-kernel validation for opposite-sign cases to ensure physical
behavior is enforced.

Closes uncscode#1096

ADW-ID: fae84b4c
Copilot AI review requested due to automatic review settings February 25, 2026 01:50
@Gorkowski Gorkowski added agent Created or managed by ADW automation blocked Blocked - review required before ADW can process labels Feb 25, 2026
Copy link
Contributor

Copilot AI left a comment

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 converts charged coagulation diagnostic tests from print-only output into proper pytest tests with quantitative assertions. It refactors two test files to verify mass/charge conservation and physical behavior for charged particle coagulation, providing regression protection for the M6 charged coagulation fixes.

Changes:

  • Converted charged_coagulation_comparison_test.py into three parameterized test scenarios with conservation and merger assertions
  • Refactored kernel_interpolation_diagnostic_test.py scenarios 4-6 to assert kernel accuracy instead of printing diagnostics

Reviewed changes

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

File Description
particula/integration_tests/charged_coagulation_comparison_test.py Refactored into three test functions (same-sign, neutral, opposite-sign) with mass/charge conservation assertions and merger count validation
particula/dynamics/coagulation/tests/kernel_interpolation_diagnostic_test.py Removed print diagnostics, added assertions for kernel values comparing direct vs interpolated calculations

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

Comment on lines +198 to +205
"""Neutral ions and neutral calcite follow Brownian baseline."""
results = _run_coagulation(
ion_charge=0.0,
use_direct_kernel=False,
n_steps=5,
calcite_count=120,
ion_count=40,
calcite_charge=0.0,
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

The neutral ions test case should have charged calcite particles (charge -6) to match the scenario described in the issue. Currently, this test sets calcite_charge=0.0, which tests an all-neutral scenario rather than the intended "neutral ions with charged calcite" baseline. This deviates from the acceptance criteria which specifies "Neutral ions (0): some ion-calcite mergers, some calcite-calcite mergers (Brownian baseline)" where calcite should maintain its -6 charge. Change calcite_charge to -6.0 to match the intended test scenario.

Suggested change
"""Neutral ions and neutral calcite follow Brownian baseline."""
results = _run_coagulation(
ion_charge=0.0,
use_direct_kernel=False,
n_steps=5,
calcite_count=120,
ion_count=40,
calcite_charge=0.0,
"""Neutral ions with charged calcite follow Brownian baseline."""
results = _run_coagulation(
ion_charge=0.0,
use_direct_kernel=False,
n_steps=5,
calcite_count=120,
ion_count=40,
calcite_charge=-6.0,

Copilot uses AI. Check for mistakes.


def test_neutral_ions_brownian_baseline():
"""Neutral ions and neutral calcite follow Brownian baseline."""
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

The docstring states "Neutral ions and neutral calcite follow Brownian baseline" but the acceptance criteria and issue description indicate this test should verify neutral ions (charge 0) interacting with charged calcite (charge -6). The docstring should be updated to reflect the correct scenario: "Neutral ions with charged calcite follow Brownian baseline" or similar phrasing that makes clear calcite should be charged.

Suggested change
"""Neutral ions and neutral calcite follow Brownian baseline."""
"""Neutral ions with charged calcite follow Brownian baseline."""

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

@Gorkowski Gorkowski left a comment

Choose a reason for hiding this comment

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

fix test units

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

convert to the default units as, pint is not aviable in ci/cd

@Gorkowski Gorkowski added request:fix Request AI to implement review suggestions adw:in-progress ADW workflow actively processing - remove to re-trigger and removed blocked Blocked - review required before ADW can process labels Feb 25, 2026
@Gorkowski
Copy link
Collaborator Author

Gorkowski commented Feb 25, 2026

🤖 Agent Developer Workflow

  • Description: Direct PR fix workflow triggered by request:fix label. Analyzes actionable review comments, generates fix plan, implements changes, validates, polishes, tests, formats, and ships fixes without creating intermediate GitHub issues.
  • ADW ID: fa511aaf
  • Current Phase: Workflow completed successfully
  • Current Step: Analyze actionable PR review comments and generate implementation plan
  • Started: 2026-02-25T02:01:20.053668Z
  • Last Update: 2026-02-25T02:18:24.878116Z

Current Status

  • Workflow completed in 17m 3s

Workflow Plan

  • ✅ Analyze PR Comments (at 2026-02-25T02:02:02.949911Z)
  • ✅ Build Implementation (at 2026-02-25T02:04:53.038816Z)
  • ✅ Validate Implementation and Fix Gaps (at 2026-02-25T02:05:55.810916Z)
  • ✅ Polish Code (at 2026-02-25T02:06:46.965792Z)
  • ✅ Run Tests (at 2026-02-25T02:16:42.159269Z)
  • ✅ Format Code and Add Docstrings (at 2026-02-25T02:17:24.083789Z)
  • ✅ Ship Fix (at 2026-02-25T02:18:23.129197Z)
📋 Recent Activity
[2026-02-25T02:05:55.810934Z] Completed step 3/7: Validate Implementation and Fix Gaps
[2026-02-25T02:05:57.445573Z] Starting step 4/7: Polish Code
[2026-02-25T02:06:46.965807Z] Completed step 4/7: Polish Code
[2026-02-25T02:06:48.562661Z] Starting step 5/7: Run Tests
[2026-02-25T02:16:42.159284Z] Completed step 5/7: Run Tests
[2026-02-25T02:16:44.003739Z] Starting step 6/7: Format Code and Add Docstrings
[2026-02-25T02:17:24.083809Z] Completed step 6/7: Format Code and Add Docstrings
[2026-02-25T02:17:25.724011Z] Starting step 7/7: Ship Fix
[2026-02-25T02:18:23.129213Z] Completed step 7/7: Ship Fix
[2026-02-25T02:18:24.875622Z] Workflow pr-fix finished: 7/7 steps completed
🔍 Archived Updates
[2026-02-25T02:01:20.154382Z] Workflow pr-fix started with 7 steps
[2026-02-25T02:01:22.247414Z] Starting step 1/7: Analyze PR Comments
[2026-02-25T02:02:02.949926Z] Completed step 1/7: Analyze PR Comments
[2026-02-25T02:02:04.690958Z] Starting step 2/7: Build Implementation
[2026-02-25T02:04:53.038834Z] Completed step 2/7: Build Implementation
[2026-02-25T02:04:54.777833Z] Starting step 3/7: Validate Implementation and Fix Gaps

This comment is automatically updated as the workflow progresses

Swap the charged coagulation atmosphere setup to use default
SI inputs instead of pint-based units, aligning with CI defaults.
Update the neutral-ions scenario docstring and set calcite charge
to -6.0 to match the charged calcite baseline.

Closes uncscode#1100

ADW-ID: fa511aaf
@Gorkowski Gorkowski merged commit d50097e into uncscode:main Feb 25, 2026
7 checks passed
@Gorkowski Gorkowski deleted the issue-1096-adw-fae84b4c branch February 25, 2026 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adw:in-progress ADW workflow actively processing - remove to re-trigger agent Created or managed by ADW automation request:fix Request AI to implement review suggestions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[M6-P3] Move diagnostics into repo and add charged coagulation integration tests

2 participants