Skip to content

spin#

Spin systems: seed one from a molecule, simulate it, and fit it to a scan with Scan.fit_spin_system.

seed #

seed(
    smiles: str,
    nucleus: Nucleus = H1,
    decoupled: bool = True,
    use_assignments: bool = False,
    include_exchangeable: bool = False,
    selected_atoms: Sequence[int] = ...,
) -> SeedSpinSystemResponse

Build a spin system from a molecule, with predicted or assigned shifts and couplings.

Parameters:

Name Type Description Default
smiles str

The molecule.

required
nucleus Nucleus

Nucleus.H1 or Nucleus.C13.

H1
decoupled bool

For 13C, whether the lines are singlets (proton decoupled); ignored for 1H.

True
use_assignments bool

Take shifts and couplings the active scan's assignment table holds instead of predicted ones.

False
include_exchangeable bool

Include exchangeable protons (1H).

False
selected_atoms Sequence[int]

Heavy-atom indices of the coupled cluster to build, when the molecule has several clusters and the response says a selection is needed.

...

Returns:

Type Description
SeedSpinSystemResponse

The spins, the coupling matrix in Hz, the symmetry ties and the coupled clusters.

Raises:

Type Description
ValueError

When smiles is empty or not a valid molecule, or nucleus is not 1H or 13C.

simulate #

simulate(
    system: SeedSpinSystemResponse | FitSpinSystemResult,
    spectrometer_frequency_mhz: float,
    observed_nucleus: Nucleus | None = None,
    linewidth_hz: float = 1.0,
    line_shape: SpinLineShape = LORENTZIAN,
    n_points: int = 8192,
    frequency_range_hz: tuple[float, float] | None = None,
    frequencies_in_ppm: bool = False,
    include_signal: bool = False,
) -> SimulateSpinSystemResponse

Simulate the spectrum of a spin system.

Parameters:

Name Type Description Default
system SeedSpinSystemResponse | FitSpinSystemResult

A seeded or fitted system.

required
spectrometer_frequency_mhz float

Proton frequency of the spectrometer in MHz.

required
observed_nucleus Nucleus | None

The nucleus observed; the seed's, else 1H, when omitted.

None
linewidth_hz float

Full width at half height of every line.

1.0
line_shape SpinLineShape

Shape of every line.

LORENTZIAN
n_points int

Points of the spectrum.

8192
frequency_range_hz tuple[float, float] | None

Span of the axis in Hz; derived from the lines when omitted.

None
frequencies_in_ppm bool

Give the axis in ppm instead of Hz.

False
include_signal bool

Also return the free-induction decay.

False

Returns:

Type Description
SimulateSpinSystemResponse

The simulated spectrum trace, the signal trace when asked for, and the transitions.

Raises:

Type Description
ValueError

When the spins and couplings do not form a valid system, or an option is out of range.