Skip to content

Commit 6e893fe

Browse files
authored
Merge pull request #17 from PyCOMPLETE/develop
v1.2.4
2 parents ad2061d + 3fb3e60 commit 6e893fe

File tree

17 files changed

+440
-1
lines changed

17 files changed

+440
-1
lines changed

Simulation.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ def init_all(self):
130130
enable_kick_y = pp.enable_kick_y)
131131

132132

133+
133134
if self.ring_of_CPUs.I_am_the_master and pp.enable_arc_dip:
134135
with open('multigrid_config_dip.txt', 'w') as fid:
135136
if hasattr(ecloud_dip.spacech_ele.PyPICobj, 'grids'):
@@ -155,6 +156,7 @@ def init_all(self):
155156
pickle.dump(ecloud_quad.spacech_ele.PyPICobj.grids, fid)
156157
else:
157158
pickle.dump('Single grid.', fid)
159+
158160

159161
# setup transverse losses (to "protect" the ecloud)
160162
import PyHEADTAIL.aperture.aperture as aperture
@@ -303,8 +305,12 @@ def init_master(self):
303305
if pp.N_turns!=pp.N_turns_target:
304306
raise ValueError('In footprint mode you need to set N_turns_target=N_turns_per_run!')
305307

308+
check_for_resubmit = True
309+
if hasattr(pp, 'check_for_resubmit'):
310+
check_for_resubmit = pp.check_for_resubmit
306311
import PyPARIS_sim_class.Save_Load_Status as SLS
307-
SimSt = SLS.SimulationStatus(N_turns_per_run=pp.N_turns, check_for_resubmit = True, N_turns_target=pp.N_turns_target)
312+
SimSt = SLS.SimulationStatus(N_turns_per_run=pp.N_turns, check_for_resubmit=check_for_resubmit,
313+
N_turns_target=pp.N_turns_target)
308314
SimSt.before_simulation()
309315
self.SimSt = SimSt
310316

@@ -426,6 +432,7 @@ def execute_orders_from_master(self, orders_from_master):
426432
for ec in self.my_list_eclouds: ec.finalize_and_reinitialize()
427433

428434

