Ian Jauslin
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jauslin <ian@jauslin.org>2019-12-16 15:06:59 -0500
committerIan Jauslin <ian@jauslin.org>2019-12-16 15:06:59 -0500
commite6bf8349d7fc554bdbd915cc65c44f23c1b86e75 (patch)
tree990c2f8a32ab12e94cd36cacb1079bfd2fd188c0 /figs/numerical.fig/simpleq/iteration.jl
Initial commitv0.0
Diffstat (limited to 'figs/numerical.fig/simpleq/iteration.jl')
-rw-r--r--figs/numerical.fig/simpleq/iteration.jl55
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