0
$\begingroup$

Recently, I have been trying to plot (or graph) the below one-dimensional wave equation:

$$T(x,y) = \sum_{n \, is \, odd}^{\infty} \frac{4T_0}{\pi n \, \sinh(\pi n)} \sin \left(\frac{n \pi}{S} x \right) \sinh \left(\frac{n \pi}{S} y \right)$$

Note that $T_0$ is a constant and $S$ is an arbitrary (side) length.

With that said, I've been wanting to plot the above equation out and check whether or not does it fulfill the boundary conditions of $T(0,y) = T(S,y) = T(x,0) = 0$ and $T(x,S) = T_0$

I did try to manipulate the below Mathematica code which graphs a Fourier Series (along with piecewise functions) to graph my equation above. However, coding quickly became progressively difficult when dealing with $x$, $y$, $S$, and $T_0$.

fApprox[max_, t_] := (1/2) + 
  Sum[ Sin[2 n Pi]/(Pi n)  Cos[
      n Pi t] + ((-1)^n - Cos[2 Pi n])/(Pi n) Sin[n Pi t], {n, 1, max}]
f[t_] := Piecewise[{{0, 0 < t < 1}, {1, 1 < t < 2}}];
Manipulate[
 Plot[{f[t], fApprox[nTerms, t]}, {t, 0, 2},
  PlotRange -> {Automatic, {-0.3, 1.3}},
  PlotStyle -> {{Thick, Blue}, Red},
  Exclusions -> None
  ],
 {{nTerms, 5, "How many terms?"}, 1, 30, 1, Appearance -> "Labeled"},
 TrackedSymbols :> {nTerms}
 ]

Source: Graphing a Fourier Series

Therefore, my question is how can I graph my one-dimensional wave equation and check whether or not does it fulfill the given boundary conditions on Mathematica? Is there a way for Mathematica to accommodate this many variables and arbitrary constants?

Thank you for reading through this as well as presenting your assistance! I sincerely appreciate any help offered by this community.

$\endgroup$
  • 1
    $\begingroup$ I am confused by this question. You say my question is how can I graph my one-dimensional wave equation and but what you show is not a solution to 1D wave equation. It looks like solution to Laplace PDE in 2D. It does not even have time in it so how could be a solution to wave PDE? I can show you how to plot the solution you show using different S and different T0 if this is what you are asking. But this is just basic use of Manipulate with 2 sliders. $\endgroup$ – Nasser Apr 26 at 4:55
  • $\begingroup$ @Nasser To my limited knowledge, it should be a 1D wave equation. Perhaps providing some context to the problem would help. Essentially, the above equation finds $T$ (i.e. temperature) everywhere on a square flat plate of side length $S$, with the boundary conditions mentioned above (i.e. T(0, y) = T(S,y) = T(x,0) = 0$ ...). Note that T(x,y) is the steady-state temperature distribution in the flat metal sheet. In short, the solution I should have should be in the form of the below example solution: $\endgroup$ – Athenian Apr 26 at 6:23
  • $\begingroup$ Example equation: $y(x,t) = 8A \sum_{n \: odd} (-1)^{\frac{n-1}{2}} \Big{\frac{1}{n\pi} \Big)^2 \sin \Big( \frac{b \pi x}{L} \Big) \cos \Big( \frac{n \pi v t}{L} \Big)$. $\endgroup$ – Athenian Apr 26 at 6:28
  • $\begingroup$ Refer here if you want to know more by what I mean: physicsforums.com/threads/… Thank you! $\endgroup$ – Athenian Apr 26 at 6:30
  • 1
    $\begingroup$ That is "steady state wave equation". Steady state wave PDE becomes Laplace PDE at steady state. since at time infinity, the time dependency goes away and we are left with only the Laplacian. $\endgroup$ – Nasser Apr 26 at 6:36
2
$\begingroup$

my question is how can I graph my one-dimensional wave equation and check whether or not does it fulfill the given boundary conditions on Mathematica?

If the question is asking how to plot

$$T(x,y) = \sum_{n \, is \, odd}^{\infty} \frac{4T_0}{\pi n \, \sinh(\pi n)} \sin \left(\frac{n \pi}{S} x \right) \sinh \left(\frac{n \pi}{S} y \right)$$

For different $S$ and $T_0$, then

enter image description here

fApprox[max_, T0_, s_, x_, y_] := 
  Sum[(4 T0)/(Pi n Sinh[n Pi]) Sin[(n Pi)/s x] Sinh[(n Pi)/s y], {n, 1, max, 2}];
Manipulate[
 Module[{x, y},
  Plot3D[{fApprox[nTerms, T0, s, x, y]}, {x, 0, s}, {y, 0, s},
   PerformanceGoal -> "Quality",
   PlotRange -> {Automatic, Automatic, All},
   ImageSize -> 400, ImageMargins -> 10, ImagePadding -> 20
   ]
  ],
 {{nTerms, 5, "How many terms?"}, 1, 30, 1, Appearance -> "Labeled"},
 {{s, 1, "S?"}, 1, 5, 1, Appearance -> "Labeled"},
 {{T0, 5, "T0?"}, 1, 30, 1, Appearance -> "Labeled"},
 TrackedSymbols :> {nTerms, s, T0}
 ]
| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you so much for your help! Admittingly, I did not know my equation was supposed to be graphed in a 3D setting. Regardless, the fact that the solution of the given boundary conditions being applied to the equation also matches the plot results does mean both the solution and the plot are correct (and perfectly match each other). This answer was very informative and I'll definitely practice more of Mathematica's code. Beyond that, thank you correcting my misconception of what I originally thought was a 1D wave equation in the comments. $\endgroup$ – Athenian Apr 26 at 13:31

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.