Examples

Simple sine source

_images/simpleSource.gif
import rippleTank as rt
import matplotlib.pyplot as plt

# creates a ripple tank
tank = rt.RippleTank()

# creates a source on the ripple tank
rt.Source(tank, rt.sineSource, freq=10)

tank.simulateTime(2.0, animation_speed = 0.5)

ani = tank.makeAnimation()
# ani.save('simpleSource.gif', writer='imagemagick')

plt.show()

Single slit

_images/singleSlit.gif
import rippleTank as rt
import matplotlib.pyplot as plt

# creates a ripple tank
tank = rt.RippleTank()

# creates a source on the ripple tank
rt.Source(tank, rt.sineSource, xcorners = (-15, 15), ycorners = (10, 11), freq = 10.0)

rt.Mask(tank).fromFunc(rt.singleSlit, ((-15, 15), (0, tank.dy)))

tank.simulateTime(2.0, animation_speed=0.5)

ani = tank.makeAnimation()
# ani.save('singleSlit.gif', writer='imagemagick')

plt.show()

Half circle, close tank

_images/halfCircle.gif
import rippleTank as rt
import matplotlib.pyplot as plt

# creates a ripple tank
tank = rt.RippleTank(bc='close')

# creates a source on the ripple tank
rt.Source(tank, rt.sineSource, xcorners = (-tank.dx, tank.dx),
                                        ycorners = (10-tank.dy, 10+tank.dy), freq = 10.0)

width = (tank.dx**2 + tank.dy**2)**0.5
rt.Mask(tank).fromFunc(rt.halfCircleMask, (0, -4, 6, width, 'x', 'lower'))

tank.simulateTime(2.0, animation_speed=0.5)

ani = tank.makeAnimation()
# ani.save('halfCircle.gif', writer='imagemagick')

plt.show()

Multiple sources

_images/multipleSources.gif
import rippleTank as rt
import matplotlib.pyplot as plt

# creates a ripple tank
tank = rt.RippleTank()

x0, y0 = -5, 0
# creates a source on the ripple tank
rt.Source(tank, rt.sineSource, xcorners = (x0-tank.dx, x0+tank.dx),
                                        ycorners = (y0-tank.dy, y0+tank.dy), freq = 10.0)
x1, y1 = 5, 0
rt.Source(tank, rt.sineSource, xcorners = (x1-tank.dx, x1+tank.dx),
                                        ycorners = (y1-tank.dy, y1+tank.dy), freq = 5.0)

tank.simulateTime(2.0, animation_speed=0.5)

ani = tank.makeAnimation()
# ani.save('multipleSources.gif', writer='imagemagick')

plt.show()

Breakwater

_images/breakwater.gif
import numpy as np
import rippleTank as rt
import matplotlib.pyplot as plt

# creates a ripple tank
tank = rt.RippleTank((-50, 50), (-50, 50), units='m')

# creates a source on the ripple tank
rt.Source(tank, rt.sineSource, xcorners = (-50, 50), ycorners = (25, 30), freq= 2/15.0)

# creates rectangular masks fom function
rt.Mask(tank).fromFunc(rt.rectangleMask,  ((0, 3), (-50, -20)) )
rt.Mask(tank).fromFunc(rt.rectangleMask, ((25, 28), (-50, -20)) )

x = np.linspace(0, 1, tank.X.shape[1])
y = np.linspace(0, 1, tank.X.shape[0])

X, Y = np.meshgrid(x, y)

# creates ocean floor
rt.Mask(tank).fromArray(Y)

tank.simulateTime(60.0, animation_speed=10.0)

ani = tank.makeAnimation()
# ani.save('breakwater.gif', writer='imagemagick')

plt.show()