feat: #1136 - [E5-F2-P3] Add latent heat energy release tracking function with tests#1145
Conversation
Add get_latent_heat_energy_released to compute Q = dm * L with sign-preserving validation on finite mass_transfer and nonnegative latent_heat inputs. Re-export through particula.dynamics and cover precision, sign convention, zero/zero edge cases, broadcasting, and validation in tests. Closes uncscode#1136 ADW-ID: e18c0b2d
Update the docs index and README to include the latent-heat energy release bookkeeping utility alongside existing condensation helpers. Closes uncscode#1136 ADW-ID: e18c0b2d
There was a problem hiding this comment.
Pull request overview
This PR adds a small diagnostic utility to track latent-heat energy exchange from condensation/evaporation steps (using the existing sign convention), exposes it via the particula.dynamics public API, and updates docs/README to surface the capability.
Changes:
- Added
get_latent_heat_energy_released(mass_transfer, latent_heat)to compute latent heat energy bookkeeping asQ = dm * Lwith input validation. - Re-exported the helper through
particula.dynamicsfor public API access. - Added unit tests covering precision, sign convention, zero cases, broadcasting, and invalid inputs; updated docs/README references.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
particula/dynamics/condensation/mass_transfer.py |
Adds the latent heat energy bookkeeping helper with @validate_inputs and float64 output casting. |
particula/dynamics/__init__.py |
Re-exports the new helper in the particula.dynamics public API. |
particula/dynamics/condensation/tests/mass_transfer_test.py |
Adds test coverage for precision, sign, broadcasting, zeros, and validation errors for the new helper. |
readme.md |
Updates feature list to mention the new latent heat energy helper. |
docs/index.md |
Updates the homepage feature bullets to include latent-heat energy bookkeeping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ADW Code ReviewPR: #1145 - feat: #1136 - [E5-F2-P3] Add latent heat energy release tracking function with tests Summary
Critical Issues (Must Fix)None. Warnings (Should Fix)
Suggestions (Overview)
Positive Observations
Inline CommentsDetailed feedback has been posted as inline comments on the following locations:
This review was generated by ADW Multi-Agent Code Review System. |
|
WARNING: Coerce array-like inputs before multiplication
Suggested fix: mass_transfer = np.asarray(mass_transfer, dtype=np.float64)
latent_heat = np.asarray(latent_heat, dtype=np.float64)
return mass_transfer * latent_heatThis ensures elementwise math, consistent dtype, and predictable broadcasting. |
|
WARNING: Add finite validation for Validation currently allows Suggested fix: @validate_inputs(
{
"mass_transfer": "finite",
"latent_heat": "finite",
"latent_heat": "nonnegative",
}
)This prevents invalid numerical states from propagating. |
🤖 Agent Developer Workflow
Current Status
Workflow Plan
📋 Recent Activity🔍 Archived UpdatesThis comment is automatically updated as the workflow progresses |
Coerce mass transfer and latent heat inputs to float64 arrays before multiplication to avoid list repetition edge cases. Add finiteness validation for latent heat, document overflow behavior, and expand tests for list inputs, nonfinite values, and the public re-export path. Closes uncscode#1145 ADW-ID: 8f9b9041
Fix SummaryAddressed PR #1145 conversation feedback by normalizing inputs for latent heat energy bookkeeping, tightening validation, adding public re-export coverage, and documenting usage/sign conventions. Changes Made
Review Comments Addressed
Files Changed
Automated fix by ADW workflow |
Target Branch:
mainFixes #1136 | Workflow:
e18c0b2dSummary
Adds a diagnostic helper to convert condensed/evaporated mass into latent heat energy, matching the sign convention for condensation (>0) and evaporation (<0). Re-exports the helper through
particula.dynamicsand documents the non-isothermal utilities in the docs index/README. Comprehensive tests cover precision, broadcasting, and validation for invalid inputs.What Changed
New/Modified Components
particula/dynamics/condensation/mass_transfer.py— Addedget_latent_heat_energy_releasedwith validation, dtype normalization, and sign-preserving energy bookkeeping.particula/dynamics/__init__.py— Re-exported the new latent heat energy helper in the public API.particula/dynamics/condensation/tests/mass_transfer_test.py— Added precision, sign, zero-case, broadcasting, and validation tests for the new helper.readme.md,docs/index.md— Mentioned latent-heat utilities and energy bookkeeping in the feature highlights.Tests Added/Updated
mass_transfer_test.py— Precision (rtol 1e-14), sign convention, zero latent heat/mass transfer, broadcasting (1D/2D, scalar/array latent heat), and validation for negative latent heat and non-finite mass transfer.How It Works
Latent heat energy bookkeeping multiplies step-level mass transfer by latent heat while preserving sign:
Validation enforces finite
mass_transferand nonnegativelatent_heat; outputs are normalized tonp.float64and broadcast according to NumPy rules.Implementation Notes
@validate_inputs, dtype normalization vianp.asarray(..., dtype=np.float64), and sign-preserving multiplication.particula.dynamicsre-export.Testing
pytest particula/dynamics/condensation/tests/mass_transfer_test.py(new cases for energy helper covering precision, sign, broadcasting, zeros, and validation).