Hi,
I’m new to Julia. I have successfully coded a runge kutta implicit method in Julia on Windows using VS code.
I have built everything from scratch. However, the running time is about 5 minutes. So I want to use NLsolve to find root faster for the implicit solver
My system of ODEs to solve within the framework of the implicit solver are as follows:
function f(u, t, dt, k)
n = length(u)
a00 = 11.0/45.0 - (7.0 * sqrt(6.0)) / 360.0
a01 = 37.0/225.0 - (169.0 * sqrt(6.0)) / 1800.0
a02 = -2.0/225.0 + sqrt(6.0) / 75.0
a10 = 37.0/225.0 + (169.0 * sqrt(6.0)) / 1800.0
a11 = 11.0/45.0 + (7.0 * sqrt(6.0)) / 360.0
a12 = -2.0/225.0 - sqrt(6.0) / 75.0
a20 = 4.0/9.0 - sqrt(6.0) / 36.0
a21 = 4.0/9.0 + sqrt(6.0) / 36.0
a22 = 1.0/9.0
c0 = 2.0/5.0 - sqrt(6.0) / 10.0
c1 = 2.0/5.0 + sqrt(6.0) / 10.0
c2 = 1.0
out = ones(n*3)
xcurr = zeros(n)
for i in 1:n
j = (i + (i * 2)) - 2
xcurr[i] = u[i] + (a00 * k[j] + a01 * k[j+1] + a02 * k[j+2])
end
o = fu(xcurr, t + c0 * dt)
for i in 1:n
j = (i + (i * 2)) - 2
out[j] = dt * o[i] - k[j]
xcurr[i] = u[i] + (a10 * k[j] + a11 * k[j+1] + a12 * k[j+2])
end
o = fu(xcurr, t + c1 * dt)
for i in 1:n
j = (i + (i * 2)) -2
out[j+1] = dt * o[i] - k[j+1]
xcurr[i] = u[i] + (a20 * k[j] + a21 * k[j+1] + a22 * k[j+2])
end
o = fu(xcurr, t + c2 * dt)
for i in 1:n
j = (i + (i * 2)) -2
out[j+2] = dt * o[i] - k[j+2]
end
return out
end
k = ones(3*m)
c1 = nlsolve(f, k)
However I’m receiving errors:
ERROR: MethodError: no method matching f(::Vector{Float64}, ::Vector{Float64})
Closest candidates are:
f(::Any, ::Any, ::Any, ::Any) at c:\Users\Vickram\Downloads\juli\rad5.jl:6
f(::Any, ::Any, ::Any, ::Any, ::Any) at
t is the time (so for one instance of the solver, the t = 0); (t = (0, 3000) )
dt is the timestep (in this example: 0.001)
u is the initial conditions (in this example: [2, 0] )
The nlsolve should solve for one instance only as such:
t = 0, dt = 0.001, u = [2, 0]; and k = [1, 1, 1, 1, 1,1]
Please help me out. Thanks