Skip to content

A Julia interface to the FMM2D library from the Flatiron Institute

License

Notifications You must be signed in to change notification settings

mipals/FMM2D.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FMM2D.jl

Build Status Coverage

FMM2D.jl is a Julia interface for computing N-body interactions using the Flatiron Institute's FMM2D library.

Currently, the wrapper only wraps the Helmholtz and Laplace functionalities.

Helmholtz FMM

Let c s C ,   s = 1 , , N denote a collection of charge strengths, v s C ,   s = 1 , , N denote a collection of dipole strengths, and d s R 2 ,   s = 1 , , N denote the corresponding dipole orientation vectors. Furthermore, k C denotes the wave number. The Helmholtz potential u caused by the presence of a collection of M sources ( x s ) at N target positions ( x t ) is computed as

u ( x t ) = s = 1 M c s H 0 ( 1 ) ( k | x t x s | ) v s d s H 0 ( 1 ) ( k | x t x s | ) , t = 1 , , N

where H 0 ( 1 ) is the Hankel function of the first kind of order 0. When x = x j the j th term is dropped from the sum. Performing this summation would scale as O ( N M ) , but using the Flatiron Insitutes Fast Multipole Library a linear scaling of O ( ( N + M ) log ( ε 1 ) ) can be achieved with ε being the desired relative precision. Note that the library also includes the option for computing the gradient and Hessian of the potential.

Example

using FMM2D

# Simple example for the FMM2D Library
thresh = 10.0^(-5)          # Tolerance
zk     = rand(ComplexF64)   # Wavenumber

# Source-to-source
n = 200
sources = rand(2,n)
charges = rand(ComplexF64,n)
pg = 3 # Evaluate potential, gradient, and Hessian at the sources
vals = hfmm2d(eps=thresh,zk=zk,sources=sources,charges=charges,pg=pg)
vals.pot
vals.grad
vals.hess

# Source-to-target
m = 200
targets = rand(2,m)
pgt = 3 # Evaluate potential, gradient, and Hessian at the targets
vals = hfmm2d(targets=targets,eps=thresh,zk=zk,sources=sources,charges=charges,pgt=pgt)
vals.pottarg
vals.gradtarg
vals.hesstarg

Laplace

The Laplace problem in 2D have the following form

u ( x ) = j = 1 N [ c j log ( | x x j | ) d j v j ( log ( | x x j | ) ) ] ,

In the case of complex charges and dipole strengths ( c j , v j C n ) the function call lfmm2d has to be used. In the case of real charges and dipole strengths ( c j , v j R n ) the function call rfmm2d has to be used.

Example

using FMM2D

# Simple example for the FMM2D Library
thresh = 10.0^(-5)          # Tolerance

# Source-to-source
n = 200
sources = rand(2,n)
charges = rand(ComplexF64,n)
dipvecs = randn(2,n)
dipstr = rand(ComplexF64,n)
pg = 3 # Evaluate potential, gradient, and Hessian at the sources
vals = lfmm2d(eps=thresh,sources=sources,charges=charges,dipvecs=dipvecs,dipstr=dipstr,pg=pg)
vals.pot
vals.grad
vals.hess

# Source-to-target
m = 100
targets = rand(2,m)
pgt = 3 # Evaluate potential, gradient, and Hessian at the targets
vals = lfmm2d(targets=targets,eps=thresh,sources=sources,charges=charges,dipvecs=dipvecs,dipstr=dipstr,pgt=pgt)
vals.pottarg
vals.gradtarg
vals.hesstarg

Stokes

u ( x ) = j = 1 N G stok ( x , x j ) c j + d j T stok ( x , x j ) v j

p ( x ) = j = 1 N P stok ( x , x j ) c j + d j Π stok ( x , x j ) v j

Related Package

FMMLIB2D.jl interfaces the FMMLIB2D library which the FMM2D library improves on.

About

A Julia interface to the FMM2D library from the Flatiron Institute

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages