I am trying to solve a set of PDE equations with parameters of v[z],q[z],T[z,t,r]. Below is my test code where I tried the method of parametricNDSolve but to no avail.

ClearAll["Global`*"] ;
equ = With[{v = v@z, q = q@z, T = T @@ {z, t, r}, p = 1/(1 + T@@ {z, t, r}^(-3/2)), 
A = NIntegrate[p*Exp[-q*r^2] r, {r, 0, \[Infinity]}],  B = NIntegrate[p*Exp[-2 q*r^2] r, {r, 0, \[Infinity]}]},
{-v D[q, z] + q*D[v, z] == -q^2*v*A,
-v*D[q, z] + 2 q*D[v, z] == -4*q^2*v*B,
D[T + (p + 1) v^2 Exp[-2 q r^2], t] + 1/r D[r*p*v^2 Exp[-2 q r^2], r] + D[p*v^2 Exp[-2 q r^2],z] == p*v^2 Exp[-2 q r^2]}]

ic = {v[0] == 1, q[0] == 1, T[0, 0, 0] == 1}
{vsol,qsol,Tsol}=ParametricNDSolveValue[{equ, ic}, {v, q, T}, {z, 0, 10}, {t, r}]

Can anyone help me out? Thanks.

  • 1
    $\begingroup$ NIntegrate can not integrate NIntegrate[p*Exp[-q*r^2] r, {r, 0, \[Infinity]}] with undefined q. Same thing for B $\endgroup$ Apr 20, 2021 at 9:48
  • $\begingroup$ Even if q should be solve numerically? Thus, is it the problem of NIntegrate in mma? No way around in mma? $\endgroup$
    – sixpenny
    Apr 20, 2021 at 10:21
  • 1
    $\begingroup$ NIntegrate can only integrate numerical functions. Non numerical functions may be integrated using Integrate $\endgroup$ Apr 20, 2021 at 10:47
  • $\begingroup$ Thanks a lot @DanielHuber $\endgroup$
    – sixpenny
    Apr 20, 2021 at 12:52
  • $\begingroup$ @sixpenny Where did you get this system? Is initial condition T[0,0,0]==1 means T[z,0,r]==1? $\endgroup$ Apr 20, 2021 at 17:20

1 Answer 1


Here is my attempt, based on the code you provided. I first replaced the formula you had for p directly in the set of equations, as it depended on T[z,t,r].

As pointed out by @Daniel Huber, you should use Integrate in A and B, with the assumption that $q>0$ for convergence.

Following the answer in this question, you should be able to solve your set of equations assuming q and v also depend on (z,t,r), not just on z.

Since you don't have any parameter, I use NDSolveValue instead of ParameterNDSolveValue. You will have some warning messages, but NDSolve will go through and give you some interpolating function, that you can visualise with SliceContourPlot3D.

Please, tell me if this can help you. Cheers

equ = With[{v = v @@ {z, t, r}, q = q @@ {z, t, r}, T = T @@ {z, t, r}, 
   A = Integrate[r*Exp[-q[z, t, r]*r^2]/(1 + T[z, t, r]^(-3/2)), {r, 0, Infinity},
      Assumptions -> q[z, t, r] > 0], B = Integrate[r*Exp[-2 q[z, t, r]*r^2]/(1 + T[z, t, r]^(-3/2)), {r, 0, Infinity}, Assumptions -> q[z, t, r] > 0]}, {-v D[q, z] + 
     q*D[v, z] == -q^2*v*A, -v*D[q, z] + 2 q*D[v, z] == -4*q^2*v*B, 
   D[T + (1/(1 + T^(-3/2)) + 1) v^2 Exp[-2 q r^2], t] + 
     1/r D[r*(1/(1 + T^(-3/2)))*v^2 Exp[-2 q r^2], r] + 
     D[(1/(1 + T^(-3/2)))*v^2 Exp[-2 q r^2], z] == (1/(1 + T^(-3/2)))*
     v^2 Exp[-2 q r^2]}]
ic = {v[0, t, r] == 1, q[0, t, r] == 1, T[0, t, r] == 1}
{vsol, qsol, Tsol} =  NDSolveValue[{equ, ic}, {v, q, T}, {z, 0, 10}, {t, 0, 10}, {r, 0.1,10}]
SliceContourPlot3D[vsol[z, t, r], "ZStackedPlanes", {z, 0, 10}, {t, 0, 10}, {r, 0.1,10}]
  • $\begingroup$ Thanks a lot @Free_ion, I will try your code in the more complex and real physical equations. By the way, it might be (?) v=v[z,t] and q=q[z,t], although T=T[z,t,r] $\endgroup$
    – sixpenny
    Apr 20, 2021 at 13:05
  • $\begingroup$ There is a message NDSolveValue::ndcf: Repeated convergence test failure at z == 0.; unable to continue.. It means that this solution defined only in domain {{0,0},{0,10}, {0.1,10}}. Also integrals A, B` ignored by NDSolve, therefore with this code we solve system of PDE, and not integrodifferential equations. $\endgroup$ Apr 20, 2021 at 17:04

Your Answer

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

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