【发布时间】:2020-03-16 22:44:57
【问题描述】:
我一直在研究一个涉及 2+1 维非线性薛定谔方程的物理问题。我想为模拟的最后一步绘制取决于 x 和 y 的密度。本次模拟对应的数据可以在this h5 file找到。
我已经为情节编写了以下脚本
import matplotlib.pyplot as plt
import numpy as np
import h5py as h5
data = h5.File('groundstate_interacting_2D_n50u2.h5', 'r')
dens = data['1']['norm_dens']
norma = data['2']['norm']
en_pot = data['3']['energyp']
en_kin = data['4']['energyk']
en_int = data['5']['energyint']
pot_chem = data['6']['potencialchem']
latticex = data['7']['x']
latticey = data['7']['y']
time = data['7']['t']
phireal = data['7']['phireal']
phiimag = data['7']['phiimag']
#computes the square of the module of the wave-function
distr = np.power(phireal[:,:,:],2) + np.power(phiimag[:,:,:],2)
X, Y = np.meshgrid(latticex, latticey)
fig, ax = plt.subplots()
mdr = ax.imshow(distr[400,:,:], interpolation='gaussian',cmap='plasma')
ax.set_ylabel('Y',fontsize='large', fontweight='bold')
ax.set_xlabel('X',fontsize='large', fontweight='bold')
ax.grid(False)
fig.colorbar(mdr)
plt.show()
在我的问题中,x 和 y 都定义在包含 32 个点的格子 (latticex and latticey) 的范围 (-4.0, 4.0) 中。我想知道是否可以在我的图中显示相同的范围。我尝试了一些方法,但都没有奏效。
【问题讨论】:
标签: python matplotlib 2d physics imshow