Cosmo ics - #522
Conversation
The power spectra provided are now going to be the total matter power spectrum at the redshift of interest and the power spectrum of the baryon-cdm overdensity (redshift-independent in linear theory). This approach is adopted from Hahn et al., MNRAS 503, 426–445 (2021).
Note that when generating the cosmological ICs we need the cosmological parameters before the particles or gravity have been initialized. We may need to split the cosmological initialization from the gravity and particle initialization. In the routine to write the growth function, the growth function file header may need to set the cosmological parameters explicitly from the parameter class rather than inherit from Cosmology(), since they may not be set at that stage.
…1 calculation from k^-2 filter
At this point, all the basic calculations required for the cosmological ICs have been computed. Given an input power spectrum from CAMB, we generate the total matter density fluctuations and the fluctuations in the baryon vs. CDM densities. We compute the initial gravitational potential from the matter overdensity field. We use the gradient of that potential times the time derivative of the growth factor to compute the gas velocities on the grid, and use the matter and baryon v. cdm overdensities to set the gas density on the grid. We then compute the potential of the baryon v. cdm overdensities. The particles are then initialized at the Lagrangian positions at the grid centers. The particle velocities are set by the time derivative of the growth factor times the gradient of the initial matter potential, just like the gas. The particle positions are perturbed by the growth factor times the gradient of the matter potential, and then further by (just) the gradient of the baryon v. cdm potential. Things that need to be checked: 1) units, especially on the time derivative of the growth factor. compare displacements from grid centers and velocities to a comparable set of ICs from another generator. 2) the initial hydrogen and helium ionization states needs to be inherited from CAMB correctly, not set via hard-coding as is now done for some reason 3) the matter power spectrum and the baryon v. cdm power spectrum should probably be checked. 4) test simulations need to be run to z=0 5) scaling tests to check the ICs generator performance with scale.
The fact that the local density field is only real cells vs. the potential being real + ghost in paris complicates using simple copy and paste. The indexing of just about everything needs to be adjusted. Likely the easiest route is to keep all the FFT routines connected to only real cells, copy in the potential solved from the density field via FFT into another array that included ghost cells, perform the required communication between ghost cells, and then proceed with the potential gradient calculation. This will require communication of the boundary values for the potentials corresponding to delta_m and delta_bc. How do we deal with populating phi when it's a different size than delta? We can perform the FFT treating them as the same size (ignoring the extra extent of phi). We can then copy from phi back to delta m. Then reindex phi, reading from delta m. We can then copy the boundary values after phi is remapped. This is a bit exhausting. It could all require revision.
We now ensure that all FFT fields are local in size, including the delta_m and delta_bc device and host fields. The potential fields require gradients and are now the full grid size. We avoid buffer transfers between the FFT-computed potential and the full grid potential by re-using the delta fields. The particle initialization now uses the gradients of the cosmological potential fields. We still need to address the transfer of the ghost cells for the cosmological potential, but the code should execute (incorrectly) through the particle initialization. We can debug memory issues, and then turn to the ghost cell communications.
Unless I invoke P.nx/ny/nz in main(), then the gravitational calculation initialization fails because the number of grid cells propagated to Henry is garbage. Maybe P is changed somewhere haphazardly? This is not my problem for now, focus on communication of boundary cells from the potential.
Note these are written for CPU only, but allow for a field to be provided as input and can be re-used with other fields beyond the cosmo potential. Re-writing for GPU+MPI should be straightforward, but will wait.
Co-authored-by: Matthew Abruzzo <matthewabruzzo@gmail.com>
Co-authored-by: Matthew Abruzzo <matthewabruzzo@gmail.com>
Co-authored-by: Matthew Abruzzo <matthewabruzzo@gmail.com>
Co-authored-by: Matthew Abruzzo <matthewabruzzo@gmail.com>
Co-authored-by: Matthew Abruzzo <matthewabruzzo@gmail.com>
Co-authored-by: Matthew Abruzzo <matthewabruzzo@gmail.com>
Co-authored-by: Matthew Abruzzo <matthewabruzzo@gmail.com>
Co-authored-by: Matthew Abruzzo <matthewabruzzo@gmail.com>
Co-authored-by: Matthew Abruzzo <matthewabruzzo@gmail.com>
Co-authored-by: Matthew Abruzzo <matthewabruzzo@gmail.com>
|
pre-commit.ci autofix |
Thank you for your efforts.
We can move these items, but they are extremely helpful for diagnosing performance. I would recommend pushing this issue to the M1 merge.
I think this is a design consideration that would require some effort. I will not have time for this until at least September.
Thank you for your efforts during review and your support, it's been extremely helpful.
I would disagree that
I agree that the ephemeral nature of the fields make them amenable to special treatment.
I agree that we could work on this in the future.
I agree.
No, I don't disagree.
I think we are just person-hour limited at this time. I'm open to revisiting this in September.
I do want to do it, we just have time constraints over the next four weeks on the cosmo ICs + RT issues that will require concerned development effort on the physics. I am happy to meet next week to discuss. |
evaneschneider
left a comment
There was a problem hiding this comment.
I'm happy to merge this in once the new Makefile parameters (the ones added in src/cholla_config.h.in) and input file parameters have been added and defined on the relevant docs pages https://cholla.readthedocs.io/en/latest/MakefileParameters.html and https://cholla.readthedocs.io/en/latest/Reference/Parameters.html. Thank you for the documentation on the ICs generation.
| error.resize(ny); | ||
|
|
||
| int i, j; | ||
| for (i = 0; i < 7; i++) |
There was a problem hiding this comment.
This is now triggering the clang-tidy error "statement should be inside braces"
There was a problem hiding this comment.
This line (22) is still triggering the clang tidy error. I think you need braces on line 22 (and probably 23 as well).
There was a problem hiding this comment.
It looks like maybe there's an accidental duplication here as well?
Typo in cosmology ics documentation Co-authored-by: Evan Schneider <eschneider@pitt.edu>
move statement inside braces Co-authored-by: Matthew Abruzzo <matthewabruzzo@gmail.com>
|
@evaneschneider I have added to the |
|
Looks good, thank you. I'll merge this in once the CI tests finish. |
Co-authored-by: Matthew Abruzzo <matthewabruzzo@gmail.com>
This update provides several additions to the cholla code base: