예제 #1
0
def test_equality():
    a = Coupling(site_index=[0, 1])
    b = Coupling(site_index=[0, 1])
    assert a == b

    c = Coupling(site_index=[0, 1], isotropic_j=16)
    assert a != c
def setup_partially_coupled_system():
    """Systems A-C-E, B, D, F"""
    sites = setup_sites()

    AC_couple = Coupling(site_index=[0, 2], isotropic_j=20)
    CE_couple = Coupling(site_index=[2, 4], isotropic_j=40)
    sys = SpinSystem(sites=sites,
                     couplings=[AC_couple, CE_couple],
                     abundance=50)

    A, B, C, D, E, F = sites
    simplified_sys = [
        SpinSystem(sites=[B], abundance=50),
        SpinSystem(sites=[D], abundance=50),
        SpinSystem(sites=[F], abundance=50),
        SpinSystem(
            sites=[A, C, E],
            couplings=[
                Coupling(site_index=[0, 1], isotropic_j=20),
                Coupling(site_index=[1, 2], isotropic_j=40),
            ],
            abundance=50,
        ),
    ]
    return sys, simplified_sys
def setup_somecoupled_system():
    """Systems A-C, B, D-E, F"""
    sites = setup_sites()

    AC_couple = Coupling(site_index=[0, 2], isotropic_j=20)
    DE_couple = Coupling(site_index=[3, 4], isotropic_j=40)
    sys = SpinSystem(sites=sites,
                     couplings=[AC_couple, DE_couple],
                     abundance=50)

    A, B, C, D, E, F = sites
    simplified_sys = [
        SpinSystem(sites=[B], abundance=50),
        SpinSystem(sites=[F], abundance=50),
        SpinSystem(
            sites=[A, C],
            couplings=[Coupling(site_index=[0, 1], isotropic_j=20)],
            abundance=50,
        ),
        SpinSystem(
            sites=[D, E],
            couplings=[Coupling(site_index=[0, 1], isotropic_j=40)],
            abundance=50,
        ),
    ]
    return sys, simplified_sys
예제 #4
0
def setup_partially_coupled_system2():
    """Systems A-C-E-F, B-D"""
    sites = setup_sites()

    AC_couple = Coupling(site_index=[0, 2], isotropic_j=20)
    BD_couple = Coupling(site_index=[1, 3], isotropic_j=120)
    CE_couple = Coupling(site_index=[2, 4], isotropic_j=40)
    EF_couple = Coupling(site_index=[4, 5], isotropic_j=10)
    sys = SpinSystem(
        sites=sites,
        couplings=[AC_couple, BD_couple, CE_couple, EF_couple],
        abundance=50,
    )

    A, B, C, D, E, F = sites
    simplified_sys = [
        SpinSystem(
            sites=[A, C, E, F],
            couplings=[
                Coupling(site_index=[0, 1], isotropic_j=20),
                Coupling(site_index=[1, 2], isotropic_j=40),
                Coupling(site_index=[2, 3], isotropic_j=10),
            ],
            abundance=50,
        ),
        SpinSystem(
            sites=[B, D],
            couplings=[Coupling(site_index=[0, 1], isotropic_j=120)],
            abundance=50,
        ),
    ]
    return sys, simplified_sys
def coupled_spin_system(j_coup=0, dipole=0):
    S1 = Site(
        isotope="1H",
        isotropic_chemical_shift=10,  # in ppm
        shielding_symmetric=SymmetricTensor(zeta=-80, eta=0.25),  # zeta in ppm
    )
    S2 = Site(isotope="1H", isotropic_chemical_shift=-10)
    S12 = Coupling(
        site_index=[0, 1],
        isotropic_j=j_coup,
        dipolar=SymmetricTensor(D=dipole, eta=0),
    )
    return SpinSystem(sites=[S1, S2], couplings=[S12])
