Update to v0.4

feature: compute the 2-point correlation function in easyeq.

  feature: compute the Fourier transform of the 2-point correlation function
           in anyeq and easyeq.

  feature: compute the local maximum of the 2-point correlation function and
           its Fourier transform.

  feature: compute the compressibility for anyeq.

  feature: allow for linear spacing of rho's.

  feature: print the scattering length.

  change: ux and uk now return real numbers.

  fix: error in the computation of the momentum distribution: wrong
       definition of delta functions.

  fix: various minor bugs.

  optimization: assign explicit types to variables.
This commit is contained in:
Ian Jauslin 2023-02-26 18:36:05 -05:00
parent e72af82c3e
commit c1b477a1b2
26 changed files with 4310 additions and 841 deletions

25
Changelog Normal file
View File

@ -0,0 +1,25 @@
0.4:
* feature: compute the 2-point correlation function in easyeq.
* feature: compute the Fourier transform of the 2-point correlation function
in anyeq and easyeq.
* feature: compute the local maximum of the 2-point correlation function and
its Fourier transform.
* feature: compute the compressibility for anyeq.
* feature: allow for linear spacing of rho's.
* feature: print the scattering length.
* change: ux and uk now return real numbers.
* fix: error in the computation of the momentum distribution: wrong
definition of delta functions.
* fix: various minor bugs.
* optimization: assign explicit types to variables.

2
NOTICE
View File

@ -1,4 +1,4 @@
simplesolv:
Licensed under the Apache 2.0 License (see LICENSE for details)
Copyright Ian Jauslin 2021
Copyright Ian Jauslin 2021-2023

11
README
View File

@ -29,7 +29,9 @@ published in the following papers:
* E.A. Carlen, I. Jauslin, E.H. Lieb - Analysis of a simple equation for the
ground state energy of the Bose gas II: Monotonicity, Convexity and
Condensate Fraction, to appear in the SIAM Journal on Mathematical Analysis
Condensate Fraction, SIAM Journal on Mathematical Analysis, volume 53,
number 5, pages 5322-5360, 2021
https://doi.org/10.1137/20M13768
https://arxiv.org/abs/2010.13882
http://ian.jauslin.org/publications/20cjl
@ -40,6 +42,13 @@ published in the following papers:
https://arxiv.org/abs/2011.10869
http://ian.jauslin.org/publications/20chjl
* I. Jauslin - The Simplified approach to the Bose gas without translation
invariance, 2023
http://ian.jauslin.org/publications/23j
* I. Jauslin - Evidence of a liquid phase in repulsive Bosonic systems using
the Simplified approach to the Bose gas, 2023
http://ian.jauslin.org/publications/23j_b
Dependencies:

View File

@ -1,4 +1,4 @@
## Copyright 2021 Ian Jauslin
## Copyright 2021-2023 Ian Jauslin
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.

View File

