I am trying to solve the following system of Hamilton-Jacobi PDE's:

$ V_1,_t - 0.5 V_1,_x^2/(1 - 0.2x)^2 + V_1,_x(0.1x^2+0.03x+.0.01)/(1 - 0.2x)+0.03(x-0.5)^2-V_1,_x V_2,_x/(1 - 0.2x)^2=0$
$ V_2,_t - 0.5 V_2,_x^2/(1 - 0.2x)^2 + V_2,_x(0.1x^2+0.03x+.0.01)/(1 - 0.2x)+0.02(x-0.5)^2-V_1,_x V_2,_x/(1 - 0.2x)^2=0$
With terminal time conditions: $V_1(T,x)=0, V_2(T,x)=0$, where T is some final time and x is scalar.
I am not an expert, but my code is:

(* PDE *)
(* v1[x,t] v2[x,t] *)

pdeF = D[v1[x, t], t] - 
   0.5*(D[v1[x, t], x])^2/(1 - 0.2*x)^2 + (D[v1[x, t], 
      x])*(0.03*x + 0.1*x^2 + 0.01 - 0)/(1 - 0.2*x) + 
   0.06*(x - 0.5)^2 - (D[v1[x, t], x])*(D[v2[x, t], x])/(1 - 0.2*x)^2 == 0

pdeM = D[v2[x, t], t] - 
   0.5*(D[v2[x, t], x])^2/(1 - 0.2*x)^2 + (D[v2[x, t], 
      x])*(0.03*x + 0.1*x^2 + 0.01 - 0)/(1 - 0.2*x) + 
   0.04*(x - 0.5)^2 - (D[v1[x, t], x])*(D[v2[x, t], x])/(1 - 0.2*x)^2 == 0

solution = 
 NDSolve[{pdeF, pdeM, v1[x, 5] == 0, v2[x, 5] == 0}, {v1[x, t], 
   v2[x, t]}, {x, 0, 1.2}, {t, 0, 5}]
NDSolve::bcart: Warning: an insufficient number of boundary conditions have been specified 
 for the direction of independent variable d. Artificial boundary effects may be present 
 in the solution. >>

When I solve it for t=[0,5] everything seems to work, however when I use larger horizon e.g. t=[0,10] or greater, it just crashes. It makes the classic error sound of windows, and then all cells seem to have been reset like i just opened the program.
Any thoughts about that? Also, if anyone has another suggestion in order to solve this system in Mathematica or other software is more than welcome, as I need to get it done asap!
Thank you all in advance, Cheers!

  • 1
    $\begingroup$ Boundary conditions are needed at x = 0 or x = 1.2. $\endgroup$ – bbgodfrey Nov 13 '15 at 5:11

Modifying the code to include the missing boundary conditions (chosen somewhat arbitrarily in the absence of additional information) that I mentioned in my comment above,

tmax = 10;
solution = NDSolveValue[{pdeF, pdeM, v1[x, tmax] == 0, v2[x, tmax] == 0, 
    v1[0, t] == 0, v2[0, t] == 0}, {v1,  v2}, {x, 0, 1.2}, {t, 0, tmax}, 
    Method -> {"MethodOfLines", "TemporalVariable" -> t}];

yields the result

Plot3D[Evaluate[Through[solution[x, t]]], {x, 0, 1.2}, {t, 0, tmax}, 
    AxesLabel -> {x, t, v}, PlotRange -> All]

enter image description here

The Method specification is necessary to tell NDSolve that t is the temporal variable, because the boundary conditions would suggest otherwise. Results are much less satisfactory, if x is assumed to be the temporal variable.

  • $\begingroup$ Firstly, a big thank you for your quick answer @bbgodfrey !! The results you present are pleasing and I can work on that, but still for greater values of tmax, I have the same original crashing problem.. In fact it works until tmax=14, then crashes. Have you witnessed the same or I've done something wrong? $\endgroup$ – Jay Nov 13 '15 at 6:08
  • $\begingroup$ @Jay Works fine for me at tmax = 25, although it becomes unstable by tmax = 50. Numerical instabilities are all too common in such calculations. $\endgroup$ – bbgodfrey Nov 13 '15 at 6:17
  • $\begingroup$ Theoretically though, the conditions on tmax : v1(x,tmax)=0 and v2(x,tmax=0) shouldn't be enough to solve the PDE numerically? As one can go at each fixed x and solve for all t using the conditions provided. Therefore we get the whole 3D surface.. I'm saying that because I believe that the boundary conditions on x=0 affect the solution $\endgroup$ – Jay Nov 13 '15 at 20:31
  • $\begingroup$ @Jay Without the boundary conditions on x, D[v1[x, t], x] and D[v2[x, t], x] cannot be determined at the boundaries. So, if those boundary conditions are not specified, NDSolve sometimes quits and sometimes makes up the needed boundary conditions. Neither is desirable. Furthermore, boundary conditions have physical meaning. Imagine playing a violin with the strings not attached at either end. $\endgroup$ – bbgodfrey Nov 13 '15 at 20:46

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.