forked from PyCOMPLETE/PyECLOUD
/
sec_emission.py
111 lines (89 loc) · 5.05 KB
/
sec_emission.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#----------------------------------------------------------------------
#
# CERN
#
# European Organization for Nuclear Research
#
#
# This file is part of the code:
#
# PyECLOUD Version 5.5.3
#
#
# Author and contact: 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
#
#
#
# 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.
#----------------------------------------------------------------------
from numpy import *
from numpy.random import lognormal
from numpy.random import randn
def hilleret_model2(switch_no_increase_energy, Ngen, sigmafit, mufit, E_th, En_impact_eV, thresh_low_energy):
if switch_no_increase_energy==0:
en_eV=lognormal(mufit,sigmafit,Ngen);
flag_above_th=(en_eV>E_th);
Nabove_th=sum(flag_above_th);
while Nabove_th>0:
en_eV[flag_above_th]=lognormal(mufit,sigmafit,Nabove_th);
flag_above_th=(en_eV>E_th);
Nabove_th=sum(flag_above_th);
if switch_no_increase_energy==1:
en_eV=0*En_impact_eV;
flag_low_energy = En_impact_eV<thresh_low_energy
flag_high_energy = ~(flag_low_energy)
N_low_ene=sum(flag_low_energy)
N_high_ene=sum(flag_high_energy)
#generate low energy
en_eV_le=randn(N_low_ene) #in eV
flag_negat=logical_or(en_eV_le<0., en_eV_le>4.)
N_neg=sum(flag_negat);
while(N_neg>0):
en_eV_le[flag_negat]=randn(N_neg) #in eV
flag_negat=logical_or(en_eV_le<0., en_eV_le>4.)
N_neg=sum(flag_negat);
sigma_le=En_impact_eV[flag_low_energy]/4.
en_eV_le=(en_eV_le+2.)*sigma_le
#generate high energy
en_eV_he=lognormal(mufit,sigmafit,N_high_ene);
flag_above_th=logical_or(en_eV_he>E_th,(en_eV_he-En_impact_eV[flag_high_energy])>0)
Nabove_th=sum(flag_above_th);
while Nabove_th>0:
en_eV_he[flag_above_th]=lognormal(mufit,sigmafit,Nabove_th);
flag_above_th=logical_or(en_eV_he>E_th,(en_eV_he-En_impact_eV[flag_high_energy])>0)
Nabove_th=sum(flag_above_th);
en_eV[flag_high_energy]=en_eV_he
en_eV[flag_low_energy]=en_eV_le
return en_eV