Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
gammaSurface/test.py
Go to the documentation of this file.
1# /opt/local/bin/python3.13 test.py
2import sys, string, os
3import numpy as np
4import matplotlib.pyplot as plt
5from matplotlib import cm
6plt.rcParams['text.usetex'] = True
7sys.path.append("../../python")
8from modlibUtils import *
9sys.path.append("../../build/tools/pyMoDELib")
10import pyMoDELib
11
12def plotGammaSurface(mat,gammaSurface,lab,pts,nc,nR,C):
13 energyDensityScaling=mat.mu_SI*mat.b_SI
14 fig, axs = plt.subplots(2,2)
15 axs[0, 0].set_aspect("equal")
16 axs[0, 1].set_aspect("equal")
17 a0=gammaSurface.A[:,0]
18 a1=gammaSurface.A[:,1]
19 r0=gammaSurface.B[:,0]
20 r1=gammaSurface.B[:,1]
21 X=np.zeros((pts+1,pts+1))
22 Y=np.zeros((pts+1,pts+1))
23 GSFE=np.zeros((pts+1,pts+1))
24 for i in range(pts+1):
25 for j in range(pts+1):
26 sL=i/pts*a0+j/pts*a1 # slip vector
27 #sL=planeValue.localSlipVector(s) # slip vector in the plane local coordinates
28 X[j,i]=sL[0]
29 Y[j,i]=sL[1]
30 GSFE[j,i]=gammaSurface.misfitEnergy(sL)*energyDensityScaling
31
32 pmsh=axs[0, 0].pcolormesh (X, Y, GSFE,cmap=cm.coolwarm,shading='gouraud')
33 axs[0, 0].arrow(0, 0, a0[0], a0[1])
34 axs[0, 0].arrow(0, 0, a1[0], a1[1])
35 axs[0, 1].arrow(0, 0, r0[0], r0[1])
36 axs[0, 1].arrow(0, 0, r1[0], r1[1])
37 for i in range(-nR,nR):
38 for j in range(-nR,nR):
39 r=i*r0+j*r1
40 axs[0, 1].scatter(r[0],r[1],0.1,color='k')
41 rcirc=plt.Circle((0, 0), np.linalg.norm(r), color='0.5',fill=False,linewidth=0.25)
42 axs[0, 1].add_patch(rcirc)
43 axs[0, 1].scatter(gammaSurface.waveVectors[:,0],gammaSurface.waveVectors[:,1],color='m',s=1)
44 axs[0, 0].scatter(gammaSurface.points[:,0],gammaSurface.points[:,1],color='k',s=1)
45
46 e=np.zeros((nc))
47 c=gammaSurface.A@C
48 for j in range(0,np.shape(c)[1]):
49 cj=c[:,j]
50 for i in range(0,nc):
51 e[i]=gammaSurface.misfitEnergy(cj/nc*i)*energyDensityScaling
52 axs[1, 0].plot(np.linspace(0, np.linalg.norm(cj), num=nc, endpoint=False),e)
53 fig.savefig(mat.materialName+lab+".pdf", bbox_inches='tight', format='pdf')
54
55
57materialFile="../../Library/Materials/W.txt"
58absoluteTemperature=0.0
59mat=pyMoDELib.PolycrystallineMaterialBase(materialFile,absoluteTemperature)
60energyDensityScaling=mat.mu_SI*mat.b_SI
61C2G=np.array([[1,0,0],[0,1,0],[0,0,1]])
62singleCrystal=pyMoDELib.SingleCrystalBase(mat,C2G)
63
64# initialize
65nR=4
66pts=50 # GSFE resolution in each direction
67nc=100 # GSFE cuts resolution
68
69C=np.array([[1,1],
70 [0,1]])
71
72for planeKey, planeValue in singleCrystal.planeNormals().items(): # loop over lattice planes
73 #b0=planeValue.primitiveVectors[0].cartesian() # first primitive vector of the matrix lattice plane
74 #b1=planeValue.primitiveVectors[1].cartesian() # second primitive vector of the matrix lattice plane
75 # Matrix
76 if planeValue.gammaSurface is not None:
77 plotGammaSurface(mat,planeValue.gammaSurface,"_plane_"+str(planeKey)+"_matrix",pts,nc,nR,C)
78 # Second Phases
79 for phaseKey, phaseValue in singleCrystal.secondPhases().items():
80 if phaseValue.gammaSurface(planeKey) is not None:
81 plotGammaSurface(mat,phaseValue.gammaSurface(planeKey),"_plane_"+str(planeKey)+"_"+phaseValue.name,pts,nc,nR,C)
plotGammaSurface(mat, gammaSurface, lab, pts, nc, nR, C)
f plot([a(1) b(1)],[a(2) b(2)], 'k') axis equal num1