2
$\begingroup$

I have been trying out mathematica 10 features, but sadly unable to use NDSolve for even simple PDE's. I am still wrestling with the problem of boundary conditions. The solution I get in the interpolating function doesn't have proper values specified in the boundary conditions. For example if I specify

<< NDSolve`FEM`
DirichletCondition[V[S, t] == 10.0, (S >=  110 && t == 1.0)]

And if i check the boundary condition V[110,1.0] it doesn't give 10.0 as the result. The values don't make sense.

Here's my original problem

 soln = NDSolveValue[
{D[V[S, t], t] + r*S*D[V[S, t], S] + 0.5 sigma^2 S^2 D[V[S,t], {S,2}] - r V[S,t] == 0, 
DirichletCondition[V[S, t] == 20.0, (S >=  110 && t == 2.0)], 
DirichletCondition[V[S, t] == 10.0, (S >=  110 && t == 1.0)],
DirichletCondition[V[S, t] == -Max[80 - S, 0], (S <=  80  && t == 2.0)], 
DirichletCondition[V[S, t] == 0.0, (S > 80 && S < 110 && t == 2.0)]}, 
  V, {S, t} ∈ mesh];


autocall[130, 1.0]
(* 15.3241 *)

which doesn't make any sense!

The condition stated preciely that at t = 1.0 make the value 10.0 for S greater than or equal to 110.0.

I am using the following mesh

ω = ImplicitRegion[True, {{S, 0, 200}, {t, 0, 2.0}}];
mesh = ToElementMesh[ω, MaxCellMeasure -> 0.005 , "MeshOrder" -> 2];

Strangest part is mathematica doesn't give any errors and now I think problem is with the interpolating function which is not satisfying the boundary conditions.

Any clues on how to solve this simple PDE? Have given up partially on this tool after trying various other options...maybe NDSolveValue is not built for such problems.

$\endgroup$
  • 2
    $\begingroup$ What is sigma? When I run your code I get the error "The PDE coefficient {{-1. S+r S,1.}} does not evaluate to a numeric matrix of dimensions {1,2}." $\endgroup$ – Marius Ladegård Meyer Jul 13 '15 at 12:09
  • 2
    $\begingroup$ What's autocall? $\endgroup$ – Feyre Jul 13 '15 at 13:40
  • $\begingroup$ What is r? It would be good if your post contains the code to reproduce the problem. $\endgroup$ – user21 Jul 13 '15 at 19:31
  • $\begingroup$ sigma = 0.20 and r = 0.01 $\endgroup$ – coffeequant Jul 14 '15 at 1:06
  • $\begingroup$ In the mathematica community post you mention that the indexing of the of the LineElement was 'weired' and the documentation was not clear. Could you elaborate a bit on this so that the documentation could be improved? $\endgroup$ – user21 Jul 14 '15 at 6:09
3
$\begingroup$

I think the problem is with your mesh. Note that the "boundary condition" you're having trouble with is not actually on the boundary of the mesh; instead, it's in the interior. You need to explicitly specify that you have a boundary at what would otherwise be "interior" points, and ToBoundaryMesh can help you do that:

mesh = ToBoundaryMesh["Coordinates" -> {{0, 0}, {200, 0}, {200, 1}, {110, 1}, {200, 2}, {0, 2}}, 
         "BoundaryElements" -> {LineElement[{{1, 2}, {2, 3}, {3, 4}, {3, 5}, {5, 6}, {6, 1}}]}]

If I run the above code with this as the mesh and $\sigma = r = 1$ (no idea if this is a valid choice), it does obey the desired boundary condition.

soln[130, 1]

(* 10. *)

For reference, here's what the plot looks like:

enter image description here

This was done, BTW, by mimicking similar code in the Mathematica documentation for NDSolve using finite elements. (Scroll down to the section "Partial Differential Equations with Variable Coefficients" for the example in question; it's not directly related, but the region was similar enough to twig my memory.)

$\endgroup$
  • $\begingroup$ wow...thats what i was looking for. thanks :) $\endgroup$ – coffeequant Jul 14 '15 at 1:06

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.