diff options
Diffstat (limited to 'figs/numerical.fig/simpleq/iteration.jl')
-rw-r--r-- | figs/numerical.fig/simpleq/iteration.jl | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/figs/numerical.fig/simpleq/iteration.jl b/figs/numerical.fig/simpleq/iteration.jl new file mode 100644 index 0000000..f6f044a --- /dev/null +++ b/figs/numerical.fig/simpleq/iteration.jl @@ -0,0 +1,55 @@ +# \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 |