2018-11-17 12:42:12 +05:30
|
|
|
#!/usr/bin/env python3
|
2011-06-21 21:55:48 +05:30
|
|
|
|
2019-06-14 16:33:30 +05:30
|
|
|
import os
|
|
|
|
import sys
|
2020-01-12 04:44:35 +05:30
|
|
|
from io import StringIO
|
2014-08-04 23:23:41 +05:30
|
|
|
from optparse import OptionParser
|
2019-06-14 16:33:30 +05:30
|
|
|
|
2014-08-04 23:23:41 +05:30
|
|
|
import damask
|
2011-06-21 21:55:48 +05:30
|
|
|
|
2019-06-14 16:33:30 +05:30
|
|
|
|
2016-01-27 22:36:00 +05:30
|
|
|
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
|
|
|
scriptID = ' '.join([scriptName,damask.version])
|
2014-03-10 19:31:39 +05:30
|
|
|
|
2019-12-23 14:49:38 +05:30
|
|
|
def parameters(stretch,strain):
|
2019-09-13 19:19:25 +05:30
|
|
|
"""Albrecht Bertram: Elasticity and Plasticity of Large Deformations An Introduction (3rd Edition, 2012), p. 102."""
|
2014-08-04 23:23:41 +05:30
|
|
|
return {
|
2019-12-23 14:49:38 +05:30
|
|
|
'V#ln': ('V',0.0),
|
|
|
|
'U#ln': ('U',0.0),
|
|
|
|
'V#Biot': ('V',-.5),
|
|
|
|
'U#Biot': ('U',+.5),
|
|
|
|
'V#Green': ('V',-1.),
|
|
|
|
'U#Green': ('U',+1.),
|
2012-11-30 20:32:25 +05:30
|
|
|
}[stretch+'#'+strain]
|
2011-12-04 15:27:13 +05:30
|
|
|
|
2011-06-21 21:55:48 +05:30
|
|
|
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
# MAIN
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
|
2019-02-17 02:50:10 +05:30
|
|
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """
|
2011-06-21 21:55:48 +05:30
|
|
|
Add column(s) containing given strains based on given stretches of requested deformation gradient column(s).
|
|
|
|
|
2014-08-06 18:57:09 +05:30
|
|
|
""", version = scriptID)
|
2011-06-21 21:55:48 +05:30
|
|
|
|
2015-08-08 00:33:26 +05:30
|
|
|
parser.add_option('-u','--right',
|
|
|
|
dest = 'right',
|
|
|
|
action = 'store_true',
|
|
|
|
help = 'material strains based on right Cauchy--Green deformation, i.e., C and U')
|
|
|
|
parser.add_option('-v','--left',
|
|
|
|
dest = 'left',
|
|
|
|
action = 'store_true',
|
|
|
|
help = 'spatial strains based on left Cauchy--Green deformation, i.e., B and V')
|
|
|
|
parser.add_option('-0','--logarithmic',
|
|
|
|
dest = 'logarithmic',
|
|
|
|
action = 'store_true',
|
|
|
|
help = 'calculate logarithmic strain tensor')
|
|
|
|
parser.add_option('-1','--biot',
|
|
|
|
dest = 'biot',
|
|
|
|
action = 'store_true',
|
|
|
|
help = 'calculate biot strain tensor')
|
|
|
|
parser.add_option('-2','--green',
|
|
|
|
dest = 'green',
|
|
|
|
action = 'store_true',
|
|
|
|
help = 'calculate green strain tensor')
|
|
|
|
parser.add_option('-f','--defgrad',
|
|
|
|
dest = 'defgrad',
|
|
|
|
action = 'extend',
|
|
|
|
metavar = '<string LIST>',
|
|
|
|
help = 'heading(s) of columns containing deformation tensor values [%default]')
|
|
|
|
|
2019-02-16 19:23:56 +05:30
|
|
|
parser.set_defaults(
|
2015-08-08 00:33:26 +05:30
|
|
|
defgrad = ['f'],
|
|
|
|
)
|
2011-06-21 21:55:48 +05:30
|
|
|
|
|
|
|
(options,filenames) = parser.parse_args()
|
2019-12-23 14:49:38 +05:30
|
|
|
if filenames == []: filenames = [None]
|
2011-06-21 21:55:48 +05:30
|
|
|
|
2019-02-16 19:23:56 +05:30
|
|
|
if len(options.defgrad) > 1:
|
2019-12-23 14:49:38 +05:30
|
|
|
options.defgrad = options.defgrad[1:]
|
2019-02-16 19:23:56 +05:30
|
|
|
|
2011-06-21 21:55:48 +05:30
|
|
|
stretches = []
|
|
|
|
strains = []
|
|
|
|
|
|
|
|
if options.right: stretches.append('U')
|
|
|
|
if options.left: stretches.append('V')
|
|
|
|
if options.logarithmic: strains.append('ln')
|
2015-07-01 21:18:34 +05:30
|
|
|
if options.biot: strains.append('Biot')
|
|
|
|
if options.green: strains.append('Green')
|
2011-06-21 21:55:48 +05:30
|
|
|
|
2016-03-02 01:41:43 +05:30
|
|
|
if options.defgrad is None:
|
2019-12-23 14:49:38 +05:30
|
|
|
parser.error('no data column specified.')
|
2015-08-08 00:33:26 +05:30
|
|
|
|
|
|
|
for name in filenames:
|
2019-12-23 14:49:38 +05:30
|
|
|
damask.util.report(scriptName,name)
|
|
|
|
|
|
|
|
table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
2015-08-08 00:33:26 +05:30
|
|
|
|
2019-12-23 14:49:38 +05:30
|
|
|
for defgrad in options.defgrad:
|
2020-03-17 16:52:48 +05:30
|
|
|
F = table.get(defgrad).reshape(-1,3,3)
|
2019-12-23 14:49:38 +05:30
|
|
|
for theStretch in stretches:
|
|
|
|
for theStrain in strains:
|
|
|
|
(t,m) = parameters(theStretch,theStrain)
|
|
|
|
label = '{}({}){}'.format(theStrain,theStretch,defgrad if defgrad != 'f' else '')
|
|
|
|
table.add(label,
|
2020-03-17 16:52:48 +05:30
|
|
|
damask.mechanics.strain_tensor(F,t,m).reshape(-1,9),
|
2019-12-23 14:49:38 +05:30
|
|
|
scriptID+' '+' '.join(sys.argv[1:]))
|
|
|
|
|
|
|
|
table.to_ASCII(sys.stdout if name is None else name)
|