mindscience.e3nn.o3.Irreps
- class mindscience.e3nn.o3.Irreps(irreps=None)[source]
Direct sum of irreducible representations of O(3). This class does not contain any data, it is a structure that describe the representation. It is typically used as argument of other classes of the library to define the input and output representations of functions. The irreps are stored as a tuple of (_MulIr) objects, each containing a multiplicity and an Irrep. This allows for easy manipulation, such as addition, multiplication, and filtering of representations.
- Parameters
irreps (Union[str, Irrep, Irreps, list[tuple[int]]], optional) – A string to represent the direct sum of irreducible representations. Default:
None.- Raises
ValueError – If irreps cannot be converted to an Irreps.
ValueError – If the mul part of irreps part is negative.
TypeError – If the mul part of irreps part is not int.
Examples
>>> from mindscience.e3nn.o3 import Irreps >>> x = Irreps([(100, (0, 1)), (50, (1, 1))]) 100x0e+50x1e >>> x.dim 250 >>> Irreps("100x0e+50x1e+0x2e") 100x0e+50x1e+0x2e >>> Irreps("100x0e+50x1e+0x2e").lmax 1 >>> Irrep("2e") in Irreps("0e+2e") True >>> Irreps(), Irreps("") (, ) >>> Irreps('2x1o+1x0o') * Irreps('2x1o+1x0e') 4x0e+1x0o+2x1o+4x1e+2x1e+4x2e
- count(ir)[source]
Multiplicity of ir.
- Parameters
ir (Irrep) – Irreducible representation.
- Returns
int, total multiplicity of ir.
Examples
>>> Irreps("1o + 3x2e").count("2e") 3
- decompose(v, batch=False)[source]
Decompose a vector into irreducible components according to the current Irreps structure.
This method reshapes the last axis of the input tensor v such that each slice corresponds to one of the irreducible representations listed in self. The resulting list contains one tensor per irrep, with shape (…, multiplicity, irrep_dimension).
- Parameters
v (Tensor) – the vector to be decomposed.
batch (bool, optional) – whether reshape the result such that there is at least a batch dimension. Default:
False.
- Returns
List of Tensors, the decomposed vectors by Irreps.
- Raises
TypeError – If v is not Tensor.
ValueError – If length of the vector v is not matching with dimension of Irreps.
Examples
>>> import mindspore as ms >>> input = ms.Tensor([1, 2, 3]) >>> m = Irreps("1o").decompose(input) >>> print(m) [Tensor(shape=[1,3], dtype=Int64, value= [[1,2,3]])]
- filter(keep=None, drop=None)[source]
Filter the Irreps by either keep or drop.
- Parameters
- Returns
Irreps, filtered irreps.
- Raises
ValueError – If both keep and drop are not None.
Examples
>>> Irreps("1o + 2e").filter(keep="1o") 1x1o >>> Irreps("1o + 2e").filter(drop="1o") 1x2e
- randn(*size, normalization='component')[source]
Generate a random tensor whose last dimension matches the total dimension of these irreps. The irreps structure is used to split the last axis into individual irrep blocks, each of which can be normalized either per-component or per-irrep norm.
- Parameters
- Returns
Tensor, the shape is size where -1 is replaced by self.dim.
- Raises
ValueError – If normalization is not 'component' or 'norm'.
Examples
>>> Irreps("5x0e + 10x1o").randn(5, -1, 5, normalization='norm').shape (5, 35, 5)
- remove_zero_multiplicities()[source]
Remove any irreps with multiplicities of zero.
- Returns
Irreps, irreps with multiplicities of zero removed.
Examples
>>> Irreps("4x0e + 0x1o + 2x3e").remove_zero_multiplicities() 4x0e+2x3e
- simplify()[source]
Simplify the representations.
- Returns
Irreps, simplified Irreps.
Examples
>>> Irreps("1e + 1e + 0e").simplify() 2x1e+1x0e >>> Irreps("1e + 1e + 0e + 1e").simplify() 2x1e+1x0e+1x1e
- sort()[source]
Sort the representations by increasing degree.
- Returns
Irreps, sorted Irreps.
p (tuple[int]), permute orders, p[old_index] = new_index.
inv (tuple[int]), inversed permute orders, p[new_index] = old_index.
Examples
>>> Irreps("1e + 0e + 1e").sort().irreps 1x0e+1x1e+1x1e >>> Irreps("2o + 1e + 0e + 1e").sort().p (3, 1, 0, 2) >>> Irreps("2o + 1e + 0e + 1e").sort().inv (2, 1, 3, 0)
- static spherical_harmonics(lmax, p=- 1)[source]
Representation of the spherical harmonics.
- Parameters
- Returns
Irreps, representation of \((Y^0, Y^1, \dots, Y^{\mathrm{lmax}})\).
Examples
>>> Irreps.spherical_harmonics(3) 1x0e+1x1o+1x2e+1x3o >>> Irreps.spherical_harmonics(4, p=1) 1x0e+1x1e+1x2e+1x3e+1x4e
- wigD_from_angles(alpha, beta, gamma, k=None)[source]
Compute the Wigner-D matrix representation of O(3) from the three Euler angles \((\alpha, \beta, \gamma)\) that describe the rotation sequence:
Rotate by \(\gamma\) around the original Y axis.
Rotate by \(\beta\) around the new X axis.
Rotate by \(\alpha\) around the newest Y axis.
The result is the direct sum of the Wigner-D matrices for each irrep contained in this Irreps object, repeated according to multiplicity.
- Parameters
alpha (Union[Tensor[float32], list[float], tuple[float], ndarray[np.float32], float]) – rotation \(\alpha\) around Y axis, applied third.
beta (Union[Tensor[float32], list[float], tuple[float], ndarray[np.float32], float]) – rotation \(\beta\) around X axis, applied second.
gamma (Union[Tensor[float32], list[float], tuple[float], ndarray[np.float32], float]) – rotation \(\gamma\) around Y axis, applied first.
k (Union[None, Tensor[float32], list[float], tuple[float], ndarray[np.float32], float], optional) – How many times the parity is applied. Default:
None.
- Returns
Tensor, representation wigner D matrix of O(3). The shape of Tensor is \((..., 2l+1, 2l+1)\) .
Examples
>>> m = Irreps("1o").wigD_from_angles(0, 0 ,0, 1) >>> print(m) [[-1, 0, 0], [ 0, -1, 0], [ 0, 0, -1]]
- wigD_from_matrix(R)[source]
Compute Wigner-D matrices of O(3) from rotation matrices.
- Parameters
R (Tensor) – Rotation matrices. The shape of Tensor is \((..., 3, 3)\).
- Returns
Tensor, representation wigner D matrix of O(3). The shape of Tensor is \((..., 2l+1, 2l+1)\) .
- Raises
TypeError – If R is not a Tensor.
Examples
>>> m = Irreps("1o").wigD_from_matrix(-ops.eye(3)) >>> print(m) [[-1, 0, 0], [ 0, -1, 0], [ 0, 0, -1]]