BrilleInterpolator
The BrilleInterpolator
object provides an easy interface to the Brille library for phonon frequencies and eigenvectors.
It can be created from a ForceConstants
object, then used to perform linear (rather than Fourier) interpolation to calculate phonon frequencies and eigenvectors at specific q-points.
Linear interpolation may be less accurate than the Fourier interpolation performed by ForceConstants
,
but should be faster for large unit cells, particularly those that require the computationally expensive dipole correction calculation.
You should test this on your particular machine and material first to see if it provides a performance benefit.
When creating a BrilleInterpolator
from ForceConstants
, Brille calculates the first Brillouin Zone (BZ) for the provided ForceConstants.crystal
,
then creates a grid of points distributed across it.
Euphonic calculates frequencies and eigenvectors at each of these grid vertices (q-points) by Fourier interpolation, which are then used to fill the grid with data.
Both the grid and the crystal are stored in the created BrilleInterpolator
object.
To calculate the frequencies and eigenvectors at a particular q-point, Brille folds the q-point into the 1st BZ, then searches for the nearest grid points and linearly interpolates between them.
Creating From Force Constants
Once a ForceConstants
object has been created, it can be used to create a BrilleInterpolator
object with BrilleInterpolator.from_force_constants
.
The Brille grid type can be chosen with the grid_type
argument (although the default trellis
is recommended),
and the number or number density of q-points in the grid can be chosen with the grid_npts
and grid_density
arguments.
A grid with more points will take longer to initialise and require more memory, but can give more accurate results.
For more information on what these mean, see the Brille documentation at https://brille.github.io/.
There is also a command-line tool, euphonic-brille-convergence which can help with choosing the number of grid points by comparing Euphonic and Brille frequencies and eigenvectors.
An example of creating a BrilleInterpolator
object from ForceConstants
is shown below:
from euphonic import ForceConstants
from euphonic.brille import BrilleInterpolator
fc = ForceConstants.from_castep('La2Zr2O7.castep_bin')
bri = BrilleInterpolator.from_force_constants(fc, grid_npts=1000)
Calculating Phonon Frequencies and Eigenvectors
Phonon frequencies and eigenvectors are calculated using
BrilleInterpolator.calculate_qpoint_phonon_modes
,
and is very similar to
ForceConstants.calculate_qpoint_phonon_modes
.
A Numpy array of q-points of shape (n_qpts, 3) must be provided, and a QpointPhononModes object is returned.
Kwargs will also be passed to Brille’s ir_interpolate_at
function, which can be used to set the number of threads with threads
for example, but by default the number of threads will be the same as used in the Euphonic Fourier interpolation.
An example is below:
import seekpath
import numpy as np
from euphonic import ForceConstants
from euphonic.brille import BrilleInterpolator
fc = ForceConstants.from_castep('La2Zr2O7.castep_bin')
bri = BrilleInterpolator.from_force_constants(fc, grid_npts=1000)
# Generate a recommended q-point path using seekpath
cell = bri.crystal.to_spglib_cell()
qpts = seekpath.get_explicit_k_path(cell)["explicit_kpoints_rel"]
# Calculate frequencies/eigenvectors
phonons = bri.calculate_qpoint_phonon_modes(qpts, threads=4)
Docstring
- class BrilleInterpolator(crystal, grid)
A class to perform linear interpolation of eigenvectors and frequencies at arbitrary q-points using the Brille library
- Variables
crystal (Crystal) – Lattice and atom information
- __init__(crystal, grid)
- Parameters
crystal (
Crystal
) – Lattice and atom informationgrid (
Union
[BZTrellisQdc
,BZMeshQdc
,BZNestQdc
]) – A Brille grid filled with phonon eigenvectors in Cartesian coordinates and phonon frequencies in Hartree. See Brille documentation for details.
- calculate_qpoint_phonon_modes(qpts, **kwargs)
Calculate phonon frequencies and eigenvectors at specified q-points via linear interpolation
- Parameters
qpts (
ndarray
) – Shape (n_qpts, 3) float ndarray. The q-points to interpolate onto in reciprocal cell vector units.**kwargs – Will be passed to the brille.BZTrellis/Mesh/Nest.ir_interpolate_at method. By default useparallel=True and threads=multiprocessing.cpu_count() are passed.
- Return type
- Returns
qpoint_phonon_modes – An object containing frequencies and eigenvectors linearly interpolated at each q-point
- calculate_qpoint_frequencies(qpts, **kwargs)
Calculate phonon frequencies at specified q-points via linear interpolation
- Parameters
qpts (
ndarray
) – Shape (n_qpts, 3) float ndarray. The q-points to interpolate onto in reciprocal cell vector units.**kwargs – Will be passed to the brille.BZTrellis/Mesh/Nest.ir_interpolate_at method. By default useparallel=True and threads=multiprocessing.cpu_count() are passed.
- Return type
- Returns
qpoint_frequencies – An object containing frequencies linearly interpolated at each q-point
- classmethod from_force_constants(force_constants, grid_type='trellis', grid_npts=1000, grid_density=None, grid_kwargs=None, interpolation_kwargs=None)
Generates a grid over the irreducible Brillouin Zone to be used for linear interpolation with Brille, with properties determined by the grid_type, grid_npts and grid_kwargs arguments. Then uses ForceConstants to fill the grid points with phonon frequencies and eigenvectors via Fourier interpolation. This returns a BrilleInterpolator object that can then be used for linear interpolation.
- Parameters
grid_type (
str
) – The Brille grid type to be used, one of {‘trellis’, ‘mesh’, ‘nest’}, creating a brille.BZTrellisQdc, brille.BZMeshQdc or brille.BZNestQdc grid respectivelygrid_npts (
int
) – The approximate number of q-points in the Brille grid. This is used to set the kwargs for the grid creation so that a grid with approximately the desired number of points is created, note this number is approximate as the number of grid points generated depends on Brille’s internal algorithm. If this number is higher, the linear interpolation is likely to give values closer to the ForceConstants Fourier interpolation, but the initialisation and memory costs will be higher. This does nothing if grid_kwargs is set.grid_density (
Optional
[int
]) – The approximate number density of q-points per 1/angstrom^3 volumegrid_kwargs (
Optional
[Dict
[str
,Any
]]) – Kwargs to be passed to the grid constructor (e.g. brille.BZTrellisQdc). If set grid_npts does nothing.interpolation_kwargs (
Optional
[Dict
[str
,Any
]]) – Kwargs to be passed to ForceConstants.calculate_qpoint_phonon_modes. Note that insert_gamma and reduce_qpoints are incompatible and will be ignored.
- Return type
TypeVar
(T
, bound= BrilleInterpolator)- Returns
brille_interpolator