435+
429436
def finalize_simulation(self):
430437
if pp.footprint_mode:
431438
# Tunes
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
rm simulation_status.sta
2+
rm bunch_evolution_*.h5
3+
rm slice_evolution_*.h5
4+
rm bunch_status_part*.h5
5+
rm *.pyc
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/bash
2+
3+
export PYTHONPATH=$PYTHONPATH:../../../
4+
5+
rm simulation_status.sta
6+
7+
# Run Serial
8+
for i in 1 2 3
9+
do
10+
echo "Run $i"
11+
../../../PyPARIS/serialexec.py sim_class=PyPARIS_sim_class.Simulation.Simulation
12+
done
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/bash
2+
3+
export PYTHONPATH=$PYTHONPATH:../../../
4+
5+
rm simulation_status.sta
6+
7+
# Run Parallel without MPI
8+
for i in 1 2 3
9+
do
10+
echo "Run $i"
11+
../../../PyPARIS/multiprocexec.py -n 3 sim_class=PyPARIS_sim_class.Simulation.Simulation
12+
done
13+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/bash
2+
3+
export PYTHONPATH=$PYTHONPATH:../../../
4+
5+
rm simulation_status.sta
6+
7+
# Run MPI
8+
for i in 1 2 3
9+
do
10+
echo "Run $i"
11+
mpiexec -n 3 ../../../PyPARIS/withmpi.py sim_class=PyPARIS_sim_class.Simulation.Simulation
12+
done
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import sys
2+
sys.path.append('../../../')
3+
4+
import PyPARIS_sim_class.Simulation as sim_mod
5+
6+
ring = sim_mod.get_serial_CPUring()
7+
ring.run()
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import sys, os
2+
sys.path.append('../../../')
3+
4+
5+
import numpy as np
6+
import matplotlib.pyplot as plt
7+
from matplotlib.ticker import MaxNLocator
8+
9+
import PyPARIS.myfilemanager as mfm
10+
11+
import mystyle as ms
12+
13+
tag = 'noecloud'
14+
15+
flag_check_damp_time = False
16+
tau_damp_x = 50.
17+
tau_damp_y = 100.
18+
19+
flag_check_Qs = True
20+
Q_s = np.nan
21+
22+
#ob = mfm.monitorh5_to_obj('bunch_evolution_00.h5')
23+
ob = mfm.monitorh5list_to_obj(
24+
['bunch_evolution_%02d.h5'%ii for ii in range(3)])
25+
26+
27+
plt.close('all')
28+
29+
# Plot transverse positions
30+
fig1 = plt.figure(1, figsize=(8,6*1.2))
31+
fig1.set_facecolor('w')
32+
ms.mystyle_arial(fontsz=16)
33+
34+
axx = fig1.add_subplot(2,1,1)
35+
axy = fig1.add_subplot(2,1,2, sharex=axx)
36+
37+
axx.plot(ob.mean_x)
38+
axy.plot(ob.mean_y)
39+
40+
if flag_check_damp_time:
41+
turn_num = np.arange(0, len(ob.mean_x), dtype=np.float)
42+
ix_max = np.argmax(ob.mean_x)
43+
iy_max = np.argmax(ob.mean_y)
44+
45+
axx.plot(ob.mean_x[ix_max]*np.exp(-(turn_num-ix_max)/tau_damp_x),
46+
linewidth=2, color='red', linestyle='--',
47+
label=r'Damping time = %.0f turns'%tau_damp_x)
48+
axy.plot(ob.mean_y[iy_max]*np.exp(-(turn_num-iy_max)/tau_damp_y),
49+
linewidth=2, color='red', linestyle='--',
50+
label=r'Damping time = %.0f turns'%tau_damp_y)
51+
52+
axx.legend(prop={'size':14}).draggable()
53+
axy.legend(prop={'size':14}).draggable()
54+
55+
axx.set_ylabel('x [m]')
56+
axy.set_ylabel('y [m]')
57+
axy.set_xlabel('Turn')
58+
59+
# Plot transverse spectra
60+
fig2 = plt.figure(2, figsize=(8,6*1.2))
61+
fig2.set_facecolor('w')
62+
63+
axfx = fig2.add_subplot(2,1,1)
64+
axfy = fig2.add_subplot(2,1,2, sharex=axfx)
65+
66+
spectx = np.abs(np.fft.rfft(ob.mean_x))
67+
specty = np.abs(np.fft.rfft(ob.mean_y))
68+
freq = np.fft.rfftfreq(len(ob.mean_x))
69+
70+
axfx.plot(freq, spectx)
71+
axfy.plot(freq, specty)
72+
73+
# Check longitudinal plane
74+
fig3 = plt.figure(3, figsize=(8,6*1.2))
75+
fig3.set_facecolor('w')
76+
axz = fig3.add_subplot(2,1,1, sharex=axx)
77+
axfz = fig3.add_subplot(2,1,2)
78+
79+
axz.plot(ob.mean_z[:-10])
80+
spectz = np.abs(np.fft.rfft(ob.mean_z[:-10]))
81+
spectz[0] = 0. # I am non interested in the average
82+
freqz = np.fft.rfftfreq(len(ob.mean_x[:-10]))
83+
axfz.plot(freqz, spectz)
84+
axfz.axvline(x=Q_s)
85+
86+
for ax in [axx, axy, axfx, axfy, axz, axfz]:
87+
ax.ticklabel_format(style='sci', scilimits=(0,0),axis='y')
88+
89+
for ax in [axx, axy, axfx, axfy, axz, axfz]:
90+
ax.yaxis.set_major_locator(MaxNLocator(5))
91+
92+
for ax in [axx, axy, axfx, axfy, axz, axfz]:
93+
ax.grid(True)
94+
95+
for fig in [fig1, fig2, fig3]:
96+
fig.suptitle('Bunch')
97+
fig.subplots_adjust(
98+
top=0.885,
99+
bottom=0.1,
100+
left=0.125,
101+
right=0.9,
102+
hspace=0.345,
103+
wspace=0.2)
104+
105+
plt.show()
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
from scipy.constants import c
2+
3+
check_for_resubmit = False
4+
5+
####################
6+
# Machine Settings #
7+
####################
8+
9+
machine_configuration = 'LHC-collision'
10+
11+
# # Use this part for optics from file
12+
# # n_segments needs to be None if optics_pickle_file is specified
13+
# optics_pickle_file = 'lhc2018_25cm_only_triplets_IR15_b1_optics.pkl'
14+
# n_segments = None
15+
# beta_x = None
16+
# beta_y = None
17+
# Q_x = None
18+
# Q_y = None
19+
20+
# # Use this part for smooth machine
21+
optics_pickle_file = None
22+
n_segments = 3
23+
beta_x = 400.0
24+
beta_y = 400.0
25+
Q_x = 62.27
26+
Q_y = 60.295
27+
28+
Qp_x = 0.
29+
Qp_y = 0.
30+
31+
octupole_knob = 0.
32+
33+
V_RF = 12e6
34+
35+
n_non_parallelizable = 2 #rf and aperture
36+
37+
# Transverse Damper Settings
38+
enable_transverse_damper = False
39+
dampingrate_x = 50.
40+
dampingrate_y = 100.
41+
if enable_transverse_damper: n_non_parallelizable += 1
42+
43+
44+
###################
45+
# Beam Parameters #
46+
###################
47+
48+
bunch_from_file = None
49+
50+
intensity = 1.2e+11
51+
52+
epsn_x = 2.5e-6
53+
epsn_y = 2.5e-6
54+
55+
sigma_z = 1.2e-9/4*c
56+
57+
x_kick_in_sigmas = 0.1
58+
y_kick_in_sigmas = 0.1
59+
60+
# Numerical Parameters
61+
n_slices = 100
62+
z_cut = 2.5e-9/2*c # For slicing
63+
macroparticles_per_slice = 1000
64+
n_macroparticles = macroparticles_per_slice*n_slices
65+
66+
67+
#################
68+
# Stop Criteria #
69+
#################
70+
71+
# 1. Turns
72+
N_turns = 10 # Per job
73+
N_turns_target = 150
74+
# 2. Losses
75+
sim_stop_frac = 0.9
76+
# 3. Emittance Growth
77+
flag_check_emittance_growth = True
78+
epsn_x_max_growth_fraction = 0.5
79+
epsn_y_max_growth_fraction = epsn_x_max_growth_fraction
80+
81+
82+
######################
83+
# Footprint Settings #
84+
######################
85+
86+
footprint_mode = False
87+
n_macroparticles_for_footprint_map = 500000
88+
n_macroparticles_for_footprint_track = 5000
89+
90+
91+
####################
92+
# E-Cloud Settings #
93+
####################
94+
95+
# General E-Cloud Settings
96+
chamb_type = 'polyg'
97+
x_aper = 2.300000e-02
98+
y_aper = 1.800000e-02
99+
filename_chm = 'LHC_chm_ver.mat'
100+
Dt_ref = 25e-12
101+
pyecl_input_folder = './pyecloud_config'
102+
sey = 1.30
103+
104+
# Transverse Multigrid Parameters
105+
PyPICmode = 'ShortleyWeller_WithTelescopicGrids'
106+
N_min_Dh_main = 10.
107+
Dh_sc_ext = .8e-3
108+
f_telescope = 0.3
109+
N_nodes_discard = 5.
110+
target_size_internal_grid_sigma = 10.
111+
target_Dh_internal_grid_sigma = 0.5
112+
custom_target_grid_arcs = None
113+
114+
# # Uncomment for custom grid
115+
# custom_target_grid_arcs = {
116+
# 'x_min_target': -3e-3,
117+
# 'x_max_target': 3e-3,
118+
# 'y_min_target': -3.1e-3,
119+
# 'y_max_target': 3.1e-3,
120+
# 'Dh_target': 7e-5}
121+
122+
# Enable Kicks Different Planes
123+
enable_kick_x = True
124+
enable_kick_y = True
125+
126+
# Dedicated Dipole E-Cloud Settings
127+
enable_arc_dip = True
128+
fraction_device_dip = 0.65
129+
init_unif_edens_flag_dip = 1
130+
init_unif_edens_dip = 1.000000e+12
131+
N_MP_ele_init_dip = 50000
132+
N_mp_max_dip = N_MP_ele_init_dip*4
133+
B_multip_dip = [8.33] #T
134+
135+
# Dedicated Quadrupole E-Cloud Settings
136+
enable_arc_quad = False
137+
fraction_device_quad = 26.000000e-02 #7.000000e-02
138+
N_mp_max_quad = 2000000
139+
B_multip_quad = [0., 188.2] #T
140+
folder_path = '../../LHC_ecloud_distrib_quads/'
141+
filename_state = 'combined_distribution_sey%.2f_%.1fe11ppb_7tev.mat'%(sey,intensity/1e11)
142+
filename_init_MP_state_quad = folder_path + filename_state
143+
144+
# Dedicated Kick Element Settings
145+
enable_eclouds_at_kick_elements = False
146+
path_buildup_simulations_kick_elements = '/home/kparasch/workspace/Triplets/ec_headtail_triplets/simulations_PyECLOUD/!!!NAME!!!_sey1.35'
147+
name_MP_state_file_kick_elements = 'MP_state_9.mat'
148+
orbit_factor = 6.250000e-01
149+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
rm multigrid_config*
2+
rm simulation_status.sta
3+
rm bunch_evolution_*.h5
4+
rm slice_evolution_*.h5
5+
rm bunch_status_part*.h5
6+
rm *.pyc
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from matplotlib import rc, rcdefaults
2+
import pylab as pl
3+
from colorsys import hsv_to_rgb
4+
5+
6+
def mystyle(fontsz=16):
7+
8+
font = {#'family' : 'normal',
9+
#'weight' : 'bold',
10+
'size' : fontsz}
11+
print fontsz
12+
rcdefaults()
13+
rc('font', **font)
14+
15+
def mystyle_arial(fontsz=16, dist_tick_lab=10):
16+
17+
rcdefaults()
18+
rc('font',**{'family':'sans-serif','sans-serif':['arial'], 'size':fontsz})
19+
rc(('xtick.major','xtick.minor','ytick.major','ytick.minor'), pad=dist_tick_lab)
20+
21+
22+
23+
def sciy():
24+
pl.gca().ticklabel_format(style='sci', scilimits=(0,0),axis='y')
25+
26+
def scix():
27+
pl.gca().ticklabel_format(style='sci', scilimits=(0,0),axis='x')
28+
29+
30+
def colorprog(i_prog, Nplots, v1 = .9, v2 = 1.):
31+
return hsv_to_rgb(float(i_prog)/float(Nplots), v1, v2)

0 commit comments

Comments
 (0)