[WIP] add radiation momentum deposition in photoionization#2007
[WIP] add radiation momentum deposition in photoionization#2007BenWibking wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new test case (DTypeFrontVC) and implements the O(v/c) radiation-pressure work term in the photochemistry solver to deposit absorbed photon momentum into the gas. Feedback on these changes highlights two issues: first, a critical bug in photochemistry.hpp where the momentum update is not scaled by energy_update_factor during multi-stage integration (while the kinetic energy subtraction is), which violates energy conservation; second, a potential division-by-zero in the test file if no chem-band flux is absorbed.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| const amrex::Real rel_err = std::abs(check.gas_px - check.expected_px) / check.expected_px; | ||
| const amrex::Real transverse_momentum = std::sqrt(check.gas_py * check.gas_py + check.gas_pz * check.gas_pz); | ||
| const amrex::Real transverse_rel = transverse_momentum / check.expected_px; |
There was a problem hiding this comment.
If no chem-band flux is absorbed (e.g., due to a setup failure or bug), check.expected_px will be 0.0_rt. This will cause a division-by-zero when computing rel_err and transverse_rel, resulting in NaN or inf values. It is safer to guard these divisions by checking if check.expected_px > 0.0_rt.
const amrex::Real rel_err = (check.expected_px > 0.0_rt) ? (std::abs(check.gas_px - check.expected_px) / check.expected_px) : std::numeric_limits<amrex::Real>::infinity();
const amrex::Real transverse_momentum = std::sqrt(check.gas_py * check.gas_py + check.gas_pz * check.gas_pz);
const amrex::Real transverse_rel = (check.expected_px > 0.0_rt) ? (transverse_momentum / check.expected_px) : std::numeric_limits<amrex::Real>::infinity();|
/azp run quick |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Description
Please write a short paragraph describing what changes this pull request makes to the code. It should provide sufficient context so that a reviewer can efficiently browse the source code changes.
Related issues
Fixes #1988.
Checklist
Before this pull request can be reviewed, all of these tasks should be completed. Denote completed tasks with an
xinside the square brackets[ ]in the Markdown source below:/azp run.