Thank you for your reply,
I’ve changed my code based on your example. However I now run into an error I can’t find much information on. Any idea what is happening?
tmax = 10000.0
tspan = (0.0,tmax)
const target_species = 0
function condition(bioS, t, integrator)
bioS .- 0.000001
end
function affect!(integrator,event_index)
bioS[event_index] = 0.0
end
extinction_cb = VectorContinuousCallback(condition,affect!, length(bioS))
p = (D, S, K, v, r, X, num_nutrient, num_plant, num_animal, num_vessel_types, bm, foodWeb, b, q, ω, c, h, e, target_species, catch_max, b0V, μ, elasticity, demand_foraging)
prob = ODEProblem(dBdT,bioS,tspan,p, callback=extinction_cb)
base_simulation=solve(prob, alg = CVODE_BDF())
UndefVarError: uBottomEltype not defined
#__init#23(::Bool, ::VectorContinuousCallback{typeof(condition),typeof(affect!),typeof(affect!),typeof(DiffEqBase.INITIALIZE_DEFAULT),Float64,Int64,Nothing}, ::Float64, ::Float64, ::Array{Float64,1}, ::Array{Float64,1}, ::Int64, ::Nothing, ::Float64, ::Float64, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::String, ::typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), ::Nothing, ::Bool, ::Bool, ::Nothing, ::Bool, ::Base.Iterators.Pairs{Symbol,CVODE_BDF{:Newton,:Dense,Nothing,Nothing},Tuple{Symbol},NamedTuple{(:alg,),Tuple{CVODE_BDF{:Newton,:Dense,Nothing,Nothing}}}}, ::typeof(DiffEqBase.__init), ::ODEProblem{Array{Float64,1},Tuple{Float64,Float64},true,Tuple{Float64,Array{Float64,1},Array{Float64,2},Array{Float64,1},Array{Float64,1},Array{Float64,1},Int64,Int64,Int64,Int64,Array{Float64,1},Array{Float64,2},Array{Float64,2},Float64,Array{Float64,1},Float64,Array{Float64,2},Array{Float64,1},Int64,Float64,Float64,Float64,Float64,typeof(demand_foraging)},ODEFunction{true,typeof(dBdT),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Symbol,VectorContinuousCallback{typeof(condition),typeof(affect!),typeof(affect!),typeof(DiffEqBase.INITIALIZE_DEFAULT),Float64,Int64,Nothing},Tuple{Symbol},NamedTuple{(:callback,),Tuple{VectorContinuousCallback{typeof(condition),typeof(affect!),typeof(affect!),typeof(DiffEqBase.INITIALIZE_DEFAULT),Float64,Int64,Nothing}}}},DiffEqBase.StandardODEProblem}, ::CVODE_BDF{:Newton,:Dense,Nothing,Nothing}, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}) at solve.jl:69
(::DiffEqBase.var"#kw##__init")(::NamedTuple{(:callback, :alg),Tuple{VectorContinuousCallback{typeof(condition),typeof(affect!),typeof(affect!),typeof(DiffEqBase.INITIALIZE_DEFAULT),Float64,Int64,Nothing},CVODE_BDF{:Newton,:Dense,Nothing,Nothing}}}, ::typeof(DiffEqBase.__init), ::ODEProblem{Array{Float64,1},Tuple{Float64,Float64},true,Tuple{Float64,Array{Float64,1},Array{Float64,2},Array{Float64,1},Array{Float64,1},Array{Float64,1},Int64,Int64,Int64,Int64,Array{Float64,1},Array{Float64,2},Array{Float64,2},Float64,Array{Float64,1},Float64,Array{Float64,2},Array{Float64,1},Int64,Float64,Float64,Float64,Float64,typeof(demand_foraging)},ODEFunction{true,typeof(dBdT),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Symbol,VectorContinuousCallback{typeof(condition),typeof(affect!),typeof(affect!),typeof(DiffEqBase.INITIALIZE_DEFAULT),Float64,Int64,Nothing},Tuple{Symbol},NamedTuple{(:callback,),Tuple{VectorContinuousCallback{typeof(condition),typeof(affect!),typeof(affect!),typeof(DiffEqBase.INITIALIZE_DEFAULT),Float64,Int64,Nothing}}}},DiffEqBase.StandardODEProblem}, ::CVODE_BDF{:Newton,:Dense,Nothing,Nothing}, ::Array{Any,1}, ::Array{Any,1}, ::Array{Any,1}) at none:0
#init_call#440(::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol},NamedTuple{(:callback, :alg),Tuple{VectorContinuousCallback{typeof(condition),typeof(affect!),typeof(affect!),typeof(DiffEqBase.INITIALIZE_DEFAULT),Float64,Int64,Nothing},CVODE_BDF{:Newton,:Dense,Nothing,Nothing}}}}, ::typeof(DiffEqBase.init_call), ::ODEProblem{Array{Float64,1},Tuple{Float64,Float64},true,Tuple{Float64,Array{Float64,1},Array{Float64,2},Array{Float64,1},Array{Float64,1},Array{Float64,1},Int64,Int64,Int64,Int64,Array{Float64,1},Array{Float64,2},Array{Float64,2},Float64,Array{Float64,1},Float64,Array{Float64,2},Array{Float64,1},Int64,Float64,Float64,Float64,Float64,typeof(demand_foraging)},ODEFunction{true,typeof(dBdT),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Symbol,VectorContinuousCallback{typeof(condition),typeof(affect!),typeof(affect!),typeof(DiffEqBase.INITIALIZE_DEFAULT),Float64,Int64,Nothing},Tuple{Symbol},NamedTuple{(:callback,),Tuple{VectorContinuousCallback{typeof(condition),typeof(affect!),typeof(affect!),typeof(DiffEqBase.INITIALIZE_DEFAULT),Float64,Int64,Nothing}}}},DiffEqBase.StandardODEProblem}, ::CVODE_BDF{:Newton,:Dense,Nothing,Nothing}, ::Vararg{Any,N} where N) at solve.jl:11
#init_call at none:0 [inlined]
#init#441 at solve.jl:30 [inlined]
#init at none:0 [inlined]
#__solve#22(::Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol},NamedTuple{(:callback, :alg),Tuple{VectorContinuousCallback{typeof(condition),typeof(affect!),typeof(affect!),typeof(DiffEqBase.INITIALIZE_DEFAULT),Float64,Int64,Nothing},CVODE_BDF{:Newton,:Dense,Nothing,Nothing}}}}, ::typeof(DiffEqBase.__solve), ::ODEProblem{Array{Float64,1},Tuple{Float64,Float64},true,Tuple{Float64,Array{Float64,1},Array{Float64,2},Array{Float64,1},Array{Float64,1},Array{Float64,1},Int64,Int64,Int64,Int64,Array{Float64,1},Array{Float64,2},Array{Float64,2},Float64,Array{Float64,1},Float64,Array{Float64,2},Array{Float64,1},Int64,Float64,Float64,Float64,Float64,typeof(demand_foragin...
I am choosing to do a continuous callback as I get a DomainError... Exponentiation yielding a complex result requires a complex argument. Replace x^y with (x+0im)^y, Complex(x)^y, or similar
, otherwise. I know this error is caused by trying to calculate a negative number with an exponent (no negatives should be allowed).