Giter Club home page Giter Club logo

sine-wave-superposition's Introduction

One-Dimensional Superposition of Sine Waves

Modeling and visualization of linear superposition of sine waves and resultant interference patterns

  • Python 3.11.4
  • Matplotlib 3.7.2
  • Seaborn 0.12.2
  • NumPy 1.25.2

Main Project Files


Content

Theoretical Background

Parameters

Implementation


Wave Equation

The sine wave equation in one-dimension can be represented as:

$y(x, t) = A \sin(kx \pm \omega t + \phi)$

where:

$y(x,t)$ is the wave displacement at position $x$ and time $t$
$A$ is the amplitude
$k = \frac{2\pi}{\lambda}$ is the wave number
$\omega = 2\pi f$ is the angular frequency
$\phi$ is the phase offset
$+$ or $โˆ’$ depends on the direction of propagation (right or left)

Superposition Principle

The superposition principle states that when two or more waves overlap in space, the resultant wave is the algebraic sum of their individual waves. When two waves $W_1$ and $W_2$ interfere, the resultant wave $W_R$ can be given by:

$W_R(x, t) = W_1(x, t) + W_2(x, t)$

Interference patterns are the result of the superposition of two or more waves. These patterns can be either constructive or destructive depending on the phase and amplitude of the interacting waves.

These patterns can display areas of both constructive and destructive interference, and they are commonly seen in phenomena like double-slit experiments and sound wave interference.


Wave Model Parameters

model_sinewave() function

Parameter Description Type
x Positions of the wave ($x$): Positions where the wave is evaluated (m) numpy.ndarray
t Time of evaluation ($t$): Time at which the wave is evaluated (s) float
A Amplitude ($A$): Maximum displacement from equilibrium (m) float
wavelength Wavelength ($\lambda$): Length of one complete wave cycle (m) float
frequency Frequency ($f$): Number of oscillations per second (Hz) float
phi Phase offset ($\phi$): Shifts the wave horizontally (radians) float (optional)
propagation Propagation direction (x-axis): 'right' for positive, 'left' for negative string (optional)
phase_polarity Phase polarity (y-axis): 'positive' retains form, 'negative' flips the wave vertically string (optional)

These parameters can be used to represent the waves in the model:

$\large y(x, t) = A \sin\left( \frac{2\pi}{\text{wavelength}} \cdot x \pm 2\pi \cdot \text{frequency} \cdot t + \phi \right)$


Superposition Plot Parameters

plot_wave_superposition() function

Parameter Description Type
wave_1_params $W_1$: Wave 1 model parameters dictionary
wave_2_params $W_2$: Wave 2 model parameters dictionary
dark_theme Dark Theme: If True, uses a dark background for the plot bool (optional)

Implementation

Modeling of sine wave superposition phenomena and interference patterns

1. Standing waves

Parameter Description $W_1$ $W_2$
A $A$: Amplitude 5.0 5.0
frequency $f$: Frequency 90.0 90.0
wavelength $\lambda$: Wavelength 10.0 10.0
phi $\phi$: Phase offset 0.0 0.0
propagation Propagation direction right left
phase_polarity Phase polarity (y) positive positive
Parameter Description Value
dark_theme Dark Theme True

Output:


2. Wave beats

Parameter Description $W_1$ $W_2$
A $A$: Amplitude 5.0 5.0
frequency $f$: Frequency 10.0 20.0
wavelength $\lambda$: Wavelength 4.0 5.0
phi $\phi$: Phase offset 0.0 0.0
propagation Propagation direction right right
phase_polarity Phase polarity (y) positive positive
Parameter Description Value
dark_theme Dark Theme True

Output:


3. Constructive Interference

Parameter Description $W_1$ $W_2$
A $A$: Amplitude 10.0 5.0
frequency $f$: Frequency 90.0 90.0
wavelength $\lambda$: Wavelength 10.0 10.0
phi $\phi$: Phase offset 0.0 0.0
propagation Propagation direction right right
phase_polarity Phase polarity (y) positive positive
Parameter Description Value
dark_theme Dark Theme True

Output:


4. Destructive Interference

Parameter Description $W_1$ $W_2$
A $A$: Amplitude 10.0 5.0
frequency $f$: Frequency 90.0 90.0
wavelength $\lambda$: Wavelength 10.0 10.0
phi $\phi$: Phase offset 0.0 $\pi$
propagation Propagation direction right right
phase_polarity Phase polarity (y) positive positive
Parameter Description Value
dark_theme Dark Theme True

Output:


5. Perfect Destructive Interference (Cancellation)

Parameter Description $W_1$ $W_2$
A $A$: Amplitude 10.0 10.0
frequency $f$: Frequency 90.0 90.0
wavelength $\lambda$: Wavelength 10.0 10.0
phi $\phi$: Phase offset 0.0 $\pi$
propagation Propagation direction right right
phase_polarity Phase polarity (y) positive positive
Parameter Description Value
dark_theme Dark Theme True

Output:


6. Fundamental Frequency + 2nd Harmonic

Parameter Description $W_1$ $W_2$
A $A$: Amplitude 5.0 2.5
frequency $f$: Frequency 90.0 180.0
wavelength $\lambda$: Wavelength 4.0 2.0
phi $\phi$: Phase offset 0.0 0.0
propagation Propagation direction right right
phase_polarity Phase polarity (y) positive positive
Parameter Description Value
dark_theme Dark Theme True

Output:


7. General superposition

Parameter Description $W_1$ $W_2$
A $A$: Amplitude 10.0 5.0
frequency $f$: Frequency 90.0 110.0
wavelength $\lambda$: Wavelength 6.0 10.0
phi $\phi$: Phase offset 0.0 0.0
propagation Propagation direction right left
phase_polarity Phase polarity (y) positive negative
Parameter Description Value
dark_theme Dark Theme True

Output:

sine-wave-superposition's People

Contributors

ssebastianmag avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

5l1v3r1 smaiti7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.