예제 #6
0
def setup_system_simplifiedSystem():
    """systems A-B-C, D-F, E"""
    sites = setup_sites()

    AB_couple = Coupling(site_index=[0, 1], isotropic_j=10, name="AB")
    BC_couple = Coupling(site_index=[1, 2], isotropic_j=10, name="BC")
    AC_couple = Coupling(site_index=[0, 2], isotropic_j=10, name="AC")
    DF_couple = Coupling(site_index=[3, 5], isotropic_j=30, name="DF")
    couplings = [AB_couple, BC_couple, AC_couple, DF_couple]
    sys = SpinSystem(sites=sites, couplings=couplings, abundance=10)

    A, B, C, D, E, F = sites
    simplified_sys = [
        SpinSystem(sites=[E], abundance=10),
        SpinSystem(
            sites=[D, F],
            couplings=[Coupling(site_index=[0, 1], isotropic_j=30, name="DF")],
            abundance=10,
        ),
        SpinSystem(
            sites=[A, B, C], couplings=[AB_couple, AC_couple, BC_couple], abundance=10
        ),
    ]
    return sys, simplified_sys
예제 #7
0
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")
예제 #8
0
def test_direct_init_coupling1():
    # test 1 --------------------------------------------------------------------------
    the_coupling = Coupling(site_index=[0, 1], isotropic_j=10)
    assert the_coupling.site_index == [0, 1]
    assert the_coupling.isotropic_j == 10
    assert the_coupling.property_units["isotropic_j"] == "Hz"

    assert the_coupling.j_symmetric is None
    assert the_coupling.j_antisymmetric is None
    assert the_coupling.dipolar is None

    # test 2 --------------------------------------------------------------------------
    the_coupling = Coupling(site_index=[0, 1],
                            isotropic_j=10,
                            j_symmetric=None)
    assert the_coupling.j_symmetric is None
    assert the_coupling.j_antisymmetric is None
    assert the_coupling.dipolar is None

    # test 3 --------------------------------------------------------------------------
    the_coupling = Coupling(
        site_index=[2, 3],
        isotropic_j=10,
        j_symmetric={
            "zeta": 12.1,
            "eta": 0.1
        },
    )
    assert the_coupling.site_index == [2, 3]
    assert the_coupling.isotropic_j == 10
    assert the_coupling.property_units["isotropic_j"] == "Hz"

    assert the_coupling.j_antisymmetric is None

    assert the_coupling.dipolar is None

    assert the_coupling.j_symmetric.zeta == 12.1
    assert the_coupling.j_symmetric.property_units["zeta"] == "Hz"
    assert the_coupling.j_symmetric.eta == 0.1

    # test 4 --------------------------------------------------------------------------
    error = "ensure this value is less than or equal to 1"
    with pytest.raises(ValidationError, match=f".*{error}.*"):
        Coupling(
            site_index=[3, 1],
            isotropic_j=10,
            j_symmetric={
                "zeta": 12.1,
                "eta": 1.5
            },
        )

    error = [
        "Site index must a list of two integers",
        "The two site indexes must be unique integers",
    ]
    with pytest.raises(ValidationError, match=".*{}.*".format(*error)):
        Coupling(site_index=[])

    with pytest.raises(ValidationError, match=".*{}.*".format(*error)):
        Coupling(site_index=[2, 3, 4])

    with pytest.raises(ValidationError, match=".*{}.*".format(*error)):
        Coupling(site_index=[2])

    with pytest.raises(ValidationError, match=".*{1}.*".format(*error)):
        Coupling(site_index=[1, 1])

    ax = Coupling.parse_dict_with_units({
        "site_index": [0, 1],
        "isotropic_j": "5 cHz"
    })
    assert ax.json() == {
        "site_index": [0, 1],
        "isotropic_j": "0.05 Hz",
    }
예제 #9
0
# **Isotopomer 1**
#
# Now, let's define the couplings and build the spin system for the most abundant
# isotopomer (pictured below).
#
# .. figure::  ../../_static/iso1.*
#     :width: 200
#     :alt: figure
#     :align: center
#
#     An isotopomer of ethanol containing all :math:`^{1}\text{H}` and all
#     :math:`^{12}\text{C}` isotopes.
#
iso1_sites = [H_CH3, H_CH3, H_CH3, H_CH2, H_CH2, H_OH]

