1
$\begingroup$

My code

Manipulate[
  Panel[Plot3D[
    Re[H + Amp*Exp[-y*Abs[f]/Sqrt[9.81*H]]*
      Exp[I*(k*x - (Sqrt[9.81*H])*t)]], 
    {x, -80000, 80000}, {y, 0, 100000}, 
    PlotPoints -> 30, MeshStyle -> None, 
    PlotStyle -> 
      Directive[Opacity[0.65], Blue, Specularity[LightBlue, 10]]]], 
  Panel[Dynamic[
    StreamPlot[
      {Sqrt[9.81/H]*
        Re[Amp*Exp[-y*Abs[f]/Sqrt[9.81*H]]*Exp[I*(k*x - ω*t)]], 0}, 
      {x, -80000, 80000}, {y, 0, 100000}]]],
  {{t, 0, "Time {s}"}, 0, 1000},
  {{Amp, 20, "Wave Amplitude"}, 0, H}, 
  {{k, 0, "Waves per Metre (x-direction)"}, 0, 0.0005}, 
  {{H, 100, "Depth"}, 0, 500},
  {{f, 0, "Coriolis Coefficient"}, -0.01, 0.01}]

I keep getting the error:

{2} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing

and

Lists {System`ProtoPlotDump`vectordataextremes$1118273, System` ProtoPlotDump`vectorcolorfunction\$1118273} and !({\"Range\", \ \"ColorFunction\"} /. \"2\") are not the same shape.

I don't know what the problem is. I hope someone can help me identify the issue.

P.S. I am a relative beginner in Mathematica and am trying to plot a Kelvin Wave.

$\endgroup$
  • 1
    $\begingroup$ Your code seems okay here. Have you tried restarting the kernel? $\endgroup$ – Simon Woods Jun 17 '17 at 12:10
  • $\begingroup$ No, I still get the same problem. Have you tried it in your own Mathematica? Does an error come up? $\endgroup$ – Jelmes Jun 17 '17 at 12:30
  • $\begingroup$ I tried it in Mathematica 11.1, it worked with no errors $\endgroup$ – Simon Woods Jun 17 '17 at 12:32
  • $\begingroup$ And did you move the sliders, particulary that of the Coriolis Coefficient? $\endgroup$ – Jelmes Jun 17 '17 at 12:49
  • 1
    $\begingroup$ Works fine here too. Try quitting Mathematica and trying again. $\endgroup$ – bill s Jun 17 '17 at 12:55
2
$\begingroup$

I did not get the error messages you report in your question when I evaluated your code on my system (V11.1.1 running on OS X 10.10.2). I did encounter some other problems. The following minor rewrite seems to work well.

Manipulate[
  Column[{
    Panel[
      Plot3D[
        Re[H + Amp*Exp[-y*Abs[f]/Sqrt[9.81*H]]*Exp[I*(k*x - (Sqrt[9.81*H])*t)]], 
        {x, -80000, 80000}, {y, 0, 100000},
        PlotPoints -> 30, MeshStyle -> None, 
        PlotStyle -> Directive[Opacity[0.65], Blue, Specularity[LightBlue, 10]]]], 
    Panel[
      StreamPlot[
        {Sqrt[9.81/H]*Re[Amp*Exp[-y*Abs[f]/Sqrt[9.81*H]]*
           Exp[I*(k*x - Sqrt[9.81*H]*t)]], 0}, 
        {x, -80000, 80000}, {y, 0,100000}]]}], 
  {{t, 0, "Time {s}"}, 0, 1000},
  {{Amp, 20, "Wave Amplitude"}, 0, H}, 
  {{k, 0, "Waves per Metre (x-direction)"}, 0, 0.0005}, 
  {{H, 100, "Depth"}, 0, 500},
  {{f, 0, "Coriolis Coefficient"}, -0.01, 0.01}]

demo

Notes

  1. I put the stream plot in the content pane with the 3D plot because I don't think you want to be treated as an annotation to the plot.
  2. I give ω an arbitrary value because you didn't define it in your code.

Edit

I have updated the code to use the relation ω = Sqrt[9.81*H]

| improve this answer | |
$\endgroup$
  • $\begingroup$ But the problem with this, is that $\omega$ is already defined by a formula (see code). If you fixed an arbitary value, it won't update the value. $\endgroup$ – Jelmes Jun 18 '17 at 13:42
  • $\begingroup$ and I'm still getting the error message with your script when I change the values. Maybe as I am working on my laptop, maybe the computation is too heavy? $\endgroup$ – Jelmes Jun 18 '17 at 13:45
  • $\begingroup$ @Jelmes. I repeat: there is no definition of ω in the code you posted. It's appearance in an expression is not a definition. If ω = Sqrt[9.81*H]), which it suggested by expression you use in your 3D plot, you must either substitute Sqrt[9.81*H]) for ω or make an explicit definition. $\endgroup$ – m_goldberg Jun 18 '17 at 16:27
  • $\begingroup$ Ah yes, I noticed that. Would I put it at the start of the code before the manipulate, or inside? $\endgroup$ – Jelmes Jun 18 '17 at 16:37
  • $\begingroup$ You noticed what? Is my conjecture that ω = Sqrt[9.81*H]) correct? Your last comment is mystifying. $\endgroup$ – m_goldberg Jun 18 '17 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.