Documentation¶
masks¶
-
class
rippleTank.masks.
Mask
(rippletank, rel_deep=None)¶ Masks represent obstacules on the ripple tank. Depending on the rel_deep they can be seen as barriers (rel_deep=0) or simply objects that vary the deep of the tank.
-
applyMask
()¶ Applies the mask object to the rippletank.
-
fromArray
(array, rel_deep=None)¶ Mask array can assigned with and incoming 2d array. The array must have the same dimensions of the ripple tank, contain ones where no effect is wanted and zeros where the deep wants to be modified. If the mask object has a rel_deep or a value is set by parameter, zeros will be changed to rel_deep.
- Raises:
- Exception: “Input array does not have the ripple tank dimensions.” Exception: “Deep must be between 0 and 1.”
-
fromFunc
(func, args=(), kwargs={})¶ Mask array can be made by calling a function func, the first argument of the function needs to be the mask object, other arguments are send to the function with the args parameter, and the keyword arguments with kwargs.
-
mask
= None¶ mask array
-
rel_deep
= None¶ relative deep of the mask
-
rippletank
= None¶ parent Tank object
-
-
rippleTank.masks.
circleMask
(mask, x0, y0, r, width=1)¶ Draws a circle centered on x0, y0 with radious r and width. Background is made with ones and the circle with zeros.
- Returns:
- np.ndarray: 2d binary array.
-
rippleTank.masks.
getPositions
(X_grid, Y_grid, xcorners, ycorners)¶ Using the coordinates in X_grid and Y_grid returns a 2d boolean array of a rectangle with xcorners and ycorners.
- Returns:
- np.ndarray: 2d boolean array.
-
rippleTank.masks.
halfCircleMask
(mask, x0, y0, r, width=1, on='x', direction='upper')¶ Draws half a circle centered on x0, y0 with radious r, and width. The direction is set with the on parameter. The direction parameter tells where to point the half circle. The on parameter can be: x, y, X, Y. The direction parameter: upper, lower.
Background is made with ones and the slit with zeros.
- Raises:
Exception: “on is not a valud location.”
Exception: “direction is not a valud direction.”
- Returns:
- np.ndarray: 2d binary array.
-
rippleTank.masks.
rectangleMask
(mask, xcorners, ycorners)¶ Draws a rectangle with xcorners and ycorners. Background is made with ones and the rectangle with zeros.
- Returns:
- np.ndarray: 2d binary array.
-
rippleTank.masks.
singleSlit
(mask, xcorners, ycorners, width=-1, on='x')¶ Draws a slit on the middle of a rectangle with xcorners, ycorners with width on the on direction. The on parameter can be: x, y, X, Y.
Background is made with ones and the slit with zeros.
- Raises:
- Exception: “on is not a valud location.”
- Returns:
- np.ndarray: 2d binary array.
sources¶
-
class
rippleTank.sources.
Source
(rippletank, function, xcorners=(-0.5, 0.5), ycorners=(-0.5, 0.5), freq=1, phase=0, amplitude=0.1)¶ Sources create perturbations on the ripple tank.
-
X_grid
= None¶ x grid coordinates
-
Y_grid
= None¶ y grid coordinates
-
amplitude
= None¶ relative amplitude of the source
-
evaluate
(i)¶ Receives an int number related with an iterator, evaluates function using that number.
- Returns:
- np.ndarray: source values.
-
freq
= None¶ frequency of the source
-
function
= None¶ function that describes source behavior
-
period
= None¶ period of the source
-
phase
= None¶ phase of the source
-
positions
= None¶ position of the source
-
rippletank
= None¶ parent tank
-
xcorners
= None¶ xcorners of the source
-
ycorners
= None¶ ycorners of the source
-
-
rippleTank.sources.
dropSource
(source, i)¶ Pulse function.
- Returns:
- np.ndarray: array with -1.0 values on source positions.
-
rippleTank.sources.
sineSource
(source, i)¶ Sine function.
- Returns:
- np.ndarray: array with sine values on source positions.
-
rippleTank.sources.
squareSource
(source, i)¶ Square function.
- Returns:
- np.ndarray: array with square values on source positions.
tank¶
-
class
rippleTank.tank.
RippleTank
(xdim=(-15, 15), ydim=(-15, 15), deep=1.0, n_cells_x=100, n_cells_y=100, mask=1.0, bc='open', alpha=0.45, units='cm')¶ RippleTank objects are the core of the simulation. They contain both sources and masks. The class describes the space in which the waves will move and the force acting on them.
-
addMask
(mask)¶ Adds a mask to the ripple tank.
-
addSource
(source)¶ Includes a source to the ripple tank.
-
amplitude
= None¶ wave amplitude values
-
animate
(i, values, skip)¶ Function used by matplotlib’s FuncAnimation.
- Returns:
- matplotlib object: imshow. matplotlib object: text.
-
animation_speed
= None¶ relative reproduction speed
-
applyMask
(frame)¶ Applies a numpy mask.
- Returns:
- np.ma: masked array.
-
applyMultipleMasks
()¶ Calculates the whole effect of the masks by multiplying them.
-
applySources
(i)¶ Sets the sources values in the amplitude array of the waves.
-
ax
= None¶ matplotlib axes
-
bc
= None¶ boundary conditions, ‘open’ or ‘close’
-
calcSpeed
(values)¶ Calculates the propagation speed depending on the actual height of the wave.
-
captureFrame
(data=None, fig=None, frame=-1)¶ Uses the rippletank’s to plot a single instant of time of data.
- Returns:
- matplotlib.figure: figure containing the main plot. matplotlib.axes: axes containing the imshow.
-
complete_values
= None¶ wave amplitude + deep
-
configPlot
(figsize=(6, 4.5), xlabel=None, ylabel=None, cmap=<matplotlib.colors.LinearSegmentedColormap object>, vmin=None, vmax=None, cbar_label=None, origin='lower')¶ Configures the plot.
- Returns:
- matplotlib.figure: figure containing the main plot. matplotlib.axes: axes containing the imshow.
-
deep
= None¶ deep of the tank, must be positive
-
dt
= None¶ dt value
-
evaluateSources
(i)¶ Evaluates all sources in the tank.
- Returns:
- np.ndarray: 2d array with the values of the source at the i instant.
-
extent
= None¶ matplotlib extent parameter
-
fig
= None¶ matplotlib figure
-
forbidden_pos
= None¶ positions where sources stand
-
fps
= None¶ frames per second value
-
g
= None¶ gravity value
-
getSecondPartEquation
(i)¶ Evaluates the central differences on x and y for the instant i+1.
- Returns:
- np.ndarray: 2d amplitude values at the instant i+1.
-
getSourcesPositions
()¶ Gets all the positions of the sources as a boolean array.
- Returns:
- np.ndarray: 2d boolean array.
-
makeAnimation
(data=None, fig=None, fps=None, duration=None)¶ Makes an animation of data, it only uses the required frames depending on the duration and fps value.
- Returns:
- matplotlib.animation.FuncAnimation: animation of the data.
-
mask
= None¶ mask appplied to the tank
-
masked_deep
= None¶ deep on every point
-
masks
= None¶ stores masks
-
n_cells_x
= None¶ number of cells on x
-
n_cells_y
= None¶ number of cells on y
-
ratiox
= None¶ finite differences quotient on x
-
ratioy
= None¶ finite differences quotient on y
-
setdt
(dt)¶ Sets the delta t value.
-
sim_duration
= None¶ time to simulate
-
simulateTime
(sim_duration, animation_speed=1.0, fps=24.0)¶ Simulates an interval of time, if the animation_speed with the current fps value does not match the sim_duration, modifies the dt value.
- Returns:
- np.ndarray: 3d array, extra dimension represents time.
-
solveBorders
(i)¶ Determins the state i+1 of the boundaries using the state i.
-
solveInstant
(i)¶ Solve the differential equation for a single instant of time, from i to i+1.
-
solvePoints
(n_instants)¶ Simulates n_instants of time.
- Returns:
- np.ndarray: 3d array, extra dimension represents time.
-
sources
= None¶ stores sources
-
speed
= None¶ speed of propagation on each point
-
units
= None¶ units used
-
verifyData
(data)¶ Verifies if parameter data is different from None. If no simulation has between run, simulates 100 instants of time.
- Returns:
- np.ndarray: 3d array, extra dimension represent time.
-
xdim
= None¶ x dimensions of the grid
-
ydim
= None¶ y dimensions of the grid
-