-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
A robust numerical scheme for the dust-gas coupling model #733
Conversation
for more information, see https://pre-commit.ci
…b.com/quokka-astro/quokka into chong/seperate-single-and-multi-group
for more information, see https://pre-commit.ci
…b.com/quokka-astro/quokka into chong/seperate-single-and-multi-group
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…astro/quokka into chong/dust-multigroup-v2
for more information, see https://pre-commit.ci
@markkrumholz You can start to review this PR. I'll try to merge this in once #731 is merged. |
@chongchonghe @markkrumholz Before adding an very elaborate and baroque scheme that uses different numerical methods in different stiffness regimes, I think it would be worth investigating adding backtracking to the Newton-Raphson solver would help: #11 |
for more information, see https://pre-commit.ci
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks fine.
Two questions:
- How did you determine 1e-6 as the threshold value to switch between the two dust solver? Is there a way to set this threshold based on an error tolerance for the dust temperature directly?
- In your description of the test problem, you say this: "The IR opacity is set to a large number so that there is zero diffusion." I don't understand how there is zero diffusion with a large opacity. Can you explain?
This threshold is determined empirically through testing the algorithm for a range of gas density and temperature. If we I set a lower number, at moderate density the algorithm falls into the well-coupled regime and fails to converge. We also want to set this number as low as possible to avoid truncations error due to the choice of the decoupled assumption. I agree that we need to justify the choice of this number by estimating the relative error. Because this transition happens in the intermediate regime, it's hard to design a test with an exact solution. I plan to do a simple analytic analysis. Bate & Keto (2015) did a similar trick by dealing the coupled and poorly coupled regime separately. They described their choice of transition condition (above Eq. 57) without justification. However, their equations is much simpler because they use single-group radiation so they don't have to worry about redistribution of radiation in frequency space by dust. In single-group RHD, our "well-coupled regime" scheme works for all regimes.
The diffusion coefficient of material with opacity |
Ok, that would be good. It should be possible to estimate from the next-to-leading order term.
I would call this a regime where the diffusion is arbitrarily slow, rather than zero. To me, "zero diffusion" makes it sound like it is streaming, rather than just very slowly diffusion. |
Here's an estimation of the 'error' of the decoupled approximation. It's not an error per se. Every numerical scheme to solve PDE has an error. All I did here is to use forward Euler as opposed to backward Euler for gas temperature update, and the relative change in the temperature is at most 10^-6, determined by that threshold parameter, so it's very stable. Here's why. In the decoupled regime, we use the following equation to update the gas temperature via the Forward Euler scheme: and The parameter |
The relative error on gas temperature introduced by the photoionization scheme from the RAMSES paper will be 5 orders of magnitude bigger than this (their ten-percent rule), and we will probably have to do something similar. So, be prepared for that. |
|
If we need to do adaptive error control, I think the radiation-matter exchange solver should just be moved into Microphysics. I will create a Slack channel to discuss this. |
I think the right thing to do here is adaptively control the relative error based on explicit computation of the of the higher-order terms in an expansion of the solution in the dust-gas coupling constant. But that can be done in a future PR. |
Ok, I've edited the PR description to say that diffusion is "extremely slow" instead of "zero". I will approve the PR, assuming tests pass. |
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
### Description In this PR, I implement photoelectric heating within the current gas-radiation-dust interaction framework. PE can be enabled by setting `enable_photoelectric_heating = true` in `ISM_Traits`. The prerequisite is `nGroups > 1` and `enable_dust_gas_thermal_coupling_model = true`. Added two test problems, `RadiationMarshakDustPE-coupled` and `RadiationMarshakDustPE-decoupled`, to test photoelectric heating in cases where gas and dust are well coupled and decoupled. These two tests share the same problem code `test_radiation_marshak_dust_and_PE.cpp` but use different runtime parameters. Here is the code structure: ``` - AddSourceTermsMultiGroup - outer loop: - compute `v_times_F_term` - solve gas-dust-radiation energy exchange: - if constexpr (!enable_dust_gas_thermal_coupling_model_) - `SolveGasRadiationEnergyExchange`: - The matter-radiation coupling scheme from the multigroup paper - else if constexpr (!enable_photoelectric_heating_) - `SolveGasDustRadiationEnergyExchange()`: - The gas-dust-radiation coupling scheme proposed in #733, which has two cases: the well-coupled case and decoupled case - else - `SolveGasDustRadiationEnergyExchangeWithPE()`: - Based on the gas-dust-radiation coupling scheme, but with modified Jacobian in the well-coupled case to include PE heating. In the decoupled case, PE heating is added via a forward-Euler update using the updated radiation energy density after the gas-dust-radiation step. - compute updated `v_times_F_term` - if `v_times_F_term` has converged, break - `UpdateFlux()` ``` ### Related issues A modification to #733 to include PE heating. ### Checklist _Before this pull request can be reviewed, all of these tasks should be completed. Denote completed tasks with an `x` inside the square brackets `[ ]` in the Markdown source below:_ - [x] I have added a description (see above). - [x] I have added a link to any related issues see (see above). - [x] I have read the [Contributing Guide](https://github.com/quokka-astro/quokka/blob/development/CONTRIBUTING.md). - [x] I have added tests for any new physics that this PR adds to the code. - [x] I have tested this PR on my local computer and all tests pass. - [x] I have manually triggered the GPU tests with the magic comment `/azp run`. - [x] I have requested a reviewer for this PR. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Description
In this PR, we solve the dust coupling to the gas and radiation in two different regimes: the well-coupled regime and the low-density, poorly-coupled regime.
Changes to the code
ComputeJacobianForGasAndDustDecoupled
to compute the Jacobian for the gas-dust-radiation system in the regime where gas and dust are decoupled.lambda_gd_times_dt
toSolveMatterRadiationEnergyExchange
.lambda_gd_times_dt
isdust_model
toSolveMatterRadiationEnergyExchange
. Unfortunately, the energy-exchange system becomes complicated and you can't deal with all three dust models by passing functions toSolveMatterRadiationEnergyExchange
.dust_model
takes three values, representing a gas-dust-radiation system in different regimes:T_d = T_gas
, and we solve a system that involves T_gas and Erad. This is the model used in Wibking & Krumholz (2022), He, Wibking & Krumholz (2024a) and He, Wibking & Krumholz (2024b).dust_model = 0
is enabled by settingenable_dust_gas_thermal_coupling_model_ = false
. Otherwise,dust_model = 1
ordust_model = 2
is determined automatically in the code on a cell-by-cell basis. See the description below.Alternative things to do
threshold_for_dust_gas_coupling
a runtime parameter. This is the parameter to control when to switch between dust model 1 and 2.Physics
In the well-coupled regime, we solve the following equations:
where$\Lambda_{\mathrm{gd}}$ is the thermal interaction rate due to collisions between the gas and the dust, which we take the rate of Keto & Field (2005)
where$\Theta_{\mathrm{gd}} = 2.5 \times 10^{-34} \mathrm{erg \ cm^3 \ s^{-1} \ K^{-3/2}}$ . This parameter can be specified in arbitrary units by the user. As in most literature, we assume that the dust is in LTE with the total radiation field (e.g. Bate & Keto 2015):
We can then define a similar set of independent variables as in the IMEX paper,$(E_{\rm gas}, R_g), g = 1, 2, ..., N_g$ , where
and solve for the following set of equations using Newton-Raphson iteration:
This is similar to the original gas-only scheme, except that the gas temperature$T$ is replaced with $T_d$ .
We still need to calculate the dust temperature$T_d$ . In the first step of the iteration, we solve for $T_d$ given $T$ and $E_g$ via combining Equation (1) and (2). Then, later in the iteration, we solve for $T_d$ via a simple relation:
where we have defined$N_{\rm gd} \equiv (\hat{c}/c) \Delta t \Theta_{\rm gd} n_H^2$ . Apparently,
Equation (4) also gives a simple formula for$d T_d / d T$ , which is used in the computation of the Jacobian. Further, the Jacobian is no longer sparse. However, I did a trick to analytically simplify the Jacobian matrix via Gauss-Jordan elimination to make it sparse so that we can use the numerical scheme in the multigroup paper. More details in Overleaf document "quokka-thermochemistry".
In the decoupled regime where$N_{\rm gd}$ is small, however, this scheme failed. This is obvious from Equation (5): even a small value of $\sum_g R_g$ will result in a large, negative $T_d$ . This is unavoidable in the Newton-Raphson step; the valid domain for $\sum_g R_g$ is tiny: $[0, N_{\rm gd} T^{3/2})$ . Here I'm considering the case where the radiation temperature is well below the gas temperature, so $T \gg T_r \approx T_d$ , therefore $\Lambda_{\rm gd} \ge 0$ .
After extensive exploration, I constructed the following scheme for the decoupled regime. First, we define the decoupled regime as when$\max(N_{\rm gd} T^{3/2}, N_{\rm gd} T_d^{3/2}) < 10^{-6} \max(E_{\rm gas}, \sum_g R_g)$ . Since the gas temperature won't change much, it can be updated via a simple forward Euler step of the following equation:
One can also choose to solve this analytically. Thus we have obtained$\Lambda_{\rm gd} \Delta t$ .
Then, we want to deal with energy exchange between radiation groups, to capture dust absorbing UV radiation and re-emitting in IR. At first, I tried to update$E_g$ with fixed $T_d$ , by solving
This can be solved with simple algebra. However, I have shown that the resulting$\sum_g R_g$ (the sum of the RHS over groups) does not necessarily equal to the $\Lambda_{\rm gd} \Delta t$ used previously to update gas temperature. This results in the failure of energy conservation. To enforce $\sum_g R_g = \Lambda_{\rm gd} \Delta t$ , we have to include $T_d$ as an independent variable; otherwise, the system is over-determined.
Then, here is the new scheme that I have shown to be very robust. After updating$T$ via Equation (6), we solve the updated $T_d$ and $E_g$ via the following set of equations:
We solve this equation via Newton-Raphson iteration on the base variable$(T_d, R_g)$ .
and the Jacobian is
This set of equations is very similar to the previous ones, so we can use the same routine with some switches to reset different Jacobian for different regimes. After this system is converged, the whole iteration is done and energy is guaranteed to be conserved (to the degree of how well the Newton-Raphson iteration converges).
Tests
RadMarshakDust
is a Marshak wave problem where FUV radiation is streaming from the left boundary, gets absorbed by dust which then radiates in IR. The IR opacity is set to a large number so that diffusion is extremely slow. I compare the (semi-)exact analytic solution with the numerical calculation and find perfect agreement. Figure shown below:Related issues
None.
Checklist
Before this pull request can be reviewed, all of these tasks should be completed. Denote completed tasks with an
x
inside the square brackets[ ]
in the Markdown source below:/azp run
.