Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
dislocationMobility/test.py
Go to the documentation of this file.
1# /opt/local/bin/python3.14 test.py
2import sys, string, os
3import numpy as np
4import pathlib as pt
5import math
6import matplotlib.pyplot as plt
7from matplotlib import cm
8plt.rcParams['text.usetex'] = True
9sys.path.append("../../python")
10from modlibUtils import *
11sys.path.append("../../build/tools/pyMoDELib")
12import pyMoDELib
13
14def plotMobility(m,mat,singleCrystal,slipSystem,ax1,ax2):
15 s0=0.01 # stress amplitude
16 S=np.outer(m,m)*s0 # stress tensor
17
18 theta=np.linspace(0, 360, num=360, endpoint=True)*np.pi/180
19 vel=np.zeros(len(theta))
20
21 for k in range(len(theta)):
22 xi=angleAxis(theta[k],slipSystem.unitNormal)@slipSystem.unitSlip # rotate b about n to define the line tangent
23 vel[k]=slipSystem.velocity(S,xi,mat.T)
24 ax1.plot(theta*180/np.pi, vel,label=str(mat.T)+'K')
25
26 stress=np.linspace(0, 0.02, num=100)
27 vels=np.zeros(len(stress))
28 vele=np.zeros(len(stress))
29 for k in range(len(stress)):
30 S=np.outer(m,m)*stress[k] # stress tensor
31 xi=angleAxis(0.0,slipSystem.unitNormal)@slipSystem.unitSlip # rotate b about n to define the line tangent
32 vels[k]=slipSystem.velocity(S,xi,mat.T)
33 xi=angleAxis(0.5*np.pi,slipSystem.unitNormal)@slipSystem.unitSlip # rotate b about n to define the line tangent
34 vele[k]=slipSystem.velocity(S,xi,mat.T)
35 ax2.plot(stress*mat.mu_SI/mat.E_SI, vels,label='edge '+str(mat.T)+'K')
36 ax2.plot(stress*mat.mu_SI/mat.E_SI, vele,'--',label='screw '+str(mat.T)+'K')
37
38def selectMobility(materialFile,Temps,slipSystemID,theta_deg,phi_deg):
39 fig1 = plt.figure()
40 ax1=plt.subplot(1,2,1)
41 ax2=plt.subplot(1,2,2)
42 for T in Temps:
43 mat=pyMoDELib.PolycrystallineMaterialBase(materialFile,T) # material object
44 singleCrystal=pyMoDELib.SingleCrystalBase(mat,np.identity(3))
45 for ssKey, slipSystem in singleCrystal.slipSystems().items(): # loop over lattice planes
46 if ssKey==slipSystemID:
47 m=slipSystem.unitNormal*np.cos(theta_deg*math.pi/180.0)+slipSystem.unitSlip*np.sin(theta_deg*math.pi/180.0)*np.cos(phi_deg*math.pi/180.0)+np.cross(slipSystem.unitNormal, slipSystem.unitSlip)*np.sin(theta_deg*math.pi/180.0)*np.sin(phi_deg*math.pi/180.0)
48 plotMobility(m,mat,singleCrystal,slipSystem,ax1,ax2)
49 ax1.grid()
50 ax1.legend()
51 plt.xlabel('character angle $[deg]$')
52 plt.ylabel(' v / c_s [-]')
53 ax2.grid()
54 ax2.legend()
55 plt.xlabel('axial stress/E $[-]$')
56 plt.ylabel(' v / c_s [-]')
57 fig1.savefig(materialName+"_"+str(slipSystemID)+".pdf", bbox_inches='tight')
58
59
62slipSystemID=0
63Temps=np.array([100,300,1000]) # Kelvin
64phi_deg=0.0
65theta_deg=45 # m = n*cos(theta)+s*sin(theta)*cos(phi)+(nxs)*sin(theta)*sin(phi)
66#m=np.array([0,0,1]) # stress axis
67#m=m/np.linalg.norm(m); # normalized stress axis
68
69for file in pt.Path('../../Library/Materials').glob('*.txt'):
70 if file.is_file():
71 materialFile=str(file)
72 print(materialFile)
73 Tm=getValueInFile(materialFile,"Tm")
74 materialName=getStringInFile(materialFile,"materialName")
75 selectMobility(materialFile,Temps,slipSystemID,theta_deg,phi_deg)
getStringInFile(fileName, variable)
angleAxis(theta, a)
getValueInFile(fileName, variable)
selectMobility(materialFile, Temps, slipSystemID, theta_deg, phi_deg)
plotMobility(m, mat, singleCrystal, slipSystem, ax1, ax2)