I am fairly new to Julia, so apologies in advance. I am trying to simultaneously solve two differential equations in Julia and having trouble. I have a MWE in Python, which is:
import numpy as np
from scipy import solve_ivp
def derivatives(T,y):
T = y[0]
t = y[1]
dtdT = T**2
dTdT = T**2
return dTdT, dtdT
def solver(Ti, Tf, n):
t_eval = np.geomspace(Ti, Tf, n)
t_span = [Ti, Tf]
y0 = [Ti, 0]
TSolved = solve_ivp(derivatives, t_span, y0, t_eval)
return TSolved.t, TSolved.y[0], TSolved.y[1]
This works and behaves how I would like it to. I've tried doing the following in Julia (same problem), and it gives me trouble:
using DifferentialEquations
function Derivatives(T,y)
T = y[1]
t = y[2]
dtdT = T^2
dTdT = T^2
return dTdT, dtdT
end
function Solver(Ti, Tf, n)
saveat = vec(10 .^ range(log(Ti), log(Tf), length=n))
TSpan = (Ti, Tf)
T0 = (Ti, 0)
DiffEq = ODEProblem(Derivatives, TSpan, T0)
Solution = solve(DiffEq, saveat=saveat)
return Solution
end
No matter how I edit it, I am getting a MethodError in Julia. I believe the problem is with how I am handling/inputting vectors and arrays, but I'm not at a bit of a loss. TIA!