Message Boards Message Boards

ParametricNDSolve error: Dependent variables cannot depend on parameters

Posted 5 months ago

I'm trying to solve numerically this system of non linear DEs and there's some trouble with the numerical solution of the last differential equation, because while running the last line of the code that uses

`ParametricNDSolveValue` appears the followin message ParametricNDSolveValue::pdvar: Dependent variables {G,F[t,a,b]} cannot depend on parameters {a,b}.

I'm not quite sure about the evaluation in the F function but I tried. Here's the code:

t0 = 7;
u0 = 1.0;
v0 = -0.5;
z0 = Sin[t0];
sol = ParametricNDSolveValue[{
    u'[x] == -Log[10] (-u[x] + a v[x]),
    v'[x] == -Log[10] (u[x] - (a w[x])^2),
    w'[x] == -Log[10] (w[x] (1 + a) - Cos[x]),
    z'[x] == -Log[10] (4 a Sin[x]),
    u[7] == u0, v[7] == v0, w[7] == w0, z[7] == z0}, {u, v, w, z}, {x,
     7, -2}, {a}, MaxSteps -> Infinity];
dynsys[x_?NumericQ, a_?NumericQ] := sol[a][x];
x[t_] := Log[1 + t]/Log[10];
F[t_?NumericQ, a_, ?NumericQ, b_?NumericQ] := 
  Sqrt[(b (1 + t)^3)/(
   1 - u[x[t]]^2 - v[x[t]]^2 - w[x[t]]^2 - z[x[t]]^2)] /. 
   dynsys[x[t], a][[1]];
Gsol = ParametricNDSolveValue[{G'[t]/(1 + t) - G[t]/(1 + t)^2 - 1/
      F[t, a, b] == 0, G[0] == 0}, {G}, {t, 0, 3}, {a, b}, 
   MaxSteps -> Infinity];
POSTED BY: Carles Lopez
3 Replies

This works:

t0 = 7;
u0 = 1;
v0 = -1/2; w0 = 1;
z0 = Sin[t0];
sol = ParametricNDSolve[{u'[x] == -Log[10] (-u[x] + a v[x]), 
    v'[x] == -Log[10] (u[x] - (a w[x])^2),
    w'[x] == -Log[10] (w[x] (1 + a) - Cos[x]),
    z'[x] == -Log[10] (4 a Sin[x]),
    u[7] == u0, v[7] == v0, w[7] == w0, z[7] == z0},
   {u, v, w, z}, {x, 7, -2}, {a},
   MaxSteps -> Infinity];
x[t_] := Log[1 + t]/Log[10];
F[t_, a_, b_] :=  Sqrt[(b (1 + t)^3)/(1 - u[a][x[t]]^2 -
       v[a][x[t]]^2 -
       w[a][x[t]]^2 - z[a][x[t]]^2)] /. sol;
Gsol = ParametricNDSolveValue[{G'[t]/(1 + t) -
     G[t]/(1 + t)^2 - 1/F[t, a, b] == 0, G[0] == 0},
  G, {t, 0, 3}, {a, b}, MaxSteps -> Infinity]
POSTED BY: Gianluca Gorni
Posted 5 months ago
  1. w0 is not defined.
  2. The "x" in u[x],v[x],w[x] and z[x] is an independent parameter (e.g., "x" is similar to "t" in ODE) but you again used the "x" as a state or dependent variable (i.e., x[t]:= Log[1 + t]/Log[10]). Thus x in u[x] and x in x[t] are mixed up. x[t] := Log[1 + t]/Log[10];
  3. The following ODE is working:

    t0 = 7.0;
    u0 = 1.0;
    v0 = -0.5;
    w0 = 0.0 (* newly added *);
    z0 = Sin[t0];
    
    sol = ParametricNDSolve[{
       u'[t] == -Log[10] (-u[t] + a v[t]),
       v'[t] == -Log[10] (u[t] - (a w[t])^2),
       w'[t] == -Log[10] (w[t] (1 + a) - Cos[t]),
       z'[t] == -Log[10] (4 a Sin[t]),
       u[7] == u0, v[7] == v0, w[7] == w0, z[7] == z0},
      {u, v, w, z},
      {t, 7, 10},
      {a},
      MaxSteps -> Infinity]
    
    Plot[v[0.0001][t] /. sol, {t, 7, 10}]
    
    Plot[#, {t, 7, 10}] & /@ {u[0.0001][t] /. sol,
      v[0.0001][t] /. sol,
      w[0.0001][t] /. sol,
      z[0.0001][t] /. sol}
    
POSTED BY: Sangdon Lee
Posted 5 months ago

Thanks for the feedback! The x[t] := Log[1 + t]/Log[10] is more of a rescaling for the F function in order to be used in the second DE. Could that be done in another way?

POSTED BY: Carles Lopez
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract