3
$\begingroup$

I have contours of the following function $$\Psi(\nu,\mu) = -\frac{1}{4} e^{-2 \mu} \cos{2 \nu} - \frac{1}{2} \mu$$ in terms of $(\nu,\mu)$:

original contour plot

I need to obtain the contours for $\Psi$ in terms of a different set of parameters $(x,y)$, which are defined using $$x=\cosh{\mu}\cos{\nu}\\ y=\sinh{\mu}\sin{\nu}$$

Is there a straightforward way to transform the axes, through post-processing or otherwise?

For interpretability, a parametric 3D plot of ($\Psi,x,y$) through

ParametricPlot3D[{\[Psi], x, y}, {\[Nu], 0, \[Pi]}, {\[Mu], -2, 2}, PlotPoints -> 100, Mesh -> None]

yields the following:

3D parametric plot

I tried using the alternative solution from this relevant problem to project this 3D plot down to a 2D contour plot, but my parametric plot doesn't seem to be a compatible Graphics3D object. Is this approach less straightforward?

$\endgroup$

3 Answers 3

3
$\begingroup$
$Version

(* "13.1.0 for Mac OS X x86 (64-bit) (June 16, 2022)" *)

Clear["Global`*"]

ψ[ν_, μ_] := -1/4 E^(-2 μ) Cos[2 ν] - μ/2

ParametricPlot3D[
 {Cosh[μ] Cos[ν], 
  Sinh[μ] Sin[ν], ψ[ν, μ]},
 {ν, 0, π}, {μ, -2, 2},
 MeshFunctions -> {#4 &, #5 &},
 MeshStyle -> {Red, Blue},
 AxesLabel ->
  (Style[#, 14] & /@ {x, y, HoldForm[ψ[ν, μ]]})]

enter image description here

sol = (ψ[ν, μ] /. Solve[
       {x == Cosh[μ] Cos[ν], y == Sinh[μ] Sin[ν], 
        0 < ν < Pi, -2 < μ < 2}, {μ, ν}, Reals, 
       Method -> Reduce] /. C[1] -> 0) // Simplify;

Show[
 ContourPlot[#[[1]], {x, -4, 4}, {y, -4, 4},
    ColorFunction -> #[[2]],
    PlotLegends -> BarLegend[Automatic,
      LegendLabel -> #[[3]]],
    FrameLabel -> (Style[#, 14] & /@ {x, y}),
    PlotPoints -> 50,
    MaxRecursion -> 2,
    PlotLabel ->
     StringForm["``", HoldForm[ψ[ν, μ][x, y]]]] & /@
  Transpose[{sol, {"TemperatureMap", "MintColors"},
    {"Lower\nHalf", "Upper\nHalf"}}]]

enter image description here

$\endgroup$
2
$\begingroup$

Consider:

x = Cosh[u] Cos[v];
y = Sinh[u] Sin[v];

and you see that {u,v} and {-u,-v} give the same {x,y} values. Further if v==0, +u and -u result in the same x/y values. The same with u==0. We therefore restrict u and v e.g. to the first quadrant.

With:

psi[v_, u_] = -1/4 Exp[-2 u] Cos[2 v] - 1/2 u;

We now first create a table with {[u,v],y[u,v],psi[u,v]}:

dat = Flatten[Table[{x, y, psi[u, v]}, {u, 0, 2, .1}, {v, 0, 3, .1}], 1];

With this data, we create an interpolating function, As the data are not on an grid, we will get a warning that only linear interpolation is used, what does not harm our calculation.

intpol = Interpolation[dat];

Now we can create a countour plot with variables x and y

ContourPlot[intpol[u, v], {u, 0, 2}, {v, 0, 3}, FrameLabel -> {"X", "Y"}]

enter image description here

$\endgroup$
2
$\begingroup$
  • We use ParametricPlot to draw the region {x[μ, ν], y[μ, ν]} where {ν, 0, π}, {μ, -2, 2} and then use MeshFunction to add the meshs which satisfies the condition Φ[ν, μ]=meshs where meshs = {-3, -2, -1, -.9, -.8, -.5, -.1, 0, .1, .2, .3, 1, 2, 3, 4, 5};.
Clear[x, y, Φ];
x[ν_, μ_] = Cosh[μ] Cos[ν];
y[ν_, μ_] = Sinh[μ] Sin[ν];
Φ[ν_, μ_] = -(1/4) E^(-2 μ) Cos[2 ν] - 
   1/2 μ;
meshs = {-3, -2, -1, -.9, -.8, -.5, -.1, 0, .1, .2, .3, 1, 2, 3, 4, 5};
ParametricPlot[{x[ν, μ], y[ν, μ]}, {ν, 
  0, π}, {μ, -2, 2}, 
 MeshFunctions -> 
  Function[{x, y, ν, μ}, Φ[ν, μ]], 
 Mesh -> {meshs}, 
 MeshShading -> ColorData["TemperatureMap"] /@ Rescale[meshs]]

enter image description here

  • Similar with the 3D version.
x[ν_, μ_] = Cosh[μ] Cos[ν];
y[ν_, μ_] = Sinh[μ] Sin[ν];
Φ[ν_, μ_] = -(1/4) E^(-2 μ) Cos[2 ν] - 
   1/2 μ;
meshs = {-3, -2, -1, -.9, -.8, -.5, -.1, 0, .1, .2, .3, 1, 2, 3, 4, 5};
ParametricPlot3D[{Φ[ν, μ], x[ν, μ], 
  y[ν, μ]}, {ν, 0, π}, {μ, -2, 2}, 
 ViewPoint -> Right, ViewProjection -> "Orthographic", 
 MeshFunctions -> {#1 &}, Mesh -> {meshs}, 
 ColorFunction -> (ColorData["TemperatureMap"][#1] &), 
 ColorFunctionScaling -> True, Axes -> {False, True, True}, 
 PlotRange -> All, PlotPoints -> 50, MaxRecursion -> 2, 
 Lighting -> "ThreePoint"]

enter image description here

$\endgroup$

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.