# Error from NDSolve “Cannot find starting value for the variable” I need help regarding this code. I have used NDSolve to find a solution.

F = Θ + a*Sin[2*π*(x - t)] +
b*Sin[2*π*(x - t) + ϕ];
N1 = Sqrt[M^2 + (1/k)];
t = 0.4;
a = 0.2;
b = 0.3;
m = 0.15;
ϕ = π/3;
M = 1;
k = 3;
Nt = 0.8;
Nb = 1;
Pr = 2;
L = 0.1;
Bm = 1;
Bh = 0.5;
Θ = 1.6;
Gr = 1.2;
Br = 0.8;
ζ = 0.02;
Rn = 0.75;
h1 = -1 - m*x - a*Sin[2*π*(x - t) + ϕ]
h2 = 1 + m*x + b*Sin[2*π*(x - t)]
sol = NDSolve[{ψ''''[
y] - ζ*(6 ψ''[y] *ψ'''[y]*ψ'''[y] +
3 ψ''[y]*ψ''[y]* ψ''''[y]) - N1*N1*ψ''[y] +
Gr*θ'[y] + Br*σ'[y] ==
0, (1 + Pr*Rn)*θ''[y] + Nb*Pr*σ'[y]*θ'[y] +
Nt*Pr*θ'[y]*θ'[y] ==
0, σ''[y] + Nt/Nb*θ''[y] == 0, ψ[h2] == F/
2, ψ[h1] == -(F/2), ψ'[h1] == 0, ψ'[h2] ==
0, σ'[h1] == Bm*σ[h1], σ'[h2] ==
Bm*(1 - σ[h2]), θ'[h1] ==
Bh*θ[h1], θ'[h2] ==
Bh*(1 - θ[h2])}, {ψ, θ, σ}, {y, h1, h2}]


I get the following error

NDSolve::ndsv: Cannot find starting value for the variable θ.

Why do I get this error for θ but not ψ or σ? Further i have used the same code for velocity graphs and they turned out really great without any errors

F = Θ + a*Sin[2*π*(x - t)] +
b*Sin[2*π*(x - t) + ϕ];
N1 = Sqrt[M^2 + (1/k)];
x = 0.4;
t = 0.2;
a = 0.3;
b = 0.4;
m = 0.25;
ϕ = 2 π/3;
M = 1;
k = 0.8;
Nt = 0.8;
Nb = 0.4;
Pr = 0.2;
Bm = 4;
Bh = 2;
Θ = 1.5;
Gr = 0.7;
Br = 0;
ζ = 0.002;
Rn = 0.6;
h1 = -1 - m*x - a*Sin[2*π*(x - t) + ϕ]
h2 = 1 + m*x + b*Sin[2*π*(x - t)]
sol = NDSolve[{ψ''''[
y] - ζ*(6 ψ''[y] *ψ'''[y]*ψ'''[y] +
3 ψ''[y]*ψ''[y]* ψ''''[y]) -
N1*N1*ψ''[y] + Gr*θ'[y] + Br*σ'[y] ==
0, (1 + Pr*Rn)*θ''[y] + Nb*Pr*σ'[y]*θ'[y] +
Nt*Pr*θ'[y]*θ'[y] ==
0, σ''[y] + Nt/Nb*θ''[y] == 0, ψ[h2] == F/
2, ψ[h1] == -(F/2), ψ'[h1] == 0, ψ'[h2] ==
0, σ'[h1] == Bm*σ[h1], σ'[h2] ==
Bm*(1 - σ[h2]), θ'[h1] ==
Bh*θ[h1], θ'[h2] ==
Bh*(1 - θ[h2])}, {ψ, θ, σ}, {y, h1, h2}];
A1 = Plot[Evaluate[D[ψ[y], y] /. sol], {y, h1, h2},
PlotRange -> All,
PlotStyle -> {Darker[Blue, 0.5], Thickness[0.004]},
AxesOrigin -> Automatic,
BaseStyle -> {FontFamily -> "Times", FontSize -> 15},
FrameLabel -> {"y", "u"}, Frame -> True, Axes -> False]


My final goal is to make a ContourPlot of the form

