Professional Documents
Culture Documents
Matlab Codes: 1 Inertial Regime
Matlab Codes: 1 Inertial Regime
Below, we provide the key MatLab codes to perform the simulations pre-
sented in the article. These codes can be modified by the readers themselves
to explore more complex cases. In each subsection, we present a function
that implements one of the FDE presented above and we suggest some pa-
rameters to run the codes. Note that we use thoroughly SI measurements
units.
1 Inertial regime
This function implements Eq. (8). Inputs: number of samples N [1e+5],
timestep Dt [1e-8 s], initial positions x1,x2 [0 m, 0 m], particle radius
R [1e-6 m], temperature T [300 K], fluid viscosity eta [0.001 Pa s -
water], and density d [2.6e+3 kg/m3]. Outputs: particle position x [m]
and time t [s].
function [x,t]=inertial(N,Dt,x1,x2,R,T,eta,d)
kB = 1.38e-23; % Boltzmann constant [J/K]
gamma = 6*pi*R*eta; % friction coefficient
m = 4/3*pi*R^3*d; % particle mass
tau = m/gamma; % momentum relaxation time
1
figure
plot(t,x)
xlabel(’time [s]’)
ylabel(’x [m]’)
2 Diffusive regime
This function implements Eq. (10). Inputs: number of samples N [1e+5],
timestep Dt [1e-3 s], initial position x1 [0 m], particle radius R [1e-6
m], temperature T [300 K], and fluid viscosity eta [0.001 Pa s - water].
Outputs: particle position x [m] and time t [s].
function [x,t]=diffusive(N,Dt,x1,R,T,eta)
kB = 1.38e-23; % Boltzmann constant [J/K]
gamma = 6*pi*R*eta; % friction coefficient
D = kB*T/gamma; % diffusion coefficient
figure
plot(t,x)
xlabel(’time [s]’)
ylabel(’x [m]’)
function [r,s]=acf(x,Dt)
2
r = xcorr(v,ceil(sqrt(length(x))),’unbiased’);
s = Dt*[0:1:length(r)-1];
figure
plot(s,r)
xlabel(’s [s]’)
ylabel(’R [m^2]’)
for n = 0:1:sqrt(length(x))
msd(n+1) = mean((x(n+1:end)-x(1:end-n)).^2);
end
s = Dt*[0:1:length(msd)-1];
figure
plot(s,msd)
xlabel(’s [s]’)
ylabel(’MSD [m^2]’)
5 Trapped particle
This function implements Eq. (16). Inputs: number of samples N [1e+5],
timestep Dt [1e-3 s], initial position x1,x2,x3 [0 m, 0 m, 0 m], particle
radius R [1e-6 m], temperature T [300 K], fluid viscosity eta [0.001 Pa
s - water], and trap stiffness kx,ky,kz [1e-6 N/m, 1e-6 N/m, 0.2e-6
N/m]. Outputs: particle position x,y,z [m] and time t [s].
function [x,y,z,t]=...
trapped(N,Dt,x1,y1,z1,R,T,eta,kx,ky,kz)
kB = 1.38e-23; % Boltzmann constant [J/K]
3
gamma = 6*pi*R*eta; % friction coefficient
D = kB*T/gamma; % diffusion coefficient
figure
plot3(x,y,z)
xlabel(’x [m]’)
ylabel(’y [m]’)
zlabel(’z [m]’)
axis equal