compose_spinor#

blochsim.compose_spinor()[source]#

Return the Cayley-Klein pair of a shaped pulse, composed over its samples.

One SU(2) rotation per sample, composed in play order, about the effective field (drive.real, drive.imag, turn_z).

Parameters:
  • drive (torch.Tensor or iterable of torch.Tensor) – Transverse field per sample, in radians per sample: a tensor with the sample axis first, or an iterable of per-sample tensors.

  • turn_z (torch.Tensor or iterable of torch.Tensor) – Longitudinal turn per sample, in radians, one per spin. A tensor holds for every sample (a static gradient); an iterable gives one tensor per sample.

Returns:

a, b – Complex128, shaped like the turn. Each sample rotates right-handedly by the length of the effective-field vector, so a spin along +z ends with Mxy = -2 conj(a b) and Mz = |a|^2 - |b|^2. A real drive of area t on resonance gives (cos(t/2), -i sin(t/2)).

Return type:

torch.Tensor

Raises:

ValueError – If an iterable turn_z and drive differ in length.

Examples using blochsim.compose_spinor#

RF pulse design by optimal control

RF pulse design by optimal control