Esempio n. 1
0
import os, numpy as np
from pymicro.crystal.texture import PoleFigure
from pymicro.crystal.microstructure import Microstructure, Grain, Orientation
from matplotlib import pyplot as plt, colors, colorbar, cm
'''
An inverse pole figure with symboled colored by the grain size.
'''
eulers = Orientation.read_orientations('../data/EBSD_20grains.txt',
                                       data_type='euler',
                                       usecols=[1, 2, 3])
grain_sizes = np.genfromtxt('../data/EBSD_20grains.txt', usecols=[9])
micro = Microstructure(name='test')
for i in range(20):
    micro.grains.append(Grain(i + 1, eulers[i + 1]))
    micro.get_grain(i + 1).volume = grain_sizes[i]

# build a custom pole figure
pf = PoleFigure(microstructure=micro, hkl='001')  #, lattice=Ti7Al)
#pf.resize_markers = True
pf.mksize = 100
pf.set_map_field('strain',
                 grain_sizes,
                 field_min_level=0.0,
                 field_max_level=1000.,
                 lut='jet')
fig = plt.figure(figsize=(8, 5))
ax1 = fig.add_axes([0.05, 0.05, 0.8, 0.9], aspect='equal')
pf.plot_sst(ax=ax1, mk='o')
ax1.set_title('%s-axis SST inverse %s projection' % (pf.axis, pf.proj))

# to add the color bar
Esempio n. 2
0
micro = Microstructure(name='1g', autodelete=True)
g = Grain(50, Orientation.from_euler((12.293, 149.266, -167.068)))
micro.add_grains([(12.293, 149.266, -167.068)], grain_ids=[50])

ipf = PoleFigure(proj='stereo', microstructure=micro)
ipf.mksize = 100
ipf.set_map_field('grain_id')

fig = plt.figure(1, figsize=(6, 5))  # for IPF
ax1 = fig.add_subplot(111, aspect='equal')
print('** plotting the initial orientation (with label for legend) **')
ipf.plot_sst(ax=ax1, mk='.', col='k', ann=False)
ax1.set_title('grain rotation in tension')
axis = np.array([0, 0, 1])

grain = micro.get_grain(50)
cgid = Microstructure.rand_cmap().colors[grain.id]  # color by grain id
g = grain.orientation_matrix()
axis_rot_sst_prev = np.array(ipf.sst_symmetry_cubic(g.dot(axis)))
print('** plotting ipf loading axis trajectory **')
for k in range(0, max_step, step):
    rot = np.array([[R11[k], R12[k], R13[k]], [R21[k], R22[k], R23[k]],
                    [R31[k], R32[k], R33[k]]])
    # apply R^t to the initial orientation given by g
    new_g = rot.transpose().dot(g)
    axis_rot_sst = ipf.sst_symmetry_cubic(new_g.dot(axis))
    ipf.plot_line_between_crystal_dir(axis_rot_sst_prev,
                                      axis_rot_sst,
                                      ax=ax1,
                                      col=cgid,
                                      steps=2)