pyspinw.sample#

Different Kinds of samples

Classes

CrystalDomain(transformation, weighting)

Orientation and amount of crystalline domain (e.g. one of a twin, or a domain in the traditional sense).

MagneticFieldPowder(hamiltonian)

Powder in magnetic field (slightly different parallelisation method to Powder)

Multidomain(hamiltonian, domains)

Sample consisting of multiple domains

ParameterizedPowderSpectrum(powder, ...[, ...])

A powder spectrum that has been parameterised

Powder(hamiltonian)

Sample is a powder

Sample(hamiltonian)

Representation of the macrostructure of a sample used in an experiment (Twin, Powder etc)

Sample1D(hamiltonian)

Sample where the direction of q does not matter

Sample3D(hamiltonian)

Sample where the direction of q matters

ScalingMethod(*values)

Scaling methods for plots

SingleCrystal(hamiltonian)

Specifies a single crystal sample

Twin(hamiltonian, twinning_plane_normal, ...)

Specify a twinned crystal by a twinning plane.

TwoMagnon(hamiltonian)

Two magnon excitations in a single crystal

class pyspinw.sample.CrystalDomain(transformation: ArrayLike, weighting: float)#

Bases: SPWSerialisable

Orientation and amount of crystalline domain (e.g. one of a twin, or a domain in the traditional sense)

serialisation_name = 'crystal_domain'#
class pyspinw.sample.MagneticFieldPowder(hamiltonian: Hamiltonian)#

Bases: Sample1D

Powder in magnetic field (slightly different parallelisation method to Powder)

class pyspinw.sample.Multidomain(hamiltonian: Hamiltonian, domains: list[CrystalDomain | tuple[ArrayLike, float]])#

Bases: Sample3D

Sample consisting of multiple domains

sample_name = 'multidomain'#
class pyspinw.sample.ParameterizedPowderSpectrum(powder: Powder, parameters: Sequence[str | list[str] | list[tuple[Exchange | Anisotropy | str, str]] | tuple[Sequence[Exchange | Anisotropy | str], str] | tuple[Exchange | Anisotropy | str, str]], path: Path1D | EmpiricalPath1D | ArrayLike, n_samples: int = 100, method: SphericalPointGeneratorType | str = 'fibonacci', min_energy: float | None = None, max_energy: float | None = None, n_energy_bins: int | None = None, energy_stddev: float | None = None, random_seed: int | None = None, use_rust: bool = True, find_ground_state_with: dict | None = None, ignore_imaginary: bool = False)#

Bases: object

A powder spectrum that has been parameterised

class pyspinw.sample.Powder(hamiltonian: Hamiltonian)#

Bases: Sample1D

Sample is a powder

parameterized_spectrum(parameters: Sequence[str | list[str] | list[tuple[Exchange | Anisotropy | str, str]] | tuple[Sequence[Exchange | Anisotropy | str], str] | tuple[Exchange | Anisotropy | str, str]], path: Path1D | EmpiricalPath1D | ArrayLike, n_samples: int = 100, method: SphericalPointGeneratorType | str = 'fibonacci', min_energy: float | None = None, max_energy: float | None = None, n_energy_bins: int | None = None, energy_stddev: float | None = None, random_seed: int | None = None, use_rust: bool = True, find_ground_state_with: dict | None = None, ignore_imaginary: bool = False)#

Get the powder spectrum as a function of parameters

show_spectrum(path: Path1D | EmpiricalPath1D | ArrayLike | tuple, n_samples: int = 100, method: SphericalPointGeneratorType | str = 'fibonacci', min_energy: float | None = None, max_energy: float | None = None, n_energy_bins: int | None = None, energy_stddev: float | None = None, random_seed: int | None = None, scaling_method: ScalingMethod | str = 'linear', show: bool = True, new_figure: bool = True, use_rust: bool = True, data: ArrayLike | None = None, ignore_imaginary: bool = False)#

Show the powder spectrum

spectrum(path: Path1D | EmpiricalPath1D | ArrayLike, n_samples: int = 100, method: SphericalPointGeneratorType | str = 'fibonacci', min_energy: float | None = None, max_energy: float | None = None, n_energy_bins: int | None = None, energy_stddev: float | None = None, random_seed: int | None = None, use_rust: bool = True, ignore_imaginary: bool = False)#

Get the powder spectrum

class pyspinw.sample.Sample(hamiltonian: Hamiltonian)#

Bases: ABC, SPWSerialisable

Representation of the macrostructure of a sample used in an experiment (Twin, Powder etc)

sample_name = '<base-class>'#
serialisation_name = 'sample'#
class pyspinw.sample.Sample1D(hamiltonian: Hamiltonian)#

Bases: Sample

Sample where the direction of q does not matter

An important difference from Sample3D is there’s no option to just get energies, this is because they will form a continuum in 1D. The 3D q-energy curves can be obtained from the Hamiltonian, they’re just not exposed at this level

class pyspinw.sample.Sample3D(hamiltonian: Hamiltonian)#

Bases: Sample

Sample where the direction of q matters

energies(path: Path, field: ArrayLike | None = None, use_rust: bool = True) → list[ndarray]#

Get the energies along a specified path

energies_and_intensities(path: Path, field: ArrayLike | None = None, use_rust: bool = True, use_rotating: bool = True, intensity_unit: IntensityUnits | str = 'cell')#

Get energy and intensity data

intensity_map(q_slice: Slice, vmin: float = 0, vmax: float | None = None, field: ArrayLike | None = None, show: bool = True, new_figure: bool = True, use_rust: bool = True, use_rotating: bool = True, intensity_unit: IntensityUnits | str = 'cell', cmap: str = 'magma_r', origin: str = 'lower')#

Plot a reciprocal space map with intensity integrated over energy.

Parameters:
  • q_slice (Slice) – 2D slice object defining the grid of q-points. Energy bounds e_min and e_max (in meV) are taken from this object.

  • vmin – Color scale limits

  • vmax – Color scale limits

  • field – external field

  • show – Whether to display the plot

  • new_figure – Whether to create a new figure

  • use_rust – Same as energies_and_intensities

  • use_rotating – Same as energies_and_intensities

  • intensity_unit – Same as energies_and_intensities

  • cmap – Matplotlib colormap name

  • origin – ‘lower’ or ‘upper’ for matplotlib imshow origin

spaghetti_plot(path: Path, evect: ArrayLike | None = None, dE: float | Callable | None = None, vmin: float = 0, vmax: float | None = None, field: ArrayLike | None = None, show: bool = True, new_figure: bool = True, use_rust: bool = True, use_rotating: bool = True, intensity_unit: IntensityUnits | str = 'cell', scale: str = 'linear')#

Create a spaghetti diagram with intensity as colorfill overplotted by mode energies

class pyspinw.sample.ScalingMethod(*values)#

Bases: Enum

Scaling methods for plots

LINEAR = 'linear'#
LOG = 'log'#
class pyspinw.sample.SingleCrystal(hamiltonian: Hamiltonian)#

Bases: Sample3D

Specifies a single crystal sample

sample_name = 'single_crystal'#
class pyspinw.sample.Twin(hamiltonian: Hamiltonian, twinning_plane_normal: ArrayLike, second_twin_fraction: float, units: CoordsUnits | str = 'lu')#

Bases: Multidomain

Specify a twinned crystal by a twinning plane.

This is a special case of Multidomain, which can use completely general transformations, and have more than one “twin”.

sample_name = 'twin'#
class pyspinw.sample.TwoMagnon(hamiltonian: Hamiltonian)#

Bases: Sample3D

Two magnon excitations in a single crystal