from matplotlib import pyplot as plt import numpy as np """ =========== Hanson model for conical indentation =========== """ H = Hanson(F=1., E=1., nu=0.3, half_angle=70.29) Ne = 20 mesh = RegularQuadMesh(N1=Ne, N2=Ne, l1=H.a * 2., l2=H.a * 2., dtf='d') mesh.nodes.translate(H.a / 20., H.a / 20.) S = mesh.nodes.eval_tensorFunction(H.sigma) R, Z, T, tri = mesh.dump2triplot() R, Z = np.array(R), np.array(Z) # Some fields srr = S.get_component(11) szz = S.get_component(22) stt = S.get_component(33) srz = S.get_component(12) smises = S.vonmises() s1, s2, s3, v1, v2, v3 = S.eigen() # Eigenvalues and eigenvectors data = smises.data N = 20 levels = np.linspace(0., max(data), N) a = H.a plt.figure() plt.tricontourf(R / a, Z / a, tri, data, levels)
def function(x, y, z, labels): r0 = 1. theta = 2 * pi * x r = y + r0 ux = -x + r * cos(theta) uy = -y + r * sin(theta) uz = 0. * z return ux, uy, uz N1, N2 = 100, 25 l1, l2 = .75, 1. Ncolor = 20 mesh = RegularQuadMesh(N1 = N1, N2 = N2, l1 = l1, l2 = l2) vectorField = mesh.nodes.eval_vectorFunction(function) mesh.nodes.apply_displacement(vectorField) field = vectorField.get_coord(2) # we chose to plot coordinate 2 field2 = vectorField.get_coord(2) # we chose to plot coordinate 2 x,y,z = mesh.get_edges() # Mesh edges X,Y,Z,tri = mesh.dump2triplot() xb,yb,zb = mesh.get_border() # mesh borders xe, ye, ze = mesh.get_edges() fig = plt.figure(figsize=(10,10)) fig.gca().set_aspect('equal') plt.axis('off') plt.plot(xb,yb,'k-', linewidth = 2.) plt.plot(xe, ye,'k-', linewidth = .5) plt.tricontour(X,Y,tri,field.data, Ncolor, colors = 'black') color = plt.tricontourf(X,Y,tri,field.data, Ncolor) plt.colorbar(color) plt.show()
from matplotlib import pyplot as plt import numpy as np """ =========== Hanson model for conical indentation =========== """ H = Hanson(F = 1., E=1., nu = 0.3, half_angle = 70.29) Ne = 20 mesh = RegularQuadMesh(N1 = Ne, N2 = Ne, l1 = H.a * 2., l2 = H.a * 2., dtf = 'd') mesh.nodes.translate(H.a/20., H.a/20.) S = mesh.nodes.eval_tensorFunction(H.sigma) R,Z,T,tri = mesh.dump2triplot() R, Z = np.array(R), np.array(Z) # Some fields srr = S.get_component(11) szz = S.get_component(22) stt = S.get_component(33) srz = S.get_component(12) smises = S.vonmises() s1, s2, s3, v1, v2, v3 = S.eigen() # Eigenvalues and eigenvectors data = smises.data N = 20 levels = np.linspace(0., max(data), N) a = H.a plt.figure() plt.tricontourf(R/a, Z/a, tri, data, levels)