# Contour Plot using NDSolve

I want to make a contour plot of the function $S$ using the following code taking $x$-asis along the horizontal and $y$-axis along vertical.

lam = 5.0;
gma = 0.5;
zeta = 2.0;
a = 0.5;
b = 2.0;
(*x=0.4;*)
t = 0.2;
Q0 = 1.0;
alp = 0.5;
F = Q0*Exp[-alp*t];
h = 1.0 - (a*Cos[Pi*(x - t)]*Cos[Pi*(x - t)]);
sys1 = {s''[
y] == (lam/2.0)^2.0*(Sinh[
4.0*s[y]]/(1.0 + 4.0*gma*Sinh[2.0*s[y]]*Sinh[2.0*s[y]]))};
iv1 = {s[-h] == zeta, s[h] == zeta};
sol[x_] := NDSolve[Join[sys1, iv1], s, {y, -1, 1}]
ContourPlot[Evaluate[s[y] /. sol], {x, 0, 1}, {y, 0, 1}]

• I'm encouraging you to focus on making NDSolve return anything at all. You need to take care about passing x from sol[x_] inside h. Since you defined sol as a function you need to use it as such ... /. sol does not make sense in this context. Once you have basic issues solved it should be easy to use it for a ContourPlot
– Kuba
Jul 18, 2017 at 12:44
• Could you kindly let me know what exactly changes need to be made in the above code to get a contour plot of s? Jul 18, 2017 at 12:52
• s is a function of a single variable? If so, what do you mean by contour plot? Jul 18, 2017 at 14:01
• Yes. I agree with you that s is a function of single variable. But the boundary conditions depend on h which implies boundary conditions depends on x. So we must have a contour which I want to plot. Jul 18, 2017 at 14:04
• @BiswajitMallick. Surely you meant a ContourPlot like that?,because it shows nothing interesting. Jul 18, 2017 at 15:16

ClearAll["Global*"](*Clears all constans*)

lam = 5.0;
gma = 0.5;
zeta = 2.0;
a = 0.5;
b = 2.0;(*x = 0.4*)
t = 0.2;
Q0 = 1.0;
alp = 0.5;
F = Q0*Exp[-alp*t];
h = 1.0 - (a*Cos[Pi*(x - t)]*Cos[Pi*(x - t)]);

sys1 = {s''[y] == (lam/2.0)^2.0*(Sinh[4.0*s[y]]/(1.0 + 4.0*gma*Sinh[2.0*s[y]]*Sinh[2.0*s[y]]))};

iv1 = {s[-h] == zeta, s[h] == zeta};

sol[x_] := NDSolve[Join[sys1, iv1], s, {y, -1, 1}]

Plot[Evaluate[Table[s[y] /. sol[x], {x, 0, 1, 1/10}]], {y, 0, 1},
PlotRange -> All, PlotLegends -> Automatic]

ListPlot3D[Partition[Flatten[Table[
Evaluate[Table[{x, y, (s[y] /. sol[x])[[1]]}, {x, 0, 1, 1/20}]], {y, 0, 1,1/20}]], 3]]

ListContourPlot[Partition[Flatten[Table[
Evaluate[Table[{x, y, (s[y] /. sol[x])[[1]]}, {x, 0, 1, 1/30}]], {y, 0, 1,1/30}]], 3], PlotLegends -> Automatic,FrameLabel -> {X, Y}]


I'm edited in yours actual code.`

• Thank you so much. Thank you for your kind help. Jul 19, 2017 at 4:48