求函数 I(a,b,c,d) 积分的 4 维最小值 (a,b,c,d)
我有一个令人讨厌的不连续二维积分 I(k,k''; J,Jp,a,b,c,d)
,它有 4 个变分参数 (a,b,c, d)
和 2 个固定常数(J,Jp)
。求积分的过程并不简单,并且有第一步。
我需要从
-pi
中找到一维积分的根 (mu
) 到pi
A = 积分 [ 1/(exp(E(k; a,b,c,d)-mu)+1 ] dk/2pi = 0.5
,其中
E
是一个由平方根和余弦组成的复杂函数。找到 mu 后,我需要找到 4D(全局)最小值
(a,b,c,d)值到此提供
J
、Jp
的二维积分(与-pi
到pi
限制相同)。结果(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.
I need to find the root (
mu
) to a one-dimensional integral from-pi
topi
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.Having found mu, I need to find the 4D (global) minimum
(a,b,c,d)
values to this two-dimensional integral (same-pi
topi
limits) withJ
,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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我根本没有看过你的方程,但我可以为你提供有关如何嵌套 lambda 的信息。您只需将 lambda a, b, c, d: 添加到当前 lambda 的前面,然后 findmu(a, b, c, d) 就会返回一个函数您将传递到 optimize.fsolve() 中,例如:
这将为
a
、b
、的值创建一个闭包c
和d
如果您传递给findmu()
,将findmu
重命名为make_findmu
或类似名称可能更有意义。使用实际的函数定义而不是 lambda 可能会使代码更具可读性:
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, thenfindmu(a, b, c, d)
would return a function that you would pass intooptimize.fsolve()
, for example:This makes a closure for the values of
a
,b
,c
, andd
that you pass intofindmu()
, it might make more sense to renamefindmu
tomake_findmu
or something similar.It might make the code more readable to use an actual function definition rather than lambdas here: