I’ve been using Julia for a little while, long enough to have successfully solved ODEs before. I’m trying to use DifferentialEquations together with Unitful, which I thought I had read should work, but it doesn’t seem to be as simple as I thought. Here’s an example mostly like what I’m trying to do:
using Unitful
using DifferentialEquations
k1 = 0.1u"1/s"
k2 = 2.0u"K/s"
ode3a = @ode_def begin
dTb = Tb*k1 + k2
end k1 k2
tspan = (0.0u"s", 6.0u"s")
params = [k1, k2]
prob = ODEProblem(ode3a, [300u"K"], tspan, params)
solve(prob)
And the result I get is
InexactError: Int64(1731//50000)
.
I’ve used a units package in Python that didn’t play nicely with solvers, so inside the RHS function I had to add units at the start and strip units away before passing back to the solver; I can do that here, but hoped to avoid that. Is there an obvious answer I’m missing?