1
$\begingroup$

I am not able to obtain any plot with the following code.

P = ParametricNDSolve[{(ϵ Cos[x] (κ (1 + ϵ Sin[x]) - 
     Tanh[κ (1 + ϵ Sin[x])] - κ (1 + ϵ Sin[x]) Tanh[κ (1 + ϵ Sin[
            x])]^2 + κ (1 + ϵ Sin[x])^4 Derivative[1][
       p][x]))/(κ (1 + ϵ Sin[x])^2) + 
  2/3 (1 + ϵ Sin[x])^3 (p^′′)[x] == 0, p[0] == 0, p[1] == 0}, p, {x, 0, 1}, {ϵ, κ}, 
 Method -> {"Shooting", "StartingInitialConditions" -> {p[0] == 0, p'[0] == 1}}]

Plot[P[0.8, 100][x], {x, 0, 1}]

What is wrong with my code?

$\endgroup$

2 Answers 2

1
$\begingroup$

You have syntax errors in specifying derivatives. Further,"ParametricNDSolve" returns a rules, not a function.

Here is the corrected code:

sol = p /. 
  ParametricNDSolve[{(ϵ Cos[
          x] (κ (1 + ϵ Sin[x]) - 
           Tanh[κ (1 + ϵ Sin[
                 x])] - κ (1 + ϵ Sin[
                x]) Tanh[κ (1 + ϵ Sin[
                   x])]^2 + κ (1 + ϵ Sin[x])^4 p' [
             x]))/(κ (1 + ϵ Sin[x])^2) + 
      2/3 (1 + ϵ Sin[x])^3 p''[x] == 0, p[0] == 0, 
    p[1] == 0}, p, {x, 0, 1}, {ϵ, κ}, 
   Method -> {"Shooting", 
     "StartingInitialConditions" -> {p[0] == 0, p'[0] == 1}}]

Plot[sol[0.8, 100][x], {x, 0, 1}]

enter image description here

$\endgroup$
0
$\begingroup$

"ShootingMethod" isn't necessary, try

P = ParametricNDSolveValue[{(\[Epsilon] Cos[
         x] (\[Kappa] (1 + \[Epsilon] Sin[x]) - 
          Tanh[\[Kappa] (1 + \[Epsilon] Sin[
                x])] - \[Kappa] (1 + \[Epsilon] Sin[
               x]) Tanh[\[Kappa] (1 + \[Epsilon] Sin[
                  x])]^2 + \[Kappa] (1 + \[Epsilon] Sin[x])^4 p'[
            x]))/(\[Kappa] (1 + \[Epsilon] Sin[x])^2) + 
     2/3 (1 + \[Epsilon] Sin[x])^3 p''[x] == 0, p[0] == 0, p[1] == 0},
   p, {x, 0, 1}, {\[Epsilon], \[Kappa]}]
Plot[P[0.8, 100][x], {x, 0, 1}]

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.