45 #include <Xyce_config.h>
52 #include <N_UTL_Expression.h>
124 Nmax_chopGiven(false),
139 bool bsuccess =
true;
155 ParameterMap::const_iterator p_i =
getParameterMap().find(std::string(
"FUNCTION"));
158 ExtendedString tmp = getValue<std::string, DopeInfo>(*
this, p);
159 setValue<std::string, DopeInfo>(*
this, p,
static_cast<std::string
>(tmp.toLower()));
163 ParameterMap::const_iterator p_i =
getParameterMap().find(std::string(
"TYPE"));
166 ExtendedString tmp = getValue<std::string, DopeInfo>(*
this, p);
167 setValue<std::string, DopeInfo>(*
this, p,
static_cast<std::string
>(tmp.toLower()));
180 std::vector<double> & CVec,
181 std::vector<double> & CdonorVec,
182 std::vector<double> & CacceptorVec,
183 std::vector<double> & xVec,
187 int NX (CVec.size());
191 if (
type ==
"ptype" ||
type ==
"acceptor")
195 else if (
type ==
"ntype" ||
type ==
"donor")
206 if (xVec[i] >
xmax || xVec[i] <
xmin)
212 CVec[i] += sign*
Nmax;
214 if (
type ==
"ptype" ||
type ==
"acceptor")
216 CacceptorVec[i] +=
Nmax;
218 else if (
type ==
"ntype" ||
type ==
"donor")
220 CdonorVec[i] +=
Nmax;
226 double deltaX = fabs(
xwidth);
228 double ax = log(
Nmax/
Nmin)/(deltaX*deltaX);
231 double scalarX = 1.0;
234 if (
given(
"XLOC") &&
given(
"XWIDTH") && deltaX != 0.0)
236 abs_dx = fabs(xVec[i]-
xloc);
241 scalarX *=
ngdep2(abs_dx, 0.0, ax, 1.0);
245 bool flatReg = (xVec[i] >
xloc);
249 scalarX *=
ngdep2(abs_dx, 0.0, ax, 1.0);
254 bool flatReg = (xVec[i] <
xloc);
258 scalarX *=
ngdep2(abs_dx, 0.0, ax, 1.0);
263 CVec[i] += sign*
Nmax*scalarX;
265 if (
type ==
"ptype" ||
type ==
"acceptor")
267 CacceptorVec[i] +=
Nmax*scalarX;
269 else if (
type ==
"ntype" ||
type ==
"donor")
271 CdonorVec[i] +=
Nmax*scalarX;
284 if (
flatX == 0) regOn =
true;
288 if (x >
xloc) regOn =
false;
294 if (x <
xloc) regOn =
false;
299 CVec[i] += (regOn)?(sign*
Nmax):(sign*
Nmin);
301 if (
type ==
"ptype" ||
type ==
"acceptor")
303 CacceptorVec[i] += (regOn)?(Nmax):(sign*
Nmin);
305 else if (
type ==
"ntype" ||
type ==
"donor")
307 CdonorVec[i] += (regOn)?(Nmax):(sign*
Nmin);
315 std::string msg =
"Dope Region : ";
317 msg +=
" has specified the expression specification, but not provided an expression.";
319 N_ERH_ErrorMgr::report ( N_ERH_ErrorMgr::DEV_FATAL,msg);
323 #ifdef Xyce_DEBUG_DEVICE
324 Xyce::dout() <<
"DopeInfo::setupInfo: exprString = " <<
exprString << std::endl;
326 Util::Expression expr;
331 double dopeValue(0.0);
333 expr.set_var(std::string(
"#X"), xVec[i]);
334 expr.evaluateFunction (dopeValue);
335 CVec[i] += sign*dopeValue;
337 if (
type ==
"ptype" ||
type ==
"acceptor")
339 CacceptorVec[i] += dopeValue;
341 else if (
type ==
"ntype" ||
type ==
"donor")
343 CdonorVec[i] += dopeValue;
352 std::string msg =
"Dope Region : ";
354 msg +=
" has specified the file specification, but not specified a file name.";
356 N_ERH_ErrorMgr::report ( N_ERH_ErrorMgr::DEV_FATAL,msg);
367 for (
int id=0;
id<dopeSize;++id)
378 double xtmp = xVec[i];
379 double dopeValue(0.0);
381 CVec[i] += sign*dopeValue;
383 if (
type ==
"ptype" ||
type ==
"acceptor")
385 CacceptorVec[i] += dopeValue;
387 else if (
type ==
"ntype" ||
type ==
"donor")
389 CdonorVec[i] += dopeValue;
396 std::string msg =
"Unrecognized Dope Region function type: ";
398 msg +=
" for region: ";
401 N_ERH_ErrorMgr::report ( N_ERH_ErrorMgr::DEV_FATAL,msg);
415 std::vector<double> & CVec,
416 std::vector<double> & CdonorVec,
417 std::vector<double> & CacceptorVec,
418 std::vector<double> & xVec,
419 std::vector<double> & yVec,
423 int numMeshPoints (CVec.size());
426 if (
type ==
"ptype" ||
type ==
"acceptor") sign = -1.0;
430 for (i=0;i<numMeshPoints;++i)
435 if (xVec[i] >
xmax || xVec[i] <
xmin)
443 if (yVec[i] >
ymax || yVec[i] <
ymin)
449 CVec[i] += sign*
Nmax;
450 if (
type ==
"ptype" ||
type ==
"acceptor")
452 CacceptorVec[i] +=
Nmax;
456 CdonorVec[i] +=
Nmax;
462 double deltaX = fabs(
xwidth);
463 double deltaY = fabs(
ywidth);
470 ax = log(
Nmax/
Nmin)/(deltaX*deltaX);
475 ay = log(
Nmax/
Nmin)/(deltaY*deltaY);
478 for (i=0;i<numMeshPoints;++i)
480 double scalarX = 1.0;
481 double scalarY = 1.0;
482 double abs_dx, abs_dy;
484 if (
given(
"XLOC") &&
given(
"XWIDTH") && deltaX != 0.0)
486 abs_dx = fabs(xVec[i]-
xloc);
491 scalarX *=
ngdep2(abs_dx, 0.0, ax, 1.0);
495 bool flatReg = (xVec[i] >
xloc);
499 scalarX *=
ngdep2(abs_dx, 0.0, ax, 1.0);
504 bool flatReg = (xVec[i] <
xloc);
508 scalarX *=
ngdep2(abs_dx, 0.0, ax, 1.0);
513 if (
given(
"YLOC") &&
given(
"YWIDTH") && deltaY != 0.0)
515 abs_dy = fabs(yVec[i]-
yloc);
519 scalarY *=
ngdep2(0.0, abs_dy, 1.0, ay);
523 bool flatReg = (yVec[i] >
yloc);
527 scalarY *=
ngdep2(0.0, abs_dy, 1.0, ay);
532 bool flatReg = (yVec[i] <
yloc);
536 scalarY *=
ngdep2(0.0, abs_dy, 1.0, ay);
541 CVec[i] += sign*
Nmax*scalarX*scalarY;
543 if (
type ==
"ptype" ||
type ==
"acceptor")
545 CacceptorVec[i] +=
Nmax*scalarX*scalarY;
549 CdonorVec[i] +=
Nmax*scalarX*scalarY;
555 for (i=0;i<numMeshPoints;++i)
564 if (
flatY == 0) regOnY =
true;
568 if(y >
yloc) regOnY =
false;
574 if (y <
yloc) regOnY =
false;
581 if (
flatX == 0) regOnX =
true;
585 if(x >
xloc) regOnX =
false;
591 if (x <
xloc) regOnX =
false;
595 bool regOn = (regOnX && regOnY);
597 CVec[i] += (regOn)?(sign*
Nmax):(sign*
Nmin);
598 if (
type ==
"ptype" ||
type ==
"acceptor")
600 CacceptorVec[i] += (regOn)?(Nmax):(sign*
Nmin);
604 CdonorVec[i] += (regOn)?(Nmax):(sign*
Nmin);
610 std::string msg =
"Unrecognized Dope Region function type: ";
612 msg +=
" for region: ";
615 N_ERH_ErrorMgr::report ( N_ERH_ErrorMgr::DEV_FATAL,msg);
636 double D = 2.0 * sqrt(Dt);
638 return 0.5 * (
erf((Wh + x)/D) +
erf((Wh - x)/D));
686 double xprime = fabs(x) - (0.5 * W);
687 return ((xprime <= 0.0) ? 1.0 : exp(-ax*xprime*xprime))*
688 ((y > 0.0) ? 0.0 : exp(-ay*y*y));
728 double retVal = exp(-ax*x*x)* exp(-ay*y*y);
742 double t1 = 1.0 / (1.0 + 0.3275911 * fabs(x));
747 double result = 1.0 - (0.254829592*t1 - 0.284496736*t2 + 1.421413741*t3 -
748 1.453152027*t4 + 1.061405429*t5) * exp(-x*x);
749 return (x < 0.0) ? -result : result;
761 std::string & filename,
762 std::vector<double> & xloc,
763 std::vector<double> & nvec,
764 std::vector<double> & y2,
774 input.open( filename.c_str(), std::ios::in );
777 bool endOfFile = input.eof();
780 endOfFile = input.eof();
790 endOfFile = input.eof();
799 xloc.push_back(x_loc);
800 nvec.push_back(value);
803 y2.resize(xloc.size(),0.0);
804 devSupport.
spline (xloc, nvec, y2);
808 std::string msg =
"Error: Cannot open doping file: " + filename;
809 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, msg);
822 std::string & filename,
823 std::vector<double> & xloc,
824 std::vector<double> & nvec,
825 std::vector<double> & y2_n,
826 std::vector<double> & pvec,
827 std::vector<double> & y2_p,
840 input.open( filename.c_str(), std::ios::in );
843 bool endOfFile = input.eof();
846 endOfFile = input.eof();
856 endOfFile = input.eof();
865 endOfFile = input.eof();
875 xloc.push_back(x_loc);
876 nvec.push_back(value1);
877 pvec.push_back(value2);
882 y2_n.resize(xloc.size(),0.0);
883 y2_p.resize(xloc.size(),0.0);
884 devSupport.
spline (xloc, nvec, y2_n);
885 devSupport.
spline (xloc, pvec, y2_p);
889 std::string msg =
"Error: Cannot open doping file: " + filename;
890 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, msg);