Skip to content

Conversation

@hsinhaoHHuang
Copy link
Contributor

Goals

  1. Expand the functionality of GAMER to use GRACKLE.
  2. Resolve the issue that GAMER's temperature in the output assumes a fixed mean molecular weight

Changes

User-end

  • Add new runtime options to store the derived fields calculated by Grackle in the snapshots.

    • OPT__OUTPUT_GRACKLE_TEMP: output the temperature calculated by Grackle
    • OPT__OUTPUT_GRACKLE_MU: output the mean molecular weight calculated by Grackle
    • OPT__OUTPUT_GRACKLE_TCOOL: output the cooling time calculated by Grackle
  • Add more options mapping to Grackle's parameters

    • GRACKLE_USE_V_HEATING_RATE: map to Grackle’s use_volumetric_heating_rate here, and users can create their function and link it to Grackle_vHeatingRate_User_Ptr in their test problem.
    • GRACKLE_USE_S_HEATING_RATE: map to Grackle’s use_specific_heating_rate here, and users can create their function and link it to Grackle_sHeatingRate_User_Ptr in their test problem.
    • GRACKLE_HYDROGEN_MFRAC: map to Grackle's HydrogenFractionByMass here.
  • Add a new testing-purposes option to allow Grackle to evolve while the fluid is frozen.

    • OPT__UNFREEZE_GRACKLE: work with OPT__FREEZE_FLUID
  • Add a new grid refinement option to flag when the cooling length is not resolved.

    • OPT__FLAG_COOLING_LEN: the refinement criteria of "cooling length/cell size" is set in Input__Flag_CoolingLen
  • Add a new time-step criterion from Grackle's cooling time.

    • DT__GRACKLE_COOLING: the time-step is restricted by a factor of the minimum of cooling time
  • Add a new test problem to test the Grackle-related functionality and see the Grackle's temperature and chemical species evolution in a controlled setup.

    • Hydro/GrackleTest
  • Update the Grackle-related parameters in the wiki.

Internally

  • Add new Grackle interface function Grackle_Calculate().
    • It will call the same Grackle_Prepare() to prepare the input arrays, so it can set up Grackle’s parameters consistently as CPU_GrackleSolver().
    • It will call the Grackle’s API functions for the calculation of derived fields:
      • calculate_temperature()
      • calculate_gamma()
      • calculate_cooling_time()
    • Usage:
      • It can be called for outputting data (total and part).
      • It can be called for refinement criteria.
      • It can be called for deciding the time-steps.
    • Currently, it can only calculate the array in the units of "patch group" at a time.

Validation

  1. DefaultTestMode = 1 in the new test problem GrackleTest
    The x-axis corresponds to a range of density from 1.0e-29 g/cm^3 to 1.0e-21 g/cm^3, while the y-axis corresponds to a range of T/mu from 1.0 K to 1.0e8 K. We can check the Grackle-calculated derived fields of different phases at once.

    • Cooling Rate
      image
    • 1 / Cooling Time
      image
    • Cooling Length
      image
    • Mean Molecular Weight
      image
  2. DefaultTestMode = 2 in the new test problem GrackleTest
    A uniform gas of density 1.0e-24 g/cm^3 and T/mu 1.0e4 K.

    • Time-step is based on the cooling time
      dt = 1.40e-02 = 1/17.85 * 0.25
      image
    • Time evolution of the temperature and chemical composition
      image
    • Temperature calculated by Grackle
      image
  3. DefaultTestMode = 3 in the new test problem GrackleTest
    A uniform gas of density 1.0e-24 g/cm^3 and T/mu 1.0e4 K initially, with user-provided heating and cooling as a function of spatial coordinates through GRACKLE_USE_V_HEATING_RATE.

    • Cooling rate
      The given central heating rate is 1.0e-24 erg cm^-3 s^-1 n_H^-1 and central cooling rate is 1.6e-20 erg cm^-3 s^-1 n_H^-2
      image
      image
    • Cooling Length
      image
    • Cooling Length / dh
      The criteria are set as 8 cells per cooling length.
      image
    • Time evolution of the temperature
      The evolution can match the analytical expectation.
      image
    • Temperature calculated by Grackle, after 10 Myr
      image

@hyschive hyschive requested a review from barrytchiang December 9, 2025 07:51
@hyschive hyschive added enhancement hydro Hydrodynamics output Data output and log amr AMR labels Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

amr AMR enhancement hydro Hydrodynamics output Data output and log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants