Skip to content

Commit c8c3bbb

Browse files
authored
Merge pull request #21 from PyCOMPLETE/develop
v.1.4.0
2 parents e08e27e + c379222 commit c8c3bbb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1354
-281
lines changed

Simulation.py

Lines changed: 448 additions & 252 deletions
Large diffs are not rendered by default.

Simulation_parameters_doc.md

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
# The Simulation_parameter.py configuration file
2+
3+
The file Simulation_parameters.py allowd configuring your PyECLOUD-PyHEADTAIL single-bunch simulation.
4+
In the following we describe its different parts:
5+
6+
## Initial imports
7+
In the beginning of the file you can import python modules or objects required to configure configurations. In this example we import some constants:
8+
9+
```python
10+
from scipy.constants import c
11+
from scipy.constants import m_p
12+
from scipy.constants import e as qe
13+
```
14+
15+
## Description of the accelerator
16+
By choosing ```"Synchrotron"``` as machine class it is possible to define all parameters of the ring (this is the recommended way of configuring the simulation):
17+
```python
18+
machine_class = 'Synchrotron'
19+
```
20+
The description of the accelerator is provided by providing the following parameters that are required to define a PyHEADTAIL synchrotron. They are individually described in the [PyHEADTAIL documentation](https://giadarol.github.io/PyHEADTAIL/PyHEADTAIL.machines.html#PyHEADTAIL.machines.synchrotron.Synchrotron).
21+
```python
22+
optics_mode = 'smooth'
23+
charge = qe
24+
mass = m_p
25+
p0 = 450e9 * qe / c
26+
circumference = 26658.8832
27+
n_segments = 16
28+
name = None
29+
s = None
30+
alpha_x = 0.
31+
beta_x = 92.7
32+
D_x = 0.
33+
alpha_y = 0
34+
beta_y = 93.2
35+
D_y = 0.
36+
accQ_x = 62.27
37+
accQ_y = 60.295
38+
Qp_x = 0.
39+
Qp_y = 0.
40+
app_x = 0.
41+
app_y = 0.
42+
app_xy = 0.
43+
longitudinal_mode = 'non-linear'
44+
Q_s = None
45+
alpha_mom_compaction = 3.225e-04
46+
h_RF = 35640
47+
V_RF = 5e6
48+
dphi_RF = 0.
49+
p_increment = 0.
50+
RF_at = 'end_of_transverse' # needs to be at the end to be compatible with PyPARIS parallelization
51+
wrap_z = False
52+
other_detuners = []
53+
```
54+
55+
The parameter ```n_non_parallelizable``` defines the number of elements at the end of the ring for which a parallelization over the slices should not be applied. For the typical simulation this is set to two (longitudinal map and transeverse collimation):
56+
```python
57+
n_non_parallelizable = 2 #rf and aperture
58+
```
59+
60+
## Transverse feedback
61+
An ideal bunch-by-bunch transverse feedback can be enabled. The damping rates are defined as the time constant observed on the envelope of the bunch centroid motion in the presence of the feedback alone:
62+
```python
63+
# Transverse Damper Settings
64+
enable_transverse_damper = False
65+
dampingrate_x = 100.
66+
dampingrate_y = 100.
67+
if enable_transverse_damper: n_non_parallelizable += 1
68+
```
69+
The last line adds the feedback to the list of non-parallelizable elements.
70+
71+
## Beam parameters
72+
73+
The parameters in this section define the bunch.
74+
75+
Optionally the bunch (particle-by-particle coordinates) can be loaded from file using the following intput variable:
76+
```python
77+
bunch_from_file = None
78+
```
79+
An example on how to save and load a bunch can be found in PyPARIS_sim_class/examples.
80+
81+
Alternatively, the bunch can be can be defined using the following input
82+
```python
83+
intensity = 1.2e+11 # Number of pearticles in the bunch
84+
epsn_x = 2.5e-6 # Normalized horizontal r.m.s emittance [m]
85+
epsn_y = 2.5e-6 # Normalized vertical r.m.s emittance [m]
86+
sigma_z = 9.181144e-02 # R.m.s bunch length [m]
87+
```
88+
The generated bunch is matched in all planes.
89+
90+
An initial transverse displacement can be defined by the following parameters:
91+
```python
92+
x_kick_in_sigmas = 0.1
93+
y_kick_in_sigmas = 0.1
94+
```
95+
## Longitudinal slicing
96+
The beam is sliced longitudinally to compute its interaction with the e-cloud:
97+
```python
98+
n_slices = 200
99+
z_cut = 2.5e-9/2*c # For slicing
100+
```
101+
```z_cut``` defined the portion of the bunch that is sliced, which is [-z_cut, z_cut].
102+
103+
## Number of macroparticles in the bunch
104+
The number of macroparticles in the bunch is defined by the following parameters:
105+
```
106+
macroparticles_per_slice = 5000
107+
n_macroparticles = macroparticles_per_slice*n_slices
108+
```
109+
## Multijob setup
110+
For very long simulations it is convenient to split the simulations over several shorter jobs. This allows also recovering the simulation from the end of the last success full jobin case of problems. This is controlled throught eh following parameters:
111+
112+
```python
113+
N_turns = 128 # Per job
114+
N_turns_target = 20000 # Entire simulation
115+
```
116+
## Stop criteria
117+
The simulation can be ended in case a certain fraction of the initial intensity is lost:
118+
119+
```python
120+
sim_stop_frac = 0.9 # Simulation stopped if 10% of the initial intensity is lost
121+
```
122+
123+
Transverse emittance blow-up can also be used a criterion for ending the simulation:
124+
125+
```python
126+
flag_check_emittance_growth = True
127+
epsn_x_max_growth_fraction = 0.5 # Stop on 50% horizontal emittance blow-up
128+
epsn_y_max_growth_fraction = 0.5 # Stop on 50% vertical emittance blow-up
129+
```
130+
131+
## Footprint mode
132+
The simulation mode can be changed to compute the tune footprint in the presence of e-cloud using the ```footprint_mode``` flag. In this case the instability simulation is not performed and only the footprint data is produced. A bunch with a very large number of macroparticles is used to compute the e-cloud filed maps. The footprint particle tunes are measured using a smaller number of macroparticles. For the computation of the footprint the longitudinal motion is automatically switched off.
133+
134+
The footprint mode is enabled and controlled using the following parameters:
135+
136+
```python
137+
footprint_mode = False
138+
n_macroparticles_for_footprint_map = 500000
139+
n_macroparticles_for_footprint_track = 5000
140+
```
141+
142+
143+
## Electron cloud settings
144+
Two kinds of e-cloud interaction can be installed at the end of each machine segment to model the e-cloud in dipoles and quadrupoles.
145+
146+
Most of the e-cloud paramters are defined by PyECLOUD input files in a specified folder:
147+
```python
148+
pyecl_input_folder = './pyecloud_config'
149+
```
150+
Whenever a parameter in the input files is also mention in the present file, the value specified here takes priority.
151+
152+
The chamber geometry can be redefined by the following parameters (see [PyECLOUD reference](https://github.com/PyCOMPLETE/PyECLOUD/wiki/reference-manual) for more details):
153+
154+
```python
155+
chamb_type = 'polyg'
156+
x_aper = 2.300000e-02
157+
y_aper = 1.800000e-02
158+
filename_chm = 'LHC_chm_ver.mat'
159+
```
160+
161+
The target duration of the electron tracking time sup-steps is defined by:
162+
```
163+
Dt_ref = 5.000000e-12
164+
```
165+
166+
The Particle-In-Cell solver used to compute beam and electron fields is configured by the following parameters (more details can be found in the [PyECLOUD reference](https://github.com/PyCOMPLETE/PyECLOUD/wiki/reference-manual) and in the [physcs models section](https://github.com/PyCOMPLETE/PyECLOUD/wiki/Physical-models-and-numerical-algorithms) of the [PyECLOUD wiki](https://github.com/PyCOMPLETE/PyECLOUD/wiki)):
167+
168+
```python
169+
PyPICmode = 'ShortleyWeller_WithTelescopicGrids'
170+
N_min_Dh_main = 10.
171+
Dh_sc_ext = .8e-3
172+
f_telescope = 0.3
173+
N_nodes_discard = 5.
174+
target_size_internal_grid_sigma = 10.
175+
target_Dh_internal_grid_sigma = 0.2
176+
custom_target_grid_arcs = None
177+
178+
# # Uncomment for custom grid
179+
# custom_target_grid_arcs = {
180+
# 'x_min_target': -3e-3,
181+
# 'x_max_target': 3e-3,
182+
# 'y_min_target': -3.1e-3,
183+
# 'y_max_target': 3.1e-3,
184+
# 'Dh_target': 7e-5}
185+
```
186+
187+
By setting:
188+
```python
189+
force_interp_at_substeps_interacting_slices = True
190+
```
191+
the electric field acting on the electrons is re-interpolated at each tracking sub-step. If theis parameter is set to false the field is evaluated only once for each beam-slice.
192+
193+
The forces of the e-cloud on the beam particle in the transverse planes can be enabled/disabled using the following flags:
194+
195+
```python
196+
enable_kick_x = True
197+
enable_kick_y = False
198+
```
199+
200+
### Dedicated settings for e-cloud un the dipole magnets
201+
202+
The following parameters configure the e-cloud in the dipoles (which are simulated starting with electrons at rest uniformly distributed in the chamber):
203+
204+
```python
205+
enable_arc_dip = True # Activate interaction with e-cloud in the dipoles
206+
fraction_device_dip = 0.65 # Fraction of the machine circumference with e-cloud in the dipoles
207+
init_unif_edens_flag_dip = 1 # Activate initial uniform distribution for electrons
208+
init_unif_edens_dip = 1.0e+12 # Initial electron density (e-/m^3)
209+
N_MP_ele_init_dip = 500000 # Number of macroparticles
210+
N_mp_max_dip = N_MP_ele_init_dip*4 # Size of arrazys used to store macroparticle coordinates
211+
B_multip_dip = [0.5] #T # Magnetic field (in Tesla)
212+
```
213+
214+
### Dedicated settings for e-cloud un the quadrupole magnets
215+
The following parameters configure the e-cloud in the magnets (which are simulated starting with an electron distribution loaded from file):
216+
217+
```python
218+
enable_arc_quad = False # Activate interaction with e-cloud in the dipoled
219+
fraction_device_quad = 7.0e-02 # Fraction of the machine circumference with e-cloud in the quadrupoles
220+
221+
N_mp_max_quad = 2000000 # Size of arrazys used to store macroparticle coordinates
222+
B_multip_quad = [0., 12.1] #T # The second element of the list is the magnetic field gradient (in Tesla/m)
223+
```
224+
The following paramenters are used to define the file containing the initial e-cloud distribution:
225+
```python
226+
folder_path = '../../LHC_ecloud_distrib_quads/'
227+
N_mp_ele_quad = 500000
228+
sey_load_quad = 1.3
229+
filename_state = 'combined_distribution_sey_%.2f_sigmat_%.3fns_450Gev_N_mp_%d_symm'%(sey_load_quad, sigma_z/c*1e9,N_mp_ele_quad)
230+
filename_init_MP_state_quad = folder_path + filename_state
231+
```
232+
233+
### Expert e-cloud kicks
234+
235+
Individual e-cloud interaction can be provided at defined kick locations when the used optics is ```'non-smooth'``` (incompatible with the settings above), suing the following parameters:
236+
237+
```python
238+
# Dedicated Kick Element Settings
239+
enable_eclouds_at_kick_elements = False
240+
path_buildup_simulations_kick_elements = 'path_to_myfolder/simulations_PyECLOUD/!!!NAME!!!_sey1.35'
241+
name_MP_state_file_kick_elements = 'MP_state_9.mat'
242+
orbit_factor = 6.250000e-01
243+
244+
```
245+

__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.3.0'
1+
__version__ = '1.4.0'

0 commit comments

Comments
 (0)