0
$\begingroup$

I'm getting crazy with this Manipulate :


Clear[l, L, nc, phic, tauC, tauG, tauS, phi0, Vinitphi, Vphi0, nL0, \
V, Vphi, VinitR, VinitR0, dV, V0, Vphi0]

VinitR0 = 0
L = 6000
nL0 = 1
phi0 = 0.4

model[Vinitphi_?NumberQ, l_?NumberQ, nc_?NumberQ, phic_?NumberQ, 
  tauC_?NumberQ, tauG_?NumberQ, tauS_?NumberQ] = 
 Module[{V, t, Vphi, VinitR}, 
  First[V[t] /. 
    NDSolve[{V'[
        t] == (-((
           4 l L nL0 \[Pi] Csch[((3/\[Pi])^(1/3) V[t]^(1/3))/(
             2^(2/3) l)] (-l^2 Sinh[((3/\[Pi])^(1/3) V[t]^(1/3))/(
                2^(2/3) l)] + (
              l (3/\[Pi])^(1/3)
                Cosh[((3/\[Pi])^(1/3) V[t]^(1/3))/(2^(2/3) l)] V[t]^(
               1/3))/2^(2/3)))/(-l - 
            L Coth[((3/\[Pi])^(1/3) V[t]^(1/3))/(
              2^(2/3) l)] + ((3/\[Pi])^(1/3)
              Coth[((3/\[Pi])^(1/3) V[t]^(1/3))/(2^(2/3) l)] V[t]^(
             1/3))/2^(2/3))) - nc V[t]) /tauG  + 
        1/tauS*(1 - VinitR[t]/Vinitphi)/phi0 - 
        1/tauC*(1 - (1 - (Vphi[t]/V[t]))^2)*
         V[t]^(2/3)*(-((
           2 (Vphi[t]/V[t]) (-2 + 2 (1 - (Vphi[t]/V[t])) + 
              phic) (-(Vphi[t]/V[t]) + phic))/(1 - phic)^2)), 
      V[0] == 1, 
      Vphi'[
        t] == ((-((
            4 l L nL0 \[Pi] Csch[((3/\[Pi])^(1/3) V[t]^(1/3))/(
              2^(2/3) l)] (-l^2 Sinh[((3/\[Pi])^(1/3) V[t]^(1/3))/(
                 2^(2/3) l)] + (
               l (3/\[Pi])^(1/3)
                 Cosh[((3/\[Pi])^(1/3) V[t]^(1/3))/(2^(2/3) l)] V[t]^(
                1/3))/2^(2/3)))/(-l - 
             L Coth[((3/\[Pi])^(1/3) V[t]^(1/3))/(
               2^(2/3) l)] + ((3/\[Pi])^(1/3)
               Coth[((3/\[Pi])^(1/3) V[t]^(1/3))/(2^(2/3) l)] V[t]^(
              1/3))/2^(2/3))) - nc V[t]) (Vphi[t]/V[t]))/tauG  + 
        1/tauS*(1 - VinitR[t]/Vinitphi), Vphi[0] == phi0, 
      VinitR'[t] == 1/tauS*(1 - VinitR[t]/Vinitphi), 
      VinitR[0] == VinitR0}, {V}, {t, 0, 170}]]]

Manipulate[
 Plot[Evaluate@({model[Vinitphi, l, nc, phic, tauC, tauG, tauS][t]}), {t, 0,
    170}], {{Vinitphi, 10^5}, 10^5, 2*10^6, 
  Appearance -> "Labeled"}, {{l, 5}, 5, 40, 
  Appearance -> "Labeled"}, {{nc, 0.3}, 0.3, 0.6, 
  Appearance -> "Labeled"}, {{phic, 0.6}, 0.6, 75, 
  Appearance -> "Labeled"}, {{tauC, 0.1}, 0.1, 1.5, 
  Appearance -> "Labeled"}, {{tauG, 1}, 1, 20, 
  Appearance -> "Labeled"}, {{tauS, 10^(-5)}, 10^(-5), 10^(-4), 
  Appearance -> "Labeled"}]

I'm getting the error :

