Upload
truonganh
View
214
Download
0
Embed Size (px)
Citation preview
Density Estimation Techniques for Density Estimation Techniques for Charged Particle Beams Charged Particle Beams
BalBalšša Terzića TerzićBeam Physics and Astrophysics Group, NICADDBeam Physics and Astrophysics Group, NICADD
Northern Illinois University, USANorthern Illinois University, USA
Work done in collaboration with Work done in collaboration with Gabriele BassiGabriele Bassi
Cockcroft InstituteCockcroft Institute
Cockcroft Institute SeminarCockcroft Institute SeminarFebruary 26, 2009February 26, 2009
MotivationMotivation• When a charged particle beam traverses a curved trajectory, beam's selfinteraction leads to coherent synchrotron radiation (CSR)
• Beam's selfinteraction has adverse effects:
• Appreciable emittance degradation• Microbunching instability which degrades beam quality (major concern for FELs, which require bright electron beams)
• Proper numerical modeling of CSR requires:
• Pointtopoint methods: solving the microscopic Maxwell's equation (LienardWiechert potentials) • Mean field methods: solving VlasovMaxwell equation (finite difference, finite element, Green's function, retarded potentials)
• Possible simplifications to 3D CSR modeling:
• 1D line approximation (IMPACT, ELEGANT): probably too simplistic • 2D approximation: codes by Li 1998, Bassi et al. 2006
MotivationMotivation
• Bassi's 2D CSR VlasovMaxwell code (original version):
• Monte Carlo code: particle density sampled by particles
• Particle density estimated analytically by a cosine expansion
• Particle density evaluated on a finite grid and stored for evaluation of retarded potentials
• Although accurate, the density estimation is quite timeconsuming
• Here we present two alternative gridbased methods for particle density estimation:
• Truncated fast cosine transform on the grid
• Waveletdenoised approximation on the grid
● Outline of the current version of Bassi's 2D CSR code
● Grid representation– Particle deposition– Numerical noise in gridbased methods
● Alternative method 1: Fast cosine transform on the grid
● Alternative method 2: Wavelet transform on the grid– Brief overview of wavelets– Wavelet denoising
● Comparison: the new methods Vs. the old– Spatial resolution– Accuracy – Smoothness– Efficiency
● Discussion of further work
● Summary
Outline of the TalkOutline of the Talk
● 2D VlasovMaxwell
● Selfconsistent treatment
● Monte Carlo: particle density ρ(x,z) is sampled by N particles (Klimontovich distribution)
and then approximated by a Monte Carlo cosine expansion:
Ncx, N
cz: # of basis func. in x and zcoord.
where
● Computation of cnm
scales as ~ O(NNcxN
cz)
● Selffields are computed from the beam's history represented by cnm
(ti)
Outline of the Current Version of Bassi's CSR CodeOutline of the Current Version of Bassi's CSR Code
x , z =∑n=1
N cx
∑m=1
N cz
cnmn x m z
k y =1 if k=0k y=2 cos k y if k≠0
cnm=1N∑i=1
N
nx im zi
K x , z =∑i=1
N
x− x i z−zi δ(y): Dirac delta function
• – gridpoint location
NGP
CIC
Grid Representation: Particle DepositionGrid Representation: Particle Deposition
● Grid determined so as to tightlyenvelope all particles– Minimizing empty cells
optimal spatial resolution
● Grid resolution:– N
x : # of gridpoint in xcoord.
– Nz : # of gridpoint in zcoord.
– Ngrid
=Nx N
z : # of nodes on grid
● Main particle deposition schemes:
– Nearest Grid Point (NGP)
– CloudInCell (CIC)
x – particle location
● Any Nbody simulation will have numerical noise
● Sources of numerical noise in ParticleInCell (PIC) simulations:
– Graininess of the distribution function: Nsimulation
<< Nphysical
– Discreteness of the computational domain: and given on a finite grid
● Understanding the numerical noise is key to removing it
● For NGP, at each gridpoint, density dist. is Poissonian:
nj is the expected number in jth cell; n integer
● For CIC, at each gridpoint, density dist. is contracted Poissonian:
a=(2/3)(D/2) 0.82 (1D), 0.67 (2D), 0.54 (3D)
Numerical Noise In GridBased MethodsNumerical Noise In GridBased Methods
P=n ! −1an j n e−an j
(For more details see Terzić, Pogorelov & Bohn 2007, PR STAB, 10, 034201)
P=n ! −1n j n e−n j
Numerical Noise In GridBased MethodsNumerical Noise In GridBased Methods
● Global measure of error (noise) in depositing particles onto a grid:
where qi= (Q
total/N)n
i , Q
total total charge; N
grid number of gridpoints
● This error/noise estimate σ is crucial for optimal noise removal
● Signal with Poissonian noise can be transformed to the signal with Gaussian noise by Anscombe transformation:
YP = signal with Poissonian (multiplicative) noise
YG = signal with Gaussian (additive) noise
● Less numerical noise running simulations with more particles
● Removing noise: – In Fourier space: simple truncation of higher frequencies– In wavelet space: judicious noise removal by wavelet thresholding
2=
1N grid
∑i=1
Ngrid
Var q i CIC2
=a2Qtotal
2
N Ngrid
Y G=2 Y P38
NGP2
=Qtotal
2
N N grid
● Once the particles have been deposited on the (Nx, N
z) grid:
1. Apply forward Fast Cosine Transform (FCT)
2. Keep only (1..Ncx, 1..N
cz) frequencies: filtering out higher frequencies
(unlike Monte Carlo, no extra work for computing up to Nx, N
z modes)
3. Apply inverse FCT
● Filtering (truncation)
– Removes contribution from high order frequencies (simple denoising)
– Smoothens the distribution
– Imposes further limitation on spatial resolution
● FCT scales as O(Ngrid
) (independent of N)
– Much faster than Monte Carlo cosine expansion
Alternative Method 1:Alternative Method 1:Fast Cosine Transform on the GridFast Cosine Transform on the Grid
● Wavelets: orthogonal basis composed of scaled and translated versions of the same localized mother wavelet ψ(x) and the scaling function ф(x):
● Discrete Wavelet Transfrom (DWT) iteratively separates scales
– O(MN) operation, M size of the wavelet filter, N size of the discrete signal
● Advantages:
– Simultaneous localization in both space and frequency (FFT only frequency)
– Compact representation of data, enabling compression (FBI fingerprints)
– Denoising: wavelets provide a natural setting for noise removal denoised simulation simulation with more particles
Brief Overview of WaveletsBrief Overview of Wavelets
f x =s000
0x ∑
i∑
jd i
ki
kx
ikx =2
k2 0
02 k x−i
Wavelet DenoisingWavelet Denoising● In wavelet space:
Signal few large wavelet coefficients cij
Noise many small wavelet coefficients cij
● Denoising by wavelet thresholding: If |c
ij|< T , set to c
ij =0 (choose threshold T carefully!)
● A great deal of study has been devoted to estimating optimal T
( σ was estimated earlier)
Denoising factor:
T=2 log N grid
Terzić, Pogorelov & Bohn 2007, PR STAB, 10, 034201DF T =
Error original
Error denoised
● When the signal is known, one can compute SignaltoNoise Ratio (SNR):
● SNR ~ √Nppc
Nppc
: avg. # of particles per cell Nppc
= N/Ncells
ANALYTICAL Nppc
=3 SNR=2.02N
ppc=205 SNR=16.89
Wavelet Denoising and CompressionWavelet Denoising and Compression
SNR= ∑iq i2
∑iq i−q i
2
q i=exactq i=approx.
● When the signal is known, one can compute SignaltoNoise Ratio (SNR):
● SNR ~ √Nppc
Nppc
: avg. # of particles per cell Nppc
= N/Ncells
2D superimposed Gaussians on 256×256 grid
ANALYTICAL Nppc
=3 SNR=2.02N
ppc=205 SNR=16.89
Wavelet Denoising and CompressionWavelet Denoising and Compression
SNR= ∑iq i2
∑iq i−q i
2
q i=exactq i=approx.
● When the signal is known, one can compute SignaltoNoise Ratio (SNR):
● SNR ~ √Nppc
Nppc
: avg. # of particles per cell Nppc
= N/Ncells
2D superimposed Gaussians on 256×256 grid
ANALYTICAL Nppc
=3 SNR=2.02N
ppc=205 SNR=16.89
Wavelet Denoising and CompressionWavelet Denoising and Compression
SNR= ∑iq i2
∑iq i−q i
2
q i=exactq i=approx.
● When the signal is known, one can compute SignaltoNoise Ratio (SNR):
● SNR ~ √Nppc
Nppc
: avg. # of particles per cell Nppc
= N/Ncells
2D superimposed Gaussians on 256×256 grid
ANALYTICAL Nppc
=3 SNR=2.02 Nppc
=205 SNR=16.89
Wavelet Denoising and CompressionWavelet Denoising and Compression
SNR= ∑iq i2
∑iq i−q i
2
q i=exactq i=approx.
● When the signal is known, one can compute SignaltoNoise Ratio (SNR):
● SNR ~ √Nppc
Nppc
: avg. # of particles per cell Nppc
= N/Ncells
2D superimposed Gaussians on 256×256 grid
● denoising by wavelet thresholding: if |cij|< T , set to 0
ANALYTICAL Nppc
=3 SNR=2.02 Nppc
=205 SNR=16.89
Wavelet Denoising and CompressionWavelet Denoising and Compression
SNR= ∑iq i2
∑iq i−q i
2
q i=exactq i=approx.
● When the signal is known, one can compute SignaltoNoise Ratio (SNR):
● SNR ~ √Nppc
Nppc
: avg. # of particles per cell Nppc
= N/Ncells
2D superimposed Gaussians on 256×256 grid
● denoising by wavelet thresholding: if |cij|< T , set to 0
● Advantages: increase in SNR by c c2 more particles (here c=8.3, c2=69)
compact storage in wavelet space (in this example 79/65536: 0.12%)
ANALYTICAL Nppc
=3 SNR=2.02 Nppc
=205 SNR=16.89
Wavelet Denoising and CompressionWavelet Denoising and Compression
SNR= ∑iq i2
∑iq i−q i
2
q i=exactq i=approx.
COMPACT: only 0.12% of coeffs
WAVELET THRESHOLDING DENOISEDN
ppc= 3 SNR = 16.83
COMPACT: only 0.12% of coeffs
● Once the particles have been deposited on the (Nx, N
z) grid:
1. Apply forward Anscombe transformation
2. Apply forward DWT
3. Remove numerical noise by wavelet thresholding
4. Apply inverse DWT
5. Apply inverse Anscombe transformation
● Wavelet thresholding– Judiciously removes numerical noise– Smoothens the distribution– Does not impose further limitation on spatial resolution
● DWT scales as O(MNgrid
) (independent of N), where M is the size of the wavelet filter– Much faster than Monte Carlo cosine expansion
Alternative Method 2:Alternative Method 2:Wavelet Transform on the GridWavelet Transform on the Grid
● Study microbunching instability in FERMI@ELETTRA (first bunch compressor system) by using an analytical model:
– Flattop distribution with a sinusoidally modulated frequency
Comparison: The New Methods Vs. The OldComparison: The New Methods Vs. The OldAnalytical ModelAnalytical Model
ρx , z =[1A cos2πz
λ] μ z g x μ z =
14 a
[ tanh za
b−tanh
z−ab
]
gx =1
2πσ x0
e−
x2
2σx0
(x,z)ρ
z
x
Quantity physical unit nondimm
m
modulation wavelength λ μmmodulation amplitude A A
m
m
m
m
transverse beam size σx0 2.3 x 104 σ
x0
longitudinal beam size σz0 9 x 104 σ
z0
= /λ λ σz0
beam parameter a 1.18 x 103 a=a/σz0
beam parameter b 1.5 x 104 b=b/ xσ0
transverse coordinate x [4σx0
,4σz0
] x=x/ xσ0
longitudinal coordinate z [2σz0
,2σz0
] z=z/ zσ0
● Gain factor: beam's response to (single wavelength) initial modulation
– Needed as a function of modulation wavelength λ
– Smaller λ higher spatial resolution more basis functions slower!
Comparison: The New Methods Vs. The OldComparison: The New Methods Vs. The OldGain FactorGain Factor
[From Bassi 2008]
Gain factor Vs. λ
● The smallest structure representable:
– Monte Carlo cosine expansion: the highest order basis function retained N
cx, N
cz: # of basis functions in x, zcoord.
– Gridbased methods: grid resolution N
x, N
z: grid resolution in x, zcoord.
● Grid is designed such that there is a fixed number of gridpoints sampling the highest order basis function retained (about 20), i.e., N
z=20N
cz
Comparison: The New Methods Vs. The OldComparison: The New Methods Vs. The OldSpatial ResolutionSpatial Resolution
λxmin, cos=
2 Lx
N cx
λzmin, cos=
2 Lz
N cz
λxmin, grid=
4 Lx
N xλz
min, grid=4 Lz
N z
λzmin, cos
λzmin, grid
cos Ncz z
z
λzmin, cos
=10 λ zmin, grid
● Limit on usability (longitudinally):
– Cosine expansion:
– Gridbased methods:
● Error of the approximation:
Comparison: The New Methods Vs. The OldComparison: The New Methods Vs. The OldSpatial ResolutionSpatial Resolution
N cz2Lz
λ zmin ,cos
N z4 Lz
λzmin ,grid
Accuracy of cosine expansion approx.: Ncz Vs. λ
E=hxhz∑i=1
Nx
∑j=1
N z
[ ρexact x i , z j−ρappx xi , z j]2
E ~ SNR−2~ N−1
● The accuracy of all approximations is determined by:
spatial resolution number of particles (N)
Comparison: The New Methods Vs. The OldComparison: The New Methods Vs. The OldAccuracyAccuracy
Approx. Error Vs. Modulation lenghtscale Approx. Error Vs. Number of particles
N=108
cosine expansion: Ncx=40, N
cz=100
grid resolution: Nx=128, N
z=1024
λ=100 μmcosine expansion: N
cx=40, N
cz=100
grid resolution: Nx=128, N
z=1024
λ zmin, cos
λ zmin, grid
● Better spatial resolution more small scale structure more noise
● Gridded density distribution is noisy. Remove noise (smoothen) by:– Truncating highfrequency components of the FFT expansion– Wavelet thresholding
Comparison: The New Methods Vs. The OldComparison: The New Methods Vs. The OldSmoothnessSmoothness
Crosssection (x=0) of density approximations
● Monte Carlo cosine exp. ~ O(NNcxN
cz)
● Particle deposition on a grid ~ O(N)● FCT+ filtering ~ O(N
grid)
● DWT + denoising ~ O(Ngrid
)
● Recall:
– Alternative method 1:● Grid + FCT
~ O(N)+ O(Ngrid
)
– Alternative method 2:● Grid + DWT
~ O(N)+ O(Ngrid
)
● In realistic simulations N >> Ngrid
particle deposition dominatesAlternative Methods 1 & 2 ~ O(N)speed (Alt. Meth. 1) = speed (Alt. Meth. 2)
Comparison: The New Methods Vs. The OldComparison: The New Methods Vs. The OldEfficiencyEfficiency
Execution time Vs. N
cosine expansion: Ncx=40, N
cz=100
grid resolution: Nx=128, N
z=1024
(Ngrid
=131072)
t deposition
tMC cos
~ O1
N cx N cz
● Both alternative methods for density estimation presented here are about N
cxN
cz times faster than Monte Carlo cosine expansion
● In the present implementation of Bassi's code: t(density estimation) : t(field computation) = 40% : 60%, so making the density estimation ~103 faster by using these new methods speeds up the code by ~ 40%
Comparison: The New Methods Vs. The OldComparison: The New Methods Vs. The OldEfficiencyEfficiency
cosine expansion: Ncx=40, N
cz=100
grid resolution: Nx=128, N
z=1024
Execution time: The New Methods Vs. The Old
t/tMC cos
= 1/(NcxN
cz)
● We will present a detailed and systematic comparison of the new gridbased methods and the Monte Carlo cosine expansion (PAC 2009)
● With these alternative methods for representing beam density, we have optimized only one part of the simulation (density estimation)
● A more timeconsuming part of the algorithm is a field calculation.We will focus on optimizing the field calculation by exploiting the advantages afforded by wavelet formulation:
– Compact representation(<0.5% of grid coefficients needed)
– Sparsity of operators (already designed a waveletbased Poisson equation solver)
– Denoised representation: more accurate
Discussion of Further WorkDiscussion of Further Work
Sparsity Vs. N1%
0.1%
● We presented two new, gridbased techniques for density estimation in beams simulations as an alternative to Monte Carlo cosine expansion:
– Truncated FCT technique:
● Orders of magnitude faster; just as accurate (equivalent to MC cosine)– Waveletdenoised technique:
● Orders of magnitude faster and appreciably more accurate
● The simulation times are significantly reduced
● Further optimization is needed on the field calculation bottleneck
– Take advantage of wavelets (sparsity, denoising)
● Compare with Li's 2D CSR code for consistency
● Closing in on the big goal: having an accurate, efficient and trustworthy code which properly accounts for beam selfinteraction due to the CSR
SummarySummary
Auxiliary SlidesAuxiliary Slides
Wavelet DecompositionWavelet Decomposition
The continuous wavelet transform of a function f (t) is
mother wavelet with scale and translation dimensions s and respectively
s ,=∫−∞
∞
f t s , t dt
s ,t =1
s t−
s t
● Approximation – apply lowpass filter to Signal and downsample
● Detail – apply highpass filter to Signal and downsample
● Wavelet synthesis (inverse wavelet transform): upsampling & filtering
● Complexity: 4MN, M the size of the wavelet, N number of cells
– Recall: FFT complexity 4N log2N
How Do Wavelets Work? How Do Wavelets Work?
Wavelet analysis (wavelet transform):
S signalA approximationD detail
● Wavelet transform separates scales
WaveletsWavelets
superimposed gaussians
FFT
wavelet transform
Numerical Noise in PIC SimulationsNumerical Noise in PIC Simulations● In wavelet space:
signal few large wavelet coefficients cij
noise many small wavelet coefficients cij
● Poissonian noise Gaussian noise
● Denoising by wavelet thresholding: if |c
ij|< T , set to c
ij =0 (choose threshold T carefully!)
● A great deal of study has been devoted to estimating optimal T
( σ was estimated earlier)
T=2 log N grid
Anscombe transformation
w/ Anscombe transformationw/out Anscombe transformation
NGP CICNppc
=5
Ni=64
Nppc
=5
Ni=64
Terzić, Pogorelov & Bohn 2007, PR STAB, 10, 034201
DF(
T)
DF(
T)