.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/1D_simulation(crystalline)/plot_4_satellite_transition_sim.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(crystalline)_plot_4_satellite_transition_sim.py: Arbitrary spin transition (single-quantum) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ²⁷Al (I=5/2) quadrupolar spectrum simulation. .. GENERATED FROM PYTHON SOURCE LINES 9-14 The mrsimulator built-in library methods, BlochDecaySpectrum and BlochDecayCTSpectrum, simulate spectrum from single quantum transitions or central transition selective transition, respectively. In this example, we show how you can simulate any arbitrary transition using the generic Method object. .. GENERATED FROM PYTHON SOURCE LINES 14-22 .. code-block:: Python import numpy as np import matplotlib.pyplot as plt from mrsimulator import Simulator, SpinSystem, Site from mrsimulator.method import Method, SpectralDimension, SpectralEvent from mrsimulator.spin_system.tensors import SymmetricTensor .. GENERATED FROM PYTHON SOURCE LINES 24-25 Create a single-site arbitrary spin system. .. GENERATED FROM PYTHON SOURCE LINES 25-33 .. code-block:: Python site = Site( name="27Al", isotope="27Al", isotropic_chemical_shift=35.7, # in ppm quadrupolar=SymmetricTensor(Cq=5.959e6, eta=0.32), # Cq is in Hz ) spin_system = SpinSystem(sites=[site]) .. GENERATED FROM PYTHON SOURCE LINES 34-49 Selecting spin transitions for simulation ----------------------------------------- The arguments of the Method object are the same as the arguments of the BlochDecaySpectrum method; however, unlike a BlochDecaySpectrum method, the :ref:`spectral_dim_api` object in Method contains an additional argument---`events`. The :ref:`event_api` object is a collection of attributes, which are local to the event. It is here where we define `transition_queries` to select one or more transitions for simulating the spectrum. Recall, a TransitionQuery object holds a channel wise SymmetryQuery. For more information, refer to the :ref:`transition_query_documentation`. In this example, we use the ``P=-1`` and ``D=2`` attributes of SymmetryQuery, to select the satellite transition, :math:`|-1/2\rangle\rightarrow|-3/2\rangle`. .. GENERATED FROM PYTHON SOURCE LINES 49-76 .. code-block:: Python method = Method( name="Inner Satellite Spectrum", channels=["27Al"], magnetic_flux_density=21.14, # in T rotor_frequency=np.inf, # in Hz rotor_angle=54.7356 * np.pi / 180, # in rads spectral_dimensions=[ SpectralDimension( count=1024, spectral_width=1e4, # in Hz reference_offset=1e4, # in Hz events=[ SpectralEvent( transition_queries=[ {"ch1": {"P": [-1], "D": [2]}}, # inner satellite ] ) ], ) ], ) # A graphical representation of the method object. plt.figure(figsize=(4, 2.5)) method.plot() plt.show() .. image-sg:: /examples/1D_simulation(crystalline)/images/sphx_glr_plot_4_satellite_transition_sim_001.png :alt: Inner Satellite Spectrum :srcset: /examples/1D_simulation(crystalline)/images/sphx_glr_plot_4_satellite_transition_sim_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 77-78 Create the Simulator object and add the method and the spin system object. .. GENERATED FROM PYTHON SOURCE LINES 78-89 .. code-block:: Python sim = Simulator(spin_systems=[spin_system], methods=[method]) sim.run() # The plot of the simulation before signal processing. 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(crystalline)/images/sphx_glr_plot_4_satellite_transition_sim_002.png :alt: plot 4 satellite transition sim :srcset: /examples/1D_simulation(crystalline)/images/sphx_glr_plot_4_satellite_transition_sim_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 90-97 Selecting both inner and outer-satellite transitions ---------------------------------------------------- Similarly, you may add another transition query to select to select additional transitions. Consider the following transitions with respective P and D values. - :math:`|-1/2\rangle\rightarrow|-3/2\rangle ~~ (P=-1, D=2)` - :math:`|-3/2\rangle\rightarrow|-5/2\rangle ~~ (P=-1, D=4)` .. GENERATED FROM PYTHON SOURCE LINES 97-125 .. code-block:: Python method2 = Method( name="Satellite Spectrum", channels=["27Al"], magnetic_flux_density=21.14, # in T rotor_frequency=np.inf, # in Hz rotor_angle=54.7356 * np.pi / 180, # in rads spectral_dimensions=[ SpectralDimension( count=1024, spectral_width=1e4, # in Hz reference_offset=1e4, # in Hz events=[ SpectralEvent( transition_queries=[ {"ch1": {"P": [-1], "D": [2]}}, # inter satellite {"ch1": {"P": [-1], "D": [4]}}, # outer satellite ] ) ], ) ], ) # A graphical representation of the method object. plt.figure(figsize=(4, 2.5)) method2.plot() plt.show() .. image-sg:: /examples/1D_simulation(crystalline)/images/sphx_glr_plot_4_satellite_transition_sim_003.png :alt: Satellite Spectrum :srcset: /examples/1D_simulation(crystalline)/images/sphx_glr_plot_4_satellite_transition_sim_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 126-127 Update the method object in the Simulator object and re-simulate .. GENERATED FROM PYTHON SOURCE LINES 127-137 .. code-block:: Python sim.methods[0] = method2 sim.run() # The plot of the simulation before signal processing. 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(crystalline)/images/sphx_glr_plot_4_satellite_transition_sim_004.png :alt: plot 4 satellite transition sim :srcset: /examples/1D_simulation(crystalline)/images/sphx_glr_plot_4_satellite_transition_sim_004.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.864 seconds) .. _sphx_glr_download_examples_1D_simulation(crystalline)_plot_4_satellite_transition_sim.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_4_satellite_transition_sim.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_4_satellite_transition_sim.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_