在 python 中结合两个势

发布于 2024-10-19 06:01:11 字数 477 浏览 5 评论 0原文

所以我需要定义Python的潜力。我有无限方势阱,并且它在中间有势垒。

对于屏障,我有这样的:

    V_x = zeros([Npts],float)
for i in range(0,Npts,1):
    if x[i] > 0 and x[i]<width:
        V_x[i]=v0

Npts 是 x 的长度,x 被定义为从 xmin 到 xmax 递增值的数组(x=arange(Xmin,Xmax+0.001,dx))。

如何将无限的潜力融入其中?

它有一定的长度(假设从 -100 到 100),并且必须表现得像不可穿透的墙(-100 和 100 处的函数必须为零)。

我可以将势垒与该电势单独组合(例如,V_b 为势垒,V_p 为无限电势,然后 V_x 可以是 V_x=V_b+V_p)。

你认为这可行吗?我在定义无限潜力时遇到了问题......

So I need to define the potential in python. I have infinite square well potential, and it has, in the middle the potential barrier.

For the barrier I have this:

    V_x = zeros([Npts],float)
for i in range(0,Npts,1):
    if x[i] > 0 and x[i]<width:
        V_x[i]=v0

Npts is the the length of the x, and x is defined as array of increasing values from xmin to xmax (x=arange(Xmin,Xmax+0.001,dx)).

How to include the infinite potential into this?

It has some length (let's say from -100 to 100) and it has to behave like impenetrable wall (the function at the -100 and 100 has to be zero).

I could combine the barrier with this potential separately (e.g. V_b for the barrier, and V_p for the infinite potential and then the V_x could be V_x=V_b+V_p).

Do you think that could work? I have the problem defining that infinite potential...

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

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

发布评论

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

评论(2

地狱即天堂 2024-10-26 06:01:11

我建议只使用一个数字来表示无限潜力,该数字比有限潜力大几个数量级(3-4)。让它变得更大不会对你们各州的能量产生太大的影响。事实上,您很快就会受到求解哈密顿量时所使用的浮点数的精度的更多限制。您实际上只需将末端设置为“无限”,因此类似以下内容应该有效:V_x[0] = V_x[-1] = abs(v0)*10**4。当然,如果你愿意的话,你可以把它设置得更大,但我认为这不会有太大的区别。如果您没有将两端设置为无限,那么您为什么要尝试在您知道波函数将为零的区域的大部分区域中求解波函数值?

另外,请注意,您的无限潜力与您所使用的单位中的 h-bar^2/2/m/delta_x^2 没有可比性。这一切都使得“无限”势能比哈密顿量中的有限势和动能项大几个数量级。

I would suggest just using a number for your infinite potential that is a few orders (3-4) of magnitude larger than your finite potential. It will not make much of a difference in the energies of your states to make it any larger. In fact, you'll quickly be limited more by the precision of the floats used when solving the Hamiltonian. You really only need to set the ends to be 'infinite' so something like the following should work: V_x[0] = V_x[-1] = abs(v0)*10**4. Of course, you can set it to be larger if you want, but I don't think that it will make much of a difference. If you aren't setting the ends to be infinite, then why are you trying to solve for the value of your wave function in large portions of the region in which you know that the wave function will be zero?

Also, be careful that your infinite potential isn't of compararable magnitude to h-bar^2/2/m/delta_x^2 in the units that you are using. It's all making the 'infinite' potential be a few orders of magnitude larger than both the finite potential and the kinetic energy terms in your Hamiltonian.

南街九尾狐 2024-10-26 06:01:11

Numpy 有一个 Inf 浮点变量,因此根据您使用势的方式,您可以显式定义它:

import numpy as np
Npts = 100
v0 = 10.0
V_x = v0*np.ones((Npts,),dtype=float)
x = np.linspace(-20,20,Npts)
width = 15.0
# now replace those values for the potential in the impenetrable
# region with np.Inf 
ii = ((x>width) | (x<0)).nonzero()
V_x[ii] = np.Inf

这为您提供了一个 x 在 -20 到 20 之间的系统,其中 V_x = v0 for 0 < ; x < 15 且 V_x = Inf,其中 x > 15或x<15 0

注意:作为一般建议,还有一些更有效的方法来设置 numpy 数组,而不是使用 for 循环,如上面的代码所示。

Numpy has a Inf float variable, so depending on how you are using the potential, you can define it explicitly:

import numpy as np
Npts = 100
v0 = 10.0
V_x = v0*np.ones((Npts,),dtype=float)
x = np.linspace(-20,20,Npts)
width = 15.0
# now replace those values for the potential in the impenetrable
# region with np.Inf 
ii = ((x>width) | (x<0)).nonzero()
V_x[ii] = np.Inf

This gives you a system with x between -20 and 20, where V_x = v0 for 0 < x < 15 and V_x = Inf for x > 15 or x < 0

Note: As a general suggestion, there are also some more efficient ways to set up numpy arrays rather than using for loops, as is shown in the above code.

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