Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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]
share|improve this question
2  
Please, add the code you are working on. –  Sektor Oct 18 '13 at 8:34
1  
Sorry, done that now. –  Kris Oct 18 '13 at 13:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.