Skip to content

Instantly share code, notes, and snippets.

@bradlipovsky
Last active July 28, 2022 16:25
Show Gist options
  • Save bradlipovsky/5f8e75d6147dd3b059a38fc783324037 to your computer and use it in GitHub Desktop.
Save bradlipovsky/5f8e75d6147dd3b059a38fc783324037 to your computer and use it in GitHub Desktop.
Plot the strains on a line running parallel to a mode 1 (opening) crack
import numpy as np
import matplotlib.pyplot as plt
# Analytical solutions found in Zehnder
a = 10
x1 = np.linspace(0,2*a,401)
x2 = np.linspace(0,1.5*a,201)
X1,X2 = np.meshgrid(x1,x2)
Z = X1 + 1j*X2
s11 = np.real(Z / np.sqrt(Z**2 - a**2))\
- X2*np.imag(1/np.sqrt(Z**2 - a**2)\
- Z**2/(Z**2-a**2)**(3/2)) - 1
s22 = np.real(Z / np.sqrt(Z**2 - a**2))\
+ X2*np.imag(1/np.sqrt(Z**2 - a**2)\
- Z**2/(Z**2-a**2)**(3/2))
E = 1e10
nu=0.3
plt.subplots(1,2,figsize=(10,3))
ax=plt.subplot(1,2,1)
p1=plt.pcolor(x1,x2,s11,vmin=-1,vmax=1,cmap='seismic')
ax.set_aspect('auto')
plt.title('S11')
plt.colorbar(p1)
plt.subplot(1,2,2)
p2=plt.pcolor(x1,x2,s22,vmin=-1,vmax=1,cmap='seismic')
plt.title('S22')
plt.colorbar(p2)
plt.tight_layout()
plt.show()
distance_from_the_fracture_plane = 20
fig2,ax2 = plt.subplots()
fig3,ax3 = plt.subplots(1,4,figsize=(10,3))
for i,nu in enumerate((0.1,0.2,0.3,0.4)):
e11 = (1+nu)/E *(s11 - nu*(s11+s22))
axx = plt.subplot(1,4,i+1)
p2=axx.pcolor(x1,x2,e11,vmin=-1e-10,vmax=1e-10,cmap='seismic')
axx.set_title(f'nu={nu}')
# axx.colorbar(p2)
ax2.plot(x1,e11[distance_from_the_fracture_plane,:],label=f'e11 with nu={nu}')
ax2.legend()
ax2.set_ylabel('Exx Strain (nanostrain)')
ax2.set_xlabel('Distance along fracture (m)')
fig3.tight_layout()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment