Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
giadarol committed Jan 27, 2020
2 parents 3a9eb00 + ac64dfe commit c67d7b4
Show file tree
Hide file tree
Showing 43 changed files with 333 additions and 51 deletions.
2 changes: 1 addition & 1 deletion 002_change_version_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
with open(filename) as fid:
content = fid.read()
if 'giovanni.iadarola@cern.ch' in content:
content = content.replace('PyECLOUD Version 8.4.0', 'PyECLOUD Version 8.4.0')
content = content.replace('PyECLOUD Version 8.4.1', 'PyECLOUD Version 8.4.1')
with open(filename, 'w') as fid:
fid.write(content)

Expand Down
2 changes: 1 addition & 1 deletion 003_change_preamble.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down
2 changes: 1 addition & 1 deletion MP_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down
4 changes: 2 additions & 2 deletions PyEC4PyHT.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down Expand Up @@ -238,7 +238,7 @@ def __init__(
"""

print("PyECLOUD Version 8.4.0")
print("PyECLOUD Version 8.4.1")

# These git commands return the hash and the branch of the specified git directory.
path_to_git = os.path.dirname(os.path.abspath(__file__)) + "/.git"
Expand Down
2 changes: 1 addition & 1 deletion beam_and_timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down
4 changes: 2 additions & 2 deletions buildup_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down Expand Up @@ -71,7 +71,7 @@ def __init__(
**kwargs
):

print("PyECLOUD Version 8.4.0")
print("PyECLOUD Version 8.4.1")
(
beamtim,
spacech_ele,
Expand Down
2 changes: 1 addition & 1 deletion cloud_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Author and contact: Giovanni IADAROLA
Expand Down
2 changes: 1 addition & 1 deletion cross_ionization.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down
2 changes: 1 addition & 1 deletion dynamics_Boris_f2py.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down
2 changes: 1 addition & 1 deletion dynamics_Boris_multipole.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down
2 changes: 1 addition & 1 deletion dynamics_dipole.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down
2 changes: 1 addition & 1 deletion dynamics_strong_B_generalized.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down
2 changes: 1 addition & 1 deletion electron_emission.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down
2 changes: 1 addition & 1 deletion gas_ionization_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down
2 changes: 1 addition & 1 deletion gen_photoemission_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down
2 changes: 1 addition & 1 deletion geom_impact_ellip.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down
2 changes: 1 addition & 1 deletion geom_impact_poly.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down
2 changes: 1 addition & 1 deletion geom_impact_poly_fast_impact.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down
2 changes: 1 addition & 1 deletion geom_impact_rect_fast_impact.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down
2 changes: 1 addition & 1 deletion h000_find_and_modify_preamble.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down
2 changes: 1 addition & 1 deletion impact_management_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down
2 changes: 1 addition & 1 deletion init.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# This file is part of the code:
#
# PyECLOUD Version 8.4.0
# PyECLOUD Version 8.4.1
#
#
# Main author: Giovanni IADAROLA
Expand Down
26 changes: 14 additions & 12 deletions mystyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@
import numpy as np


def mystyle(fontsz=16):
def mystyle(fontsz=16, traditional_look=True):
rcdefaults()
version = matplotlib.__version__.split('.')[0]
if version == '2':
print('Reverting matplotlib look to v1.5')
plt.rcParams['axes.autolimit_mode'] = 'round_numbers'
plt.rcParams['axes.xmargin'] = 0
plt.rcParams['axes.ymargin'] = 0
plt.rcParams['xtick.direction'] = 'in'
plt.rcParams['ytick.direction'] = 'in'
plt.rcParams['xtick.top'] = True
plt.rcParams['ytick.right'] = True
plt.rcParams['legend.numpoints'] = 1
plt.style.use('classic')

if traditional_look:
if int(version) >= '2':
print('Reverting matplotlib look to v1.5')
plt.rcParams['axes.autolimit_mode'] = 'round_numbers'
plt.rcParams['axes.xmargin'] = 0
plt.rcParams['axes.ymargin'] = 0
plt.rcParams['xtick.direction'] = 'in'
plt.rcParams['ytick.direction'] = 'in'
plt.rcParams['xtick.top'] = True
plt.rcParams['ytick.right'] = True
plt.rcParams['legend.numpoints'] = 1
plt.style.use('classic')

font = { # 'family' : 'normal',
#'weight' : 'bold',
Expand Down
89 changes: 89 additions & 0 deletions other/follow_electrons/000_run_simulation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import numpy as np

from PyECLOUD.buildup_simulation import BuildupSimulation

sim_input_folder = '../../testing/tests_buildup/LHC_ArcDipReal_450GeV_sey1.70_2.5e11ppb_bl_1.00ns'
sim_input_folder = 'input_files'
t_stop_list = [1800e-9]

i_observe = range(0, 60000, 100)

def observe_electrons(sim):

ec = sim.cloud_list[0]

if not hasattr(ec, 'x_follow'):
ec.x_follow = []
ec.y_follow = []
ec.z_follow = []
ec.nel_follow = []

mask_observe = np.zeros_like(ec.MP_e.x_mp, dtype=np.bool)
mask_observe[i_observe] = True

x_temp = ec.MP_e.x_mp[mask_observe]
y_temp = ec.MP_e.y_mp[mask_observe]
z_temp = ec.MP_e.z_mp[mask_observe]
nel_temp = ec.MP_e.nel_mp[mask_observe]

temp_mask = mask_observe.copy()
temp_mask[ec.MP_e.N_mp:] = False
N_keep = np.sum(temp_mask)

x_temp[N_keep:] = np.nan
y_temp[N_keep:] = np.nan
z_temp[N_keep:] = np.nan
nel_temp [N_keep:] = np.nan

ec.x_follow.append(x_temp)
ec.y_follow.append(y_temp)
ec.z_follow.append(z_temp)
ec.nel_follow.append(nel_temp)

return np.sum(nel_temp)

step_by_step_custom_observables = {
'N_observed': observe_electrons,
}

pass_by_pass_custom_observables = {
}

save_once_custom_observables = {
}

sim = BuildupSimulation(pyecl_input_folder=sim_input_folder,
logfile_path='logfile.txt',
progress_path='progress.txt',
filen_main_outp='./Pyecltest.mat',
secondary_angle_distribution = 'cosine_3D',
fact_clean = 0., # cleanings would move electrons around
extract_sey=False,
step_by_step_custom_observables = step_by_step_custom_observables,
pass_by_pass_custom_observables = pass_by_pass_custom_observables,
save_once_custom_observables = save_once_custom_observables)

ec = sim.cloud_list[0]

for ii, t_stop in enumerate(t_stop_list):
print('\n\n==============================')
print(('Simulation run %d - t_stop = %s s'%(ii, repr(t_stop))))
print((' starting at tt=%s s'%repr(sim.beamtim.tt_curr)))

sim.run(t_end_sim = t_stop)

print((' after run a tt=%s'%repr(sim.beamtim.tt_curr)))


x_foll = np.array(ec.x_follow)
y_foll = np.array(ec.y_follow)
z_foll = np.array(ec.z_follow)
nel_foll = np.array(ec.nel_follow)

import scipy.io as sio
sio.savemat('followed_electrons.mat',{
'x': x_foll,
'y': y_foll,
'z': z_foll,
'nel': nel_foll,
}, oned_as='row')
Loading

0 comments on commit c67d7b4

Please sign in to comment.