绘制众所周知的双井表面

发布于 2025-02-07 05:42:57 字数 2107 浏览 0 评论 0 原文

我正在尝试从物理学(Muller Brown的潜力)中绘制众所周知的能量景观。 取自文献( https://arxiv.org/abs/1701.01241 ):

在我的轮廓图的情况下,我看不到这两个井,看起来好像只是一个高斯。 我做错了吗?

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mp

# Parameters of Muller Brown Potential (cf. Bonfati & Cob 2017)
A = np.array([-200, -100, -170, 15])
a = np.array([-1, -1, -6.5, 0.7])
b = np.array([0, 0, 11, 0.6])
c = np.array([-10, -10, -6.5, 0.7])
x_m = np.array([1, 0, -0.5, -1])
y_m = np.array([0, 0.5, 1.5, 1])

x = np.linspace(-1.5, 1, 1000)
y = np.linspace(-0.5, 2, 1000)
XX, YY = np.meshgrid(x, y)


Z =A[0]*np.exp( a[0]*(XX-x_m[0])**2 + b[0]*(XX-x_m[0])*(YY-y_m[0]) + c[0]*(YY-y_m[0])**2 )
+  A[1]*np.exp( a[1]*(XX-x_m[1])**2 + b[1]*(XX-x_m[1])*(YY-y_m[1]) + c[1]*(YY-y_m[1])**2 )
+  A[2]*np.exp( a[2]*(XX-x_m[2])**2 + b[2]*(XX-x_m[2])*(YY-y_m[2]) + c[2]*(YY-y_m[2])**2 )
+  A[3]*np.exp( a[3]*(XX-x_m[3])**2 + b[3]*(XX-x_m[3])*(YY-y_m[3]) + c[3]*(YY-y_m[3])**2 )



fig, ax = plt.subplots()

c=ax.contourf(XX, YY, Z)
plt.colorbar(c)
ax.set_xlabel('x')
ax.set_ylabel('y')

编辑:将绘图区域的限制设置为作者似乎无济于事。 如果我使用的话,

x = np.linspace(-2, 0, 1000)
y = np.linspace(0, 2, 1000)

我会看到这个:

I am trying to plot a well known energy landscape from physics, the Muller Brown potential.
Taken from the literature (https://arxiv.org/abs/1701.01241):
enter image description here
enter image description here
The authors' plot:

With my contour plot, however, I cannot see the two wells, it looks as if it was just a single Gaussian.
Am I doing something wrong?

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mp

# Parameters of Muller Brown Potential (cf. Bonfati & Cob 2017)
A = np.array([-200, -100, -170, 15])
a = np.array([-1, -1, -6.5, 0.7])
b = np.array([0, 0, 11, 0.6])
c = np.array([-10, -10, -6.5, 0.7])
x_m = np.array([1, 0, -0.5, -1])
y_m = np.array([0, 0.5, 1.5, 1])

x = np.linspace(-1.5, 1, 1000)
y = np.linspace(-0.5, 2, 1000)
XX, YY = np.meshgrid(x, y)


Z =A[0]*np.exp( a[0]*(XX-x_m[0])**2 + b[0]*(XX-x_m[0])*(YY-y_m[0]) + c[0]*(YY-y_m[0])**2 )
+  A[1]*np.exp( a[1]*(XX-x_m[1])**2 + b[1]*(XX-x_m[1])*(YY-y_m[1]) + c[1]*(YY-y_m[1])**2 )
+  A[2]*np.exp( a[2]*(XX-x_m[2])**2 + b[2]*(XX-x_m[2])*(YY-y_m[2]) + c[2]*(YY-y_m[2])**2 )
+  A[3]*np.exp( a[3]*(XX-x_m[3])**2 + b[3]*(XX-x_m[3])*(YY-y_m[3]) + c[3]*(YY-y_m[3])**2 )



fig, ax = plt.subplots()

c=ax.contourf(XX, YY, Z)
plt.colorbar(c)
ax.set_xlabel('x')
ax.set_ylabel('y')

enter image description here

edit: Setting the limits of the plot region to the ones the authors does not seem to help.
If I use

x = np.linspace(-2, 0, 1000)
y = np.linspace(0, 2, 1000)

I see this:
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一刻暧昧 2025-02-14 05:42:57

您忘记了 z 的表达式周围的paranththess,因此您只能有效地评估第一个求和。

x = np.linspace(-1.5, 0.2, 1000)
y = np.linspace(0, 1.9, 1000)
XX, YY = np.meshgrid(x, y)

Z = (A[0]*np.exp( a[0]*(XX-x_m[0])**2 + b[0]*(XX-x_m[0])*(YY-y_m[0]) + c[0]*(YY-y_m[0])**2 )
    +A[1]*np.exp( a[1]*(XX-x_m[1])**2 + b[1]*(XX-x_m[1])*(YY-y_m[1]) + c[1]*(YY-y_m[1])**2 )
    +A[2]*np.exp( a[2]*(XX-x_m[2])**2 + b[2]*(XX-x_m[2])*(YY-y_m[2]) + c[2]*(YY-y_m[2])**2 )
    +A[3]*np.exp( a[3]*(XX-x_m[3])**2 + b[3]*(XX-x_m[3])*(YY-y_m[3]) + c[3]*(YY-y_m[3])**2 ))

bonus>

m1 = (-0.558223634633024, 1.441725841804669)
m2 = (-0.050010822998206, 0.466694104871972)
s1 = (-0.822001558732732, 0.624312802814871)
plt.plot(*m1, 'm*'), plt.text(*m1, "  Min 1")
plt.plot(*m2, 'm*'), plt.text(*m2, "  Min 2")
plt.plot(*s1, 'bo'), plt.text(*s1, "  Saddle 1")

You forgot the parantheses around the expression for Z so that you effectively evaluated only the first summand.

x = np.linspace(-1.5, 0.2, 1000)
y = np.linspace(0, 1.9, 1000)
XX, YY = np.meshgrid(x, y)

Z = (A[0]*np.exp( a[0]*(XX-x_m[0])**2 + b[0]*(XX-x_m[0])*(YY-y_m[0]) + c[0]*(YY-y_m[0])**2 )
    +A[1]*np.exp( a[1]*(XX-x_m[1])**2 + b[1]*(XX-x_m[1])*(YY-y_m[1]) + c[1]*(YY-y_m[1])**2 )
    +A[2]*np.exp( a[2]*(XX-x_m[2])**2 + b[2]*(XX-x_m[2])*(YY-y_m[2]) + c[2]*(YY-y_m[2])**2 )
    +A[3]*np.exp( a[3]*(XX-x_m[3])**2 + b[3]*(XX-x_m[3])*(YY-y_m[3]) + c[3]*(YY-y_m[3])**2 ))

Bonus:

m1 = (-0.558223634633024, 1.441725841804669)
m2 = (-0.050010822998206, 0.466694104871972)
s1 = (-0.822001558732732, 0.624312802814871)
plt.plot(*m1, 'm*'), plt.text(*m1, "  Min 1")
plt.plot(*m2, 'm*'), plt.text(*m2, "  Min 2")
plt.plot(*s1, 'bo'), plt.text(*s1, "  Saddle 1")

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文