<jupyter_start><jupyter_text>Rb₂CrO₄, ⁸⁷Rb (I=3/2) SAS⁸⁷Rb (I=3/2) Switched-angle spinning (SAS) simulation. The following is a Switched-Angle Spinning (SAS) simulation of$\text{Rb}_2\text{CrO}_4$. While $\text{Rb}_2\text{CrO}_4$ has tworubidium sites, the site with the smaller quadrupolar interaction was selectivelyobserved and reported by Shore `et al.` [f1]_. The following is the simulationbased on the published tensor parameters.<jupyter_code>import matplotlib.pyplot as plt

from mrsimulator import Simulator, SpinSystem, Site
from mrsimulator.methods import Method2D
from mrsimulator import signal_processing as sp<jupyter_output><empty_output><jupyter_text>Generate the site and spin system objects.<jupyter_code>site = Site(
    isotope="87Rb",
    isotropic_chemical_shift=-7,  # in ppm
    shielding_symmetric={"zeta": 110, "eta": 0},
    quadrupolar={
        "Cq": 3.5e6,  # in Hz
        "eta": 0.3,
        "alpha": 0,  # in rads
        "beta": 70 * 3.14159 / 180,  # in rads
        "gamma": 0,  # in rads
    },
)
spin_system = SpinSystem(sites=[site])<jupyter_output><empty_output><jupyter_text>Use the generic 2D method, `Method2D`, to simulate a SAS spectrum by customizing themethod parameters, as shown below. Note, the Method2D method simulates an infinitespinning speed spectrum.<jupyter_code>sas = Method2D(
    channels=["87Rb"],
    magnetic_flux_density=4.2,  # in T
    spectral_dimensions=[
        {
            "count": 256,
            "spectral_width": 1.5e4,  # in Hz
            "reference_offset": -5e3,  # in Hz
            "label": "70.12 dimension",
            "events": [
                {
                    "rotor_angle": 70.12 * 3.14159 / 180,
                    "transition_query": [{"P": [-1], "D": [0]}],
                }
            ],  # in radians
        },
        {
            "count": 512,
            "spectral_width": 15e3,  # in Hz
            "reference_offset": -7e3,  # in Hz
            "label": "MAS dimension",
            "events": [
                {
                    "rotor_angle": 54.74 * 3.14159 / 180,
                    "transition_query": [{"P": [-1], "D": [0]}],
                }
            ],  # in radians
        },
    ],
)<jupyter_output><empty_output><jupyter_text>Create the Simulator object, add the method and spin system objects, andrun the simulation.<jupyter_code>sim = Simulator()
sim.spin_systems = [spin_system]  # add the spin systems
sim.methods = [sas]  # add the method.

# Configure the simulator object. For non-coincidental tensors, set the value of the
# `integration_volume` attribute to `hemisphere`.
sim.config.integration_volume = "hemisphere"
sim.run()<jupyter_output><empty_output><jupyter_text>The plot of the simulation.<jupyter_code>data = sim.methods[0].simulation

plt.figure(figsize=(4.25, 3.0))
ax = plt.subplot(projection="csdm")
cb = ax.imshow(data / data.max(), aspect="auto", cmap="gist_ncar_r")
plt.colorbar(cb)
ax.invert_xaxis()
plt.tight_layout()
plt.show()<jupyter_output><empty_output><jupyter_text>Add post-simulation signal processing.<jupyter_code>processor = sp.SignalProcessor(
    operations=[
        # Gaussian convolution along both dimensions.
        sp.IFFT(dim_index=(0, 1)),
        sp.apodization.Gaussian(FWHM="0.2 kHz", dim_index=0),
        sp.apodization.Gaussian(FWHM="0.2 kHz", dim_index=1),
        sp.FFT(dim_index=(0, 1)),
    ]
)
processed_data = processor.apply_operations(data=data)
processed_data /= processed_data.max()<jupyter_output><empty_output><jupyter_text>The plot of the simulation after signal processing.<jupyter_code>plt.figure(figsize=(4.25, 3.0))
ax = plt.subplot(projection="csdm")
cb = ax.imshow(processed_data.real, cmap="gist_ncar_r", aspect="auto")
plt.colorbar(cb)
ax.invert_xaxis()
plt.tight_layout()
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13082155939298795, 'fraction_numerical': 0.029827315541601257, 'mean_word_length': 3.2667410714285716, 'pattern_counts': {'":': 25, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '354730', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1414, 'n_tokens_neox': 1288, 'n_words': 293, 'path': 'docs/notebooks/examples/2D_simulation(crystalline)/plot_3_SAS_Rb2CrO4.ipynb', 'repo_name': 'pjgrandinetti/mrsimulator', 'size': '3822'}