2018-11-17 12:42:12 +05:30
|
|
|
#!/usr/bin/env python3
|
2014-04-02 00:11:14 +05:30
|
|
|
# -*- coding: UTF-8 no BOM -*-
|
2013-06-04 18:26:57 +05:30
|
|
|
|
2016-03-01 22:55:14 +05:30
|
|
|
import os,sys,math
|
2014-08-05 01:37:20 +05:30
|
|
|
import numpy as np
|
2013-06-04 18:26:57 +05:30
|
|
|
from optparse import OptionParser
|
2014-08-05 01:37:20 +05:30
|
|
|
import damask
|
2013-06-04 18:26:57 +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-08-05 01:37:20 +05:30
|
|
|
|
2016-03-23 06:22:02 +05:30
|
|
|
slipSystems = {
|
|
|
|
'fcc':
|
|
|
|
np.array([
|
|
|
|
# Slip direction Plane normal
|
|
|
|
[ 0, 1,-1, 1, 1, 1, ],
|
|
|
|
[-1, 0, 1, 1, 1, 1, ],
|
|
|
|
[ 1,-1, 0, 1, 1, 1, ],
|
|
|
|
[ 0,-1,-1, -1,-1, 1, ],
|
|
|
|
[ 1, 0, 1, -1,-1, 1, ],
|
|
|
|
[-1, 1, 0, -1,-1, 1, ],
|
|
|
|
[ 0,-1, 1, 1,-1,-1, ],
|
|
|
|
[-1, 0,-1, 1,-1,-1, ],
|
|
|
|
[ 1, 1, 0, 1,-1,-1, ],
|
|
|
|
[ 0, 1, 1, -1, 1,-1, ],
|
|
|
|
[ 1, 0,-1, -1, 1,-1, ],
|
|
|
|
[-1,-1, 0, -1, 1,-1, ],
|
|
|
|
],'f'),
|
|
|
|
'bcc':
|
|
|
|
np.array([
|
|
|
|
# Slip system <111>{110}
|
|
|
|
[ 1,-1, 1, 0, 1, 1, ],
|
|
|
|
[-1,-1, 1, 0, 1, 1, ],
|
|
|
|
[ 1, 1, 1, 0,-1, 1, ],
|
|
|
|
[-1, 1, 1, 0,-1, 1, ],
|
|
|
|
[-1, 1, 1, 1, 0, 1, ],
|
|
|
|
[-1,-1, 1, 1, 0, 1, ],
|
|
|
|
[ 1, 1, 1, -1, 0, 1, ],
|
|
|
|
[ 1,-1, 1, -1, 0, 1, ],
|
|
|
|
[-1, 1, 1, 1, 1, 0, ],
|
|
|
|
[-1, 1,-1, 1, 1, 0, ],
|
|
|
|
[ 1, 1, 1, -1, 1, 0, ],
|
|
|
|
[ 1, 1,-1, -1, 1, 0, ],
|
|
|
|
# Slip system <111>{112}
|
|
|
|
[-1, 1, 1, 2, 1, 1, ],
|
|
|
|
[ 1, 1, 1, -2, 1, 1, ],
|
|
|
|
[ 1, 1,-1, 2,-1, 1, ],
|
|
|
|
[ 1,-1, 1, 2, 1,-1, ],
|
|
|
|
[ 1,-1, 1, 1, 2, 1, ],
|
|
|
|
[ 1, 1,-1, -1, 2, 1, ],
|
|
|
|
[ 1, 1, 1, 1,-2, 1, ],
|
|
|
|
[-1, 1, 1, 1, 2,-1, ],
|
|
|
|
[ 1, 1,-1, 1, 1, 2, ],
|
|
|
|
[ 1,-1, 1, -1, 1, 2, ],
|
|
|
|
[-1, 1, 1, 1,-1, 2, ],
|
|
|
|
[ 1, 1, 1, 1, 1,-2, ],
|
|
|
|
],'f'),
|
|
|
|
'hex':
|
|
|
|
np.array([
|
|
|
|
# Basal systems <11.0>{00.1} (independent of c/a-ratio, Bravais notation (4 coordinate base))
|
|
|
|
[ 2, -1, -1, 0, 0, 0, 0, 1, ],
|
|
|
|
[-1, 2, -1, 0, 0, 0, 0, 1, ],
|
|
|
|
[-1, -1, 2, 0, 0, 0, 0, 1, ],
|
|
|
|
# 1st type prismatic systems <11.0>{10.0} (independent of c/a-ratio)
|
|
|
|
[ 2, -1, -1, 0, 0, 1, -1, 0, ],
|
|
|
|
[-1, 2, -1, 0, -1, 0, 1, 0, ],
|
|
|
|
[-1, -1, 2, 0, 1, -1, 0, 0, ],
|
|
|
|
# 2nd type prismatic systems <10.0>{11.0} -- a slip; plane normals independent of c/a-ratio
|
|
|
|
[ 0, 1, -1, 0, 2, -1, -1, 0, ],
|
|
|
|
[-1, 0, 1, 0, -1, 2, -1, 0, ],
|
|
|
|
[ 1, -1, 0, 0, -1, -1, 2, 0, ],
|
|
|
|
# 1st type 1st order pyramidal systems <11.0>{-11.1} -- plane normals depend on the c/a-ratio
|
|
|
|
[ 2, -1, -1, 0, 0, 1, -1, 1, ],
|
|
|
|
[-1, 2, -1, 0, -1, 0, 1, 1, ],
|
|
|
|
[-1, -1, 2, 0, 1, -1, 0, 1, ],
|
|
|
|
[ 1, 1, -2, 0, -1, 1, 0, 1, ],
|
|
|
|
[-2, 1, 1, 0, 0, -1, 1, 1, ],
|
|
|
|
[ 1, -2, 1, 0, 1, 0, -1, 1, ],
|
|
|
|
# pyramidal system: c+a slip <11.3>{-10.1} -- plane normals depend on the c/a-ratio
|
|
|
|
[ 2, -1, -1, 3, -1, 1, 0, 1, ],
|
|
|
|
[ 1, -2, 1, 3, -1, 1, 0, 1, ],
|
|
|
|
[-1, -1, 2, 3, 1, 0, -1, 1, ],
|
|
|
|
[-2, 1, 1, 3, 1, 0, -1, 1, ],
|
|
|
|
[-1, 2, -1, 3, 0, -1, 1, 1, ],
|
|
|
|
[ 1, 1, -2, 3, 0, -1, 1, 1, ],
|
|
|
|
[-2, 1, 1, 3, 1, -1, 0, 1, ],
|
|
|
|
[-1, 2, -1, 3, 1, -1, 0, 1, ],
|
|
|
|
[ 1, 1, -2, 3, -1, 0, 1, 1, ],
|
|
|
|
[ 2, -1, -1, 3, -1, 0, 1, 1, ],
|
|
|
|
[ 1, -2, 1, 3, 0, 1, -1, 1, ],
|
|
|
|
[-1, -1, 2, 3, 0, 1, -1, 1, ],
|
|
|
|
# pyramidal system: c+a slip <11.3>{-1-1.2} -- as for hexagonal ice (Castelnau et al. 1996, similar to twin system found below)
|
|
|
|
[ 2, -1, -1, 3, -2, 1, 1, 2, ], # sorted according to similar twin system
|
|
|
|
[-1, 2, -1, 3, 1, -2, 1, 2, ], # <11.3>{-1-1.2} shear = 2((c/a)^2-2)/(3 c/a)
|
|
|
|
[-1, -1, 2, 3, 1, 1, -2, 2, ],
|
|
|
|
[-2, 1, 1, 3, 2, -1, -1, 2, ],
|
|
|
|
[ 1, -2, 1, 3, -1, 2, -1, 2, ],
|
|
|
|
[ 1, 1, -2, 3, -1, -1, 2, 2, ],
|
|
|
|
],'f'),
|
|
|
|
}
|
2013-06-04 18:26:57 +05:30
|
|
|
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
# MAIN
|
|
|
|
# --------------------------------------------------------------------
|
2014-08-05 01:37:20 +05:30
|
|
|
|
2019-02-16 22:55:41 +05:30
|
|
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """
|
2016-03-23 21:32:51 +05:30
|
|
|
Add columns listing Schmid factors (and optional trace vector of selected system) for given Euler angles.
|
2013-06-04 18:26:57 +05:30
|
|
|
|
2014-08-06 18:57:09 +05:30
|
|
|
""", version = scriptID)
|
2013-06-04 18:26:57 +05:30
|
|
|
|
2016-03-23 06:22:02 +05:30
|
|
|
latticeChoices = ('fcc','bcc','hex')
|
2018-12-10 13:57:39 +05:30
|
|
|
parser.add_option('-l',
|
|
|
|
'--lattice',
|
2016-03-23 06:22:02 +05:30
|
|
|
dest = 'lattice', type = 'choice', choices = latticeChoices, metavar='string',
|
|
|
|
help = 'type of lattice structure [%default] {}'.format(latticeChoices))
|
2016-03-02 01:44:06 +05:30
|
|
|
parser.add_option('--covera',
|
2016-03-23 06:22:02 +05:30
|
|
|
dest = 'CoverA', type = 'float', metavar = 'float',
|
2019-02-16 19:23:56 +05:30
|
|
|
help = 'C over A ratio for hexagonal systems [%default]')
|
2018-12-10 13:57:39 +05:30
|
|
|
parser.add_option('-f',
|
|
|
|
'--force',
|
2016-03-23 06:22:02 +05:30
|
|
|
dest = 'force',
|
|
|
|
type = 'float', nargs = 3, metavar = 'float float float',
|
|
|
|
help = 'force direction in lab frame [%default]')
|
2018-12-10 13:57:39 +05:30
|
|
|
parser.add_option('-n',
|
|
|
|
'--normal',
|
2016-03-23 06:22:02 +05:30
|
|
|
dest = 'normal',
|
|
|
|
type = 'float', nargs = 3, metavar = 'float float float',
|
2018-12-10 13:57:39 +05:30
|
|
|
help = 'stress plane normal in lab frame, per default perpendicular to the force')
|
|
|
|
parser.add_option('-o',
|
|
|
|
'--orientation',
|
2016-03-23 06:22:02 +05:30
|
|
|
dest = 'quaternion',
|
2018-12-09 15:23:53 +05:30
|
|
|
metavar = 'string',
|
2018-12-10 13:57:39 +05:30
|
|
|
help = 'label of crystal orientation given as unit quaternion [%default]')
|
2016-03-23 06:22:02 +05:30
|
|
|
|
2016-03-23 21:32:51 +05:30
|
|
|
parser.set_defaults(force = (0.0,0.0,1.0),
|
2018-12-10 13:57:39 +05:30
|
|
|
quaternion='orientation',
|
2016-03-23 06:22:02 +05:30
|
|
|
normal = None,
|
|
|
|
lattice = latticeChoices[0],
|
|
|
|
CoverA = math.sqrt(8./3.),
|
|
|
|
)
|
|
|
|
|
|
|
|
(options, filenames) = parser.parse_args()
|
|
|
|
|
|
|
|
force = np.array(options.force)
|
|
|
|
force /= np.linalg.norm(force)
|
|
|
|
|
2018-12-10 13:57:39 +05:30
|
|
|
if options.normal is not None:
|
2016-03-23 06:22:02 +05:30
|
|
|
normal = np.array(options.normal)
|
|
|
|
normal /= np.linalg.norm(normal)
|
|
|
|
if abs(np.dot(force,normal)) > 1e-3:
|
2013-06-04 18:26:57 +05:30
|
|
|
parser.error('stress plane normal not orthogonal to force direction')
|
|
|
|
else:
|
2016-03-23 06:22:02 +05:30
|
|
|
normal = force
|
2013-06-04 18:26:57 +05:30
|
|
|
|
2018-11-22 23:15:01 +05:30
|
|
|
slip_direction = np.zeros((len(slipSystems[options.lattice]),3),'f')
|
|
|
|
slip_normal = np.zeros_like(slip_direction)
|
2016-03-23 06:22:02 +05:30
|
|
|
|
|
|
|
|
|
|
|
if options.lattice in latticeChoices[:2]:
|
2018-11-22 23:15:01 +05:30
|
|
|
slip_direction = slipSystems[options.lattice][:,:3]
|
|
|
|
slip_normal = slipSystems[options.lattice][:,3:]
|
2016-03-23 06:22:02 +05:30
|
|
|
elif options.lattice == latticeChoices[2]:
|
|
|
|
# convert 4 Miller index notation of hex to orthogonal 3 Miller index notation
|
2018-11-22 23:15:01 +05:30
|
|
|
for i in range(len(slip_direction)):
|
|
|
|
slip_direction[i] = np.array([slipSystems['hex'][i,0]*1.5,
|
2016-03-23 06:22:02 +05:30
|
|
|
(slipSystems['hex'][i,0] + 2.*slipSystems['hex'][i,1])*0.5*np.sqrt(3),
|
|
|
|
slipSystems['hex'][i,3]*options.CoverA,
|
|
|
|
])
|
2018-11-22 23:15:01 +05:30
|
|
|
slip_normal[i] = np.array([slipSystems['hex'][i,4],
|
2016-03-23 06:22:02 +05:30
|
|
|
(slipSystems['hex'][i,4] + 2.*slipSystems['hex'][i,5])/np.sqrt(3),
|
|
|
|
slipSystems['hex'][i,7]/options.CoverA,
|
|
|
|
])
|
|
|
|
|
2018-11-22 23:15:01 +05:30
|
|
|
slip_direction /= np.tile(np.linalg.norm(slip_direction,axis=1),(3,1)).T
|
|
|
|
slip_normal /= np.tile(np.linalg.norm(slip_normal ,axis=1),(3,1)).T
|
2016-03-23 06:22:02 +05:30
|
|
|
|
|
|
|
# --- loop over input files ------------------------------------------------------------------------
|
2013-06-04 18:26:57 +05:30
|
|
|
|
2015-08-31 16:30:45 +05:30
|
|
|
if filenames == []: filenames = [None]
|
|
|
|
|
|
|
|
for name in filenames:
|
2016-03-23 06:22:02 +05:30
|
|
|
try: table = damask.ASCIItable(name = name,
|
|
|
|
buffered = False)
|
|
|
|
except: continue
|
2015-09-24 14:54:42 +05:30
|
|
|
damask.util.report(scriptName,name)
|
2014-08-05 01:37:20 +05:30
|
|
|
|
2016-03-23 06:22:02 +05:30
|
|
|
# ------------------------------------------ read header ------------------------------------------
|
|
|
|
|
|
|
|
table.head_read()
|
2014-08-05 01:37:20 +05:30
|
|
|
|
2016-03-23 06:22:02 +05:30
|
|
|
# ------------------------------------------ sanity checks ----------------------------------------
|
2018-12-09 15:23:53 +05:30
|
|
|
if not table.label_dimension(options.quaternion) == 4:
|
|
|
|
damask.util.croak('input {} does not have dimension 4.'.format(options.quaternion))
|
2016-03-23 06:22:02 +05:30
|
|
|
table.close(dismiss = True) # close ASCIItable and remove empty file
|
2014-08-07 00:36:33 +05:30
|
|
|
continue
|
2016-03-23 06:22:02 +05:30
|
|
|
|
2018-12-09 15:23:53 +05:30
|
|
|
column = table.label_index(options.quaternion)
|
2014-08-05 01:37:20 +05:30
|
|
|
|
2014-08-06 20:55:18 +05:30
|
|
|
# ------------------------------------------ assemble header ---------------------------------------
|
2014-08-05 01:37:20 +05:30
|
|
|
|
2016-03-23 06:22:02 +05:30
|
|
|
table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:]))
|
2016-04-11 16:54:43 +05:30
|
|
|
table.labels_append(['{id}_'
|
|
|
|
'S[{direction[0]:.1g}_{direction[1]:.1g}_{direction[2]:.1g}]'
|
|
|
|
'({normal[0]:.1g}_{normal[1]:.1g}_{normal[2]:.1g})'\
|
2016-03-23 06:22:02 +05:30
|
|
|
.format( id = i+1,
|
|
|
|
normal = theNormal,
|
|
|
|
direction = theDirection,
|
2018-11-22 23:15:01 +05:30
|
|
|
) for i,(theNormal,theDirection) in enumerate(zip(slip_normal,slip_direction))])
|
2014-08-05 01:37:20 +05:30
|
|
|
table.head_write()
|
2013-06-04 18:26:57 +05:30
|
|
|
|
2014-08-06 20:55:18 +05:30
|
|
|
# ------------------------------------------ process data ------------------------------------------
|
2016-03-23 06:22:02 +05:30
|
|
|
|
2014-08-05 01:37:20 +05:30
|
|
|
outputAlive = True
|
|
|
|
while outputAlive and table.data_read(): # read next data line of ASCII table
|
2018-12-09 15:23:53 +05:30
|
|
|
o = damask.Orientation(quaternion = np.array(list(map(float,table.data[column:column+4]))))
|
2018-11-22 23:15:01 +05:30
|
|
|
|
|
|
|
table.data_append( np.abs( np.sum(slip_direction * (o.quaternion * force) ,axis=1) \
|
|
|
|
* np.sum(slip_normal * (o.quaternion * normal),axis=1)))
|
2014-08-05 01:37:20 +05:30
|
|
|
outputAlive = table.data_write() # output processed line
|
|
|
|
|
2016-03-23 06:22:02 +05:30
|
|
|
# ------------------------------------------ output finalization -----------------------------------
|
2014-08-05 01:37:20 +05:30
|
|
|
|
2016-03-23 06:22:02 +05:30
|
|
|
table.close() # close ASCII tables
|