-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_grid.m
147 lines (118 loc) · 3.1 KB
/
make_grid.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
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
function [N,Ex,Ey,Ez,Bx,By,Bz,Jx,Jy,Jz,Ux,Uy,Uz,Vx,Vy,Vz,grid] = make_grid
%%% Initialize memory %%%
%[DEFAULT] Setup Grid: (Boundary Grid):
grid.Nx = 2*5120; % Only specified here
grid.xmin = 0;
grid.xmax = 1.0;
grid.dx = (grid.xmax - grid.xmin)/grid.Nx;
grid.time = 0;
grid.dt = 0.1;
grid.t_max = 200;
grid.NT = ceil(grid.t_max/grid.dt);
grid.Output_interval = 100;
grid.moving_frame = 0;
%[DEFAULT] Dictates Solve type
% Options: "FDTD"; "Muscl";
grid.solve_type_field = "FDTD"; %"Muscl"; %"FDTD"; %"Muscl";
grid.laser_envelope_model = "false"; %"false"; %"true";
%[DEFAULT] Constants, updated in IC.m
grid.c = 1;
grid.mu_0 = 1;
grid.eps_0 = 1;
grid.iter = 1;
grid.m0 = 1;
grid.e0 = -1; %Electrons
%[DEFAULT] Grids, updated in IC.m
grid.dx = (grid.xmax - grid.xmin)/grid.Nx;
grid.time = 0;
grid.cfl = 0.45; %clf = udt/dx <= C_max
grid.dt = 0.98*grid.dx/grid.c;
grid.NT = ceil(grid.t_max/grid.dt);
%Restrict:
Nx = grid.Nx;
%Boundaries, B (subdomain):
grid.Bx_i_0 = 1;
grid.Bx_i_end = Nx;
grid.By_i_0 = 1;
grid.By_i_end = Nx-1;
grid.Bz_i_0 = 1;
grid.Bz_i_end = Nx-1;
%Boundaries, E (subdomain):
grid.Ex_i_0 = 1;
grid.Ex_i_end = Nx-1;
grid.Ey_i_0 = 2;
grid.Ey_i_end = Nx-1;
grid.Ez_i_0 = 2;
grid.Ez_i_end = Nx-1;
% If there are externally applied fields
grid.external_fields = "Specified";
%Build grids:
% 1: Bx, Ey, Ez, U.. J.. V..
% 1: Ex. By, Bz
grid.x1 = linspace(grid.xmin,grid.xmax,Nx);
grid.x2 = linspace(grid.xmin+grid.dx/2,grid.xmax-grid.dx/2,Nx-1);
%Main Grids
Nx = grid.Nx;
if grid.solve_type_field == "FDTD"
Ex = zeros(1,Nx-1);
Jx = zeros(1,Nx-1);
By = zeros(1,Nx-1);
Bz = zeros(1,Nx-1);
else
Ex = zeros(1,Nx);
Jx = zeros(1,Nx);
By = zeros(1,Nx);
Bz = zeros(1,Nx);
end
Ey = zeros(1,Nx);
Ez = zeros(1,Nx);
Jy = zeros(1,Nx);
Jz = zeros(1,Nx);
Bx = zeros(1,Nx);
Ux = zeros(1,Nx);
Uy = zeros(1,Nx);
Uz = zeros(1,Nx);
N = zeros(1,Nx);
Vx = zeros(1,Nx);
Vy = zeros(1,Nx);
Vz = zeros(1,Nx);
% WFA
% grid.problem_name = "WFA";
% grid.BC_cond = "Non_Periodic";
% grid.BC_type = "WFA";
% grid.WFA_type = 1;
% grid.IC_type = grid.BC_type;
% WFA2: Energy diagnostic
grid.problem_name = "WFA";
grid.BC_cond = "Non_Periodic";
grid.BC_type = "WFA";
grid.WFA_type = 2;
grid.IC_type = grid.BC_type;
%fluid diagnostic
% grid.problem_name = "Fluid Diagnostic";
% grid.BC_cond = "Non_Periodic";
% grid.BC_type = "fluid_only_diagnostic";
% grid.IC_type = grid.BC_type;
% BCs and ICs extensions
% grid.BC_cond = "Periodic";
% grid.BC_type = "Periodic";
% grid.IC_type = grid.BC_type;
% grid.problem_name = "Periodic_Photon";
% JE9: Cuttoff EC
%Turn on options: i.e. If there are externally applied fields, based on
%the name
% grid.problem_name = "JE9";
% grid.BC_cond = "Non_Periodic";
% grid.BC_type = "Tunneling through an electron-cyclotron cutoff layer";
% grid.IC_type = grid.BC_type;
% JE8: Cuttoff Plasma Wave beach
% grid.problem_name = "JE8";
% grid.BC_cond = "Non_Periodic";
% grid.BC_type = "Propagation into a plasma wave beach";
% grid.IC_type = grid.BC_type;
%Make the file/ delete if already exists:
grid.filename = "Output/out.txt";
if exist(grid.filename, 'file')==2
delete(grid.filename);
end
end