forked from SmileiPIC/Smilei
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_fields_vector.m
90 lines (82 loc) · 2.3 KB
/
plot_fields_vector.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
clear;
directory_name = './output/';
file_name = 'Fields0';
file_number = '.h5';
full_name = strcat(directory_name, file_name, file_number);
info = h5info(full_name);
%h5disp(full_name);
Ndata = size(info.Groups.Groups,1);
Ndata = 8;
%datasets = info.Groups.Groups(1).Datasets;
name1x = strcat(info.Groups.Groups(1).Name, '/Bx');
name1y = strcat(info.Groups.Groups(1).Name, '/By');
name1z = strcat(info.Groups.Groups(1).Name, '/Bz');
name2x = strcat(info.Groups.Groups(Ndata).Name, '/Bx');
name2y = strcat(info.Groups.Groups(Ndata).Name, '/By');
name2z = strcat(info.Groups.Groups(Ndata).Name, '/Bz');
name3x = strcat(info.Groups.Groups(Ndata).Name, '/Ex');
name3y = strcat(info.Groups.Groups(Ndata).Name, '/Ey');
name3z = strcat(info.Groups.Groups(Ndata).Name, '/Ez');
Bx1= hdf5read(full_name, name1x);
By1= hdf5read(full_name, name1y);
Bz1= hdf5read(full_name, name1z);
%B0 = sqrt(Bx1(10,10)*Bx1(10,10) + By1(10,10)*By1(10,10) + Bz1(10,10)*Bz1(10,10));
Bx= hdf5read(full_name, name2x);
By= hdf5read(full_name, name2y);
Bz= hdf5read(full_name, name2z);
Ex= hdf5read(full_name, name3x);
Ey= hdf5read(full_name, name3y);
Ez= hdf5read(full_name, name3z);
Ny=size(Bx,1);
Nx=size(Bx,2);
set(0,'DefaultFigureColormap',feval('jet'));
% figure(1);
% colormap Jet;
% [X, Y] = meshgrid(1:Nx, 1:Ny);
% surf(X, Y, Bx);
% shading interp;
% title ('Bx');
% xlabel ('x');
% ylabel ('y');
% zlabel ('Bx');
% grid ;
%
% sampling = 20;
% startx = fix(Nx/10);
% endx = fix(Nx/5);
% tempB(1:Ny, 1:(endx-startx + 1)) = 0;
% for i = startx:endx,
% for j = 1:Ny,
% tempB(j,i-startx+1) = sqrt(Bx(j,i)*Bx(j,i) + By(j,i)*By(j,i) + Bz(j,i)*Bz(j,i))/B0;
% end;
% end;
% figure(2);
% colormap Jet;
% [X, Y] = meshgrid((startx:endx)*0.2*sampling, (1:Ny)*0.4*sampling);
% surf(X, Y, tempB);
% shading interp;
% colorbar;
% title ('B');
% xlabel ('x \omega_e /c');
% ylabel ('y \omega_e /c');
% zlabel ('B/B_0');
% grid ;
factor = 2;
smallNx = fix(Nx/factor);
smallNy = fix(Ny/factor);
startx = 0;
smallBx(1:smallNy,1:smallNx) = 0;
smallBy(1:smallNy,1:smallNx) = 0;
for i=1:smallNy,
for j = 1:smallNx,
smallBx(i,j)=Bx(factor*i,startx+factor*j);
smallBy(i,j)=By(factor*i,startx+factor*j);
end;
end;
figure(3);
quiver((1:smallNx)*factor,(1:smallNy)*factor,smallBx,smallBy)
title ('Bx-By');
xlabel ('x');
ylabel ('y');
zlabel ('Bx-By');
grid ;