HH_coupling_1 = Coupling(site_index=[0, 3], isotropic_j=7)
HH_coupling_2 = Coupling(site_index=[0, 4], isotropic_j=7)
HH_coupling_3 = Coupling(site_index=[1, 3], isotropic_j=7)
HH_coupling_4 = Coupling(site_index=[1, 4], isotropic_j=7)
HH_coupling_5 = Coupling(site_index=[2, 3], isotropic_j=7)
HH_coupling_6 = Coupling(site_index=[2, 4], isotropic_j=7)

iso1_couplings = [
    HH_coupling_1,
    HH_coupling_2,
    HH_coupling_3,
    HH_coupling_4,
    HH_coupling_5,
    HH_coupling_6,
]
예제 #10
0
def setup_partially_coupled_system3():
    """Systems A-B-C-D-E-F"""
    sys, _ = setup_partially_coupled_system2()
    sys.couplings.insert(0, Coupling(site_index=[0, 1], isotropic_j=1020))
    return sys, [sys]
from mrsimulator.spin_system.tensors import SymmetricTensor

# sphinx_gallery_thumbnail_number = 2

# %%
# For demonstration, we will create two spin systems, one with a single site and other
# with two spin 1/2 sites.

S1 = Site(
    isotope="1H",
    isotropic_chemical_shift=10,  # in ppm
    shielding_symmetric=SymmetricTensor(zeta=-80, eta=0.25),  # zeta in ppm
)
S2 = Site(isotope="1H", isotropic_chemical_shift=-10)
S12 = Coupling(site_index=[0, 1],
               isotropic_j=100,
               dipolar=SymmetricTensor(D=2000, eta=0, alpha=0))

spin_system_1 = SpinSystem(sites=[S1], label="Uncoupled system")
spin_system_2 = SpinSystem(sites=[S1, S2],
                           couplings=[S12],
                           label="Coupled system")

