Boundary Shapes

Everything in this simulation is a particle: a discrete point in 2-D space.

On the right, 3 kinds of particles: red tracers, yellow tracers, and blue boundary points.

The particles within the fluid that we observe are called "tracers", and the static particles that comprise the container are called "boundary points". This page is concerned with boundary points. Their positions are represented as complex doubles. Below is a code snippet that uses quadr.m to generate boundary points. This is the first step in any simulation.

Complex doubles as coordinates

% 3 line snippet, insertable to video-writing files

% in the "Boundary Conditions" section

N = 128; % number of boundary points

boundary.Z = @(t) exp(1i*t); % complex circle

boundary = quadr(boundary, N);


% plot for demo

plot(boundary.x, ' . '); axis equal, hold on;

title('Circle Plot');



The "quadr" function take as input a struct with a field function handle 'Z' and adds many fields to that struct. Of interest to us here is the field 'x'. After calling quadr on "boundary", "boundary.x" is a complex double array. Each complex number is a coordinate in space, with the real part corresponding to the x-value of a boundary point and the imaginary part corresponding to the y-value of a boundary point. In this way, boundary.x holds the positions of our boundary points.

Taking advantage of complex doubles as coordinates is powerful as it allows for a virtually unlimited number of boundary shapes.

The next example provides a code snippet of the boundary generated by a conformal mapping of a circle onto a square.

The "Soft Square" Boundary

% 6 line snippet, insert this into "Boundary Conditions section"

N = 512;

alpha = 99/100; % mapping coefficient

x = @(u,v) 1/2*sqrt(2+u.^2-v.^2+2*sqrt(2)*u) - 1/2*sqrt(2+u.^2-v.^2-2*sqrt(2)*u);

y = @(u,v) 1/2*sqrt(2-u.^2+v.^2+2*sqrt(2)*v) - 1/2*sqrt(2-u.^2+v.^2-2*sqrt(2)*v);

boundary.Z = @(t) x(alpha*real(exp(1i*t)),alpha*imag(exp(1i*t))) + 1i*y(alpha*real(exp(1i*t)),alpha*imag(exp(1i*t)));

boundary = quadr(boundary, N);


% plot for demo

plot(boundary.x,'.'); axis equal, hold on;

title('Soft Square');




The above code generates this plot.


To look more into conformal mappings from circle to square, and where those x and y functions come from, take a look at this arxiv article.

This last code snippet provides richness to boundary shape experimentation.

The "Flower" Boundary

N = 256;

WIDTH = 3; % 'WIDTH' specifies a

PETALS = 6;

boundary.Z = @(t) (WIDTH + sin(PETALS.*t)).*exp(1i*t)/(1 + WIDTH);

boundary = quadr(boundary, N);


% plot for demo

plot(boundary.x,'.'); axis equal, hold on;

title('Flower');




Changing the WIDTH and PETALS are excellent ways to investigate the effect that boundary shape has on the flow of particles within the container.