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