# %%
# **Create a custom method**
#
# Writing a custom method is simply specifying an appropriate list of event objects per
# spectral dimension. In this example, we are interested in a one-dimensional Hahnecho
# method, and we use the generic `Method1D` class as a template. For a Hahnecho, we will
# use two types of Event objects---SpectralEvent and MixingEvent.
#
예제 #12
0
def test_direct_init_spin_system():
    # test-1 # empty spin system
    the_spin_system = SpinSystem(sites=[],
                                 abundance=10,
                                 transition_pathways=None)

    assert the_spin_system.sites == []
    assert the_spin_system.abundance == 10.0
    assert the_spin_system.transition_pathways is None

    assert the_spin_system.json() == {"abundance": "10.0 %"}
    assert the_spin_system.json(units=False) == {
        "abundance": 10.0,
    }

    # test-2 # site
    test_site = Site(isotope="29Si", isotropic_chemical_shift=10)

    assert test_site.isotope.symbol == "29Si"
    assert test_site.isotropic_chemical_shift == 10.0
    assert test_site.property_units["isotropic_chemical_shift"] == "ppm"

    assert test_site.json() == {
        "isotope": "29Si",
        "isotropic_chemical_shift": "10.0 ppm",
    }
    assert test_site.json(units=False) == {
        "isotope": "29Si",
        "isotropic_chemical_shift": 10.0,
    }

    # test-3 # one site spin system
    the_spin_system = SpinSystem(sites=[test_site], abundance=10)
    assert isinstance(the_spin_system.sites[0], Site)
    assert the_spin_system.abundance == 10.0
    assert the_spin_system.json() == {
        "sites": [{
            "isotope": "29Si",
            "isotropic_chemical_shift": "10.0 ppm"
        }],
        "abundance": "10.0 %",
    }
    assert the_spin_system.json(units=False) == {
        "sites": [{
            "isotope": "29Si",
            "isotropic_chemical_shift": 10.0
        }],
        "abundance": 10,
    }

    # test-4 # two sites spin system
    the_spin_system = SpinSystem(sites=[test_site, test_site], abundance=10)
    assert isinstance(the_spin_system.sites[0], Site)
    assert isinstance(the_spin_system.sites[1], Site)
    assert id(the_spin_system.sites[0]) != id(the_spin_system.sites[1])
    assert the_spin_system.abundance == 10.0
    assert the_spin_system.json() == {
        "sites": [
            {
                "isotope": "29Si",
                "isotropic_chemical_shift": "10.0 ppm"
            },
            {
                "isotope": "29Si",
                "isotropic_chemical_shift": "10.0 ppm"
            },
        ],
        "abundance":
        "10.0 %",
    }
    assert the_spin_system.json(units=False) == {
        "sites": [
            {
                "isotope": "29Si",
                "isotropic_chemical_shift": 10.0
            },
            {
                "isotope": "29Si",
                "isotropic_chemical_shift": 10.0
            },
        ],
        "abundance":
        10,
    }

    # test-5 # coupling
    test_coupling = Coupling(site_index=[0, 1],
                             isotropic_j=10,
                             dipolar={"D": 100})

    assert test_coupling.site_index == [0, 1]
    assert test_coupling.isotropic_j == 10.0
    assert test_coupling.property_units["isotropic_j"] == "Hz"

    assert test_coupling.dipolar.D == 100.0
    assert test_coupling.dipolar.property_units["D"] == "Hz"

    assert test_coupling.json() == {
        "site_index": [0, 1],
        "isotropic_j": "10.0 Hz",
        "dipolar": {
            "D": "100.0 Hz"
        },
    }
    assert test_coupling.json(units=False) == {
        "site_index": [0, 1],
        "isotropic_j": 10.0,
        "dipolar": {
            "D": 100.0
        },
    }

    # test-6 #  two sites and one coupling spin system
    the_spin_system = SpinSystem(sites=[test_site, test_site],
                                 couplings=[test_coupling],
                                 abundance=10)
    assert isinstance(the_spin_system.sites[0], Site)
    assert isinstance(the_spin_system.sites[1], Site)
    assert isinstance(the_spin_system.couplings[0], Coupling)
    assert id(the_spin_system.sites[0]) != id(the_spin_system.sites[1])
    assert the_spin_system.abundance == 10.0
    assert the_spin_system.json() == {
        "sites": [
            {
                "isotope": "29Si",
                "isotropic_chemical_shift": "10.0 ppm"
            },
            {
                "isotope": "29Si",
                "isotropic_chemical_shift": "10.0 ppm"
            },
        ],
        "couplings": [{
            "site_index": [0, 1],
            "isotropic_j": "10.0 Hz",
            "dipolar": {
                "D": "100.0 Hz"
            },
        }],
        "abundance":
        "10.0 %",
    }
    assert the_spin_system.json(units=False) == {
        "sites": [
            {
                "isotope": "29Si",
                "isotropic_chemical_shift": 10.0
            },
            {
                "isotope": "29Si",
                "isotropic_chemical_shift": 10.0
            },
        ],
        "couplings": [{
            "site_index": [0, 1],
            "isotropic_j": 10.0,
            "dipolar": {
                "D": 100.0
            }
        }],
        "abundance":
        10,
    }

    # test-5
    the_spin_system = SpinSystem(
        name="Just a test",
        description="The same",
        sites=[
            {
                "isotope": "1H",
                "isotropic_chemical_shift": 0
            },
            {
                "isotope": "17O",
                "isotropic_chemical_shift": -10,
                "quadrupolar": {
                    "Cq": 5.1e6,
                    "eta": 0.5
                },
            },
        ],
        couplings=[{
            "site_index": [0, 1],
            "isotropic_j": 34
        }],
        abundance=4.23,
    )
    assert the_spin_system.name == "Just a test"
    assert the_spin_system.description == "The same"
    assert the_spin_system.sites[0].isotope.symbol == "1H"
    assert the_spin_system.sites[0].isotropic_chemical_shift == 0
    assert the_spin_system.sites[1].isotope.symbol == "17O"
    assert the_spin_system.sites[1].isotropic_chemical_shift == -10
    assert the_spin_system.sites[1].quadrupolar.Cq == 5.1e6
    assert the_spin_system.sites[1].quadrupolar.eta == 0.5
    assert the_spin_system.couplings[0].site_index == [0, 1]
    assert the_spin_system.couplings[0].isotropic_j == 34.0
    assert the_spin_system.abundance == 4.23

    serialize = the_spin_system.json()
    assert serialize == {
        "name":
        "Just a test",
        "description":
        "The same",
        "sites": [
            {
                "isotope": "1H",
                "isotropic_chemical_shift": "0.0 ppm"
            },
            {
                "isotope": "17O",
                "isotropic_chemical_shift": "-10.0 ppm",
                "quadrupolar": {
                    "Cq": "5100000.0 Hz",
                    "eta": 0.5
                },
            },
        ],
        "couplings": [{
            "site_index": [0, 1],
            "isotropic_j": "34.0 Hz"
        }],
        "abundance":
        "4.23 %",
    }
    assert the_spin_system == SpinSystem.parse_dict_with_units(serialize)

    json_no_unit = the_spin_system.json(units=False)
    assert json_no_unit == {
        "name":
        "Just a test",
        "description":
        "The same",
        "sites": [
            {
                "isotope": "1H",
                "isotropic_chemical_shift": 0
            },
            {
                "isotope": "17O",
                "isotropic_chemical_shift": -10.0,
                "quadrupolar": {
                    "Cq": 5100000,
                    "eta": 0.5
                },
            },
        ],
        "couplings": [{
            "site_index": [0, 1],
            "isotropic_j": 34.0
        }],
        "abundance":
        4.23,
    }
    assert the_spin_system == SpinSystem(**json_no_unit)
