Memosa-FVM  0.2
TrapBandTunnelingDiscretization.h
Go to the documentation of this file.
1 // This file os part of FVM
2 // Copyright (c) 2012 FVM Authors
3 // See LICENSE file for terms.
4 
5 #ifndef _TRAPBANDTUNNELINGDISCRETIZATION_H_
6 #define _TRAPBANDTUNNELINGDISCRETIZATION_H_
7 
8 #include "PhysicsConstant.h"
9 #include "ElectricBC.h"
10 #include "Field.h"
11 #include "MultiField.h"
12 #include "MultiFieldMatrix.h"
13 #include "Mesh.h"
14 #include "Discretization.h"
15 #include "StorageSite.h"
16 #include "DiagonalMatrix.h"
17 #include "CRMatrix.h"
19 
20 template <class X, class Diag, class OffDiag>
22 {
23  public:
27  typedef typename CCMatrix::DiagArray DiagArray;
29  typedef Array<X> XArray;
31 
33  const GeomFields& geomFields,
34  const Field& varField,
35  const Field& electricField,
36  const Field& conductionbandField,
37  const ElectricModelConstants<T_Scalar>& constants):
38  Discretization(meshes),
39  _geomFields(geomFields),
40  _varField(varField),
41  _electricField(electricField),
42  _conductionbandField(conductionbandField),
43  _constants(constants)
44  {}
45 
46  void discretize(const Mesh& mesh, MultiFieldMatrix& mfmatrix,
47  MultiField& xField, MultiField& rField)
48  {
49  const StorageSite& cells = mesh.getCells();
50  const int nCells = cells.getSelfCount();
51 
52  const TArray& conduction_band = dynamic_cast<const TArray&> (_conductionbandField[cells]);
53 
54  const VectorT3Array& electric_field = dynamic_cast<const VectorT3Array&> (_electricField[cells]);
55 
56  const VectorT3Array& cellCentroid =
57  dynamic_cast<const VectorT3Array& > (_geomFields.coordinate[cells]);
58 
59  const MultiField::ArrayIndex cVarIndex(&_varField,&cells);
60 
61  CCMatrix& matrix = dynamic_cast<CCMatrix&>(mfmatrix.getMatrix(cVarIndex,cVarIndex));
62 
63  const XArray& xCell = dynamic_cast<const XArray&>(_varField[cells]);
64 
65  XArray& rCell = dynamic_cast<XArray&>(rField[cVarIndex]);
66 
67  DiagArray& diag = matrix.getDiag();
68 
69  const TArray& cellVolume =
70  dynamic_cast<const TArray&>(_geomFields.volume[cells]);
71 
72  const CRConnectivity& cellCells = mesh.getCellCells();
73 
74  TArray* ts = (new TArray(cells.getCount()));
75  *ts = 0;
76  TArray& transmission = *ts;
77 
78  const T_Scalar electron_capture_cross = _constants["electron_capture_cross"];
79  const T_Scalar electron_effmass = _constants["electron_effmass"];
80  const int normal = _constants["normal_direction"];
81  const int nTrap = _constants["nTrap"];
82  vector<T_Scalar> electron_trapdepth = _constants.electron_trapdepth;
83  //const T_Scalar epsilon = 1e-18;
84 
85  const int nMax = 200;
86 
87  T_Scalar transmissionHigh(0), transmissionLow(0);
88 
89  int idHigh, idLow, high, low, me, count;
90 
91  bool foundHigh, foundLow, flag;
92 
93  idHigh = idLow = 0;
94 
95  foundHigh = foundLow = false;
96 
97  for(int c=0; c<cells.getCount(); c++){
98  transmission[c] = 0.0;
99  }
100 
101  for(int c=0; c<nCells; c++){
102 
103  for(int i=0; i<nTrap; i++){
104 
105  T_Scalar en = conduction_band[c] - electron_trapdepth[i];
106 
107  transmission[c] = 1.0;
108 
109  //-------------------------------------------------------------------------//
110 
111  high = low = me = c;
112 
113  flag = false; //hit the boundary or not?
114 
115  count = 0;
116 
117  while(flag == false && count < nMax ){
118 
119  const int nbc = cellCells.getCount(me);
120 
121  T_Scalar drmin = 0.0;
122 
123  int neighborUp = 0;
124 
125  for(int nc = 0; nc < nbc; nc++){
126 
127  const int neighbor = cellCells(me, nc);
128  const T_Scalar dr = cellCentroid[me][normal] - cellCentroid[neighbor][normal];
129  if (dr < drmin){
130  drmin = dr;
131  neighborUp = neighbor;
132  }
133  }
134  if (neighborUp < nCells) {
135  high = neighborUp;
136  low = me;
137  me = high;
138  }
139  else flag = true;
140 
141  T_Scalar dX = cellCentroid[me][normal] - cellCentroid[low][normal];
142  T_Scalar factor = -2.0/HBAR_SI * sqrt(2.0*electron_effmass*ME*QE);
143  T_Scalar valueMe = PositiveValueOf( conduction_band[me] - en);
144  T_Scalar valueLow = PositiveValueOf( conduction_band[low] - en);
145  T_Scalar avg = (valueMe + valueLow) / 2.0;
146  T_Scalar exponent = factor * sqrt(avg) * fabs(dX);
147 
148  transmission[me] = transmission[low] * exp(exponent);
149 
150  if (en - conduction_band[me] >0 ){
151 
152  foundHigh = true;
153  idHigh = me;
154  transmissionHigh = transmission[me];
155  // cout << "found high " << c <<" " << me << " " << transmissionHigh << endl;
156  break;
157 
158  }
159  count ++;
160  }
161 
162 #if 0
163  //-------------------------------------------------------------------------//
164 
165  high = low = me = c;
166 
167  flag = false;
168 
169  count = 0;
170 
171  while(flag == false && count < nMax){
172 
173  const int nbc = cellCells.getCount(me);
174 
175  T_Scalar drmin = 0.0;
176 
177  int neighborUp = 0;
178 
179  for(int nc = 0; nc < nbc; nc++){
180  const int neighbor = cellCells(me, nc);
181  const T_Scalar dr = cellCentroid[me][normal] - cellCentroid[neighbor][normal];
182  if (dr > drmin){
183  drmin = dr;
184  neighborUp = neighbor;
185  }
186  }
187 
188  if (neighborUp < nCells) {
189  high = neighborUp;
190  low = me;
191  me = high;
192  }
193  else flag = true;
194 
195  T_Scalar dX = cellCentroid[me][normal] - cellCentroid[low][normal];
196  T_Scalar factor = -2.0/HBAR_SI * sqrt(2.0*electron_effmass*ME*QE);
197  T_Scalar valueMe = PositiveValueOf( conduction_band[me] - en);
198  T_Scalar valueLow = PositiveValueOf( conduction_band[low] - en);
199  T_Scalar avg = (valueMe + valueLow) / 2.0;
200  T_Scalar exponent = factor * sqrt(avg) * fabs(dX);
201 
202  transmission[me] = transmission[low] * exp(exponent);
203 
204  if (en - conduction_band[me] >0 ){
205 
206  foundLow = true;
207  idLow = me;
208  transmissionLow = transmission[me];
209  //cout << "found low " << c <<" " << me << endl;
210  break;
211  }
212  // cout << c << " low " << low << endl;
213  count ++;
214 
215  }
216 #endif
217  //-------------------------------------------------------------------------//
218 
219  const T_Scalar ef = mag(electric_field[c]);
220 
221  const T_Scalar alpha = cellVolume[c] * QE * ef * ef * electron_capture_cross /
222  (16 * PI*PI * HBAR_SI * electron_effmass * electron_trapdepth[i]);
223 
224  if (foundLow == true){
225  rCell[c][i] -= alpha * transmissionLow * xCell[c][i];
226  diag[c](i,i) -= alpha * transmissionLow;
227  //diag[c][i] -= alpha * transmissionLow;
228  rCell[idLow][nTrap] += alpha * transmissionLow * xCell[c][i];
229  }
230 
231  if (foundHigh == true){
232  rCell[c][i] -= alpha * transmissionHigh * xCell[c][i];
233  diag[c](i,i) -= alpha * transmissionHigh;
234  //diag[c][i] -= alpha * transmissionHigh;
235  rCell[idHigh][nTrap] += alpha * transmissionHigh * xCell[c][i];
236  }
237  }
238  }
239  }
240 
241 
242  private:
244  const Field& _varField;
248 
249 
250 };
251 
252 #endif
int getCount(const int i) const
Matrix & getMatrix(const Index &rowIndex, const Index &colIndex)
#define PI
int getSelfCount() const
Definition: StorageSite.h:40
Field coordinate
Definition: GeomFields.h:19
Definition: Field.h:14
Definition: Mesh.h:49
T mag(const Vector< T, 3 > &a)
Definition: Vector.h:260
Array< Vector< T_Scalar, 3 > > VectorT3Array
Array< Diag > & getDiag()
Definition: CRMatrix.h:856
#define ME
Tangent sqrt(const Tangent &a)
Definition: Tangent.h:317
#define HBAR_SI
pair< const Field *, const StorageSite * > ArrayIndex
Definition: MultiField.h:21
#define QE
const CRConnectivity & getCellCells() const
Definition: Mesh.cpp:480
const StorageSite & getCells() const
Definition: Mesh.h:109
Field volume
Definition: GeomFields.h:26
const T PositiveValueOf(T input)
Tangent fabs(const Tangent &a)
Definition: Tangent.h:312
Definition: Array.h:14
TrapBandTunnelingDiscretization(const MeshList &meshes, const GeomFields &geomFields, const Field &varField, const Field &electricField, const Field &conductionbandField, const ElectricModelConstants< T_Scalar > &constants)
int getCount() const
Definition: StorageSite.h:39
void discretize(const Mesh &mesh, MultiFieldMatrix &mfmatrix, MultiField &xField, MultiField &rField)
vector< T > electron_trapdepth
Definition: ElectricBC.h:77
const ElectricModelConstants< T_Scalar > & _constants
vector< Mesh * > MeshList
Definition: Mesh.h:439