2018-11-17 12:42:12 +05:30
|
|
|
#!/usr/bin/env python3
|
2013-02-25 22:42:13 +05:30
|
|
|
|
2019-05-29 13:10:56 +05:30
|
|
|
import os
|
|
|
|
import sys
|
2014-10-09 22:33:06 +05:30
|
|
|
from optparse import OptionParser
|
2019-05-29 13:10:56 +05:30
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
2014-10-09 22:33:06 +05:30
|
|
|
import damask
|
|
|
|
|
2019-05-31 13:57:26 +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-10-09 22:33:06 +05:30
|
|
|
|
2019-05-29 13:10:56 +05:30
|
|
|
|
2014-10-09 22:33:06 +05:30
|
|
|
# --------------------------------------------------------------------
|
2013-05-14 23:21:53 +05:30
|
|
|
# MAIN
|
2014-10-09 22:33:06 +05:30
|
|
|
# --------------------------------------------------------------------
|
|
|
|
|
2019-05-29 13:10:56 +05:30
|
|
|
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [geomfile]', description = """
|
|
|
|
Generate description of an osteon enclosing the Harvesian canal and separated by interstitial tissue.
|
2013-02-25 22:42:13 +05:30
|
|
|
The osteon phase is lamellar with a twisted plywood structure.
|
2013-02-27 16:26:30 +05:30
|
|
|
Its fiber orientation is oscillating by +/- amplitude within one period.
|
2014-10-09 22:33:06 +05:30
|
|
|
|
|
|
|
""", version = scriptID)
|
|
|
|
|
2013-02-25 22:42:13 +05:30
|
|
|
|
2019-05-29 13:10:56 +05:30
|
|
|
parser.add_option('-g', '--grid',
|
|
|
|
dest='grid', type='int',
|
|
|
|
nargs=2, metavar = 'int int',
|
2015-11-16 15:24:39 +05:30
|
|
|
help='a,b grid of hexahedral box [%default]')
|
2019-05-29 13:10:56 +05:30
|
|
|
parser.add_option('-s', '--size',
|
|
|
|
dest='size',
|
|
|
|
type='float', nargs=2, metavar = 'float float',
|
2015-11-16 15:24:39 +05:30
|
|
|
help='x,y size of hexahedral box [%default]')
|
2019-05-29 13:10:56 +05:30
|
|
|
parser.add_option('-c', '--canal',
|
|
|
|
dest='canal',
|
|
|
|
type='float', metavar = 'float',
|
2013-04-12 18:18:39 +05:30
|
|
|
help='Haversian canal radius [%default]')
|
2019-05-29 13:10:56 +05:30
|
|
|
parser.add_option('-o', '--osteon',
|
|
|
|
dest='osteon',
|
|
|
|
type='float', metavar = 'float',
|
2015-11-16 15:24:39 +05:30
|
|
|
help='horizontal osteon radius [%default]')
|
2019-05-29 13:10:56 +05:30
|
|
|
parser.add_option('-l', '--lamella',
|
|
|
|
dest='period',
|
|
|
|
type='float', metavar = 'float',
|
2013-04-12 18:18:39 +05:30
|
|
|
help='lamella width [%default]')
|
2019-05-29 13:10:56 +05:30
|
|
|
parser.add_option('-a', '--amplitude',
|
|
|
|
dest='amplitude',
|
|
|
|
type='float', metavar = 'float',
|
2013-04-12 18:18:39 +05:30
|
|
|
help='amplitude of twisted plywood wiggle in deg [%default]')
|
2019-05-29 13:10:56 +05:30
|
|
|
parser.add_option( '--aspect',
|
|
|
|
dest='aspect',
|
|
|
|
type='float', metavar = 'float',
|
2015-11-16 15:24:39 +05:30
|
|
|
help='vertical/horizontal osteon aspect ratio [%default]')
|
2019-05-30 17:37:49 +05:30
|
|
|
parser.add_option('-w', '--omega',
|
2019-05-29 13:10:56 +05:30
|
|
|
dest='omega',
|
|
|
|
type='float', metavar = 'float',
|
2015-11-16 15:24:39 +05:30
|
|
|
help='rotation angle around normal of osteon [%default]')
|
2019-05-29 13:10:56 +05:30
|
|
|
parser.add_option( '--homogenization',
|
|
|
|
dest='homogenization',
|
|
|
|
type='int', metavar = 'int',
|
2013-04-12 18:18:39 +05:30
|
|
|
help='homogenization index to be used [%default]')
|
2013-02-25 22:42:13 +05:30
|
|
|
|
2015-11-16 15:24:39 +05:30
|
|
|
parser.set_defaults(canal = 25e-6,
|
|
|
|
osteon = 100e-6,
|
|
|
|
aspect = 1.0,
|
|
|
|
omega = 0.0,
|
|
|
|
period = 5e-6,
|
|
|
|
amplitude = 60,
|
|
|
|
size = (300e-6,300e-6),
|
|
|
|
grid = (512,512),
|
2019-05-29 13:10:56 +05:30
|
|
|
homogenization = 1)
|
2013-02-25 22:42:13 +05:30
|
|
|
|
2015-11-16 15:24:39 +05:30
|
|
|
(options,filename) = parser.parse_args()
|
2013-02-25 22:42:13 +05:30
|
|
|
|
2015-11-16 15:24:39 +05:30
|
|
|
|
2019-05-29 13:10:56 +05:30
|
|
|
name = None if filename == [] else filename[0]
|
|
|
|
damask.util.report(scriptName,name)
|
2015-11-16 15:24:39 +05:30
|
|
|
|
2019-05-29 17:36:39 +05:30
|
|
|
omega = np.deg2rad(options.omega)
|
|
|
|
rotation = np.array([[ np.cos(omega),np.sin(omega),],
|
|
|
|
[-np.sin(omega),np.cos(omega),]])
|
2013-02-25 22:42:13 +05:30
|
|
|
|
2019-05-29 13:10:56 +05:30
|
|
|
grid = np.array(options.grid,'i')
|
|
|
|
size = np.array(options.size,'d')
|
2013-04-12 18:18:39 +05:30
|
|
|
|
2019-05-29 17:36:39 +05:30
|
|
|
X0,Y0 = np.meshgrid(size[0]/grid[0] * (np.arange(grid[0]) - grid[0]/2 + 0.5),
|
|
|
|
size[1]/grid[0] * (np.arange(grid[1]) - grid[1]/2 + 0.5), indexing='ij')
|
2013-02-25 22:42:13 +05:30
|
|
|
|
2013-05-14 23:21:53 +05:30
|
|
|
X = X0*rotation[0,0] + Y0*rotation[0,1] # rotate by omega
|
|
|
|
Y = X0*rotation[1,0] + Y0*rotation[1,1] # rotate by omega
|
2013-02-25 22:42:13 +05:30
|
|
|
|
2019-05-29 17:36:39 +05:30
|
|
|
radius = np.sqrt(X*X + Y*Y/options.aspect**2.0)
|
2014-10-09 22:33:06 +05:30
|
|
|
alpha = np.degrees(np.arctan2(Y/options.aspect,X))
|
2019-05-29 13:10:56 +05:30
|
|
|
beta = options.amplitude*np.sin(2.0*np.pi*(radius-options.canal)/options.period)
|
|
|
|
|
2019-05-29 17:48:11 +05:30
|
|
|
microstructure = np.where(radius < float(options.canal), 1,0) \
|
2019-05-29 13:10:56 +05:30
|
|
|
+ np.where(radius > float(options.osteon),2,0)
|
|
|
|
|
|
|
|
# extend to 3D
|
|
|
|
size = np.append(size,np.min(size/grid))
|
|
|
|
grid = np.append(grid,1)
|
|
|
|
microstructure = microstructure.reshape(microstructure.shape+(1,))
|
|
|
|
|
2019-05-29 17:48:11 +05:30
|
|
|
Alpha = np.zeros(grid[0]*grid[1],'d')
|
|
|
|
Beta = np.zeros(grid[0]*grid[1],'d')
|
2019-05-29 13:10:56 +05:30
|
|
|
|
|
|
|
i = 3
|
2019-05-29 17:36:39 +05:30
|
|
|
for y in range(grid[1]):
|
|
|
|
for x in range(grid[0]):
|
|
|
|
if microstructure[x,y] == 0:
|
|
|
|
microstructure[x,y] = i
|
2019-05-29 17:48:11 +05:30
|
|
|
Alpha[i] = alpha[x,y]
|
2019-05-30 13:11:22 +05:30
|
|
|
Beta [i] = beta [x,y]
|
2019-05-30 17:37:49 +05:30
|
|
|
i+=1
|
2019-05-29 13:10:56 +05:30
|
|
|
|
2019-05-30 17:35:45 +05:30
|
|
|
config_header = ['<texture>',
|
|
|
|
'[canal]',
|
|
|
|
'[interstitial]'
|
|
|
|
]
|
2019-05-29 13:10:56 +05:30
|
|
|
for i in range(3,np.max(microstructure)):
|
2019-05-30 17:35:45 +05:30
|
|
|
config_header += ['[Point{}]'.format(i-2),
|
|
|
|
'(gauss)\tphi1 {:.2f}\tPhi {:.2f}\tphi2 0'.format(Alpha[i],Beta[i])
|
|
|
|
]
|
2019-05-30 17:37:49 +05:30
|
|
|
|
2019-05-30 17:35:45 +05:30
|
|
|
config_header = ['<microstructure>',
|
|
|
|
'[canal]',
|
|
|
|
'crystallite 1',
|
|
|
|
'(constituent)\tphase 1\ttexture 1\tfraction 1.0',
|
|
|
|
'[interstitial]',
|
|
|
|
'crystallite 1',
|
|
|
|
'(constituent)\tphase 2\ttexture 2\tfraction 1.0'
|
|
|
|
]
|
2019-05-29 13:10:56 +05:30
|
|
|
for i in range(3,np.max(microstructure)):
|
2019-05-30 17:35:45 +05:30
|
|
|
config_header += ['[Point{}]'.format(i-2),
|
|
|
|
'crystallite 1',
|
|
|
|
'(constituent)\tphase 3\ttexture {}\tfraction 1.0'.format(i)
|
|
|
|
]
|
2019-05-29 13:10:56 +05:30
|
|
|
|
2019-05-30 14:15:17 +05:30
|
|
|
header = [scriptID + ' ' + ' '.join(sys.argv[1:])]\
|
|
|
|
+ config_header
|
2019-05-29 13:10:56 +05:30
|
|
|
geom = damask.Geom(microstructure.reshape(grid),
|
|
|
|
size,-size/2,
|
|
|
|
homogenization=options.homogenization,comments=header)
|
|
|
|
damask.util.croak(geom)
|
2019-05-30 17:37:49 +05:30
|
|
|
|
2019-11-24 23:32:19 +05:30
|
|
|
geom.to_file(sys.stdout if name is None else name,pack=False)
|