GeFiCa
Germanium detector Field Calculator
XYZ.cc
Go to the documentation of this file.
1 #include "XYZ.h"
2 #include "Units.h"
3 #include "SquarePointContact.h"
4 using namespace GeFiCa;
5 
6 void XYZ::SetupWith(Detector &detector)
7 {
8  Grid::SetupWith(detector); // check number of calls
9 
10  TString type(detector.ClassName());
11  if (type.Contains("SquarePointContact")) {
12  SquarePointContact& spc = (SquarePointContact&) detector;
13  spc.CheckConfigurations();
14  GetInfoFrom(spc);
15  } else {
16  Error("SetupWith", "%s is not expected.", type.Data());
17  Error("SetupWith", "Please use SquarePointContact detector.");
18  abort();
19  }
20 
21  fDetector = &detector; // for GetC to use fDetector->Bias[]
22 }
23 //_____________________________________________________________________________
24 //
25 void XYZ::OverRelaxAt(size_t idx)
26 {
27  if (fIsFixed[idx]) return; // no need to calculate on boundaries
28 
29  double dxp=dC1p[idx]!=0?dC1p[idx]:dC1m[idx];
30  double dxm=dC1m[idx]!=0?dC1m[idx]:dC1p[idx];
31  double dyp=dC2p[idx]!=0?dC2p[idx]:dC2m[idx];
32  double dym=dC2m[idx]!=0?dC2m[idx]:dC2p[idx];
33  double dzp=dC3p[idx]!=0?dC3p[idx]:dC3m[idx];
34  double dzm=dC3m[idx]!=0?dC3m[idx]:dC3p[idx];
35 
36  double vxp,vxm,vyp,vym,vzp,vzm;
37  if (idx<N1*N2) vzm=Vp[idx]; // bottom boundary
38  else vzm=Vp[idx-N1*N2];
39  if (idx>=N1*N2*N3-N1*N2) vzp=Vp[idx]; // top boundary
40  else vzp=Vp[idx+N1*N2];
41  if (idx%(N1*N2)>(N1*N2)-N1-1) vyp=Vp[idx]; // back boundary
42  else vyp=Vp[idx+N1];
43  if (idx%(N1*N2)<N1) vym=Vp[idx]; // front boundary
44  else vym=Vp[idx-N1];
45  if ((idx%(N1*N2))%N1==N1-1) vxp=Vp[idx]; // right boundary
46  else vxp=Vp[idx+1];
47  if ((idx%(N1*N2))%N1==0) vxm=Vp[idx]; // left boundary
48  else vxm=Vp[idx-1];
49 
50  // update potential
51  double vnew = ( Src[idx]/2 + (vxp/dxp+vxm/dxm)/(dxm+dxp)
52  + (vyp/dyp+vym/dym)/(dym+dyp) + (vzp/dzp+vzm/dzm)/(dzp+dzm) )
53  / ( (1/dxp+1/dxm)/(dxp+dxm)
54  + (1/dyp+1/dym)/(dyp+dym) + (1/dzp+1/dzm)/(dzp+dzm) );
55  vnew = RelaxationFactor*(vnew-Vp[idx])+Vp[idx]; // over relax
56 
57  // update Vp for impurity-only case even if the point is undepleted
58  if (fDetector->Bias[0]==fDetector->Bias[1]) { Vp[idx]=vnew; return; }
59 
60  //check depletion
61  fIsDepleted[idx]=false; // default
62  //find minimal potential in all neighboring points
63  double vmin=vxp; // minimal Vp around point[idx]
64  if (vmin>vxm)vmin=vxm;
65  if (vmin>vyp)vmin=vyp;
66  if (vmin>vym)vmin=vym;
67  if (vmin>vzp)vmin=vzp;
68  if (vmin>vzm)vmin=vzm;
69  //find maximal potential in all neighboring points
70  double vmax=vxp; // maximal Vp around point[idx]
71  if (vmax<vxm)vmax=vxm;
72  if (vmax<vyp)vmax=vyp;
73  if (vmax<vym)vmax=vym;
74  if (vmax<vzp)vmax=vzp;
75  if (vmax<vzm)vmax=vzm;
76  //if vnew is greater or smaller than max and min, set vnew to it.
77  if (vnew<vmin) Vp[idx]=vmin;
78  else if(vnew>vmax) Vp[idx]=vmax;
79  else { Vp[idx]=vnew; fIsDepleted[idx]=true; } // vmin<vnew<vmax
80 }
81 //______________________________________________________________________________
82 //
83 double XYZ::GetC()
84 {
85  //FIXME:function of integration need to be update for xyz
86  return -1;
87 
88  Grid::GetC(); // calculate field excluding undepleted region
89 
90  // calculate C based on CV^2/2 = epsilon int E^2 dx^3 / 2
92  double dV=spc.Bias[0]-spc.Bias[1]; if(dV<0)dV=-dV;
93  double SumofElectricField=0;
94  for(size_t i=0;i<GetN();i++) {
95  double e1=E1[i];
96  double e2=E2[i];
97  double dr=dC1p[i];
98  double dz=dC2p[i];
99  SumofElectricField+=(e1*e1+e2*e2)*C1[i]*dr*dz;
100  }
101  double c=SumofElectricField*2*3.14159*epsilon/dV/dV;
102  Info("GetC","%.2f pF",c/pF);
103  return c;
104 }
105 //_____________________________________________________________________________
106 //
108 {
109  double dx=spc.Width/(N1-1), dy=spc.Length/(N2-1), dz=spc.Height/(N3-1);
110 
111  for (size_t i=0; i<N3; i++) {
112  for (size_t j=0; j<N2; j++) {
113  for (size_t k=0; k<N1; k++) {
114  C1.push_back(k*dx); C2.push_back(j*dy); C3.push_back(i*dz);
115  dC1p.push_back(dx); dC1m.push_back(dx);
116  dC2p.push_back(dy); dC2m.push_back(dy);
117  dC3p.push_back(dz); dC3m.push_back(dz);
118  E1.push_back(0); E2.push_back(0); E3.push_back(0);
119  Et.push_back(0); Vp.push_back(0);
120  fIsFixed.push_back(false); fIsDepleted.push_back(false);
121  Src.push_back(-spc.GetImpurity(C3.back())*Qe/epsilon);
122 
123  if (k==0) { // left most surface
124  dC1m.back()=0; E2.back()=0; E3.back()=0; Vp.back()=spc.Bias[1];
125  fIsFixed.back()=true; fIsDepleted.back()=true;
126  }
127  if (k==N1-1) { // right most surface
128  dC1p.back()=0; E2.back()=0; E3.back()=0; Vp.back()=spc.Bias[1];
129  fIsFixed.back()=true; fIsDepleted.back()=true;
130  }
131  if (j==0) { // front most surface
132  dC2m.back()=0; E1.back()=0; E3.back()=0; Vp.back()=spc.Bias[1];
133  fIsFixed.back()=true; fIsDepleted.back()=true;
134  }
135  if (j==N2-1) { // back most surface
136  dC2p.back()=0; E1.back()=0; E3.back()=0; Vp.back()=spc.Bias[1];
137  fIsFixed.back()=true; fIsDepleted.back()=true;
138  }
139  if (i==0) { // top surface
140  dC3m.push_back(0);
141  // wrap around
142  if (C1.back()<=(spc.Width-spc.WrapAroundW)/2
143  || C1.back()>=(spc.Width+spc.WrapAroundW)/2) {
144  E1.back()=0; E2.back()=0; Vp.back()=spc.Bias[1];
145  fIsFixed.back()=true; fIsDepleted.back()=true;
146  }
147  if (C2.back()<=(spc.Length-spc.WrapAroundL)/2
148  || C2.back()>=(spc.Length+spc.WrapAroundL)/2) {
149  E1.back()=0; E2.back()=0; Vp.back()=spc.Bias[1];
150  fIsFixed.back()=true; fIsDepleted.back()=true;
151  }
152  // point contact
153  if (C3.back()<=spc.PointContactH
154  && C1.back()>=(spc.Width-spc.PointContactW)/2
155  && C1.back()<=(spc.Width+spc.PointContactW)/2
156  && C2.back()>=(spc.Length-spc.PointContactL)/2
157  && C2.back()<=(spc.Length+spc.PointContactL)/2) {
158  fIsFixed.back()=true; fIsDepleted.back()=true;
159  Vp.back()=spc.Bias[0];
160  }
161  }
162  if (i==N3-1) { // bottom electrode
163  dC3p.push_back(0);
164  E1.back()=0; E2.back()=0; Vp.back()=spc.Bias[1];
165  fIsFixed.back()=true; fIsDepleted.back()=true;
166  }
167  }
168  }
169  }
170 }
171 //___________________________________________________________________________
172 //
174 {
175  for (size_t idx=0; idx<GetN(); idx++) {
176  double dxm=dC1m[idx];
177  double dxp=dC1p[idx];
178  double dym=dC2m[idx];
179  double dyp=dC2p[idx];
180  double dzm=dC3m[idx];
181  double dzp=dC3p[idx];
182  double vym,vyp,vxm,vxp,vzp,vzm;
183  if (idx<N1*N2) vzm=Vp[idx];
184  else vzm=Vp[idx-N1*N2];
185  if (idx>=N1*N2*N3-N1*N2) vzp=Vp[idx];
186  else vzp=Vp[idx+N1*N2];
187  if (idx%(N1*N2)>(N1*N2)-N1-1) vyp=Vp[idx];
188  else vyp=Vp[idx+N1];
189  if (idx%(N1*N2)<N1) vym=Vp[idx];
190  else vym=Vp[idx-N1];
191  if ((idx%(N1*N2))%N1==N1-1) vxp=Vp[idx];
192  else vxp=Vp[idx+1];
193  if ((idx%(N1*N2))%N1==0) vxm=Vp[idx];
194  else vxm=Vp[idx-1];
195  E1[idx]=(vxp-vxm)/(dxm+dxp);
196  E2[idx]=(vyp-vym)/(dym+dyp);
197  E3[idx]=(vzp-vzm)/(dzm+dzp);
198 
199  Et[idx]=sqrt(E1[idx]*E1[idx]+E2[idx]*E2[idx]+E3[idx]*E3[idx]);
200  }
201 }
double PointContactH
Height of point contact.
std::vector< double > dC1m
step length to previous point alone C1
Definition: Grid.h:21
std::vector< double > E3
projection of Et on C3
Definition: Grid.h:19
std::vector< double > Bias
bias on electrodes
Definition: Detector.h:35
double Length
Length(y) of crystal.
double WrapAroundW
Inner width of outer contact.
std::vector< bool > fIsFixed
true if field values are fixed
Definition: Grid.h:129
std::vector< double > E1
projection of Et on C1
Definition: Grid.h:17
size_t N2
number of points along the 2nd coordinate
Definition: Grid.h:54
std::vector< double > dC3p
step length to next point alone C3
Definition: Grid.h:24
double GetC()
Definition: XYZ.cc:83
Configuration of squre point contact detectors.
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
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 Width
Width(x) of crystal.
static const double epsilon
permittivity of Ge [C/volt/cm]
Definition: Units.h:27
void CalculateE()
Calculate Et, E1, E2, E3 from Vp.
Definition: XYZ.cc:173
std::vector< bool > fIsDepleted
true if a grid point is depleted
Definition: Grid.h:130
void OverRelaxAt(size_t idx)
Over relax potential Vp[.
Definition: XYZ.cc:25
Detector * fDetector
! Pointer to associated detector object
Definition: Grid.h:132
double PointContactL
Length of point contact.
std::vector< double > dC2p
step length to next point along C2
Definition: Grid.h:22
A file defining commonly used units & constants.
size_t N3
number of points along the 3rd coordinate
Definition: Grid.h:55
static const double pF
pico farad
Definition: Units.h:22
void SetupWith(Detector &detector)
Fix potentials on boundaries based on.
Definition: XYZ.cc:6
double GetImpurity(double height)
Return net impurity concentration at.
Definition: Detector.h:20
double WrapAroundL
Inner length of outer contact.
void GetInfoFrom(SquarePointContact &detector)
Definition: XYZ.cc:107
double GetC()
Get detector capacitance.
Definition: Grid.cc:198
std::vector< double > Vp
potential at each point
Definition: Grid.h:15
static const double Qe
electron charge in Coulomb [C]
Definition: Units.h:24
std::vector< double > dC3m
step length to previous point alone C3
Definition: Grid.h:25
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
std::vector< double > C3
the 3rd coordinates of the points
Definition: Grid.h:14
double RelaxationFactor
within (0,2), used to speed up convergence
Definition: Grid.h:58
double PointContactW
Width of point contact.