-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mean opacity for variable kappa based on piecewise-power-law approximation #626
Conversation
for more information, see https://pre-commit.ci
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.
clang-tidy made some suggestions
for more information, see https://pre-commit.ci
…-astro/quokka into chongchong/kappa-int-v8.2
for more information, see https://pre-commit.ci
…-astro/quokka into chongchong/kappa-int-v8.2
Azure Pipelines successfully started running 5 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 5 pipeline(s). |
In that case, I'll leave that for future work. If you can approximate log_2(x), then you can approximate log(x) with log(x) = log_2(x) * log(2). For now, I'll do a quick benchmark as you suggested. |
The 3D GPU test is taking very long. This PR is fine: pulse_MG_int takes 2.5 hours on gadi. However, the old pulse_MG test will take a projected time of 100 hours to finish. I suspect this is because of the low |
OK. I did a benchmark on gadi gpuvolta for the old pulse-MG test (bin-centered opacity) and the new pulse-MG-int (bin integrated opacity with piecewise power-law) test. The elapsed time is 45min vs 37min. The new test is faster, but I realized it is not a fair test. The old test runs two simulations, each with 4 photon groups. The new test runs two simulations, one with 4 photon groups and the other with 1 group (exact solution where kappa is integrated over the whole spectrum). The amount of computation is roughly proportional to the nGroups, so the elapsed time per group are: old: 45/8=5.625, new: 37/5=7.4. So, the difference is not large. I wouldn't worry too much about transcendental functions on GPU. |
for more information, see https://pre-commit.ci
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.
clang-tidy made some suggestions
for more information, see https://pre-commit.ci
/azp run |
Azure Pipelines successfully started running 5 pipeline(s). |
Can you run a test with a 128^3 grid (with |
@BenWibking Old, bin-centered approach,
New,
With 4 GPUs, the performance is similar, too. These takes (about 4x) shorter time to run, although the reported μs/zone-update is bigger. Old,
new:
|
Ok, that seems reasonable to me. As a final check, can you see how many iterations per zone there are on average for your benchmark runs? When I tested the radiation code in the methods paper using 128^3 grids, I got 40 million updates/sec/GPU. However, that problem was optically thin, so there number of iterations should have been close to 1. |
@BenWibking |
Yes. There currently isn't one, but there is one for the number of cooling iterations, which you could very nearly copy and paste from: quokka/src/TabulatedCooling.hpp Line 309 in d7f4b43
|
OK, I'll try that later. Gadi is currently down. |
/azp run |
Azure Pipelines successfully started running 5 pipeline(s). |
I did the same test with the RadForce problem instead. This is in the optically-thin limit and the performance is 8.3 Mupdates/s. Note that this is done with 2 photon groups, and the computational complexity is supposed to scale linearly with the number of photon groups (with a ~2.5 jump from 1 group to 2 groups due to additional setup for multigroup, e.g. interpolating the Planck integral). This brings this test to roughly 20 Mupdates/s/GPU per group. This also applies to the RadhydroPulseMGint problem presented above which uses 4 groups. Old,
New, PPL
|
Ok, I am satisfied with this. (Sometime in the future, we should figure out why it's a factor of ~2 slower than the version from the original paper.) |
@markkrumholz Should we merge this PR? I think the only thing I haven't addressed is the Piecewise powerlaw reconstruction of the radiation quantities, which I haven't finished and I'll leave for the next PR. |
Will look today and approve. It’s first thing in the morning here. |
Description
This PR implements piecewise-power-law approximation for multigroup radiation transfer. We calculate Planck-mean, energy-mean, and flux-mean opacity given an arbitrary function kappa(nu, T, rho) based on piecewise-power-law fitting to kappa(nu), E(nu), and F(nu). The user can enable this routine by setting
OpacityModel
toOpacityModel::piecewisePowerLaw
. See examples in test_radhydro_shock_multigroup.cpp and test_radhydro_pulse_MG_int.hpp. The original approach that the opacities are defined viaComputePlanckOpacity
,ComputeFluxMeanOpacity
, etc are retained by settingOpacityModel
toOpacityModel::user
, which is the default.We calculate the power-law slope of a radiation quantity via the following relations:
where
I will try to construct a better estimate of the power-law slope in a separate PR. The user can choose to overwrite this by defining your own
RadSystem<problem_t>::ComputeRadQuantityExponents
; see example in test_radhydro_pulse_MG_int.cpp.The power-law fitting of$\kappa(\nu)$ can be specified in two ways. The first method is to specify its power-law slope and lower-bound value for every photon bin, given $T$ and $\rho$ . The second method is to specify a precise definition of $\kappa(\nu, T, \rho)$ . Then, a power-law fitting to $\kappa(\nu)$ is done on the fly in the following way:
This is definitely not the most accurate way to do this as it is not volume conservative, but it's simple and this is important since it's done for every cell. An alternative is to construct$\kappa_{L,i}$ and $\alpha_{\kappa,i}$ in the beginning if $\kappa$ does not depend on $T$ or $\rho$ .
Related issues
N/A
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
.