Description For 2d Wave Equation Codes
Description For 2d Wave Equation Codes
1. Solve 2d wave equation with Finite difference method The 2d wave equation is: ( )
( ) is function that need to find, it can be different thing - time, coordinates, depending on physics task: change of height of water in a pool, change of pressure when sound expansion, electric potential in electromagnetic waves. - is speed of waves. is strength of waves decay. finite difference methods give as approximation for derivative If there is a some function ( ) and we have mesh second derivative approximately: with step , is values of at then
where time index, - x index, Then we can find next time step:
- y index. Let
( where
) )
end of for
where
is current values,
- is old values,
is new values.
i+4
i+3 i+2 i+1 i
i-1
this thing:
i+1,j,k
i,j,k
i,j+1,k
can be made with conv2 matlab function. It is 2d convolution. It is need to convolve with this matrix: ( conv2(u,D,'same') 'same' makes return same size matrix as u sizes. Then here boundary condition on edges used. )
2. Refraction Let say on the bottom of pool of water we have some picture. Water surface has height change . equation for is 2d wave equation. We want to know how the picture will be distorted after it come out from water. Let water surface in some place was inclined at small angle :
ray
te wa
e f ac ur s
a a
d
b c
s=?
because ray has time reversal nature then we can consider that ray come from eye to pool bottom. Our task is to find shift . From refraction low:
In 2d waves we have to inclinings one along x another along y. The angles can be found from gradient:
derevatives in matlab can be found as covolution with sobel operator: http://en.wikipedia.org/wiki/Sobel_operator Shifted pixels colors can be get as 2d interpolation. inter2 matlab function used.
3. Reflection Let we have water surface in plane y=0, a ray go at angle Normal vector to water surface in point p is to the plane y=0 and reflected at point p.
(x0 ,y0 )
x n
p z
(x0 ,-y0 )
If water surface has no inclining then vector ( ) and ray go to point in plane z=0
now let water surface incline a little: ( direction of the ray before reflection: ( point of reflection position: ( ray direction after reflection: ( ( ( ) ( ) )( ) ( ) ) ) ) )
( ( )
) ( (
( )( )
) ) ( )
So shift to
is
Shift to
is ( )
vector (