Merge branch 'simplify_strain_calculation' into 'development'

Simplify strain calculation

See merge request damask/DAMASK!92
This commit is contained in:
Philip Eisenlohr 2019-09-14 21:42:52 +02:00
commit 060564ddb4
1 changed files with 7 additions and 11 deletions

View File

@ -13,7 +13,7 @@ scriptName = os.path.splitext(os.path.basename(__file__))[0]
scriptID = ' '.join([scriptName,damask.version])
def operator(stretch,strain,eigenvalues):
"""Albrecht Bertram: Elasticity and Plasticity of Large Deformations An Introduction (3rd Edition, 2012), p. 102"""
"""Albrecht Bertram: Elasticity and Plasticity of Large Deformations An Introduction (3rd Edition, 2012), p. 102."""
return {
'V#ln': np.log(eigenvalues) ,
'U#ln': np.log(eigenvalues) ,
@ -88,7 +88,7 @@ for name in filenames:
try:
table = damask.ASCIItable(name = name,
buffered = False)
except: continue
except IOError: continue
damask.util.report(scriptName,name)
# ------------------------------------------ read header ------------------------------------------
@ -136,23 +136,19 @@ for name in filenames:
for column in items['tensor']['column']: # loop over all requested defgrads
F = np.array(list(map(float,table.data[column:column+items['tensor']['dim']])),'d').reshape(items['tensor']['shape'])
(U,S,Vh) = np.linalg.svd(F) # singular value decomposition
R = np.dot(U,Vh) # rotation of polar decomposition
stretch['U'] = np.dot(np.linalg.inv(R),F) # F = RU
stretch['V'] = np.dot(F,np.linalg.inv(R)) # F = VR
R_inv = np.dot(U,Vh).T # rotation of polar decomposition
stretch['U'] = np.dot(R_inv,F) # F = RU
stretch['V'] = np.dot(F,R_inv) # F = VR
for theStretch in stretches:
stretch[theStretch] = np.where(abs(stretch[theStretch]) < 1e-12, 0, stretch[theStretch]) # kill nasty noisy data
(D,V) = np.linalg.eig(stretch[theStretch]) # eigen decomposition (of symmetric matrix)
(D,V) = np.linalg.eigh((stretch[theStretch]+stretch[theStretch].T)*0.5) # eigen decomposition (of symmetric(ed) matrix)
neg = np.where(D < 0.0) # find negative eigenvalues ...
D[neg] *= -1. # ... flip value ...
V[:,neg] *= -1. # ... and vector
for i,eigval in enumerate(D):
if np.dot(V[:,i],V[:,(i+1)%3]) != 0.0: # check each vector for orthogonality
V[:,(i+1)%3] = np.cross(V[:,(i+2)%3],V[:,i]) # correct next vector
V[:,(i+1)%3] /= np.sqrt(np.dot(V[:,(i+1)%3],V[:,(i+1)%3].conj())) # and renormalize (hyperphobic?)
for theStrain in strains:
d = operator(theStretch,theStrain,D) # operate on eigenvalues of U or V
eps = (np.dot(V,np.dot(np.diag(d),V.T)).real).reshape(9) # build tensor back from eigenvalue/vector basis
eps = np.dot(V,np.dot(np.diag(d),V.T)).reshape(9) # build tensor back from eigenvalue/vector basis
table.data_append(list(eps))