Skip to content
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

Make the cooling-choice a runtime parameter #415

Open
wants to merge 21 commits into
base: dev
Choose a base branch
from

Conversation

mabruzzo
Copy link
Collaborator

@mabruzzo mabruzzo commented Aug 5, 2024

This PR builds on #414. (That needs to be merged first)

Overview

At present, there are presently 4 different methods for chemistry or heating & cooling:

(i) chemistry-gpu, (ii) grackle, (iii) tabulated-cloudy, (iv) piecewise-cie1

At present, this choice is entirely controlled at compile time. The changes in this PR make it possible to specify the tabulated-cooling or piecewise-cie at runtime (the ground-work is laid for specifying both other choices at runtime, but they still require macros).

I also made it possible to switch photo-electric heating on and off (when using tabulated-cooling only).

Description

I had to do a fair bit of refactoring.

The basic control-flow is as follows:

  • Before starting the simulation, the main function passes in the ParameterMap (it holds all parsed parameters into) configure_chemistry_callback.
    • if the chemistry.kind parameter is none this will return none (unless the macros for chemistry-gpu or grackle are defined -- in that case the program aborts)
    • if the chemistry.kind parameter is tabulated-cloudy or piecewise-cie this returns a callback to be used for performing heating/cooling
    • if chemistry.kind isn't specified, the default value is picked based on the macros (this is done to avoid breaking tests)
    • If the macros are defined for chemistry-gpu or grackle then this returns nothing (this is a short-term stopgap solution)
  • The callback is an object of type std::function<void(Grid3D&)>, which is basically a C++ function-pointer that can wrap functor-objects in addition to regular functions (this is important for retaining the state associated with any functor-objects and properly calling destructors).
  • The main function then passes in the callback into Grid.Update_Hydro_Grid. If the callback is not empty, it will always be called.

I had to do some refactoring of src/cooling/cooling_cuda.cu in order to make this select-able at runtime.

Configuration parameters

The new parameters are all in the [cooling] parameter table. (Parameter-tables are introduced in #414 and we leverage functionality to raise errors when there are unused parameters in the cooling group)

The new parameters include:

  • cooling.kind
    • allowed values: none, chemistry-gpu, grackle, tabulated-cloudy, piecewise-cie
    • default: defaults to none when no chemistry/heating&cooling parameters are given
    • description: when none, there is no chemistry/heating/cooling
  • cooling.data_file
    • description: this can optionally be used to specify a custom path to the data file when using tabulated-cloudy. It is an error to specify this for any other cooling.kind
  • chemistry.photoelectric_heating
    • type: boolean
    • default: false
    • description: this can optionally be used to introduce photoelectric-heating when using cooling.kind == tabulated-cloudy. It is an error to specify this for any other cooling.kind
  • chemistry.photoelectric_n_av_cgs
    • type: float
    • default: 100.0
    • description: when cooling.kind == tabulated-cloudy and chemistry.photoelectric_heating == true, this can be used to specify the average number-density in the domain in cgs units (which is used to compute impact of photoelectric heating). It is an error to specify when chemistry.photoelectric_heating == false

Footnotes

  1. Let me know if you would prefer different names

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant