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:

然而,用我的等高线图,我看不到这两个井,它看起来就像是一个单一的高斯.

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:将绘图区域的界限设置为作者似乎没有帮助的界限.

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

I see this: enter image description here

推荐答案

您忘记了表达式Z周围的偏执词,因此您实际上只计算了第一个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

Python相关问答推荐

过滤绕轴旋转的螺旋桨

为什么dict(id=1,**{id:2})有时会引发KeyMessage:id而不是TypMessage?

从今天起的future 12个月内使用Python迭代

当密钥是复合且唯一时,Pandas合并抱怨标签不唯一

提取两行之间的标题的常规表达

Python daskValue错误:无法识别的区块管理器dask -必须是以下之一:[]

Python上的Instagram API:缺少client_id参数"

Python,Fitting into a System of Equations

Python中绕y轴曲线的旋转

avxspan与pandas period_range

在Python中使用if else或使用regex将二进制数据如111转换为001""

在代码执行后关闭ChromeDriver窗口

替换现有列名中的字符,而不创建新列

ModuleNotFoundError:没有模块名为x时try 运行我的代码''

如何在Great Table中处理inf和nans

使用字典或列表的值组合

Python日志(log)模块如何在将消息发送到父日志(log)记录器之前向消息添加类实例变量

什么是一种快速而优雅的方式来转换一个包含一串重复的列,而不对同一个值多次运行转换,

使用Python TCP套接字发送整数并使用C#接收—接收正确数据时出错

裁剪数字.nd数组引发-ValueError:无法将空图像写入JPEG