-
-
Notifications
You must be signed in to change notification settings - Fork 80
Description
I am solving the 1D KS equation using FDM. I transformed the PDE into a set of ODEs inside a function that I called DerSen.jl. I used RK4 to solve the ODEs and the solution I got is correct.
using DifferentialEquations
p=c # parameters
u0=U[:,1] #Float
tspan=(0.0,Tspan)
prob=ODEProblem(DerSen,u0,tspan,p)
sol = solve(prob,RK4(),saveat=Δt)
U=convert(Array,sol)
t_vec=sol.tI would like to go further and compute the adjoint sensitivity of this model. My code is as follows:
using Sundials, DiffEqBase
g(u,p,t) = (sum(u).^2) ./ 2
function dg(out,u,p,t)
for i=1:Nx
out[i]=sum(U[i,:])
end
end
res = adjoint_sensitivities(sol,Vern9(),g,nothing,dg,abstol=1e-8,
reltol=1e-8,iabstol=1e-8,ireltol=1e-8)and I get this error massage that I don't understand
LoadError: MethodError: no method matching similar(::Float64)
Closest candidates are:
similar(!Matched::JuliaInterpreter.Compiled, !Matched::Any) at C:\Users*.juliapro\JuliaPro_v1.2.0-1\packages\JuliaInterpreter\MXq3U\src\types.jl:7
similar(!Matched::DataFrames.StackedVector, !Matched::Type, !Matched::Union{Integer, AbstractUnitRange}...) at C:\Users*.juliapro\JuliaPro_v1.2.0-1\packages\DataFrames\yH0f6\src\abstractdataframe\reshape.jl:401
similar(!Matched::Sundials.NVector) at C:\Users**.juliapro\JuliaPro_v1.2.0-1\packages\Sundials\fVIue\src\nvector_wrapper.jl:69
...