Freiflächen in 3d plotten mit malplotlib
Verfasst: Mittwoch 11. März 2020, 18:17
Hallo,
ich möchte 3-dimensionale Formen wie Kegel, Zylinder usw. mit Matplotlib darstellen. Im konkreten Bsp. geht es um die MohrCoulomb yield function in 3D. Diese ist eine Pyramide mit einer unregelmäßigen hexagonalen Grundfläche - siehe Bild
Diese Yield Surface ist durch 6 Fläche begrenzt und Ich habe nun versucht die formeln in python zu definieren und dann mit matplotlib darzustellen - leider kommt hier absolut nicht das heraus was ich haben möchte.....
Ich schaffe es auch nicht den Kegel so darzustellen dass er die entlang der hydrostatischen Achse im dreidimensionalen Raum liegt.
leider finde ich online nur sehr wenig zu diesem spezifischen Thema, deshalb hoffe ich das mir hier jemand weiterhelfen kann.
Vielen Dank schon mal im Voraus!
Mohr Coulomb Yield Surface:

der code den ich für Mohr Coulomb geschrieben habe lautet wie folgt:
from mpl_toolkits.mplot3d import axes3d
from matplotlib.collections import PolyCollection
from mpl_toolkits.mplot3d.art3d import Poly3DCollection as p3dc
import matplotlib.pyplot as plt
import numpy as np
phi = 30/180*np.pi
c = 0
x = np.linspace(0,1000,5)
y = z = x*((1-np.sin(phi))/(1+np.sin(phi))) - (2*c*np.cos(phi))/(1+np.sin(phi))
#print(x,y,z)
def f1(x,z):
return (x-z)-(x+z)*np.sin(phi)-2*c*np.cos(phi)
X1, Z1 = np.meshgrid(x, z)
Y1 = f1(X1, Z1)
def f2(x,y):
return (x-y)-(x+y)*np.sin(phi)-2*c*np.cos(phi)
X2, Y2 = np.meshgrid(x, y)
Z2 = f2(X2,Y2)
def f3(x,y):
return (y-x)-(y+x)*np.sin(phi)-2*c*np.cos(phi)
X3, Y3 = np.meshgrid(x, y)
Z3 = f3(X3,Y3)
def f4(y,z):
return (y-z)-(y+z)*np.sin(phi)-2*c*np.cos(phi)
Y4, Z4 = np.meshgrid(y,z)
X4 = f4(Y4,Z4)
def f5(y,z):
return (z-y)-(z+y)*np.sin(phi)-2*c*np.cos(phi)
Y5, Z5 = np.meshgrid(y,z)
X5 = f5(Y5, Z5)
def f6(x,z):
return (z-x)-(z+x)*np.sin(phi)-2*c*np.cos(phi)
X6, Z6 = np.meshgrid(x,z)
Y6 = f5(X6, Z6)
fig = plt.figure()
ax = plt.axes(projection='3d')
#ax.contour3D(X, Y, Z, 30, cmap='binary')
ax.plot_surface(X1,Y1,Z1)
ax.plot_wireframe(X2,Y2,Z2)
ax.plot_wireframe(X3,Y3,Z3)
ax.plot_wireframe(X4,Y4,Z4)
ax.plot_wireframe(X5,Y5,Z5)
ax.plot_wireframe(X6,Y6,Z6)
ax.set_xlabel('Sigma 1')
ax.set_ylabel('Sigma 3')
ax.set_zlabel('Sigma 3');
plt.show()
ich möchte 3-dimensionale Formen wie Kegel, Zylinder usw. mit Matplotlib darstellen. Im konkreten Bsp. geht es um die MohrCoulomb yield function in 3D. Diese ist eine Pyramide mit einer unregelmäßigen hexagonalen Grundfläche - siehe Bild
Diese Yield Surface ist durch 6 Fläche begrenzt und Ich habe nun versucht die formeln in python zu definieren und dann mit matplotlib darzustellen - leider kommt hier absolut nicht das heraus was ich haben möchte.....
Ich schaffe es auch nicht den Kegel so darzustellen dass er die entlang der hydrostatischen Achse im dreidimensionalen Raum liegt.
leider finde ich online nur sehr wenig zu diesem spezifischen Thema, deshalb hoffe ich das mir hier jemand weiterhelfen kann.
Vielen Dank schon mal im Voraus!
Mohr Coulomb Yield Surface:

der code den ich für Mohr Coulomb geschrieben habe lautet wie folgt:
from mpl_toolkits.mplot3d import axes3d
from matplotlib.collections import PolyCollection
from mpl_toolkits.mplot3d.art3d import Poly3DCollection as p3dc
import matplotlib.pyplot as plt
import numpy as np
phi = 30/180*np.pi
c = 0
x = np.linspace(0,1000,5)
y = z = x*((1-np.sin(phi))/(1+np.sin(phi))) - (2*c*np.cos(phi))/(1+np.sin(phi))
#print(x,y,z)
def f1(x,z):
return (x-z)-(x+z)*np.sin(phi)-2*c*np.cos(phi)
X1, Z1 = np.meshgrid(x, z)
Y1 = f1(X1, Z1)
def f2(x,y):
return (x-y)-(x+y)*np.sin(phi)-2*c*np.cos(phi)
X2, Y2 = np.meshgrid(x, y)
Z2 = f2(X2,Y2)
def f3(x,y):
return (y-x)-(y+x)*np.sin(phi)-2*c*np.cos(phi)
X3, Y3 = np.meshgrid(x, y)
Z3 = f3(X3,Y3)
def f4(y,z):
return (y-z)-(y+z)*np.sin(phi)-2*c*np.cos(phi)
Y4, Z4 = np.meshgrid(y,z)
X4 = f4(Y4,Z4)
def f5(y,z):
return (z-y)-(z+y)*np.sin(phi)-2*c*np.cos(phi)
Y5, Z5 = np.meshgrid(y,z)
X5 = f5(Y5, Z5)
def f6(x,z):
return (z-x)-(z+x)*np.sin(phi)-2*c*np.cos(phi)
X6, Z6 = np.meshgrid(x,z)
Y6 = f5(X6, Z6)
fig = plt.figure()
ax = plt.axes(projection='3d')
#ax.contour3D(X, Y, Z, 30, cmap='binary')
ax.plot_surface(X1,Y1,Z1)
ax.plot_wireframe(X2,Y2,Z2)
ax.plot_wireframe(X3,Y3,Z3)
ax.plot_wireframe(X4,Y4,Z4)
ax.plot_wireframe(X5,Y5,Z5)
ax.plot_wireframe(X6,Y6,Z6)
ax.set_xlabel('Sigma 1')
ax.set_ylabel('Sigma 3')
ax.set_zlabel('Sigma 3');
plt.show()