diff --git a/change_version_number.py b/002_change_version_number.py similarity index 81% rename from change_version_number.py rename to 002_change_version_number.py index 762eada7..530fc66c 100644 --- a/change_version_number.py +++ b/002_change_version_number.py @@ -9,7 +9,7 @@ with open(filename) as fid: content=fid.read() if 'giovanni.iadarola@cern.ch' in content: - content=content.replace('PyECLOUD Version 6.7.0', 'PyECLOUD Version 6.7.0') + content=content.replace('PyECLOUD Version 6.7.1', 'PyECLOUD Version 6.7.1') with open(filename,'w') as fid: fid.write(content) diff --git a/003_change_preamble.py b/003_change_preamble.py new file mode 100644 index 00000000..1027dce5 --- /dev/null +++ b/003_change_preamble.py @@ -0,0 +1,113 @@ +raise ValueError("Not to be used to change the version!\nComment this line to change preamble.") + + +import os + +before_preamble = 0 +in_preamble = 1 +after_preamble = 2 + + +id_preamble_begin = '#-Begin-preamble----' +id_preamble_end = '#-End-preamble--------' + +preamble_new = """#-Begin-preamble------------------------------------------------------- +# +# CERN +# +# European Organization for Nuclear Research +# +# +# This file is part of the code: +# +# PyECLOUD Version 6.7.1 +# +# +# Main author: Giovanni IADAROLA +# BE-ABP Group +# CERN +# CH-1211 GENEVA 23 +# SWITZERLAND +# giovanni.iadarola@cern.ch +# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo +# +# +# Copyright CERN, Geneva 2011 - Copyright and any other +# appropriate legal protection of this computer program and +# associated documentation reserved in all countries of the +# world. +# +# Organizations collaborating with CERN may receive this program +# and documentation freely and without charge. +# +# CERN undertakes no obligation for the maintenance of this +# program, nor responsibility for its correctness, and accepts +# no liability whatsoever resulting from its use. +# +# Program and documentation are provided solely for the use of +# the organization to which they are distributed. +# +# This program may not be copied or otherwise distributed +# without permission. This message must be retained on this and +# any other authorized copies. +# +# The material cannot be sold. CERN should be given credit in +# all references. +# +#-End-preamble---------------------------------------------------------""" + +new_preamble_lines = preamble_new.split('\n') + + + +for dirpath, _, filenames in os.walk('.'): + full_paths = [os.path.join(dirpath, x) for x in filenames] + + python_files = [x for x in full_paths if x.endswith('.py')] + for path in python_files: + + if os.path.abspath(path) == os.path.abspath(__file__): + continue + + with open(path, 'r') as f: + content = f.read() + + if new_preamble_lines[0] not in content: + continue + + print(path) + + lines = content.split('\n') + + prev_line = None + new_lines = [] + status = before_preamble + + for line in lines: + if status == before_preamble: + if id_preamble_begin in line: + status = in_preamble + new_lines.extend(new_preamble_lines) + elif status == in_preamble: + if id_preamble_end in prev_line: + status = after_preamble + elif status == after_preamble: + pass + + + if status != in_preamble: + new_lines.append(line) + + prev_line = line + + new_lines = [x+'\n' for ctr, x in enumerate(new_lines) if ctr+1 != len(new_lines)] + + with open(path, 'w') as f: + f.writelines(new_lines) + print('Modified %s' % path) + diff --git a/MP_system.py b/MP_system.py index a4b8e56b..90d2b52d 100644 --- a/MP_system.py +++ b/MP_system.py @@ -1,4 +1,4 @@ -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -7,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -47,7 +45,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- import numpy as np from numpy.random import rand diff --git a/PyEC4PyHT.py b/PyEC4PyHT.py index 2b92f96e..d5e03fcf 100644 --- a/PyEC4PyHT.py +++ b/PyEC4PyHT.py @@ -1,5 +1,4 @@ -#---------------------------------------------------------------------- -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -8,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -48,7 +45,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- import os import subprocess @@ -67,7 +65,7 @@ class Ecloud(object): def __init__(self, L_ecloud, slicer, Dt_ref, pyecl_input_folder='./', flag_clean_slices=False, slice_by_slice_mode=False, space_charge_obj=None, MP_e_mass=m_e, MP_e_charge=-e, **kwargs): - print 'PyECLOUD Version 6.7.0' + print 'PyECLOUD Version 6.7.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' diff --git a/PyEC4PyHT_fastion.py b/PyEC4PyHT_fastion.py index f720ccab..af928660 100644 --- a/PyEC4PyHT_fastion.py +++ b/PyEC4PyHT_fastion.py @@ -1,5 +1,4 @@ -#---------------------------------------------------------------------- -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -8,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -48,7 +45,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- import numpy as np from scipy.constants import c, e diff --git a/beam_and_timing.py b/beam_and_timing.py index 2fccd821..2203449e 100644 --- a/beam_and_timing.py +++ b/beam_and_timing.py @@ -1,4 +1,4 @@ -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -7,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -47,7 +45,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- import numpy as np diff --git a/buildup_simulation.py b/buildup_simulation.py index 9cae91a1..62e3c910 100644 --- a/buildup_simulation.py +++ b/buildup_simulation.py @@ -1,6 +1,6 @@ #!/afs/cern.ch/project/uslarp/opt/lxplus64/Python-2.7.2/bin/python -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -9,23 +9,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -49,7 +47,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- import init as init @@ -59,7 +58,7 @@ class BuildupSimulation(object): def __init__(self, pyecl_input_folder='./', **kwargs): - print 'PyECLOUD Version 6.7.0' + print 'PyECLOUD Version 6.7.1' beamtim,MP_e, dynamics,impact_man, pyeclsaver, \ gas_ion_flag, resgasion, t_ion, \ spacech_ele,t_sc_ON, photoem_flag, phemiss,\ diff --git a/default_input_parameters.py b/default_input_parameters.py index e63e85ff..c3dc90c9 100644 --- a/default_input_parameters.py +++ b/default_input_parameters.py @@ -4,6 +4,7 @@ # This most importantly excludes python lists. Tuples may be used in their place. parameters_dict = { + 'superparameters':{'pi'}, #are allowed anywhere and can be repeated (for backwards compatibility) 'simulation_parameters': { 'mandatory': { diff --git a/doc/reference/reference.pdf b/doc/reference/reference.pdf index d787f582..fc470196 100644 Binary files a/doc/reference/reference.pdf and b/doc/reference/reference.pdf differ diff --git a/doc/reference/src/reference.tex b/doc/reference/src/reference.tex index 8b27c1fd..00fa36ab 100644 --- a/doc/reference/src/reference.tex +++ b/doc/reference/src/reference.tex @@ -390,7 +390,7 @@ \subsection{Simulation parameters} \multicolumn{2}{p{.97\textwidth}}{\textbf{Photoemission parameters} (if generation by photoemission is not desired, the following parameters can be omitted).} \\ \hline \textbf{photoem\_flag} & (optional -- default=0) \newline - (0 $\Rightarrow$ Off, 1 $\Rightarrow$ traditional, 2 or 'from\_file' $\Rightarrow$ From file, 3 or 'per\_segment' $\Rightarrow$ Part of chamber definition) Enables primary electron generation by photoemission. + (0 $\Rightarrow$ Off, 1 $\Rightarrow$ traditional, 2 or 'from\_file' $\Rightarrow$ Angular distribution from file, 3 or 'per\_segment' $\Rightarrow$ Part of chamber definition) Enables primary electron generation by photoemission. \\ \hline \textbf{k\_pe\_st} & [m$^{-1}$] Number of photoelectrons to be generated per proton and per unit length. \\ \hline diff --git a/dynamics_Boris_f2py.py b/dynamics_Boris_f2py.py index fd770a7e..fa6ea626 100644 --- a/dynamics_Boris_f2py.py +++ b/dynamics_Boris_f2py.py @@ -1,4 +1,4 @@ -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -7,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -47,7 +45,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- from numpy import array, cross, sum, squeeze import scipy.io as sio diff --git a/dynamics_Boris_multipole.py b/dynamics_Boris_multipole.py index 7b6c14d0..3e3312d0 100644 --- a/dynamics_Boris_multipole.py +++ b/dynamics_Boris_multipole.py @@ -1,4 +1,4 @@ -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -7,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -47,7 +45,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- import math import numpy as np diff --git a/dynamics_dipole.py b/dynamics_dipole.py index f99e434f..96755d35 100644 --- a/dynamics_dipole.py +++ b/dynamics_dipole.py @@ -1,4 +1,4 @@ -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -7,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -47,7 +45,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- import sincc_cosincc_cubsincc as cs diff --git a/dynamics_strong_B_generalized.py b/dynamics_strong_B_generalized.py index 0d156631..644119f0 100644 --- a/dynamics_strong_B_generalized.py +++ b/dynamics_strong_B_generalized.py @@ -1,4 +1,4 @@ -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -7,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -47,7 +45,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- from numpy import sqrt, sin, cos, squeeze, sum diff --git a/sec_emission.py b/electron_emission.py similarity index 94% rename from sec_emission.py rename to electron_emission.py index d1c86b77..9321b7ed 100644 --- a/sec_emission.py +++ b/electron_emission.py @@ -1,4 +1,4 @@ -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -7,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -47,7 +45,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- from __future__ import division import time diff --git a/gas_ionization_class.py b/gas_ionization_class.py index 6912bfc5..b5b9baa7 100644 --- a/gas_ionization_class.py +++ b/gas_ionization_class.py @@ -1,4 +1,4 @@ -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -7,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -47,7 +45,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- from numpy.random import rand diff --git a/gen_photoemission_class.py b/gen_photoemission_class.py index 81f68786..c4f32b19 100644 --- a/gen_photoemission_class.py +++ b/gen_photoemission_class.py @@ -1,4 +1,4 @@ -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -7,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -47,7 +45,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- from __future__ import division, print_function import numpy as np @@ -56,7 +55,7 @@ import scipy.io as sio from scipy.constants import c -import sec_emission +import electron_emission class PyECLOUD_PhotoemissionException(ValueError): pass @@ -118,7 +117,7 @@ def __init__(self, inv_CDF_refl_photoem_file, k_pe_st, refl_frac, e_pe_sigma, e_ self.out_radius = out_radius self.chamb = chamb self.resc_fac = resc_fac - self.angle_dist_func = sec_emission.get_angle_dist_func(photoelectron_angle_distribution) + self.angle_dist_func = electron_emission.get_angle_dist_func(photoelectron_angle_distribution) self.flag_continuous_emission = flag_continuous_emission if flag_continuous_emission: @@ -132,7 +131,7 @@ def __init__(self, inv_CDF_refl_photoem_file, k_pe_st, refl_frac, e_pe_sigma, e_ if np.any(self.chamb.is_outside(x0_refl_np_arr, y0_refl_np_arr)): raise PyECLOUD_PhotoemissionException('x0_refl, y0_refl is outside of the chamber!') - self.get_energy = sec_emission.get_energy_distribution_func(energy_distribution, e_pe_sigma, e_pe_max) + self.get_energy = electron_emission.get_energy_distribution_func(energy_distribution, e_pe_sigma, e_pe_max) print('Done photoemission init. Energy distribution: %s' % energy_distribution) @@ -206,8 +205,8 @@ def __init__(self, inv_CDF_all_photoem_file, chamb, resc_fac, energy_distributio if flag_continuous_emission: self.mean_lambda = np.mean(beamtim.lam_t_array) - self.get_energy = sec_emission.get_energy_distribution_func(energy_distribution, e_pe_sigma, e_pe_max) - self.angle_dist_func = sec_emission.get_angle_dist_func(photoelectron_angle_distribution) + self.get_energy = electron_emission.get_energy_distribution_func(energy_distribution, e_pe_sigma, e_pe_max) + self.angle_dist_func = electron_emission.get_angle_dist_func(photoelectron_angle_distribution) print('Done photoemission init') def generate(self, MP_e, lambda_t, Dt): @@ -237,8 +236,8 @@ def __init__(self, chamb, energy_distribution, e_pe_sigma, e_pe_max, k_pe_st, self.k_pe_st = k_pe_st self.chamb = chamb self.flag_continuous_emission = flag_continuous_emission - self.get_energy = sec_emission.get_energy_distribution_func(energy_distribution, e_pe_sigma, e_pe_max) - self.angle_dist_func = sec_emission.get_angle_dist_func(photoelectron_angle_distribution) + self.get_energy = electron_emission.get_energy_distribution_func(energy_distribution, e_pe_sigma, e_pe_max) + self.angle_dist_func = electron_emission.get_angle_dist_func(photoelectron_angle_distribution) if self.flag_continuous_emission: self.mean_lambda = np.mean(beamtim.lam_t_array) print('Done photoemission init') diff --git a/geom_impact_ellip.py b/geom_impact_ellip.py index f350fbf6..cb30c274 100644 --- a/geom_impact_ellip.py +++ b/geom_impact_ellip.py @@ -1,4 +1,4 @@ -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -7,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -47,7 +45,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- diff --git a/geom_impact_poly.py b/geom_impact_poly.py index d567bc88..0f730f2d 100644 --- a/geom_impact_poly.py +++ b/geom_impact_poly.py @@ -1,4 +1,4 @@ -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -7,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -47,7 +45,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- diff --git a/geom_impact_poly_fast_impact.py b/geom_impact_poly_fast_impact.py index 378632f5..514c3a35 100644 --- a/geom_impact_poly_fast_impact.py +++ b/geom_impact_poly_fast_impact.py @@ -1,4 +1,4 @@ -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -7,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -47,7 +45,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- from __future__ import division, print_function diff --git a/geom_impact_rect_fast_impact.py b/geom_impact_rect_fast_impact.py index 07994cee..d080fb19 100644 --- a/geom_impact_rect_fast_impact.py +++ b/geom_impact_rect_fast_impact.py @@ -1,4 +1,4 @@ -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -7,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -47,7 +45,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- import geom_impact_poly_fast_impact as gipfi import numpy as np diff --git a/h000_find_and_modify_preamble.py b/h000_find_and_modify_preamble.py new file mode 100644 index 00000000..4c6bcea8 --- /dev/null +++ b/h000_find_and_modify_preamble.py @@ -0,0 +1,92 @@ +import os + +begin = '''#---------------------------------------------------------------------- +# +# CERN +# +# European Organization for Nuclear Research +''' + +#-Begin-preamble------------------------------------------------------- +# +# CERN +# +# European Organization for Nuclear Research +# +# +# This file is part of the code: +# +# PyECLOUD Version 6.7.1 +# +# +# Main author: Giovanni IADAROLA +# BE-ABP Group +# CERN +# CH-1211 GENEVA 23 +# SWITZERLAND +# giovanni.iadarola@cern.ch +# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo +# +# +# Copyright CERN, Geneva 2011 - Copyright and any other +# appropriate legal protection of this computer program and +# associated documentation reserved in all countries of the +# world. +# +# Organizations collaborating with CERN may receive this program +# and documentation freely and without charge. +# +# CERN undertakes no obligation for the maintenance of this +# program, nor responsibility for its correctness, and accepts +# no liability whatsoever resulting from its use. +# +# Program and documentation are provided solely for the use of +# the organization to which they are distributed. +# +# This program may not be copied or otherwise distributed +# without permission. This message must be retained on this and +# any other authorized copies. +# +# The material cannot be sold. CERN should be given credit in +# all references. +# +#-End-preamble--------------------------------------------------------- + + +for dirpath, _, filenames in os.walk('.'): + full_paths = [os.path.join(dirpath, x) for x in filenames] + + python_files = [x for x in full_paths if x.endswith('.py')] + for path in python_files: + + if os.path.abspath(path) == os.path.abspath(__file__): + continue + + with open(path, 'r') as f: + content = f.read() + + if begin in content: + print(path) + content = content.replace(begin, newbegin) + + with open(path, 'w') as f: + f.write(content) + + if end in content: + print 'End to be changed:' + print(path) + content = content.replace(end, newend) + + with open(path, 'w') as f: + f.write(content) + + if '#--------------' in content: + print 'Test' + print(path) + + diff --git a/impact_management_class.py b/impact_management_class.py index d2ff28e2..287413bc 100644 --- a/impact_management_class.py +++ b/impact_management_class.py @@ -1,4 +1,4 @@ -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -7,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -47,10 +45,11 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- import numpy as np -import sec_emission +import electron_emission import hist_for as histf import seg_impact as segi @@ -116,7 +115,7 @@ def __init__(self, switch_no_increase_energy, chamb, sey_mod, E_th, sigmafit, mu self.nel_hist_impact_seg=np.zeros(chamb.N_vert,float) self.energ_eV_impact_seg =np.zeros(chamb.N_vert,float) - self.angle_dist_func = sec_emission.get_angle_dist_func(secondary_angle_distribution) + self.angle_dist_func = electron_emission.get_angle_dist_func(secondary_angle_distribution) print 'Done impact man. init.' @@ -274,7 +273,7 @@ def backtrack_and_second_emiss(self, old_pos, MP_e): N_mp_new = N_mp_old + n_add_total # replace impacted MPs that are not reflected - En_truesec_eV = sec_emission.sec_energy_hilleret_model2( + En_truesec_eV = electron_emission.sec_energy_hilleret_model2( switch_no_increase_energy, N_true_sec, sigmafit, mufit, E_th, E_impact_eV[flag_truesec], thresh_low_energy) vx_emit[flag_truesec], vy_emit[flag_truesec], vz_emit[flag_truesec] = self.angle_dist_func( N_true_sec, En_truesec_eV, Norm_x[flag_truesec], Norm_y[flag_truesec]) @@ -291,7 +290,7 @@ def backtrack_and_second_emiss(self, old_pos, MP_e): E_impact_eV_add = np.repeat(E_impact_eV, n_add) # Generate new MP properties, angles and energies - En_truesec_eV_add = sec_emission.sec_energy_hilleret_model2( + En_truesec_eV_add = electron_emission.sec_energy_hilleret_model2( switch_no_increase_energy, n_add_total, sigmafit, mufit, E_th, E_impact_eV_add, thresh_low_energy) vx_mp_add, vy_mp_add, vz_mp_add = self.angle_dist_func( n_add_total, En_truesec_eV_add, norm_x_add, norm_y_add) diff --git a/init.py b/init.py index f606607b..a5188cda 100644 --- a/init.py +++ b/init.py @@ -1,4 +1,4 @@ -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -7,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -47,7 +45,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- from __future__ import division, print_function import os @@ -155,7 +154,7 @@ def read_input_files_and_init_components(pyecl_input_folder='./', skip_beam=Fals pyeclsaver = None # Init chamber - flag_non_unif_sey = (cc.switch_model == 'ECLOUD_unif') + flag_non_unif_sey = (cc.switch_model == 'ECLOUD_nunif') chamber_kwargs = { 'flag_verbose_file': cc.flag_verbose_file, 'flag_verbose_stdout': cc.flag_verbose_stdout, diff --git a/input_parameters_format_specification.py b/input_parameters_format_specification.py index 7501f14e..836ca946 100644 --- a/input_parameters_format_specification.py +++ b/input_parameters_format_specification.py @@ -28,7 +28,7 @@ def assert_module_has_parameters(module, module_name): mandatory_parameters = parameters_dict[module_name]['mandatory'] optional_parameters = set(parameters_dict[module_name]['optional'].keys()) - allowed_parameters = set.union(mandatory_parameters, optional_parameters) + allowed_parameters = set.union(mandatory_parameters, optional_parameters, parameters_dict['superparameters']) extra_parameters = set.difference(module_contents, allowed_parameters) if extra_parameters: @@ -47,6 +47,9 @@ def update_module(module, new_module): Some entries are skipped. """ for attr in dir(new_module): + + if attr=='pi': continue + value = getattr(new_module, attr) if attr.startswith('_') or isinstance(value, types.ModuleType): continue @@ -100,6 +103,11 @@ def import_module_from_file(module_name, file_name): try: new_file_name = dir_name+'/temp_file_%s.py' % (module_name+'_'+str(time.time())).replace('.','_') shutil.copy(file_name, new_file_name) + + # As we use pi in many old input files + with open(new_file_name, 'r') as fid: content = fid.read() + content = "from numpy import pi\n\n"+content + with open(new_file_name, 'w') as fid: fid.write(content) if sys.version_info.major == 2: import imp diff --git a/main.py b/main.py index 0314503c..255dcfa6 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,6 @@ #!/afs/cern.ch/project/uslarp/opt/lxplus64/Python-2.7.2/bin/python -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -9,23 +9,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -49,7 +47,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- #for compatibility with old PyECLOUD versions diff --git a/other/photoemission_angular_distribution/000_generate_pyecloud_photoem_input.py b/other/photoemission_angular_distribution/000_generate_pyecloud_photoem_input.py index 5dc8cb12..21abe1a8 100644 --- a/other/photoemission_angular_distribution/000_generate_pyecloud_photoem_input.py +++ b/other/photoemission_angular_distribution/000_generate_pyecloud_photoem_input.py @@ -24,11 +24,11 @@ u_sam = np.linspace(0, 1, N_u_sam) angles = np.interp(u_sam, cdf, theta_unif) -# Save -pyecl_phem_filename = 'inv_cdf_phem_ang_dirstrib' +# Save +pyecl_phem_filename = 'inv_cdf_phem_ang_distrib' sio.savemat(pyecl_phem_filename, { -'u_sam':u_sam, -'angles':angles}, oned_as ='row') + 'u_sam':u_sam, + 'angles':angles}, oned_as='row') pl.close('all') diff --git a/other/photoemission_angular_distribution/001_test_generated_file.py b/other/photoemission_angular_distribution/001_test_generated_file.py index 35c21161..e4015503 100644 --- a/other/photoemission_angular_distribution/001_test_generated_file.py +++ b/other/photoemission_angular_distribution/001_test_generated_file.py @@ -9,21 +9,21 @@ import geom_impact_ellip as gie import MP_system as mps -file_to_test = 'inv_cdf_phem_ang_dirstrib.mat' +file_to_test = 'inv_cdf_phem_ang_distrib.mat' # generate a chamber chamb = gie.ellip_cham_geom_object(x_aper = 2e-2, y_aper=1e-2) # Build object used by pyecloud -ob = gp.photoemission_from_file(inv_CDF_all_photoem_file = file_to_test, - chamb = chamb, resc_fac = 1., +ob = gp.photoemission_from_file(inv_CDF_all_photoem_file = file_to_test, + chamb = chamb, resc_fac = 1., energy_distribution = 'gaussian', - e_pe_sigma=3., - e_pe_max=10., + e_pe_sigma=3., + e_pe_max=10., k_pe_st = 1., - out_radius=10e-2, - photoelectron_angle_distribution = 'cosine_3D', - beamtim = None, + out_radius=10e-2, + photoelectron_angle_distribution = 'cosine_3D', + beamtim = None, flag_continuous_emission = False) N_mp_test = 100000 @@ -37,28 +37,28 @@ MPe = mps.MP_system( N_mp_max = N_mp_test, nel_mp_ref_0 = 1., - fact_split = 1., - fact_clean = 1e-10, - N_mp_regen_low = 0, - N_mp_regen = 10e9, - N_mp_after_regen = 0.5e9, - Dx_hist_reg = 1, Nx_reg=10, Ny_reg=10, - Nvx_reg=10, - Nvy_reg=10, - Nvz_reg=10, + fact_split = 1., + fact_clean = 1e-10, + N_mp_regen_low = 0, + N_mp_regen = 10e9, + N_mp_after_regen = 0.5e9, + Dx_hist_reg = 1, Nx_reg=10, Ny_reg=10, + Nvx_reg=10, + Nvy_reg=10, + Nvz_reg=10, regen_hist_cut = 1., - chamb=chamb, - N_mp_soft_regen=10e9, - N_mp_after_soft_regen=10e9, - charge=-1.602176565e-19, + chamb=chamb, + N_mp_soft_regen=10e9, + N_mp_after_soft_regen=10e9, + charge=-1.602176565e-19, mass=9.10938291e-31) - + ob.generate(MPe, lambda_t = float(N_mp_test), Dt=1.*3e-8*0.1) theta_part = np.arctan2(MPe.y_mp[:MPe.N_mp], MPe.x_mp[:MPe.N_mp]) hist, x_hist = np.histogram(theta_part, bins = 1000, range = (-np.pi, np.pi)) - + hist_list.append(hist) combined_hist = np.mean(np.array(hist_list), axis=0) @@ -78,7 +78,3 @@ pl.show() - - - - diff --git a/other/photoemission_angular_distribution/inv_cdf_phem_ang_dirstrib.mat b/other/photoemission_angular_distribution/inv_cdf_phem_ang_distrib.mat similarity index 100% rename from other/photoemission_angular_distribution/inv_cdf_phem_ang_dirstrib.mat rename to other/photoemission_angular_distribution/inv_cdf_phem_ang_distrib.mat diff --git a/perfect_absorber_class.py b/perfect_absorber_class.py index 470107c2..5e71ece0 100644 --- a/perfect_absorber_class.py +++ b/perfect_absorber_class.py @@ -1,4 +1,4 @@ -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -7,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -47,7 +45,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- import hist_for as histf import numpy as np diff --git a/proc_video3.py b/proc_video3.py index 8d45bc26..da83cf87 100644 --- a/proc_video3.py +++ b/proc_video3.py @@ -1,4 +1,4 @@ -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -7,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -47,7 +45,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- import scipy.io as sio diff --git a/pyecloud_saver.py b/pyecloud_saver.py index 975ae984..a104eea8 100644 --- a/pyecloud_saver.py +++ b/pyecloud_saver.py @@ -1,5 +1,4 @@ -#---------------------------------------------------------------------- -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -8,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -48,7 +45,8 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- from __future__ import print_function import scipy.io as sio @@ -96,7 +94,7 @@ def __init__(self, logfile_path): print(git_branch) with open(self.logfile_path,'w') as flog: - flog.write('PyECLOUD Version 6.7.0\n') + flog.write('PyECLOUD Version 6.7.1\n') flog.write('%s\n' % git_hash) flog.write('%s\n' % git_branch) flog.write('Simulation started on %s\n' % timestr) diff --git a/sec_emission_model_ECLOUD.py b/sec_emission_model_ECLOUD.py index 150adfe6..807e16b2 100644 --- a/sec_emission_model_ECLOUD.py +++ b/sec_emission_model_ECLOUD.py @@ -1,4 +1,4 @@ -#---------------------------------------------------------------------- +#-Begin-preamble------------------------------------------------------- # # CERN # @@ -7,23 +7,21 @@ # # This file is part of the code: # -# PyECLOUD Version 6.7.0 +# PyECLOUD Version 6.7.1 # # -# Author and contact: Giovanni IADAROLA +# Main author: Giovanni IADAROLA # BE-ABP Group # CERN # CH-1211 GENEVA 23 # SWITZERLAND # giovanni.iadarola@cern.ch # -# contact: Giovanni RUMOLO -# BE-ABP Group -# CERN -# CH-1211 GENEVA 23 -# SWITZERLAND -# giovanni.rumolo@cern.ch -# +# Contributors: Eleanora Belli +# Philipp Dijkstal +# Lotta Mether +# Annalisa Romano +# Giovanni Rumolo # # # Copyright CERN, Geneva 2011 - Copyright and any other @@ -47,39 +45,39 @@ # # The material cannot be sold. CERN should be given credit in # all references. -#---------------------------------------------------------------------- +# +#-End-preamble--------------------------------------------------------- from numpy import sqrt, exp from numpy.random import rand -import numpy as np def yield_fun2(E, costheta, Emax, del_max, R0, E0, s, flag_costheta_delta_scale=True, flag_costheta_Emax_shift=True): if flag_costheta_delta_scale: - del_max_tilde=del_max*exp(0.5*(1.-costheta)); + del_max_tilde=del_max*exp(0.5*(1.-costheta)) else: del_max_tilde=del_max - - if flag_costheta_Emax_shift: - E_max_tilde=Emax*(1.+0.7*(1.-costheta)); + + if flag_costheta_Emax_shift: + E_max_tilde=Emax*(1.+0.7*(1.-costheta)) else: E_max_tilde=Emax - - x=E/E_max_tilde; - true_sec=del_max_tilde*(s*x)/(s-1.+x**s); - reflected=R0*((sqrt(E)-sqrt(E+E0))/(sqrt(E)+sqrt(E+E0)))**2.; + x=E/E_max_tilde + + true_sec=del_max_tilde*(s*x)/(s-1.+x**s) + reflected=R0*((sqrt(E)-sqrt(E+E0))/(sqrt(E)+sqrt(E+E0)))**2. - delta=true_sec+reflected; + delta=true_sec+reflected ref_frac=0.*delta mask_non_zero=(delta>0) - ref_frac[mask_non_zero]=reflected[mask_non_zero]/delta[mask_non_zero]; + ref_frac[mask_non_zero]=reflected[mask_non_zero]/delta[mask_non_zero] return delta, ref_frac class SEY_model_ECLOUD: - def __init__(self, Emax,del_max,R0,E0=150., s=1.35, flag_costheta_delta_scale = True, flag_costheta_Emax_shift=True): + def __init__(self, Emax,del_max,R0,E0=150., s=1.35, flag_costheta_delta_scale=True, flag_costheta_Emax_shift=True): self.Emax = Emax self.del_max = del_max self.R0 = R0 @@ -88,15 +86,15 @@ def __init__(self, Emax,del_max,R0,E0=150., s=1.35, flag_costheta_delta_scale = self.flag_costheta_delta_scale = flag_costheta_delta_scale self.flag_costheta_Emax_shift = flag_costheta_Emax_shift - print 'Secondary emission model: ECLOUD E0=%.4f s=%.4f'%(self.E0, self.s) + print 'Secondary emission model: ECLOUD E0=%.4f s=%.4f' % (self.E0, self.s) def SEY_process(self,nel_impact,E_impact_eV, costheta_impact, i_impact): - yiel, ref_frac=yield_fun2(E_impact_eV,costheta_impact,self.Emax,self.del_max,self.R0, E0=self.E0, s=self.s, - flag_costheta_delta_scale=self.flag_costheta_delta_scale, - flag_costheta_Emax_shift=self.flag_costheta_Emax_shift) - flag_elast=(rand(len(ref_frac))