feat: #1135 - [E5-F2-P2] Add non-isothermal mass transfer rate function with tests#1144
Conversation
Add get_mass_transfer_rate_latent_heat using the thermal resistance factor and preserve isothermal parity when latent heat is zero. Export the function through particula.dynamics and expand mass_transfer tests to cover parity, rate reduction, broadcasting, and validation errors. Closes uncscode#1135 ADW-ID: 12b5f7df
Update E5-F2 planning docs and epic metadata to reflect the active P2 phase. Refresh public-facing docs and README highlights for latent-heat mass transfer utilities, and refine the mass-transfer docstring for consistency. Closes uncscode#1135 ADW-ID: 12b5f7df
There was a problem hiding this comment.
Pull request overview
Adds a latent-heat-aware (non-isothermal) mass transfer rate helper to the condensation dynamics utilities, re-exported through particula.dynamics, and expands unit test coverage to lock in isothermal parity and non-isothermal behavior.
Changes:
- Added
get_mass_transfer_rate_latent_heat()that applies the Phase 1 thermal resistance correction while preserving exact isothermal parity whenlatent_heat=0. - Re-exported the new helper from
particula.dynamicsfor public API access. - Extended condensation mass transfer tests to cover parity, reduction, broadcasting, and validation; refreshed related docs/dev-plan indices.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| readme.md | Updates feature bullets to mention the new latent-heat mass transfer helper. |
| particula/dynamics/condensation/mass_transfer.py | Adds get_mass_transfer_rate_latent_heat() wrapping isothermal rate with thermal resistance correction. |
| particula/dynamics/init.py | Re-exports get_mass_transfer_rate_latent_heat via the public dynamics API. |
| particula/dynamics/condensation/tests/mass_transfer_test.py | Adds unit tests for parity, reduction, broadcasting, and validation of the new helper. |
| docs/index.md | Updates docs landing page to mention non-isothermal condensation support. |
| adw-docs/dev-plans/features/index.md | Marks E5-F2 as in progress. |
| adw-docs/dev-plans/features/E5-F2-non-isothermal-mass-transfer.md | Updates phase status/details and links to issue #1135. |
| adw-docs/dev-plans/epics/E5-non-isothermal-condensation.md | Refreshes epic status context with the in-progress phase reference. |
| adw-docs/dev-plans/README.md | Updates dev-plan index to show E5-F2 as in progress. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Args: | ||
| pressure_delta: Difference in partial pressure [Pa]. | ||
| first_order_mass_transport: Mass transport coefficient K [m³/s]. | ||
| temperature: Temperature T [K]. | ||
| molar_mass: Molar mass M [kg/mol]. | ||
| latent_heat: Latent heat of vaporization L [J/kg]. | ||
| thermal_conductivity: Gas thermal conductivity kappa [W/(m·K)]. | ||
| vapor_pressure_surface: Equilibrium vapor pressure at the surface | ||
| [Pa]. | ||
| diffusion_coefficient: Vapor diffusion coefficient D [m²/s]. | ||
|
|
||
| Returns: | ||
| Non-isothermal mass transfer rate [kg/s], matching the broadcasted | ||
| input shape. | ||
|
|
||
| Raises: | ||
| ValueError: If any validated inputs violate positive/nonnegative |
There was a problem hiding this comment.
Docstring section headers here use "Args:" while the surrounding functions in this module use the "Arguments:" / "Returns:" format (often with leading hyphen bullets). To keep the documentation style consistent (and avoid doc rendering inconsistencies), please align this docstring’s section headers/format with the rest of mass_transfer.py (e.g., change "Args:" to "Arguments:" and match bullet styling).
| Args: | |
| pressure_delta: Difference in partial pressure [Pa]. | |
| first_order_mass_transport: Mass transport coefficient K [m³/s]. | |
| temperature: Temperature T [K]. | |
| molar_mass: Molar mass M [kg/mol]. | |
| latent_heat: Latent heat of vaporization L [J/kg]. | |
| thermal_conductivity: Gas thermal conductivity kappa [W/(m·K)]. | |
| vapor_pressure_surface: Equilibrium vapor pressure at the surface | |
| [Pa]. | |
| diffusion_coefficient: Vapor diffusion coefficient D [m²/s]. | |
| Returns: | |
| Non-isothermal mass transfer rate [kg/s], matching the broadcasted | |
| input shape. | |
| Raises: | |
| ValueError: If any validated inputs violate positive/nonnegative | |
| Arguments: | |
| - pressure_delta: Difference in partial pressure [Pa]. | |
| - first_order_mass_transport: Mass transport coefficient K [m³/s]. | |
| - temperature: Temperature T [K]. | |
| - molar_mass: Molar mass M [kg/mol]. | |
| - latent_heat: Latent heat of vaporization L [J/kg]. | |
| - thermal_conductivity: Gas thermal conductivity kappa [W/(m·K)]. | |
| - vapor_pressure_surface: Equilibrium vapor pressure at the surface | |
| [Pa]. | |
| - diffusion_coefficient: Vapor diffusion coefficient D [m²/s]. | |
| Returns: | |
| - Non-isothermal mass transfer rate [kg/s], matching the broadcasted | |
| input shape. | |
| Raises: | |
| - ValueError: If any validated inputs violate positive/nonnegative |
ADW Code ReviewPR: #1144 - feat: #1135 - [E5-F2-P2] Add non-isothermal mass transfer rate 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: Guard invalid thermal correction factor
Suggested fix: if thermal_factor <= 0:
raise ValueError("thermal_factor must be positive")This ensures the correction remains physical and avoids divide-by-zero/negative factors. |
|
WARNING: Avoid extra copy in return
Suggested fix: return np.asarray(result)This reduces allocations in hot paths. |
|
WARNING: Docstring should use Google-style Args/Returns
Suggested fix: Args:
...
Returns:
...This keeps docstrings consistent with repo conventions. |
🤖 Agent Developer Workflow
Current Status
Workflow Plan
📋 Recent Activity🔍 Archived UpdatesThis comment is automatically updated as the workflow progresses |
Add a non-positive thermal factor check to prevent invalid non-isothermal corrections and update mass transfer helpers for consistent docstrings and array handling. Add validation coverage for diffusion, conductivity, and surface pressure inputs, and refresh dev-plan status notes. Closes uncscode#1144 ADW-ID: 86e769a4
Fix SummaryAddressed actionable review feedback for non-isothermal mass transfer updates, including docstring alignment, validation guards, and test coverage for thermal inputs. Changes Made
Review Comments Addressed
(Review comment IDs were not recorded in the workflow state; items are summarized from the spec plan.) Files Changed
Automated fix by ADW workflow |
Target Branch:
mainFixes #1135 | Workflow:
12b5f7dfSummary
Adds a latent-heat-aware mass transfer rate helper that preserves exact isothermal parity while applying the thermal resistance correction from Phase 1. Re-exports the function through
particula.dynamicsand extends the condensation tests to lock parity, magnitude reduction, broadcasting, and validation behaviors. Dev-plan and docs indices were refreshed to reflect the new non-isothermal capability.What Changed
New Components
Modified Components
particula/dynamics/condensation/mass_transfer.py- Addedget_mass_transfer_rate_latent_heat, applying the thermal resistance factor and preserving isothermal parity when latent heat is zero.particula/dynamics/__init__.py- Re-exportedget_mass_transfer_rate_latent_heatfor public API access.particula/dynamics/condensation/tests/mass_transfer_test.py- Added parity, reduction, broadcasting, and validation tests for the new function.adw-docs/dev-plans/features/E5-F2-non-isothermal-mass-transfer.mdand indices (adw-docs/dev-plans/README.md,adw-docs/dev-plans/features/index.md,docs/index.md,readme.md) - Documented the feature and links.Tests Added/Updated
particula/dynamics/condensation/tests/mass_transfer_test.py- Isothermal parity (scalar/array), rate reduction for latent heat > 0, water 293 K reference, shape broadcasting mix, and validation error coverage for latent heat, temperature, and molar mass.How It Works
get_mass_transfer_rate_latent_heatwraps the existing isothermal rate and divides by the thermal resistance factor baseline to preserve parity and apply latent-heat slowdown:Implementation Notes
latent_heat = 0,correction = 1so the result matchesget_mass_transfer_ratetortol=1e-15(locked by tests).np.asarrayon all inputs; validation through@validate_inputsmirrors existing constraints and adds thermal parameters.Testing
pytest particula/dynamics/condensation/tests/mass_transfer_test.py