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
|
2019-11-27 03:23:46 +05:30
|
|
|
import sys
|
|
|
|
from io import StringIO
|
2014-07-09 15:37:24 +05:30
|
|
|
from optparse import OptionParser
|
2019-06-14 16:33:30 +05:30
|
|
|
|
2014-07-09 15:37:24 +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-02-26 20:26:06 +05:30
|
|
|
|
2019-06-14 16:33:30 +05:30
|
|
|
|
2011-06-21 21:55:48 +05:30
|
|
|
# --------------------------------------------------------------------
|
|
|
|
# MAIN
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
|
2019-02-16 22:11:56 +05:30
|
|
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """
|
|
|
|
Add column containing Cauchy stress based on deformation gradient and first Piola--Kirchhoff stress.
|
2011-06-21 21:55:48 +05:30
|
|
|
|
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('-f','--defgrad',
|
|
|
|
dest = 'defgrad',
|
|
|
|
type = 'string', metavar = 'string',
|
|
|
|
help = 'heading of columns containing deformation gradient [%default]')
|
|
|
|
parser.add_option('-p','--stress',
|
|
|
|
dest = 'stress',
|
|
|
|
type = 'string', metavar = 'string',
|
|
|
|
help = 'heading of columns containing first Piola--Kirchhoff stress [%default]')
|
|
|
|
|
|
|
|
parser.set_defaults(defgrad = 'f',
|
|
|
|
stress = 'p',
|
|
|
|
)
|
2011-06-21 21:55:48 +05:30
|
|
|
|
|
|
|
(options,filenames) = parser.parse_args()
|
2019-11-27 03:23:46 +05:30
|
|
|
if filenames == []: filenames = [None]
|
|
|
|
|
2015-08-08 00:33:26 +05:30
|
|
|
for name in filenames:
|
2019-11-27 03:23:46 +05:30
|
|
|
damask.util.report(scriptName,name)
|
|
|
|
|
|
|
|
table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
2019-12-05 10:40:27 +05:30
|
|
|
table.add('Cauchy',
|
2020-02-21 23:20:30 +05:30
|
|
|
damask.mechanics.Cauchy(table.get(options.stress ).reshape(-1,3,3),
|
|
|
|
table.get(options.defgrad).reshape(-1,3,3)).reshape(-1,9),
|
2019-12-05 10:40:27 +05:30
|
|
|
scriptID+' '+' '.join(sys.argv[1:]))
|
2019-11-27 13:14:38 +05:30
|
|
|
|
2019-11-27 03:23:46 +05:30
|
|
|
table.to_ASCII(sys.stdout if name is None else name)
|