我想绘制以下场方程:
但我不知道如何将边界限制为三角形x>=0, y>=0, x<=1-y
:
# stream plot with matplotlib
import numpy as np
import matplotlib.pyplot as plt
def velocity_i(x,y):
vx = x*(3*x+4*y-3)
vy = y*(3*x+4*y-4)
return vx, vy
n=100
x = np.linspace(0, 1, n)
y = np.linspace(0, 1, n)
X, Y = np.meshgrid(x, y)
Ux, Uy = velocity_i(X, Y)
vels = (Ux**2+Uy**2)**0.5
plt.figure(figsize=(5,4))
stream = plt.streamplot(X, Y,
Ux,Uy,
arrowsize=1,
arrowstyle='->',
color= vels,
density=1,
linewidth=1,
)
plt.xlabel(r"$\Omega_{\rm m}$",fontsize='14')
plt.ylabel(r"$\Omega_{\rm …
Run Code Online (Sandbox Code Playgroud)