求函数 I(a,b,c,d) 积分的 4 维最小值 (a,b,c,d)

发布于 2025-01-07 17:16:19 字数 1379 浏览 4 评论 0原文

我有一个令人讨厌的不连续二维积分 I(k,k''; J,Jp,a,b,c,d) ,它有 4 个变分参数 (a,b,c, d) 和 2 个固定常数(J,Jp)。求积分的过程并不简单,并且有第一步。

  1. 我需要从 -pi 中找到一维积分的根 (mu) 到 pi

    A = 积分 [ 1/(exp(E(k; a,b,c,d)-mu)+1 ] dk/2pi = 0.5,

    其中 E 是一个由平方根和余弦组成的复杂函数。

  2. 找到 mu 后,我需要找到 4D(全局)最小值 (a,b,c,d)值到此提供 JJp 的二维积分(与 -pipi 限制相同)。

    结果(J,Jp) = 最小值[ 积分 [ I(J,Jp;k,k''; a,b,c,d,mu) ] dk/2pi dk''/2pi ]< /code>

复杂的函数 I 基本上看起来就像

I(J,Jp;k,k''; a,b,c,d,mu) = A(k)*A(k'')*f(a,b,c,d)*[J cos(k+k'') + Jp cos(k-k'')]

我已经完成了使用假定值 a,b,c,d 查找 mu 的第一步,但是我不确定如何处理它们的任意值。除了嵌套所有 lambda 函数之外还有其他方法吗?即便如此,我该如何嵌套 lambda 函数来完成我的需要呢?

beta=100.0
a=1.2
b=1.5
c=0.1
d=0.5
findmu = lambda mu: integrate.quad(lambda k:1.0/(2.0*pi)*1.0/(exp(beta*(0.5*(c+d-2.0*(1.0+b)*cos(k)-sqrt(32.0*(b*cos(k/2.0))**2.0+(c-d-2.0*(1-b)*cos(k))**2.0))-mu))+1.0)-0.5/(2.0*pi), -pi,pi)
mu0 = optimize.fsolve(findmu,0.0)

我用 Mathematica 编写了程序,但获得最小值需要很长时间,而且有时是错误的。我想尝试将其移植到我目前正在学习的Python。谢谢!

编辑:有关物理系统的更多信息:第一步是通过对系统进行填充来找到量子系统的费米能级。通过费米能级,我们可以找到哪些变分参数可以最小化该 Hartree-Fock 系统的基态能量。

I have a nasty discontinuous 2 dimensional integral I(k,k''; J,Jp,a,b,c,d) that has 4 variational parameters (a,b,c,d) and 2 fixed constants (J,Jp). The procedure to finding the integral isn't straightforward and has a first step.

  1. I need to find the root (mu) to a one-dimensional integral from -pi
    to pi

    A = Integrate [ 1/(exp(E(k; a,b,c,d)-mu)+1 ] dk/2pi = 0.5,

    where E is a complicated function consisting of square roots and cosines.

  2. Having found mu, I need to find the 4D (global) minimum (a,b,c,d) values to this two-dimensional integral (same -pi to pi limits) with J, Jp supplied.

    result(J,Jp) = Minimum[ Integrate [ I(J,Jp;k,k''; a,b,c,d,mu) ] dk/2pi dk''/2pi ]

The complicated function I basically looks like

I(J,Jp;k,k''; a,b,c,d,mu) = A(k)*A(k'')*f(a,b,c,d)*[J cos(k+k'') + Jp cos(k-k'')]

I have done the first step to finding mu with assumed values of a,b,c,d, but am unsure how to go about with arbitrary values of them. Is there another way besides nesting all the lambda functions? Even so, how do I go about nesting lambda functions to accomplish what I need?

beta=100.0
a=1.2
b=1.5
c=0.1
d=0.5
findmu = lambda mu: integrate.quad(lambda k:1.0/(2.0*pi)*1.0/(exp(beta*(0.5*(c+d-2.0*(1.0+b)*cos(k)-sqrt(32.0*(b*cos(k/2.0))**2.0+(c-d-2.0*(1-b)*cos(k))**2.0))-mu))+1.0)-0.5/(2.0*pi), -pi,pi)
mu0 = optimize.fsolve(findmu,0.0)

I have the procedure written in Mathematica, but it's taking too long to obtain the minimum, and are sometimes wrong. I would like to try porting it over to Python, which I am currently learning. Thanks!

EDIT: More information on the physical system: The first step is finding the Fermi level of a quantum system by imposing the filling of the system. With the Fermi level, one can find what variational parameters minimize the ground state energy of this Hartree-Fock system.

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

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

发布评论

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

评论(1

各空 2025-01-14 17:16:19

我根本没有看过你的方程,但我可以为你提供有关如何嵌套 lambda 的信息。您只需将 lambda a, b, c, d: 添加到当前 lambda 的前面,然后 findmu(a, b, c, d) 就会返回一个函数您将传递到 optimize.fsolve() 中,例如:

beta=100.0
findmu = lambda a, b, c, d: lambda mu: integrate.quad(lambda k:1.0/(2.0*pi)*1.0/(exp(beta*(0.5*(c+d-2.0*(1.0+b)*cos(k)-sqrt(32.0*(b*cos(k/2.0))**2.0+(c-d-2.0*(1-b)*cos(k))**2.0))-mu))+1.0)-0.5/(2.0*pi), -pi,pi)
mu0 = optimize.fsolve(findmu(1.2, 1.5, 0.1, 0.5),0.0)
# now just tweak the values for the arguments to findmu in subsequent calls

这将为 ab的值创建一个闭包cd如果您传递给 findmu(),将 findmu 重命名为 make_findmu 或类似名称可能更有意义。

使用实际的函数定义而不是 lambda 可能会使代码更具可读性:

def make_findmu(a, b, c, d):
    beta = 100.0
    return lambda mu: integrate.quad(lambda k:1.0/(2.0*pi)*1.0/(exp(beta*(0.5*(c+d-2.0*(1.0+b)*cos(k)-sqrt(32.0*(b*cos(k/2.0))**2.0+(c-d-2.0*(1-b)*cos(k))**2.0))-mu))+1.0)-0.5/(2.0*pi), -pi,pi)

mu0 = optimize.fsolve(make_findmu(1.2, 1.5, 0.1, 0.5),0.0)

I have not looked at your equation at all, but I can give you the information on how to nest the lambdas. You can simply add lambda a, b, c, d: to the front of your current lambda, then findmu(a, b, c, d) would return a function that you would pass into optimize.fsolve(), for example:

beta=100.0
findmu = lambda a, b, c, d: lambda mu: integrate.quad(lambda k:1.0/(2.0*pi)*1.0/(exp(beta*(0.5*(c+d-2.0*(1.0+b)*cos(k)-sqrt(32.0*(b*cos(k/2.0))**2.0+(c-d-2.0*(1-b)*cos(k))**2.0))-mu))+1.0)-0.5/(2.0*pi), -pi,pi)
mu0 = optimize.fsolve(findmu(1.2, 1.5, 0.1, 0.5),0.0)
# now just tweak the values for the arguments to findmu in subsequent calls

This makes a closure for the values of a, b, c, and d that you pass into findmu(), it might make more sense to rename findmu to make_findmu or something similar.

It might make the code more readable to use an actual function definition rather than lambdas here:

def make_findmu(a, b, c, d):
    beta = 100.0
    return lambda mu: integrate.quad(lambda k:1.0/(2.0*pi)*1.0/(exp(beta*(0.5*(c+d-2.0*(1.0+b)*cos(k)-sqrt(32.0*(b*cos(k/2.0))**2.0+(c-d-2.0*(1-b)*cos(k))**2.0))-mu))+1.0)-0.5/(2.0*pi), -pi,pi)

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