-
Notifications
You must be signed in to change notification settings - Fork 0
/
track-proton.py
executable file
·49 lines (42 loc) · 1.63 KB
/
track-proton.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
#!/usr/bin/env python
from math import *
import numpy as np
import matplotlib.pyplot as plt
import BasicFunc as func
import Input as para
#################################################################################
num_of_turns = para.app3_num_of_turns # total number of turns for a ramping cycle
#################################################################################
default_var_phi = 3.14
default_var_dE = 0.0
var_phi = default_var_phi # need to varify in "while" loop
var_dE = default_var_dE # need to varify in "while" loop
var_t = 0.0 # set initial ramping time = 0 (s)
var_E = func.E_total_p(var_t)
var_beta2 = func.beta2_p(var_E)
show_dPoP = 9999.0*np.ones(num_of_turns)
show_phi = 9999.0*np.ones(num_of_turns)
search_step = 0
Delta_rad = 0.01
while (abs(show_phi[num_of_turns-1])>default_var_phi):
for i in range(num_of_turns):
var_dE, var_phi = func.iteration_p(var_dE, var_phi, var_t, var_E)
show_phi[i] = var_phi
show_dPoP[i] = var_dE/var_E/var_beta2
var_t = func.t_p_new(var_t, var_E)
var_E = func.E_total_p(var_t)
var_beta2 = func.beta2_p(var_E)
search_step += 1
var_phi = default_var_phi - Delta_rad*search_step
var_dE = 0.0
print 'start phi (Rad)= ', (var_phi + Delta_rad)
plt.figure(1)
##################################################
plt.xlim(para.set_xlim1, para.set_xlim2)
plt.ylim(para.set_ylim1, para.set_ylim2)
##################################################
plt.xlabel('$\phi$ (rad)', fontsize=20)
plt.ylabel('$\Delta P / P $ (%)', fontsize=20)
plt.plot(show_phi, 100.0*show_dPoP, 'ro-', markeredgecolor = 'none')
plt.grid(True)
plt.show()