@ -4,10 +4,13 @@ doi:{\tt\color{blue}\href{http://dx.doi.org/10.1103/PhysRevA.103.053309}{10.1103
\bibitem[CJL20]{CJL20}E.A. Carlen, I. Jauslin, E.H. Lieb - {\it Analysis of a simple equation for the ground state energy of the Bose gas}, Pure and Applied Analysis, volume~\-2, issue~\-3, pages~\-659-684, 2020,\par\penalty10000
doi:{\tt\color{blue}\href{http://dx.doi.org/10.2140/paa.2020.2.659}{10.2140/paa.2020.2.659}}, arxiv:{\tt\color{blue}\href{http://arxiv.org/abs/1912.04987}{1912.04987}}.\par\medskip
\bibitem[CJL20b]{CJL20b}E.A. Carlen, I. Jauslin, E.H. Lieb - {\it Analysis of a simple equation for the ground state of the Bose gas II: Monotonicity, Convexity and Condensate Fraction}, 2020, to appear in the SIAM journal of Mathematical Analysis,\par\penalty10000
arxiv:{\tt\color{blue}\href{http://arxiv.org/abs/2010.13882}{2010.13882}}.\par\medskip
\bibitem[CJL21]{CJL21}E.A. Carlen, I. Jauslin, E.H. Lieb - {\it Analysis of a Simple Equation for the Ground State of the Bose Gas II: Monotonicity, Convexity, and Condensate Fraction}, SIAM Journal on Mathematical Analysis, volume~\-53, number~\-5, pages~\-5322-5360, 2021,\par\penalty10000
doi:{\tt\color{blue}\href{http://dx.doi.org/10.1137/20M1376820}{10.1137/20M1376820}}, arxiv:{\tt\color{blue}\href{http://arxiv.org/abs/2010.13882}{2010.13882}}.\par\medskip
\bibitem[DLMF]{DLMF1.1.3}F.W.J. Olver, A.B. Olde Daalhuis, D.W. Lozier, B.I. Schneider, R.F. Boisvert, C.W. Clark, B.R. Miller, B.V. Saunders, H.S. Cohl, M.A. McClain (editors) - {\it NIST Digital Library of Mathematical Functions}, Release~\-1.1.3 of~\-2021-09-15, 2021.\par\medskip
\bibitem[Ja23]{Ja23}I. Jauslin - {\it The Simplified approach to the Bose gas without translation invariance}, 2023\par\penalty10000
{\tt\color{blue}\href{http://ian.jauslin.org/publications/23j/}{http://ian.jauslin.org/publications/23j/}}.\par\medskip
\bibitem[Ta87]{Ta87}Y. Taguchi - {\it Fourier coefficients of periodic functions of Gevrey classes and ultradistributions}, Yokohama Mathematical Journal, volume~\-35, pages~\-51-60, 1987.\par\medskip

View File

@ -1,4 +1,4 @@
%% Copyright 2021 Ian Jauslin
%% Copyright 2021-2023 Ian Jauslin
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.

View File

@ -1,4 +1,4 @@
%% Copyright 2021 Ian Jauslin
%% Copyright 2021-2023 Ian Jauslin
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.

View File

@ -219,6 +219,7 @@
% counters
\stepcounter{subsectioncount}
\setcounter{subsubsectioncount}{0}
\setcounter{subsubsubsectioncount}{0}
\ifsubsectionsineq
\setcounter{seqcount}0
\fi
@ -268,6 +269,7 @@
\def\subsubsection#1{
% counters
\stepcounter{subsubsectioncount}
\setcounter{subsubsubsectioncount}{0}
% space before subsubsection (if not first)
\ifnum\thesubsubsectioncount>1
@ -302,6 +304,49 @@
\medskip\penalty10000
}
%% subsubsubsection
% counter
\newcounter{subsubsubsectioncount}
% space before subsubsubsection
\newlength\subsubsubsecskip
\setlength\subsubsubsecskip{20pt}
\def\subsubsubsection#1{
% counters
\stepcounter{subsubsubsectioncount}
% space before subsubsubsection (if not first)
\ifnum\thesubsubsubsectioncount>1
\vskip\subsubsubsecskip
\penalty-500
\fi
% hyperref anchor
\hrefanchor
% define tag (for \label)
\xdef\tag{\sectionprefix\thesectioncount.\thesubsectioncount.\thesubsubsectioncount.\thesubsubsubsectioncount}
% get widths
\def\@secnum{{\bf\hskip1.5cm\sectionprefix\thesectioncount.\thesubsectioncount.\thesubsubsectioncount.\thesubsubsubsectioncount.\hskip5pt}}
\settowidth\secnumwidth{\@secnum}
\setlength\sectitlewidth\textwidth
\addtolength\sectitlewidth{-\secnumwidth}
% print name
\parbox{\textwidth}{
\@secnum
\parbox[t]{\sectitlewidth}{\bf #1}}
% write to table of contents
\iftoc
% save lncount in aux variable which is written to toc
\immediate\write\tocoutput{\noexpand\expandafter\noexpand\edef\noexpand\csname toc@subsubsubsec.\thesectioncount.\thesubsectioncount.\thesubsubsectioncount.\thesubsubsubsectioncount\endcsname{\thelncount}}
\write\tocoutput{\noexpand\tocsubsubsubsection{#1}{\thepage}}
\fi
% space
\par\penalty10000
\medskip\penalty10000
}
%% itemize
\newlength\itemizeskip
% left margin for items
@ -638,6 +683,7 @@
\stepcounter{tocsectioncount}
\setcounter{tocsubsectioncount}{0}
\setcounter{tocsubsubsectioncount}{0}
\setcounter{tocsubsubsubsectioncount}{0}
% write
\smallskip\hyperlink{ln.\csname toc@sec.\thetocsectioncount\endcsname}{{\bf \tocsectionprefix\thetocsectioncount}.\hskip5pt {\color{blue}#1}\leaderfill#2}\par
}
@ -645,6 +691,7 @@
\def\tocsubsection #1#2{
\stepcounter{tocsubsectioncount}
\setcounter{tocsubsubsectioncount}{0}
\setcounter{tocsubsubsubsectioncount}{0}
% write
{\hskip10pt\hyperlink{ln.\csname toc@subsec.\thetocsectioncount.\thetocsubsectioncount\endcsname}{{\bf \thetocsectioncount.\thetocsubsectioncount}.\hskip5pt {\color{blue}\small #1}\leaderfill#2}}\par
}
@ -654,6 +701,12 @@
% write
{\hskip20pt\hyperlink{ln.\csname toc@subsubsec.\thetocsectioncount.\thetocsubsectioncount.\thetocsubsubsectioncount\endcsname}{{\bf \thetocsectioncount.\thetocsubsectioncount.\thetocsubsubsectioncount}.\hskip5pt {\color{blue}\small #1}\leaderfill#2}}\par
}
\newcounter{tocsubsubsubsectioncount}
\def\tocsubsubsubsection #1#2{
\stepcounter{tocsubsubsubsectioncount}
% write
{\hskip30pt\hyperlink{ln.\csname toc@subsubsubsec.\thetocsectioncount.\thetocsubsectioncount.\thetocsubsubsectioncount.\thetocsubsubsubsectioncount\endcsname}{{\bf \thetocsectioncount.\thetocsubsectioncount.\thetocsubsubsectioncount.\thetocsubsubsubsectioncount}.\hskip5pt {\color{blue}\small #1}\leaderfill#2}}\par
}
\def\tocappendices{
\medskip
\setcounter{tocsectioncount}0

View File

@ -1,4 +1,4 @@
%% Copyright 2021 Ian Jauslin
%% Copyright 2021-2023 Ian Jauslin
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.

View File

@ -1,4 +1,4 @@
%% Copyright 2021 Ian Jauslin
%% Copyright 2021-2023 Ian Jauslin
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.

View File

@ -1,4 +1,4 @@
%% Copyright 2021 Ian Jauslin
%% Copyright 2021-2023 Ian Jauslin
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@ -33,12 +33,15 @@
\newif\ifresetatsubsubsection
\DeclareOption{reset_at_subsubsection}{\resetatsubsubsectiontrue}
\DeclareOption{no_reset_at_subsubsection}{\resetatsubsubsectionfalse}
\newif\ifresetatsubsubsubsection
\DeclareOption{reset_at_subsubsubsection}{\resetatsubsubsubsectiontrue}
\DeclareOption{no_reset_at_subsubsubsection}{\resetatsubsubsubsectionfalse}
\newif\ifresetattheo
\DeclareOption{reset_at_theo}{\resetattheotrue}
\DeclareOption{no_reset_at_theo}{\resetattheofalse}
\def\point@defaultoptions{
\ExecuteOptions{reset_at_section, reset_at_subsection, reset_at_subsubsection, no_reset_at_theo}
\ExecuteOptions{reset_at_section, reset_at_subsection, reset_at_subsubsection, reset_at_subsubsubsection, no_reset_at_theo}
\ProcessOptions
%% reset at every new section
@ -56,6 +59,11 @@
\let\point@oldsubsubsection\subsubsection
\gdef\subsubsection{\resetpointcounter\point@oldsubsubsection}
\fi
%% reset at every new subsubsubsection
\ifresetatsubsubsubsection
\let\point@oldsubsubsubsection\subsubsubsection
\gdef\subsubsubsection{\resetpointcounter\point@oldsubsubsubsection}
\fi
%% reset at every new theorem
\ifresetattheo

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
## Copyright 2021 Ian Jauslin
## Copyright 2021-2023 Ian Jauslin
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
@ -13,7 +13,15 @@
## limitations under the License.
# Chebyshev expansion
@everywhere function chebyshev(a,taus,weights,P,N,J,nu)
@everywhere function chebyshev(
a::Array{Float64,1},
taus::Array{Float64,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
N::Int64,
J::Int64,
nu::Int64
)
out=zeros(Float64,J*(P+1))
for zeta in 0:J-1
for n in 0:P
@ -27,7 +35,15 @@
end
# evaluate function from Chebyshev expansion
@everywhere function chebyshev_eval(Fa,x,taus,chebyshev,P,J,nu)
@everywhere function chebyshev_eval(
Fa::Array{Float64,1},
x::Float64,
taus::Array{Float64,1},
chebyshev::Array{Polynomial,1},
P::Int64,
J::Int64,
nu::Int64
)
# change variable
tau=(1-x)/(1+x)
@ -48,7 +64,11 @@ end
# convolution
# input the Chebyshev expansion of a and b, as well as the A matrix
@everywhere function conv_chebyshev(Fa,Fb,A)
@everywhere function conv_chebyshev(
Fa::Array{Float64,1},
Fb::Array{Float64,1},
A::Array{Array{Float64,2},1}
)
out=zeros(Float64,length(A))
for i in 1:length(A)
out[i]=dot(Fa,A[i]*Fb)
@ -57,12 +77,27 @@ end
end
# <ab>
@everywhere function avg_chebyshev(Fa,Fb,A0)
@everywhere function avg_chebyshev(
Fa::Array{Float64,1},
Fb::Array{Float64,1},
A0::Float64
)
return dot(Fa,A0*Fb)
end
# 1_n * a
@everywhere function conv_one_chebyshev(n,zetapp,Fa,A,taus,weights,P,N,J,nu1)
@everywhere function conv_one_chebyshev(
n::Int64,
zetapp::Int64,
Fa::Array{Float64,1},
A::Array{Array{Float64,2},1},
taus::Array{Float64,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
N::Int64,
J::Int64,
nu1::Int64
)
out=zeros(Float64,N*J)
for m in 1:N*J
for l in 0:P
@ -74,7 +109,15 @@ end
return out
end
# a * v
@everywhere function conv_v_chebyshev(a,Upsilon,k,taus,weights,N,J)
@everywhere function conv_v_chebyshev(
a::Array{Float64,1},
Upsilon::Array{Array{Float64,1},1},
k::Array{Float64,1},
taus::Array{Float64,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
N::Int64,
J::Int64
)
out=zeros(Float64,J*N)
for i in 1:J*N
for zetap in 0:J-1
@ -86,7 +129,16 @@ end
end
return out
end
@everywhere function conv_one_v_chebyshev(n,zetap,Upsilon,k,taus,weights,N,J)
@everywhere function conv_one_v_chebyshev(
n::Int64,
zetap::Int64,
Upsilon::Array{Array{Float64,1},1},
k::Array{Float64,1},
taus::Array{Float64,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
N::Int64,
J::Int64
)
out=zeros(Float64,J*N)
xj=weights[1][n]
for i in 1:J*N
@ -96,7 +148,14 @@ end
end
# <av>
@everywhere function avg_v_chebyshev(a,Upsilon0,k,taus,weights,N,J)
@everywhere function avg_v_chebyshev(a,
Upsilon0::Array{Float64,1},
k::Array{Float64,1},
taus::Array{Float64,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
N::Int64,
J::Int64
)
out=0.
for zetap in 0:J-1
for j in 1:N
@ -107,13 +166,28 @@ end
return out
end
# <1_nv>
@everywhere function avg_one_v_chebyshev(n,zetap,Upsilon0,k,taus,weights,N)
@everywhere function avg_one_v_chebyshev(
n::Int64,
zetap::Int64,
Upsilon0::Array{Float64,1},
k::Array{Float64,1},
taus::Array{Float64,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
N::Int64
)
xj=weights[1][n]
return (taus[zetap+2]-taus[zetap+1])/(32*pi)*weights[2][n]*cos(pi*xj/2)*(1+k[zetap*N+n])^2*k[zetap*N+n]*Upsilon0[zetap*N+n]
end
# compute \int dq dxi u1(k-xi)u2(q)u3(xi)u4(k-q)u5(xi-q)
@everywhere function double_conv_S_chebyshev(FU1,FU2,FU3,FU4,FU5,Abar)
@everywhere function double_conv_S_chebyshev(
FU1::Array{Float64,1},
FU2::Array{Float64,1},
FU3::Array{Float64,1},
FU4::Array{Float64,1},
FU5::Array{Float64,1},
Abar::Array{Float64,5}
)
out=zeros(Float64,length(Abar))
for i in 1:length(Abar)
for j1 in 1:length(FU1)
@ -133,7 +207,17 @@ end
# compute A
@everywhere function Amat(k,weights,taus,T,P,N,J,nua,nub)
@everywhere function Amat(
k::Array{Float64,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
taus::Array{Float64,1},
T::Array{Polynomial,1},
P::Int64,
N::Int64,
J::Int64,
nua::Int64,
nub::Int64
)
out=Array{Array{Float64,2},1}(undef,J*N)
for i in 1:J*N
out[i]=zeros(Float64,J*(P+1),J*(P+1))
@ -152,7 +236,11 @@ end
end
# compute Upsilon
@everywhere function Upsilonmat(k,v,weights)
@everywhere function Upsilonmat(
k::Array{Float64,1},
v::Function,
weights::Tuple{Array{Float64,1},Array{Float64,1}}
)
out=Array{Array{Float64,1},1}(undef,length(k))
for i in 1:length(k)
out[i]=Array{Float64,1}(undef,length(k))
@ -162,7 +250,11 @@ end
end
return out
end
@everywhere function Upsilon0mat(k,v,weights)
@everywhere function Upsilon0mat(
k::Array{Float64,1},
v::Function,
weights::Tuple{Array{Float64,1},Array{Float64,1}}
)
out=Array{Float64,1}(undef,length(k))
for j in 1:length(k)
out[j]=2*k[j]*v(k[j])
@ -171,17 +263,36 @@ end
end
# alpha_-
@everywhere function alpham(k,t)
@everywhere function alpham(
k::Float64,
t::Float64
)
return (1-k-(1-t)/(1+t))/(1+k+(1-t)/(1+t))
end
# alpha_+
@everywhere function alphap(k,t)
@everywhere function alphap(
k::Float64,
t::Float64
)
return (1-abs(k-(1-t)/(1+t)))/(1+abs(k-(1-t)/(1+t)))
end
# compute \bar A
@everywhere function barAmat(k,weights,taus,T,P,N,J,nu1,nu2,nu3,nu4,nu5)
@everywhere function barAmat(
k::Float64,
weights::Tuple{Array{Float64,1},Array{Float64,1}},
taus::Array{Float64,1},
T::Array{Polynomial,1},
P::Int64,
N::Int64,
J::Int64,
nu1::Int64,
nu2::Int64,
nu3::Int64,
nu4::Int64,
nu5::Int64
)
out=zeros(Float64,J*(P+1),J*(P+1),J*(P+1),J*(P+1),J*(P+1))
for zeta1 in 0:J-1
for n1 in 0:P
@ -211,27 +322,107 @@ end
return out
end
@everywhere function barAmat_int1(tau,k,taus,T,weights,nu1,nu2,nu3,nu4,nu5,zeta1,zeta2,zeta3,zeta4,zeta5,n1,n2,n3,n4,n5)
@everywhere function barAmat_int1(tau,
k::Float64,
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
nu1::Int64,
nu2::Int64,
nu3::Int64,
nu4::Int64,
nu5::Int64,
zeta1::Int64,
zeta2::Int64,
zeta3::Int64,
zeta4::Int64,
zeta5::Int64,
n1::Int64,
n2::Int64,
n3::Int64,
n4::Int64,
n5::Int64
)
if(alpham(k,tau)<taus[zeta2+2] && alphap(k,tau)>taus[zeta2+1])
return 2*(1-tau)/(1+tau)^(3-nu1)*T[n1+1]((2*tau-(taus[zeta1+1]+taus[zeta1+2]))/(taus[zeta1+2]-taus[zeta1+1]))*integrate_legendre(sigma->barAmat_int2(tau,sigma,k,taus,T,weights,nu2,nu3,nu4,nu5,zeta2,zeta3,zeta4,zeta5,n2,n3,n4,n5),max(taus[zeta2+1],alpham(k,tau)),min(taus[zeta2+2],alphap(k,tau)),weights)
else
return 0.
end
end
@everywhere function barAmat_int2(tau,sigma,k,taus,T,weights,nu2,nu3,nu4,nu5,zeta2,zeta3,zeta4,zeta5,n2,n3,n4,n5)
@everywhere function barAmat_int2(tau,
sigma::Float64,
k::Float64,
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
nu2::Int64,
nu3::Int64,
nu4::Int64,
nu5::Int64,
zeta2::Int64,
zeta3::Int64,
zeta4::Int64,
zeta5::Int64,
n2::Int64,
n3::Int64,
n4::Int64,
n5::Int64
)
return 2*(1-sigma)/(1+sigma)^(3-nu2)*T[n2+1]((2*sigma-(taus[zeta2+1]+taus[zeta2+2]))/(taus[zeta2+2]-taus[zeta2+1]))*integrate_legendre(taup->barAmat_int3(tau,sigma,taup,k,taus,T,weights,nu3,nu4,nu5,zeta3,zeta4,zeta5,n3,n4,n5),taus[zeta3+1],taus[zeta3+2],weights)
end
@everywhere function barAmat_int3(tau,sigma,taup,k,taus,T,weights,nu3,nu4,nu5,zeta3,zeta4,zeta5,n3,n4,n5)
@everywhere function barAmat_int3(tau,
sigma::Float64,
taup::Float64,
k::Float64,
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
nu3::Int64,
nu4::Int64,
nu5::Int64,
zeta3::Int64,
zeta4::Int64,
zeta5::Int64,
n3::Int64,
n4::Int64,
n5::Int64
)
if(alpham(k,taup)<taus[zeta4+2] && alphap(k,taup)>taus[zeta4+1])
return 2*(1-taup)/(1+taup)^(3-nu3)*T[n3+1]((2*taup-(taus[zeta3+1]+taus[zeta3+2]))/(taus[zeta3+2]-taus[zeta3+1]))*integrate_legendre(sigmap->barAmat_int4(tau,sigma,taup,sigmap,k,taus,T,weights,nu4,nu5,zeta4,zeta5,n4,n5),max(taus[zeta4+1],alpham(k,taup)),min(taus[zeta4+2],alphap(k,taup)),weights)
else
return 0.
end
end
@everywhere function barAmat_int4(tau,sigma,taup,sigmap,k,taus,T,weights,nu4,nu5,zeta4,zeta5,n4,n5)
@everywhere function barAmat_int4(tau,
sigma::Float64,
taup::Float64,
sigmap::Float64,
k::Float64,
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
nu4::Int64,
nu5::Int64,
zeta4::Int64,
zeta5::Int64,
n4::Int64,
n5::Int64
)
return 2*(1-sigmap)/(1+sigmap)^(3-nu4)*T[n4+1]((2*sigma-(taus[zeta4+1]+taus[zeta4+2]))/(taus[zeta4+2]-taus[zeta4+1]))*integrate_legendre(theta->barAmat_int5(tau,sigma,taup,sigmap,theta,k,taus,T,weights,nu5,zeta5,n5),0.,2*pi,weights)
end
@everywhere function barAmat_int5(tau,sigma,taup,sigmap,theta,k,taus,T,weights,nu5,zeta5,n5)
@everywhere function barAmat_int5(tau,
sigma::Float64,
taup::Float64,
sigmap::Float64,
theta::Float64,
k::Float64,
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
nu5::Int64,
zeta5::Int64,
n5::Int64
)
R=barAmat_R((1-sigma)/(1+sigma),(1-tau)/(1+tau),(1-sigmap)/(1+sigmap),(1-taup)/(1+taup),theta,k)
if((1-R)/(1+R)<taus[zeta5+2] && (1-R)/(1+R)>taus[zeta5+1])
return (2/(2+R))^nu5*T[n5+1]((2*(1-R)/(1+R)-(taus[zeta5+1]+taus[zeta5+2]))/(taus[zeta5+2]-taus[zeta5+1]))
@ -240,13 +431,22 @@ end
end
end
# R(s,t,s',t,theta,k)
@everywhere function barAmat_R(s,t,sp,tp,theta,k)
return sqrt(k^2*(s^2+t^2+sp^2+tp^2)-k^4-(s^2-t^2)*(sp^2-tp^2)-sqrt((4*k^2*s^2-(k^2+s^2-t^2)^2)*(4*k^2*sp^2-(k^2+sp^2-tp^2)^2))*cos(theta))/(sqrt(2)*k)
@everywhere function barAmat_R(
s::Float64,
t::Float64,
sp::Float64,
tp::Float64,
theta::Float64,
k::Float64
)
return sqrt(k^2*(s^2+t^2+sp^2+tp^2)-k^4-(s^2-t^2)*(sp^2-tp^2)-sqrt((4*k^2*s^2-(k^2+s^2-t^2)^2)*(4*k^2*sp^2-(k^2+sp^2-tp^2)^2))*cos(theta))/(sqrt(2.)*k)
end
# compute Chebyshev polynomials
@everywhere function chebyshev_polynomials(P)
T=Array{Polynomial}(undef,P+1)
@everywhere function chebyshev_polynomials(
P::Int64
)
T=Array{Polynomial,1}(undef,P+1)
T[1]=Polynomial([1])
T[2]=Polynomial([0,1])
for n in 1:P-1
@ -258,7 +458,15 @@ end
end
# compute \int f*u dk/(2*pi)^3
@everywhere function integrate_f_chebyshev(f,u,k,taus,weights,N,J)
@everywhere function integrate_f_chebyshev(
f::Function,
u::Array{Float64,1},
k::Array{Float64,1},
taus::Array{Float64,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
N::Int64,
J::Int64
)
out=0.
for zeta in 0:J-1
for i in 1:N
@ -268,7 +476,15 @@ end
return out
end
@everywhere function inverse_fourier_chebyshev(u,x,k,taus,weights,N,J)
@everywhere function inverse_fourier_chebyshev(
u::Array{Float64,1},
x::Float64,
k::Array{Float64,1},
taus::Array{Float64,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
N::Int64,
J::Int64
)
out=0.
for zeta in 0:J-1
for j in 1:N
@ -277,3 +493,54 @@ end
end
return out
end
# compute B (for the computation of the fourier transform of the two-point correlation)
@everywhere function Bmat(
q::Float64,
k::Array{Float64,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
taus::Array{Float64,1},
T::Array{Polynomial,1},
P::Int64,
N::Int64,
J::Int64,
nu::Int64
)
out=Array{Array{Float64,1},1}(undef,J*N)
for i in 1:J*N
out[i]=zeros(Float64,J*(P+1))
for zeta in 0:J-1
for n in 0:P
out[i][zeta*(P+1)+n+1]=1/(8*pi^3*k[i]*q)*(betam(k[i],q)>taus[zeta+2] || betap(k[i],q)<taus[zeta+1] ? 0. : integrate_legendre(sigma->(1-sigma)/(1+sigma)^(3-nu)*T[n+1]((2*sigma-(taus[zeta+1]+taus[zeta+2]))/(taus[zeta+2]-taus[zeta+1])),max(taus[zeta+1],betam(k[i],q)),min(taus[zeta+2],betap(k[i],q)),weights))
end
end
end
return out
end
# beta_-
@everywhere function betam(
k::Float64,
q::Float64
)
return (1-k-q)/(1+k+q)
end
# beta_+
@everywhere function betap(
k::Float64,
q::Float64
)
return (1-abs(k-q))/(1+abs(k-q))
end
# mathfrak S (for the computation of the fourier transform of the two-point correlation)
@everywhere function chebyshev_frakS(
Ff::Array{Float64,1},
B::Array{Array{Float64,1},1}
)
out=zeros(Float64,length(B))
for i in 1:length(B)
out[i]=dot(Ff,B[i])
end
return out
end

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
## Copyright 2021 Ian Jauslin
## Copyright 2021-2023 Ian Jauslin
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
@ -13,7 +13,12 @@
## limitations under the License.
# approximate \int_a^b f using Gauss-Legendre quadratures
@everywhere function integrate_legendre(f,a,b,weights)
@everywhere function integrate_legendre(
f::Function,
a::Float64,
b::Float64,
weights::Tuple{Array{Float64,1},Array{Float64,1}}
)
out=0
for i in 1:length(weights[1])
out+=(b-a)/2*weights[2][i]*f((b-a)/2*weights[1][i]+(b+a)/2)
@ -21,7 +26,13 @@
return out
end
# \int f*g where g is sampled at the Legendre nodes
@everywhere function integrate_legendre_sampled(f,g,a,b,weights)
@everywhere function integrate_legendre_sampled(
f::Function,
g::Array{Float64,1},
a::Float64,
b::Float64,
weights::Tuple{Array{Float64,1},Array{Float64,1}}
)
out=0
for i in 1:length(weights[1])
out+=(b-a)/2*weights[2][i]*f((b-a)/2*weights[1][i]+(b+a)/2)*g[i]
@ -31,7 +42,12 @@ end
# approximate \int_a^b f/sqrt((b-x)(x-a)) using Gauss-Chebyshev quadratures
@everywhere function integrate_chebyshev(f,a,b,N)
@everywhere function integrate_chebyshev(
f::Function,
a::Float64,
b::Float64,
N::Int64
)
out=0
for i in 1:N
out=out+pi/N*f((b-a)/2*cos((2*i-1)/(2*N)*pi)+(b+a)/2)
@ -40,7 +56,11 @@ end
end
# approximate \int_0^\infty dr f(r)*exp(-a*r) using Gauss-Chebyshev quadratures
@everywhere function integrate_laguerre(f,a,weights_gL)
@everywhere function integrate_laguerre(
f::Function,
a::Float64,
weights_gL::Tuple{Array{Float64,1},Array{Float64,1}}
)
out=0.
for i in 1:length(weights_gL[1])
out+=1/a*f(weights_gL[1][i]/a)*weights_gL[2][i]
@ -49,10 +69,28 @@ end
end
# Hann window
@everywhere function hann(x,L)
@everywhere function hann(
x::Float64,
L::Float64
)
if abs(x)<L/2
return cos(pi*x/L)^2
else
return 0.
end
end
# Fourier transform (in 3d)
@everywhere function hann_fourier(
k::Float64,
L::Float64
)
return L^2*4*pi^3/k*(((k*L)^3-4*k*L*pi^2)*cos(k*L/2)-2*(3*(k*L)^2-4*pi^2)*sin(k*L/2))/((k*L)^3-4*k*L*pi^2)^2
end
# normalized Gaussian (in 3d)
@everywhere function gaussian(
k::Float64,
L::Float64
)
return exp(-k^2/(2*L))/sqrt(8*pi^3*L^3)
end

View File

@ -1,4 +1,4 @@
## Copyright 2021 Ian Jauslin
## Copyright 2021-2023 Ian Jauslin
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
@ -14,7 +14,11 @@
# linear interpolation: given vectors x,y, compute a linear interpolation for y(x0)
# assume x is ordered
@everywhere function linear_interpolation(x0,x,y)
@everywhere function linear_interpolation(
x0::Float64,
x::Array{Float64,1},
y::Array{Float64,1}
)
# if x0 is beyond all x's, then return the corresponding boundary value.
if x0>x[length(x)]
return y[length(y)]
@ -28,7 +32,12 @@
# interpolate
return y[i]+(y[i+1]-y[i])*(x0-x[i])/(x[i+1]-x[i])
end
@everywhere function bracket(x0,x,a,b)
@everywhere function bracket(
x0::Float64,
x::Array{Float64,1},
a::Int64,
b::Int64
)
i=floor(Int64,(a+b)/2)
if x0<x[i]
return bracket(x0,x,a,i)
@ -41,15 +50,18 @@ end
# polynomial interpolation of a family of points
@everywhere function poly_interpolation(x,y)
@everywhere function poly_interpolation(
x::Array{Float64,1},
y::Array{Float64,1}
)
# init for recursion
rec=Array{Polynomial{Float64}}(undef,length(x))
rec=Array{Polynomial{Float64},1}(undef,length(x))
for i in 1:length(x)
rec[i]=Polynomial([1.])
end
# compute \prod (x-x_i)
poly_interpolation_rec(rec,x,1,length(x))
poly_interpolation_rec(rec,x,1.,length(x))
# sum terms together
out=0.
@ -60,7 +72,12 @@ end
return out
end
# recursive helper function
@everywhere function poly_interpolation_rec(out,x,a,b)
@everywhere function poly_interpolation_rec(
out::Array{Float64,1},
x::Array{Float64,1},
a::Float64,
b::Float64
)
if a==b
return
end
@ -91,7 +108,10 @@ end
return
end
## the following does the same, but has complexity N^2, the function above has N*log(N)
#@everywhere function poly_interpolation(x,y)
#@everywhere function poly_interpolation(
# x::Array{Float64,1},
# y::Array{Float64,1}
#)
# out=Polynomial([0.])
# for i in 1:length(x)
# prod=Polynomial([1.])

View File

@ -1,4 +1,4 @@
## Copyright 2021 Ian Jauslin
## Copyright 2021-2023 Ian Jauslin
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
@ -22,6 +22,8 @@ include("chebyshev.jl")
include("integration.jl")
include("interpolation.jl")
include("tools.jl")
include("multithread.jl")
include("optimization.jl")
include("potentials.jl")
include("print.jl")
include("easyeq.jl")
@ -36,9 +38,6 @@ function main()
rho=1e-6
e=1e-4
# incrementally initialize Newton algorithm
nlrho_init=1
# potential
v=k->v_exp(k,1.)
a0=a0_exp(1.)
@ -49,19 +48,29 @@ function main()
v_param_e=1.
# plot range when plotting in rho
minlrho=-6
maxlrho=2
# linear
minrho=1e-6
maxrho=1e2
nrho=0
# logarithmic
minlrho=-6.
maxlrho=2.
nlrho=100
rhos=Array{Float64}(undef,0)
# list
rhos=Array{Float64,1}(undef,0)
# plot range when plotting in e
minle=-6
maxle=2
minle=-6.
maxle=2.
nle=100
es=Array{Float64}(undef,0)
es=Array{Float64,1}(undef,0)
# plot range when plotting in x
xmin=0
xmax=100
xmin=0.
xmax=100.
nx=100
# plot range when plotting in k
kmin=0.
kmax=10.
nk=100
# cutoffs
tolerance=1e-11
@ -77,8 +86,8 @@ function main()
J=10
# starting rho from which to incrementally initialize Newton algorithm
# default must be set after reading rho, if not set explicitly
minlrho_init=nothing
minlrho_init=-6.
nlrho_init=0
# Hann window for Fourier transforms
windowL=1e3
@ -98,6 +107,18 @@ function main()
anyeq_compleq_approx=Anyeq_approx(1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.)
anyeq_approx=anyeq_bigeq_approx
# numerical approximations of derivatives
dx=1e-7
dk=1e-7
# initial guess for 2pt_max
x0=1.
k0=1.
# maximum step in 2pt_max
maxstep=Inf
# tolerance for max search
tolerance_max=Inf
# read cli arguments
(params,potential,method,savefile,command)=read_args(ARGS)
@ -109,8 +130,8 @@ function main()
print(stderr,"error: could not read parameter '",param,"'.\n")
exit(-1)
end
lhs=terms[1]
rhs=terms[2]
lhs=string(terms[1])
rhs=string(terms[2])
if lhs=="rho"
rho=parse(Float64,rhs)
elseif lhs=="minlrho_init"
@ -133,6 +154,12 @@ function main()
maxlrho=parse(Float64,rhs)
elseif lhs=="nlrho"
nlrho=parse(Int64,rhs)
elseif lhs=="minrho"
minrho=parse(Float64,rhs)
elseif lhs=="maxrho"
maxrho=parse(Float64,rhs)
elseif lhs=="nrho"
nrho=parse(Int64,rhs)
elseif lhs=="es"
es=parse_list(rhs)
elseif lhs=="minle"
@ -147,6 +174,12 @@ function main()
xmax=parse(Float64,rhs)
elseif lhs=="nx"
nx=parse(Int64,rhs)
elseif lhs=="kmin"
kmin=parse(Float64,rhs)
elseif lhs=="kmax"
kmax=parse(Float64,rhs)
elseif lhs=="nk"
nk=parse(Int64,rhs)
elseif lhs=="P"
P=parse(Int64,rhs)
elseif lhs=="N"
@ -155,6 +188,18 @@ function main()
J=parse(Int64,rhs)
elseif lhs=="window_L"
windowL=parse(Float64,rhs)
elseif lhs=="dx"
dx=parse(Float64,rhs)
elseif lhs=="x0"
x0=parse(Float64,rhs)
elseif lhs=="dk"
dk=parse(Float64,rhs)
elseif lhs=="k0"
k0=parse(Float64,rhs)
elseif lhs=="maxstep"
maxstep=parse(Float64,rhs)
elseif lhs=="tolerance_max"
tolerance_max=parse(Float64,rhs)
elseif lhs=="aK"
anyeq_approx.aK=parse(Float64,rhs)
elseif lhs=="bK"
@ -242,37 +287,48 @@ function main()
## set parameters
# rhos
if length(rhos)==0
rhos=Array{Float64}(undef,nlrho)
for j in 0:nlrho-1
rhos[j+1]=(nlrho==1 ? 10^minlrho : 10^(minlrho+(maxlrho-minlrho)/(nlrho-1)*j))
# linear only if nrho is specified
if nrho>0
rhos=Array{Float64,1}(undef,nrho)
for j in 0:nrho-1
rhos[j+1]=(nrho==1 ? minrho : minrho+(maxrho-minrho)/(nrho-1)*j)
end
else
rhos=Array{Float64,1}(undef,nlrho)
for j in 0:nlrho-1
rhos[j+1]=(nlrho==1 ? 10^minlrho : 10^(minlrho+(maxlrho-minlrho)/(nlrho-1)*j))
end
end
end
# es
if length(es)==0
es=Array{Float64}(undef,nle)
es=Array{Float64,1}(undef,nle)
for j in 0:nle-1
es[j+1]=(nle==1 ? 10^minle : 10^(minle+(maxle-minle)/(nle-1)*j))
end
end
# default minlrho_init
if (minlrho_init==nothing)
minlrho_init=log10(rho)
end
# splines
taus=Array{Float64}(undef,J+1)
taus=Array{Float64,1}(undef,J+1)
for j in 0:J
taus[j+1]=-1+2*j/J
end
# tolerance_max
if tolerance_max==Inf
tolerance_max=tolerance
end
## run command
if method=="easyeq"
if command=="scattering_length"
@printf("% .15e\n",a0)
elseif method=="easyeq"
if command=="energy"
easyeq_energy(minlrho_init,nlrho_init,order,rho,a0,v,maxiter,tolerance,easyeq_approx)
# e(rho)
elseif command=="energy_rho"
easyeq_energy_rho(rhos,order,a0,v,maxiter,tolerance,easyeq_approx)
easyeq_energy_rho(rhos,minlrho_init,nlrho_init,order,a0,v,maxiter,tolerance,easyeq_approx)
# u(k)
elseif command=="uk"
easyeq_uk(minlrho_init,nlrho_init,order,rho,a0,v,maxiter,tolerance,easyeq_approx)
@ -285,7 +341,28 @@ function main()
elseif command=="condensate_fraction"
easyeq_condensate_fraction(minlrho_init,nlrho_init,order,rho,a0,v,maxiter,tolerance,easyeq_approx)
elseif command=="condensate_fraction_rho"
easyeq_condensate_fraction_rho(rhos,order,a0,v,maxiter,tolerance,easyeq_approx)
easyeq_condensate_fraction_rho(rhos,minlrho_init,nlrho_init,order,a0,v,maxiter,tolerance,easyeq_approx)
# 2pt correlation
elseif command=="2pt"
easyeq_2pt(xmin,xmax,nx,minlrho_init,nlrho_init,order,windowL,rho,a0,v,maxiter,tolerance,easyeq_approx)
# max of 2pt correlation
elseif command=="2pt_max"
easyeq_2pt_max(dx,x0,minlrho_init,nlrho_init,order,windowL,rho,a0,v,maxstep,maxiter,tolerance,tolerance_max,easyeq_approx)
# max of 2pt correlation as a function of rho
elseif command=="2pt_max_rho"
easyeq_2pt_max_rho(rhos,dx,x0,minlrho_init,nlrho_init,order,windowL,a0,v,maxstep,maxiter,tolerance,tolerance_max,easyeq_approx)
# fourier transform of 2pt correlation
elseif command=="2pt_fourier"
easyeq_2pt_fourier(kmin,kmax,nk,minlrho_init,nlrho_init,order,windowL,rho,a0,v,maxiter,tolerance,easyeq_approx)
# max of fourier transform of 2pt correlation
elseif command=="2pt_fourier_max"
easyeq_2pt_fourier_max(dk,k0,minlrho_init,nlrho_init,order,windowL,rho,a0,v,maxstep,maxiter,tolerance,tolerance_max,easyeq_approx)
# max of 2pt correlation as a function of rho
elseif command=="2pt_fourier_max_rho"
easyeq_2pt_fourier_max_rho(rhos,dk,k0,minlrho_init,nlrho_init,order,windowL,a0,v,maxstep,maxiter,tolerance,tolerance_max,easyeq_approx)
# momentum distribution
elseif command=="momentum_distribution"
easyeq_momentum_distribution(kmin,kmax,minlrho_init,nlrho_init,order,windowL,rho,a0,v,maxiter,tolerance,easyeq_approx)
else
print(stderr,"unrecognized command '",command,"'.\n")
exit(-1)
@ -316,7 +393,7 @@ function main()
anyeq_energy(rho,minlrho_init,nlrho_init,taus,P,N,J,a0,v,maxiter,tolerance,anyeq_approx,savefile)
# e(rho)
elseif command=="energy_rho"
anyeq_energy_rho(rhos,taus,P,N,J,a0,v,maxiter,tolerance,anyeq_approx,savefile)
anyeq_energy_rho(rhos,minlrho_init,nlrho_init,taus,P,N,J,a0,v,maxiter,tolerance,anyeq_approx,savefile)
elseif command=="energy_rho_init_prevrho"
anyeq_energy_rho_init_prevrho(rhos,taus,P,N,J,a0,v,maxiter,tolerance,anyeq_approx,savefile)
elseif command=="energy_rho_init_nextrho"
@ -331,12 +408,29 @@ function main()
elseif command=="condensate_fraction"
anyeq_condensate_fraction(rho,minlrho_init,nlrho_init,taus,P,N,J,a0,v,maxiter,tolerance,anyeq_approx,savefile)
elseif command=="condensate_fraction_rho"
anyeq_condensate_fraction_rho(rhos,taus,P,N,J,a0,v,maxiter,tolerance,anyeq_approx,savefile)
anyeq_condensate_fraction_rho(rhos,minlrho_init,nlrho_init,taus,P,N,J,a0,v,maxiter,tolerance,anyeq_approx,savefile)
# momentum distribution
elseif command=="momentum_distribution"
anyeq_momentum_distribution(rho,minlrho_init,nlrho_init,taus,P,N,J,a0,v,maxiter,tolerance,anyeq_approx,savefile)
anyeq_momentum_distribution(kmin,kmax,rho,minlrho_init,nlrho_init,taus,P,N,J,windowL,a0,v,maxiter,tolerance,anyeq_approx,savefile)
elseif command=="2pt"
anyeq_2pt_correlation(minlrho_init,nlrho_init,taus,P,N,J,windowL,rho,a0,v,maxiter,tolerance,xmin,xmax,nx,anyeq_approx,savefile)
elseif command=="2pt_max"
anyeq_2pt_correlation_max(rho,minlrho_init,nlrho_init,dx,x0,maxstep,taus,P,N,J,windowL,a0,v,maxiter,tolerance,tolerance_max,anyeq_approx,savefile)
elseif command=="2pt_max_rho"
anyeq_2pt_correlation_max_rho(rhos,minlrho_init,nlrho_init,dx,x0,maxstep,taus,P,N,J,windowL,a0,v,maxiter,tolerance,tolerance_max,anyeq_approx,savefile)
elseif command=="2pt_fourier"
anyeq_2pt_correlation_fourier(minlrho_init,nlrho_init,taus,P,N,J,windowL,rho,a0,v,maxiter,tolerance,kmin,kmax,nk,anyeq_approx,savefile)
elseif command=="2pt_fourier_test"
anyeq_2pt_correlation_fourier_test(minlrho_init,nlrho_init,taus,P,N,J,windowL,rho,a0,v,maxiter,tolerance,xmax,kmin,kmax,nk,anyeq_approx,savefile)
elseif command=="2pt_fourier_max"
anyeq_2pt_correlation_fourier_max(rho,minlrho_init,nlrho_init,dk,k0,maxstep,taus,P,N,J,windowL,a0,v,maxiter,tolerance,tolerance_max,anyeq_approx,savefile)
elseif command=="2pt_fourier_max_rho"
anyeq_2pt_correlation_fourier_max_rho(rhos,minlrho_init,nlrho_init,dk,k0,maxstep,taus,P,N,J,windowL,a0,v,maxiter,tolerance,tolerance_max,anyeq_approx,savefile)
elseif command=="uncondensed_2pt"
anyeq_uncondensed_2pt_correlation(minlrho_init,nlrho_init,taus,P,N,J,windowL,rho,a0,v,maxiter,tolerance,xmin,xmax,nx,anyeq_approx,savefile)
# compressibility
elseif command=="compressibility_rho"
anyeq_compressibility_rho(rhos,minlrho_init,nlrho_init,taus,P,N,J,a0,v,maxiter,tolerance,anyeq_approx,savefile)
else
print(stderr,"unrecognized command: '",command,"'\n")
exit(-1)
@ -360,9 +454,11 @@ function main()
end
# parse a comma separated list as an array of Float64
function parse_list(str)
function parse_list(
str::String
)
elems=split(str,",")
out=Array{Float64}(undef,length(elems))
out=Array{Float64,1}(undef,length(elems))
for i in 1:length(elems)
out[i]=parse(Float64,elems[i])
end
@ -370,7 +466,9 @@ function parse_list(str)
end
# read cli arguments
function read_args(ARGS)
function read_args(
ARGS
)
# flag
flag=""

16
src/multithread.jl Normal file
View File

@ -0,0 +1,16 @@
# split up 1...n among workers
function spawn_workers(n::Int64)
# number of workers
nw=nworkers()
# split jobs among workers
work=Array{Array{Int64,1},1}(undef,nw)
# init empty arrays
for p in 1:nw
work[p]=Int64[]
end
for i in 1:n
append!(work[(i-1)%nw+1],[i])
end
return work
end

94
src/optimization.jl Normal file
View File

@ -0,0 +1,94 @@
# gradient descent: find local minimum of function of one variable from initial guess
# numerically estimate the derivative
@everywhere function gradient_descent(
f::Function,
x0::Float64,
delta::Float64, # shift is delta*df
dx::Float64, # finite difference for numerical derivative evaluation
maxiter::Int64 # interrupt and fail after maxiter steps
)
counter=0
# init
x=x0
while counter<maxiter
# value at x and around
val=f(x)
valm=f(x-dx)
valp=f(x+dx)
# quit if minimum
if(val<valm && val<valp)
return(x,val)
end
# derivative
df=(valp-val)/dx
# step
x=x-delta*df
counter+=1
end
# fail
return(Inf,Inf)
end
# Newton algorithm to compute extrema
# numerically estimate the derivatives
@everywhere function newton_maximum(
f::Function,
x0::Float64,
dx::Float64, # finite difference for numerical derivative evaluation
maxiter::Int64,
tolerance::Float64,
maxstep::Float64 # maximal size of step
)
counter=0
# init
x=x0
while counter<maxiter
# value at x and around
val=f(x)
valm=f(x-dx)
valp=f(x+dx)
# derivative
dfp=(valp-val)/dx
dfm=(val-valm)/dx
# second derivative
ddf=(dfp-dfm)/dx
#@printf(stderr,"% .15e % .15e % .15e % .15e\n",x,val,dfp,ddf)
if abs(dfp/ddf)<tolerance
# check it is a local maximum
if ddf<0
return(x,val)
else
return(Inf,Inf)
end
end
# step
step=dfp/abs(ddf)
# step too large
if abs(step)>maxstep
step=maxstep*sign(step)
end
x=x+step
# fail if off to infinity
if x==Inf || x==-Inf
return(x,val)
end
counter+=1
end
# fail
return(Inf,Inf)
end

View File

@ -1,4 +1,4 @@
## Copyright 2021 Ian Jauslin
## Copyright 2021-2023 Ian Jauslin
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
@ -13,10 +13,15 @@
## limitations under the License.
# exponential potential in 3 dimensions
@everywhere function v_exp(k,a)
@everywhere function v_exp(
k::Float64,
a::Float64
)
return 8*pi/(1+k^2)^2*a
end
@everywhere function a0_exp(a)
@everywhere function a0_exp(
a::Float64
)
if a>0.
return log(a)+2*MathConstants.eulergamma+2*besselk(0,2*sqrt(a))/besseli(0,2*sqrt(a))
elseif a<0.
@ -27,15 +32,24 @@ end
end
# exp(-x)-a*exp(-b*x) in 3 dimensions
@everywhere function v_expcry(k,a,b)
@everywhere function v_expcry(
k::Float64,
a::Float64,
b::Float64
)
return 8*pi*((1+k^2)^(-2)-a*b*(b^2+k^2)^(-2))
end
@everywhere function a0_expcry(a,b)
@everywhere function a0_expcry(
a::Float64,
b::Float64
)
return 1.21751642717932720441274114683413710125487579284827462 #ish
end
# x^2*exp(-|x|) in 3 dimensions
@everywhere function v_npt(k)
@everywhere function v_npt(
k::Float64
)
return 96*pi*(1-k^2)/(1+k^2)^4
end
@everywhere function a0_npt()
@ -43,7 +57,9 @@ end
end
# 1/(1+x^4/4) potential in 3 dimensions
@everywhere function v_alg(k)
@everywhere function v_alg(
k::Float64
)
if(k==0)
return 4*pi^2
else
@ -53,32 +69,50 @@ end
a0_alg=1. #ish
# (1+a x^4)/(1+x^2)^4 potential in 3 dimensions
@everywhere function v_algwell(k)
@everywhere function v_algwell(
k::Float64
)
a=4
return pi^2/24*exp(-k)*(a*(k^2-9*k+15)+k^2+3*k+3)
end
a0_algwell=1. #ish
# potential corresponding to the exact solution c/(1+b^2x^2)^2
@everywhere function v_exact(k,b,c,e)
@everywhere function v_exact(
k::Float64,
b::Float64,
c::Float64,
e::Float64
)
if k!=0
return 48*pi^2*((18+3*sqrt(c)-(4-3*e/b^2)*c-(1-2*e/b^2)*c^1.5)/(4*(3+sqrt(c))^2*sqrt(c))*exp(-sqrt(1-sqrt(c))*k/b)+(-18+3*sqrt(c)+(4-3*e/b^2)*c-(1-2*e/b^2)*c^1.5)/(4*(3-sqrt(c))^2*sqrt(c))*exp(-sqrt(1+sqrt(c))*k/b)+(1-k/b)/2*exp(-k/b)-c*e/b^2*(3*(9-c)*k/b+8*c)/(8*(9-c)^2)*exp(-2*k/b))/k
else
return 48*pi^2*(-sqrt(1-sqrt(c))/b*(18+3*sqrt(c)-(4-3*e/b^2)*c-(1-2*e/b^2)*c^1.5)/(4*(3+sqrt(c))^2*sqrt(c))-sqrt(1+sqrt(c))/b*(-18+3*sqrt(c)+(4-3*e/b^2)*c-(1-2*e/b^2)*c^1.5)/(4*(3-sqrt(c))^2*sqrt(c))-1/b-c*e/b^2*(27-19*c)/(8*(9-c)^2))
end
end
@everywhere function a0_exact(b,c,e)
@everywhere function a0_exact(
b::Float64,
c::Float64,
e::Float64
)
return 1. #ish
end
# tent potential (convolution of soft sphere with itself): a*pi/12*(2*|x|/b-2)^2*(2*|x|/b+4) for |x|<b
@everywhere function v_tent(k,a,b)
@everywhere function v_tent(
k::Float64,
a::Float64,
b::Float64
)
if k!=0
return (b/2)^3*a*(4*pi*(sin(k*b/2)-k*b/2*cos(k*b/2))/(k*b/2)^3)^2
else
return (b/2)^3*a*(4*pi/3)^2
end
end
@everywhere function a0_tent(a,b)
@everywhere function a0_tent(
a::Float64,
b::Float64
)
return b #ish
end

View File

@ -1,4 +1,4 @@
## Copyright 2021 Ian Jauslin
## Copyright 2021-2023 Ian Jauslin
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.

View File

@ -1,4 +1,4 @@
## Copyright 2021 Ian Jauslin
## Copyright 2021-2023 Ian Jauslin
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
@ -13,12 +13,27 @@
## limitations under the License.
# Compute Kv=(-\Delta+v+4e(1-\rho u*))^{-1}v
function anyeq_Kv(minlrho,nlrho,taus,P,N,J,rho,a0,v,maxiter,tolerance,xmin,xmax,nx)
function anyeq_Kv(
minlrho::Float64,
nlrho::Int64,
taus::Array{Float64,1},
P::Int64,
N::Int64,
J::Int64,
rho::Float64,
a0::Float64,
v::Function,
maxiter::Int64,
tolerance::Float64,
xmin::Float64,
xmax::Float64,
nx::Int64
)
# init vectors
(weights,T,k,V,V0,A,Upsilon,Upsilon0)=anyeq_init(taus,P,N,J,v)
# compute initial guess from medeq
rhos=Array{Float64}(undef,nlrho)
rhos=Array{Float64,1}(undef,nlrho)
for j in 0:nlrho-1
rhos[j+1]=(nlrho==1 ? rho : 10^(minlrho+(log10(rho)-minlrho)/(nlrho-1)*j))
end
@ -44,7 +59,17 @@ function anyeq_Kv(minlrho,nlrho,taus,P,N,J,rho,a0,v,maxiter,tolerance,xmin,xmax,
end
# Compute the condensate fraction for simpleq using Kv
function simpleq_Kv_condensate_fraction(rhos,taus,P,N,J,a0,v,maxiter,tolerance)
function simpleq_Kv_condensate_fraction(
rhos::Array{Float64,1},
taus::Array{Float64,1},
P::Int64,
N::Int64,
J::Int64,
a0::Float64,
v::Function,
maxiter::Int64,
tolerance::Float64
)
# init vectors
(weights,T,k,V,V0,A,Upsilon,Upsilon0)=anyeq_init(taus,P,N,J,v)
@ -67,19 +92,35 @@ function simpleq_Kv_condensate_fraction(rhos,taus,P,N,J,a0,v,maxiter,tolerance)
end
# Compute the two-point correlation function for simpleq using Kv
function simpleq_Kv_2pt(minlrho,nlrho,taus,P,N,J,rho,a0,v,maxiter,tolerance,xmin,xmax,nx)
function simpleq_Kv_2pt(
minlrho::Float64,
nlrho::Int64,
taus::Array{Float64,1},
P::Int64,
N::Int64,
J::Int64,
rho::Float64,
a0::Float64,
v::Function,
maxiter::Int64,
tolerance::Float64,
xmin::Float64,
xmax::Float64,
nx::Int64
)
# init vectors
(weights,T,k,V,V0,A,Upsilon,Upsilon0)=anyeq_init(taus,P,N,J,v)
# compute initial guess from medeq
rhos=Array{Float64}(undef,nlrho)
rhos=Array{Float64,1}(undef,nlrho)
for j in 0:nlrho-1
rhos[j+1]=(nlrho==1 ? rho : 10^(minlrho+(log10(rho)-minlrho)/(nlrho-1)*j))
end
u0s=anyeq_init_medeq(rhos,N,J,k,a0,v,maxiter,tolerance)
u0=u0s[nlrho]
(u,E,error)=anyeq_hatu(u0,P,N,J,rho,a0,weights,k,taus,V,V0,A,nothing,Upsilon,Upsilon0,v,maxiter,tolerance,Anyeq_approx(0.,0.,1.,0.,0.,0.,0.,0.,0.,0.,0.))
Abar=Array{Float64,5}(undef,0,0,0,0,0)
(u,E,error)=anyeq_hatu(u0,P,N,J,rho,a0,weights,k,taus,V,V0,A,Abar,Upsilon,Upsilon0,v,maxiter,tolerance,Anyeq_approx(0.,0.,1.,0.,0.,0.,0.,0.,0.,0.,0.))
# Kv in Fourier space
Kvk=simpleq_Kv_Kvk(u,V,E,rho,Upsilon,k,taus,weights,N,J)
@ -103,7 +144,18 @@ function simpleq_Kv_2pt(minlrho,nlrho,taus,P,N,J,rho,a0,v,maxiter,tolerance,xmin
end
# Kv
function simpleq_Kv_Kvk(u,V,E,rho,Upsilon,k,taus,weights,N,J)
function simpleq_Kv_Kvk(
u::Array{Float64,1},
V::Array{Float64,1},
E::Float64,
rho::Float64,
Upsilon::Array{Array{Float64,1},1},
k::Array{Float64,1},
taus::Array{Float64,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
N::Int64,
J::Int64
)
# (-Delta+v+4e(1-\rho u*)) in Fourier space
M=Array{Float64,2}(undef,N*J,N*J)
for zetapp in 0:J-1

View File

@ -1,4 +1,4 @@
## Copyright 2021 Ian Jauslin
## Copyright 2021-2023 Ian Jauslin
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
@ -13,28 +13,26 @@
## limitations under the License.
# compute energy as a function of rho
function simpleq_hardcore_energy_rho(rhos,taus,P,N,J,maxiter,tolerance)
## spawn workers
# number of workers
nw=nworkers()
# split jobs among workers
work=Array{Array{Int64,1},1}(undef,nw)
# init empty arrays
for p in 1:nw
work[p]=zeros(0)
end
for j in 1:length(rhos)
append!(work[j%nw+1],j)
end
function simpleq_hardcore_energy_rho(
rhos::Array{Float64,1},
taus::Array{Float64,1},
P::Int64,
N::Int64,
J::Int64,
maxiter::Int64,
tolerance::Float64
)
# spawn workers
work=spawn_workers(length(rhos))
# initialize vectors
(weights,weights_gL,r,T)=simpleq_hardcore_init(taus,P,N,J)
# initial guess
u0s=Array{Array{Float64}}(undef,length(rhos))
e0s=Array{Float64}(undef,length(rhos))
u0s=Array{Array{Float64,1}}(undef,length(rhos))
e0s=Array{Float64,1}(undef,length(rhos))
for j in 1:length(rhos)
u0s[j]=Array{Float64}(undef,N*J)
u0s[j]=Array{Float64,1}(undef,N*J)
for i in 1:N*J
u0s[j][i]=1/(1+r[i]^2)^2
end
@ -43,17 +41,17 @@ function simpleq_hardcore_energy_rho(rhos,taus,P,N,J,maxiter,tolerance)
# save result from each task
us=Array{Array{Float64}}(undef,length(rhos))
es=Array{Float64}(undef,length(rhos))
err=Array{Float64}(undef,length(rhos))
us=Array{Array{Float64,1}}(undef,length(rhos))
es=Array{Float64,1}(undef,length(rhos))
err=Array{Float64,1}(undef,length(rhos))
count=0
# for each worker
@sync for p in 1:nw
@sync for p in 1:length(work)
# for each task
@async for j in work[p]
count=count+1
if count>=nw
if count>=length(work)
progress(count,length(rhos),10000)
end
# run the task
@ -67,12 +65,20 @@ function simpleq_hardcore_energy_rho(rhos,taus,P,N,J,maxiter,tolerance)
end
# compute u(x)
function simpleq_hardcore_ux(rho,taus,P,N,J,maxiter,tolerance)
function simpleq_hardcore_ux(
rho::Float64,
taus::Array{Float64,1},
P::Int64,
N::Int64,
J::Int64,
maxiter::Int64,
tolerance::Float64
)
# initialize vectors
(weights,weights_gL,r,T)=simpleq_hardcore_init(taus,P,N,J)
# initial guess
u0=Array{Float64}(undef,N*J)
u0=Array{Float64,1}(undef,N*J)
for i in 1:N*J
u0[i]=1/(1+r[i]^2)^2
end
@ -86,28 +92,26 @@ function simpleq_hardcore_ux(rho,taus,P,N,J,maxiter,tolerance)
end
# compute condensate fraction as a function of rho
function simpleq_hardcore_condensate_fraction_rho(rhos,taus,P,N,J,maxiter,tolerance)
## spawn workers
# number of workers
nw=nworkers()
# split jobs among workers
work=Array{Array{Int64,1},1}(undef,nw)
# init empty arrays
for p in 1:nw
work[p]=zeros(0)
end
for j in 1:length(rhos)
append!(work[j%nw+1],j)
end
function simpleq_hardcore_condensate_fraction_rho(
rhos::Array{Float64,1},
taus::Array{Float64,1},
P::Int64,
N::Int64,
J::Int64,
maxiter::Int64,
tolerance::Float64
)
# spawn workers
work=spawn_workers(length(rhos))
# initialize vectors
(weights,weights_gL,r,T)=simpleq_hardcore_init(taus,P,N,J)
# initial guess
u0s=Array{Array{Float64}}(undef,length(rhos))
e0s=Array{Float64}(undef,length(rhos))
u0s=Array{Array{Float64,1}}(undef,length(rhos))
e0s=Array{Float64,1}(undef,length(rhos))
for j in 1:length(rhos)
u0s[j]=Array{Float64}(undef,N*J)
u0s[j]=Array{Float64,1}(undef,N*J)
for i in 1:N*J
u0s[j][i]=1/(1+r[i]^2)^2
end
@ -116,17 +120,17 @@ function simpleq_hardcore_condensate_fraction_rho(rhos,taus,P,N,J,maxiter,tolera
# save result from each task
us=Array{Array{Float64}}(undef,length(rhos))
es=Array{Float64}(undef,length(rhos))
err=Array{Float64}(undef,length(rhos))
us=Array{Array{Float64,1}}(undef,length(rhos))
es=Array{Float64,1}(undef,length(rhos))
err=Array{Float64,1}(undef,length(rhos))
count=0
# for each worker
@sync for p in 1:nw
@sync for p in 1:length(work)
# for each task
@async for j in work[p]
count=count+1
if count>=nw
if count>=length(work)
progress(count,length(rhos),10000)
end
# run the task
@ -142,13 +146,18 @@ end
# initialize computation
@everywhere function simpleq_hardcore_init(taus,P,N,J)
@everywhere function simpleq_hardcore_init(
taus::Array{Float64,1},
P::Int64,
N::Int64,
J::Int64
)
# Gauss-Legendre weights
weights=gausslegendre(N)
weights_gL=gausslaguerre(N)
# r
r=Array{Float64}(undef,J*N)
r=Array{Float64,1}(undef,J*N)
for zeta in 0:J-1
for j in 1:N
xj=weights[1][j]
@ -164,9 +173,23 @@ end
end
# compute u using chebyshev expansions
@everywhere function simpleq_hardcore_hatu(u0,e0,rho,r,taus,T,weights,weights_gL,P,N,J,maxiter,tolerance)
@everywhere function simpleq_hardcore_hatu(
u0::Array{Float64,1},
e0::Float64,
rho::Float64,
r::Array{Float64,1},
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
weights_gL::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
N::Int64,
J::Int64,
maxiter::Int64,
tolerance::Float64
)
# init
vec=Array{Float64}(undef,J*N+1)
vec=Array{Float64,1}(undef,J*N+1)
for i in 1:J*N
vec[i]=u0[i]
end
@ -194,8 +217,20 @@ end
end
# Xi
@everywhere function simpleq_hardcore_Xi(u,e,rho,r,taus,T,weights,weights_gL,P,N,J)
out=Array{Float64}(undef,J*N+1)
@everywhere function simpleq_hardcore_Xi(
u::Array{Float64,1},
e::Float64,
rho::Float64,
r::Array{Float64,1},
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
weights_gL::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
N::Int64,
J::Int64
)
out=Array{Float64,1}(undef,J*N+1)
FU=chebyshev(u,taus,weights,P,N,J,4)
#D's
@ -215,7 +250,19 @@ end
return out
end
# DXi
@everywhere function simpleq_hardcore_DXi(u,e,rho,r,taus,T,weights,weights_gL,P,N,J)
@everywhere function simpleq_hardcore_DXi(
u::Array{Float64,1},
e::Float64,
rho::Float64,
r::Array{Float64,1},
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
weights_gL::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
N::Int64,
J::Int64
)
out=Array{Float64,2}(undef,J*N+1,J*N+1)
FU=chebyshev(u,taus,weights,P,N,J,4)
@ -232,15 +279,15 @@ end
for zetapp in 0:J-1
for n in 1:N
one=zeros(Int64,J*N)
one[zetapp*N+n]=1
one=zeros(Float64,J*N)
one[zetapp*N+n]=1.
Fone=chebyshev(one,taus,weights,P,N,J,4)
for i in 1:J*N
# du/du
out[i,zetapp*N+n]=dot(Fone,d1[i])+2*dot(FU,d2[i]*Fone)-(zetapp*N+n==i ? 1 : 0)
# du/de
out[i,J*N+1]=(dsed0[i]+dot(FU,dsed1[i])+dot(FU,dsed2[i]*FU))/(2*sqrt(abs(e)))*(e>=0 ? 1 : -1)
out[i,J*N+1]=(dsed0[i]+dot(FU,dsed1[i])+dot(FU,dsed2[i]*FU))/(2*sqrt(abs(e)))*(e>=0. ? 1. : -1.)
end
# de/du
out[J*N+1,zetapp*N+n]=2*pi*rho*
@ -253,14 +300,26 @@ end
#de/de
out[J*N+1,J*N+1]=-1+2*pi*rho*
(2-dsedgamma0(e,rho,weights)-dot(FU,dsedgamma1(e,rho,taus,T,weights,weights_gL,P,J,4))-dot(FU,dsedgamma2(e,rho,taus,T,weights,weights_gL,P,J,4)*FU))/denom/
(2*sqrt(abs(e)))*(e>=0 ? 1 : -1)
(2*sqrt(abs(e)))*(e>=0. ? 1. : -1.)
return out
end
# dXi/dmu
@everywhere function simpleq_hardcore_dXidmu(u,e,rho,r,taus,T,weights,weights_gL,P,N,J)
out=Array{Float64}(undef,J*N+1)
@everywhere function simpleq_hardcore_dXidmu(
u::Array{Float64,1},
e::Float64,
rho::Float64,
r::Array{Float64,1},
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
weights_gL::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
N::Int64,
J::Int64
)
out=Array{Float64,1}(undef,J*N+1)
FU=chebyshev(u,taus,weights,P,N,J,4)
#D's
@ -281,17 +340,37 @@ end
end
# B's
@everywhere function B0(r)
@everywhere function B0(
r::Float64
)
return pi/12*(r-1)^2*(r+5)
end
@everywhere function B1(r,zeta,n,taus,T,weights,nu)
@everywhere function B1(
r::Float64,
zeta::Int64,
n::Int64,
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
nu::Int64
)
return (taus[zeta+1]>=(2-r)/r || taus[zeta+2]<=-r/(r+2) ? 0 :
8*pi/(r+1)*integrate_legendre(tau->
(1-(r-(1-tau)/(1+tau))^2)/(1+tau)^(3-nu)*T[n+1]((2*tau-(taus[zeta+1]+taus[zeta+2]))/(taus[zeta+2]-taus[zeta+1])),max(taus[zeta+1],-r/(r+2))
,min(taus[zeta+2],(2-r)/r),weights)
)
end
@everywhere function B2(r,zeta,n,zetap,m,taus,T,weights,nu)
@everywhere function B2(
r::Float64,
zeta::Int64,
n::Int64,
zetap::Int64,
m::Int64,
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
nu::Int64
)
return 32*pi/(r+1)*integrate_legendre(tau->
1/(1+tau)^(3-nu)*T[n+1]((2*tau-(taus[zeta+1]+taus[zeta+2]))/(taus[zeta+2]-taus[zeta+1]))*
(taus[zetap+1]>=alphap(abs(r-(1-tau)/(1+tau))-2*tau/(1+tau),tau) || taus[zetap+2]<=alpham(1+r,tau) ? 0 :
@ -303,30 +382,49 @@ end
end
# D's
@everywhere function D0(e,rho,r,weights,N,J)
out=Array{Float64}(undef,J*N)
@everywhere function D0(
e::Float64,
rho::Float64,
r::Array{Float64,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
N::Int64,
J::Int64
)
out=Array{Float64,1}(undef,J*N)
for i in 1:J*N
out[i]=exp(-2*sqrt(abs(e))*r[i])/(r[i]+1)+
rho*sqrt(abs(e))/(r[i]+1)*integrate_legendre(s->
(s+1)*B0(s)*(exp(-2*sqrt(abs(e))*(r[i]-s))-exp(-2*sqrt(abs(e))*(r[i]+s)))/2
,0,min(1,r[i]),weights)+
,0.,min(1.,r[i]),weights)+
(r[i]>=1 ? 0 :
rho*sqrt(abs(e))/(2*(r[i]+1))*(1-exp(-4*sqrt(abs(e))*r[i]))*integrate_legendre(s->
(s+r[i]+1)*B0(s+r[i])*exp(-2*sqrt(abs(e))*s)
,0,1-r[i],weights)
,0.,1. -r[i],weights)
)
end
return out
end
@everywhere function D1(e,rho,r,taus,T,weights,weights_gL,P,N,J,nu)
out=Array{Array{Float64}}(undef,J*N)
@everywhere function D1(
e::Float64,
rho::Float64,
r::Array{Float64,1},
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
weights_gL::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
N::Int64,
J::Int64,
nu::Int64
)
out=Array{Array{Float64,1},1}(undef,J*N)
for i in 1:J*N
out[i]=Array{Float64}(undef,(P+1)*J)
out[i]=Array{Float64,1}(undef,(P+1)*J)
for zeta in 0:J-1
for n in 0:P
out[i][zeta*(P+1)+n+1]=rho*sqrt(abs(e))/(r[i]+1)*integrate_legendre(s->
(s+1)*B1(s,zeta,n,taus,T,weights,nu)*(exp(-2*sqrt(abs(e))*(r[i]-s))-exp(-2*sqrt(abs(e))*(r[i]+s)))/2
,0,r[i],weights)+
,0.,r[i],weights)+
rho*sqrt(abs(e))/(2*(r[i]+1))*(1-exp(-4*sqrt(abs(e))*r[i]))*integrate_laguerre(s->
(s+r[i]+1)*B1(s+r[i],zeta,n,taus,T,weights,nu)
,2*sqrt(abs(e)),weights_gL)
@ -336,7 +434,19 @@ end
return out
end
@everywhere function D2(e,rho,r,taus,T,weights,weights_gL,P,N,J,nu)
@everywhere function D2(
e::Float64,
rho::Float64,
r::Array{Float64,1},
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
weights_gL::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
N::Int64,
J::Int64,
nu::Int64
)
out=Array{Array{Float64,2}}(undef,J*N)
for i in 1:J*N
out[i]=Array{Float64,2}(undef,(P+1)*J,(P+1)*J)
@ -346,7 +456,7 @@ end
for m in 0:P
out[i][zeta*(P+1)+n+1,zetap*(P+1)+m+1]=rho*sqrt(abs(e))/(r[i]+1)*integrate_legendre(s->
(s+1)*B2(s,zeta,n,zetap,m,taus,T,weights,nu)*(exp(-2*sqrt(abs(e))*(r[i]-s))-exp(-2*sqrt(abs(e))*(r[i]+s)))/2
,0,r[i],weights)+
,0.,r[i],weights)+
rho*sqrt(abs(e))/(2*(r[i]+1))*(1-exp(-4*sqrt(abs(e))*r[i]))*integrate_laguerre(s->
(s+r[i]+1)*B2(s+r[i],zeta,n,zetap,m,taus,T,weights,nu)
,2*sqrt(abs(e)),weights_gL)
@ -359,28 +469,47 @@ end
end
# dD/d sqrt(abs(e))'s
@everywhere function dseD0(e,rho,r,weights,N,J)
out=Array{Float64}(undef,J*N)
@everywhere function dseD0(
e::Float64,
rho::Float64,
r::Array{Float64,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
N::Int64,
J::Int64
)
out=Array{Float64,1}(undef,J*N)
for i in 1:J*N
out[i]=-2*r[i]*exp(-2*sqrt(abs(e))*r[i])/(r[i]+1)+
rho/(r[i]+1)*integrate_legendre(s->
(s+1)*B0(s)*((1-2*sqrt(abs(e))*r[i])*(exp(-2*sqrt(abs(e))*(r[i]-s))-exp(-2*sqrt(abs(e))*(r[i]+s)))/2+2*sqrt(abs(e))*s*(exp(-2*sqrt(abs(e))*(r[i]-s))+exp(-2*sqrt(abs(e))*(r[i]+s)))/2)
,0,min(1,r[i]),weights)+
,0.,min(1.,r[i]),weights)+
(r[i]>=1 ? 0 :
rho/(2*(r[i]+1))*integrate_legendre(s->(s+r[i]+1)*B0(s+r[i])*((1-2*sqrt(abs(e))*s)*(1-exp(-4*sqrt(abs(e))*r[i]))*exp(-2*sqrt(abs(e))*s)+4*sqrt(abs(e))*r[i]*exp(-2*sqrt(abs(e))*(2*r[i]+s))),0,1-r[i],weights)
rho/(2*(r[i]+1))*integrate_legendre(s->(s+r[i]+1)*B0(s+r[i])*((1-2*sqrt(abs(e))*s)*(1-exp(-4*sqrt(abs(e))*r[i]))*exp(-2*sqrt(abs(e))*s)+4*sqrt(abs(e))*r[i]*exp(-2*sqrt(abs(e))*(2*r[i]+s))),0.,1. -r[i],weights)
)
end
return out
end
@everywhere function dseD1(e,rho,r,taus,T,weights,weights_gL,P,N,J,nu)
out=Array{Array{Float64}}(undef,J*N)
@everywhere function dseD1(
e::Float64,
rho::Float64,
r::Array{Float64,1},
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
weights_gL::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
N::Int64,
J::Int64,
nu::Int64
)
out=Array{Array{Float64,1},1}(undef,J*N)
for i in 1:J*N
out[i]=Array{Float64}(undef,(P+1)*J)
out[i]=Array{Float64,1}(undef,(P+1)*J)
for zeta in 0:J-1
for n in 0:P
out[i][zeta*(P+1)+n+1]=rho/(r[i]+1)*integrate_legendre(s->
(s+1)*B1(s,zeta,n,taus,T,weights,nu)*((1-2*sqrt(abs(e))*r[i])*(exp(-2*sqrt(abs(e))*(r[i]-s))-exp(-2*sqrt(abs(e))*(r[i]+s)))/2+2*sqrt(abs(e))*s*(exp(-2*sqrt(abs(e))*(r[i]-s))+exp(-2*sqrt(abs(e))*(r[i]+s)))/2)
,0,r[i],weights)+
,0.,r[i],weights)+
rho/(2*(r[i]+1))*integrate_laguerre(s->
(s+r[i]+1)*B1(s+r[i],zeta,n,taus,T,weights,nu)*((1-2*sqrt(abs(e))*s)*(1-exp(-4*sqrt(abs(e))*r[i]))+4*sqrt(abs(e))*r[i]*exp(-4*sqrt(abs(e))*r[i]))
,2*sqrt(abs(e)),weights_gL)
@ -389,7 +518,19 @@ end
end
return out
end
@everywhere function dseD2(e,rho,r,taus,T,weights,weights_gL,P,N,J,nu)
@everywhere function dseD2(
e::Float64,
rho::Float64,
r::Array{Float64,1},
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
weights_gL::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
N::Int64,
J::Int64,
nu::Int64
)
out=Array{Array{Float64,2}}(undef,J*N)
for i in 1:J*N
out[i]=Array{Float64,2}(undef,(P+1)*J,(P+1)*J)
@ -399,7 +540,7 @@ end
for m in 0:P
out[i][zeta*(P+1)+n+1,zetap*(P+1)+m+1]=rho/(r[i]+1)*integrate_legendre(s->
(s+1)*B2(s,zeta,n,zetap,m,taus,T,weights,nu)*((1-2*sqrt(abs(e))*r[i])*(exp(-2*sqrt(abs(e))*(r[i]-s))-exp(-2*sqrt(abs(e))*(r[i]+s)))/2+2*sqrt(abs(e))*s*(exp(-2*sqrt(abs(e))*(r[i]-s))+exp(-2*sqrt(abs(e))*(r[i]+s)))/2)
,0,r[i],weights)+
,0.,r[i],weights)+
rho/(2*(r[i]+1))*integrate_laguerre(s->
(s+r[i]+1)*B2(s+r[i],zeta,n,zetap,m,taus,T,weights,nu)*((1-2*sqrt(abs(e))*s)*(1-exp(-4*sqrt(abs(e))*r[i]))+4*sqrt(abs(e))*r[i]*exp(-4*sqrt(abs(e))*r[i]))
,2*sqrt(abs(e)),weights_gL)
@ -412,28 +553,47 @@ end
end
# dD/d sqrt(abs(e+mu/2))'s
@everywhere function dsmuD0(e,rho,r,weights,N,J)
out=Array{Float64}(undef,J*N)
@everywhere function dsmuD0(
e::Float64,
rho::Float64,
r::Array{Float64,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
N::Int64,
J::Int64
)
out=Array{Float64,1}(undef,J*N)
for i in 1:J*N
out[i]=-2*r[i]*exp(-2*sqrt(abs(e))*r[i])/(r[i]+1)+
rho/(r[i]+1)*integrate_legendre(s->
(s+1)*B0(s)*((-1-2*sqrt(abs(e))*r[i])*(exp(-2*sqrt(abs(e))*(r[i]-s))-exp(-2*sqrt(abs(e))*(r[i]+s)))/2+2*sqrt(abs(e))*s*(exp(-2*sqrt(abs(e))*(r[i]-s))+exp(-2*sqrt(abs(e))*(r[i]+s)))/2)
,0,min(1,r[i]),weights)+
,0.,min(1.,r[i]),weights)+
(r[i]>=1 ? 0 :
rho/(2*(r[i]+1))*integrate_legendre(s->(s+r[i]+1)*B0(s+r[i])*((-1-2*sqrt(abs(e))*s)*(1-exp(-4*sqrt(abs(e))*r[i]))*exp(-2*sqrt(abs(e))*s)+4*sqrt(abs(e))*r[i]*exp(-2*sqrt(abs(e))*(2*r[i]+s))),0,1-r[i],weights)
rho/(2*(r[i]+1))*integrate_legendre(s->(s+r[i]+1)*B0(s+r[i])*((-1-2*sqrt(abs(e))*s)*(1-exp(-4*sqrt(abs(e))*r[i]))*exp(-2*sqrt(abs(e))*s)+4*sqrt(abs(e))*r[i]*exp(-2*sqrt(abs(e))*(2*r[i]+s))),0.,1. -r[i],weights)
)
end
return out
end
@everywhere function dsmuD1(e,rho,r,taus,T,weights,weights_gL,P,N,J,nu)
out=Array{Array{Float64}}(undef,J*N)
@everywhere function dsmuD1(
e::Float64,
rho::Float64,
r::Array{Float64,1},
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
weights_gL::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
N::Int64,
J::Int64,
nu::Int64
)
out=Array{Array{Float64,1},1}(undef,J*N)
for i in 1:J*N
out[i]=Array{Float64}(undef,(P+1)*J)
out[i]=Array{Float64,1}(undef,(P+1)*J)
for zeta in 0:J-1
for n in 0:P
out[i][zeta*(P+1)+n+1]=rho/(r[i]+1)*integrate_legendre(s->
(s+1)*B1(s,zeta,n,taus,T,weights,nu)*((-1-2*sqrt(abs(e))*r[i])*(exp(-2*sqrt(abs(e))*(r[i]-s))-exp(-2*sqrt(abs(e))*(r[i]+s)))/2+2*sqrt(abs(e))*s*(exp(-2*sqrt(abs(e))*(r[i]-s))+exp(-2*sqrt(abs(e))*(r[i]+s)))/2)
,0,r[i],weights)+
,0.,r[i],weights)+
rho/(2*(r[i]+1))*integrate_laguerre(s->
(s+r[i]+1)*B1(s+r[i],zeta,n,taus,T,weights,nu)*((-1-2*sqrt(abs(e))*s)*(1-exp(-4*sqrt(abs(e))*r[i]))+4*sqrt(abs(e))*r[i]*exp(-4*sqrt(abs(e))*r[i]))
,2*sqrt(abs(e)),weights_gL)
@ -442,7 +602,19 @@ end
end
return out
end
@everywhere function dsmuD2(e,rho,r,taus,T,weights,weights_gL,P,N,J,nu)
@everywhere function dsmuD2(
e::Float64,
rho::Float64,
r::Array{Float64,1},
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
weights_gL::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
N::Int64,
J::Int64,
nu::Int64
)
out=Array{Array{Float64,2}}(undef,J*N)
for i in 1:J*N
out[i]=Array{Float64,2}(undef,(P+1)*J,(P+1)*J)
@ -452,7 +624,7 @@ end
for m in 0:P
out[i][zeta*(P+1)+n+1,zetap*(P+1)+m+1]=rho/(r[i]+1)*integrate_legendre(s->
(s+1)*B2(s,zeta,n,zetap,m,taus,T,weights,nu)*((-1-2*sqrt(abs(e))*r[i])*(exp(-2*sqrt(abs(e))*(r[i]-s))-exp(-2*sqrt(abs(e))*(r[i]+s)))/2+2*sqrt(abs(e))*s*(exp(-2*sqrt(abs(e))*(r[i]-s))+exp(-2*sqrt(abs(e))*(r[i]+s)))/2)
,0,r[i],weights)+
,0.,r[i],weights)+
rho/(2*(r[i]+1))*integrate_laguerre(s->
(s+r[i]+1)*B2(s+r[i],zeta,n,zetap,m,taus,T,weights,nu)*((-1-2*sqrt(abs(e))*s)*(1-exp(-4*sqrt(abs(e))*r[i]))+4*sqrt(abs(e))*r[i]*exp(-4*sqrt(abs(e))*r[i]))
,2*sqrt(abs(e)),weights_gL)
@ -465,11 +637,25 @@ end
end
# gamma's
@everywhere function gamma0(e,rho,weights)
return 2*rho*e*integrate_legendre(s->(s+1)*B0(s)*exp(-2*sqrt(abs(e))*s),0,1,weights)
@everywhere function gamma0(
e::Float64,
rho::Float64,
weights::Tuple{Array{Float64,1},Array{Float64,1}}
)
return 2*rho*e*integrate_legendre(s->(s+1)*B0(s)*exp(-2*sqrt(abs(e))*s),0.,1.,weights)
end
@everywhere function gamma1(e,rho,taus,T,weights,weights_gL,P,J,nu)
out=Array{Float64}(undef,J*(P+1))
@everywhere function gamma1(
e::Float64,
rho::Float64,
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
weights_gL::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
J::Int64,
nu::Int64
)
out=Array{Float64,1}(undef,J*(P+1))
for zeta in 0:J-1
for n in 0:P
out[zeta*(P+1)+n+1]=2*rho*e*integrate_laguerre(s->(s+1)*B1(s,zeta,n,taus,T,weights,nu),2*sqrt(abs(e)),weights_gL)
@ -477,7 +663,17 @@ end
end
return out
end
@everywhere function gamma2(e,rho,taus,T,weights,weights_gL,P,J,nu)
@everywhere function gamma2(
e::Float64,
rho::Float64,
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
weights_gL::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
J::Int64,
nu::Int64
)
out=Array{Float64,2}(undef,J*(P+1),J*(P+1))
for zeta in 0:J-1
for n in 0:P
@ -492,11 +688,25 @@ end
end
# dgamma/d sqrt(abs(e))'s
@everywhere function dsedgamma0(e,rho,weights)
return 4*rho*sqrt(abs(e))*integrate_legendre(s->(s+1)*B0(s)*(1-sqrt(abs(e))*s)*exp(-2*sqrt(abs(e))*s),0,1,weights)
@everywhere function dsedgamma0(
e::Float64,
rho::Float64,
weights::Tuple{Array{Float64,1},Array{Float64,1}}
)
return 4*rho*sqrt(abs(e))*integrate_legendre(s->(s+1)*B0(s)*(1-sqrt(abs(e))*s)*exp(-2*sqrt(abs(e))*s),0.,1.,weights)
end
@everywhere function dsedgamma1(e,rho,taus,T,weights,weights_gL,P,J,nu)
out=Array{Float64}(undef,J*(P+1))
@everywhere function dsedgamma1(
e::Float64,
rho::Float64,
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
weights_gL::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
J::Int64,
nu::Int64
)
out=Array{Float64,1}(undef,J*(P+1))
for zeta in 0:J-1
for n in 0:P
out[zeta*(P+1)+n+1]=4*rho*e*integrate_laguerre(s->(s+1)*B1(s,zeta,n,taus,T,weights,nu)*(1-sqrt(abs(e))*s),2*sqrt(abs(e)),weights_gL)
@ -504,7 +714,17 @@ end
end
return out
end
@everywhere function dsedgamma2(e,rho,taus,T,weights,weights_gL,P,J,nu)
@everywhere function dsedgamma2(
e::Float64,
rho::Float64,
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
weights_gL::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
J::Int64,
nu::Int64
)
out=Array{Float64,2}(undef,J*(P+1),J*(P+1))
for zeta in 0:J-1
for n in 0:P
@ -519,11 +739,25 @@ end
end
# dgamma/d sqrt(e+mu/2)'s
@everywhere function dsmudgamma0(e,rho,weights)
return -4*rho*e*integrate_legendre(s->(s+1)*s*B0(s)*exp(-2*sqrt(abs(e))*s),0,1,weights)
@everywhere function dsmudgamma0(
e::Float64,
rho::Float64,
weights::Tuple{Array{Float64,1},Array{Float64,1}}
)
return -4*rho*e*integrate_legendre(s->(s+1)*s*B0(s)*exp(-2*sqrt(abs(e))*s),0.,1.,weights)
end
@everywhere function dsmudgamma1(e,rho,taus,T,weights,weights_gL,P,J,nu)
out=Array{Float64}(undef,J*(P+1))
@everywhere function dsmudgamma1(
e::Float64,
rho::Float64,
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
weights_gL::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
J::Int64,
nu::Int64
)
out=Array{Float64,1}(undef,J*(P+1))
for zeta in 0:J-1
for n in 0:P
out[zeta*(P+1)+n+1]=-4*rho*e*integrate_laguerre(s->s*(s+1)*B1(s,zeta,n,taus,T,weights,nu),2*sqrt(abs(e)),weights_gL)
@ -531,7 +765,17 @@ end
end
return out
end
@everywhere function dsmudgamma2(e,rho,taus,T,weights,weights_gL,P,J,nu)
@everywhere function dsmudgamma2(
e::Float64,
rho::Float64,
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
weights_gL::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
J::Int64,
nu::Int64
)
out=Array{Float64,2}(undef,J*(P+1),J*(P+1))
for zeta in 0:J-1
for n in 0:P
@ -546,25 +790,41 @@ end
end
# \bar gamma's
@everywhere function gammabar0(weights)
return 4*pi*integrate_legendre(s->s^2*B0(s-1),0,1,weights)
@everywhere function gammabar0(
weights::Tuple{Array{Float64,1},Array{Float64,1}}
)
return 4*pi*integrate_legendre(s->s^2*B0(s-1),0.,1.,weights)
end
@everywhere function gammabar1(taus,T,weights,P,J,nu)
out=Array{Float64}(undef,J*(P+1))
@everywhere function gammabar1(
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
J::Int64,
nu::Int64
)
out=Array{Float64,1}(undef,J*(P+1))
for zeta in 0:J-1
for n in 0:P
out[zeta*(P+1)+n+1]=4*pi*integrate_legendre(s->s^2*B1(s-1,zeta,n,taus,T,weights,nu),0,1,weights)
out[zeta*(P+1)+n+1]=4*pi*integrate_legendre(s->s^2*B1(s-1,zeta,n,taus,T,weights,nu),0.,1.,weights)
end
end
return out
end
@everywhere function gammabar2(taus,T,weights,P,J,nu)
@everywhere function gammabar2(
taus::Array{Float64,1},
T::Array{Polynomial,1},
weights::Tuple{Array{Float64,1},Array{Float64,1}},
P::Int64,
J::Int64,
nu::Int64
)
out=Array{Float64,2}(undef,J*(P+1),J*(P+1))
for zeta in 0:J-1
for n in 0:P
for zetap in 0:J-1
for m in 0:P
out[zeta*(P+1)+n+1,zetap*(P+1)+m+1]=4*pi*integrate_legendre(s->s^2*B2(s-1,zeta,n,zetap,m,taus,T,weights,nu),0,1,weights)
out[zeta*(P+1)+n+1,zetap*(P+1)+m+1]=4*pi*integrate_legendre(s->s^2*B2(s-1,zeta,n,zetap,m,taus,T,weights,nu),0.,1.,weights)
end
end
end

View File

@ -1,4 +1,4 @@
## Copyright 2021 Ian Jauslin
## Copyright 2021-2023 Ian Jauslin
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
@ -13,7 +13,12 @@
## limitations under the License.
# compute rho(e) using the iteration
function simpleq_iteration_rho_e(es,order,v,maxiter)
function simpleq_iteration_rho_e(
es::Array{Float64,1},
order::Int64,
v::Function,
maxiter::Int64
)
for j in 1:length(es)
(u,rho)=simpleq_iteration_hatun(es[j],order,v,maxiter)
@printf("% .15e % .15e\n",es[j],real(rho[maxiter+1]))
@ -21,7 +26,15 @@ function simpleq_iteration_rho_e(es,order,v,maxiter)
end
# compute u(x) using the iteration and print at every step
function simpleq_iteration_ux(order,e,v,maxiter,xmin,xmax,nx)
function simpleq_iteration_ux(
order::Int64,
e::Float64,
v::Function,
maxiter::Int64,
xmin::Float64,
xmax::Float64,
nx::Int64
)
(u,rho)=simpleq_iteration_hatun(e,order,v,maxiter)
weights=gausslegendre(order)
@ -37,7 +50,12 @@ end
# \hat u_n
function simpleq_iteration_hatun(e,order,v,maxiter)
function simpleq_iteration_hatun(
e::Float64,
order::Int64,
v::Function,
maxiter::Int64
)
# gauss legendre weights
weights=gausslegendre(order)
@ -46,7 +64,7 @@ function simpleq_iteration_hatun(e,order,v,maxiter)
(Eta,Eta0)=easyeq_init_H(weights,v)
# init u and rho
u=Array{Array{Float64}}(undef,maxiter+1)
u=Array{Array{Float64,1},1}(undef,maxiter+1)
u[1]=zeros(Float64,order)
rho=zeros(Float64,maxiter+1)
@ -60,7 +78,11 @@ function simpleq_iteration_hatun(e,order,v,maxiter)
end
# A
function simpleq_iteration_A(e,weights,Eta)
function simpleq_iteration_A(
e::Float64,
weights::Tuple{Array{Float64,1},Array{Float64,1}},
Eta::Array{Float64,1}
)
N=length(weights[1])
out=zeros(Float64,N,N)
for i in 1:N
@ -75,7 +97,12 @@ function simpleq_iteration_A(e,weights,Eta)
end
# b
function simpleq_iteration_b(u,e,rho,V)
function simpleq_iteration_b(
u::Array{Float64,1},
e::Float64,
rho::Float64,
V::Array{Float64,1}
)
out=zeros(Float64,length(V))
for i in 1:length(V)
out[i]=V[i]+2*e*rho*u[i]^2
@ -84,7 +111,13 @@ function simpleq_iteration_b(u,e,rho,V)
end
# rho_n
function simpleq_iteration_rhon(u,e,weights,V0,Eta0)
function simpleq_iteration_rhon(
u::Array{Float64,1},
e::Float64,
weights::Tuple{Array{Float64,1},Array{Float64,1}},
V0::Float64,
Eta0::Float64
)
S=V0
for i in 1:length(weights[1])
y=(weights[1][i]+1)/2

View File

@ -1,4 +1,4 @@
## Copyright 2021 Ian Jauslin
## Copyright 2021-2023 Ian Jauslin
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
@ -13,7 +13,9 @@
## limitations under the License.
# \Phi(x)=2*(1-sqrt(1-x))/x
@everywhere function Phi(x)
@everywhere function Phi(
x::Float64
)
if abs(x)>1e-5
return 2*(1-sqrt(abs(1-x)))/x
else
@ -21,7 +23,9 @@
end
end
# \partial\Phi
@everywhere function dPhi(x)
@everywhere function dPhi(
x::Float64
)
#if abs(x-1)<1e-5
# @printf(stderr,"warning: dPhi is singular at 1, and evaluating it at (% .8e+i% .8e)\n",real(x),imag(x))
#end
@ -33,17 +37,25 @@ end
end
# apply Phi to every element of a vector
@everywhere function dotPhi(v)
@everywhere function dotPhi(
v::Array{Float64,1}
)
out=zeros(Float64,length(v))
for i in 1:length(v)
out[i]=Phi(v[i])
end
return out
end
@everywhere function dotdPhi(v)
@everywhere function dotdPhi(
v::Array{Float64,1}
)
out=zeros(Float64,length(v))
for i in 1:length(v)
out[i]=dPhi(v[i])
end
return out
end
@everywhere function sinc(x::Float64)
return (x == 0 ? 1 : sin(x)/x)
end