.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/a_models/plot_magnetized_galaxy_clusters.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_a_models_plot_magnetized_galaxy_clusters.py: ==================================== Build a Magnetized Galaxy Cluster ==================================== This example generates a set of magnetized galaxy cluster models with varying magnetic pressure fractions (beta parameters) and compares their resulting temperature, entropy, magnetic field strength, and Alfven speed profiles. Each model uses the same density profile but varies the magnetic support, demonstrating the effects of magnetization on thermodynamic quantities. .. GENERATED FROM PYTHON SOURCE LINES 15-29 Setup ----- In this example, we'll use the :class:`~pisces.models.galaxy_clusters.spherical.MagnetizedSphericalGalaxyClusterModel` class to construct magnetized galaxy clusters with different degrees of physical support. This is parameterized through the :math:`\beta` parameter which is defined such that .. math:: \beta = \frac{P_{\rm thermal}}{P_{\rm magnetic}}. With different values of :math:`\beta`, the temperature structure and various other thermodynamic properties of the clusters will vary. To get started, we'll need to import the relevant building blocks. .. GENERATED FROM PYTHON SOURCE LINES 29-40 .. code-block:: Python import tempfile import numpy as np import unyt from pisces.models.galaxy_clusters import MagnetizedSphericalGalaxyClusterModel # Import the model class and the construction profiles. from pisces.profiles import NFWDensityProfile .. GENERATED FROM PYTHON SOURCE LINES 41-47 Profiles '''''''' To start building the models, we'll need to create the initial profiles. A quick look at the documentation for the model shows that the full cluster model can be built from a **total density profile** :math:`\rho_{\rm tot}` and a **gas density profile** :math:`\rho_{\rm gas}`. For realism, we'll use a gas fraction close to ``0.1``, which is pretty standard for most clusters. We'll also use an NFW core density around :math:`5 \times 10^6 \;{\rm M_\odot\; kpc^{-3}}`. .. GENERATED FROM PYTHON SOURCE LINES 47-58 .. code-block:: Python # Construct the total profile. total_density_profile = NFWDensityProfile( rho_0=unyt.unyt_quantity(5e6, "Msun/kpc**3"), r_s=unyt.unyt_quantity(200, "kpc") ) # Construct the gas density profile. gas_density_profile = NFWDensityProfile( rho_0=unyt.unyt_quantity(5e5, "Msun/kpc**3"), r_s=unyt.unyt_quantity(220, "kpc") ) .. GENERATED FROM PYTHON SOURCE LINES 59-65 Model Construction ------------------ Now that we have the density profiles, it's an easy matter to generate the relevant profiles using the :meth:`~pisces.models.galaxy_clusters.spherical.MagnetizedSphericalGalaxyClusterModel.from_density_and_total_density` method. We'll store the data files in a temporary directory and create a number of models for different values of the :math:`\beta` parameter. .. GENERATED FROM PYTHON SOURCE LINES 65-93 .. code-block:: Python # Create a temp directory. tmpdir = tempfile.TemporaryDirectory() # Define the selection of beta values beta_set = [np.inf, 1000, 500, 200, 100, 50, 10, 5, 1] # Set some parameters. rmin, rmax = unyt.unyt_quantity(1, "kpc"), unyt.unyt_quantity(5, "Mpc") models = {} for beta_id, beta in enumerate(beta_set): # Determine the filename. filename = f"{tmpdir.name}/model_beta_{beta_id}.h5" # Create the model models[beta_id] = MagnetizedSphericalGalaxyClusterModel.from_density_and_total_density( gas_density_profile, total_density_profile, filename, min_radius=rmin, max_radius=rmax, num_points=500, overwrite=True, beta_profile=beta, # This sets the beta value. ) .. rst-class:: sphx-glr-script-out .. code-block:: none Preparing metadata...: 0%| | 0/8 [00:00` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_magnetized_galaxy_clusters.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_magnetized_galaxy_clusters.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_