pyspinw.hamiltonian#
Selection of different Hamiltonians
Functions
|
Bins a set of energy/intensity into a spectrum with Gaussian broadening |
|
Removes degenerate and ghost (zero-intensity) modes from spectrum |
|
Returns floating point unique values within a given tolerance |
Classes
|
Hamiltonian base class |
|
Parameterisation of a Hamiltonian |
- class pyspinw.hamiltonian.Hamiltonian(structure: Structure, exchanges: list[Exchange], anisotropies: list[Anisotropy] | None = None)#
Bases:
SPWSerialisableHamiltonian base class
- property anisotropies#
Get the anisotropies
- anisotropies_by_name(regex)#
Get list of anisotropies whose names match the regex
- energies_and_intensities(path: Path, field: ArrayLike | None = None, use_rust: bool = True, use_rotating: bool = True, intensity_unit: IntensityUnits | str = 'cell', components: str = 'Sperp')#
Calculate the energy levels and intensities of the system for the given q-vectors.
- Parameters:
path – required Path along which to calculate
field – Optional magnetic field vector, in tesla
use_rust – Whether to use Rust or Python calculator (default: True)
use_rotating – Whether to use the rotating frame calculator if possible (default: True)
intensity_unit – Whether to normalise intensity per unit cell or spin (default: ‘cell’)
components – Whether to compute a particular polarised neutron component (default: ‘Sperp’); for the accepted strings, including ‘all’, see
pyspinw.polarisation.calculate_polarised_intensity()
- energy_plot(path: Path, field: ArrayLike | None = None, show: bool = True, new_figure: bool = True, use_rust: bool = True)#
Create a spaghetti diagram
- property exchanges#
Get the exchanges
- exchanges_by_name(regex)#
Get list of exchanges whose names match the regex
- expanded(supercell_size: tuple[int, int, int] | None = None)#
Expand the supercell structure into a single cell structure
- ground_state(fixed: list[Site] | None = None, planar: list[Site | tuple[Site, ArrayLike]] | None = None, planar_axis: ArrayLike | None = None, field: ArrayLike | None = None, step_size: float = 0.1, initial_randomisation: InitialRandomisation | str = InitialRandomisation.JITTER, seed: int | None = None, rtol: float = 1e-10, atol: float = 1e-12, max_iters: int = 1000, verbose: bool = True)#
Get the classical ground state via gradient descent
For more direct control, use the
ClassicalEnergyMinimisationclass- Parameters:
fixed – List of sites that should be ignored by the minimisation, i.e. fixed in place
planar – List of sites, or (site, axis) tuples that should be constrained to a plane
planar_axis – Axis to use for planar constraints if not specified explicitly, default=[0,0,1]
field – Magnetic field applied, in tesla
step_size – Size of step to make relative to the force, smaller values than the default might be needed for systems with high energy.
initial_randomisation – Option to RANDOMISE or JITTER the starting state, default JITTER, can also be NONE
seed – Seed to use in any randomisation steps
rtol – Convergence criterion, stop when [energy change] < rtol x [initial energy change]
atol – Convergence criterion, stop when [energy change] < atol
max_iters – Limit on the number of iterations
verbose – Print information about the process to stdout
- Returns:
A new
Hamiltonianwith optimised spin state
- 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
- parameterize(*parameters: str | list[str] | list[tuple[Exchange | Anisotropy | str, str]] | tuple[Sequence[Exchange | Anisotropy | str], str] | tuple[Exchange | Anisotropy | str, str], find_ground_state_with: dict | None = None) HamiltonianParameterization#
Get a function that maps floats to a hamiltonian with the floats controlling the specified parameters
- print_summary()#
Print a textual summary to stdout
- serialisation_name = 'hamiltonian'#
- sorted_positive_energies(path: Path, field: ArrayLike | None = None, use_rust: bool = True) list[ndarray]#
Return energies as series corresponding to q, sorted by energy
- 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', components: str = 'Sperp')#
Create a spaghetti diagram with intensity as colorfill overplotted by mode energies
- spaghetti_plot_dual(path: Path, 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', components: str = 'Sperp')#
Create a spaghetti diagram with energy top and intensity bottom
- spinwave_calculation(path: Path, field: ArrayLike | None = None, use_rust: bool = True, use_rotating: bool = True, intensity_unit: IntensityUnits | str = 'cell', save_sab: bool = False, save_wavefunctions: bool = False) tuple[ndarray, ndarray, ndarray, ndarray]#
Performs a spin wave calculation of the system for the given q-point path.
- Parameters:
path – required Path along which to calculate
field – Optional magnetic field vector, in tesla
use_rust – Whether to use Rust or Python calculator (default: True)
use_rotating – Whether to use the rotating frame calculator if possible (default: True)
intensity_unit – Whether to normalise intensity per unit cell or spin (default: ‘cell’)
save_sab – Whether return the Sab matrices (default: False)
save_wavefunctions – Whether to return the eigenvectors at each Q-point (default: False)
- Returns:
energies, intensities, sab, wavefunctions
If save_sab or save_wavefunctions are False, then sab or wavefunctions will be None
- property structure#
Get the magnetic structure
- symmetry_filled() Hamiltonian#
Check that the hamiltonian obeys its symmetry
- symmetry_transformed(operation: SpaceOperation)#
Transform the Hamiltonian using this spacegroup
If your system is physical this should not do anything to it except change the names/colors etc around. Useful for checking things related to symmetry.
- property text_summary: str#
String giving details of the system
- updated(structure: Structure | None = None, exchanges: list[Exchange] | None = None, anisotropies: list[Anisotropy] | None = None)#
Create a new Hamiltonian, but with some fields replaced (those not None)
- without_nonmagnetic()#
Get a copy of this Hamiltonian with the nonmagnetic sites removed
- class pyspinw.hamiltonian.HamiltonianParameterization(hamiltonian: Hamiltonian, *parameters: str | list[str] | list[tuple[Exchange | Anisotropy | str, str]] | tuple[Sequence[Exchange | Anisotropy | str], str] | tuple[Exchange | Anisotropy | str, str], find_ground_state_with: dict | None = None)#
Bases:
objectParameterisation of a Hamiltonian
This is a callable class that returns a Hamiltonian with exchanges set by specified parameters
- pyspinw.hamiltonian.egrid(energy: ArrayLike, intensity: ArrayLike, evect: ArrayLike, dE: float | Callable)#
Bins a set of energy/intensity into a spectrum with Gaussian broadening
- pyspinw.hamiltonian.omegasum(energy: ArrayLike, intensity: ArrayLike, tol: float = 1e-05, zeroint: int = 0, is_series: bool = True)#
Removes degenerate and ghost (zero-intensity) modes from spectrum
- pyspinw.hamiltonian.uniquetol(values: ArrayLike, tol: float = 1e-05)#
Returns floating point unique values within a given tolerance