0
$\begingroup$

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}]
$\endgroup$
5
  • $\begingroup$ 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 $\endgroup$
    – Kuba
    Jul 18, 2017 at 12:44
  • $\begingroup$ Could you kindly let me know what exactly changes need to be made in the above code to get a contour plot of s? $\endgroup$ Jul 18, 2017 at 12:52
  • $\begingroup$ s is a function of a single variable? If so, what do you mean by contour plot? $\endgroup$
    – yohbs
    Jul 18, 2017 at 14:01
  • $\begingroup$ 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. $\endgroup$ Jul 18, 2017 at 14:04
  • $\begingroup$ @BiswajitMallick. Surely you meant a ContourPlot like that?,because it shows nothing interesting. $\endgroup$ Jul 18, 2017 at 15:16

1 Answer 1

0
$\begingroup$
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}]

enter image description here

I'm edited in yours actual code.

$\endgroup$
1
  • $\begingroup$ Thank you so much. Thank you for your kind help. $\endgroup$ Jul 19, 2017 at 4:48

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.