Project Number: MQP ERT JK10
Project Number: MQP ERT JK10
i=1
m
i
v
i
m
t
. (2.4)
M
= M. Equation
(2.4) also uses the total mass in the box, i.e.,
m
t
=
M
i=1
m
i
. (2.5)
R is given by
R =
_
cos() sin()
sin() cos()
_
. (2.6)
Since the rotation matrix R is an orthogonal matrix, it satises
RR
1
= RR
T
= I . (2.7)
In order to ensure detailed balance, the direction of rotation is randomly picked for each
box. This is implemented by randomly picking a plus or minus sign in Equation (2.6). The
collision process is demonstrated for two particles in Figure 2.2.2.
12
(a) Particles
come in with
velocities
V
1
and
V
2
(b) Relative velocities
are rotated by
(c) Initial and nal veloci-
ties
Figure 2.2: Example of an SRD collision with two equal mass particles. The collision angle
= 90
i=1
m
i
v
i
(t + ) =
M
i=1
m
i
R(v
i
(t) u(t)) + m
t
u(t) .
Using the denition of u from Equation (2.4) gives
M
i=1
m
i
v
i
(t + ) = m
t
u(t) +
M
i=1
Rm
i
(v
i
(t) u(t))
= m
t
u(t) +
M
i=1
Rm
i
(v
i
(t)) m
t
Ru(t)
= m
t
u(t) +
M
i=1
Rm
i
(v
i
(t))
M
i=1
m
i
Rv
i
(t)
=
M
i=1
m
i
v
i
(t) +
M
i=1
m
i
(R(v
i
(t) v
i
(t))
=
M
i=1
m
i
v
i
(t) .
13
Energy conservation can similarly be calculated by
M
i=1
1
2
m
i
|v
i
(t + )|
2
=
M
i=1
1
2
m
i
(R(v
i
(t) u(t)) +u(t))
2
=
M
i=1
1
2
m
i
_
u(t)
2
+ 2R(v
i
(t) u(t)) u(t) +RR
T
(v
i
(t) u(t))
2
_
which by Equation (2.7) becomes
M
i=1
1
2
m
i
|v
i
(t + )|
2
=
M
i=1
1
2
m
i
_
u(t)
2
+ 2R(v
i
(t) u(t)) u(t) + (v
i
(t) u(t))
2
_
,
and the expansion of the last term, by Equation (2.4) becomes
M
i=1
1
2
m
i
|v
i
(t + )|
2
=
1
2
m
t
_
2u(t)
2
2u(t)
2
+ 2R(u(t) u(t)) u(t)
_
+
M
i=1
1
2
m
i
v
i
(t)
2
=
M
i=1
1
2
m
i
v
i
(t)
2
.
Since momentum and energy are conserved within each individual box, they are also
conserved in the sum of all boxes.
2.2.4 Shifting
In cases where a simulation includes an arbitrarily imposed structure, there is a potential for
Galilean invariance problems. In SRD, diusive transport is aected (see Section 2.5.4)[14].
When there is a ow in one direction (or equivalently, the reference frame is moving), diusion
in the direction of the ow is faster than it would otherwise be (Figure 2.15). In order to
resolve this, the location of the whole grid is randomly shifted at each timestep. Instead of
every collision happening with the boxes in the same place, each timestep places them in a
dierent location, oset randomly in the range [a/2, a/2]. Since the range is equal to the
size of the boxes, this shifting means that the boxes are blurred across their entire size.
An example shift by a vector
b is given in Figure 2.3.
Even with shifting, the simulation still has a square structure to it. This shows up as a
higher order eect such as in the freezing transition demonstrated in Section 4.2.2.
14
Figure 2.3: A collision grid of side length a that is shifted by
b, overlaid on its unshifted
position.
2.3 Initialization
In a typical simulation, the particles are initialized with positions drawn from a uniform
distribution across the entire eld. Their velocities are also drawn from a uniform distribu-
tion, but a uniform distribution does not guarantee zero overall momentum and a specic
energy or temperature. As such, the starting distribution is arbitrary and irrelevant as long
as it is uniform, because the velocities of all particles are then scaled to match the specied
momentum and temperature. First, the momentum is normalized by taking the average
velocity of the system
v
total
=
N
i=1
m
i
v
i
N
i=1
m
i
(2.8)
and subtracting it from the velocity of each individual particle. This velocity is similar to
the u of the particles in a single box, except averaged over all boxes. Next, the temperature
is normalized by calculating the actual temperature with
T
1
2N
N
i=1
m
i
_
v
2
ix
+ v
2
iy
_
, (2.9)
and multiplying each velocity by the factor
_
Ttarget
T
actual
. Finally, any desired starting velocity for
the system is directly added to the velocity of each particle. This is done after the calculation
of the kinetic energy for the temperature, because the coherent motion of all particles is
15
equivalent to a Galilean transformation, and has no eect on internal temperature. This
could be done, for example, to have a ow in a channel (Section 2.5.5) with slip walls
(Section 2.4). If it was applied before the temperature normalization, it would articially
cool the system.
2.4 Boundary Conditions
Since free particles will eventually leave the eld, it is necessary to somehow constrain them to
the designated area. To deal with this, boundary conditions are applied after the streaming
step. There are a few types of boundary conditions: periodic, slip, no-slip, and thermal.
2.4.1 Periodic Boundary Conditions
Periodic boundary conditions are an implementation of an innite area. This is done by
taking particles on one edge of the eld and transporting them to the opposite edge. In
order to be able to make measurements using the total displacement however, it is necessary
to preserve that parameter and apply the boundary condition to another one. This is eected
by assigning
x
simulation
= x L x . (2.10)
The reason why x
simulation
is separate from x is so that while all simulation interactions use
the simulation coordinate, measurements can be done on the system which require knowing
total displacement. For example, when measuring diusion, if a particle went a distance L
in one direction, x
simulation
would report that it had not moved, while x would show that it
had. An example of periodic boundary conditions in one dimension is shown in Figure 2.4.
This is a simple boundary method that strictly conserves momentum and energy. Since
the wrapping mimics an innite space (topologically it is actually the surface of a toroid),
it is also good for tests. It does, however, have the disadvantage of allowing the eects of a
particle to propagate all the way around the simulation and come back to interact with the
same particle. For small system sizes, such self-interactions can cause problems.
2.4.2 Slip and No-Slip Walls
Slip and no-slip walls are very similar, in that they both take an incoming particle and
reverse its direction in the direction normal to the wall. The dierence is that while a slip
Figure 2.4: An example of one dimensional periodic boundary conditions.
16
(a) No-slip (b) Slip
Figure 2.5: Slip and no-slip walls.
wall does nothing to the tangential component of the velocity, a no-slip wall inverts it. To
deal with the fact that the particle will have a position outside of the eld, it is reected
back inside. This makes the particle act as if it had participated in the collision part way
through the timestep, and had nished the available time with its new parameters. Both
types of walls strictly conserve energy, but only conserve momentum on average.
2.4.3 Thermal Walls
Thermal walls entirely reset a particles velocity in both directions. The normal component
of the velocity, v
) =
mv
k
B
T
e
mv
2
2k
B
T
, (2.11)
while the tangential component of the velocity, v
||
, is drawn from a normal distribution
P
_
v
||
_
=
_
m
2k
B
T
e
mv
2
||
2k
B
T
. (2.12)
This acts both as a no-slip boundary, as well as a thermostat at the wall [11].
For all wall types, the actual collision of the particle and the wall does not happen
precisely at the end of a timestep. For the previous types of walls, this could be accounted
for simply with algebra. However, in the case of thermal walls, the post-collision velocity
is not a function strictly of the pre-collision velocity, and thus extra care is required. To
deal with for this, the collision is re-calculated, with the timestep split into two parts. The
intersection time of the particle and the wall is calculated, and the timestep is broken into
two portions at that moment. The rst portion of the timestep is used to bring the particle
right up to the wall, and then the particles velocity is assigned from the above distributions.
Now that the particle has its new trajectory, it uses the second portion of the timestep to
continue away from the wall.
2.4.4 Ghost Particles
One of the problems that arises when shifting and walls are used in conjunction with each
other is that of shifting across a boundary. If one is not careful, shifting can make the system
act (during the collision step) as if it had periodic boundary conditions, when it in fact does
17
not. This is because the shift could wrap one edge of the domain onto another, thus resulting
in particles on one edge colliding with particles on the other edge. This could be avoided
by making sure that they are included in separate boxes, as if on a domain of size L, with
walls at a and L a. This would result in partially lled collision boxes, however. To solve
this, one may put a set of ghost particles into that box in order to make the box have M
particles to collide. The velocities of these particles will be drawn from a Maxwell-Boltzmann
distribution, with zero mean velocity and the same temperature as the wall [11].
2.5 Equilibrium Measurements
There are a number of coecients that can both be calculated from the properties of the SRD
model and can be experimentally measured from the simulation. In order for the simulation
to be valid, both the experimental and theoretical values of these must match.
2.5.1 Momentum and Energy
The easiest parameters to measure are momentum and energy. Without the inuence of
walls or external forces, the two quantities should never change, as shown in Section 2.2.3.
As demonstrated by Figures 2.6, 2.7, and 2.8, energy and momentum are constant at their
expected values. This means that they are conserved by the SRD algorithm, as expected.
2.5.2 Velocity Distributions
While the total momentum remains constant, the distribution of velocities can vary as the
simulation runs. While the particles are initialized with uniformly distributed velocities,
their distribution should change to match the Maxwell-Boltzmann distribution,
P (v
) dv
=
_
m
2k
B
T
e
m
2k
B
T
v
2
dv
, (2.13)
where k
B
is the Boltzmann constant, T is the temperature once the system reaches equilib-
rium [21], and is a direction x, y, or z.
As shown in Figures 2.9 and 2.10, the velocity distributions quickly converge to the form
given by the Maxwell-Boltzmann distribution. Since the simulation was initialized with
a uniform velocity distribution, this shows that the SRD method correctly generates its
equilibrium distribution.
2.5.3 Pressure
In a thermodynamically accurate simulation of an ideal gas (what SRD models), the ideal gas
law PV = Nk
B
T, where P is pressure, V is volume, and N is the number of particles should
be obeyed. However, since the simulation is two dimensional, the corresponding equation is
PA = Nk
B
T , (2.14)
18
Figure 2.6: Total energy with respect to time. L = 32, a = 1, N = 4096, M = 4, k
B
T = 1,
= 1, = 90
.
Figure 2.7: Total x momentum with respect to time. L = 32, a = 1, N = 4096, M = 4,
k
B
T = 1, = 1, = 90
.
19
Figure 2.8: Total y momentum with respect to time. L = 32, a = 1, N = 4096, M = 4,
k
B
T = 1, = 1, = 90
.
Figure 2.9: Distribution of x velocities at the end of a simulation run. a = 1, = 1, k
B
T = 1,
= 90
.
20
Figure 2.10: Distribution of y velocities at the end of a simulation run. a = 1, = 1,
k
B
T = 1, = 90
.
where P is linear pressure (force per unit length) and A is the area. Pressure is determined
based on the momentum traveling through a line. Instead of measuring the force on the line,
the simulation allows one to measure the force that would have been on it, without actually
having to aect the uid.
Since all of the parameters except for P can be set for the simulation, it is easy to test
this. Figures 2.11 and 2.12 show pressure as a function of area and temperature respectively.
21
Figure 2.11: Pressure as a function of area for dierent values of temperature. N = 65, 536,
a = 1, = 1, = 90
.
Figure 2.12: Pressure as a function of temperature for dierent values of area. N = 65, 536,
a = 1, = 1, = 90
.
22
As predicted, pressure and area have an inverse relation, while pressure and temperature
are directly proportional. This means that the simulation is properly modeling an ideal gas.
2.5.4 Diusive Transport
Another parameter that can be measured is the diusion coecient D. This is measured as
change in the mean squared displacement of the particles as a function of time, i.e.
x
2
= 2Dt , (2.15)
where x is the coordinate of a particle. Analytical calculation shows that the diusion
coecient should work out to [21]
D =
k
B
T
2M
_
2M
(1 cos ) (M 1 + e
M
)
1
_
, (2.16)
where is the timestep size, M is the number of particles per cell (Equation (2.1)), and
is the angle rotated through during a collision (Equation (2.6)). This coecient has no
dependence on direction, its value should be the same for both dimensions. One would expect
that in a nite simulation domain, diusion could only be measured for a short period of time
until the particles under consideration run into the edges of the simulation. This happens
quite quickly (on the order of tens to hundreds of timesteps depending on parameters). In
order to properly measure diusion for long periods of time, periodic boundary conditions
are used (Section 2.4). Due to the wrapping explained earlier, the simulation domain appears
innite. This means that distances far larger than the available space can be observed, and
the diusion coecients can be calculated over a longer time (and thus more accurately).
The larger diusion area allowed is shown in Figure 2.13.
The diusion coecient was measured for a sample of particles whose locations at the
start of the simulation were recorded, and dierences averaged at each timestep (Figure
2.14). The expected line from Equation 2.16 is plotted along with both the x and y diusion
results. The diusion coecients are the slopes of the lines. The agreement is excellent.
Before shifting was implemented, the simulation had Galilean invariance problems. When
the particles are at a low enough temperature or high enough density, and the system has
a ow, the diusion coecient in the direction of motion was greater than the diusion
coecient in the other direction (Figure 2.15). This was solved by implementing shifting as
described in Section 2.2.4. The improved version behaves as expected regardless of ow.
2.5.5 Viscous Transport
Another parameter that can be obtained from the simulations is the viscosity. This can
easily be measured by applying thermal walls to one dimension of the simulation, emulating
an innite channel. By including an acceleration term, a ow can be induced in the uid.
This is usually called Poiseuille ow, and has a parabolic velocity distribution given by
v(x) =
g
2
_
_
(x
L
2
_
2
_
L
2
_
2
_
(2.17)
23
Figure 2.13: Traced path of one particle over 20,000 timesteps. L = 32, a = 1, T = 1, = 1,
= 90
.
Figure 2.14: Mean squared displacement as a function of time for x and y components. Solid
line is the theory from Equation (2.16).
24
Figure 2.15: Diusion when a ow is imposed in the x direction. The diusion coecients
dier by 20% between the x and y directions when shifting is not enabled. M = 16, T =
0.015625, = 1, = 90
.
25
where = mM = m
N
L
2
is the density and g is the acceleration of each particle.
This can be shown by starting with the denition of viscosity, which is
F =
v
x
, (2.18)
where F is the force, v is the velocity, and x is the position. Taking a 2D channel from
L/2 to L/2, the system will be symmetric across x = 0. One can thus treat the channel
as a smaller channel from 0 to L/2, with the side at x = 0 frictionless. In equilibrium, the
forces will balance, and so a dierential segment of uid at x will support all of the uid
from x = 0 to x. Equivalently, it will support
F = gx =
v
x
, (2.19)
which leads to
v
x
=
x
. (2.20)
Integrating from 0 to x and shifting so that v(L/2) = 0 gives
v(x) =
g
1
2
_
_
L
2
_
2
x
2
_
.
A transformation from x = 0 to x = L/2 gives Equation (2.17).
This means that the experimental result can be matched against the expected prole to
extract the viscosity . The viscosity can also be calculated using
=
k
B
T
2m
_
M
(M 1 + e
M
) sin
2
1
_
+
a
2
1
6dM
_
M 1 + e
M
_
(1 cos ) (2.21)
where a is the width of each box [21].
With the Poiseuille ow, the velocity distribution, shown in Figure 2.16, was parabolic
as expected from Equation (2.13). The temperature distribution across the channel was
approximately constant across the middle of the channel, also as expected (Figure 2.17).
26
Figure 2.16: Velocity distribution across a channel. a = 1, k
B
T = 0.01, L = 64, = 1,
m = 1, M = 4, g = 0.0001, = 90
.
Figure 2.17: Temperature distribution across a channel. a = 1, k
B
T = 0.01, L = 64, = 1,
m = 1, M = 4, g = 0.0001, = 90
.
27
Chapter 3
Modeling Polymers in an SRD Solvent
The coarse-grained nature of the SRD simulation method allows it to be used as a solvent
for other methods. Taking advantage of this, a molecular dynamics module was created and
used to model polymers. This chapter explains the methods used for modeling a polymer.
Once modeled, applications range from viscous relaxation to swimming organisms.
3.1 Modeling of Polymers
Since polymers are long repeating chemical chains, they can be modeled easily as a chain
of points connected together. These connections can be modeled as potentials. A cartoon
description of a polymer is given in Figure 3.1.
Figure 3.1: An example of a continuous polymer.
28
3.1.1 Continuum Model
In order to describe the potentials that describe a polymer, one may rst consider a contin-
uum model. Using r(s) as the position of each point on the polymer, and
t(s) =
r
s
(3.1)
as the tangent vector to r is a good way to start. If
t/s = 0,
t(s) is constant, and thus the
polymer is a straight rod. Thus, bending energy must be a quadratic of
t/s. By denition
(
t
s
= 0 (3.2)
and so the next available term is
_
t
s
_
2
. This gives
U
bend
=
1
2
EI
_
L
0
ds
_
t
s
_
2
(3.3)
where L
U
k
B
T
e
IE
2k
B
T
0
ds
t
s
2
e
Lp
2
0
ds
t
s
2
From here, one can show that
t(s)
t(0)
_
2
=
2s
L
p
, (3.4)
which is similar in form to the diusion equation (2.15). Thus, L
1
p
acts like a diusion
coecient for the polymer.
End-to-end distance R
ee
can also be calculated, i.e.,
R
2
ee
=
_
L
0
ds
_
L
0
ds
t(s)
t(s
) (3.5)
using
t(s)
t(0) = e
s
Lp
gives
R
2
ee
= 2L
L
p
2L
2
p
_
1 e
Lp
_
(3.6)
As expected, this gives the correct behavior in its limits. With
L
Lp
1, R
2
ee
= 2L
L
p
. For
L
Lp
1, R
2
ee
= (L
)
2
.
29
Figure 3.2: An example of a discretized polymer with four segments.
3.1.2 Discrete Treatment
In order to simulate the polymer, however, it needs to be broken down into discrete lengths,
as shown in Figure 3.1.2. Making a discrete treatment of the polymer involves using r
i
, and
t
i
, instead of r(s) and
t(s), respectively. The bending energy can immediately be converted
to
U
bend
=
1
2
EI
n1
i=1
_
t
i+1
t
i
_
2
(r
i+1
r
i
)
2
l . (3.7)
Here l is the segment length and n is the number of segments. Since
t
i
is a unit vector,
combined with subtraction of zero-point energy, the numerator of the sum reduces to 2
t
i
t
i+1
. Assuming that segments have xed length, (r
i+1
r
i
)
2
= l
2
. Thus,
U
bend
=
l
n1
i=1
t
i
t
i+1
(3.8)
where EI. This means that the polymer chains can be given arbitrary rigidities,
controlled by .
3.1.3 Stretching Energy
For the component of the energy from stretching, the discrete model can be used from the
beginning. Placing a spring between each point on the chain gives a potential of,
U = 1/2k (|r
i1
r
i
| l)
2
(3.9)
such that the forces obeyed Hookes law with spring constant k.
F = k (|r
i1
r
i
| l)
t (3.10)
This constraint makes the polymer behave as a freely jointed chain. Each individual link
is kept at its given length l, and the links can rotate freely.
30
Figure 3.3: Coupling between the uid and a polymer.
3.1.4 Resulting Forces
The total internal potential energy for the polymer is then given by
U
internal
= U
bend
+ U
stretch
. (3.11)
Thus, the behavior of the polymer is
m
d
2
x
dt
2
= U
internal
+ F
random
+ F
dissipative
(3.12)
where U
internal
are the internal potentials, and there are an additional two forces: F
random
and
F
dissipative
. The random force applies Brownian kicks to the polymer, while the dissipative
force acts as a heat bath to absorb energy from the polymers relaxation. Unless solvent
molecules are included explicitly these forces do not conserve momentum, and therefore do
not produce the correct in hydrodynamic behavior.
3.1.5 SRD Heat Bath
It is possible to have molecular dynamics support full hydrodynamics, but it requires mod-
eling the solvent as well, which is very expensive.
However, it is possible to use an inexpensive SRD solvent as the heat bath for the poly-
mer. The SRD solvent can provide the friction and random force required for the MD to
work properly. Since the forces are the product of interactions with the surrounding uid,
momentum is conserved, and is passed back to the uid.
The coupling is done by having the particles that are part of MD participate in the SRD
collisions as if they were regular solvent particles. This gives
u =
i=0
m
i
v
i
+
j=0
m
j
v
j
i=0
m
i
+
j=0
m
j
(3.13)
where the rst sum (over i) is the same as in Equation (2.8), and the second sum (over j) is
for the additional M
. This is shown in
Figure 3.4, by how the = 0 curve follows
n.
3.2.2 Radius of Gyration
The radius of gyration, R
g
gives a measure of the dimensions of the chain. It is dened as
R
2
g
=
1
n
n
i=0
(r r
cm
)
2
(3.17)
32
10
n
1
10
L
t
(
a
)
=0
=10
Figure 3.4: Polymer length for = 0, 10. a = 1, l = 1, k
B
T = 1, = 1, L = 32, M = 5.
where the center of mass is
r
cm
=
1
n
n
i=0
r (3.18)
R
g
depends on both the chain length n, and the stiness, , as shown in Figure 3.5. A stier
chain will be more spread apart, and thus have a greater R
g
.
33
10
n
1
10
R
g
(
a
)
=0
=10
Figure 3.5: Radius of Gyration for = 0, 10. a = 1, l = 1, k
B
T = 1, = 1, L = 32, M = 5.
34
Chapter 4
Non-ideal and Binary Fluids
Since SRD uses point particles, the resulting equation of state is that of an ideal gas. In
order to have a non-ideal equation of state, particles need to act as if they have non-zero
diameter. This is done using a new type of collision rule, as explained in the next section.
4.1 Description of Model
The non-ideal model extends SRD by also including an inter-cell collision term. In each
timestep, the collision step has an additional part, where all of the particles in a cell are
collided against all of the particles in a neighboring cell.
4.1.1 Super-cells
In order to do the collisions, cell pairs are required. This is done by splitting the domain
into super-cells of size 2a, where a is the size of a SRD collision cell (Figure 4.1). In each
super-cell, during each timestep, the particles can either collide horizontally, vertically, or
diagonally. The probability of collisions is equal for each option. However, since there are
two dierent ways of having horizontal collisions, it has twice the probability of the other
two. Thus, horizontal and vertical collisions each have a 25% probability, while diagonal
collisions have a 50% probability.
The super-cells used for non-ideal collisions also have shifting. The shifting used is similar
to the shifting used in normal SRD (Section (2.2.4)), but it uses a range of [a, a]. This
is because the super-cells are of size 2a, and spreading the shifting over that requires the
greater range.
4.1.2 Modication of SRD Rules
All of the particles in a super-cell collide against all of the particles in the paired super-cell.
The collision is simple, where the parallel components of the velocity interchange while the
perpendicular components are unchanged. This gives a set of rules as described in Table
4.1.2.
35
Figure 4.1: A super-cell on an SRD domain.
(a) Horizontal: = x (b) Vertical: = y (c) Diagonal:
=
x+ y
2
,
x y
2
Figure 4.2: Possible collision pairs.
36
Collision
x
v
x
(t + ) = 2u
x
v
x
(t)
v
y
(t + ) = v
y
(t)
y
v
x
(t + ) = v
x
(t)
v
y
(t + ) = 2u
y
v
y
(t)
x+ y
2
v
x
(t + ) = u
x
+ u
y
v
y
(t)
v
y
(t + ) = u
x
+ u
y
v
x
(t)
x y
2
v
x
(t + ) = u
x
u
y
+ v
y
(t)
v
y
(t + ) = u
y
u
x
+ v
x
(t)
Table 4.1: Non-ideal collision equations.
In order to have the proper thermodynamics, collisions happen with a probability P,
given by
P = tanh(AuM
a
M
b
) , (4.1)
where A is a parameter (like inverse temperature), u is the dierence in velocities between
box a and b, and M
a
and M
b
are the number of particles in each of the two participating
boxes.
The hyperbolic tangent function is used because it provides a nice curve for mapping
the domain [0, ) onto [0, 1]. It is linear with slope d tanh(x)/dx = 1 at x = 0, but
asymptotically approaches 1 as x approaches innity. This helps keep the probability in the
appropriate domain, though A should be chosen such that the probability does not saturate.
If A is too high, the probability looses its dependence on M
A
, M
B
, and u, which is a
reection of k
B
T.
All of the dierent steps in a timestep should happen simultaneously in order to be
invariant under time-reversal. For SRD this is not a problem, because the collision step does
not aect position, and the streaming step does not aect velocity. For SRD and non-ideal
collisions in the same system, however, this is important, and needs to be addressed. The
simplest way of solving the problem is to randomly average it out, similar to the spacial
random averaging used for shifting. By randomly picking which collision type to do rst, it
means that on average the collisions happen at the same time, and time-reversal invariance
is restored.
4.2 Test of Model
4.2.1 Conservation Laws
The primary test of the new collision rules is conservation of momentum and energy. In
theory both are conserved, since the collisions are elastic. Simulation results show that they
are indeed conserved, as expected (data not shown).
37
0 8 16 24 32
X
0
8
16
24
32
Y
Figure 4.3: A frozen non-ideal uid. L = 32, a = 1, M = 5, k
B
T = 0.001, = 0.1, = 90
.
Though not thermodynamically consistent, A is chosen extremely large to emphasize the
eect.
4.2.2 Freezing
Since the new collisions model a hard-sphere uid with a non-ideal equation of state, it is
capable of freezing at low enough temperatures. The square structure of the SRD model
means that the frozen uid has a square crystal structure. When it freezes, sets of particles
clump together. These particles behave as normal SRD, since they are close enough that
the non-ideal collision rarely aects them (only when shifting causes a boundary to cross the
group). The groups then collide with each other via the non-ideal term, since they are too
far away for SRD to aect them. This keeps them stable.
4.3 Binary Fluid
Using the non-ideal uid collisions, a binary uid can also be simulated. Instead of having
just a single species of particle in the simulation, one can have two of them. They interact
with each other dierently (although symmetrically), resulting in an immiscible binary uid,
as explained in the following sections.
4.3.1 Binary Collisions
While the non-ideal collisions normally happen with all the particles in two adjacent boxes,
in the case of binary collisions, it is only between dierent particle types. With two particle
species A and B, A particles in the rst box collide with B particles in the second box, while
B particles in the rst box collide with A particles in the second box. This means that
38
(a) Spontaneously cooled homogeneous
mixture.
(b) After some time, the uid has par-
tially separated into its components.
Figure 4.4: Binary mixture separating.
Figure 4.5: A binary droplet.
a homogeneous (only type A) uid will behave as normal SRD. However, at an interface
between A and B, the particles will collide with each other and be mutually repelled.
4.3.2 Phase Separation and Droplet Formation
The repulsion between the two species is eective enough to let the two uids phase separate
from a homogeneous mixture into areas of their components. Figure 4.3.2 shows 50%-50%
mixture phase separating after starting from a completely random distribution. Figure 4.3.2
shows an example of a droplet of radius 12, which is made with a with a 56%-44% mixture.
39
Chapter 5
Conclusions and Future Directions
We wrote an implementation of the SRD uid simulation technique. This implementation
was analytically proven to conserve momentum an energy, and demonstrated to do so in
practice as well. Previous work has analytically determined the expected diusion coecient
and kinematic viscosity for an SRD uid, and simulation results match these theoretical
expectations. Additionally, pressure was measured, and the ideal gas properties of SRD
were demonstrated.
This method has a number of potential applications. The rst of these is combining
molecular dynamics and multiple-component simulations to model surfactant systems. This
would allow us to study capillary waves in the surface of a droplet, and look at how surface
tension changes with the addition of a surfactant. Extending the molecular dynamics part
would allow us to model a Purcell swimmer. While the Purcell swimmer has been modeled
before in a continuum system, the Brownian kicks of the SRD solvent would provide a novel
(and more realistic) environment. Depending on the implementation, it could be possible to
have the rods connecting particles in molecular dynamics be solid boundaries. This would
also enable the simulation of impermeable and semi-permeable membranes, commonly found
in biological systems.
40
Appendix A
Code Samples
As our implementation of the SRD simulation method was written in C, the example pieces
of code provided here are also.
A.1 Data Types
There are structs for particles and for boxes:
typedef struct {
double sX; //position
double sY;
double vX; //velocity
double vY;
int rX; //wrap count
int rY;
int mass;
} particle;
typedef struct {
double mX; //total momentum
double mY;
double count; //particles in the box
int rotDir; //direction of rotation
} box;
A.2 SRD Collisions
The core of the SRD collision:
void collide(particle particles[], box boxes[], double boxShiftX, double boxShiftY) {
int i;
double nX;
double nY;
int boxnum;
for(i=0;i<PART_COUNT;i++) {
41
boxnum = CALC_BOX_NUM; //a macro for determining the ID of the box the particle is in.
particles[i].vX -= boxes[boxnum].mX; //subtract average velocity
particles[i].vY -= boxes[boxnum].mY;
nX = particles[i].vX*Wxx+boxes[boxnum].rotDir*particles[i].vY*Wxy; //do rotation
nY = boxes[boxnum].rotDir*particles[i].vX*Wyx+particles[i].vY*Wyy;
particles[i].vX = nX + boxes[boxnum].mX; //add average velocity back
particles[i].vY = nY + boxes[boxnum].mY;
}
}
A.3 Eulerian Streaming
Simple Eulerian Streaming:
void move(particle particles[]) {
int i;
for(i=0;i<PART_COUNT;i++) {
particles[i].sX += particles[i].vX*TAU;
particles[i].sY += particles[i].vY*TAU;
}
}
A.4 Thermal Walls
Thermal Walls:
inline void thermalWallsX(particle* part) { //inlined to improve efficiency
double t;
if(part->sX < 0) {
t = part->sX/part->vX;
part->sY -= t*part->vY;
part->vX = randm()*SQRT_WALL_TEMP*SQRT_2;
part->vY = randn()*SQRT_WALL_TEMP;
part->sX = part->vX*t;
part->sY += part->vY*t;
} else if(part->sX > WIDTH) {
t = (part->sX-WIDTH)/part->vX;
part->sY -= t*part->vY;
part->vX = -1*randm()*SQRT_WALL_TEMP*SQRT_2;
part->vY = randn()*SQRT_WALL_TEMP;
part->sX = WIDTH+part->vX*t;
part->sY += part->vY*t;
}
}
42
A.5 Periodic Boundary Conditions
inline void periodicBoundaryCondX(particle* part) {
part->rX += floor(part->sX/WIDTH);
part->sX -= WIDTH*floor(part->sX/WIDTH);
}
43
Bibliography
[1] F. J Alexander and A. L Garcia. The direct simulation monte carlo method. Computers in Physics,
11(6):588, 1997. 8
[2] G. A. Bird. Molecular Dynamics and the Direct Simulation of Gas Flow. Oxford Science Publications,
Oxford, 1994. 8
[3] W. D Cornell, P. Cieplak, C. I Bayly, I. R Gould, K. M Merz, D. M Ferguson, D. C Spellmeyer, T. Fox,
J. W Caldwell, and P. A Kollman. A second generation force eld for the simulation of proteins, nucleic
acids, and organic molecules. Journal of the American Chemical Society, 117(19):51795197, 1995. 7
[4] E. R Davidson and D. Feller. Basis set selection for molecular calculations. Chemical Reviews,
86(4):681696, 1986. 7
[5] J. K.G Dhont. An introduction to dynamics of colloids. Elsevier Science, 1996. 8
[6] P. Espanol. Hydrodynamics from dissipative particle dynamics. Physical Review E, 52(2):17341742,
1995. 7
[7] P. Espanol and P. Warren. Statistical mechanics of dissipative particle dynamics. EPL (Europhysics
Letters), 30:191, 1995. 7
[8] Robert Eymard, Thierry Gallouet, Rapha`ele Herbin, P.G. Ciarlet, and J.L. Lions. Finite volume
methods. In Solution of Equation in [real]n (Part 3), Techniques of Scientic Computing (Part 3),
volume Volume 7, pages 7131018. Elsevier, 2000. 6
[9] U. Frisch, B. Hasslacher, and Y. Pomeau. Lattice-gas automata for the Navier-Stokes equation. Physical
review letters, 56(14):15051508, 1986. 6
[10] Alejandro Garcia. Numerical methods for physics. Prentice Hall, Upper Saddle River N.J., 2nd ed.
edition, 2000. 8
[11] G. Gompper, T. Ihle, D. Kroll, and R. Winkler. Multi-particle collision dynamics: A particle-based
mesoscale simulation approach to the hydrodynamics of complex uids. In Christian Holm and Kurt
Kremer, editors, Advanced Computer Simulation Approaches for Soft Matter Sciences III, volume 221
of Advances in Polymer Science, pages 187. Springer Berlin / Heidelberg, 2009. 10.1007/978-3-540-
87706-6-1. 8, 17, 18
[12] X. He, S. Chen, and G. D Doolen. A novel thermal model for the lattice boltzmann method in incom-
pressible limit* 1. Journal of Computational Physics, 146(1):282300, 1998. 6
[13] P. J. Hoogerbrugge and J. Koelman. Simulating microscopic hydrodynamic phenomena with dissipative
particle dynamics. EPL (Europhysics Letters), 19:155, 1992. 7
[14] T. Ihle and D. Kroll. Stochastic rotation dynamics:a galilean-invariant mesoscopic model for uid ow.
Physical Review E, 63(2), 2001. 8, 14
44
[15] R. G Larson. The structure and rheology of complex uids. New York: Oxford, 2001. 9
[16] Anatoly Malevanets and Raymond Kapral. Mesoscopic model for solvent dynamics. The Journal of
Chemical Physics, 110(17):8605, 1999. 8, 10
[17] S. L Mayo, B. D Olafson, and W. A Goddard. DREIDING: a generic force eld for molecular simulations.
Journal of Physical Chemistry, 94(26):88978909, 1990. 7
[18] G. R McNamara and G. Zanetti. Use of the boltzmann equation to simulate lattice-gas automata.
Physical Review Letters, 61(20):23322335, 1988. 6
[19] M. Ripoll, K. Mussawisade, R. G. Winkler, and G. Gompper. Dynamic regimes of uids simulated by
multiparticle-collision dynamics. Physical Review E, 72(1):016701, 2005. 8
[20] X. Shan and H. Chen. Lattice boltzmann model for simulating ows with multiple phases and compo-
nents. Physical Review E, 47(3):1815, 1993. 6
[21] E. T uzel, T. Ihle, and D. Kroll. Dynamic correlations in stochastic rotation dynamics. Physical Review
E, 74(5), 2006. 18, 23, 26
[22] Frank White. Viscous uid ow. McGraw-Hill Higher Education, New York NY, 3rd ed. edition, 2006.
9
45