1
$\begingroup$

I have an equation to solve using NDSolve which involves two parameters: $en$ and $k$. The equation produces a set of curves when $en$ is plotted against $k$. In order to isolate the curves, I have currently defined a load of rectangular regions for NDSolve to work within (which each contain part of only ONE curve - I get problems if there is more than one in a region). I do know however, that all the curves lie within curved regions defined by a parabola and my code would be much simpler if I could use regions such as $\left \{ k,0,4 \right \}, \left \{ en, f1(k),f2(k) \right \}$ where the $f$'s are the known parabolas as functions of $k$ . Is there any way to get NDSolve to work within a curved grid when finding the solutions?

The code I have:

L = 8; Clear[k, en]; Clear[uall]; 
solution1 = 
NDSolve[{-D[uall[x, en, k], x, x] + ((x - k)^2 - en(*+V[x]*)) uall[x,
    en, k] == 0., uall[0, en, k] == 0, 
Derivative[1, 0, 0][uall][0, en, k] == 1}, 
uall, {x, 0, L}, {en, 1.8, 3.6}, {k, -.1, 0.6}]; 
solution2 = 
NDSolve[{-D[uall[x, en, k], x, x] + ((x - k)^2 - en(*+V[x]*)) uall[x,
    en, k] == 0., uall[0, en, k] == 0, 
Derivative[1, 0, 0][uall][0, en, k] == 1}, 
uall, {x, 0, L}, {en, .95, 2.}, {k, 0.57, 1.05}]; 
solution3 = 
NDSolve[{-D[uall[x, en, k], x, x] + ((x - k)^2 - en(*+V[x]*)) uall[x,
    en, k] == 0., uall[0, en, k] == 0, 
Derivative[1, 0, 0][uall][0, en, k] == 1}, 
uall, {x, 0, L}, {en, .95, 1.5}, {k, .95, 2.7}]; 
solution4 = 
NDSolve[{-D[uall[x, en, k], x, x] + ((x - k)^2 - en(*+V[x]*)) uall[x,
    en, k] == 0., uall[0, en, k] == 0, 
Derivative[1, 0, 0][uall][0, en, k] == 1}, 
uall, {x, 0, L}, {en, .9, 1.2}, {k, 2.5, 4.1}];
(*Set up previous calculations as function with k as an argument*)
Eofk1[k_] := 
  en /. FindRoot[(uall[8, en, k] /. solution1) == 0, {en, 2.4}];
Eofk2[k_] := 
  en /. FindRoot[(uall[8, en, k] /. solution2) == 0, {en, 2.00}];
Eofk3[k_] := 
  en /. FindRoot[(uall[8, en, k] /. solution3) == 0, {en, 1.2}];
Eofk4[k_] := 
  en /. FindRoot[(uall[8, en, k] /. solution4) == 0, {en, 1.001}];
(*Plot the dispersion en(k) by using the function defined in the \
relevant ranges*)
c1 = Plot[Eofk1[k], {k, -.05, .58}, 
  PlotRange -> {{-0.05, 5.}, {0, 12.}}, 
  PlotStyle -> {RGBColor[1, 0, 0]}];
c2 = Plot[Eofk2[k], {k, .58, 1.}, PlotRange -> {{-0., 5.}, {0, 12.}}, 
  PlotStyle -> {RGBColor[1, 0, 0]}];
c3 = Plot[Eofk3[k], {k, 1.0, 2.6}, PlotRange -> {{0, 5}, {0, 12.}}, 
  PlotStyle -> {RGBColor[1, 0, 0]}];
c4 = Plot[Eofk4[k], {k, 2.6, 4.0}, PlotRange -> {{-0., 5.}, {0, 12.}},
  PlotStyle -> {RGBColor[1, 0, 0]}];
Show[c1, c2, c3, c4]
$\endgroup$
3
  • 2
    $\begingroup$ Please, add the code you are working on. $\endgroup$
    – Sektor
    Oct 18, 2013 at 8:34
  • 1
    $\begingroup$ Sorry, done that now. $\endgroup$
    – Kris
    Oct 18, 2013 at 13:12
  • $\begingroup$ If it's a linear pde, you can use FEM and ImplicitRegion. See mathematica.stackexchange.com/questions/39402/… for an example. $\endgroup$
    – Michael E2
    Mar 6, 2015 at 11:28

1 Answer 1

1
$\begingroup$

You can analytically solve that problem by using hypergeometric functions. There is no need to specify a curved region for NDSolve.

L = 8; Clear[k, en]; Clear[uall];

solution = DSolve[{-D[uall[x, en, k], x, x] + ((x - k)^2 - en) uall[x, en, k] ==
0., uall[0, en, k] == 0, Derivative[1, 0, 0][uall][0, en, k] == 1.}, uall, {x, en, k}];

Eofk1[k_] := en /. FindRoot[(uall[8, en, k] /. solution) == 0, {en, 1.2}];

Plot[Eofk1[k], {k, -.05, 4.}, PlotRange -> {{-0.05, 5.}, {0, 4.}}]

Note: the solution takes around 2 min to evaluate on Mathematica 10.0.2.

Solution of FindRoot

$\endgroup$
1
  • $\begingroup$ Thanks, that's extremely pleasing. I may have to go and teach myself about hypergeometric functions. $\endgroup$
    – Kris
    Apr 5, 2015 at 15:58

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.