option (as in addSpectralDecomposition)

This commit is contained in:
Martin Diehl 2020-02-15 16:26:56 +01:00
parent e3753e9444
commit ad062ada6b
2 changed files with 10 additions and 2 deletions

View File

@ -648,7 +648,7 @@ class DADF5():
'data': mechanics.eigenvectors(x['data']),
'label': 'v({})'.format(x['label']),
'meta' : {
'Unit': '1',
'Unit': '1',
'Description': 'Eigenvectors of {} ({})'.format(x['label'],x['meta']['Description']),
'Creator': 'dadf5.py:add_eigenvectors v{}'.format(version)
}

View File

@ -51,7 +51,7 @@ def eigenvalues(x):
return np.linalg.eigvalsh(symmetric(x))
def eigenvectors(x):
def eigenvectors(x,RHS=False):
"""
Return eigenvectors of a symmetric tensor.
@ -61,9 +61,17 @@ def eigenvectors(x):
----------
x : numpy.array of shape (:,3,3) or (3,3)
Symmetric tensor of which the eigenvectors are computed.
RHS: bool, optional
Enforce right-handed coordinate system. Default is False.
"""
(u,v) = np.linalg.eigh(symmetric(x))
if RHS:
if np.shape(x) == (3,3):
if np.linalg.det(v) < 0.0: v[:,2] *= -1.0
else:
v[np.linalg.det(v) < 0.0,:,2] *= -1.0
return v