Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_Reaction.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_Reaction.h,v $
27 //
28 // Purpose : Provide a generic class for reactions using simple
29 // law-of-mass-action kinetics, i.e.:
30 // A+2B+C -> D + 3E + F
31 // implies that the reaction happens at a rate:
32 // reactionRate = k*[A][B]^2[C]
33 // where [X] means "concentration of species X"
34 //
35 //
36 // Special Notes :
37 //
38 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
39 //
40 // Creation Date : 03/20/06
41 //
42 // Revision Information:
43 // ---------------------
44 //
45 // Revision Number: $Revision: 1.10 $
46 //
47 // Revision Date : $Date: 2014/05/01 22:27:13 $
48 //
49 // Current Owner : $Author: lcmusso $
50 //-----------------------------------------------------------------------------
51 
52 #ifndef N_DEV_REACTION_H
53 #define N_DEV_REACTION_H
54 #include <iosfwd>
55 #include <vector>
56 
57 #include <N_DEV_Specie.h>
59 
60 namespace Xyce {
61 namespace Device {
62 
63 class Reaction
64 {
65 public:
66  Reaction();
67  Reaction(std::vector< std::pair<int,double> > & ,
68  std::vector< std::pair<int,double> > &,
69  double);
70  Reaction(const Reaction &right);
71  ~Reaction();
72  void setRateConstant(double);
73  void setRateConstantFromCalculator(double T);
74  void setRateConstantFromCalculator(double T,
75  std::vector<double> &concs,
76  std::vector<double> &constant_vec);
77  void scaleRateConstant(double);
80  void setReactants(std::vector< std::pair<int,double> > &products );
81  void addReactant(int species,double stoich);
82  void setProducts(std::vector< std::pair<int,double> > &products );
83  void addProduct(int species,double stoich);
84  double getRate(std::vector<double> &concentrations,
85  std::vector<double> &constants);
86  void getDdt(std::vector<double> &concentrations,
87  std::vector<double> &constants,
88  std::vector<double> &ddt);
89  void getDRateDC(std::vector<double> &concentrations,
90  std::vector<double> &constants,
91  std::vector<double> &dratedc);
92  void getDRateDConst(int constNum,
93  std::vector<double> &concentrations,
94  std::vector<double> &constants,
95  double &dratedc);
96  void getJac(std::vector<double> &concentrations,
97  std::vector<double> &constants,
98  std::vector<std::vector<double> > &jac);
99  void getDFdConst(int constantNumber,
100  std::vector<double> &concentrations,
101  std::vector<double> &constants,
102  std::vector<double> &dFdConst);
103 
104  void output ( const std::vector<Specie> & species,
105  std::ostream & os ) const;
106 
107  void setSimpleRateCalculator(double k, double C0, double t0, double x0);
108  void setCaptureRateCalculator(double sigma, double v, double C0, double t0,
109  double x0);
110  void setEmissionRateCalculator(double sigma, double v, double N,
111  double Energy, double C0, double t0,
112  double x0);
113  void setComplexRateCalculator(std::vector<Specie> &VariableSpecies,
114  std::vector<Specie> &ConstantSpecies,
115  double C0, double t0, double x0);
116  void setDecomplexRateCalculator(std::vector<Specie> &VariableSpecies,
117  std::vector<Specie> &ConstantSpecies,
118  double bindingEnergy,
119  double gammaAB, double gammaA, double gammaB,
120  double concSi,
121  double C0, double t0, double x0);
122 
123  void setBourgoinCorbettHoleRateCalculator(std::vector<Specie> &VariableSpecies,
124  std::vector<Specie> &ConstantSpecies,
125  double sigma,double C0, double t0, double x0);
126 
127  inline void setScaleFactors(double C0, double t0, double x0)
128  {
129  if (myRateCalc)
130  myRateCalc->setScaleFactors(C0,t0,x0);
131  };
132 
133  Reaction & operator=(const Reaction & right);
134 
135 private:
136  void setDependency(int cSize);
137  void setConstDependency(int cSize);
138  std::vector< std::pair<int,double> > theReactants;
139  std::vector< std::pair<int,double> > theProducts;
141  int numconcs; // size of vector of concentrations
142  int numconsts; // size of vector of constants
143  std::vector<int> concDependency;
144  std::vector<int> constDependency;
146 
147 
148 };
149 
150 //-----------------------------------------------------------------------------
151 // Function : Reaction::setRateConstant
152 // Purpose : Accessor function to set rate constant
153 // Special Notes :
154 // Scope : public
155 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
156 // Creation Date : 3/20/06
157 //-----------------------------------------------------------------------------
158 inline void Reaction::setRateConstant(double rateConst)
159 {
160  theRateConstant=rateConst;
161 }
162 
163 //-----------------------------------------------------------------------------
164 // Function : Reaction::scaleRateConstant
165 // Purpose : Accessor function to scale rate constant
166 // Special Notes :
167 // Scope : public
168 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
169 // Creation Date : 3/20/06
170 //-----------------------------------------------------------------------------
171 inline void Reaction::scaleRateConstant(double scalar)
172 {
173  theRateConstant *= scalar;
174 }
175 
176 } // namespace Device
177 } // namespace Xyce
178 
180 
181 #endif