Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add plane_wave.ipynb #12

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

add plane_wave.ipynb #12

wants to merge 5 commits into from

Conversation

fs446
Copy link
Member

@fs446 fs446 commented Apr 29, 2022

added a Jupyter notebook for

  • 1D plane wave
  • 2D plane wave
  • point source as self exercise
  • 1D standing wave phenomena

plane_wave.ipynb Outdated
" To the extent possible under law,\n",
" <span rel=\"dct:publisher\" resource=\"[_:publisher]\">the person who associated CC0</span>\n",
" with this work has waived all copyright and related or neighboring\n",
" rights to this work. Author: <a href=\"https://github.com/fs446\">https://github.com/fs446</a>\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to include authorship information (which I specifically chose not to do, in order to lower the bar for contributions), you can use the tool at https://creativecommons.org/choose/zero/waiver. Mentioning your name here does not change the obligations of users (they still have none).

If you want to legally require people to mention your name when they reproduce/change the materials, you should use CC-BY instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this hint! I removed the autorship, such that we are consistent within this course. I only liked the idea, that interested people find autorship information directly in the notebook and don't need to trace this in the git repo (where this information is encoded anyway). However, I did not figure the implications of different licensing models. So making it most convenient for re-usage is nice to me too.

plane_wave.ipynb Outdated
@@ -0,0 +1,643 @@
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's obviously a matter of taste, but I prefer kebab-case over snake_case for file names, unless it's not technically possible.

Either way, it would be good to be consistent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An old bad habit presumably originating from my assembler coding days :-) Changed for consistency to plane-wave.ipynb, which I then also have done for greens-functions.ipynb (I hope there is no dependency on this in the other notebooks).

plane_wave.ipynb Outdated
"source": [
"# 1. Plane wave in free field\n",
"\n",
"We play around with the plane wave solution $p \\,\\propto\\, \\mathrm{e}^{\\mathrm{j}(-k_x x - k_y y + \\omega t)}$ of the linear, homogeneous wave equation\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "linear and homogeneous" or just "linear homogeneous"?

plane_wave.ipynb Outdated
"\n",
"We play around with the plane wave solution $p \\,\\propto\\, \\mathrm{e}^{\\mathrm{j}(-k_x x - k_y y + \\omega t)}$ of the linear, homogeneous wave equation\n",
"\n",
"$$\\mathrm{div}\\,\\mathrm{grad}\\,p(\\mathbf{x},t) - \\frac{1}{c^2} \\frac{\\partial^2 p(\\mathbf{x},t)}{\\partial t^2} = 0$$\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a matter of taste but I would use the compact Laplacian notation and define it in the following text using div and grad.

plane_wave.ipynb Outdated
"source": [
"# 1. Plane wave in free field\n",
"\n",
"We play around with the plane wave solution $p \\,\\propto\\, \\mathrm{e}^{\\mathrm{j}(-k_x x - k_y y + \\omega t)}$ of the linear, homogeneous wave equation\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason of using propto instead of introducing an amplitude like p_A in the code below?

plane_wave.ipynb Outdated
"outputs": [],
"source": [
"c = 343 # m/s, speed of sound\n",
"wave_length = 1 # m\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about starting with frequency f or angular frequency w, as mentioned in the text above?
In my opinion, it will better highlight the relation of temporal and spatial frequencies (i.e. dispersion relation).
It seems a bit weird in the code below, that the angular frequency/speed-of-sound is computed from 1/wavelength.

plane_wave.ipynb Outdated
"metadata": {},
"outputs": [],
"source": [
"col_tick = np.linspace(-pA, +pA, 255, endpoint=True)\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really cool!

My little concern is that the students might understand 2D plane wave as something like a surface wave, which is two different physical phenomena.

plane_wave.ipynb Outdated
"source": [
"# 3. Plane wave with certain boundary conditions lead to a standing wave\n",
"\n",
"We consider 1D radiation along $x$-axis. Hence, $k_x^2 = \\left(\\frac{\\omega}{c}\\right)^2$, $k_y=$, $k_z=0$.\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k_y = k_z = 0 (without comma) or k_y=0, k_z=0

plane_wave.ipynb Outdated
"\n",
"We consider 1D radiation along $x$-axis. Hence, $k_x^2 = \\left(\\frac{\\omega}{c}\\right)^2$, $k_y=$, $k_z=0$.\n",
"\n",
"At $-l$ (with $l>0$), i.e. at some point on the negative $x$-axis, there is an ideal membrane located, which injects the harmonic velocity $v_A$ into a (long, thin) tube.\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At x=-l ?

plane_wave.ipynb Outdated
"# boundary condition for rigid wall\n",
"p_cpx = 2*pA * np.cos(kx*x)\n",
"v_cpx = 2*pA * -1j / (rho0*c) * np.sin(kx*x)\n",
"\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be helpful to comment that the time-harmonic term (phasor) is not included and will be multiplied in the following code.

plane_wave.ipynb Outdated
"\n",
"\n",
"ax.set_xlabel('x / m')\n",
"ax.set_ylabel(r'$\\frac{p}{pA}$, $\\frac{v}{pA}\\cdot\\rho_0 c$')\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding a second y-label (for velocity) on the right side.

plane_wave.ipynb Outdated
" frames=np.arange(n_periods*n_samples_per_period+4),\n",
" blit=True, interval=50,\n",
" repeat=False)\n",
"plt.show()"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very cool!

* Added visualization task for modes
* proofreading
* Deleted solution part from the task.
Minor changes in written text.
* Added introduction.
* Descriptional improvements at 2d case.
* Inserted the equations to show that the boundary conditions are satisfied.
* some mods/adds to modal stuff
* Deleted time dependencies in 2d case.
---------
Co-authored-by: Frank Schultz <scf175@googlemail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants