-
Notifications
You must be signed in to change notification settings - Fork 0
/
2task.jl
executable file
·189 lines (150 loc) · 4.49 KB
/
2task.jl
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
##########################################################
# Particle trajectory with different initial conditions
##########################################################
using Plots; gr()
k = 1/(4*pi*8.85e-12)
e = 1.6e-19
wholeTime = 1e-13
dt = 1e-20
b = 5e-14
Au_d = 10^(-14) #diameter of Au atom in meters
h = 0.00001 #accuracy parameter
#################### Depending on q #######################
v0 = 1e+7
m = 6.64456e-27
Q = -79*e
tx = [0, 1337]
ty = [0, 1337]
p_q = scatter(tx, ty,
xlims = (-3e-13, 5e-13),
ylims = (-3e-13, 7e-13),
label = "Au",
formatter = :scientific,
title="Depending on q"
)
charges = [-2.85*e, -1.03*e, 0.23e, 1e-23, 3*e, 5*e, 100e, 120e]
for q in charges
tmp = k * Q * q * dt / m
i = 2
x = Float64[]
y = Float64[]
v_x = Float64[]
v_y = Float64[]
push!(v_x, v0)
push!(v_y, 0)
push!(x, -(10*Au_d))
push!(y, b)
for t in dt:dt:wholeTime
push!(v_x, v_x[i-1] + h * tmp * x[i-1] / ( ( x[i-1]^2 + y[i-1]^2 ) ^ (3/2) ) )
push!(v_y, v_y[i-1] + h * tmp * y[i-1] / ( ( x[i-1]^2 + y[i-1]^2 ) ^ (3/2) ) )
push!(x, x[i-1] + (h/2) * (v_x[i-1] + v_x[i]) * dt)
push!(y, y[i-1] + (h/2) * (v_y[i-1] + v_y[i]) * dt)
i += 1
end
plot!(p_q, x, y, label = q)
end
#################### Depending on Q #######################
v0 = 1e+7
m = 6.64456e-27
q = 2*e
tx = [0, 1337]
ty = [0, 1337]
p_Q = scatter(tx, ty,
xlims = (-3e-13, 5e-13),
ylims = (-3e-13, 7e-13),
label = "Au",
formatter = :scientific,
title="Depending on Q"
)
charges = [-110*e, -50*e, -10*e, 5*e, 26*e, 40*e, 99*e, e, 0.5e]
for Q in charges
tmp = k * Q * q * dt / m
i = 2
x = Float64[]
y = Float64[]
v_x = Float64[]
v_y = Float64[]
push!(v_x, v0)
push!(v_y, 0)
push!(x, -(10*Au_d))
push!(y, b)
for t in dt:dt:wholeTime
push!(v_x, v_x[i-1] + h * tmp * x[i-1] / ( ( x[i-1]^2 + y[i-1]^2 ) ^ (3/2) ) )
push!(v_y, v_y[i-1] + h * tmp * y[i-1] / ( ( x[i-1]^2 + y[i-1]^2 ) ^ (3/2) ) )
push!(x, x[i-1] + (h/2) * (v_x[i-1] + v_x[i]) * dt)
push!(y, y[i-1] + (h/2) * (v_y[i-1] + v_y[i]) * dt)
i += 1
end
plot!(p_Q, x, y, label = Q)
end
#################### Depending on m #######################
v0 = 1e+7
Q = 79*e
q = 2*e
tx = [0, 1337]
ty = [0, 1337]
p_m = scatter(tx, ty,
xlims = (-3e-13, 5e-13),
ylims = (-3e-13, 7e-13),
label = "Au",
formatter = :scientific,
title="Depending on m"
)
masses = [3e-29, 3e-27, 6e-27, 8e-27, 1e-26, 2.5e-26, 4e-25]
for m in masses
tmp = k * Q * q * dt / m
i = 2
x = Float64[]
y = Float64[]
v_x = Float64[]
v_y = Float64[]
push!(v_x, v0)
push!(v_y, 0)
push!(x, -(10*Au_d))
push!(y, b)
for t in dt:dt:wholeTime
push!(v_x, v_x[i-1] + h * tmp * x[i-1] / ( ( x[i-1]^2 + y[i-1]^2 ) ^ (3/2) ) )
push!(v_y, v_y[i-1] + h * tmp * y[i-1] / ( ( x[i-1]^2 + y[i-1]^2 ) ^ (3/2) ) )
push!(x, x[i-1] + (h/2) * (v_x[i-1] + v_x[i]) * dt)
push!(y, y[i-1] + (h/2) * (v_y[i-1] + v_y[i]) * dt)
i += 1
end
plot!(p_m, x, y, label = m)
end
#################### Depending on v0 #######################
m = 6e-27
Q = 79*e
q = 2*e
tx = [0, 1337]
ty = [0, 1337]
p_v0 = scatter(tx, ty,
xlims = (-3e-13, 5e-13),
ylims = (-3e-13, 7e-13),
label = "Au",
formatter = :scientific,
title="Depending on v0"
)
speeds = [1e6, 5e6, 8.9e6, 9.43e6, 1.23e7, 1.43e7, 3e7]
for v0 in speeds
tmp = k * Q * q * dt / m
i = 2
x = Float64[]
y = Float64[]
v_x = Float64[]
v_y = Float64[]
push!(v_x, v0)
push!(v_y, 0)
push!(x, -(10*Au_d))
push!(y, b)
for t in dt:dt:wholeTime
push!(v_x, v_x[i-1] + h * tmp * x[i-1] / ( ( x[i-1]^2 + y[i-1]^2 ) ^ (3/2) ) )
push!(v_y, v_y[i-1] + h * tmp * y[i-1] / ( ( x[i-1]^2 + y[i-1]^2 ) ^ (3/2) ) )
push!(x, x[i-1] + (h/2) * (v_x[i-1] + v_x[i]) * dt)
push!(y, y[i-1] + (h/2) * (v_y[i-1] + v_y[i]) * dt)
i += 1
end
plot!(p_v0, x, y, label = v0)
end
plot(p_q, p_Q, p_m, p_v0, layout = 4)
plot!(size=(1000,1000))
savefig("plot2.png")