56 lines
1.1 KiB
Julia
56 lines
1.1 KiB
Julia
# \hat u_n
|
|
function hatun_iteration(e,order,d,v,maxiter)
|
|
# gauss legendre weights
|
|
weights=gausslegendre(order)
|
|
|
|
# init V and Eta
|
|
(V,V0,Eta,Eta0)=init_veta(weights,d,v)
|
|
|
|
# init u and rho
|
|
u=Array{Array{Complex{Float64}}}(undef,maxiter+1)
|
|
u[1]=zeros(Complex{Float64},order)
|
|
rho=zeros(Complex{Float64},maxiter+1)
|
|
|
|
# iterate
|
|
for n in 1:maxiter
|
|
u[n+1]=A(e,weights,Eta)\b(u[n],e,rho[n],V)
|
|
rho[n+1]=rhon(u[n+1],e,weights,V0,Eta0)
|
|
end
|
|
|
|
return (u,rho)
|
|
end
|
|
|
|
# A
|
|
function A(e,weights,Eta)
|
|
N=length(weights[1])
|
|
out=zeros(Complex{Float64},N,N)
|
|
for i in 1:N
|
|
k=(1-weights[1][i])/(1+weights[1][i])
|
|
out[i,i]=k^2+4*e
|
|
for j in 1:N
|
|
y=(weights[1][j]+1)/2
|
|
out[i,j]+=weights[2][j]*(1-y)*Eta[i][j]/(2*(2*pi)^3*y^3)
|
|
end
|
|
end
|
|
return out
|
|
end
|
|
|
|
# b
|
|
function b(u,e,rho,V)
|
|
out=zeros(Complex{Float64},length(V))
|
|
for i in 1:length(V)
|
|
out[i]=V[i]+2*e*rho*u[i]^2
|
|
end
|
|
return out
|
|
end
|
|
|
|
# rho_n
|
|
function rhon(u,e,weights,V0,Eta0)
|
|
S=V0
|
|
for i in 1:length(weights[1])
|
|
y=(weights[1][i]+1)/2
|
|
S+=-weights[2][i]*(1-y)*u[i]*Eta0[i]/(2*(2*pi)^3*y^3)
|
|
end
|
|
return 2*e/S
|
|
end
|