.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/1D_simulation(macro_amorphous)/plot_6_extended_czjzek.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_examples_1D_simulation(macro_amorphous)_plot_6_extended_czjzek.py: Extended Czjzek distribution (Shielding and Quadrupolar) ======================================================== In this example, we illustrate the simulation of spectrum originating from an extended Czjzek distribution of traceless symmetric tensors. We show two cases, an extended Czjzek distribution of the shielding and quadrupolar tensor parameters, respectively. .. GENERATED FROM PYTHON SOURCE LINES 12-13 Import the required modules. .. GENERATED FROM PYTHON SOURCE LINES 13-23 .. code-block:: Python import numpy as np import matplotlib.pyplot as plt from mrsimulator import Simulator from mrsimulator.method.lib import BlochDecaySpectrum, BlochDecayCTSpectrum from mrsimulator.models import ExtCzjzekDistribution from mrsimulator.utils.collection import single_site_system_generator from mrsimulator.method import SpectralDimension .. GENERATED FROM PYTHON SOURCE LINES 25-33 Symmetric shielding tensor -------------------------- Create the extended Czjzek distribution ''''''''''''''''''''''''''''''''''''''' First, create a distribution of the zeta and eta parameters of the shielding tensors using the :ref:`extended_czjzek_distribution` model as follows, .. GENERATED FROM PYTHON SOURCE LINES 33-42 .. code-block:: Python # The range of zeta and eta coordinates over which the distribution is sampled. z_lim = np.arange(100) * 0.4 + 40 # in ppm e_lim = np.arange(21) / 20 dominant = {"zeta": 60, "eta": 0.3} z_dist, e_dist = np.meshgrid(z_lim, e_lim) _, _, amp = ExtCzjzekDistribution(dominant, eps=0.14).pdf(pos=[z_lim, e_lim]) .. GENERATED FROM PYTHON SOURCE LINES 43-44 The following is the plot of the extended Czjzek distribution. .. GENERATED FROM PYTHON SOURCE LINES 44-51 .. code-block:: Python plt.figure(figsize=(4.25, 3.0)) plt.contourf(z_dist, e_dist, amp, levels=10) plt.xlabel(r"$\zeta$ / ppm") plt.ylabel(r"$\eta$") plt.tight_layout() plt.show() .. image-sg:: /examples/1D_simulation(macro_amorphous)/images/sphx_glr_plot_6_extended_czjzek_001.png :alt: plot 6 extended czjzek :srcset: /examples/1D_simulation(macro_amorphous)/images/sphx_glr_plot_6_extended_czjzek_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 52-56 Simulate the spectrum ''''''''''''''''''''' Create the spin systems from the above :math:`\zeta` and :math:`\eta` parameters. .. GENERATED FROM PYTHON SOURCE LINES 56-61 .. code-block:: Python systems = single_site_system_generator( isotope="13C", shielding_symmetric={"zeta": z_dist, "eta": e_dist}, abundance=amp ) print(len(systems)) .. rst-class:: sphx-glr-script-out .. code-block:: none 850 .. GENERATED FROM PYTHON SOURCE LINES 62-68 .. code-block:: Python method = BlochDecaySpectrum( channels=["13C"], rotor_frequency=0, # in Hz rotor_angle=0, # in rads ) .. GENERATED FROM PYTHON SOURCE LINES 69-70 Create a simulator object and add the above system. .. GENERATED FROM PYTHON SOURCE LINES 70-73 .. code-block:: Python sim = Simulator(spin_systems=systems, methods=[method]) sim.run() .. GENERATED FROM PYTHON SOURCE LINES 74-76 The following is the static spectrum arising from a Czjzek distribution of the second-rank traceless shielding tensors. .. GENERATED FROM PYTHON SOURCE LINES 76-82 .. code-block:: Python plt.figure(figsize=(4.25, 3.0)) ax = plt.subplot(projection="csdm") ax.plot(sim.methods[0].simulation.real, color="black", linewidth=1) plt.tight_layout() plt.show() .. image-sg:: /examples/1D_simulation(macro_amorphous)/images/sphx_glr_plot_6_extended_czjzek_002.png :alt: plot 6 extended czjzek :srcset: /examples/1D_simulation(macro_amorphous)/images/sphx_glr_plot_6_extended_czjzek_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 83-91 Quadrupolar tensor ------------------ Create the extended Czjzek distribution ''''''''''''''''''''''''''''''''''''''' Similarly, you may also create an extended Czjzek distribution of the electric field gradient (EFG) tensor parameters. .. GENERATED FROM PYTHON SOURCE LINES 91-100 .. code-block:: Python # The range of Cq and eta coordinates over which the distribution is sampled. cq_lim = np.arange(100) * 0.1 # assumed in MHz e_lim = np.arange(21) / 20 dominant = {"Cq": 6.1, "eta": 0.1} cq_dist, e_dist = np.meshgrid(cq_lim, e_lim) _, _, amp = ExtCzjzekDistribution(dominant, eps=0.25).pdf(pos=[cq_lim, e_lim]) .. GENERATED FROM PYTHON SOURCE LINES 101-102 The following is the plot of the extended Czjzek distribution. .. GENERATED FROM PYTHON SOURCE LINES 102-109 .. code-block:: Python plt.figure(figsize=(4.25, 3.0)) plt.contourf(cq_dist, e_dist, amp, levels=10) plt.xlabel(r"$C_q$ / MHz") plt.ylabel(r"$\eta$") plt.tight_layout() plt.show() .. image-sg:: /examples/1D_simulation(macro_amorphous)/images/sphx_glr_plot_6_extended_czjzek_003.png :alt: plot 6 extended czjzek :srcset: /examples/1D_simulation(macro_amorphous)/images/sphx_glr_plot_6_extended_czjzek_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 110-114 Simulate the spectrum ''''''''''''''''''''' **Static spectrum** Create the spin systems. .. GENERATED FROM PYTHON SOURCE LINES 114-125 .. code-block:: Python systems = single_site_system_generator( isotope="71Ga", quadrupolar={"Cq": cq_dist * 1e6, "eta": e_dist}, abundance=amp ) method = BlochDecayCTSpectrum( channels=["71Ga"], magnetic_flux_density=9.4, # in T rotor_frequency=0, # in Hz rotor_angle=0, # in rads spectral_dimensions=[SpectralDimension(count=2048, spectral_width=2e5)], ) .. GENERATED FROM PYTHON SOURCE LINES 126-127 Create a simulator object and add the above system. .. GENERATED FROM PYTHON SOURCE LINES 127-130 .. code-block:: Python sim = Simulator(spin_systems=systems, methods=[method]) sim.run() .. GENERATED FROM PYTHON SOURCE LINES 131-133 The following is a static spectrum arising from an extended Czjzek distribution of the second-rank traceless EFG tensors. .. GENERATED FROM PYTHON SOURCE LINES 133-140 .. code-block:: Python plt.figure(figsize=(4.25, 3.0)) ax = plt.subplot(projection="csdm") ax.plot(sim.methods[0].simulation.real, color="black", linewidth=1) ax.invert_xaxis() plt.tight_layout() plt.show() .. image-sg:: /examples/1D_simulation(macro_amorphous)/images/sphx_glr_plot_6_extended_czjzek_004.png :alt: plot 6 extended czjzek :srcset: /examples/1D_simulation(macro_amorphous)/images/sphx_glr_plot_6_extended_czjzek_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 141-142 **MAS spectrum** .. GENERATED FROM PYTHON SOURCE LINES 142-155 .. code-block:: Python mas = BlochDecayCTSpectrum( channels=["71Ga"], magnetic_flux_density=9.4, # in T rotor_frequency=25000, # in Hz rotor_angle=54.7356 * np.pi / 180, # in rads spectral_dimensions=[ SpectralDimension(count=2048, spectral_width=2e5, reference_offset=-1e4) ], ) sim.methods[0] = mas # add the method sim.config.number_of_sidebands = 16 sim.run() .. GENERATED FROM PYTHON SOURCE LINES 156-158 The following is the MAS spectrum arising from an extended Czjzek distribution of the second-rank traceless EFG tensors. .. GENERATED FROM PYTHON SOURCE LINES 158-164 .. code-block:: Python plt.figure(figsize=(4.25, 3.0)) ax = plt.subplot(projection="csdm") ax.plot(sim.methods[0].simulation.real, color="black", linewidth=1) ax.invert_xaxis() plt.tight_layout() plt.show() .. image-sg:: /examples/1D_simulation(macro_amorphous)/images/sphx_glr_plot_6_extended_czjzek_005.png :alt: plot 6 extended czjzek :srcset: /examples/1D_simulation(macro_amorphous)/images/sphx_glr_plot_6_extended_czjzek_005.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 6.952 seconds) .. _sphx_glr_download_examples_1D_simulation(macro_amorphous)_plot_6_extended_czjzek.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_6_extended_czjzek.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_6_extended_czjzek.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_