new TensorData(M)
Create a TensorData object, to store whole tensors, diagonalise their symmetric part and return derived quantities
| Name | Type | Description |
|---|---|---|
M | Array | | Tensor in 3x3 matrix form |
Methods
efgAtomicToHz(Q) → {TensorData}
Convert this TensorData to return a clone that has been converted from atomic units to Hertz, assuming it's an Electric Field Gradient tensor.
| Name | Type | Description |
|---|---|---|
Q | Number | Quadrupolar moment of the given nucleus (millibarn, as in the isotope data tables) |
Converted tensor
- Type:
- TensorData
euler(mode, active, convention, degrees, EPS) → {Array}
Calculate the Euler angles for the TensorData. Returns an array of [alpha, beta, gamma], in radians unless degrees is true.
This function is based on the code from TensorView for MATLAB by Leo Svenningsson and Leonard J. Mueller https://doi.org/10.1016/j.ssnmr.2022.101849
| Name | Type | Default | Description |
|---|---|---|---|
mode | String | zyz | Mode to use: either 'zyz' or 'zxz' (default is 'zyz') |
active | Boolean | true | If true, make it an active transformation (default is true) |
convention | String | Eval ordering convention to use (default is whatever is set in 'this.convention) | |
degrees | Boolean | If true, return angles in degrees (default is false) | |
EPS | Number | Tolerance for comparing eigenvalues etc. (default is 1e-6) |
Array of [alpha, beta, gamma] in radians
TODO: check edge cases, esp. axial symmetry TODO: add in conversion from radians to degrees
- Type:
- Array
iscAtomicToHz(g1, g2) → {TensorData}
Convert this TensorData to return a clone that has been converted from atomic units to Hertz, assuming it's an Indirect Spin-spin Coupling tensor.
| Name | Type | Description |
|---|---|---|
g1 | Number | Gyromagnetic ratio of the first atom |
g2 | Number | Gyromagnetic ratio of the second atom |
Converted tensor
- Type:
- TensorData
rotate(basis, active) → {TensorData}
Rotate the TensorData by a given basis, either as passive or active transformation. Returns the rotated TensorData (does not modify this in place). Default is passive. The convention is such that for a symmetric tensor,
T.rotate(T.eigenvectors)
returns the diagonalised tensor.
| Name | Type | Default | Description |
|---|---|---|---|
basis | Array | | Basis to rotate into | |
active | Boolean | false | If true, make it an active transformation (default is false) |
Rotated tensor
- Type:
- TensorData
rotateByAngleAxis(a, v, intrinsic) → {TensorData}
Rotate the TensorData by a given angle around a given axis. Uses the rotate_matrix utility function.
| Name | Type | Description |
|---|---|---|
a | number | | The angle that the matrix is rotated around the vector 'v'. 'a' can also be a vector and then 'a' is rotated into 'v'. Angles are in radians. |
v | string | | Vector to rotate the matrix around. Vectors can be given as strings: 'x', '-x', 'y', ... .These correspond to the local coordinate system of the tensor if intrinsic == true. |
intrinsic | boolean | If true, rotate the tensor intrinsically (default is true). i.e. the tensor is rotated in the local coordinate system. |
Rotated tensor
- Type:
- TensorData
sort_eigs()
This method sorts the eigenvalues and eigenvectors in Haeberlen and NQR order.
Haeberlen Order: The method first calculates the absolute difference between each eigenvalue and the isotropic value. These differences are then sorted in ascending order. The sorted eigenvalues are stored in this._haeb_evals. The corresponding eigenvectors are also sorted in the same order, but with the first and second elements swapped. The sorted eigenvectors are stored in this._haeb_evecs.
NQR Order: The method then repeats the same process for the original eigenvalues, but without swapping the first and second elements. The sorted original eigenvalues are stored in this._nqr_evals.
Note: The method uses the lodash (_) library for the zip, range, and sortBy functions. The mjs.transpose function is used to transpose the array of eigenvectors, and mjs.cross is used to calculate the cross product of two vectors.
sorted_eigenvalues(convention, return_indices) → {Array}
Get the eigenvalues of the tensor, sorted in the given convention.
| Name | Type | Default | Description |
|---|---|---|---|
convention | String | Convention to sort the eigenvalues by. Can be "increasing", "decreasing", "haeberlen" or "nqr". | |
return_indices | Boolean | false | If true, return the indices of the sorted eigenvalues, in addition to the sorted eigenvalues. |
If the convention is not one of the above.
- Type
- Error
Array of sorted eigenvalues, or array of sorted eigenvalues and indices, depending on the value of return_indices.
- Type:
- Array
// Get the eigenvalues of a tensor, sorted in increasing order
var tensor = new TensorData([[1, 0, 0], [0, 2, 0], [0, 0, -6]]);
var sorted = tensor.sorted_eigenvalues("increasing");
// sorted = [-6, 1, 2]sorted_eigenvectors(convention) → {Array}
Get the eigenvectors of the tensor, sorted in the given convention.
| Name | Type | Description |
|---|---|---|
convention | String | Convention to sort the eigenvalues by. Can be "increasing", "decreasing", "haeberlen" or "nqr". |
Array of sorted eigenvectors.
- Type:
- Array