-
Notifications
You must be signed in to change notification settings - Fork 35
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
Light refactor of EnzoMethodPmDeposit::compute
and gas-deposition drift-time bugfix
#239
Conversation
For the Enzo experts out there, I did have a minor clarifying question about lines 204-206 of Grid_DepositBaryons.C. Does If you don't have time to look this up, we can punt this question to PR #187 |
…posit Previously the drift time for the gas density was set to the value of `alpha` (taken from `Method:pm_deposit:alpha`). As @stefanarridge pointed out in PR enzo-project#89 this didn't make a lot of sense. I also ran into issues with introducing a Stable Jeans Wave regression test in PR enzo-project#186 that required me to set `Method:pm_deposit:alpha` to 0. For comparison, the drift time for the gravitating mass particles is set to `alpha * dt / cosmo_a`, in which: - `alpha` again comes from `Method:pm_deposit:alpha` - `dt` is the time-step during the current cycle - `cosmo_a` is the scale factor computed at `time + alpha * dt` (where `time` is the time at the start of the current cycle) To investigate this issue I checked the original code from enzo-dev in `Grid_DepositBaryons.C`. I concluded that enzo-dev sets the gas density's drift-timestep should get set in exactly the same way as the Particle's drift timestep. However, when using the PPM and Zeus Hydro-solvers, the drift timestep is set to 0 (this is consistent with a comment @johnwise made during his review of PR enzo-project#189). Since our 2 primary hydro-solvers in Enzo-E (Ppm and VL+CT) currently handle these source terms with the same temporal order as these solvers, we now force the gas-deposition drift timestep to be 0 in `EnzoMethodPmDeposit`. We will need to revisit this exact behavior when we eventually modify the VL+CT solver to handle self-gravity in a higher temporal-order manner.
I'm almost certain those are comoving cell widths, not proper, so the multiplication by a does not match Enzo. However, note that this doesn't impact anything if dt is zero for the baryon deposit because those cell widths are only used in grid_cic.F by multiplying by dt (so since we have set dt=0 here, it doesn't matter what we pass in for the cell widths). This should probably be cleaned up at some point, but I'm happy punting this to a future PR. |
PR enzo-project#239 introduced a minor bug in which array used for storing the output of dep_grid_cic was not large enough. This caused dep_grid_cic to write values to invalid locations in memory. This bug manifested in weird ways when using compiling with intel compilers (under special conditions) In addition to fixing that bug, some variable names were updated so that their significance became more apparent
This PR was primarily written to implement a bugfix (relevant to PR #187), but I got a little carried away with some refactoring.
The first 2 commit lightly refactors
EnzoMethodPmDeposit::compute
. I have summarized these changes in the following spoiler tag.Refactoring changes
std::vector
andCelloArray
(so that we don't need to explicitly deallocate the pointers) and could drop some calls tostd::fill_n
std::fill_n
CelloArray
in some places (calls tofield::view
does more and louder error-checking thanfield::values
)dep_grid_cic
only includes cells for the active zone.The primary motivation for this PR was to address a bug related to the gas-deposition drift-time. Previously this drift time was set to the value of
alpha
(taken fromMethod:pm_deposit:alpha
). As @stefanarridge pointed out in PR #89 this didn't make a lot of sense. I also ran into issues with introducing a Stable Jeans Wave regression test in PR #186 that required me to setMethod:pm_deposit:alpha
to 0.For comparison, the drift time for depositing gravitating mass particles is set to
alpha * dt / cosmo_a
, in which:alpha
again comes fromMethod:pm_deposit:alpha
dt
is the time-step during the current cyclecosmo_a
is the scale factor computed attime + alpha * dt
(wheretime
is the time at the start of the current cycle)To investigate this issue I checked the original code from enzo-dev in
Grid_DepositBaryons.C
. I concluded that enzo-dev sets the gas density's drift-timestep should get set in exactly the same way as the Particle's drift timestep. However, when using the PPM and Zeus Hydro-solvers, the drift timestep is set to 0 (this is consistent with a comment @johnwise made during his review of PR #89). Since our 2 primary hydro-solvers in Enzo-E (Ppm and VL+CT) currently handle these acceleration source terms with the same temporal order as the solvers, we now force the gas-deposition drift timestep to be 0 inEnzoMethodPmDeposit
.