-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pixel3D_SolvePoisson2D.m
191 lines (160 loc) · 7.32 KB
/
Pixel3D_SolvePoisson2D.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
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
190
191
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Solve Poisson equation to compute the potential %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PitchX = Pitch along X [um]
% PitchY = Pitch along Y [um]
% BiasV = Sensor backplane voltage [V] == 0 ? compute weighting field
% epsR = Relative permittivity
% rho = Charge density in the bulk [(Coulomb/um^3)]
function [pdem,Potential,DecomposedGeom] =...
Pixel3D_SolvePoisson2D(PitchX,PitchY,BiasV,epsR,rho)
TStart = cputime; % CPU time at start
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Variable initialization %
%%%%%%%%%%%%%%%%%%%%%%%%%%%
eps0 = 8.85e-18; % Vacuum permittivity [F/um]
MeshMax = 5; % Maximum mesh edge length [um]
Radius = 2.5; % Column radius [um]
NPixelsX = 5; % Number of pixels along X
NPixelsY = 5; % Number of pixels along Y
BiasW = 0; % Bias to compute weighting potential
if BiasV == 0
BiasW = 1;
end
%%%%%%%%%%%%%%%%%%%%
% Create PDE model %
%%%%%%%%%%%%%%%%%%%%
fprintf('@@@ I''m solving Poisson equation in 2D to calculate the potential @@@\n');
pdem = createpde('electromagnetic','electrostatic');
%%%%%%%%%%%%%%%%%%%%%%
% Create 2D geometry %
%%%%%%%%%%%%%%%%%%%%%%
% Whole volume
R1 = [ 3 4 -(PitchX*NPixelsX/2+PitchX/2) PitchX*NPixelsX/2+PitchX/2 PitchX*NPixelsX/2+PitchX/2 -(PitchX*NPixelsX/2+PitchX/2)...
PitchY*NPixelsY/2+PitchY/2 PitchY*NPixelsY/2+PitchY/2 -(PitchY*NPixelsY/2+PitchY/2) -(PitchY*NPixelsY/2+PitchY/2) ]';
%%%%%%%%%%%%%%%%%%%
% Junction colums %
%%%%%%%%%%%%%%%%%%%
Cs11 = [ 1 PitchX*0 PitchY*0 Radius 0 0 0 0 0 0 ]';
Cs12 = [ 1 PitchX*2 -PitchY*1 Radius 0 0 0 0 0 0 ]';
Cs13 = [ 1 PitchX*2 PitchY*0 Radius 0 0 0 0 0 0 ]';
Cs14 = [ 1 PitchX*2 PitchY*1 Radius 0 0 0 0 0 0 ]';
Cs15 = [ 1 PitchX*2 PitchY*2 Radius 0 0 0 0 0 0 ]';
Cs21 = [ 1 PitchX*1 -PitchY*2 Radius 0 0 0 0 0 0 ]';
Cs22 = [ 1 PitchX*1 -PitchY*1 Radius 0 0 0 0 0 0 ]';
Cs23 = [ 1 PitchX*1 PitchY*0 Radius 0 0 0 0 0 0 ]';
Cs24 = [ 1 PitchX*1 PitchY*1 Radius 0 0 0 0 0 0 ]';
Cs25 = [ 1 PitchX*1 PitchY*2 Radius 0 0 0 0 0 0 ]';
Cs31 = [ 1 PitchX*0 -PitchY*2 Radius 0 0 0 0 0 0 ]';
Cs32 = [ 1 PitchX*0 -PitchY*1 Radius 0 0 0 0 0 0 ]';
Cs33 = [ 1 PitchX*2 -PitchY*2 Radius 0 0 0 0 0 0 ]'; % Scambio con Cs11
Cs34 = [ 1 PitchX*0 PitchY*1 Radius 0 0 0 0 0 0 ]';
Cs35 = [ 1 PitchX*0 PitchY*2 Radius 0 0 0 0 0 0 ]';
Cs41 = [ 1 -PitchX*1 -PitchY*2 Radius 0 0 0 0 0 0 ]';
Cs42 = [ 1 -PitchX*1 -PitchY*1 Radius 0 0 0 0 0 0 ]';
Cs43 = [ 1 -PitchX*1 PitchY*0 Radius 0 0 0 0 0 0 ]';
Cs44 = [ 1 -PitchX*1 PitchY*1 Radius 0 0 0 0 0 0 ]';
Cs45 = [ 1 -PitchX*1 PitchY*2 Radius 0 0 0 0 0 0 ]';
Cs51 = [ 1 -PitchX*2 -PitchY*2 Radius 0 0 0 0 0 0 ]';
Cs52 = [ 1 -PitchX*2 -PitchY*1 Radius 0 0 0 0 0 0 ]';
Cs53 = [ 1 -PitchX*2 PitchY*0 Radius 0 0 0 0 0 0 ]';
Cs54 = [ 1 -PitchX*2 PitchY*1 Radius 0 0 0 0 0 0 ]';
Cs55 = [ 1 -PitchX*2 PitchY*2 Radius 0 0 0 0 0 0 ]';
%%%%%%%%%%%%%%%
% Bias colums %
%%%%%%%%%%%%%%%
Cb11 = [ 1 PitchX*2+PitchX/2 -PitchY*2+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb12 = [ 1 PitchX*2+PitchX/2 -PitchY*1+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb13 = [ 1 PitchX*2+PitchX/2 PitchY*0+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb14 = [ 1 PitchX*2+PitchX/2 PitchY*1+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb15 = [ 1 PitchX*2+PitchX/2 PitchY*2+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb21 = [ 1 PitchX*1+PitchX/2 -PitchY*2+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb22 = [ 1 PitchX*1+PitchX/2 -PitchY*1+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb23 = [ 1 PitchX*1+PitchX/2 PitchY*0+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb24 = [ 1 PitchX*1+PitchX/2 PitchY*1+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb25 = [ 1 PitchX*1+PitchX/2 PitchY*2+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb31 = [ 1 PitchX*0+PitchX/2 -PitchY*2+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb32 = [ 1 PitchX*0+PitchX/2 -PitchY*1+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb33 = [ 1 PitchX*0+PitchX/2 PitchY*0+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb34 = [ 1 PitchX*0+PitchX/2 PitchY*1+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb35 = [ 1 PitchX*0+PitchX/2 PitchY*2+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb41 = [ 1 -PitchX*1+PitchX/2 -PitchY*2+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb42 = [ 1 -PitchX*1+PitchX/2 -PitchY*1+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb43 = [ 1 -PitchX*1+PitchX/2 PitchY*0+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb44 = [ 1 -PitchX*1+PitchX/2 PitchY*1+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb45 = [ 1 -PitchX*1+PitchX/2 PitchY*2+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb51 = [ 1 -PitchX*2+PitchX/2 -PitchY*2+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb52 = [ 1 -PitchX*2+PitchX/2 -PitchY*1+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb53 = [ 1 -PitchX*2+PitchX/2 PitchY*0+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb54 = [ 1 -PitchX*2+PitchX/2 PitchY*1+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb55 = [ 1 -PitchX*2+PitchX/2 PitchY*2+PitchY/2 Radius 0 0 0 0 0 0 ]';
%%%%%%%%%%%%%%%%%%%%%
% Extra bias colums %
%%%%%%%%%%%%%%%%%%%%%
Cb61 = [ 1 -PitchX*3+PitchX/2 -PitchY*2+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb62 = [ 1 -PitchX*3+PitchX/2 -PitchY*1+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb63 = [ 1 -PitchX*3+PitchX/2 PitchY*0+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb64 = [ 1 -PitchX*3+PitchX/2 PitchY*1+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb65 = [ 1 -PitchX*3+PitchX/2 PitchY*2+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb16 = [ 1 PitchX*2+PitchX/2 -PitchY*3+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb26 = [ 1 PitchX*1+PitchX/2 -PitchY*3+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb36 = [ 1 PitchX*0+PitchX/2 -PitchY*3+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb46 = [ 1 -PitchX*1+PitchX/2 -PitchY*3+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb56 = [ 1 -PitchX*2+PitchX/2 -PitchY*3+PitchY/2 Radius 0 0 0 0 0 0 ]';
Cb66 = [ 1 -PitchX*3+PitchX/2 -PitchY*3+PitchY/2 Radius 0 0 0 0 0 0 ]';
gd = [R1,...
Cs11,Cs12,Cs13,Cs14,Cs15,...
Cs21,Cs22,Cs23,Cs24,Cs25,...
Cs31,Cs32,Cs33,Cs34,Cs35,...
Cs41,Cs42,Cs43,Cs44,Cs45,...
Cs51,Cs52,Cs53,Cs54,Cs55,...
Cb11,Cb12,Cb13,Cb14,Cb15,...
Cb21,Cb22,Cb23,Cb24,Cb25,...
Cb31,Cb32,Cb33,Cb34,Cb35,...
Cb41,Cb42,Cb43,Cb44,Cb45,...
Cb51,Cb52,Cb53,Cb54,Cb55,...
Cb61,Cb62,Cb63,Cb64,Cb65,...
Cb16,Cb26,Cb36,Cb46,Cb56,...
Cb66];
sf = 'R1-(';
ns = char('R1 ');
for i = 1:NPixelsX
for j = 1:NPixelsY
sf = strcat(sf,sprintf('Cs%d%d+',i,j));
ns = [ns; sprintf('Cs%d%d',i,j)];
end
end
for i = 1:NPixelsX+1
for j = 1:NPixelsY+1
sf = strcat(sf,sprintf('Cb%d%d+',i,j));
ns = [ns; sprintf('Cb%d%d',i,j)];
end
end
sf = strcat(sf(1:end-1),')');
ns = ns';
DecomposedGeom = decsg(gd,sf,ns);
geometryFromEdges(pdem,DecomposedGeom);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Apply boundary conditions (only on conductors) %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Boundary of the domain
electromagneticBC(pdem,'SurfaceCurrentDensity',0,'edge',1:4);
% Central pixel signal columns
electromagneticBC(pdem,'Voltage',BiasW,'edge',5:8);
% Other pixels signal columns
electromagneticBC(pdem,'Voltage',0,'edge',9:12 + 4*(NPixelsX*NPixelsY-2));
% All pixels bias columns
electromagneticBC(pdem,'Voltage',BiasV,'edge',13 + 4*(NPixelsX*NPixelsY-2):pdem.Geometry.NumEdges);
%%%%%%%%%%%%%%%%%
% Generate mesh %
%%%%%%%%%%%%%%%%%
msh = generateMesh(pdem,'Hmax',MeshMax,'GeometricOrder','quadratic');
%%%%%%%%%%%%%%%%%%%%%%%%%%
% Solve Poisson equation %
%%%%%%%%%%%%%%%%%%%%%%%%%%
pdem.VacuumPermittivity = eps0;
electromagneticSource(pdem,'face',1,'ChargeDensity',rho);
electromagneticProperties(pdem,'RelativePermittivity',epsR,'face',1);
Potential = solve(pdem);
fprintf('CPU time --> %.2f [min]\n\n',(cputime-TStart)/60);
end