Ian Jauslin
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/simpleq-iteration.jl')
-rw-r--r--src/simpleq-iteration.jl49
1 files changed, 41 insertions, 8 deletions
diff --git a/src/simpleq-iteration.jl b/src/simpleq-iteration.jl
index 98977b8..4c4de07 100644
--- a/src/simpleq-iteration.jl
+++ b/src/simpleq-iteration.jl
@@ -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