Code covered by the BSD License  

Highlights from
Biohydrodynamics Toolbox

image thumbnail
from Biohydrodynamics Toolbox by Alexandre Munnier
Tool to simulate easily the motion of moving solids or swimming robots in a potential fluid flow.

bht_boundary_check page
bht_boundary_check page
Biohydrodynamics Toolbox    

bht_boundary_check


Check user-defined boundary M-File.

Syntax

bht_boundary_check(filename,settings,tol)

Description

The purpose of this function is to visualize what the user-defined boundaries look like and to check the formula of the first and second derivates given in the related M-File. The command line:
>> bht_boundary_check(fun,settings,tol) 
does the following:
  •  A graphic window is opened in which is pictured the boundary and its tangent and normal vectors, defined by the M-File filename with the settings given in the input array variable settings. Tangent and normal vectors are computed with the first derivative formula given in the M-File. Therefore, if the tangent vectors (pictured in red) appear to be not really tangent to the line, it means that there may be an error in this formula. The solid's center of mass is also displayed. We recall that the center of mass must coincide with the origin for solid's boundaries.
  • The numeric first and second derivatives' approximations with theoretical order of accuracy tol are computed by means of the central difference formula. The result is compared with the analytic formula given in the M-File. The error functions for both derivatives are ploted. We point out that errors larger than the theoretical one do not necessarily mean that the formula is wrong. Conversely, there can be an error in the formula even if the computed errors are within the theoretical one.

Example

In the following example, the boundary defined by the M-File bht_link1 is checked. The theoretical accuracy order is 1e-8. Here is what is displayed in the current workspace:
>> bht_boundary_check('bht_link1',[-2.1,0.35,-0.9,0.9],1e-8);
Coordinates of the center of mass: [-0.58071 -2.708e-17]
For solid's boundary only, it should be [0 0]. If not, the boundary will be automatically translated while running bht_data_compile.
Error order estimated: 1e-08
Max error for first derivatives: 1.0198e-08  4.2758e-09 -> Ok
Max error for second derivatives: 2.6015e-08  1.2166e-08 -> Ok
The following figures are displayed as well:
Images/boundarycheck.jpg

See also

Fluid's boundaries
bht_boundaries_init
bht_data_compile
2008 - A. Munnier and B. Pincon (Insitut Elie Cartan and INRIA Lorraine, Projet CORIDA, Nancy, France).       

Contact us at files@mathworks.com