Library of energy engines
Elastic
Functions that define a term in the elastic energy.
These functions will be added into <class interaction> for automatic differentiation.
Notes
This file is part of OpenFerro.
- openferro.engine.elastic.homo_elastic_energy(global_strain, parameters)[source]
Returns the homogeneous elastic energy of a strain field.
- Parameters:
global_strain (jnp.ndarray) – The global strain of a supercell, shape=(6)
parameters (jnp.ndarray) – The parameters of the energy function
- Returns:
The homogeneous elastic energy
- Return type:
jnp.ndarray
- openferro.engine.elastic.pV_energy(global_strain, parameters)[source]
Returns pressure * (volume - reference volume)
- Parameters:
global_strain (jnp.ndarray) – The global strain of a supercell, shape=(6)
parameters (jnp.ndarray) – The parameters of the energy function
- Returns:
The pV energy
- Return type:
jnp.ndarray
- openferro.engine.elastic.inhomo_elastic_energy(local_displacement, parameters)[source]
Returns the inhomogeneous elastic energy of a strain field.
- Parameters:
local_displacement (jnp.ndarray) – The local displacement field, shape=(nx, ny, nz, 3)
parameters (tuple) – The parameters of the energy function containing: - B11 (float): elastic constant B11 - B12 (float): elastic constant B12 - B44 (float): elastic constant B44
- Returns:
The total elastic energy (homogeneous + inhomogeneous)
- Return type:
jnp.ndarray
Ferroelectric
Functions that define a ferroelectric term in the Hamiltonian. They will be added into <class interaction> for automatic differentiation.
- openferro.engine.ferroelectric.self_energy_onsite_isotropic(field, parameters)[source]
Returns the isotropic self-energy of a 3D field. See Eq.(2-3) in [Zhong, W., David Vanderbilt, and K. M. Rabe. Physical Review B 52.9 (1995): 6301.] for meaning of the parameters.
- Parameters:
field (jnp.array) – The field to calculate the energy
parameters (jax.numpy array) – The parameters of the energy function
- Returns:
The energy of the field
- Return type:
jnp.array
- openferro.engine.ferroelectric.self_energy_onsite_scalar(field, parameters)[source]
Returns the self-energy of a scalar field. E= sum_i E_i. (sum over the lattice sites i) E_i = k_2 * u_i^2 + alpha * u_i^4
- Parameters:
field (jnp.array) – The field to calculate the energy
parameters (jax.numpy array) – The parameters of the energy function
- Returns:
The energy of the field
- Return type:
jnp.array
- openferro.engine.ferroelectric.short_range_1stnn_isotropic_scalar(field, parameters)[source]
Returns the short-range interaction of nearest neighbors for a R^3 field defined on a lattice with periodic boundary conditions.
- Parameters:
field (jnp.array) – The field to calculate the energy
parameters (jax.numpy array) – The parameters of the energy function
- Returns:
The energy of the field
- Return type:
jnp.array
- openferro.engine.ferroelectric.short_range_1stnn_isotropic(field, parameters)[source]
Returns the short-range interaction of nearest neighbors for a R^3 field defined on a isotropic lattice with periodic boundary conditions.
- Parameters:
field (jnp.array) – The field to calculate the energy
parameters (jax.numpy array) – The parameters of the energy function
- Returns:
The energy of the field
- Return type:
jnp.array
- openferro.engine.ferroelectric.short_range_1stnn_anisotropic(field, parameters)[source]
Returns the short-range interaction of nearest neighbors for a R^3 field defined on a anisotropic lattice with periodic boundary conditions.
- Parameters:
field (jnp.array) – The field to calculate the energy
parameters (jax.numpy array) – The parameters of the energy function
- Returns:
The energy of the field
- Return type:
jnp.array
- openferro.engine.ferroelectric.short_range_2ednn_isotropic(field, parameters)[source]
Returns the short-range interaction of nearest neighbors for a R^3 field defined on a lattice with periodic boundary conditions.
- Parameters:
field (jnp.array) – The field to calculate the energy
parameters (jax.numpy array) – The parameters of the energy function
- Returns:
The energy of the field
- Return type:
jnp.array
- openferro.engine.ferroelectric.get_short_range_3rdnn_isotropic()[source]
Returns the engine of short-range interaction of third nearest neighbors for a R^3 field defined on a lattice with periodic boundary conditions.
- Returns:
The interaction function
- Return type:
function
- openferro.engine.ferroelectric.homo_strain_dipole_interaction(global_strain, dipole_field, parameters)[source]
Returns the homogeneous strain dipole interaction energy.
- Parameters:
global_strain (jnp.array) – Shape=(6), the global strain of a supercell
dipole_field (jnp.array) – Shape=(nx, ny, nz, 3), the dipole field
parameters (jax.numpy array) – The parameters of the energy function containing B1xx : Elastic constant B1xx B1yy : Elastic constant B1yy B4yz : Elastic constant B4yz
- Returns:
The homogeneous strain dipole interaction energy
- Return type:
jnp.array
- openferro.engine.ferroelectric.get_inhomo_strain_dipole_interaction(enable_jit=True)[source]
Returns the inhomogeneous strain dipole interaction function.
- Parameters:
enable_jit (bool, optional) – Whether to enable JIT compilation, by default True
- Returns:
The interaction function
- Return type:
function
- openferro.engine.ferroelectric.dipole_efield_interaction(field, parameters)[source]
Returns the dipole-electric field interaction energy.
- Parameters:
field (jnp.array) – The field to calculate the energy
parameters (jax.numpy array) – The parameters of the energy function
- Returns:
The interaction energy
- Return type:
jnp.array
Magnetic
Functions that define a term in the magnetic Hamiltonian. They will be added into <class interaction> for automatic differentiation.
- openferro.engine.magnetic.get_isotropic_exchange_energy_engine(rollers)[source]
Returns the exchange energy engine for a R^3 field defined on a lattice with periodic boundary conditions.
- Parameters:
rollers (list) – List of jnp.roll functions specifying the neighbors
- Returns:
Energy engine function
- Return type:
callable
- openferro.engine.magnetic.cubic_anisotropy_energy(field, parameters)[source]
Returns the anisotropy energy of the field.
- Parameters:
field (ndarray) – The magnetic field
parameters (ndarray) – Array containing K1 and K2 anisotropy constants
- Returns:
The anisotropy energy: -K1*(mx^2*my^2 + my^2*mz^2 + mx^2*mz^2) - K2*mx^2*my^2*mz^2
- Return type:
- openferro.engine.magnetic.Dzyaloshinskii_Moriya_energy(field, parameters)[source]
Returns the Dzyaloshinskii-Moriya energy of the field.
- Parameters:
field (ndarray) – The magnetic field
parameters (ndarray) – Array of parameters
- Returns:
The Dzyaloshinskii-Moriya energy
- Return type:
- openferro.engine.magnetic.external_field_energy(field, parameters)[source]
Returns the external field energy of the field.
- Parameters:
field (ndarray) – The magnetic field
parameters (ndarray) – Array containing the external field B_ext
- Returns:
The external field energy: -field·B_ext
- Return type:
Ewald
Functions for Ewald summation
- openferro.engine.ewald.get_dipole_dipole_ewald(latt, sharding=None)[source]
Returns the function to calculate the energy of dipole-dipole interaction.
Implemented according to Sec.5.3 of “Wang, D., et al. ‘Ewald summation for ferroelectric perovksites with charges and dipoles.’ Computational Materials Science 162 (2019): 314-321.”
- Parameters:
latt (Lattice) – The lattice object containing size and lattice vectors
sharding (jax.sharding.Sharding, optional) – Sharding specification for distributed arrays
- Returns:
Function that calculates dipole-dipole interaction energy
- Return type:
callable
- openferro.engine.ewald.dipole_dipole_ewald_plain(field, parameters)[source]
Brute-force Ewald summation for dipole-dipole interaction.
For benchmarking purpose only.
- Parameters:
field (ndarray) – The field values, shape=(l1, l2, l3, 3)
parameters (dict) –
- Dictionary containing:
- a1float
First lattice vector
- a2float
Second lattice vector
- a3float
Third lattice vector
- Z_starfloat
Born effective charge
- epsilon_inffloat
High-frequency dielectric constant
- Returns:
The dipole-dipole interaction energy
- Return type:
Multiferroic
derroic energy.
These functions will be added into <class interaction> for automatic differentiation.
Notes
This file is part of OpenFerro.
- openferro.engine.multiferroic.mean_field_on_interwaving_sublattice(field)[source]
Returns the mean-field of a field on an interwaving sublattice. Say we have two cubic sublattices A and B. We have a field defined on sublattice A. We want to calculate the mean-field (averaged over the 8 nearest neighbors of a B-site) of this field on sublattice B.
Let the lattice constant be unit length. We assume that the origin of sublattice B is at (0,0,0) and the origin of sublattice A is at (-0.5,-0.5,-0.5). So (0,0,0) and (-0.5,-0.5,-0.5) will make a primitive cell. We will adopt this convention throughout this file. Note such a convention is not unique. It is just for consistency among the energy engines defined for multiferroics, to avoid confusion over the annoying amounts of jnp.roll.
- Parameters:
field (jnp.array) – The field to calculate the mean-field
- Returns:
The mean-field of the field
- Return type:
jnp.array
- openferro.engine.multiferroic.mean_field_1stnn_on_single_lattice(field)[source]
Returns the average of a field over the 6 nearest neighbors of a given site, on a cubic lattice.
- openferro.engine.multiferroic.mean_field_2ndnn_on_single_lattice(field)[source]
Returns the average of a field over the 12 nearest neighbors of a given site, on a cubic lattice.
- openferro.engine.multiferroic.mean_field_3rdnn_on_single_lattice(field)[source]
Returns the average of a field over the 8 nearest neighbors of a given site, on a cubic lattice.
- openferro.engine.multiferroic.short_range_1stnn_uniaxial_quartic(field, parameters)[source]
Returns the short-range interaction of nearest neighbors for a \(R^3\) field defined on a isotropic lattice with periodic boundary conditions. The energy is given by:
\[\sum_{i, \alpha} K u^3_{i, \alpha} (u_{i+\alpha, \alpha} + u_{i-\alpha, \alpha})\]- Parameters:
field (jnp.array) – The field to calculate the energy
parameters (jax.numpy array) – The parameters of the energy function
- Returns:
The energy of the field
- Return type:
jnp.array
- openferro.engine.multiferroic.short_range_1stnn_trilinear_two_sublattices(field_A, field_B, parameters)[source]
Returns the short-range interaction of nearest neighbors for two \(R^3\) fields defined on interwaving sublattices (A and B sublattices) with periodic boundary conditions. The energy is given by:
\[\sum_{i \sim j, \alpha \neq \beta} D_{ij,\alpha\beta} a_{j, \alpha} b_{i, \alpha} b_{i, \beta}\]Here i is the index of sublattice A and j is the index of sublattice B. \(i\sim j\) means that i and j are nearest neighbors. \(D_{ij,\alpha\beta}\) is the trilinear coupling constant. For interwaving cubic lattices, there are 8 such nearest neighbors for a given i.
Define \(a'_{i}\) to be the mean-field (averaged over the 8 nearest neighbors of a B-site) of field_A on the B site-i. The energy is given by
\[\sum_{i, \alpha \neq \beta} 8 D^{\mathrm{nn}}_{\alpha\beta} a'_{i, \alpha} b_{i, \alpha} b_{i, \beta}\]- Parameters:
field_A (jnp.array) – The field of sublattice A to calculate the energy
field_B (jnp.array) – The field of sublattice B to calculate the energy
parameters (jax.numpy array) – The parameters of the energy function
- Returns:
The energy of the field
- Return type:
jnp.array
- openferro.engine.multiferroic.short_range_1stnn_biquadratic_iiii_two_sublattices(field_A, field_B, parameters)[source]
Returns the short-range interaction of nearest neighbors for two \(R^3\) fields defined on interwaving sublattices (A and B sublattices) with periodic boundary conditions.
Let the lattice constant be unit length. We assume that the origin of field_B is at (0,0,0) and the origin of field_A is at (-0.5,-0.5,-0.5). So (0,0,0) and (-0.5,-0.5,-0.5) will make a primitive cell. We will adopt this convention implementing the sum over i and j. Note such a convention is not unique. It is just for consistency among the energy engines defined for multiferroics, to avoid confusion over the annoying amounts of jnp.roll.
Define \(a'_{i}\) to be the mean-field (averaged over the 8 nearest neighbors of a B-site) of field_A on the B site-i.
The energy is given by:
\[\sum_{i, \alpha \beta \gamma \delta} E_{\alpha\beta\gamma\delta} b_{i, \alpha} b_{i, \beta} a'_{i, \gamma} a'_{i, \delta}\]- Parameters:
field_A (jnp.array) – The field of sublattice A to calculate the energy
field_B (jnp.array) – The field of sublattice B to calculate the energy
parameters (jax.numpy array) – The parameters of the energy function
- Returns:
The energy of the field
- Return type:
jnp.array
- openferro.engine.multiferroic.short_range_biquadratic_ijii_two_sublattices(field_A, field_B, parameters)[source]
Returns the short-range interaction of nearest neighbors for two \(R^3\) fields defined on interwaving sublattices (A and B sublattices) with periodic boundary conditions.
Let the lattice constant be unit length. We assume that the origin of field_B is at (0,0,0) and the origin of field_A is at (-0.5,-0.5,-0.5). So (0,0,0) and (-0.5,-0.5,-0.5) will make a primitive cell. We will adopt this convention implementing the sum over i and j. Note such a convention is not unique. It is just for consistency among the energy engines defined for multiferroics, to avoid confusion over the annoying amounts of jnp.roll.
Define \(a'_{i}\) to be the mean-field (averaged over the 8 nearest neighbors of a B-site) of field_A on the B site-i.
The energy is given by:
\[\sum_{ij, \alpha \beta \gamma \delta} E_{\alpha\beta\gamma\delta} b_{i, \alpha} b_{j, \beta} a'_{i, \gamma} a'_{i, \delta}\]- Parameters:
field_A (jnp.array) – The field of sublattice A to calculate the energy
field_B (jnp.array) – The field of sublattice B to calculate the energy
parameters (jax.numpy array) – The parameters of the energy function
- Returns:
The energy of the field
- Return type:
jnp.array
- openferro.engine.multiferroic.short_range_biquadratic_ijii(field_A, field_B, parameters)[source]
Returns the short-range interaction of nearest neighbors for two \(R^3\) fields defined on a cubic lattice with periodic boundary conditions.
The energy is given by:
\[\sum_{ij, \alpha \beta \gamma \delta} E_{\alpha\beta\gamma\delta} b_{i, \alpha} b_{j, \beta} a_{i, \gamma} a_{i, \delta}\]j is summed over the 1st, 2nd, 3rd nearest neighbors of i.
- Parameters:
field_A (jnp.array) – The field a to calculate the energy
field_B (jnp.array) – The field b to calculate the energy
parameters (jax.numpy array) – The parameters of the energy function
- Returns:
The energy of the field
- Return type:
jnp.array
- openferro.engine.multiferroic.homo_strain_spin_interaction(global_strain, spin_field, parameters)[source]
Returns the homogeneous strain spin interaction energy.
The energy is given by:
\[\sum_{i,j,l,\alpha,\beta} G_{ij, l\alpha\beta} \eta_{l} m_{i, \alpha} m_{j, \beta}\]l is index of strain under Voigt notation.
When i and j are 1st nearest neighbors, \(G_{ij, l\alpha\beta} = G_{1nn, l\alpha\beta}\)
When i and j are 2nd nearest neighbors, \(G_{ij, l\alpha\beta} = G_{2nn, l\alpha\beta}\)
When i and j are 3rd nearest neighbors, \(G_{ij, l\alpha\beta} = G_{3nn, l\alpha\beta}\)
- Parameters:
global_strain (jnp.array) – Shape=(6), the global strain of a supercell
spin_field (jnp.array) – Shape=(nx, ny, nz, 3), the spin field
parameters (jax.numpy array) – The parameters of the energy function containing G_1nn_1xx : Strain-spin interaction constant G1xx (or Gxxxx) for 1st nearest neighbors G_1nn_1yy : Strain-spin interaction constant G1yy (or Gxxyy) for 1st nearest neighbors G_1nn_4yz : Strain-spin interaction constant G4yz (or Gxyxy) for 1st nearest neighbors G_2nn_1xx : Strain-spin interaction constant G1xx (or Gxxxx) for 2nd nearest neighbors G_2nn_1yy : Strain-spin interaction constant G1yy (or Gxxyy) for 2nd nearest neighbors G_2nn_4yz : Strain-spin interaction constant G4yz (or Gxyxy) for 2nd nearest neighbors G_3nn_1xx : Strain-spin interaction constant G1xx (or Gxxxx) for 3rd nearest neighbors G_3nn_1yy : Strain-spin interaction constant G1yy (or Gxxyy) for 3rd nearest neighbors G_3nn_4yz : Strain-spin interaction constant G4yz (or Gxyxy) for 3rd nearest neighbors
- Returns:
The homogeneous strain dipole interaction energy
- Return type:
jnp.array
- openferro.engine.multiferroic.homo_strain_spin_1stnn_interaction(global_strain, spin_field, parameters)[source]
Returns the homogeneous strain spin interaction energy.
The energy is given by:
\[\sum_{i,j,l,\alpha,\beta} G_{ij, l\alpha\beta} \eta_{l} m_{i, \alpha} m_{j, \beta}\]l is index of strain under Voigt notation.
i and j are 1st nearest neighbors \(G_{ij, l\alpha\beta} = G_{l\alpha\beta}\)
- Parameters:
global_strain (jnp.array) – Shape=(6), the global strain of a supercell
spin_field (jnp.array) – Shape=(nx, ny, nz, 3), the spin field
parameters (jax.numpy array) – The parameters of the energy function containing G_1xx : Strain-spin interaction constant G1xx (or Gxxxx) for 1st nearest neighbors G_1yy : Strain-spin interaction constant G1yy (or Gxxyy) for 1st nearest neighbors G_4yz : Strain-spin interaction constant G4yz (or Gxyxy) for 1st nearest neighbors
- Returns:
The homogeneous strain dipole interaction energy
- Return type:
jnp.array
- openferro.engine.multiferroic.homo_strain_spin_2ndnn_interaction(global_strain, spin_field, parameters)[source]
Returns the homogeneous strain spin interaction energy.
The energy is given by:
\[\sum_{i,j,l,\alpha,\beta} G_{ij, l\alpha\beta} \eta_{l} m_{i, \alpha} m_{j, \beta}\]l is index of strain under Voigt notation.
i and j are 2nd nearest neighbors \(G_{ij, l\alpha\beta} = G_{l\alpha\beta}\)
- Parameters:
global_strain (jnp.array) – Shape=(6), the global strain of a supercell
spin_field (jnp.array) – Shape=(nx, ny, nz, 3), the spin field
parameters (jax.numpy array) – The parameters of the energy function containing G_1xx : Strain-spin interaction constant G1xx (or Gxxxx) for 2nd nearest neighbors G_1yy : Strain-spin interaction constant G1yy (or Gxxyy) for 2nd nearest neighbors G_4yz : Strain-spin interaction constant G4yz (or Gxyxy) for 2nd nearest neighbors
- Returns:
The homogeneous strain dipole interaction energy
- Return type:
jnp.array
- openferro.engine.multiferroic.homo_strain_spin_3rdnn_interaction(global_strain, spin_field, parameters)[source]
Returns the homogeneous strain spin interaction energy.
The energy is given by:
\[\sum_{i,j,l,\alpha,\beta} G_{ij, l\alpha\beta} \eta_{l} m_{i, \alpha} m_{j, \beta}\]l is index of strain under Voigt notation.
i and j are 3rd nearest neighbors \(G_{ij, l\alpha\beta} = G_{l\alpha\beta}\)
- Parameters:
global_strain (jnp.array) – Shape=(6), the global strain of a supercell
spin_field (jnp.array) – Shape=(nx, ny, nz, 3), the spin field
parameters (jax.numpy array) – The parameters of the energy function containing G_1xx : Strain-spin interaction constant G1xx (or Gxxxx) for 3rd nearest neighbors G_1yy : Strain-spin interaction constant G1yy (or Gxxyy) for 3rd nearest neighbors G_4yz : Strain-spin interaction constant G4yz (or Gxyxy) for 3rd nearest neighbors
- Returns:
The homogeneous strain dipole interaction energy
- Return type:
jnp.array
- openferro.engine.multiferroic.get_inhomo_strain_spin_interaction(enable_jit=True)[source]
Returns the inhomogeneous strain spin interaction function.
- Parameters:
enable_jit (bool, optional) – Whether to enable JIT compilation, by default True
- Returns:
The interaction function
- Return type:
function
- openferro.engine.multiferroic.DM_AFD_1stnn(AFD_field, spin_field, parameters)[source]
Returns the Dzyaloshinskii-Moriya interaction (involving oxygen octahedral titling AFD mode) of nearest neighbors for atomistic spin field on cubic lattice with periodic boundary conditions.
The energy is given by:
\[\]rac{1}{2}sum_{isim j} L (omega_i - omega_j)cdot (m_i cross m_j)
Here i and j are nearest neighbors.
- AFD_fieldjnp.array
The AFD field (\(\omega\)) to calculate the energy
- spin_fieldjnp.array
The spin field (\(m\)) to calculate the energy
- parametersjax.numpy array
The parameters of the energy function
- jnp.array
The energy of the field