예제 #13
0
from mrsimulator.methods import BlochDecaySpectrum
from mrsimulator import signal_processing as sp
from mrsimulator.spin_system.tensors import SymmetricTensor

# sphinx_gallery_thumbnail_number = 1

# %%
# **Spin Systems**
#
# Create a 13C-1H coupled spin system.
spin_system = SpinSystem(
    sites=[
        Site(isotope="13C", isotropic_chemical_shift=0.0),
        Site(isotope="1H", isotropic_chemical_shift=0.0),
    ],
    couplings=[Coupling(site_index=[0, 1], dipolar=SymmetricTensor(D=-2e4))],
)
# %%
# **Methods**
#
# Create a BlochDecaySpectrum method.
method = BlochDecaySpectrum(
    channels=["13C"],
    magnetic_flux_density=9.4,  # in T
    spectral_dimensions=[dict(count=2048, spectral_width=8.0e4)],
)

# %%
# **Simulator**
#
# Create the Simulator object and add the method and the spin system object.
예제 #14
0
def test_parse_json_site():
    # test 1 --------------------------------------------------------------------------
    good_json_coupling = {
        "site_index": [0, 1],
        "isotropic_j": "5 Hz",
        "j_symmetric": {
            "zeta": "13.89 Hz",
            "eta": 0.25
        },
    }

    # testing method parse_dict_with_units()
    the_coupling = Coupling.parse_dict_with_units(good_json_coupling)
    assert the_coupling.site_index == [0, 1]
    assert the_coupling.isotropic_j == 5
    assert the_coupling.property_units["isotropic_j"] == "Hz"

    assert the_coupling.j_antisymmetric is None
    assert the_coupling.dipolar is None

    assert the_coupling.j_symmetric.zeta == 13.89
    assert the_coupling.j_symmetric.property_units["zeta"] == "Hz"
    assert the_coupling.j_symmetric.eta == 0.25
    assert the_coupling.j_symmetric.alpha is None
    assert the_coupling.j_symmetric.beta is None
    assert the_coupling.j_symmetric.gamma is None

    # test 2 --------------------------------------------------------------------------
    good_json_2 = {
        "site_index": [5, 3],
        "isotropic_j": "-10 Hz",
        "dipolar": {
            "D": "5.12 kHz",
            "eta": 0.5
        },
    }

    the_coupling = Coupling.parse_dict_with_units(good_json_2)
    assert the_coupling.site_index == [5, 3]
    assert the_coupling.isotropic_j == -10.0
    assert the_coupling.property_units["isotropic_j"] == "Hz"

    assert the_coupling.j_antisymmetric is None
    assert the_coupling.j_symmetric is None

    assert the_coupling.dipolar.D == 5120.0
    assert the_coupling.dipolar.eta == 0.5

    # test 3 bad input ----------------------------------------------------------------
    bad_json = {"zite_index": [0, 1], "isotropic_j": "5 ppm"}

    error = "Error enforcing units for isotropic_j: 5 ppm"
    with pytest.raises(Exception, match=f".*{error}.*"):
        Coupling.parse_dict_with_units(bad_json)

    error = "Error enforcing units for j_symmetric.zeta: ppm."
    with pytest.raises(ValueError, match=f".*{error}.*"):
        Coupling.parse_dict_with_units({
            "site_index": [0, 1],
            "isotropic_j": "10 kHz",
            "j_symmetric": {
                "zeta": "12.1 ppm",
                "eta": 0.5
            },
        })
