-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot-electron.py
executable file
·119 lines (102 loc) · 4.14 KB
/
plot-electron.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
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/env python
from math import *
import numpy as np
import matplotlib.pyplot as plt
import BasicFunc as func
var_turn = 0 # initial number of turn = 0 turn
var_turn_reach_V_max = 0 # initial number of turn = 0 turn
var_t = 0 # initial time = 0 (s)
var_KE = func.KE(var_t) # initial kinetic energy (at t = 0)
MAX_element = 1000000 # maximum number of point to show in the plot
show_t = np.ones(MAX_element)
show_KE = np.ones(MAX_element)
show_V = np.ones(MAX_element)
show_phis = np.ones(MAX_element)
show_Q_s = np.ones(MAX_element)
show_alpha = np.ones(MAX_element)
show_area = np.ones(MAX_element)
show_beta2 = np.ones(MAX_element)
show_v = np.ones(MAX_element)
while (var_KE<=(func.E_max-0.001)):
var_E = func.E_total_e(var_t)
var_V = func.V_RF(var_t)
var_KE = func.KE(var_t)
var_phis = func.phis_e(var_t, var_E)
var_Q_s = func.Q_s_e(var_E, var_V, var_t)
var_alpha = func.alpha_ad_e(var_E, var_V, var_t)
var_area = func.area_e(var_E, var_V, var_t)
var_beta2 = func.beta2_e(var_E)
var_v = func.v_e(var_E)
show_t[var_turn] = var_t
show_KE[var_turn] = var_KE
show_V[var_turn] = var_V
show_phis[var_turn] = var_phis
show_Q_s[var_turn] = var_Q_s
show_alpha[var_turn] = var_alpha
show_area[var_turn] = var_area
show_v[var_turn] = var_v
var_t = func.t_e_new(var_t, var_E)
var_turn += 1
if (var_V <= (func.V_max-0.001)):
var_turn_reach_V_max += 1
print 'total no. of turns: ', var_turn
print 'total no. of turns reaching maximunm RF voltage: ', var_turn_reach_V_max
print 'total ramping time (s): ', var_t
plt.figure(1)
plt.xlabel('Time (ms)', fontsize=30)
plt.ylabel('Kinetic Energy (MeV)', fontsize=30)
plt.xticks(fontsize=25)
plt.yticks(fontsize=25)
plt.plot(show_t[:var_turn]*1.0e+3, show_KE[:var_turn]*1.0e-6, 'b-', markeredgecolor = 'none', linewidth=4)
#plt.grid(True)
plt.savefig('electron_KE.eps', format='eps', dpi=1000, bbox_inches='tight')
plt.figure(2)
plt.xlabel('Time (ms)', fontsize=30)
plt.ylabel('RF Voltage (kV)', fontsize=30)
plt.xticks(fontsize=25)
plt.yticks(fontsize=25)
plt.plot(show_t[:var_turn_reach_V_max]*1.0e+3, show_V[:var_turn_reach_V_max]*1.0e-3, 'b-', markeredgecolor = 'none', linewidth=4)
#plt.grid(True)
plt.savefig('electron_V_RF.eps', format='eps', dpi=1000, bbox_inches='tight')
plt.figure(3)
plt.xlabel('Time (ms)', fontsize=30)
plt.ylabel('$\phi_s$ (degree)', fontsize=30)
plt.xticks(fontsize=25)
plt.yticks(fontsize=25)
plt.plot(show_t[:var_turn]*1.0e+3, show_phis[:var_turn]*180.0/3.1415926, 'b-', markeredgecolor = 'none', linewidth=4)
#plt.grid(True)
plt.savefig('electron_phis.eps', format='eps', dpi=1000, bbox_inches='tight')
plt.figure(4)
plt.xlabel('Time (ms)', fontsize=30)
plt.ylabel('Synchrotron Tune ($Q_s$)', fontsize=30)
plt.xticks(fontsize=25)
plt.yticks(fontsize=25)
plt.plot(show_t[:var_turn]*1.0e+3, show_Q_s[:var_turn], 'b-', markeredgecolor = 'none', linewidth=4)
#plt.grid(True)
plt.savefig('electron_Qs.eps', format='eps', dpi=1000, bbox_inches='tight')
plt.figure(5)
plt.xlabel('Time (ms)', fontsize=30)
plt.ylabel('Adiabatic Coefficient (x$10^{-6}$)', fontsize=25)
plt.xticks(fontsize=25)
plt.yticks(fontsize=25)
#plt.plot(show_t[:var_turn]*1.0e+3, show_alpha[:var_turn]*1.0e+6, 'b-', markeredgecolor = 'none', linewidth=4)
plt.plot(show_t[:var_turn_reach_V_max]*1.0e+3, show_alpha[:var_turn_reach_V_max]*1.0e+6, 'b-', markeredgecolor = 'none', linewidth=4)
#plt.grid(True)
plt.savefig('electron_alpha_ad.eps', format='eps', dpi=1000, bbox_inches='tight')
plt.figure(6)
plt.xlabel('Time (ms)', fontsize=30)
plt.ylabel('Bucket Area', fontsize=30)
plt.xticks(fontsize=25)
plt.yticks(fontsize=25)
plt.plot(show_t[:var_turn]*1.0e+3, show_area[:var_turn], 'b-', markeredgecolor = 'none', linewidth=4)
#plt.grid(True)
plt.savefig('electron_BArea.eps', format='eps', dpi=1000, bbox_inches='tight')
plt.figure(7)
plt.xlabel('Time (ms)', fontsize=30)
plt.ylabel('Particle Velocity (c)', fontsize=30)
plt.xticks(fontsize=25)
plt.yticks(fontsize=25)
plt.plot(show_t[:var_turn]*1.0e+3, show_v[:var_turn]/func.c_speed, 'b-', markeredgecolor = 'none', linewidth=4)
#plt.grid(True)
plt.savefig('electron_velocity.eps', format='eps', dpi=1000, bbox_inches='tight')
plt.show()