-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathES1main.m
112 lines (84 loc) · 1.65 KB
/
ES1main.m
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
%ES1 - Main Program
clear variables
FIRST
INIT
N_grid = linspace(0,1,N);
phi_left = 0;
phi_right = 0;
sink_countl = 0;
sink_countr = 0;
sink_countil = 0;
sink_countir = 0;
wall_ions = zeros(N,1);
gridt = linspace(0,(nt+1)*dt,(nt+1));
x_hist = zeros(nt,1);
xi_hist = zeros(nt,1);
vi_hist = zeros(nt,1);
v_hist = zeros(nt,1);
x_hist(1) = x(1);
xi_hist(1) = ionx(1);
v_hist(1) = v_hist(1);
vi_hist(1) = vxi(1);
SINK
SETRHO
FIELDS
SETV
%F(3) = struct('cdata',[],'colormap',[]);
for i=1:nt
if mod(i,1) == 0
%{
figure(1) % create new figure
subplot(2,3,1) % first subplot
plot(gridx,density_e, gridx, density_i)
title('Density')
subplot(2,3,2) % first subplot
hist([vx,vxi],ng)
title('Velocity Hist.')
subplot(2,3,3) % first subplot
scatter(x,vx)
hold on
scatter(ionx,vxi)
axis([0 1 -1e8 1e8])
title('Phase Space')
hold off
subplot(2,3,4) % first subplot
plot(gridx,phi)
title('Potential')
subplot(2,3,5) % first subplot
plot(gridx,E)
title('E field')
subplot(2,3,6) % first subplot
hist(wall_ions(1:(sink_countil + sink_countir)), ng)
title('Ion Impact v')
%}
end
figure(2)
scatter(x,vx, '.')
ylim([-1e6 1e6])
hold on
scatter(ionx,vxi, '.')
title('Phase Space')
xlabel('Position');
ylabel('Velocity');
hold off
F(i) = getframe;
ACCEL
MOVE
x_hist(i+1) = x(1);
xi_hist(i+1) = ionx(1);
v_hist(i+1) = vx(1);
vi_hist(i+1) = vxi(1);
SINK
sink_countl;
sink_countr;
sink_countil;
sink_countir;
SETRHO
FIELDS
i
end
numtimes=1;
fps=1;
figure
movie(F,numtimes,fps);
movie2avi(F, 'two_stream.avi');