0
$\begingroup$

I have two couple ODEs and the second one has a delay in the time for starting. I mean, the first ODE starts at t=0 and the second one at t=20. How can I solve the second one in the correct time after the first one has already started to be solved?

the system is:

NDSolve[{ 
  mRNA'[t] == im (1 - Exp[-Kb Yab] - Kdm mRNA[t], 
  P'[t] == Kt mRNA[t] - Kdp P[t], mRNA[0] == 0, 
  P[0] == 0}, {mRNA[t], P[t]}, {t, 0, 400}]
$\endgroup$

2 Answers 2

1
$\begingroup$

Here's one way:

im = Kb = Yab = Kdm = Kt = Kdp = 1;
NDSolve[{mRNA'[t] == im (1 - Exp[-Kb Yab] - Kdm mRNA[t]), 
  P'[t] == If[t > 20, Kt mRNA[t] - Kdp P[t], 0], mRNA[0] == 0, 
  P[0] == 0}, {mRNA, P}, {t, 0, 400}]
$\endgroup$
1
$\begingroup$

Since the first equation is totally independent of the second variable P, you can solve it analytically first. Saying "the second starts at t = 20", I think you mean P[20]==0 and for lower t.

im = Kb = Yab = Kdm = Kt = Kdp = 1;

mRNAsol = mRNA /. First@
   DSolve[{Derivative[1][mRNA][t] == 1 - 1/E - mRNA[t], mRNA[0] == 0},
 mRNA, t]

(*   Function[{t}, (-1 + E) E^(-1 - t) (-1 + E^t)]   *)

Psol[t_] = Piecewise[{{P[t] /. 
 First@DSolve[{Derivative[1][P][t] == mRNAsol[t] - P[t], 
    P[20] == 0}, P, t], t > 20}}, 0]

(*   Piecewise[{{E^(-1 - t)*(-20 + 20*E + 
        E^20 - E^21 - E^t + 
        E^(1 + t) + t - E*t), 
   t > 20}}, 0]   *)

Plot[{mRNAsol[t], Psol[t]}, {t, 0, 40}, PlotStyle -> {Blue, Red}, 
   PlotRange -> All]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.