How to stop particles crossing the solid cylinder boundary

4 visualizaciones (últimos 30 días)
K_A
K_A el 12 de Nov. de 2021
Comentada: Walter Roberson el 28 de Nov. de 2021
Hello,
I am doing random walk particle tracking simulation. In my problem, I have to implement reflected boundary on the cylinder. In this code, the check implies that if particles enter into the cylinder, its previous position should not change.
However, particles still entering into the cylinder. Below is my code.
%% loop starts
for i = 1:T % T is the total computation time of simulation
t = i*dt; % dt is the time step
%% Particle tracking starts
x_ out = x_previous + u.dt + sqrt(2Ddt); % x_out--> current position, x_previous--> previous position of
% particle, u is the x-velocity component
y_ out = y_previous + v.dt + sqrt(2Ddt); % y_out--> current position, y_in--> previous position of #
% particle, v is the y-velocity velocity component
%% Check whether particle reflects from cylinder obstacle
% x_c and y_c is the center location for cylinder (obstacle) in the flow
Incircle = sqrt((x_out - x_c(j)).^2 + (y_out - y_c(j)).^2);
Particle_enter = find (Incircle < D/2); % Particle entered in obstacle having diameter (D)
%% if particle cross cylinder boundary, do not update its position
If ismember(Particle_enter,1)
kk1 = find(ismember(isIncircle, 1) == 1);
x_out = x_previous(kk1); % Do not update location
y_out = y_previous(kk1);
end
x_previous = x_out;
y_previous = y_out;
end
Any suggestion/modification in the code will be helpful
Thanks
  5 comentarios
K_A
K_A el 12 de Nov. de 2021
Hello Image Analyst,
I tried to reflect it from the cylinder boundary by finding those particles which are sitting in the cylinder and kick them
out by giving them reverse velocity. However, that also did not work.
Image Analyst
Image Analyst el 13 de Nov. de 2021
Yes of course -- that would be the wrong formula unless the particle was aiming directly at the center. If it's a "glancing blow" then you need to take the slope of the cylinder at the point of impact into account. You need to have another array, slope, where the elements are the arctangent of y_c over x_c. Then it's just simple geometry/algebra/trigonometry to reflect a line off of a plane at that slope.

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 12 de Nov. de 2021
Editada: Jan el 12 de Nov. de 2021
What about:
Outcircle = ((x_out - x_c(j)).^2 + (y_out - y_c(j)).^2) >= (D/2)^2;
x_out(Outcircle) = x_previous(Outcircle);
y_out(Outcircle) = y_previous(Outcircle);
Note: sqrt() is expensive. Squaring the radius is much cheaper.
  4 comentarios
K_A
K_A el 13 de Nov. de 2021
Editada: K_A el 13 de Nov. de 2021
Hello Jan,
I apologize for ambiguity and formating of my question. I do store output in x_out and y_out (there is no space in x and out). For clarity, I have modified output variables names to avoid any amibiguties. The physical interpretation of equation
xout = xprevious + u*dt + randn(N,1).*(2*D*dt)^0.5;
yout = yprevious + v*dt + randn(N,1).*(2*D*dt)^0.5;
is that In order to move a particle in the space (here 2-dimension), I need its intial positions (xprevious and yprevious) and corresponding velocities (u--> velocity component in x direction and v--> velocity component in y direction). I obtain velocity components from other solver. In addition, here the walker is random (not purposeful or determinstic), so I add random noise (here N is the total number of particles) with some strength (sqrt(2*D*dt)).
By this equation, particles should move in forward direction. In my problem, there is an obstacle. Particles cannot cross solid boundary, so either they have to reflect or remain where they are. I am trying to implement the later one which is
Outcircle = ((xout - xc).^2 + (yout - yc).^2 >= (D/2)^2);
xout(Outcircle) = xprevious(Outcircle);
yout(Outcircle) = yprevious(Outcircle);
I did not get any error message. When I say it does not work, I mean before applying the check, I got result shown in before_check image. Here particle moves as time advances but enters into the obtscle.
However, when I apply the check as you suggested, I got result shown in after_check image. Here particles are not moving at all which is not expected by the governing equation defined above.
Walter Roberson
Walter Roberson el 28 de Nov. de 2021
We need your full code, so that we are not busy trying to fix problems that we imagine that you might possibly have.

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by