def test_BlochDecaySpectrum(): # test-1 m1 = BlochDecaySpectrum() dimension_dictionary_ = { "count": 1024, "spectral_width": "25000.0 Hz", "reference_offset": "0.0 Hz", } should_be = { "name": "BlochDecaySpectrum", "channels": ["1H"], "magnetic_flux_density": "9.4 T", "rotor_frequency": "0.0 Hz", "rotor_angle": "0.955316618 rad", "spectral_dimensions": [dimension_dictionary_], } dict_ = m1.json() assert Method.parse_dict_with_units(dict_) == m1 dict_.pop("description") assert dict_ == should_be # test-2 m2_dict = { "channels": ["29Si"], "magnetic_flux_density": "11.7 T", "rotor_angle": "90 deg", "spectral_dimensions": [{}], } m2 = BlochDecaySpectrum.parse_dict_with_units(m2_dict) angle = 90 * np.pi / 180 dimension_dictionary_ = { "count": 1024, "spectral_width": "25000.0 Hz", "reference_offset": "0.0 Hz", } should_be = { "name": "BlochDecaySpectrum", "channels": ["29Si"], "magnetic_flux_density": "11.7 T", "rotor_frequency": "0.0 Hz", "rotor_angle": f"{angle} rad", "spectral_dimensions": [dimension_dictionary_], } dict_ = m2.json() assert Method.parse_dict_with_units(dict_) == m2 dict_.pop("description") assert dict_ == should_be
def CSA_VAS_method(): return BlochDecaySpectrum( channels=["29Si"], rotor_frequency=5000, rotor_angle=1.57079, spectral_dimensions=[dict(spectral_width=25000)], )
def setup_sim_and_processor(): site = Site(isotope="1H", shielding_symmetric={"zeta": -100, "eta": 0.3}) spin_sys = SpinSystem(sites=[site, site], abundance=45) method = BlochDecaySpectrum(channels=["1H"]) sim = Simulator(spin_systems=[spin_sys, spin_sys], methods=[method, method]) sim.run(method_index=0) processor = sp.SignalProcessor(operations=[ sp.IFFT(), sp.apodization.Exponential(FWHM="2500 Hz"), sp.FFT(), sp.Scale(factor=20), ]) processors = [processor] * 2 application = { "com.github.DeepanshS.mrsimulator": { "foo": "This is some metadata" }, "com.github.DeepanshS.mrsimulator-app": { "params": "The JSON string of params" }, } return sim, processors, application
def test_empty_spin_sys_simulator(): sim = Simulator() sim.methods = [ BlochDecaySpectrum(channels=["1H"], spectral_dimensions=[{"count": 10}]) ] sim.config.decompose_spectrum = "spin_system" sim.run() assert np.allclose(sim.methods[0].simulation.y[0].components[0], 0)
def test_two_site_no_coupling_test(): site1 = Site( isotope="29Si", isotropic_chemical_shift=10, shielding_symmetric={ "zeta": 5, "eta": 0 }, ) site2 = Site( isotope="29Si", isotropic_chemical_shift=-10, shielding_symmetric={ "zeta": -5, "eta": 0 }, ) iso_two_site = [SpinSystem(sites=[site1, site2])] iso_single_sites = [SpinSystem(sites=[site1]), SpinSystem(sites=[site2])] sim1 = Simulator() sim1.spin_systems += iso_two_site sim1.methods += [ BlochDecaySpectrum( channels=["29Si"], spectral_dimensions=[dict(count=2048, spectral_width=25000)], ) ] sim1.run() sim2 = Simulator() sim2.spin_systems += iso_single_sites sim2.methods += [ BlochDecaySpectrum( channels=["29Si"], spectral_dimensions=[dict(count=2048, spectral_width=25000)], ) ] sim2.run() data1 = (sim1.methods[0].simulation / 2).y[0].components data2 = sim2.methods[0].simulation.y[0].components assert np.allclose(data1, data2)
def pre_setup(): site_1 = Site(isotope="13C", shielding_symmetric={"zeta": 50, "eta": 0.5}) spin_system = SpinSystem(sites=[site_1]) method = BlochDecaySpectrum( channels=["13C"], spectral_dimensions=[{"count": 1024, "spectral_width": 25000}] ) sim = Simulator() sim.spin_systems.append(spin_system) sim.methods += [method] return sim
def setup(): site = Site(isotope="1H", shielding_symmetric={"zeta": -100, "eta": 0.3}) spin_sys = SpinSystem(sites=[site, site], abundance=45) method = BlochDecaySpectrum(channels=["1H"]) sim = Simulator(spin_systems=[spin_sys, spin_sys], methods=[method, method]) sim.run(method_index=0) processor = sp.SignalProcessor(operations=[ sp.IFFT(), sp.apodization.Exponential(FWHM="2500 Hz"), sp.FFT(), sp.Scale(factor=20), ]) processors = [processor] * 2 return sim, processors
def generate_shielding_kernel(zeta_, eta_, angle, freq, n_sidebands, to_ppm=True): method = BlochDecaySpectrum( channels=["29Si"], magnetic_flux_density=9.4, spectral_dimensions=[ dict(count=96, spectral_width=208.33 * 96, reference_offset=0) ], rotor_angle=angle, rotor_frequency=freq, ) if to_ppm: larmor_frequency = -method.channels[ 0].gyromagnetic_ratio * 9.4 # in MHz zeta_ /= larmor_frequency spin_systems = [ SpinSystem(sites=[ Site(isotope="29Si", shielding_symmetric={ "zeta": z, "eta": e }) ]) for z, e in zip(zeta_, eta_) ] sim = Simulator() sim.spin_systems = spin_systems sim.methods = [method] sim.config.decompose_spectrum = "spin_system" sim.config.number_of_sidebands = n_sidebands sim.run(pack_as_csdm=False) sim_lineshape = sim.methods[0].simulation.real sim_lineshape = np.asarray(sim_lineshape).reshape(4, 4, 96) sim_lineshape = sim_lineshape / sim_lineshape[0, 0].sum() sim_lineshape[0, :, :] /= 2.0 sim_lineshape[:, 0, :] /= 2.0 sim_lineshape.shape = (16, 96) return sim_lineshape
def test_simulator_2(): sim = Simulator() sim.spin_systems = [ SpinSystem( sites=[Site(isotope="1H"), Site(isotope="23Na")], couplings=[Coupling(site_index=[0, 1], isotropic_j=15)], ) ] sim.methods = [ BlochDecaySpectrum( channels=["1H"], spectral_dimensions=[{ "count": 10 }], experiment=cp.as_csdm(np.arange(10)), ) ] sim.name = "test" sim.label = "test0" sim.description = "testing-testing 1.2.3" sim.run() # save sim.save("test_sim_save.temp") sim_load = Simulator.load("test_sim_save.temp") sim_load_data = sim_load.methods[0].simulation sim_data = sim.methods[0].simulation sim_load_data._timestamp = "" assert sim_load_data.dict() == sim_data.dict() sim_load.methods[0].simulation = None sim.methods[0].simulation = None assert sim_load.spin_systems == sim.spin_systems assert sim_load.methods == sim.methods assert sim_load.name == sim.name assert sim_load.description == sim.description os.remove("test_sim_save.temp")
def kernel(self, supersampling=1): """ Return the NMR nuclear shielding anisotropic line-shape kernel. Args: supersampling: An integer. Each cell is supersampled by the factor `supersampling` along every dimension. Returns: A numpy array containing the line-shape kernel. """ args_ = deepcopy(self.method_args) method = BlochDecaySpectrum.parse_dict_with_units(args_) isotope = args_["channels"][0] zeta, eta = self._get_zeta_eta(supersampling) x_csdm = self.inverse_kernel_dimension[0] if x_csdm.coordinates.unit.physical_type == "frequency": # convert zeta to ppm if given in frequency units. zeta /= self.larmor_frequency # zeta in ppm for dim_i in self.inverse_kernel_dimension: if dim_i.origin_offset.value == 0: dim_i.origin_offset = f"{abs(self.larmor_frequency)} MHz" spin_systems = [ SpinSystem(sites=[ dict(isotope=isotope, shielding_symmetric=dict(zeta=z, eta=e)) ]) for z, e in zip(zeta, eta) ] sim = Simulator() sim.config.number_of_sidebands = self.number_of_sidebands sim.config.decompose_spectrum = "spin_system" sim.spin_systems = spin_systems sim.methods = [method] sim.run(pack_as_csdm=False) amp = sim.methods[0].simulation.real return self._averaged_kernel(amp, supersampling)
def setup_simulator(): site = Site( isotope="23Na", isotropic_chemical_shift=32, shielding_symmetric={ "zeta": -120, "eta": 0.1 }, quadrupolar={ "Cq": 1e5, "eta": 0.31, "beta": 5.12 }, ) sys = SpinSystem(sites=[site], abundance=0.123) sim = Simulator() sim.spin_systems.append(sys) sim.methods.append( BlochDecayCTSpectrum(channels=["2H"], rotor_frequency=1e3)) sim.methods.append( BlochDecaySpectrum(channels=["2H"], rotor_frequency=12.5e3)) sim.methods.append(ThreeQ_VAS(channels=["27Al"])) sim.methods.append(SSB2D(channels=["17O"], rotor_frequency=35500)) return sim
__email__ = "*****@*****.**" sim = Simulator() the_site = {"isotope": "1H", "isotropic_chemical_shift": "0 ppm"} the_spin_system = {"name": "site A", "sites": [the_site], "abundance": "80%"} spin_system_object = SpinSystem.parse_dict_with_units(the_spin_system) sim.spin_systems += [ spin_system_object, spin_system_object, spin_system_object ] sim.config.decompose_spectrum = "spin_system" sim.methods += [ BlochDecaySpectrum( channels=["1H"], magnetic_flux_density=9.4, spectral_dimensions=[{ "count": 65536, "spectral_width": 25000 }], ) ] sim.run() freqHz = sim.methods[0].spectral_dimensions[0].coordinates_Hz() def test_scale(): PS_0 = [sp.Scale(factor=10)] post_sim = sp.SignalProcessor(operations=PS_0) data = post_sim.apply_operations(data=sim.methods[0].simulation.copy()) _, y0, y1, y2 = sim.methods[0].simulation.to_list() _, y0_, y1_, y2_ = data.to_list()
sites = [S29_1, S29_2, S29_3] # all sites # %% # **Step 2:** Create the spin systems from these sites. Again, we create three # single-site spin systems for better performance. spin_systems = [SpinSystem(sites=[s]) for s in sites] # %% # **Step 3:** Create a Bloch decay spectrum method. method = BlochDecaySpectrum( channels=["29Si"], magnetic_flux_density=14.1, # in T rotor_frequency=1500, # in Hz spectral_dimensions=[{ "count": 2048, "spectral_width": 25000, # in Hz "reference_offset": -10000, # in Hz "label": r"$^{29}$Si resonances", }], ) # %% # **Step 4:** Create the Simulator object and add the method and spin system objects. sim = Simulator() sim.spin_systems += spin_systems # add the spin systems sim.methods += [method] # add the method # %% # **Step 5:** Simulate the spectrum. sim.run()
}, ) spin_systems = [SpinSystem(sites=[site])] # %% # **Method** # # For the sideband-only cross-section, use the BlochDecaySpectrum method. # Get the dimension information from the experiment. spectral_dims = get_spectral_dimensions(pass_cross_section) PASS = BlochDecaySpectrum( channels=["13C"], magnetic_flux_density=9.395, # in T rotor_frequency=1500, # in Hz spectral_dimensions=spectral_dims, experiment=pass_cross_section, # also add the measurement to the method. ) # Optimize the script by pre-setting the transition pathways for each spin system from # the method. for sys in spin_systems: sys.transition_pathways = PASS.get_transition_pathways(sys) # %% # **Guess Spectrum** # Simulation # ---------- sim = Simulator(spin_systems=spin_systems, methods=[PASS])
file_ = "https://sandbox.zenodo.org/record/687656/files/protein_GB1_15N_13CA_13CO.mrsys" sim.load_spin_systems(file_) # load the spin systems. print(f"number of spin systems = {len(sim.spin_systems)}") # %% all_sites = sim.sites().to_pd() all_sites.head() # %% # Create a :math:`^{13}\text{C}` Bloch decay spectrum method. method_13C = BlochDecaySpectrum( channels=["13C"], magnetic_flux_density=11.74, # in T rotor_frequency=3000, # in Hz spectral_dimensions=[{ "count": 8192, "spectral_width": 5e4, # in Hz "reference_offset": 2e4, # in Hz "label": r"$^{13}$C resonances", }], ) # %% # Since the spin systems contain both :math:`^{13}\text{C}` and :math:`^{15}\text{N}` # sites, let's also create a :math:`^{15}\text{N}` Bloch decay spectrum method. method_15N = BlochDecaySpectrum( channels=["15N"], magnetic_flux_density=11.74, # in T rotor_frequency=3000, # in Hz spectral_dimensions=[{ "count": 8192,
# single-site spin systems for better performance. spin_systems = [ SpinSystem(sites=[Si29_1]), SpinSystem(sites=[Si29_2]), SpinSystem(sites=[Si29_3]), ] # %% # **Step 3:** Create a Bloch decay spectrum method. method = BlochDecaySpectrum( channels=["29Si"], magnetic_flux_density=14.1, # in T rotor_frequency=1500, # in Hz spectral_dimensions=[ dict( count=2048, spectral_width=25000, # in Hz reference_offset=-10000, # in Hz label=r"$^{29}$Si resonances", ) ], ) # A graphical representation of the method object. plt.figure(figsize=(4, 2)) method.plot() plt.show() # %% # **Step 4:** Create the Simulator object and add the method and spin system objects. sim = Simulator()
sim.load_spin_systems(file_) # load the spin systems. print(f"number of spin systems = {len(sim.spin_systems)}") # %% all_sites = sim.sites().to_pd() all_sites.head() # %% # Create a :math:`^{13}\text{C}` Bloch decay spectrum method. method_13C = BlochDecaySpectrum( channels=["13C"], magnetic_flux_density=11.74, # in T rotor_frequency=3000, # in Hz spectral_dimensions=[ dict( count=8192, spectral_width=5e4, # in Hz reference_offset=2e4, # in Hz label=r"$^{13}$C resonances", ) ], ) # %% # Since the spin systems contain both :math:`^{13}\text{C}` and :math:`^{15}\text{N}` # sites, let's also create a :math:`^{15}\text{N}` Bloch decay spectrum method. method_15N = BlochDecaySpectrum( channels=["15N"], magnetic_flux_density=11.74, # in T rotor_frequency=3000, # in Hz spectral_dimensions=[
# are the array of tensor parameter coordinates, and ``pdf`` is the array of the # corresponding amplitudes. spin_systems = single_site_system_generator( isotope="29Si", isotropic_chemical_shift=iso, shielding_symmetric={"zeta": zeta, "eta": eta}, abundance=pdf, ) # %% # **Method:** # # Let's also create a Bloch decay spectrum method. method = BlochDecaySpectrum( channels=["29Si"], spectral_dimensions=[ dict(spectral_width=25000, reference_offset=-7000) # values in Hz ], ) # %% # The above method simulates a static :math:`^{29}\text{Si}` spectrum at 9.4 T field # (default value). # # **Simulator:** # # Now that we have the spin systems and the method, create the simulator object and # add the respective objects. sim = Simulator() sim.spin_systems = spin_systems # add the spin systems sim.methods = [method] # add the method
def CSA_static_method(): return BlochDecaySpectrum(channels=["29Si"], spectral_dimensions=[dict(spectral_width=25000)])
def test_more_spectral_dimensions(): error = "Method requires exactly 1 spectral dimensions, given 2." with pytest.raises(ValueError, match=f".*{error}.*"): BlochDecaySpectrum(spectral_dimensions=[{}, {}])
} method2 = { "channels": ["1H"], "magnetic_flux_density": "9.4 T", "rotor_frequency": "1 kHz", "rotor_angle": "54.735 deg", "spectral_dimensions": [ {"count": 2048, "spectral_width": "25 kHz", "reference_offset": "0 Hz",} ], } sim = Simulator() sim.spin_systems = [SpinSystem.parse_dict_with_units(item) for item in spin_systems] sim.methods = [ BlochDecaySpectrum.parse_dict_with_units(method1), BlochDecaySpectrum.parse_dict_with_units(method2), ] sim.run() freq1, amp1 = sim.methods[0].simulation.to_list() freq2, amp2 = sim.methods[1].simulation.to_list() fig, ax = plt.subplots(1, 2, figsize=(6, 3)) ax[0].plot(freq1, amp1, linewidth=1.0, color="k") ax[0].set_xlabel(f"frequency ratio / {freq2.unit}") ax[0].grid(color="gray", linestyle="--", linewidth=0.5, alpha=0.5) ax[0].set_title("Static") ax[1].plot(freq2, amp2, linewidth=1.0, color="k") ax[1].set_xlabel(f"frequency ratio / {freq2.unit}")
isotropic_chemical_shift=5.0, # in ppm, shielding_symmetric=SymmetricTensor(zeta=-80, eta=0.5), # zeta in Hz ) spin_systems = [SpinSystem(sites=[P_31])] # %% # **Method** # Get the spectral dimension parameters from the experiment. spectral_dims = get_spectral_dimensions(experiment) static1D = BlochDecaySpectrum( channels=["31P"], magnetic_flux_density=9.395, # in T rotor_frequency=0, # in Hz spectral_dimensions=spectral_dims, experiment=experiment, # experimental dataset ) # Optimize the script by pre-setting the transition pathways for each spin system from # the method. for sys in spin_systems: sys.transition_pathways = static1D.get_transition_pathways(sys) # %% # **Guess Model Spectrum** # Simulation # ---------- sim = Simulator(spin_systems=spin_systems, methods=[static1D])
isotope="13C", isotropic_chemical_shift=43.0, # in ppm ) spin_systems = [SpinSystem(sites=[C1], name="C1"), SpinSystem(sites=[C2], name="C2")] # %% # **Method** # Get the spectral dimension parameters from the experiment. spectral_dims = get_spectral_dimensions(experiment) MAS = BlochDecaySpectrum( channels=["13C"], magnetic_flux_density=7.05, # in T rotor_frequency=5000, # in Hz spectral_dimensions=spectral_dims, experiment=experiment, # experimental dataset ) # Optimize the script by pre-setting the transition pathways for each spin system from # the method. for sys in spin_systems: sys.transition_pathways = MAS.get_transition_pathways(sys) # %% # **Guess Model Spectrum** # Simulation # ---------- sim = Simulator(spin_systems=spin_systems, methods=[MAS])
def test_simulator_1(): sim = Simulator() sim.spin_systems = [SpinSystem(sites=[Site(isotope="1H"), Site(isotope="23Na")])] sim.methods = [BlochDecaySpectrum(channels=["1H"])] sim.name = "test" sim.label = "test0" sim.description = "testing-testing 1.2.3" red_dict = sim.json(units=False) _ = [item.pop("description") for item in red_dict["methods"]] assert red_dict == { "name": "test", "label": "test0", "description": "testing-testing 1.2.3", "spin_systems": [ { "sites": [ {"isotope": "1H", "isotropic_chemical_shift": 0.0}, {"isotope": "23Na", "isotropic_chemical_shift": 0.0}, ], } ], "methods": [ { "channels": ["1H"], "name": "BlochDecaySpectrum", "magnetic_flux_density": 9.4, "rotor_angle": 0.9553166181245, "rotor_frequency": 0.0, "spectral_dimensions": [ { "count": 1024, "events": [{"transition_query": [{"ch1": {"P": [-1]}}]}], "spectral_width": 25000.0, } ], } ], "config": { "decompose_spectrum": "none", "integration_density": 70, "integration_volume": "octant", "number_of_sidebands": 64, }, } # save sim.save("test_sim_save.temp") sim_load = Simulator.load("test_sim_save.temp") assert sim_load.spin_systems == sim.spin_systems assert sim_load.methods == sim.methods assert sim_load.name == sim.name assert sim_load.description == sim.description assert sim_load == sim # without units sim.save("test_sim_save_no_unit.temp", with_units=False) sim_load = Simulator.load("test_sim_save_no_unit.temp", parse_units=False) assert sim_load == sim os.remove("test_sim_save.temp") os.remove("test_sim_save_no_unit.temp")
) # %% # **Step 2:** Create the method object. # # The method should be the same as the one used # in the measurement. In this example, we use the `BlochDecaySpectrum` method. Note, # when creating the method object, the value of the method parameters must match the # respective values used in the experiment. MAS = BlochDecaySpectrum( channels=["29Si"], magnetic_flux_density=7.1, # in T rotor_frequency=780, # in Hz spectral_dimensions=[ dict( count=2048, spectral_width=25000, # in Hz reference_offset=-5000, # in Hz ) ], experiment=synthetic_experiment, # add the measurement to the method. ) # %% # **Step 3:** Create the Simulator object, add the method and spin system objects, and # run the simulation. sim = Simulator(spin_systems=[spin_system], methods=[MAS]) sim.run() # %% # **Step 4:** Create a SignalProcessor class and apply post simulation processing.
) for beta in beta_orientation ] # %% # **Methods** # # Next, we create methods to simulate the sideband manifolds for the above spin # systems at four spinning rates: 3 kHz, 5 kHz, 8 kHz, 12 kHz. spin_rates = [3e3, 5e3, 8e3, 12e3] # in Hz # The variable `methods` is a list of four BlochDecaySpectrum methods. methods = [ BlochDecaySpectrum( channels=["13C"], magnetic_flux_density=9.4, # in T rotor_frequency=vr, # in Hz spectral_dimensions=[dict(count=2048, spectral_width=8.0e4)], ) for vr in spin_rates ] # %% # **Simulator** # # Create the Simulator object and add the method and the spin system objects. sim = Simulator() sim.spin_systems = spin_systems # add the three spin systems sim.methods = methods # add the four methods sim.config.integration_volume = "hemisphere" # set averaging to hemisphere # decompose spectrum to individual spin systems. sim.config.decompose_spectrum = "spin_system"
def SSB2D_setup(ist, vr, method_type): sites = [ Site( isotope=ist, isotropic_chemical_shift=29, shielding_symmetric={ "zeta": -70, "eta": 0.000 }, ), Site( isotope=ist, isotropic_chemical_shift=44, shielding_symmetric={ "zeta": -96, "eta": 0.166 }, ), Site( isotope=ist, isotropic_chemical_shift=57, shielding_symmetric={ "zeta": -120, "eta": 0.168 }, ), ] spin_systems = [SpinSystem(sites=[s]) for s in sites] B0 = 11.7 if method_type == "PASS": method = SSB2D( channels=[ist], magnetic_flux_density=B0, # in T rotor_frequency=vr, spectral_dimensions=[ { "count": 32, "spectral_width": 32 * vr, # in Hz "label": "Anisotropic dimension", }, # The last spectral dimension block is the direct-dimension { "count": 2048, "spectral_width": 2e4, # in Hz "reference_offset": 5e3, # in Hz "label": "Fast MAS dimension", }, ], ) else: method = Method2D( channels=[ist], magnetic_flux_density=B0, # in T spectral_dimensions=[ { "count": 64, "spectral_width": 8e4, # in Hz "label": "Anisotropic dimension", "events": [{ "rotor_angle": 90 * 3.14159 / 180 }], }, # The last spectral dimension block is the direct-dimension { "count": 2048, "spectral_width": 2e4, # in Hz "reference_offset": 5e3, # in Hz "label": "Fast MAS dimension", }, ], affine_matrix=[[1, -1], [0, 1]], ) sim = Simulator() sim.spin_systems = spin_systems # add spin systems sim.methods = [method] # add the method. sim.run() data_ssb = sim.methods[0].simulation dim_ssb = data_ssb.x[0].coordinates.value if method_type == "PASS": bloch = BlochDecaySpectrum( channels=[ist], magnetic_flux_density=B0, # in T rotor_frequency=vr, # in Hz spectral_dimensions=[ { "count": 32, "spectral_width": 32 * vr, # in Hz "reference_offset": 0, # in Hz "label": "MAS dimension", }, ], ) else: bloch = BlochDecaySpectrum( channels=[ist], magnetic_flux_density=B0, # in T rotor_frequency=vr, # in Hz rotor_angle=90 * 3.14159 / 180, spectral_dimensions=[ { "count": 64, "spectral_width": 8e4, # in Hz "reference_offset": 0, # in Hz "label": "MAS dimension", }, ], ) for i in range(3): iso = spin_systems[i].sites[0].isotropic_chemical_shift sys = spin_systems[i].copy() sys.sites[0].isotropic_chemical_shift = 0 sim2 = Simulator() sim2.spin_systems = [sys] # add spin systems sim2.methods = [bloch] # add the method. sim2.run() index = np.where(dim_ssb < iso)[0][-1] one_d_section = data_ssb.y[0].components[0][:, index] one_d_section /= one_d_section.max() one_d_sim = sim2.methods[0].simulation.y[0].components[0] one_d_sim /= one_d_sim.max() np.testing.assert_almost_equal(one_d_section, one_d_sim, decimal=6)
# coupled spin systems SpinSystem(sites=[sn119, sn117], couplings=[j_sn], abundance=sn117_abundance), ] # %% # **Method** # Get the spectral dimension parameters from the experiment. spectral_dims = get_spectral_dimensions(experiment) MAS = BlochDecaySpectrum( channels=["119Sn"], magnetic_flux_density=9.395, # in T rotor_frequency=10000, # in Hz spectral_dimensions=spectral_dims, experiment=experiment, # add the measurement to the method. ) # Optimize the script by pre-setting the transition pathways for each spin system from # the method. for sys in spin_systems: sys.transition_pathways = MAS.get_transition_pathways(sys) # %% # **Guess Spectrum** # Simulation # ---------- sim = Simulator(spin_systems=spin_systems, methods=[MAS])
# %% # Simulate the spectrum # ''''''''''''''''''''' # # Create the spin systems from the above :math:`\zeta` and :math:`\eta` parameters. systems = single_site_system_generator( isotope="13C", shielding_symmetric={"zeta": z_dist, "eta": e_dist}, abundance=amp ) print(len(systems)) # %% # Create a simulator object and add the above system. sim = Simulator() sim.spin_systems = systems # add the systems sim.methods = [BlochDecaySpectrum(channels=["13C"])] # add the method sim.run() # %% # The following is the static spectrum arising from a Czjzek distribution of the # second-rank traceless shielding tensors. 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() # %% # Quadrupolar tensor # ------------------ #
SpinSystem(sites=[C1], name="C1"), SpinSystem(sites=[C2], name="C2") ] # %% # **Method**: Create the three MAS method objects with respective MAS spinning speeds. # Get the spectral dimension parameters from the respective experiment and setup the # corresponding method. # Method for dataset 1 spectral_dims1 = get_spectral_dimensions(experiment1) MAS1 = BlochDecaySpectrum( channels=["13C"], magnetic_flux_density=7.05, # in T rotor_frequency=5000, # in Hz spectral_dimensions=spectral_dims1, experiment=experiment1, # add experimental dataset 1 ) # Method for dataset 2 spectral_dims2 = get_spectral_dimensions(experiment2) MAS2 = BlochDecaySpectrum( channels=["13C"], magnetic_flux_density=7.05, # in T rotor_frequency=1940, # in Hz spectral_dimensions=spectral_dims2, experiment=experiment2, # add experimental dataset 2 ) # Method for dataset 3