GeFiCa
Germanium detector Field Calculator
RhoZ.cc
Go to the documentation of this file.
1 #include "RhoZ.h"
2 #include "Units.h"
3 #include "PointContact.h"
4 #include "Segmented.h"
5 using namespace GeFiCa;
6 
7 void RhoZ::SetupWith(Detector &detector)
8 {
9  Grid::SetupWith(detector); // check number of calls
10 
11  TString type(detector.ClassName());
12  if (type.Contains("PointContact")) {
13  if (N1%2==1) { // we want no grid point right on z-axis
14  Error("SetupWith",
15  "Please assign even number of grid points along radius.");
16  abort();
17  }
18  PointContact& pc = (PointContact&) detector;
20  GetInfoFrom(pc);
21  }
22  else if (type.Contains("Segmented"))
23  {
24  if (N1%2==1) { // we want no grid point right on z-axis
25  Error("SetupWith",
26  "Please assign even number of grid points along radius.");
27  abort();
28  }
29  Segmented & se = (Segmented &) detector;
31  GetInfoFrom(se);
32 
33  }
34  else {
35  Error("SetupWith", "%s is not expected.", type.Data());
36  Error("SetupWith", "Please use "
37  "PointContact or Segmented detector.");
38  abort();
39  }
40 
41  fDetector = &detector; // for GetC to use fDetector->Bias[]
42 }
43 //______________________________________________________________________________
44 //
45 void RhoZ::OverRelaxAt(size_t idx)
46 {
47  if (fIsFixed[idx]) return; // no need to calculate on boundaries
48 
49  // setup potential differences
50  double drm=dC1m[idx]!=0?dC1m[idx]:dC1p[idx]; // dr_minus
51  double drp=dC1p[idx]!=0?dC1p[idx]:dC1m[idx];
52  double dzm=dC2m[idx]!=0?dC2m[idx]:dC2p[idx];
53  double dzp=dC2p[idx]!=0?dC2p[idx]:dC2m[idx]; // dz_plus
54 
55  // setup potential for boundary points
56  double vzm,vzp,vrm,vrp; // vzm: v_z_minus
57  if (idx>=N1) vzm=Vp[idx-N1];
58  else vzm=Vp[idx+N1]; // mirroring potential for bottom boundary points
59  if (idx>=N1*N2-N1) vzp=Vp[idx]; // set potential for top boundary points
60  else vzp=Vp[idx+N1];
61  if (idx%N1==0) vrm=Vp[idx]; // set potential for left boundary points
62  else vrm=Vp[idx-1];
63  if (idx%N1==N1-1) vrp=Vp[idx]; // set potential for right boundary points
64  else vrp=Vp[idx+1];
65 
66  // update potential
67  double vnew = (Src[idx]/2 + 0.5/C1[idx]*(vrp-vrm)/(drm+drp)
68  + (vrp/drp+vrm/drm)/(drm+drp) + (vzp/dzp+vzm/dzm)/(dzp+dzm))
69  /((1/drm+1/drp)/(drm+drp) + (1/dzp+1/dzm)/(dzp+dzm));
70  vnew = RelaxationFactor*(vnew-Vp[idx])+Vp[idx]; // over relax
71 
72  // update Vp for impurity-only case even if the point is undepleted
73  if (fDetector->Bias[0]==fDetector->Bias[1]) { Vp[idx]=vnew; return; }
74 
75  // check depletion
76  fIsDepleted[idx]=false; // default
77  //find minimal potential in all neighboring points
78  double vmin=vrm; // minimal Vp around point[idx]
79  if (vmin>vrp) vmin=vrp;
80  if (vmin>vzp) vmin=vzp;
81  if (vmin>vzm) vmin=vzm;
82  //find maximal potential in all neighboring points
83  double vmax=vrm; // maximal Vp around point[idx]
84  if (vmax<vrp) vmax=vrp;
85  if (vmax<vzp) vmax=vzp;
86  if (vmax<vzm) vmax=vzm;
87  //if vnew is greater or smaller than vmax and vmin, set vnew to it.
88  if (vnew<vmin) Vp[idx]=vmin;
89  else if(vnew>vmax) Vp[idx]=vmax;
90  else { Vp[idx]=vnew; fIsDepleted[idx]=true; } // vmin<vnew<vmax
91 }
92 //______________________________________________________________________________
93 //
94 double RhoZ::GetC()
95 {
96  Grid::GetC(); // calculate field excluding undepleted region
97 
98  // calculate C based on CV^2/2 = epsilon int E^2 dx^3 / 2
100  double dV=pc.Bias[0]-pc.Bias[1]; if(dV<0)dV=-dV;
101  double SumofElectricField=0;
102  for(size_t i=0;i<GetN();i++) {
103  double e1=E1[i];
104  double e2=E2[i];
105  double dr=dC1p[i];
106  double dz=dC2p[i];
107  SumofElectricField+=(e1*e1+e2*e2)*C1[i]*dr*dz;
108  }
109  double c=SumofElectricField*2*3.14159*epsilon/dV/dV;
110  Info("GetC","%.2f pF",c/pF);
111  return c;
112 }
113 //______________________________________________________________________________
114 //
116 {
117  // set positions of grid points
118  for (size_t i=0; i<N1; i++) { // bottom line
119  dC1p.push_back(2*pc.Radius/(N1-1)); dC1m.push_back(2*pc.Radius/(N1-1));
120  dC2p.push_back(pc.Height/(N2-1));
121  dC2m.push_back(pc.Height/(N2-1)); // there are mirrored points below
122  C1.push_back(-pc.Radius+i*dC1p[i]); C2.push_back(0);
123  E1.push_back(0); E2.push_back(0); Et.push_back(0); Vp.push_back(0);
124  fIsFixed.push_back(false); fIsDepleted.push_back(false);
125  Src.push_back(-pc.GetImpurity(C2[i])*Qe/epsilon);
126  }
127  for (size_t i=N1; i<N1*N2; i++) { // the rest
128  dC1p.push_back(2*pc.Radius/(N1-1)); dC1m.push_back(2*pc.Radius/(N1-1));
129  dC2p.push_back(pc.Height/(N2-1)); dC2m.push_back(pc.Height/(N2-1));
130  C1.push_back(C1[i-N1]); C2.push_back(C2[i-N1]+dC2p[i-N1]);
131  E1.push_back(0); E2.push_back(0); Et.push_back(0); Vp.push_back(0);
132  fIsFixed.push_back(false); fIsDepleted.push_back(false);
133  Src.push_back(-pc.GetImpurity(C2[i])*Qe/epsilon);
134  }
135  // set impurity in groove and potentials of grid points
136  size_t npc=0; // number of grid points in PC
137  for (size_t i=N1*N2; i-->0;) {
138  if (C1[i]>=-pc.PointContactR && C1[i]<=pc.PointContactR
139  && C2[i]<=pc.PointContactH) { // point contact
140  Vp[i]=pc.Bias[0]; fIsFixed[i]=true; npc++;
141  } else if (C1[i]<=pc.BoreR && C1[i]>=-pc.BoreR
142  && C2[i]>=pc.Height-pc.BoreH) { // bore hole
143  Vp[i]=pc.Bias[1]; fIsFixed[i]=true;
144  } else if (((C1[i]>pc.WrapAroundR-pc.GrooveW && C1[i]<pc.WrapAroundR)
145  || (C1[i]>-pc.WrapAroundR && C1[i]<-pc.WrapAroundR+pc.GrooveW))
146  && C2[i]<pc.GrooveH) { // groove
147  Vp[i]=pc.Bias[1]/4; Src[i]=0;
148  } else // bulk
149  Vp[i]=(pc.Bias[0]+pc.Bias[1])/2;
150  double slope, intercept;
151  if (pc.CornerW>0) { // has top taper
152  slope=-pc.CornerH/pc.CornerW;
153  intercept=pc.Height-slope*(pc.Radius-pc.CornerW);
154  if (C2[i]>-slope*C1[i]+intercept||C2[i]>slope*C1[i]+intercept) {
155  Vp[i]=pc.Bias[1]; fIsFixed[i]=true;
156  }
157  }
158  if (pc.TaperW>0) { // has bottom taper
159  slope=pc.TaperH/(pc.TaperW);
160  intercept=-(pc.Radius-pc.TaperW)*slope;
161  if (C2[i]<=C1[i]*slope+intercept || C2[i]<=-C1[i]*slope+intercept) {
162  Vp[i]=pc.Bias[1]; fIsFixed[i]=true;
163  }
164  }
165  if (pc.BoreTaperW>0) { // has bore taper
166  slope=pc.BoreTaperH/pc.BoreTaperW;
167  intercept=pc.Height-slope*(pc.BoreR+pc.BoreTaperW);
168  if ((C2[i]>-slope*C1[i]+intercept && C1[i]<=-pc.BoreR) ||
169  (C2[i]>slope*C1[i]+intercept && C1[i]>=pc.BoreR)) {
170  Vp[i]=pc.Bias[1]; fIsFixed[i]=true;
171  }
172  }
173  }
174  if (npc<1) { Error("GetInfoFrom", "no point in point contact!"); abort(); }
175  for (size_t i=N1*N2-1; i>=N1*N2-N1; i--) { // top boundary
176  Vp[i]=pc.Bias[1]; fIsFixed[i]=true; dC2p[i]=0;
177  }
178  for (size_t i=0; i<=N1*N2-N1; i=i+N1) { // left & right boundaries
179  Vp[i]=pc.Bias[1]; Vp[i+N1-1]=pc.Bias[1];
180  fIsFixed[i]=true; fIsFixed[i+N1-1]=true;
181  dC1m[i]=0; dC1p[i+N1-1]=0;
182  }
183  for (size_t i=0; i<N1; i++) { // bottom boundary
184  dC2m[i]=0;
185  if (C1[i]>=pc.WrapAroundR||C1[i]<=-pc.WrapAroundR) {// wrap arround
186  fIsFixed[i]=true;
187  Vp[i]=pc.Bias[1];
188  }
189  }
190 
192 }
193 //______________________________________________________________________________
194 //
196 {
197  double slope, intercept;
198  for (size_t i=0; i<GetN(); i++) {
199  if (C2[i]-pc.PointContactH<dC2m[i] && C2[i]>pc.PointContactH
200  && C1[i]<(pc.PointContactR+1e-4*mm) && C1[i]>-(pc.PointContactR+1e-4*mm)) {
201  dC2m[i]=C2[i]-pc.PointContactH; // top of point contact
202  // since C2[i] is too close to boundary, we regard it as on the boundary
203  // Fixme: same protection should be applied to other boundaries
204  if (dC2m[i]<1e-4*mm) { Vp[i]=pc.Bias[0]; fIsFixed[i]=true; }
205  }
206  if (C1[i]-pc.PointContactR<dC1m[i]&&C1[i]>pc.PointContactR
207  &&C2[i]<pc.PointContactH+1e-4*mm) {
208  dC1m[i]=C1[i]-pc.PointContactR; // right of point contact
209  if (dC1m[i]<1e-4*mm) { Vp[i]=pc.Bias[0]; fIsFixed[i]=true; }
210  }
211  if (-C1[i]-pc.PointContactR<dC1p[i]&&C1[i]<-pc.PointContactR
212  &&C2[i]<pc.PointContactH+1e-4*mm) {
213  dC1p[i]=-C1[i]-pc.PointContactR; // left of point contact
214  if (dC1p[i]<1e-4*mm) { Vp[i]=pc.Bias[0]; fIsFixed[i]=true; }
215  }
216  if (C1[i]-pc.BoreR>0&&C1[i]-pc.BoreR<dC1m[i]
217  &&C2[i]>pc.Height-pc.BoreH-1e-4*mm){ //right side of bore
218  dC1m[i]=C1[i]-pc.BoreR;
219  if (dC1m[i]<1e-4*mm) { Vp[i]=pc.Bias[0]; fIsFixed[i]=true; }
220  }
221  if (-C1[i]-pc.BoreR>0&&-C1[i]-pc.BoreR<dC1p[i]
222  &&C2[i]>=pc.Height-pc.BoreH-1e-4*mm){ //left side of bore
223  dC1p[i]=-C1[i]-pc.BoreR;
224  if (dC1p[i]<1e-4*mm) { Vp[i]=pc.Bias[0]; fIsFixed[i]=true; }
225  }
226  //down side of bore
227  if (pc.Height-pc.BoreH-1e-4*mm-C2[i]>0 && pc.Height-pc.BoreH-C2[i]<dC2p[i]
228  && C1[i]>-pc.BoreR-1e-4*mm && C1[i]<pc.BoreR+1e-4*mm) {
229  dC2p[i]=pc.Height-pc.BoreH-C2[i];
230  if (dC2p[i]<1e-4*mm) { Vp[i]=pc.Bias[1]; fIsFixed[i]=true; }
231  }
232  // Fixme: V around groove bounaries are all changable,
233  // which should be reallocated?
234  if (pc.WrapAroundR-C1[i]<dC1p[i]&&C1[i]<pc.WrapAroundR&&i<N1)
235  dC1p[i]=pc.WrapAroundR-C1[i];
236  if (pc.WrapAroundR+C1[i]<dC1p[i]&&C1[i]>-pc.WrapAroundR&&i<N1)
237  dC1m[i]=pc.WrapAroundR+C1[i];
238  if (pc.CornerW>0) { // has top taper
239  slope=-pc.CornerH/pc.CornerW;
240  intercept=pc.Height-slope*(pc.Radius-pc.CornerW);
241  if (C1[i]+C2[i]/slope-intercept/slope>0 &&
242  C1[i]+C2[i]/slope-intercept/slope<dC1m[i] &&
243  C2[i]>pc.Height-pc.CornerH) // left
244  dC1m[i]=C1[i]+C2[i]/slope-intercept/slope;
245  if (-C1[i]+C2[i]/slope-intercept/slope>0 &&
246  -C1[i]+C2[i]/slope-intercept/slope<dC1p[i] &&
247  C2[i]>pc.Height-pc.CornerH) // right
248  dC1p[i]=-C1[i]+C2[i]/slope-intercept/slope;
249  if((C1[i]*slope+intercept)-C2[i]<dC2p[i] &&
250  C1[i]>pc.Radius-pc.CornerW&&(C1[i]*slope+intercept)-C2[i]>0)
251  dC2p[i]=(C1[i]*slope+intercept)-C2[i];
252  if((-C1[i]*slope+intercept)-C2[i]<dC2p[i] &&
253  C1[i]<-pc.Radius+pc.CornerW&&(-C1[i]*slope+intercept)-C2[i]>0)
254  dC2p[i]=(-C1[i]*slope+intercept)-C2[i];
255  }
256  if (pc.TaperW>0) { // has bottom taper
257  slope=pc.TaperH/pc.TaperW;
258  intercept=-(pc.Radius-pc.TaperW)*slope;
259  if (C2[i]-(slope*C1[i]+intercept)<dC2m[i]
260  && C2[i]-(slope*C1[i]+intercept)>0 && i>=N1-1) // right side, C2
261  dC2m[i]=C2[i]-(slope*C1[i]+intercept );
262  if ((C2[i]-intercept)/slope-C1[i]<dC1p[i]
263  && (C2[i]-intercept)/slope-C1[i]>0) // right side, C1
264  dC1p[i]=(C2[i]-intercept)/slope-C1[i];
265  if (C2[i]-(-slope*C1[i]+intercept)<dC2m[i]
266  && C2[i]-(-slope*C1[i]+intercept)>0 && i>=N1-1) // left side, C2
267  dC2m[i]=C2[i]-(-slope*C1[i]+intercept);
268  if (C1[i]+(C2[i]-intercept)/slope<dC1m[i]
269  && C1[i]+(C2[i]-intercept)/slope>0) // left side, C1
270  dC1m[i]=C1[i]+(C2[i]-intercept)/slope;
271  }
272  if (pc.BoreTaperW>0) { // has bore taper
273  slope=pc.BoreTaperH/pc.BoreTaperW;
274  intercept=pc.Height-slope*(pc.BoreR+pc.BoreTaperW);
275  if (C1[i]-C2[i]/slope+intercept/slope<dC1m[i] &&
276  C2[i]>pc.Height-pc.BoreTaperH &&
277  C1[i]-C2[i]/slope+intercept/slope>0) //right side of hole taper
278  dC1m[i]=C1[i]-C2[i]/slope+intercept/slope;
279  if (-C1[i]-C2[i]/slope+intercept/slope>0 &&
280  -C1[i]-C2[i]/slope+intercept/slope<dC1p[i] &&
281  C2[i]>pc.Height-pc.BoreTaperH) //left side of hole taper
282  dC1p[i]=-C1[i]-C2[i]/slope+intercept/slope;
283  if((C1[i]*slope+intercept)-C2[i]<dC2p[i] &&
284  C1[i]<pc.BoreR+pc.BoreTaperW && C1[i]>pc.BoreR
285  && (C1[i]*slope+intercept)-C2[i]>0) // right side of hole taper
286  dC2p[i]=(C1[i]*slope+intercept)-C2[i];
287  if((-C1[i]*slope+intercept)-C2[i]<dC2p[i] &&
288  C1[i]>-pc.BoreR-pc.BoreTaperW && C1[i]<-pc.BoreR
289  && (-C1[i]*slope+intercept)-C2[i]>0) // left side of hole taper
290  dC2p[i]=(-C1[i]*slope+intercept)-C2[i];
291  }
292  }
293 }
294 //______________________________________________________________________________
295 //
297 {
298  Grid::CalculateE(); // deal with E1
299  for (size_t i=0; i<GetN(); i++) { // deal with E2
300  if (i<N1) E2[i]=-(Vp[i+N1]-Vp[i])/dC2p[i]; // lower boundary
301  else if (i>GetN()-N1) E2[i]=-(Vp[i]-Vp[i-N1])/dC2m[i]; // upper boundary
302  else E2[i]=-(Vp[i+N1]-Vp[i-N1])/(dC2p[i]+dC2m[i]); // the rest
303  if (i%N1==0) E1[i]=-(Vp[i+1]-Vp[i])/dC1p[i]; // left boundary
304  if ((i+1)%N1==0) E1[i]=-(Vp[i]-Vp[i-1])/dC1m[i]; // right boundary
305  Et[i]=sqrt(E1[i]*E1[i]+E2[i]*E2[i]);
306  }
307 }
std::vector< double > dC1m
step length to previous point alone C1
Definition: Grid.h:21
std::vector< double > Bias
bias on electrodes
Definition: Detector.h:35
Configuration of point contact detectors.
Definition: PointContact.h:9
double GrooveH
Height of Groove.
Definition: PointContact.h:30
double BoreH
Depth of bore hole.
Definition: PointContact.h:17
std::vector< bool > fIsFixed
true if field values are fixed
Definition: Grid.h:129
double Radius
Radius of crystal.
Definition: PointContact.h:12
double CornerH
Height of taper (bore side)
Definition: PointContact.h:26
double GetC()
Definition: RhoZ.cc:94
std::vector< double > E1
projection of Et on C1
Definition: Grid.h:17
double CornerW
Width of taper (bore side)
Definition: PointContact.h:25
size_t N2
number of points along the 2nd coordinate
Definition: Grid.h:54
double BoreTaperW
width of bore hole taper
Definition: PointContact.h:19
double WrapAroundR
Inner radius of outer contact.
Definition: PointContact.h:28
std::vector< double > Src
-(net impurity concentration)x|Qe|/epsilon
Definition: Grid.h:56
size_t N1
number of points along the 1st coordinate
Definition: Grid.h:53
std::vector< double > C2
the 2nd coordinates of the points
Definition: Grid.h:13
virtual void SetupWith(Detector &detector)
Fix potentials on boundaries based on.
Definition: Grid.cc:111
void CalculateE()
Calculate Et, E1, E2, E3 from Vp.
Definition: RhoZ.cc:296
double PointContactH
Height of point contact.
Definition: PointContact.h:15
Configuration of segmented true coaxial detectors.
Definition: Segmented.h:11
Detector & crystal properties.
Definition: Detector.h:32
std::vector< double > dC1p
step length to next point alone C1
Definition: Grid.h:20
size_t GetN()
total number of points
Definition: Grid.h:26
double Height
height of crystal
Definition: Detector.h:13
std::vector< double > dC2m
step length to previous point along C2
Definition: Grid.h:23
double GrooveW
Width of Groove.
Definition: PointContact.h:29
static const double epsilon
permittivity of Ge [C/volt/cm]
Definition: Units.h:27
void OverRelaxAt(size_t idx)
Over relax potential Vp[.
Definition: RhoZ.cc:45
static const double mm
minimeter
Definition: Units.h:15
std::vector< bool > fIsDepleted
true if a grid point is depleted
Definition: Grid.h:130
Detector * fDetector
! Pointer to associated detector object
Definition: Grid.h:132
std::vector< double > dC2p
step length to next point along C2
Definition: Grid.h:22
void ReallocateGridPointsNearBoundaries(PointContact &detector)
Definition: RhoZ.cc:195
A file defining commonly used units & constants.
static const double pF
pico farad
Definition: Units.h:22
double BoreTaperH
height of bore hole taper
Definition: PointContact.h:20
double GetImpurity(double height)
Return net impurity concentration at.
Definition: Detector.h:20
void GetInfoFrom(Segmented &detector)
Definition: RhoZ.h:18
double BoreR
radius of bore hole
Definition: PointContact.h:18
virtual void CalculateE()
Calculate Et, E1, E2, E3 from Vp.
Definition: Grid.cc:551
double GetC()
Get detector capacitance.
Definition: Grid.cc:198
double PointContactR
Radius of point contact.
Definition: PointContact.h:14
void CheckConfigurations()
Definition: Segmented.cc:11
std::vector< double > Vp
potential at each point
Definition: Grid.h:15
double TaperH
Height of taper (point contact side)
Definition: PointContact.h:23
double TaperW
Width of taper (point contact side)
Definition: PointContact.h:22
static const double Qe
electron charge in Coulomb [C]
Definition: Units.h:24
void SetupWith(Detector &detector)
Fix potentials on boundaries based on.
Definition: RhoZ.cc:7
The only namespace in GeFiCa.
Definition: Detector.h:6
std::vector< double > Et
total electric field strength
Definition: Grid.h:16
std::vector< double > E2
projection of Et on C2
Definition: Grid.h:18
std::vector< double > C1
the 1st coordinates of the points
Definition: Grid.h:12
double RelaxationFactor
within (0,2), used to speed up convergence
Definition: Grid.h:58