ContourPlot[ψ[y], {y, -2, 2}, {x, 0, 2}, Contours -> 60,
ColorFunction -> (Hue[#] &), ClippingStyle -> Automatic]

• I need help regarding this code.i am unable to run it on mathematica to find contourplots.please help.. i have used NDSolve to find solution.. – Anonymous Oct 28 '15 at 4:55
• Where are you stuck? What kind of error message are you getting? Is the problem with ContourPlot or with NDSolve? – Jason B. Oct 28 '15 at 7:58
• I am getting this error. – Anonymous Oct 28 '15 at 9:20
• NDSolve::ndsv: Cannot find starting value for the variable [Theta]. >> – Anonymous Oct 28 '15 at 9:21
• So that means that your system of differential equations isn't enough to find a solution - it needs some kind of boundary condition for theta – Jason B. Oct 28 '15 at 9:22

Okay so your NDSolve won't run unless you have x defined, but you want to make a ContourPlot with x as one of the axes. So you need to make a Table, where for every value of x you rerun the NDSolve and then make a Table where you run over the y values.

But there is a hitch, since the domain on which your NDSolve is valid is different for every value of x - so your data won't be rectangular, nor will your contour plot.

sol[x_] :=
Module[{F, t, N1, a, b, m, ϕ, M, k, Nt, Nb, Pr, L, Bm,
Bh, Θ, Gr, Br, Rn, h1, h2, sol, ζ},
F = Θ + a*Sin[2*π*(x - t)] +
b*Sin[2*π*(x - t) + ϕ];
N1 = Sqrt[M^2 + (1/k)];
t = 0.4;
a = 0.2;
b = 0.3;
m = 0.15;
ϕ = π/3;
M = 1;
k = 3;
Nt = 0.8;
Nb = 1;
Pr = 2;
L = 0.1;
Bm = 1;
Bh = 0.5;
Θ = 1.6;
Gr = 1.2;
Br = 0.8;
ζ = 0.02;
Rn = 0.75;
h1 = -1 - m*x - a*Sin[2*π*(x - t) + ϕ];
h2 = 1 + m*x + b*Sin[2*π*(x - t)];
sol = NDSolve[{ψ''''[
y] - ζ*(6 ψ''[y]*ψ'''[y]*ψ'''[y] +
3 ψ''[y]*ψ''[y]*ψ''''[y]) -
N1*N1*ψ''[y] + Gr*θ'[y] + Br*σ'[y] == 0,
(1 + Pr*Rn)*θ''[y] + Nb*Pr*σ'[y]*θ'[y] +
Nt*Pr*θ'[y]*θ'[y] ==
0, σ''[y] + Nt/Nb*θ''[y] == 0, ψ[h2] ==
F/2, ψ[h1] == -(F/2), ψ'[h1] == 0,
ψ'[h2] == 0,
σ'[h1] == Bm*σ[h1],
σ'[h2] == Bm*(1 - σ[h2]),
θ'[h1] == Bh*θ[h1],
θ'[h2] == Bh*(1 - θ[h2])}
, {ψ, θ, σ}, {y, h1, h2}];
{h1, h2, sol}
];


Generate the data

Monitor[
data = Flatten[
Table[
{h1, h2, funcs} = sol[x];
Table[
{x, y, Last@(ψ[y] /. funcs)}
, {y, h1, h2, .05}]

, {x, 0, 2, .05}]
, 1];
, {x, y}]


and plot it

ListContourPlot[data, Contours -> 60, ColorFunction -> (Hue[#] &),
ClippingStyle -> Automatic] • You might want to explicitly note that Parula is not a built-in Mathematica color gradient. – J. M.'s technical difficulties Oct 28 '15 at 12:24
• Yeah, I'll just take that part out, not really relevant to the issue at hand – Jason B. Oct 28 '15 at 12:43
• well thanks a lot for your help :). I really appreciate that :)..Actually i want streamlines like these... I have added them in the question – Anonymous Oct 29 '15 at 4:38
• @Anonymous, the differential equations you provided do not generate the plot that you showed - they generate the plot I made. I wish you luck in finding out why not. – Jason B. Oct 29 '15 at 7:57
• @JasonB hmm Thanks a lot for your help :) I appreciate you taking out time to help me. – Anonymous Oct 30 '15 at 4:21