Download A Particle in Cell Corrected Approach to Direct Sum

Document related concepts

Path integral formulation wikipedia , lookup

Relativistic quantum mechanics wikipedia , lookup

Brownian motion wikipedia , lookup

Transcript
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
A Particle in Cell Corrected Approach to
Direct Sum
Ben Lewis, Bridget Morales, David Marsico, Jason
McKelvey, and Madie Wilkin
Adviser: Dr. Andrew Christlieb
Co-advisers: Eric Wolf and Justin Droba
Michigan St. University
July 23, 2014
The N-Body Problem
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
Solar systems
The N-Body Problem
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
Solar systems
Interacting charges, gases and plasma
The N-Body Problem
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
Solar systems
Interacting charges, gases and plasma
We want to solve the system of ODE’s given by:
dxi
= vi
dt
for i = 1, . . . , n.
dvi
Fi (x1 , . . . , xn )
= ai =
dt
mi
Traditional Solutions
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
Direct Sum
Particle Mesh
Particle-Particle Particle-Mesh
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
The net force on particle i is:
Fi =
n
X
j=1
j6=i
qi Ej,i
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
The net force on particle i is:
Fi =
n
X
qi Ej,i
j=1
j6=i
Ej,i is the electric field from particle j at the location of
particle i and qi is the charge
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
The net force on particle i is:
Fi =
n
X
qi Ej,i
j=1
j6=i
Ej,i is the electric field from particle j at the location of
particle i and qi is the charge
To calculate the force on all of the particles, we must
repeat this summation for each of the n particles
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
The net force on particle i is:
Fi =
n
X
qi Ej,i
j=1
j6=i
Ej,i is the electric field from particle j at the location of
particle i and qi is the charge
To calculate the force on all of the particles, we must
repeat this summation for each of the n particles
The problem with direct sum is that it is O(N 2 )
Goal
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
Find efficient ways to solve the n-body problem.
Goal
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
Find efficient ways to solve the n-body problem.
Improve efficiency from O(n2 ) to O(n) + O(k 2 ) where
k << n and k is the number of particles per cell.
Table: Theoretical Time Comparison (3600
MHz computer)
N
Ej,i =
qj
0 G(xj |xi )
Fj,i = qi ∗ Ej,i
O(N 2 )
O(N)
10
10−8
sec
10−9 sec
103
10−4 sec
10−7 sec
106
5 min
10−4 sec
109
8 yrs
.28 sec
1012
106
yrs
4.6 min
We are working on it.
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
We made a Finite Difference Mesh based method, which is
a variation of the Particle-Particle Particle-Mesh method,
that improved efficiency from O(n2 ) to approximately
O(n)
We are working on it.
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
We made a Finite Difference Mesh based method, which is
a variation of the Particle-Particle Particle-Mesh method,
that improved efficiency from O(n2 ) to approximately
O(n)
We want to compute the field on the particles quickly
We are working on it.
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
We made a Finite Difference Mesh based method, which is
a variation of the Particle-Particle Particle-Mesh method,
that improved efficiency from O(n2 ) to approximately
O(n)
We want to compute the field on the particles quickly
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
(n)
(n−1/2)
(n+1)
xi , vi
xi
Interpolate
Leapfrog
(n−1/2)
ρ(n)
vi
Poisson Solve
φ(n)
Leapfrog
Finite
Difference
E (n)
Interpolate
(n)
ai
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
(n)
(n−1/2)
(n+1)
xi , vi
xi
Interpolate
Leapfrog
(n−1/2)
ρ(n)
vi
Poisson Solve
φ(n)
Boundary
Integral
Corrected
Direct Sum
Leapfrog
E (n)
Interpolate
(n)
ai
Using Finite Difference to Solve
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
(x̄, ȳ + h)
(x̄ − h, ȳ )
(x̄ − h, ȳ + h)
(x̄, ȳ + h)
(x̄ + h, ȳ + h)
(x̄ + h, ȳ )
(x̄ − h, ȳ )
(x̄, ȳ − h)
Five-Point Stencil
(x̄ − h, ȳ − h)
(x̄ + h, ȳ )
(x̄, ȳ − h)
(x̄ + h, ȳ − h)
Nine-Point Stencil
Using Finite Difference to Solve
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
(x̄, ȳ + h)
(x̄ − h, ȳ )
(x̄ − h, ȳ + h)
(x̄, ȳ + h)
(x̄ + h, ȳ + h)
(x̄ + h, ȳ )
(x̄ − h, ȳ )
(x̄, ȳ − h)
Five-Point Stencil
∇2 φ = ∂xx φ + ∂yy φ
(x̄ − h, ȳ − h)
(x̄ + h, ȳ )
(x̄, ȳ − h)
(x̄ + h, ȳ − h)
Nine-Point Stencil
Using Finite Difference to Solve
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
(x̄, ȳ + h)
(x̄ − h, ȳ )
(x̄ − h, ȳ + h)
(x̄, ȳ + h)
(x̄ + h, ȳ + h)
(x̄ + h, ȳ )
(x̄ − h, ȳ )
(x̄, ȳ − h)
(x̄ − h, ȳ − h)
(x̄ + h, ȳ )
(x̄, ȳ − h)
(x̄ + h, ȳ − h)
Five-Point Stencil
Nine-Point Stencil
2
∇ φ = ∂xx φ + ∂yy φ
∇2 φ =
j,k+1 −2φj,k +φj,k−1
φj+1,k −2φj,k +φj−1,k
+φ
+ O(∆x 2 + ∆y 2 )
(∆x)2
(∆y )2
where j is the index for x and k is the index for y
Using Finite Difference to Solve
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
(x̄, ȳ + h)
(x̄ − h, ȳ )
(x̄ − h, ȳ + h)
(x̄, ȳ + h)
(x̄ + h, ȳ + h)
(x̄ + h, ȳ )
(x̄ − h, ȳ )
(x̄, ȳ − h)
(x̄ − h, ȳ − h)
(x̄ + h, ȳ )
(x̄, ȳ − h)
(x̄ + h, ȳ − h)
Five-Point Stencil
Nine-Point Stencil
2
∇ φ = ∂xx φ + ∂yy φ
∇2 φ =
j,k+1 −2φj,k +φj,k−1
φj+1,k −2φj,k +φj−1,k
+φ
+ O(∆x 2 + ∆y 2 )
(∆x)2
(∆y )2
where j is the index for x and k is the index for y
~=ρ
Aφ
~
Using Finite Difference to Solve
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
(x̄, ȳ + h)
(x̄ − h, ȳ )
(x̄ − h, ȳ + h)
(x̄, ȳ + h)
(x̄ + h, ȳ + h)
(x̄ + h, ȳ )
(x̄ − h, ȳ )
(x̄, ȳ − h)
(x̄ − h, ȳ − h)
(x̄ + h, ȳ )
(x̄, ȳ − h)
(x̄ + h, ȳ − h)
Five-Point Stencil
Nine-Point Stencil
2
∇ φ = ∂xx φ + ∂yy φ
∇2 φ =
j,k+1 −2φj,k +φj,k−1
φj+1,k −2φj,k +φj−1,k
+φ
+ O(∆x 2 + ∆y 2 )
(∆x)2
(∆y )2
where j is the index for x and k is the index for y
~=ρ
Aφ
~
−h)
Ey (x, y ) = φ(x,y +h)−φ(x,y
,
2h
φ(x+h,y )−φ(x−h,y )
Ex (x, y ) =
2h
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
Acceleration is used to find the velocity at t = n + .5
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
Acceleration is used to find the velocity at t = n + .5
That velocity is then used to find the position of each
particle at t = n + 1
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
Acceleration is used to find the velocity at t = n + .5
That velocity is then used to find the position of each
particle at t = n + 1
This is the leapfrog algorithm
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
Acceleration is used to find the velocity at t = n + .5
That velocity is then used to find the position of each
particle at t = n + 1
This is the leapfrog algorithm
v1/2 = v0 + a0 ·
dt
2
vn+1/2 = vn−1/2 + an · dt
xn = xn−1 + vn−1/2 · dt
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
Deriving Green’s Identity
φ(x) =
N
X
i=1
Z
G (xi −x0 )−
∂V
(G (x − x0 )∇φ − φ∇G (x − x0 ))·~
nds
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
Deriving Green’s Identity
φ(x) =
N
X
Z
G (xi −x0 )−
(G (x − x0 )∇φ − φ∇G (x − x0 ))·~
nds
∂V
i=1
Z
V
∇ · F~ dv =
Z
∂V
F~ · n~ds
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
Deriving Green’s Identity
φ(x) =
N
X
Z
G (xi −x0 )−
(G (x − x0 )∇φ − φ∇G (x − x0 ))·~
nds
∂V
i=1
Z
V
∇ · F~ dv =
Z
F~ · n~ds
∂V
Let F~ = θγ where θ is a scalar function, γ = ∇ψ is a vector
function.
Z
Z
2
(θ∇ψ · n~) ds
θ∇ ψ + ∇θ · ∇ψ dV =
V
∂V
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
Deriving Green’s Identity
φ(x) =
N
X
Z
G (xi −x0 )−
(G (x − x0 )∇φ − φ∇G (x − x0 ))·~
nds
∂V
i=1
Z
V
∇ · F~ dv =
Z
F~ · n~ds
∂V
Let F~ = θγ where θ is a scalar function, γ = ∇ψ is a vector
function.
Z
Z
2
(θ∇ψ · n~) ds
θ∇ ψ + ∇θ · ∇ψ dV =
V
∂V
If we let θ = G (x − x0 ) and ψ = φ, then we can solve for the
potential φ(x)
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
We can use the fact that
N
P
ρ=
δ(x − xi )
i=1
A Particle in
Cell Corrected
Approach to
Direct Sum
We can use the fact that
N
P
ρ=
δ(x − xi )
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
We can solve for φ to obtain:
Z
N
X
φ(x) =
G (xi − x0 ) −
i=1
i=1
∂V
(G ∇φ − φ∇G ) · n~ds
A Particle in
Cell Corrected
Approach to
Direct Sum
We can use the fact that
N
P
ρ=
δ(x − xi )
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
We can solve for φ to obtain:
Z
N
X
φ(x) =
G (xi − x0 ) −
i=1
i=1
φx,j =
N
P
i=1
i6=j
−1
2π
ln (||xi − xj ||2 ) +
(G ∇φ − φ∇G ) · n~ds
∂V
H
∂Ω (φ∇G
− G ∇φ) · n~ ds
A Particle in
Cell Corrected
Approach to
Direct Sum
We can use the fact that
N
P
ρ=
δ(x − xi )
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
We can solve for φ to obtain:
Z
N
X
φ(x) =
G (xi − x0 ) −
i=1
i=1
φx,j =
N
P
i=1
i6=j
−1
2π
ln (||xi − xj ||2 ) +
(G ∇φ − φ∇G ) · n~ds
∂V
H
∂Ω (φ∇G
− G ∇φ) · n~ ds
New equation because Potential Theory tells us it is the
same
N
H
P
−1
φx,j =
2π ln (||xi − xj ||2 ) + ∂Ω σs (y )G (xj − y ) ds(y )
i=1
i6=j
A Particle in
Cell Corrected
Approach to
Direct Sum
We can use the fact that
N
P
ρ=
δ(x − xi )
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
We can solve for φ to obtain:
Z
N
X
φ(x) =
G (xi − x0 ) −
i=1
i=1
φx,j =
N
P
i=1
i6=j
−1
2π
ln (||xi − xj ||2 ) +
(G ∇φ − φ∇G ) · n~ds
∂V
H
∂Ω (φ∇G
− G ∇φ) · n~ ds
New equation because Potential Theory tells us it is the
same
N
H
P
−1
φx,j =
2π ln (||xi − xj ||2 ) + ∂Ω σs (y )G (xj − y ) ds(y )
i=1
i6=j
σ is like a surface charge
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
We use direct sum to calculate the field due to local
particles
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
We use direct sum to calculate the field due to local
particles
In order to evaluate the boundary integral, we solve using
numerical quadrature.
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
We use direct sum to calculate the field due to local
particles
In order to evaluate the boundary integral, we solve using
numerical quadrature.
We end up with a matrix that we have to invert to obtain
the surface charge.
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
We use direct sum to calculate the field due to local
particles
In order to evaluate the boundary integral, we solve using
numerical quadrature.
We end up with a matrix that we have to invert to obtain
the surface charge.
Then, instead of doing this everywhere which would be
O(n2 ), we make this a subcell method which gives
O(n) + O(k 2 ).
Solving for Sigma
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
R s2
s1
σG ds
Solving for Sigma
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
R s2
s1
σG ds
We take a limit to the boundary with respect to variable x
and get the integral equation
Solving for Sigma
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
R s2
s1
σG ds
We take a limit to the boundary with respect to variable x
and get the integral equation
We turn the integral into discrete approximations that we
can solve
Solving for Sigma
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
R s2
s1
σG ds
We take a limit to the boundary with respect to variable x
and get the integral equation
We turn the integral into discrete approximations that we
can solve
The integral becomes four sums
Solving for Sigma
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
R s2
s1
σG ds
We take a limit to the boundary with respect to variable x
and get the integral equation
We turn the integral into discrete approximations that we
can solve
The integral becomes four sums
We use integral mean value theorem and trapezoid rule to
end up with the Green’s matrix
4k R
P
s2
s1 σG ds
i=1
Solving for Sigma
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
R s2
s1
σG ds
We take a limit to the boundary with respect to variable x
and get the integral equation
We turn the integral into discrete approximations that we
can solve
The integral becomes four sums
We use integral mean value theorem and trapezoid rule to
end up with the Green’s matrix
4k R
P
s2
s1 σG ds
i=1
Then we end up with a system of equations in which we
need to perform a Green’s matrix inversion
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
In order to get the Boundary Integral Corrected Direct Sum
Electric Fields we need several things
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
In order to get the Boundary Integral Corrected Direct Sum
Electric Fields we need several things
List of all particles inside the cell
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
List of all particles in boundary cells
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
Potential at all 12 border points per cell
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
Something to take the above and calculate the electric
field
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
For loop over all cells
A Particle in
Cell Corrected
Approach to
Direct Sum
For loop over all cells
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
If we can get this done, then it’s a matter of increasing
customizability
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
Figure: Uncorrected
A Particle in
Cell Corrected
Approach to
Direct Sum
Ben Lewis,
Bridget
Morales,
David
Marsico,
Jason
McKelvey,
Madie Wilkin
Figure: Point charge at the center