Hi everyone.
This is my first foray into the Julia world, and I’m a little stuck on the best way to frame a problem I would like to solve with DifferentialEquations.jl
.
Consider a set of coupled ODEs:
\begin{align} \dot{C} &= E-\phi C\\ \dot{T} &= log(1+C) -T \\ \dot{E} &= \chi(T) E \end{align}
which are constructed to be non-dimensional (for example T = \hat{T}/\alpha, where \hat{T} has some associated unit removed by a known, constant \alpha), and solved in the time basis t=\hat{t}/\tau.
Here, \chi(T) = \tau[\hat{\chi}(\hat{T})-\mu], where \tau and \mu are constant, but as you can see, this is a conversion to the dimensional basis.
To start with, I’d create a representative function and set up the ODE solver:
function closed_system(du,u,p,t)
du[1] = u[3]-p[1]*u[1}
du[2] = log(1+u[1])-u[2]
du[3] = χ(u[2])*u[3]
end
u0 = [380.0;0.7;160.0]
tspan = (2000.0/τ,22000.0/τ)
p = [1.0]
prob = ODEProblem(closed_system,u0,tspan,p)
with χ
not implemented yet, since we need the dimensional value \hat{\chi}(\hat{T}) = \xi(1-\delta\cdot\hat{T}) (where \xi and \delta are known constants).
With a bit of conversion we can arrive at a complete solution:
function closed_system(du,u,p,t)
χhat(That) = p[5]*(1-p[6]*That)
χ(T) = p[2]*(χhat(T*p[4])-p[3])
du[1] = u[3]-p[1]*u[1]
du[2] = log(1+u[1])-u[2]
du[3] = χ(u[2])*u[3]
end
u0 = [380.0;0.7;160.0]
tspan = (2000.0/τ,22000.0/τ)
#ϕ, τ, μ, α, ξ, δ
p = [1.0;50.0;0.01;4.328;0.01;0.5]
prob = ODEProblem(closed_system,u0,tspan,p)
soln = solve(prob)
So that all seems to be fine, but here’s where I hit a roadblock:
\begin{align} d\hat{W}/d\hat{t} &= \hat{\chi}(\hat{T})\hat{W} &\quad (1)\\ E &= [\tau\eta\exp(-\mu\hat{t})\hat{W}]/C_{pi} &\quad (2) \end{align}
New values I’ve not introduced yet are known constants, but as you can see I now need to couple this dimensional value of \hat{W} into the system of equations, since it is dependent on the \hat{\chi}(\hat{T}) result.
As its an equation in the dimensional basis though, I can’t just set it up as du[4] = χhat(T*p[4])*u[4]
, since t
in closed_system
is non-dimensional.
Question 1. Is it possible to add the ODE (1) into the system of equations if is uses a different time basis like this?
The second problem here is the equation (2) dependency. I’m fairly certain it would be possible to put function calls into the parameters portion for example, but since this dependency is again in connected to the dimensional basis through \hat{t} and \hat{W}, I’m at a loss how one would go about this at all.
Question 2. How could one frame the two equations (1) and (2) such that they could affect the closed_system
function appropriately?
Any help would be appreciated. If you need any more information about my problem that I’ve left out for simplicity let me know.