예제 #15
0
def test_site_dipolar_set_to_None():
    a = Coupling(site_index=[0, 1], dipolar=None)
    assert a.site_index == [0, 1]
    assert a.isotropic_j == 0
    assert a.dipolar is None
예제 #16
0
def test_site_object_methods():
    good_json_2 = {"site_index": [0, 1], "isotropic_j": "-10 Hz"}
    the_coupling = Coupling.parse_dict_with_units(good_json_2)

    # testing method dict()
    result = {
        "site_index": [0, 1],
        "isotropic_j": -10.0,
        "property_units": {
            "isotropic_j": "Hz"
        },
        "name": None,
        "label": None,
        "description": None,
        "dipolar": None,
        "j_symmetric": None,
        "j_antisymmetric": None,
    }
    assert the_coupling.dict() == result, "Failed Coupling.dict()"

    # testing method json()
    result = {"site_index": [0, 1], "isotropic_j": "-10.0 Hz"}
    assert the_coupling.json() == result, "Failed Coupling.json()"

    result = {
        "site_index": [1, 2],
        "isotropic_j": "10.0 Hz",
        "j_symmetric": {
            "zeta": "12.1 Hz",
            "eta": 0.1,
            "alpha": "2.1 rad"
        },
        "j_antisymmetric": {
            "zeta": "-1.1 Hz",
            "alpha": "0.1 rad",
            "beta": "2.5 rad",
        },
        "dipolar": {
            "D": "10000.0 Hz",
            "eta": 0.6
        },
    }
    the_coupling = Coupling(
        site_index=[1, 2],
        isotropic_j=10,
        j_symmetric={
            "zeta": 12.1,
            "eta": 0.1,
            "alpha": 2.1
        },
        j_antisymmetric={
            "zeta": -1.1,
            "alpha": 0.1,
            "beta": 2.5
        },
        dipolar={
            "D": 10e3,
            "eta": 0.6
        },
    )
    assert the_coupling.json() == result, "Failed Coupling.json()"
