From 16bffd3ada400158f6156b70f3c9b6318ffb6ea2 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 4 Sep 2024 06:47:09 -0600 Subject: [PATCH] use automated file lookup in pygrackle examples --- src/python/examples/cooling_cell.py | 8 +++++--- src/python/examples/cooling_rate.py | 6 +++--- src/python/examples/freefall.py | 6 +++--- src/python/examples/yt_grackle.py | 7 ++++--- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/python/examples/cooling_cell.py b/src/python/examples/cooling_cell.py index 0809d086..cd6355f6 100644 --- a/src/python/examples/cooling_cell.py +++ b/src/python/examples/cooling_cell.py @@ -22,13 +22,13 @@ from pygrackle import \ chemistry_data, \ + constants, \ evolve_constant_density, \ setup_fluid_container from pygrackle.utilities.physical_constants import \ mass_hydrogen_cgs, \ sec_per_Myr, \ cm_per_mpc -from pygrackle.utilities.data_path import grackle_data_dir from pygrackle.utilities.model_tests import \ get_model_set, \ model_test_format_version @@ -62,8 +62,10 @@ my_chemistry.primordial_chemistry = 0 my_chemistry.metal_cooling = 1 my_chemistry.UVbackground = 1 - my_chemistry.grackle_data_file = \ - os.path.join(grackle_data_dir, "CloudyData_UVB=HM2012.h5") + my_chemistry.grackle_data_file = "CloudyData_UVB=HM2012.h5" + my_chemistry.grackle_data_file_options = constants.GR_DFOPT_MANAGED + + density = 0.1 * mass_hydrogen_cgs # g /cm^3 temperature = 1e6 # K diff --git a/src/python/examples/cooling_rate.py b/src/python/examples/cooling_rate.py index f3720d9d..346b9383 100644 --- a/src/python/examples/cooling_rate.py +++ b/src/python/examples/cooling_rate.py @@ -19,8 +19,8 @@ from pygrackle import \ chemistry_data, \ + constants, \ setup_fluid_container -from pygrackle.utilities.data_path import grackle_data_dir from pygrackle.utilities.physical_constants import \ mass_hydrogen_cgs, \ sec_per_Myr, \ @@ -63,8 +63,8 @@ my_chemistry.UVbackground = 1 my_chemistry.self_shielding_method = 0 my_chemistry.H2_self_shielding = 0 - my_chemistry.grackle_data_file = \ - os.path.join(grackle_data_dir, "CloudyData_UVB=HM2012.h5") + my_chemistry.grackle_data_file = "CloudyData_UVB=HM2012.h5" + my_chemistry.grackle_data_file_options = constants.GR_DFOPT_MANAGED my_chemistry.use_specific_heating_rate = 1 my_chemistry.use_volumetric_heating_rate = 1 diff --git a/src/python/examples/freefall.py b/src/python/examples/freefall.py index 81035b61..8b2d3806 100644 --- a/src/python/examples/freefall.py +++ b/src/python/examples/freefall.py @@ -18,6 +18,7 @@ from pygrackle import \ chemistry_data, \ + constants, \ evolve_constant_density, \ evolve_freefall, \ setup_fluid_container @@ -25,7 +26,6 @@ mass_hydrogen_cgs, \ sec_per_Myr, \ cm_per_mpc -from pygrackle.utilities.data_path import grackle_data_dir from pygrackle.utilities.model_tests import \ get_model_set, \ model_test_format_version @@ -65,8 +65,8 @@ my_chemistry.CaseBRecombination = 1 my_chemistry.cie_cooling = 1 my_chemistry.h2_optical_depth_approximation = 1 - my_chemistry.grackle_data_file = os.path.join( - grackle_data_dir, "cloudy_metals_2008_3D.h5") + my_chemistry.grackle_data_file = "cloudy_metals_2008_3D.h5" + my_chemistry.grackle_data_file_options = constants.GR_DFOPT_MANAGED redshift = 0. diff --git a/src/python/examples/yt_grackle.py b/src/python/examples/yt_grackle.py index fabe95e3..4f0a8a58 100644 --- a/src/python/examples/yt_grackle.py +++ b/src/python/examples/yt_grackle.py @@ -15,8 +15,7 @@ import sys import yt -from pygrackle import add_grackle_fields -from pygrackle.utilities.data_path import grackle_data_dir +from pygrackle import add_grackle_fields, constants from pygrackle.utilities.model_tests import model_test_format_version output_name = os.path.basename(__file__[:-3]) # strip off ".py" @@ -45,9 +44,11 @@ ds = yt.load(ds_path) - grackle_data_file = os.path.join(grackle_data_dir, "CloudyData_UVB=HM2012.h5") + grackle_data_file = "CloudyData_UVB=HM2012.h5" + grackle_data_file_options = constants.GR_DFOPT_MANAGED grackle_pars = {'grackle_data_file': grackle_data_file, + 'grackle_data_file_options': grackle_data_file_options, 'UVbackground': 1, 'h2_on_dust': 1}