.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gen_examples/plot_getting_started.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_gen_examples_plot_getting_started.py: Getting Started =============== This example showcases a simple, one-component plasma, and might be a good starting point. .. GENERATED FROM PYTHON SOURCE LINES 8-79 .. image-sg:: /gen_examples/images/sphx_glr_plot_getting_started_001.svg :alt: Be plasma at 2eV and 1g/cc with Z=2 :srcset: /gen_examples/images/sphx_glr_plot_getting_started_001.svg :class: sphx-glr-single-img .. code-block:: Python from functools import partial import matplotlib.pyplot as plt # jax provides a submodule which can be (mostly) used as a drop-in replacement # for numpy. We use jnp to avoid confusion. from jax import numpy as jnp import jaxrts # We use the jpu package (which is enabling the usage of pint with jax) to # handle units. See below for how to use this ureg = jaxrts.ureg # Initialize a Plasma State (We use a Berillium Plasma, here) state = jaxrts.PlasmaState( ions=[jaxrts.Element("Be")], # Specify the elements as a list Z_free=jnp.array([2]), # This is the ionization per species mass_density=jnp.array([1]) * ureg.gram / ureg.centimeter**3, T_e=2 * ureg.electron_volt / ureg.k_B, # T_e is the electron temperature. # If no T_i (ion temperature) is given, we assume equilibrium of ion and # electron temperatures ) # Now, we also have to define a Setup # jpu and pint also allow to convert string to quantities with units, as you # can see below. setup = jaxrts.Setup( scattering_angle=ureg("60°"), energy=ureg("4700 eV"), measured_energy=ureg("4700 eV") + jnp.linspace(-100, 40, 500) * ureg.electron_volt, instrument=partial( jaxrts.instrument_function.instrument_gaussian, sigma=ureg("5.0eV") / ureg.hbar / (2 * jnp.sqrt(2 * jnp.log(2))), ), ) # Add Models. In the typical way, we use the Chihara decomposition in the code, # differentiating 4 contributions to the full XRTS signal, based on the # different processes causing them. # # These processes are # # free-free scattering # bound-free scattering # free-bound scattering # elastic scattering by electrons, which follow the motion of the ions, closely # # At a minimum, a user has to set models for these contributions. This is done # by adding keys to the plasma state. state["ionic scattering"] = jaxrts.models.OnePotentialHNCIonFeat() state["free-free scattering"] = jaxrts.models.RPA_DandreaFit() state["bound-free scattering"] = jaxrts.models.SchumacherImpulse() state["free-bound scattering"] = jaxrts.models.DetailedBalance() # Generate the spectrum See_tot = state.probe(setup) # Plot the result plt.plot( setup.measured_energy.m_as(ureg.electron_volt), See_tot.m_as(ureg.second), ) plt.xlabel("Probed Energy [eV]") plt.ylabel("$S_{ee}^{tot}$ [s]") plt.title("Be plasma at 2eV and 1g/cc with Z=2") plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 8.878 seconds) .. _sphx_glr_download_gen_examples_plot_getting_started.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_getting_started.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_getting_started.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_