mindchemistry.e3.o3.Irreps
- class mindchemistry.e3.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.
- Parameters
irreps (Union[str, Irrep, Irreps, List[Tuple[int]]]) – a string to represent the direct sum of irreducible representations.
- 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.
- Supported Platforms:
Ascend
Examples
>>> from mindchemistry.e3.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) – Irrep
- Returns
int, total multiplicity of ir.
Examples
>>> Irreps("1o + 3x2e").count("2e") 3
- decompose(v, batch=False)[source]
Decompose a vector by Irreps.
- Parameters
v (Tensor) – the vector to be decomposed.
batch (bool) – 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]
Random tensor.
- Parameters
- Returns
Tensor, the shape is size where -1 is replaced by self.dim.
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
Examples
>>> Irreps("4x0e + 0x1o + 2x3e").remove_zero_multiplicities() 4x0e+2x3e
- simplify()[source]
Simplify the representations.
- Returns
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 (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]
Representation wigner D matrices of O(3) from Euler angles.
- 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]) – 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]
Representation 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]]