예제 #17
0
def add_site(doctest_namespace):

    doctest_namespace["np"] = np
    doctest_namespace["plt"] = plt
    doctest_namespace["SpinSystem"] = SpinSystem
    doctest_namespace["Simulator"] = Simulator
    doctest_namespace["Site"] = Site
    doctest_namespace["Coupling"] = Coupling
    doctest_namespace["SymmetricTensor"] = SymmetricTensor
    doctest_namespace["st"] = SymmetricTensor
    doctest_namespace["pprint"] = pprint
    doctest_namespace["Isotope"] = Isotope
    doctest_namespace["sp"] = sp
    doctest_namespace["Method2D"] = Method2D

    site1 = Site(
        isotope="13C",
        isotropic_chemical_shift=20,
        shielding_symmetric=SymmetricTensor(zeta=10, eta=0.5),
    )
    doctest_namespace["site1"] = site1

    coupling1 = Coupling(
        site_index=[0, 1],
        isotropic_j=20,
        j_symmetric=SymmetricTensor(zeta=10, eta=0.5),
    )
    doctest_namespace["coupling1"] = coupling1

    site2 = Site(
        isotope="1H",
        isotropic_chemical_shift=-4,
        shielding_symmetric=SymmetricTensor(zeta=2.1, eta=0.1),
    )
    doctest_namespace["site2"] = site2

    site3 = Site(
        isotope="27Al",
        isotropic_chemical_shift=120,
        shielding_symmetric=SymmetricTensor(zeta=2.1, eta=0.1),
        quadrupole=SymmetricTensor(Cq=5.1e6, eta=0.5),
    )
    doctest_namespace["site3"] = site3

    spin_system_1H_13C = SpinSystem(sites=[site1, site2])
    doctest_namespace["spin_system_1H_13C"] = spin_system_1H_13C

    spin_system_1 = SpinSystem(sites=[site1])
    doctest_namespace["spin_system_1"] = spin_system_1

    doctest_namespace["spin_systems"] = SpinSystem(sites=[site1, site2, site3])

    spin_systems = [SpinSystem(sites=[site]) for site in [site1, site2, site3]]

    sim = Simulator()
    sim.spin_systems += spin_systems
    doctest_namespace["sim"] = sim

    # coesite
    O17_1 = Site(
        isotope="17O",
        isotropic_chemical_shift=29,
        quadrupolar=SymmetricTensor(Cq=6.05e6, eta=0.000),
    )
    O17_2 = Site(
        isotope="17O",
        isotropic_chemical_shift=41,
        quadrupolar=SymmetricTensor(Cq=5.43e6, eta=0.166),
    )
    O17_3 = Site(
        isotope="17O",
        isotropic_chemical_shift=57,
        quadrupolar=SymmetricTensor(Cq=5.45e6, eta=0.168),
    )
    O17_4 = Site(
        isotope="17O",
        isotropic_chemical_shift=53,
        quadrupolar=SymmetricTensor(Cq=5.52e6, eta=0.169),
    )
    O17_5 = Site(
        isotope="17O",
        isotropic_chemical_shift=58,
        quadrupolar=SymmetricTensor(Cq=5.16e6, eta=0.292),
    )

    sites = [O17_1, O17_2, O17_3, O17_4, O17_5]
    abundance = [0.83, 1.05, 2.16, 2.05, 1.90]  # abundance of each spin system
    spin_systems = [
        SpinSystem(sites=[s], abundance=a) for s, a in zip(sites, abundance)
    ]

    method = BlochDecayCTSpectrum(
        channels=["17O"],
        rotor_frequency=14000,
        spectral_dimensions=[{
            "count": 2048,
            "spectral_width": 50000
        }],
    )

    sim_coesite = Simulator()
    sim_coesite.spin_systems += spin_systems
    sim_coesite.methods += [method]

    doctest_namespace["sim_coesite"] = sim_coesite

    # Transitions
    t1 = Transition(initial=[0.5, 0.5], final=[0.5, -0.5])
    doctest_namespace["t1"] = t1

    t2 = Transition(initial=[0.5, 0.5], final=[-0.5, 0.5])
    doctest_namespace["t2"] = t2

    path = TransitionPathway([t1, t2])
    doctest_namespace["path"] = path
# - 1) an uncoupled :math:`^{119}\text{Sn}` and
# - 2) a coupled :math:`^{119}\text{Sn}`-:math:`^{117}\text{Sn}` spin systems.
sn119 = Site(
    isotope="119Sn",
    isotropic_chemical_shift=-210,
    shielding_symmetric={
        "zeta": 700,
        "eta": 0.1
    },
)
sn117 = Site(
    isotope="117Sn",
    isotropic_chemical_shift=0,
)
j_sn = Coupling(
    site_index=[0, 1],
    isotropic_j=8150.0,
)

sn117_abundance = 7.68  # in %
spin_systems = [
    # uncoupled spin system
    SpinSystem(sites=[sn119], abundance=100 - sn117_abundance),
    # coupled spin systems
    SpinSystem(sites=[sn119, sn117],
               couplings=[j_sn],
               abundance=sn117_abundance),
]

# %%
# **Method**
예제 #19
0
                isotope="13C",
                isotropic_chemical_shift=0.0,  # in ppm
                shielding_symmetric=SymmetricTensor(
                    zeta=18.87562,  # in ppm
                    eta=0.4,
                    beta=beta,
                ),
            ),
            Site(
                isotope="1H",
                isotropic_chemical_shift=0.0,  # in ppm
            ),
        ],
        couplings=[
            Coupling(
                site_index=[0, 1], isotropic_j=200.0, dipolar=SymmetricTensor(D=-2.1e4)
            )
        ],
    )
    for beta in beta_orientation
]
# %%
# 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"],