我一直在研究一个涉及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)内定义。我想知道是否有可能在我的绘图中显示相同的范围。我试过一些东西,但都不管用
由于没有使用
imshow
的norm
参数,因此可以使用vmin
和vmax
来指定颜色映射的上限和下限。例如:没有
vmin
和vmax
:与
vmin
和vmax
一起:这将反映在色条中,尽管为了简单起见我忽略了它们
相关问题 更多 >
编程相关推荐