遮罩圆形区域的流线图

2024-05-28 23:48:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我用streamplot来画一个开放圆周围的应力轨迹。我不想分析圆半径内的应力轨迹,原因有两个:(1)应力不会像穿过孔洞周围的介质那样通过空气传播,(2)数学不允许。我一直在胡思乱想做个面具,但一直没能让它发挥作用。也许还有更好的办法。有人知道我如何在不在洞的半径内绘制这些轨迹吗?实际上,我需要某种命令来告诉流线图在到达孔的外半径时停止,但同时也知道在哪里可以再次拾取。下面代码的第一部分只是用来推导应力轨迹方向的数学。我把这个作为参考。接下来,我画出轨迹。在

import numpy as np
import matplotlib.pyplot as plt
from pylab import *

def stress_trajectory_cartesian(X,Y,chi,F,a):
    # r is the radius out from the center of the hole at which we want to know the stress
    # Theta is the angle from reference at which we want to know the stress
    # a is the radius of the hole
    r = np.sqrt(np.power(X,2)+np.power(Y,2))*1.0
    c = (1.0*a)/(1.0*r)
    theta = np.arctan2(Y,X)

    A = 0.5*(1 - c**2. + (1 - 4*c**2. + 3*c**4.)*np.cos(2*theta))
    B = 0.5*(1 - c**2. - (1 - 4*c**2. + 3*c**4.)*np.cos(2*theta))
    C = 0.5*(1 + c**2. - (1 + 3*c**4.)*np.cos(2*theta))
    D = 0.5*(1 + c**2. + (1+ 3*c**4.)*np.cos(2*theta))
    E = 0.5*((1 + 2*c**2. - 3*c**4.)*np.sin(2*theta))

    tau_r = 1.0*F*c**2. + (A-1.0*chi*B) # Radial stress
    tau_theta = -1.*F*c**2. + (C - 1.0*chi*D) # Tangential stress
    tau_r_theta = (-1 - 1.0*chi)*E # Shear stress

    tau_xx = .5*tau_r*(np.cos(2*theta)+1) -1.0*tau_r_theta*np.sin(2*theta) + .5*(1-np.cos(2*theta))*tau_theta
    tau_xy = .5*np.sin(2*theta)*(tau_r - tau_theta) + 1.0*tau_r_theta*np.cos(2*theta)
    tau_yy = .5*(1-np.cos(2*theta))*tau_r + 1.0*tau_r_theta*np.sin(2*theta) + .5*(np.cos(2*theta)+1)*tau_theta

    tan_2B = (2.*tau_xy)/(1.0*tau_xx - 1.0*tau_yy)
    beta1 = .5*np.arctan(tan_2B)
    beta2 = .5*np.arctan(tan_2B) + np.pi/2.

    return beta1, beta2

# Functions to plot beta as a vector field in the Cartesian plane
def stress_beta1_cartesian(X,Y,chi,F,a):
    return stress_trajectory_cartesian(X,Y,chi,F,a)[0]
def stress_beta2_cartesian(X,Y,chi,F,a):
    return stress_trajectory_cartesian(X,Y,chi,F,a)[1]
#Used to return the directions of the betas
def to_unit_vector_x(angle):
    return np.cos(angle)
def to_unit_vector_y(angle):
    return np.sin(angle)

下面的代码绘制了应力轨迹:

^{pr2}$

Tags: thetoreturn轨迹defnp半径sin
1条回答
网友
1楼 · 发布于 2024-05-28 23:48:56

我认为对于不想考虑的区域,您只需要具有^ {CD1>}值。我在下面生成了一个简单的示例。在

import numpy as np
import matplotlib.pyplot as plt

Y, X = np.mgrid[-5:5:100j, -5:5:100j]
R = np.sqrt(X**2 + Y**2)
U = -1 - X**2 + Y
V = 1 + X - Y**2
U[R<1] = np.nan
V[R<1] = np.nan

plt.streamplot(X, Y, U, V, density=2.5, arrowstyle='-')
plt.axis("image")
plt.savefig("stream.png", dpi=300)
plt.show()

有情节的

enter image description here

相关问题 更多 >

    热门问题