Xyce  6.1
N_DEV_ReactionNetwork.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright 2002 Sandia Corporation. Under the terms
5 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
6 // Government retains certain rights in this software.
7 //
8 // Xyce(TM) Parallel Electrical Simulator
9 // Copyright (C) 2002-2015 Sandia Corporation
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //-----------------------------------------------------------------------------
24 
25 //-----------------------------------------------------------------------------
26 // Filename : $RCSfile: N_DEV_ReactionNetwork.h,v $
27 //
28 // Purpose :
29 //
30 // Special Notes :
31 //
32 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
33 //
34 // Creation Date : 03/20/2006
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.21.2.1 $
40 //
41 // Revision Date : $Date: 2015/04/02 18:20:09 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-----------------------------------------------------------------------------
45 #ifndef N_DEV_ReactionNetwork_H
46 #define N_DEV_ReactionNetwork_H
47 
48 #include <N_UTL_fwd.h>
49 #include <iosfwd>
50 #include <vector>
51 #include <map>
52 #include <string>
53 
54 #include <N_DEV_Reaction.h>
55 #include <N_DEV_Specie.h>
56 #include <N_DEV_MaterialLayer.h>
57 
58 #include <N_ERH_ErrorMgr.h>
59 // ---------- Forward Declarations ----------
60 
61 // Note: sstream and strstream are only needed here because of all the
62 // inlined functions.
63 #include <sstream>
64 
65 namespace Xyce {
66 namespace Device {
67 
68 //-----------------------------------------------------------------------------
69 // Class : N_DEV_ReactionNetwork
70 // Purpose :
71 // Special Notes :
72 // Creator : Tom Russo, SNL
73 // Creation Date : 03/20/2006
74 //-----------------------------------------------------------------------------
76 {
77 public:
78 
79  ReactionNetwork(const std::string &name = "NoName");
80  ReactionNetwork(const ReactionNetwork & right);
81  virtual ~ReactionNetwork();
82 
83  void setReactionNetworkFromFile(const NetlistLocation &netlist_location, const std::string &fileName);
84 
85  void addReaction(const std::string &name);
86  void addReaction(const std::string &name, Reaction &reaction);
87  void addReactant(const std::string &name, const std::string &reactant, double stoich);
88  void addProduct(const std::string &name, const std::string &reactant, double stoich);
89 
90  // set rate constant calculator for each type of reaction
91  void setSimpleCalc(const std::string &name, double k);
92  void setCaptureCalc(const std::string &name, double sigma, double v);
93  void setEmissionCalc(const std::string &name, double sigma, double v, double N, double E);
94  void setElectronCaptureCalc(const std::string &name, double sigma);
95  void setElectronEmissionCalc(const std::string &name, double sigma, double E);
96  void setFDElectronEmissionCalc(const std::string &name, double sigma, double E);
97  void setHoleCaptureCalc(const std::string &name, double sigma);
98  void setHoleEmissionCalc(const std::string &name, double sigma, double E);
99  void setFDHoleEmissionCalc(const std::string &name, double sigma, double E);
100  void setComplexCalc(const std::string &name);
101  void setComplexMultiplierCalc(const std::string &name, double multiplier);
102  void setDecomplexCalc(const std::string &name, double bindingEnergy,
103  double gammaAB, double gammaA, double gammaB, double concSi);
104  void setBourgoinCorbettHoleCalc(const std::string &name,double sigma);
105  void setBourgoinCorbettCalc(const std::string &speciesName,const std::string &carrierName,
106  double sigma, double hopDistance);
107 
108  void setRateConstant(const std::string &name, double k);
109  void scaleRateConstant(const std::string &name, double kscale);
110 
111  void setScaleParams(double c, double t, double x);
112  void setMaterial(MaterialLayer *material, double Temp);
113  void setCoefficients(double Temp);
114  void setRxnVariableCoeffs(bool variableCoeffs);
115 
116  // Use rate constant calculators
117  void scaleRateConstantFromCalculator(const std::string &name);
118  void unscaleRateConstantFromCalculator(const std::string &name);
119  void setRateConstantFromCalculator(const std::string &name, double T);
120  void setRateConstantsFromCalc(double T);
121  void setRateConstantFromCalculator(const std::string &name, double T,
122  std::vector<double> &concs,
123  std::vector<double> &constant_vec);
124  void setRateConstantsFromCalc(double T,
125  std::vector<double> &concs,
126  std::vector<double> &constant_vec);
129 
130  void setSpecies(std::vector<Specie> &theSpeciesVect);
131  void addSpecie(const Specie &aSpecie);
132  void setConstants(std::vector<Specie> &theConstantsVect);
133  void addConstant(const Specie &aConstant);
134 
135  int getReactionNum(const std::string name);
136 
137  void addSourceTerm(const std::string &speciesName, const std::string &expressionStr);
138  void addSourceTerm(const std::string &speciesName,Util::Expression *expression);
139  void addMasterSourceTerm(const std::string &speciesName);
140 
141  void addInitialCondition(const std::string &speciesName, double value);
142  std::pair<std::string,double> getInitialCondition(int i);
144 
145  void setSimTime(double time);
146  double getBreakpointTime();
147  inline void setSourceScaleFac(double scf) {sourceScaleFac=scf;};
148  inline void setMasterSourceValue(double msv) {masterSourceValue=msv;};
149 
150  void getDdt(std::vector<double> &concs,std::vector<double> &constants,
151  std::vector<double> &ddt);
152  void getJac(std::vector<double> &concs, std::vector<double> &constants,
153  std::vector<std::vector<double> >&jac);
154  void getDFdConst(const std::string &constantName,
155  std::vector<double> &concs, std::vector<double> &constants,
156  std::vector<double> &dFdConst);
157 
158  void getJacobianVC(std::vector<double> &concs, std::vector<double> &constants,
159  std::vector<std::vector<double> >&jac, std::vector<double> &constVec);
160 
161  double getRate(std::vector<double> &concs,std::vector<double> &constants,
162  std::vector<int> &captureVect, std::vector<int> &emissionVect);
163  void getDRateDC(std::vector<double> &concs,std::vector<double> &constants,
164  std::vector<int> &captureVect, std::vector<int> &emissionVect,
165  std::vector<double>&dratedc);
166 
167  void getDRateDConst(std::vector<double> &concs,std::vector<double> &constants,
168  std::vector<int> &captureVect, std::vector<int> &emissionVect,
169  std::vector<double>&dratedc);
170 
171  double getCaptureLifetime(std::vector<double> &concs,std::vector<double> &constants,
172  std::vector<int> &captureVect,double &concentration);
173  void getCaptureLifetimes(std::vector<double> &concs,std::vector<double> &constants,
174  std::vector<int> &captureVect,double &concentration,
175  std::vector<double> &lifetimes);
176  double getELifetime(std::vector<double>&concs,std::vector<double>&constants);
177  double getHLifetime(std::vector<double>&concs,std::vector<double>&constants);
178  void getELifetimes(std::vector<double>&concs,std::vector<double>&constants,
179  std::vector<double> &lifetimes);
180  void getHLifetimes(std::vector<double>&concs,std::vector<double>&constants,
181  std::vector<double> &lifetimes);
182 
183  double getERate(std::vector<double> &concs,std::vector<double> &constants);
184  double getHRate(std::vector<double> &concs,std::vector<double> &constants);
185 
186  void getDERateDC(std::vector<double> &concs,std::vector<double> &constants,
187  std::vector<double>&dratedc);
188  void getDHRateDC(std::vector<double> &concs,std::vector<double> &constants,
189  std::vector<double>&dratedc);
190 
191  void getDERateDConst(std::vector<double> &concs,std::vector<double> &constants,
192  std::vector<double>&dratedConst);
193  void getDHRateDConst(std::vector<double> &concs,std::vector<double> &constants,
194  std::vector<double>&dratedConst);
195 
196  int getNumSpecies();
197  int getNumConstants();
198  const std::string & getSpeciesName(int i);
199  const std::string & getConstantsName(int i);
200  int getSpeciesNum(const std::string &name);
201  int getConstantNum(const std::string &name);
202  int getReactantNum(const std::string &name);
203  bool reactantExist(const std::string &name);
204  bool constantExist(const std::string &name);
205 
206  void setName(const std::string &name);
207  void clear();
208  void output(std::ostream & os) const;
209 
210  double getDiffusionCoefficient (const std::string & name, const double temp);
211  double getDiffusionCoefficient (int specie, const double temp);
212  double getDiffusionCoefficient (int specie, const double temp,
213  std::vector<double> concs,
214  std::vector<double> carrierConcs);
215 
216  int getChargeState (const std::string & name);
217  int getChargeState (int specie);
218 
219  void setApplySources(bool flag);
220 
221 private:
222  Reaction &getReaction(const std::string &name);
223  Reaction &getReaction(int i);
224 
225  std::map<std::string,int> speciesMap;
226  std::vector<Specie> species;
227  std::map<std::string,int> constantsMap;
228  std::vector<Specie> constants;
229  std::vector<std::pair<std::string,double> > initialConditions;
230  std::vector<Reaction> theReactions;
231  std::map<std::string,int> reactionNamesMap;
232  std::vector<std::string> reactionNames;
233  std::string myName;
234  std::vector<int> electronCaptureReactions;
235  std::vector<int> holeCaptureReactions;
236  std::vector<int> electronEmissionReactions;
237  std::vector<int> holeEmissionReactions;
238  std::vector< std::pair<int,Util::Expression *> > theSourceTerms;
239  std::vector<int> masterSourceSpecies;
242  double C0;
243  double t0;
244  double x0;
247 
249 };
250 
251 //-----------------------------------------------------------------------------
252 // Function : ReactionNetwork::clear
253 // Purpose : make the reaction network an empty one
254 // Special Notes :
255 // Scope : public
256 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
257 // Creation Date : 3/20/06
258 //-----------------------------------------------------------------------------
260 {
261  speciesMap.clear();
262  species.clear();
263  constantsMap.clear();
264  constants.clear();
265  theReactions.clear();
266  reactionNamesMap.clear();
267  setName("NoName");
268 }
269 
270 //-----------------------------------------------------------------------------
271 // Function : ReactionNetwork::setName
272 // Purpose : Accessor function to set network name
273 // Special Notes :
274 // Scope : public
275 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
276 // Creation Date : 3/20/06
277 //-----------------------------------------------------------------------------
278 inline void ReactionNetwork::setName(const std::string &name)
279 {
280  myName=name;
281 }
282 
283 //-----------------------------------------------------------------------------
284 // Function : ReactionNetwork::getNumSpecies
285 // Purpose : Accessor function to returning number of species recorded
286 // Special Notes : Only solution species returned, does not include constants
287 // Scope : public
288 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
289 // Creation Date : 3/20/06
290 //-----------------------------------------------------------------------------
292 {
293  return (species.size());
294 }
295 
296 //-----------------------------------------------------------------------------
297 // Function : ReactionNetwork::getNumConstants
298 // Purpose : Accessor function to returning number of constant species
299 // Special Notes :
300 // Scope : public
301 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
302 // Creation Date : 8/10/06
303 //-----------------------------------------------------------------------------
305 {
306  return (constants.size());
307 }
308 
309 //-----------------------------------------------------------------------------
310 // Function : ReactionNetwork::getSpeciesName
311 // Purpose : Accessor function to returning name of indicated species
312 // Special Notes : Only returns solution species names, not constants
313 // Scope : public
314 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
315 // Creation Date : 3/20/06
316 //-----------------------------------------------------------------------------
317 inline const std::string & ReactionNetwork::getSpeciesName(int i)
318 {
319  return species[i].getName();
320 }
321 
322 //-----------------------------------------------------------------------------
323 // Function : ReactionNetwork::getConstantsName
324 // Purpose : Accessor function to returning name of indicated constant
325 // species
326 // Special Notes : Only returns solution constants names, not variable species
327 // Scope : public
328 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
329 // Creation Date : 3/20/06
330 //-----------------------------------------------------------------------------
331 inline const std::string & ReactionNetwork::getConstantsName(int i)
332 {
333  return constants[i].getName();
334 }
335 
336 //-----------------------------------------------------------------------------
337 // Function : ReactionNetwork::getSpeciesNum
338 // Purpose : Accessor function to return number of named variable specie
339 // Special Notes : returns -1 if the specified specie is not a variable
340 // Scope : public
341 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
342 // Creation Date : 3/20/06
343 //-----------------------------------------------------------------------------
344 inline int ReactionNetwork::getSpeciesNum(const std::string &name)
345 {
346  std::map<std::string,int>::iterator n_i;
347  n_i = speciesMap.find(name);
348 
349  if (n_i == speciesMap.end())
350  {
351  return -1;
352  }
353  else
354  {
355  return n_i->second;
356  }
357 }
358 
359 //-----------------------------------------------------------------------------
360 // Function : ReactionNetwork::reactantExist
361 // Purpose : Returns false if the named specie doesn't exist, or if
362 // it is a constant.
363 // Special Notes :
364 // Scope : public
365 // Creator : Eric Keiter, SNL, Electrical and Microsystems Modeling
366 // Creation Date : 4/24/07
367 //-----------------------------------------------------------------------------
368 inline bool ReactionNetwork::reactantExist(const std::string &name)
369 {
370  bool retFlag(true);
371  int i=getSpeciesNum(name);
372  if (i == -1)
373  {
374  retFlag = false; // this reactant does not exist.
375  }
376 
377  return retFlag;
378 }
379 
380 //-----------------------------------------------------------------------------
381 // Function : ReactionNetwork::constantExist
382 // Purpose : Returns false if the named specie doesn't exist, or if
383 // it is a constant.
384 // Special Notes :
385 // Scope : public
386 // Creator : Eric Keiter, SNL, Electrical and Microsystems Modeling
387 // Creation Date : 4/24/07
388 //-----------------------------------------------------------------------------
389 inline bool ReactionNetwork::constantExist(const std::string &name)
390 {
391  bool retFlag(true);
392  int i=getConstantNum(name);
393  if (i == -1)
394  {
395  retFlag = false; // this constant does not exist.
396  }
397 
398  return retFlag;
399 }
400 
401 //-----------------------------------------------------------------------------
402 // Function : ReactionNetwork::getReactantNum
403 // Purpose : Accessor function to return number of named specie
404 // Special Notes : Returns negative numbers for constants, positive for
405 // variables
406 // The species in question better exist, coz there's no way
407 // to return an error condition other than bombing.
408 // Scope : public
409 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
410 // Creation Date : 3/20/06
411 //-----------------------------------------------------------------------------
412 inline int ReactionNetwork::getReactantNum(const std::string &name)
413 {
414  int i=getSpeciesNum(name);
415  if (i == -1)
416  {
417  i=getConstantNum(name);
418  if (i == -1)
419  {
420  Report::UserFatal() << "Invalid species name specified: " << name;
421  }
422  i = -(i+1);
423  }
424  return i;
425 }
426 
427 //-----------------------------------------------------------------------------
428 // Function : ReactionNetwork::getConstantNum
429 // Purpose : Accessor function to return number of named constant specie
430 // Special Notes : returns -1 if the specified specie is not a constant
431 // Scope : public
432 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
433 // Creation Date : 3/20/06
434 //-----------------------------------------------------------------------------
435 inline int ReactionNetwork::getConstantNum(const std::string &name)
436 {
437  std::map<std::string,int>::iterator n_i;
438  n_i = constantsMap.find(name);
439 
440  if (n_i == constantsMap.end())
441  {
442  return -1;
443  }
444  else
445  {
446  return n_i->second;
447  }
448 }
449 
450 //-----------------------------------------------------------------------------
451 // Function : ReactionNetwork::addInitialCondition
452 // Purpose : add an initial condition to the list
453 //
454 // Scope : public
455 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
456 // Creation Date : 03/20/06
457 //-----------------------------------------------------------------------------
458 inline void ReactionNetwork::addInitialCondition(const std::string &speciesName, double value)
459 {
460  initialConditions.push_back(std::pair<std::string,double>(speciesName,value));
461 }
462 
463 //-----------------------------------------------------------------------------
464 // Function : ReactionNetwork::getNumInitialConditions
465 // Purpose : get an initial condition from the list
466 //
467 // Scope : public
468 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
469 // Creation Date : 03/20/06
470 //-----------------------------------------------------------------------------
471 inline int
473 {
474  return(initialConditions.size());
475 }
476 //-----------------------------------------------------------------------------
477 // Function : ReactionNetwork::getInitialCondition
478 // Purpose : get an initial condition from the list
479 //
480 // Scope : public
481 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
482 // Creation Date : 03/20/06
483 //-----------------------------------------------------------------------------
484 inline std::pair<std::string,double>
486 {
487  return(initialConditions[i]);
488 }
489 
490 //-----------------------------------------------------------------------------
491 // Function : ReactionNetwork::getReactionNum
492 // Purpose : Accessor function to return number of named reaction
493 // Special Notes :
494 // Scope : public
495 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
496 // Creation Date : 3/20/06
497 //-----------------------------------------------------------------------------
498 inline int ReactionNetwork::getReactionNum(std::string name)
499 {
500  std::map<std::string,int>::iterator n_i;
501  n_i = reactionNamesMap.find(name);
502 
503  if (n_i == reactionNamesMap.end())
504  {
505  return -1;
506  }
507  else
508  {
509  return n_i->second;
510  }
511 }
512 
513 //-----------------------------------------------------------------------------
514 // Function : ReactionNetwork::getReaction
515 // Purpose : Accessor function to returning reference to indexed reaction
516 // Special Notes :
517 // Scope : public
518 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
519 // Creation Date : 3/20/06
520 //-----------------------------------------------------------------------------
522 {
523  return theReactions[i];
524 }
525 
526 //-----------------------------------------------------------------------------
527 // Function : ReactionNetwork::getReaction
528 // Purpose : Accessor function to returning reference to named reaction
529 // Special Notes :
530 // Scope : public
531 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
532 // Creation Date : 3/20/06
533 //-----------------------------------------------------------------------------
534 
535 inline Reaction &ReactionNetwork::getReaction(const std::string &name)
536 {
537  int ni;
538  ni=getReactionNum(name);
539  if (ni == -1)
540  {
541  Report::UserFatal() << "Attempt to access non-existant reaction " << name;
542  }
543 
544  return theReactions[ni];
545 }
546 
547 //-----------------------------------------------------------------------------
548 // Function : ReactionNetwork::setSimpleCalc
549 // Purpose : set the named reaction's rate calculator to type Simple
550 // Special Notes :
551 // Scope : public
552 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
553 // Creation Date : 08/01/06
554 //-----------------------------------------------------------------------------
555 inline void ReactionNetwork::setSimpleCalc(const std::string &name, double k)
556 {
558 }
559 
560 //-----------------------------------------------------------------------------
561 // Function : ReactionNetwork::setCaptureCalc
562 // Purpose : set the named reaction's rate calculator to type Capture
563 // Special Notes :
564 // Scope : public
565 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
566 // Creation Date : 08/01/06
567 //-----------------------------------------------------------------------------
568 inline void ReactionNetwork::setCaptureCalc(const std::string &name, double sigma, double v)
569 {
571 }
572 //-----------------------------------------------------------------------------
573 // Function : ReactionNetwork::setElectronCaptureCalc
574 // Purpose : set the named reaction's rate calculator to type Capture
575 // Special Notes : Specifically uses v_n=2.3e7 cm/s
576 // Scope : public
577 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
578 // Creation Date : 08/01/06
579 //-----------------------------------------------------------------------------
580 inline void ReactionNetwork::setElectronCaptureCalc(const std::string &name, double sigma)
581 {
582  //carrier velocities are a function of the bulk device material
583  //The reaction network is set up prior to the device and so material
584  //properties are unknown when this method is called. Instead of passing
585  //through a velocity, I'm passing through a carrier charge so that
586  //when the mulk material is known, this reaction can identify the carrier
587  //that is being captured and the velocity can be set appropriately for
588  //the device material. --LCM
589  getReaction(name).setCaptureRateCalculator(sigma,-1.0,C0,t0,x0);
590 }
591 //-----------------------------------------------------------------------------
592 // Function : ReactionNetwork::setHoleCaptureCalc
593 // Purpose : set the named reaction's rate calculator to type Capture
594 // Special Notes : uses v_p=1.9e7 cm/s
595 // Scope : public
596 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
597 // Creation Date : 08/01/06
598 //-----------------------------------------------------------------------------
599 inline void ReactionNetwork::setHoleCaptureCalc(const std::string &name, double sigma)
600 {
601  //carrier velocities are a function of the bulk device material
602  //The reaction network is set up prior to the device and so material
603  //properties are unknown when this method is called. Instead of passing
604  //through a velocity, I'm passing through a carrier charge so that
605  //when the mulk material is known, this reaction can identify the carrier
606  //that is being captured and the velocity can be set appropriately for
607  //the device material. --LCM
608  getReaction(name).setCaptureRateCalculator(sigma,+1.0,C0,t0,x0);
609 }
610 
611 //-----------------------------------------------------------------------------
612 // Function : ReactionNetwork::setEmissionCalc
613 // Purpose : set the named reaction's rate calculator to type emission
614 // Special Notes :
615 // Scope : public
616 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
617 // Creation Date : 08/01/06
618 //-----------------------------------------------------------------------------
619 inline void ReactionNetwork::setEmissionCalc(const std::string &name, double sigma, double v, double N, double E)
620 {
621  getReaction(name).setEmissionRateCalculator(sigma,v,N,E,C0,t0,x0);
622 }
623 //-----------------------------------------------------------------------------
624 // Function : ReactionNetwork::setElectronEmissionCalc
625 // Purpose : set the named reaction's rate calculator to type emission
626 // Special Notes :Uses v_n=2.3e7 cm/s and N_c=2.86e19 cm^{-3}
627 // Scope : public
628 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
629 // Creation Date : 08/01/06
630 //-----------------------------------------------------------------------------
631 inline void ReactionNetwork::setElectronEmissionCalc(const std::string &name, double sigma, double E)
632 {
633  //carrier velocities and DOS are a function of the bulk device material
634  //The reaction network is set up prior to the device and so material
635  //properties are unknown when this method is called. Instead of passing
636  //through a velocity, I'm passing through a carrier charge so that
637  //when the mulk material is known, this reaction can identify the carrier
638  //that is being emitted and the velocity can be set appropriately for
639  //the device material. --LCM
640  getReaction(name).setEmissionRateCalculator(sigma,-1.0,2.86e19,E,C0,t0,x0);
641 }
642 //-----------------------------------------------------------------------------
643 // Function : ReactionNetwork::setHoleEmissionCalc
644 // Purpose : set the named reaction's rate calculator to type emission
645 // Special Notes : uses v_p=1.9e7 cm/s and N_v=2.66e19 cm^{-3}
646 // Scope : public
647 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
648 // Creation Date : 08/01/06
649 //-----------------------------------------------------------------------------
650 inline void ReactionNetwork::setHoleEmissionCalc(const std::string &name, double sigma, double E)
651 {
652  //carrier velocities and DOS are a function of the bulk device material
653  //The reaction network is set up prior to the device and so material
654  //properties are unknown when this method is called. Instead of passing
655  //through a velocity, I'm passing through a carrier charge so that
656  //when the mulk material is known, this reaction can identify the carrier
657  //that is being emitted and the velocity can be set appropriately for
658  //the device material. --LCM
659  getReaction(name).setEmissionRateCalculator(sigma,+1.0,2.66e19,E,C0,t0,x0);
660 }
661 
662 //-----------------------------------------------------------------------------
663 // Function : ReactionNetwork::setComplexCalc
664 // Purpose : set the named reaction's rate calculator to type emission
665 // Special Notes :
666 // Scope : public
667 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
668 // Creation Date : 08/01/06
669 //-----------------------------------------------------------------------------
670 inline void ReactionNetwork::setComplexCalc(const std::string &name)
671 {
673 }
674 
675 //-----------------------------------------------------------------------------
676 // Function : ReactionNetwork::setComplexMultiplierCalc
677 // Purpose : set the named reaction's rate calculator to type complex with
678 // : a multiplier on the rate
679 // Special Notes :
680 // Scope : public
681 // Creator : Lawrence C Musson, SNL
682 // Creation Date : 06/26/2014
683 //-----------------------------------------------------------------------------
684  inline void ReactionNetwork::setComplexMultiplierCalc(const std::string &name, double multiplier)
685 {
687 }
688 
689 //-----------------------------------------------------------------------------
690 // Function : ReactionNetwork::setDecomplexCalc
691 // Purpose : set the named reaction's rate calculator to type emission
692 // Special Notes :
693 // Scope : public
694 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
695 // Creation Date : 08/01/06
696 //-----------------------------------------------------------------------------
697 inline void ReactionNetwork::setDecomplexCalc(const std::string &name,
698  double bindingEnergy,
699  double gammaAB,
700  double gammaA,
701  double gammaB,
702  double concSi)
703 {
704 
706  bindingEnergy,gammaAB,gammaA,
707  gammaB,concSi,C0,t0,x0);
708 }
709 
710 
711 //-----------------------------------------------------------------------------
712 // Function : ReactionNetwork::setBourgoinCorbettHoleCalc
713 // Purpose : set the named reaction's rate calculator to type Bourgoin
714 // Corbett hole-enhanced diffusion
715 // Special Notes :
716 // Scope : public
717 // Creator : Lawrence C Musson, SNL
718 // Creation Date : 03/25/14
719 //-----------------------------------------------------------------------------
720  inline void ReactionNetwork::setBourgoinCorbettHoleCalc(const std::string &name,double sigma)
721 {
722 
724  sigma,
725  C0,t0,x0);
726 }
727 
728 
729 //-----------------------------------------------------------------------------
730 // Function : ReactionNetwork::output
731 // Purpose :
732 // Special Notes :
733 // Scope : public
734 // Creator : Eric R. Keiter, SNL, Electrical and Microsystems Modeling
735 // Creation Date : 05/27/06
736 //-----------------------------------------------------------------------------
737 inline void ReactionNetwork::output(std::ostream & os) const
738 {
739  int i;
740 
741  for (i=0;i< species.size();++i)
742  {
743  os << "species["<<i<<"] = " << species[i].getName() << std::endl;
744  }
745  os << std::endl;
746 
747 
748  for (i=0;i<theReactions.size();++i)
749  {
750  os << reactionNames[i];
751  theReactions[i].output( species, os);
752  }
753 
754  if (electronCaptureReactions.size() != 0)
755  {
756  os << "Electron Capture Reactions: " << std::endl;
757  for ( i=0; i<electronCaptureReactions.size(); ++i)
758  {
759  os << " Reaction number " << electronCaptureReactions[i] << "("
760  << reactionNames[electronCaptureReactions[i]] << ")" << std::endl;
761  }
762  }
763  if (holeCaptureReactions.size() != 0)
764  {
765  os << "Hole Capture Reactions: " << std::endl;
766  for ( i=0; i<holeCaptureReactions.size(); ++i)
767  {
768  os << " Reaction number " << holeCaptureReactions[i] << "("
769  << reactionNames[holeCaptureReactions[i]] << ")" << std::endl;
770  }
771  }
772  if (electronEmissionReactions.size() != 0)
773  {
774  os << "Electron Emission Reactions: " << std::endl;
775  for ( i=0; i<electronEmissionReactions.size(); ++i)
776  {
777  os << " Reaction number " << electronEmissionReactions[i] << "("
778  << reactionNames[electronEmissionReactions[i]] << ")" << std::endl;
779  }
780  }
781  if (holeEmissionReactions.size() != 0)
782  {
783  os << "Hole Emission Reactions: " << std::endl;
784  for ( i=0; i<holeEmissionReactions.size(); ++i)
785  {
786  os << " Reaction number " << holeEmissionReactions[i] << "("
787  << reactionNames[holeEmissionReactions[i]] << ")" << std::endl;
788  }
789  }
790 
791  return;
792 }
793 
794 //-----------------------------------------------------------------------------
795 // Function : ReactionNetwork::operator<<
796 // Purpose : "<<" operator
797 // Special Notes :
798 // Scope : public
799 // Creator : Eric R. Keiter, SNL, Electrical and Microsystems Modeling
800 // Creation Date : 05/27/06
801 //-----------------------------------------------------------------------------
802 inline std::ostream & operator<<(std::ostream & os, const ReactionNetwork & rn)
803 {
804  os << "Reaction Network: " << std::endl;
805  rn.output(os);
806 
807  return os;
808 }
809 
810 
811 //-----------------------------------------------------------------------------
812 // Function : ReactionNetwork::getERate
813 // Purpose : Compute the total rate at which electrons are "consumed" or
814 // "produced" by all the capture and emission reactions,
815 // if there are any. This can be used even if the electron
816 // concentration is held fixed (it'll just be the sum of all
817 // reaction rates involving electrons).
818 // Special Notes : Assumes that all emission and capture reactions are
819 // of the form B=>A+E or A+E=>B and will be incorrect if
820 // any reaction not of this form is given a name with
821 // "_ELECTRON_EMISSION" or "_ELECTRON_CAPTURE" in it.
822 //
823 // Scope : public
824 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
825 // Creation Date : 03/20/06
826 //-----------------------------------------------------------------------------
827 inline double ReactionNetwork::getERate(std::vector<double> &concs,
828  std::vector<double> &constant_vec)
829 {
830  return getRate(concs,constant_vec,electronCaptureReactions,
832 }
833 
834 //-----------------------------------------------------------------------------
835 // Function : ReactionNetwork::getELifetime
836 // Purpose :
837 // Special Notes :
838 // Scope : public
839 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
840 // Creation Date : 09/20/06
841 //-----------------------------------------------------------------------------
842 inline double ReactionNetwork::getELifetime(std::vector<double> &concs,
843  std::vector<double> &constant_vec)
844 {
845 
846  double eConc;
847  int concNum=getReactantNum("E");
848  // Bleah
849  if (concNum < 0)
850  eConc = constant_vec[-(concNum+1)];
851  else
852  eConc = concs[concNum];
853 
854 
855  return getCaptureLifetime(concs,constant_vec,electronCaptureReactions,
856  eConc);
857 }
858 
859 //-----------------------------------------------------------------------------
860 // Function : ReactionNetwork::getELifetimes
861 // Purpose :
862 // Special Notes :
863 // Scope : public
864 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
865 // Creation Date : 09/20/06
866 //-----------------------------------------------------------------------------
867 inline void ReactionNetwork::getELifetimes(std::vector<double> &concs,
868  std::vector<double> &constant_vec,
869  std::vector<double> &lifetimes)
870 {
871 
872  double eConc;
873  int concNum=getReactantNum("E");
874  // Bleah
875  if (concNum < 0)
876  eConc = constant_vec[-(concNum+1)];
877  else
878  eConc = concs[concNum];
879 
880 
882  eConc,lifetimes);
883 }
884 
885 //-----------------------------------------------------------------------------
886 // Function : ReactionNetwork::getDERateDC
887 // Purpose : compute vector of derivatives of net electron emission
888 // rate (e.g. result of getERate) with respect to concentration
889 //
890 // Scope : public
891 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
892 // Creation Date : 03/20/06
893 //-----------------------------------------------------------------------------
894 inline void ReactionNetwork::getDERateDC(std::vector<double> &concs,
895  std::vector<double> &constant_vec,
896  std::vector<double> &dRatedC)
897 {
898  getDRateDC(concs,constant_vec,electronCaptureReactions,
899  electronEmissionReactions,dRatedC);
900 }
901 
902 //-----------------------------------------------------------------------------
903 // Function : ReactionNetwork::getDERateDConst
904 // Purpose : compute vector of derivatives of net electron emission
905 // rate (e.g. result of getERate) with respect to concentration
906 //
907 // Scope : public
908 // Creator : Eric R. Keiter
909 // Creation Date : 11/15/08
910 //-----------------------------------------------------------------------------
911 inline void ReactionNetwork::getDERateDConst(std::vector<double> &concs,
912  std::vector<double> &constant_vec,
913  std::vector<double> &dRatedConst)
914 {
915  getDRateDConst(concs,constant_vec,electronCaptureReactions,
916  electronEmissionReactions,dRatedConst);
917 }
918 
919 //-----------------------------------------------------------------------------
920 // Function : ReactionNetwork::getHRate
921 // Purpose : Compute the total rate at which holes are "consumed" or
922 // "produced" by all the capture and emission reactions,
923 // if there are any. This can be used even if the electron
924 // concentration is held fixed (it'll just be the sum of all
925 // reaction rates involving electrons).
926 // Special Notes : Assumes that all emission and capture reactions are
927 // of the form B=>A+H or A+H=>B and will be incorrect if
928 // any reaction not of this form is given a name with
929 // "_HOLE_EMISSION" or "_HOLE_CAPTURE" in it.
930 // Scope : public
931 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
932 // Creation Date : 03/20/06
933 //-----------------------------------------------------------------------------
934 inline double ReactionNetwork::getHRate(std::vector<double> &concs,
935  std::vector<double> &constant_vec)
936 {
937  return getRate(concs,constant_vec,holeCaptureReactions,
939 }
940 
941 
942 //-----------------------------------------------------------------------------
943 // Function : ReactionNetwork::getHLifetime
944 // Purpose :
945 // Special Notes :
946 // Scope : public
947 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
948 // Creation Date : 09/20/06
949 //-----------------------------------------------------------------------------
950 inline double ReactionNetwork::getHLifetime(std::vector<double> &concs,
951  std::vector<double> &constant_vec)
952 {
953 
954  double hConc;
955  int concNum=getReactantNum("H");
956  // Bleah
957  if (concNum < 0)
958  hConc = constant_vec[-(concNum+1)];
959  else
960  hConc = concs[concNum];
961 
962  return getCaptureLifetime(concs,constant_vec,holeCaptureReactions,
963  hConc);
964 }
965 
966 //-----------------------------------------------------------------------------
967 // Function : ReactionNetwork::getHLifetimes
968 // Purpose :
969 // Special Notes :
970 // Scope : public
971 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
972 // Creation Date : 09/20/06
973 //-----------------------------------------------------------------------------
974 inline void ReactionNetwork::getHLifetimes(std::vector<double> &concs,
975  std::vector<double> &constant_vec,
976  std::vector<double> &lifetimes)
977 {
978 
979  double hConc;
980  int concNum=getReactantNum("H");
981  // Bleah
982  if (concNum < 0)
983  hConc = constant_vec[-(concNum+1)];
984  else
985  hConc = concs[concNum];
986 
987 
988  getCaptureLifetimes(concs,constant_vec,holeCaptureReactions,
989  hConc,lifetimes);
990 }
991 
992 //-----------------------------------------------------------------------------
993 // Function : ReactionNetwork::getDHRateDC
994 // Purpose : compute vector of derivatives of net hole emission
995 // rate (e.g. result of getHRate) with respect to concentration
996 //
997 // Scope : public
998 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
999 // Creation Date : 03/20/06
1000 //-----------------------------------------------------------------------------
1001 inline void ReactionNetwork::getDHRateDC(std::vector<double> &concs,
1002  std::vector<double> &constant_vec,
1003  std::vector<double> &dRatedC)
1004 {
1005  getDRateDC(concs,constant_vec,holeCaptureReactions,
1006  holeEmissionReactions,dRatedC);
1007 }
1008 
1009 //-----------------------------------------------------------------------------
1010 // Function : ReactionNetwork::getDHRateDConst
1011 // Purpose : compute vector of derivatives of net hole emission
1012 // rate (e.g. result of getHRate) with respect to concentration
1013 //
1014 // Scope : public
1015 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
1016 // Creation Date : 03/20/06
1017 //-----------------------------------------------------------------------------
1018 inline void ReactionNetwork::getDHRateDConst(std::vector<double> &concs,
1019  std::vector<double> &constant_vec,
1020  std::vector<double> &dRatedConst)
1021 {
1022  getDRateDConst(concs,constant_vec,holeCaptureReactions,
1023  holeEmissionReactions,dRatedConst);
1024 }
1025 
1026 //-----------------------------------------------------------------------------
1027 // Function : ReactionNetwork::getDiffusionCoefficient
1028 // Purpose :
1029 // Scope : public
1030 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
1031 // Creation Date : 03/20/06
1032 //-----------------------------------------------------------------------------
1034 (const std::string & name, const double temp)
1035 {
1036  int num = getSpeciesNum(name);
1037  double D = 0.0;
1038 
1039  if (num < 0)
1040  D = 0.0;
1041  else
1042  D = species[num].getDiffusionCoefficient(temp);
1043 
1044  return D;
1045 }
1046 
1047 //-----------------------------------------------------------------------------
1048 // Function : ReactionNetwork::getDiffusionCoefficient
1049 // Purpose :
1050 // Scope : public
1051 // Creator : Eric Keiter, SNL, Electrical and Microsystems Modeling
1052 // Creation Date : 10/31/06
1053 //-----------------------------------------------------------------------------
1055 (int specie, const double temp)
1056 {
1057  double D = 0.0;
1058 
1059  if (specie < 0)
1060  D = 0.0;
1061  else
1062  D = species[specie].getDiffusionCoefficient(temp);
1063 
1064  return D;
1065 }
1066 
1067 
1068 //-----------------------------------------------------------------------------
1069 // Function : ReactionNetwork::getDiffusionCoefficient
1070 // Purpose :
1071 // Scope : public
1072 // Creator : Eric Keiter, SNL, Electrical and Microsystems Modeling
1073 // Creation Date : 10/31/06
1074 //-----------------------------------------------------------------------------
1076  (int specie, const double temp,
1077  std::vector<double> concs,
1078  std::vector<double> carrierConcs)
1079 {
1080  double D = 0.0;
1081 
1082  if (specie < 0)
1083  D = 0.0;
1084  else
1085  D = species[specie].getDiffusionCoefficient(temp, concs, carrierConcs);
1086 
1087  return D;
1088 }
1089 
1090 //-----------------------------------------------------------------------------
1091 // Function : ReactionNetwork::getChargeState
1092 // Purpose :
1093 // Scope : public
1094 // Creator : Lawrence C Musson
1095 // Creation Date : 02/22/2012
1096 //-----------------------------------------------------------------------------
1098 (const std::string & name)
1099 {
1100  int num = getSpeciesNum(name);
1101  int z = 0;
1102 
1103  if (num < 0)
1104  z = 0;
1105  else
1106  z = species[num].getChargeState();
1107 
1108  return z;
1109 }
1110 
1111 //-----------------------------------------------------------------------------
1112 // Function : ReactionNetwork::getChargeState
1113 // Purpose :
1114 // Scope : public
1115 // Creator : Lawrence C Musson
1116 // Creation Date : 10/31/06
1117 //-----------------------------------------------------------------------------
1119 (int specie)
1120 {
1121  int z = 0;
1122 
1123  if (specie < 0)
1124  z = 0;
1125  else
1126  z = species[specie].getChargeState();
1127 
1128  return z;
1129 }
1130 
1131 //-----------------------------------------------------------------------------
1132 // Function : ReactionNetwork::setApplySources
1133 // Purpose :
1134 // Scope : public
1135 // Creator : Eric Keiter, SNL, Electrical and Microsystems Modeling
1136 // Creation Date : 04/19/09
1137 //-----------------------------------------------------------------------------
1138 inline void ReactionNetwork::setApplySources(bool flag)
1139 {
1140  applySources = flag;
1141 }
1142 
1143 } // namespace Device
1144 } // namespace Xyce
1145 
1146 #endif
void setBourgoinCorbettCalc(const std::string &speciesName, const std::string &carrierName, double sigma, double hopDistance)
std::vector< std::pair< int, Util::Expression * > > theSourceTerms
void setSimpleRateCalculator(double k, double C0, double t0, double x0)
void addConstant(const Specie &aConstant)
void setComplexMultiplierRateCalculator(std::vector< Specie > &VariableSpecies, std::vector< Specie > &ConstantSpecies, double C0, double t0, double x0, double multiplier)
bool reactantExist(const std::string &name)
double getHRate(std::vector< double > &concs, std::vector< double > &constants)
void getDERateDConst(std::vector< double > &concs, std::vector< double > &constants, std::vector< double > &dratedConst)
void scaleRateConstant(const std::string &name, double kscale)
void output(std::ostream &os) const
int getChargeState(const std::string &name)
void getDHRateDConst(std::vector< double > &concs, std::vector< double > &constants, std::vector< double > &dratedConst)
double getELifetime(std::vector< double > &concs, std::vector< double > &constants)
void setScaleParams(double c, double t, double x)
Pure virtual class to augment a linear system.
double getHLifetime(std::vector< double > &concs, std::vector< double > &constants)
void getDRateDConst(std::vector< double > &concs, std::vector< double > &constants, std::vector< int > &captureVect, std::vector< int > &emissionVect, std::vector< double > &dratedc)
std::map< std::string, int > reactionNamesMap
void getELifetimes(std::vector< double > &concs, std::vector< double > &constants, std::vector< double > &lifetimes)
double getCaptureLifetime(std::vector< double > &concs, std::vector< double > &constants, std::vector< int > &captureVect, double &concentration)
void getCaptureLifetimes(std::vector< double > &concs, std::vector< double > &constants, std::vector< int > &captureVect, double &concentration, std::vector< double > &lifetimes)
void setHoleEmissionCalc(const std::string &name, double sigma, double E)
void setName(const std::string &name)
void setElectronCaptureCalc(const std::string &name, double sigma)
void unscaleRateConstantFromCalculator(const std::string &name)
const std::string & getSpeciesName(int i)
std::vector< std::pair< std::string, double > > initialConditions
void getDdt(std::vector< double > &concs, std::vector< double > &constants, std::vector< double > &ddt)
void setSimpleCalc(const std::string &name, double k)
const std::string & getConstantsName(int i)
const T & value(const ParameterBase &entity, const Descriptor &descriptor)
Returns the value of the parameter for the entity.
Definition: N_DEV_Pars.h:1224
void addReactant(const std::string &name, const std::string &reactant, double stoich)
void setEmissionRateCalculator(double sigma, double v, double N, double Energy, double C0, double t0, double x0)
void getJacobianVC(std::vector< double > &concs, std::vector< double > &constants, std::vector< std::vector< double > > &jac, std::vector< double > &constVec)
double getRate(std::vector< double > &concs, std::vector< double > &constants, std::vector< int > &captureVect, std::vector< int > &emissionVect)
std::map< std::string, int > speciesMap
void addMasterSourceTerm(const std::string &speciesName)
void setComplexCalc(const std::string &name)
void setFDElectronEmissionCalc(const std::string &name, double sigma, double E)
Reaction & getReaction(const std::string &name)
void setDecomplexCalc(const std::string &name, double bindingEnergy, double gammaAB, double gammaA, double gammaB, double concSi)
std::vector< Reaction > theReactions
double getDiffusionCoefficient(const std::string &name, const double temp)
double getERate(std::vector< double > &concs, std::vector< double > &constants)
void getDHRateDC(std::vector< double > &concs, std::vector< double > &constants, std::vector< double > &dratedc)
void setCaptureCalc(const std::string &name, double sigma, double v)
void getDERateDC(std::vector< double > &concs, std::vector< double > &constants, std::vector< double > &dratedc)
std::vector< int > electronEmissionReactions
void getHLifetimes(std::vector< double > &concs, std::vector< double > &constants, std::vector< double > &lifetimes)
bool constantExist(const std::string &name)
void setElectronEmissionCalc(const std::string &name, double sigma, double E)
void setDecomplexRateCalculator(std::vector< Specie > &VariableSpecies, std::vector< Specie > &ConstantSpecies, double bindingEnergy, double gammaAB, double gammaA, double gammaB, double concSi, double C0, double t0, double x0)
void getJac(std::vector< double > &concs, std::vector< double > &constants, std::vector< std::vector< double > > &jac)
void setHoleCaptureCalc(const std::string &name, double sigma)
void getDFdConst(const std::string &constantName, std::vector< double > &concs, std::vector< double > &constants, std::vector< double > &dFdConst)
void setMaterial(MaterialLayer *material, double Temp)
void addReaction(const std::string &name)
void setEmissionCalc(const std::string &name, double sigma, double v, double N, double E)
void setBourgoinCorbettHoleCalc(const std::string &name, double sigma)
void setConstants(std::vector< Specie > &theConstantsVect)
void setRxnVariableCoeffs(bool variableCoeffs)
void scaleRateConstantFromCalculator(const std::string &name)
void setCaptureRateCalculator(double sigma, double v, double C0, double t0, double x0)
void setSpecies(std::vector< Specie > &theSpeciesVect)
std::vector< int > electronCaptureReactions
std::vector< std::string > reactionNames
int getSpeciesNum(const std::string &name)
void setFDHoleEmissionCalc(const std::string &name, double sigma, double E)
std::pair< std::string, double > getInitialCondition(int i)
void setComplexMultiplierCalc(const std::string &name, double multiplier)
void setRateConstantFromCalculator(const std::string &name, double T)
void addSpecie(const Specie &aSpecie)
void setBourgoinCorbettHoleRateCalculator(std::vector< Specie > &VariableSpecies, std::vector< Specie > &ConstantSpecies, double sigma, double C0, double t0, double x0)
int getReactantNum(const std::string &name)
int getConstantNum(const std::string &name)
std::map< std::string, int > constantsMap
void setRateConstant(const std::string &name, double k)
ReactionNetwork(const std::string &name="NoName")
void addProduct(const std::string &name, const std::string &reactant, double stoich)
int getReactionNum(const std::string name)
void setReactionNetworkFromFile(const NetlistLocation &netlist_location, const std::string &fileName)
void getDRateDC(std::vector< double > &concs, std::vector< double > &constants, std::vector< int > &captureVect, std::vector< int > &emissionVect, std::vector< double > &dratedc)
void addSourceTerm(const std::string &speciesName, const std::string &expressionStr)
void addInitialCondition(const std::string &speciesName, double value)
std::ostream & operator<<(std::ostream &os, const Configuration &configuration)
Definition: N_DEV_Dump.C:134
void setComplexRateCalculator(std::vector< Specie > &VariableSpecies, std::vector< Specie > &ConstantSpecies, double C0, double t0, double x0)