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.8.2.1 $
46 //
47 // Revision Date : $Date: 2014/02/26 20:16:30 $
48 //
49 // Current Owner : $Author: tvrusso $
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 scaleRateConstant(double);
77  void setReactants(std::vector< std::pair<int,double> > &products );
78  void addReactant(int species,double stoich);
79  void setProducts(std::vector< std::pair<int,double> > &products );
80  void addProduct(int species,double stoich);
81  double getRate(std::vector<double> &concentrations,
82  std::vector<double> &constants);
83  void getDdt(std::vector<double> &concentrations,
84  std::vector<double> &constants,
85  std::vector<double> &ddt);
86  void getDRateDC(std::vector<double> &concentrations,
87  std::vector<double> &constants,
88  std::vector<double> &dratedc);
89  void getDRateDConst(int constNum,
90  std::vector<double> &concentrations,
91  std::vector<double> &constants,
92  double &dratedc);
93  void getJac(std::vector<double> &concentrations,
94  std::vector<double> &constants,
95  std::vector<std::vector<double> > &jac);
96  void getDFdConst(int constantNumber,
97  std::vector<double> &concentrations,
98  std::vector<double> &constants,
99  std::vector<double> &dFdConst);
100 
101  void output ( const std::vector<Specie> & species,
102  std::ostream & os ) const;
103 
104  void setSimpleRateCalculator(double k, double C0, double t0, double x0);
105  void setCaptureRateCalculator(double sigma, double v, double C0, double t0,
106  double x0);
107  void setEmissionRateCalculator(double sigma, double v, double N,
108  double Energy, double C0, double t0,
109  double x0);
110  void setComplexRateCalculator(std::vector<Specie> &VariableSpecies,
111  std::vector<Specie> &ConstantSpecies,
112  double C0, double t0, double x0);
113  void setDecomplexRateCalculator(std::vector<Specie> &VariableSpecies,
114  std::vector<Specie> &ConstantSpecies,
115  double bindingEnergy,
116  double gammaAB, double gammaA, double gammaB,
117  double concSi,
118  double C0, double t0, double x0);
119 
120  inline void setScaleFactors(double C0, double t0, double x0)
121  {
122  if (myRateCalc)
123  myRateCalc->setScaleFactors(C0,t0,x0);
124  };
125 
126  Reaction & operator=(const Reaction & right);
127 
128 private:
129  void setDependency(int cSize);
130  void setConstDependency(int cSize);
131  std::vector< std::pair<int,double> > theReactants;
132  std::vector< std::pair<int,double> > theProducts;
134  int numconcs; // size of vector of concentrations
135  int numconsts; // size of vector of constants
136  std::vector<int> concDependency;
137  std::vector<int> constDependency;
139 
140 
141 };
142 
143 //-----------------------------------------------------------------------------
144 // Function : Reaction::setRateConstant
145 // Purpose : Accessor function to set rate constant
146 // Special Notes :
147 // Scope : public
148 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
149 // Creation Date : 3/20/06
150 //-----------------------------------------------------------------------------
151 inline void Reaction::setRateConstant(double rateConst)
152 {
153  theRateConstant=rateConst;
154 }
155 
156 //-----------------------------------------------------------------------------
157 // Function : Reaction::scaleRateConstant
158 // Purpose : Accessor function to scale rate constant
159 // Special Notes :
160 // Scope : public
161 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
162 // Creation Date : 3/20/06
163 //-----------------------------------------------------------------------------
164 inline void Reaction::scaleRateConstant(double scalar)
165 {
166  theRateConstant *= scalar;
167 }
168 
169 } // namespace Device
170 } // namespace Xyce
171 
173 
174 #endif