2018-12-09 18:39:26 +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
|
2019-11-27 13:15:01 +05:30
|
|
|
from io import StringIO
|
2014-06-17 12:40:10 +05:30
|
|
|
from optparse import OptionParser
|
2019-06-14 16:33:30 +05:30
|
|
|
|
2014-06-17 12:40:10 +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
|
|
|
|
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 vonMises equivalent values for symmetric part of requested strains and/or stresses.
|
|
|
|
|
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('-e','--strain',
|
|
|
|
dest = 'strain',
|
|
|
|
action = 'extend', metavar = '<string LIST>',
|
|
|
|
help = 'heading(s) of columns containing strain tensors')
|
|
|
|
parser.add_option('-s','--stress',
|
|
|
|
dest = 'stress',
|
|
|
|
action = 'extend', metavar = '<string LIST>',
|
|
|
|
help = 'heading(s) of columns containing stress tensors')
|
|
|
|
|
2019-02-26 05:59:12 +05:30
|
|
|
parser.set_defaults(strain = [],
|
|
|
|
stress = [],
|
|
|
|
)
|
2011-06-21 21:55:48 +05:30
|
|
|
(options,filenames) = parser.parse_args()
|
|
|
|
|
2019-02-26 05:59:12 +05:30
|
|
|
if options.stress is [] and options.strain is []:
|
2019-11-27 13:15:01 +05:30
|
|
|
parser.error('no data column specified...')
|
2015-08-08 00:33:26 +05:30
|
|
|
|
2015-08-21 01:12:05 +05:30
|
|
|
if filenames == []: filenames = [None]
|
2015-08-08 00:33:26 +05:30
|
|
|
|
|
|
|
for name in filenames:
|
2019-11-27 13:15:01 +05:30
|
|
|
damask.util.report(scriptName,name)
|
|
|
|
|
|
|
|
table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
|
|
|
for strain in options.strain:
|
2019-12-05 10:40:27 +05:30
|
|
|
table.add('Mises({})'.format(strain),
|
|
|
|
damask.mechanics.Mises_strain(damask.mechanics.symmetric(table.get(strain).reshape(-1,3,3))),
|
|
|
|
scriptID+' '+' '.join(sys.argv[1:]))
|
2019-11-27 13:15:01 +05:30
|
|
|
for stress in options.stress:
|
2019-12-05 10:40:27 +05:30
|
|
|
table.add('Mises({})'.format(stress),
|
|
|
|
damask.mechanics.Mises_stress(damask.mechanics.symmetric(table.get(stress).reshape(-1,3,3))),
|
|
|
|
scriptID+' '+' '.join(sys.argv[1:]))
|
2019-11-27 13:15:01 +05:30
|
|
|
|
|
|
|
table.to_ASCII(sys.stdout if name is None else name)
|