fixed bugs (grain index start, alpha orientation for elliptic osteons).

added option to rotate osteon relative to periodic box.
This commit is contained in:
Philip Eisenlohr 2013-02-27 10:56:30 +00:00
parent 62e55483f7
commit 565c532546
2 changed files with 39 additions and 27 deletions

View File

@ -31,38 +31,41 @@ class extendedOption(Option):
parser = OptionParser(option_class=extendedOption, usage='%prog', description = """
Generate a geometry file of an osteon enclosing the Harvesian canal and separated by interstitial tissue.
The osteon phase is lamellar with a twisted plywood structure.
Its orientation is oscillating by +/- amplitude within one period.
""" + string.replace('$Id: geom_fromMinimalSurface.py 2078 2013-01-18 12:59:26Z MPIE\p.eisenlohr $','\n','\\n')
Its fiber orientation is oscillating by +/- amplitude within one period.
""" + string.replace('$Id$','\n','\\n')
)
parser.add_option('-c', '--canal', dest='canal', type='float', \
help='Haversian canal radius')
help='Haversian canal radius')
parser.add_option('-o', '--osteon', dest='osteon', type='float', \
help='Osteon radius (horizontal)')
help='Osteon radius (horizontal)')
parser.add_option('-r', '--aspect', dest='aspect', type='float', \
help='Osteon aspect ratio (vert/horiz)')
parser.add_option('-s', '--size', dest='size', type='float', \
help='box size (horizontal)')
help='Osteon aspect ratio (vert/horiz)')
parser.add_option('-w', '--omega', dest='omega', type='float', \
help='rotation angle (around normal) of osteon')
parser.add_option('-s', '--size', dest='size', type='float', \
help='box size (horizontal)')
parser.add_option('-m', '--margin', dest='margin', type='float', \
help='margin width')
help='margin width')
parser.add_option('-N', '--resolution', dest='resolution', type='int', \
help='box size in pixels (horizontal)')
help='box size in pixels (horizontal)')
parser.add_option('-a', '--amplitude', dest='amplitude', type='float', \
help='Amplitude of twisted plywood wiggle in deg')
help='Amplitude of twisted plywood wiggle in deg')
parser.add_option('-p', '--period', dest='period', type='float', \
help='lamella width')
help='lamella width')
parser.add_option('--homogenization', dest='homogenization', type='int', \
help='homogenization index to be used')
parser.add_option('--crystallite', dest='crystallite', type='int', \
help='crystallite index to be used')
help='homogenization index to be used')
parser.add_option('--crystallite', dest='crystallite', type='int', \
help='crystallite index to be used')
parser.add_option('--configuration', dest='config', action='store_true', \
help='output material configuration')
help='output material configuration')
parser.add_option('-2', '--twodimensional', dest='twoD', action='store_true', \
help='output geom file with two-dimensional data arrangement')
help='output geom file with two-dimensional data arrangement')
parser.set_defaults(canal = 25e-6)
parser.set_defaults(osteon = 75e-6)
parser.set_defaults(aspect = 1.0)
parser.set_defaults(omega = 0.0)
parser.set_defaults(period = 5e-6)
parser.set_defaults(amplitude = 60)
parser.set_defaults(size = 300e-6)
@ -117,27 +120,35 @@ else:
options.canal *= info['resolution'][0]/info['dimension'][0] # rescale to pixel dimension
options.osteon *= info['resolution'][0]/info['dimension'][0] # rescale to pixel dimension
options.period *= info['resolution'][0]/info['dimension'][0] # rescale to pixel dimension
options.omega *= math.pi/180.0 # rescale ro radians
rotation = numpy.array([[ math.cos(options.omega),math.sin(options.omega),],
[-math.sin(options.omega),math.cos(options.omega),]],'d')
X0 = numpy.tile(range(info['resolution'][0]),(info['resolution'][0],1)) - info['resolution'][0]/2 + 0.5
Y0 = numpy.tile(range(info['resolution'][1]),(info['resolution'][1],1)).transpose() - info['resolution'][1]/2 + 0.5
X = X0*rotation[0,0] + Y0*rotation[1,0] # rotate by omega
Y = X0*rotation[0,1] + Y0*rotation[1,1] # rotate by omega
X = numpy.tile(range(info['resolution'][0]),(info['resolution'][0],1)) - info['resolution'][0]/2 + 0.5
Y = numpy.tile(range(info['resolution'][1]),(info['resolution'][1],1)).transpose() - info['resolution'][1]/2 + 0.5
radius = numpy.sqrt(X*X/options.aspect/options.aspect + Y*Y)
alpha = numpy.degrees(numpy.arctan2(Y,X))
alpha = numpy.degrees(numpy.arctan2(X/options.aspect,Y))
beta = options.amplitude*numpy.sin(math.pi*(radius-options.canal)/options.period)
microstructure = numpy.where(radius < float(options.canal),1,0) + numpy.where(radius > float(options.osteon),2,0)
sys.stderr.write('micro %f\n'%(time.clock()))
info['grains'] = 2
info['grains'] = 3
alphaOfGrain = numpy.zeros(info['resolution'][0]*info['resolution'][1],'d')
betaOfGrain = numpy.zeros(info['resolution'][0]*info['resolution'][1],'d')
for y in xrange(info['resolution'][1]):
for x in xrange(info['resolution'][0]):
if microstructure[x,y] == 0:
info['grains'] += 1
microstructure[x,y] = info['grains']
alphaOfGrain[info['grains']] = alpha[x,y]
betaOfGrain[ info['grains']] = beta[x,y]
info['grains'] += 1
sys.stderr.write('micro assemble %f\n'%(time.clock()))
@ -145,7 +156,7 @@ sys.stderr.write('micro assemble %f\n'%(time.clock()))
# -------------------------------------- switch according to task ----------------------------------
formatwidth = 1+int(math.floor(math.log10(info['grains'])))
formatwidth = 1+int(math.floor(math.log10(info['grains']-1)))
if options.config:
file['output'].write('<microstructure>\n')
@ -155,16 +166,16 @@ if options.config:
file['output'].write('\n[interstitial]\n' + \
'crystallite %i\n'%options.crystallite + \
'(constituent)\tphase 2\ttexture 2\tfraction 1.0\n')
for i in xrange(2,info['grains']):
file['output'].write('\n[Grain%s]\n'%(str(i+1).zfill(formatwidth)) + \
for i in xrange(3,info['grains']):
file['output'].write('\n[Grain%s]\n'%(str(i).zfill(formatwidth)) + \
'crystallite %i\n'%options.crystallite + \
'(constituent)\tphase 3\ttexture %s\tfraction 1.0\n'%(str(i+1).rjust(formatwidth)))
'(constituent)\tphase 3\ttexture %s\tfraction 1.0\n'%(str(i).rjust(formatwidth)))
file['output'].write('\n<texture>\n')
file['output'].write('\n[canal]\n')
file['output'].write('\n[interstitial]\n')
for i in xrange(2,info['grains']):
file['output'].write('\n[Grain%s]\n'%(str(i+1).zfill(formatwidth)) + \
for i in xrange(3,info['grains']):
file['output'].write('\n[Grain%s]\n'%(str(i).zfill(formatwidth)) + \
'(gauss)\tphi1 %g\tPhi %g\tphi2 0\tscatter 0.0\tfraction 1.0\n'%(\
alphaOfGrain[i],\
betaOfGrain[i]))

View File

@ -20,6 +20,7 @@ bin_link = { \
'geom_fromAng.py',
'geom_fromMinimalSurface.py',
'geom_fromVoronoiTessellation.py',
'geom_Osteon.py',
'geom_canvas.py',
'geom_check.py',
'geom_rescale.py',