NDSolve::ndnum: Encountered non-numerical value for a derivative at t$174887 == 0.`.

Could you help me please ?

$\endgroup$
2
$\begingroup$

ParametricNDSolve is designed for your purpose.

Clear[l, L, nc, phic, tauC, tauG, tauS, phi0, Vinitphi, Vphi0, nL0, \
V, Vphi, VinitR, VinitR0, dV, V0, Vphi0, pfun]
VinitR0 = 0;
L = 6000;
nL0 = 1;
phi0 = 0.4;
pfun = ParametricNDSolve[{V'[
      t] == (-((4 l L nL0 \[Pi] Csch[((3/\[Pi])^(1/3) V[
                    t]^(1/3))/(2^(2/
                    3) l)] (-l^2 Sinh[((3/\[Pi])^(1/3) V[
                    t]^(1/3))/(2^(2/3) l)] + (l (3/\[Pi])^(1/
                    3) Cosh[((3/\[Pi])^(1/3) V[
                    t]^(1/3))/(2^(2/3) l)] V[t]^(1/3))/2^(2/3)))/(-l -
               L Coth[((3/\[Pi])^(1/3) V[
                    t]^(1/3))/(2^(2/3) l)] + ((3/\[Pi])^(1/
                    3) Coth[((3/\[Pi])^(1/3) V[
                    t]^(1/3))/(2^(2/3) l)] V[t]^(1/3))/2^(2/3))) - 
         nc V[t])/tauG + 1/tauS*(1 - VinitR[t]/Vinitphi)/phi0 - 
      1/tauC*(1 - (1 - (Vphi[t]/V[t]))^2)*
       V[t]^(2/3)*(-((2 (Vphi[t]/V[t]) (-2 + 2 (1 - (Vphi[t]/V[t])) + 
               phic) (-(Vphi[t]/V[t]) + phic))/(1 - phic)^2)), 
    V[0] == 1, 
    Vphi'[t] == ((-((4 l L nL0 \[Pi] Csch[((3/\[Pi])^(1/3) V[
                    t]^(1/3))/(2^(2/
                    3) l)] (-l^2 Sinh[((3/\[Pi])^(1/3) V[
                    t]^(1/3))/(2^(2/3) l)] + (l (3/\[Pi])^(1/

                       3) Cosh[((3/\[Pi])^(1/3) V[
                    t]^(1/3))/(2^(2/3) l)] V[t]^(1/3))/2^(2/3)))/(-l -
                 L Coth[((3/\[Pi])^(1/3) V[
                    t]^(1/3))/(2^(2/3) l)] + ((3/\[Pi])^(1/
                    3) Coth[((3/\[Pi])^(1/3) V[
                    t]^(1/3))/(2^(2/3) l)] V[t]^(1/3))/2^(2/3))) - 
           nc V[t]) (Vphi[t]/V[t]))/tauG + 
      1/tauS*(1 - VinitR[t]/Vinitphi), Vphi[0] == phi0, 
    VinitR'[t] == 1/tauS*(1 - VinitR[t]/Vinitphi), 
    VinitR[0] == VinitR0}, {V}, {t, 0, 170}, {Vinitphi, l, nc, phic, 
    tauC, tauG, tauS}];
Manipulate[
 Plot[Evaluate@({(V[Vinitphi, l, nc, phic, tauC, tauG, tauS] /. pfun)[
      t]}), {t, 0, 170}, PlotRange -> All], {{Vinitphi, 10^5}, 10^5, 
  2*10^6, Appearance -> "Labeled"}, {{l, 5}, 5, 40, 
  Appearance -> "Labeled"}, {{nc, 0.3}, 0.3, 0.6, 
  Appearance -> "Labeled"}, {{phic, 0.6}, 0.6, 75, 
  Appearance -> "Labeled"}, {{tauC, 0.1}, 0.1, 1.5, 
  Appearance -> "Labeled"}, {{tauG, 1}, 1, 20, 
  Appearance -> "Labeled"}, {{tauS, 10^(-5)}, 10^(-5), 10^(-4), 
  Appearance -> "Labeled"}]

Manipulate Pic

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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