Hello,
Sorry I am asking so many questions on here. I would like to be able to integrate part of an equation within a MTK model so that each time step the integration is performed with the current variables and parameters. However, when building the model, the integration wants to perform at that moment therefore it is unsolvable as it tries to perform symbolic rather than numeric integration. This is compounded by the fact that a component within the integral is an inteprolation function which can’t be integrated any way other than numerically. Here is a MWE:
function func()
@parameters a b
@variables x
return a*x + b
end
function theintegral(int)
@variables x
return SymbolicNumericIntegration.integrate(x*int(x)*func(),(x,-10,10),symbolic=false)
end
function OurODE(;name)
@variables a(t) placeholder(t)
eqs = D(a) ~ placeholder
end
function main()
int = get_interpolate(stuff)
@named ODE = OurODE
integral = theintegral(int)
connections = [ODE.placeholder ~ integral]
connected = compose(ODESystem(connections,t,name=:connected,ODE)
connected_simp = structural_simplify(connected)
u0=[ODE.a => 0.0]
p[ODE.b => 1]
prob=ODEProblem(connected_simp,u0,(0.0,500),p
sol=solve(prob,AutoVern7(Rodas5());abstol=1e-10,reltol=1e-10)
end
This should have enough information that it can solve everything numerically at the time I want it solved but it tries to solve the integral at the call to theintegral(int) which makes sense but I want it to return almost a placeholder num that says it will integrate numerically when it gets there. Is this too much to ask/is there a different way of doing this
Any help would be appreciated thank you.