1.02k likes | 1.17k Views
PyECLOUD. G. Iadarola , G. Rumolo. Thanks to: R. De Maria, K. Li. ECLOUD meeting 28/11/2011. Outline. Why a new code for electron cloud build-up simulation? From ECLOUD to PyECLOUD Management of macroparticle size and number Back-tracking algorithm for the impacting electrons
E N D
PyECLOUD G. Iadarola, G. Rumolo Thanks to: R. De Maria, K. Li ECLOUD meeting 28/11/2011
Outline • Why a new code for electron cloud build-up simulation? • From ECLOUD to PyECLOUD • Management of macroparticle size and number • Back-tracking algorithm for the impacting electrons • Beam field calculation • Space charge field • Preliminary convergence study • PyECLOUD at work • Conclusion and future work
Outline • Why a new code for electron cloud build-up simulation? • From ECLOUD to PyECLOUD • Management of macroparticle size and number • Back-tracking algorithm for the impacting electrons • Beam field calculation • Space charge field • Preliminary convergence study • PyECLOUD at work • Conclusion and future work
Why a new code for electron cloud build-up simulation? • At the very beginning our idea was to reorganize ECLOUD in order to make it easier the development of new features, to identify and correct of present and future bugs, to access to a larger amount of information about our simulations.
Why a new code for electron cloud build-up simulation? • At the very beginning our idea was to reorganize ECLOUD in order to make it easier the development of new features, to identify and correct of present and future bugs, to access to a larger amount of information about our simulations. • This task has revealed to be quite hard since: • The code is scarcely modular: the frequent use of global variables makes very difficult to extract subroutines and building self consistent modules for development and testing purposes • In Fortran 77 is very difficult to write readable and flexible code (even a proper indentation is a non-trivial task)
Why a new code for electron cloud build-up simulation? • At the very beginning our idea was to reorganize ECLOUD in order to make it easier the development of new features, to identify and correct of present and future bugs, to access to a larger amount of information about our simulations. • We have retained that the effort of writing a fully reorganized code,in a newer and more powerful language, should be compensated by a significantly increased efficiency in future development and debugging.
Python • It is a powerful general purpose interpreted language: • Allows incremental and interactive development of the code, encouraging an highly modular structure. Reading and understanding the code, writing extensions, exploring different solutions is much faster (orders of magnitude!!) with respect to compiled languages (especially looking at FORTRAN 77) • Open source libraries (like NumPy and SciPy) make it a very powerful tool for scientific computation (comparable to a specialized commercial tool like MATLAB) • Computationally intensive parts can be written in C/C++ or FORTRAN and easily integrated in a Python code (successfully employed in our distribution computation/interpolation routines – x6 overall speed up)
Outline • Why a new code for electron cloud build-up simulation? • From ECLOUD to PyECLOUD • Management of macroparticle size and number • Back-tracking algorithm for the impacting electrons • Beam field calculation • Space charge field • Preliminary convergence study • PyECLOUD at work • Conclusion and future work
From ECLOUD to PyECLOUD • Writing PyECLOUD has required a detailed analysis of ECLOUD algorithm and implementation, looking also at the related long experience in electron cloud simulations. • Attention has been devoted to the individuation of ECLOUD limitations, in particular in terms of its convergence properties with respect to the electron distribution in bending magnets (how many stripes…)
From ECLOUD to PyECLOUD • Writing PyECLOUD has required a detailed analysis of ECLOUD algorithm and implementation, looking also at the related long experience in electron cloud simulations. • Attention has been devoted to the individuation of ECLOUD limitations, in particular in terms of its convergence properties with respect to the electron distribution in bending magnets (how many stripes…) • As a result, several features have been significantly modified in order to improve the code’s performances in terms: • Accuracy • Efficiency • Flexibility
Ingredients for e-cloud build-up simulation • 1. Seed electrons generation • (gas ionization, photoemission)
Ingredients for e-cloud build-up simulation • 1. Seed electrons generation • (gas ionization, photoemission) • 2. Force exerted by the beam on e-
Ingredients for e-cloud build-up simulation • 1. Seed electrons generation • (gas ionization, photoemission) • 2. Force exerted by the beam on e- • 3. Force exerted by the e- on each other • (space charge)
Ingredients for e-cloud build-up simulation • 1. Seed electrons generation • (gas ionization, photoemission) • 2. Force exerted by the beam on e- • 3. Force exerted by the e- on each other • (space charge) • 4. Equations of motion • (also in presence of an external magnetic field)
Ingredients for e-cloud build-up simulation • 1. Seed electrons generation • (gas ionization, photoemission) • 2. Force exerted by the beam on e- • 3. Force exerted by the e- on each other • (space charge) • 4. Equations of motion • (also in presence of an external magnetic field) • 5. Secondary emission
From ECLOUD to PyECLOUD • The most relevant improvements introduced in PyECLOUD are: • A different management of macroparticle size and number • A more accurate back-tracking algorithm for the impacting electrons • A more efficient computation of the electric field generated by the travelling proton beam • A more general ad accurate method for the evaluation of the electrons space-charge field
Outline • Why a new code for electron cloud build-up simulation? • From ECLOUD to PyECLOUD • Management of macroparticle size and number • Back-tracking algorithm for the impacting electrons • Beam field calculation • Space charge field • Preliminary convergence study • PyECLOUD at work • Conclusion and future work
Macroparticles • The simulation of the dynamics of the entire number of electrons (≈1010 per meter) is extremely heavy (practically unaffordable) • Since the dynamics equation of the electron depends only on the q/m ratio of the electron a macroparticle (MP) method can be used: • The MP size can be seen as the “resolution” our electron gas simulation
Macroparticles • In an electron-cloud buildup, due to the multipacting process, the electron number spreads several orders of magnitude: • It is practically impossible to choose a MP size that is suitable for the entire simulation (allowing a satisfactory description of the phenomenon and a computationally affordable number of MPs)
ECLOUD – MP number control: the CLEAN routine • In ECLOUD the clean routine is called once per bunch passage and when the number of MPs goes beyond 2*105
ECLOUD – MP number control: the CLEAN routine • In ECLOUD the clean routine is called once per bunch passage and when the number of MPs goes beyond 2*105 • If the number of MPs Nmpis >5*104 it randomly eliminates MPs in order to obtain Nmp ≈ 5*104.
ECLOUD – MP number control: the CLEAN routine • In ECLOUD the clean routine is called once per bunch passage and when the number of MPs goes beyond 2*105 • If the number of MPs Nmpis >5*104 it randomly eliminates MPs in order to obtain Nmp ≈ 5*104.
ECLOUD – MP number control: the CLEAN routine • In ECLOUD the clean routine is called once per bunch passage and when the number of MPs goes beyond 2*105 • If the number of MPs Nmpis >5*104 it randomly eliminates MPs in order to obtain Nmp ≈ 5*104. • Then the remaining MPs’ charge is rescaled in order to obtain the same total charge present in the chamber before the clean
ECLOUD – MP number control: the CLEAN routine • In ECLOUD the clean routine is called once per bunch passage and when the number of MPs goes beyond 2*105 • If the number of MPs Nmpis >5*104 it randomly eliminates MPs in order to obtain Nmp ≈ 5*104. • Then the remaining MPs’ charge is rescaled in order to obtain the same total charge present in the chamber before the clean • This approach guarantees the charge conservation but does not preserve the total energy or the velocity distribution of the electrons.
ECLOUD – MP number control: other observations • In a typical ECLOUD simulation (SPS MBB SEY=1.5): • The number and the sizeof MPs produced by the seed generation mechanism is kept constant during the entire simulation. • As consequence, at saturation, we have a certain number of MPs carrying practically no charge (≈ 5% of the MPs carries ≈1ppm of the total charge)
ECLOUD – MP number control: other observations • In a typical ECLOUD simulation (SPS MBB SEY=1.5): • The number and the size of MPs produced by the seed generation mechanism is kept constant during the entire simulation. • As consequence, at saturation, we have a certain number of MPs carrying practically no charge (≈ 5% of the MPs carries ≈1ppm of the total charge) • At saturation, there is a consistent number of MPs which are trapped near the chamber wall and undergo several low energy impact becoming smaller and smaller. • In ECLOUD there is no mechanism which selectively eliminates them.
PyECLOUD – MP number control: a global approach • In PyECLOUD we try to treat in a unified way all issues related to MP size and number, namely:
PyECLOUD – MP number control: a global approach • In PyECLOUD we try to treat in a unified way all issues related to MP size and number, namely: • Given the number of seed e-to be generated in a certain time-step how many MP do we generate? (i.e. how do we choose their size?)
PyECLOUD – MP number control: a global approach • In PyECLOUD we try to treat in a unified way all issues related to MP size and number, namely: • Given the number of seed e-to be generated in a certain time-step how many MP do we generate? (i.e. how do we choose their size?) • When a MP hits the wall when it is sufficient to change the size of the current MP according to the Secondary Emission Yield and when true secondary MPs must be created?
PyECLOUD – MP number control: a global approach • In PyECLOUD we try to treat in a unified way all issues related to MP size and number, namely: • Given the number of seed e-to be generated in a certain time-step how many MP do we generate? (i.e. how do we choose their size?) • When a MP hits the wall when it is sufficient to change the size of the current MP according to the Secondary Emission Yield and when true secondary MPs must be created? • When a MP (after some low energy impacts) is considered so small to be eliminated without affecting the simulation? x
PyECLOUD – MP number control: a global approach • In PyECLOUD we try to treat in a unified way all issues related to MP size and number, namely: • Given the number of seed e-to be generated in a certain time-step how many MP do we generate? (i.e. how do we choose their size?) • When a MP hits the wall when it is sufficient to change the size of the current MP according to the Secondary Emission Yield and when true secondary MPs must be created? • When a MP (after some low energy impacts) is considered so small to be eliminated without affecting the simulation? • What to do when, because of multipacting process, the number of MPs becomes too large for a reasonable computational burden ? x
PyECLOUD – MP number control: a global approach • We control all this issues through the single parameter Nref which is a target average size of the MPs (i.e. our resolution) and is adaptively changed during the simulation:
PyECLOUD – MP number control: a global approach • We control all this issues through the single parameter Nref which is a target average size of the MPs (i.e. our resolution) and is adaptively changed during the simulation: • Given the number of seed e-to be generated , the generated MPs have size Nrefand their number is chosen as a consequence
PyECLOUD – MP number control: a global approach • We control all this issues through the single parameter Nref which is a target average size of the MPs (i.e. our resolution) and is adaptively changed during the simulation: • Given the number of seed e-to be generated , the generated MPs have size Nrefand their number is chosen as a consequence • When a MP hits the wall, additional true secondary MPs are emitted if the total emitted charge is >1.5Nref and, in that case, their number is chosen so that their size is as close as possible to Nref
PyECLOUD – MP number control: a global approach • We control all this issues through the single parameter Nref which is a target average size of the MPs (i.e. our resolution) and is adaptively changed during the simulation: • Given the number of seed e-to be generated , the generated MPs have size Nrefand their number is chosen as a consequence • When a MP hits the wall, additional true secondary MPs are emitted if the total emitted charge is >1.5Nref and, in that case, their number is chosen so that their size is as close as possible to Nref • At each bunch passage a clean function is called that eliminates all the MPs with charge <10-4Nref x
PyECLOUD – MP number control: a global approach • When the number of MPs becomes larger than a certain threshold (≈105) that means that the computational burden is becoming too high, we change MPtarget size (Nref ) and perform a regeneration of the MPs system:
PyECLOUD – MP number control: a global approach • When the number of MPs becomes larger than a certain threshold (≈105) that means that the computational burden is becoming too high, we change MPtarget size (Nref ) and perform a regeneration of the MPs system: • Each macroparticle is assigned to a cell of a uniform grid in the 5-D space (x,y,vx,vy,vz) obtaining an approximation of the phase space distribution
PyECLOUD – MP number control: a global approach • When the number of MPs becomes larger than a certain threshold (≈105) that means that the computational burden is becoming too high, we change MPtarget size (Nref ) and perform a regeneration of the MPs system: • Each macroparticle is assigned to a cell of a uniform grid in the 5-D space (x,y,vx,vy,vz) obtaining an approximation of the phase space distribution
PyECLOUD – MP number control: a global approach • When the number of MPs becomes larger than a certain threshold (≈105) that means that the computational burden is becoming too high, we change MPtarget size (Nref ) and perform a regeneration of the MPs system: • Each macroparticle is assigned to a cell of a uniform grid in the 5-D space (x,y,vx,vy,vz) obtaining an approximation of the phase space distribution
PyECLOUD – MP regeneration • When the number of MPs becomes larger than a certain threshold (≈105) that means that the computational burden is becoming too high, we change MPtarget size (Nref ) and perform a regeneration of the MPs system: • Each macroparticle is assigned to a cell of a uniform grid in the 5-D space (x,y,vx,vy,vz) obtaining an approximation of the phase space distribution • The new target MP size is chosen so that:
PyECLOUD – MP regeneration • When the number of MPs becomes larger than a certain threshold (≈105) that means that the computational burden is becoming too high, we change MPtarget size (Nref ) and perform a regeneration of the MPs system: • Each macroparticle is assigned to a cell of a uniform grid in the 5-D space (x,y,vx,vy,vz) obtaining an approximation of the phase space distribution • The new target MP size is chosen so that: • A new MPs set, having the new reference size, is generated according to the computed distribution.
PyECLOUD – MP regeneration • When the number of MPs becomes larger than a certain threshold (≈105) that means that the computational burden is becoming too high, we change MPtarget size (Nref ) and perform a regeneration of the MPs system: • Each macroparticle is assigned to a cell of a uniform grid in the 5-D space (x,y,vx,vy,vz) obtaining an approximation of the phase space distribution • The new target MP size is chosen so that: • A new MPs set, having the new reference size, is generated according to the computed distribution. • All moments related to position and velocity (e.g. energy distrib. , charge distrib.) are preserved. The error on total charge and total energy does not go beyond 1-2%
Outline • Why a new code for electron cloud build-up simulation? • From ECLOUD to PyECLOUD • Management of macroparticle size and number • Back-tracking algorithm for the impacting electrons • Beam field calculation • Space charge field • Preliminary convergence study • PyECLOUD at work • Conclusion and future work
Impacting electrons backtracking - ECLOUD • Electrons impacting on the chamber’s wall are detected when they are found outside the chamber and must be backtracked on the wall. • ECLOUD applies a simple rescaling of the electron’s position:
Impacting electrons backtracking - ECLOUD • Electrons impacting on the chamber’s wall are detected when they are found outside the chamber and must be backtracked on the wall. • ECLOUD applies a simple rescaling of the electron’s position:
Impacting electrons backtracking - ECLOUD • Electrons impacting on the chamber’s wall are detected when they are found outside the chamber and must be backtracked on the wall. • ECLOUD applies a simple rescaling of the electron’s position: • This forces to choose very small time-steps in order to avoid perturbations on the distribution of the electron cloud.
Impacting electrons backtracking - PyECLOUD • Electrons impacting on the chamber’s wall are detected when they are found outside the chamber and must be backtracked on the wall. • PyECLOUD always stores the MPs’ position at previous timestep in order to compute the crossing point between the chamber’s wall and the electron’s trajectory :
Impacting electrons backtracking - PyECLOUD • Electrons impacting on the chamber’s wall are detected when they are found outside the chamber and must be backtracked on the wall. • PyECLOUD always stores the MPs’ position at previous timestep in order to compute the crossing point between the chamber’s wall and the electron’s trajectory :
Impacting electrons backtracking - PyECLOUD • Electrons impacting on the chamber’s wall are detected when they are found outside the chamber and must be backtracked on the wall. • PyECLOUD always stores the MPs’ position at previous timestep in order to compute the crossingpoint between the chamber’s wall and the electron’s trajectory :
Impacting electrons backtracking - PyECLOUD • Electrons impacting on the chamber’s wall are detected when they are found outside the chamber and must be backtracked on the wall. • PyECLOUD always stores the MPs’ position at previous timestep in order to compute the crossingpoint between the chamber’s wall and the electron’s trajectory : • Together with the improved space-charge computation, this simple trick has a great impact on the convergence properties with respect to the timestep (as we will see in a few slides).