.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "generated/gallery/user_guide/plot_recomb_rate.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_generated_gallery_user_guide_plot_recomb_rate.py: Ionization and recombination rates =================================== This example shows how to compute the recombination rate as a function of temperature for Fe 16, including the radiative and dielectronic components. .. GENERATED FROM PYTHON SOURCE LINES 9-19 .. code-block:: Python import astropy.units as u import matplotlib.pyplot as plt import numpy as np from astropy.visualization import quantity_support from fiasco import Ion quantity_support() .. rst-class:: sphx-glr-script-out .. code-block:: none .MplQuantityConverter object at 0x7fc3a2869910> .. GENERATED FROM PYTHON SOURCE LINES 20-22 First, instantiate the Fe XVI ion object. This can be done in a number of ways, but we will use the spectroscopic roman numeral notation. .. GENERATED FROM PYTHON SOURCE LINES 22-24 .. code-block:: Python ion = Ion('Fe XVI', np.logspace(4, 8, 100) * u.K) .. GENERATED FROM PYTHON SOURCE LINES 25-34 We can calculate the recombination rate, which includes contributions from both radiative and dielectronic recombination. We can also compute these separately in order to understand over what temperature range each process dominates. Similarly, we can calculate the ionization rate which includes contributions from direction ionization and excitation autoionization. We can plot the recombination and ionization rates, including all components, as a function of temperature. .. GENERATED FROM PYTHON SOURCE LINES 34-52 .. code-block:: Python fig, ax = plt.subplots(tight_layout=True) ax.plot(ion.temperature, ion.recombination_rate, label='Recombination', color='C0',) ax.plot(ion.temperature, ion.dielectronic_recombination_rate, label='Dielectronic', color='C0', ls='--') ax.plot(ion.temperature, ion.radiative_recombination_rate, label='Radiative', color='C0', ls=':') ax.plot(ion.temperature, ion.ionization_rate, label='Ionization', color='C1') ax.plot(ion.temperature, ion.direct_ionization_rate, label='Direct', color='C1', ls='--') ax.plot(ion.temperature, ion.excitation_autoionization_rate, label='Excitation Autoionization', color='C1', ls=':') ax.set_xscale('log') ax.set_yscale('log') ax.set_ylim(1e-12, 1e-9) ax.legend() plt.show() .. image-sg:: /generated/gallery/user_guide/images/sphx_glr_plot_recomb_rate_001.png :alt: plot recomb rate :srcset: /generated/gallery/user_guide/images/sphx_glr_plot_recomb_rate_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.529 seconds) .. _sphx_glr_download_generated_gallery_user_guide_plot_recomb_rate.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_recomb_rate.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_recomb_rate.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_