Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_RxnSet.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_RxnSet.h,v $
27 //
28 // Purpose :
29 //
30 // Special Notes :
31 //
32 // Creator : Thomas V. Russo, SNL, Component Information and Models
33 //
34 // Creation Date : 08/19/04
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.25 $
40 //
41 // Revision Date : $Date: 2014/05/21 18:25:49 $
42 //
43 // Current Owner : $Author: dgbaur $
44 //-----------------------------------------------------------------------------
45 
46 #ifndef Xyce_N_DEV_RxnSet_h
47 #define Xyce_N_DEV_RxnSet_h
48 
49 // ---------- Standard Includes ----------
50 
51 // ---------- Xyce Includes ----------
52 #include <N_DEV_Configuration.h>
53 #include <N_DEV_fwd.h>
54 #include <N_DEV_DeviceBlock.h>
56 #include <N_DEV_DevicePDEModel.h>
57 #include <N_DEV_CompositeParam.h>
58 
59 #include <N_DEV_Param.h>
60 #include <N_UTL_BreakPoint.h>
61 #include <N_DEV_TransportHelper.h>
62 
63 namespace Xyce {
64 namespace Device {
65 
66 namespace RxnSet {
67 
68 class Model;
69 class Instance;
70 
71 struct Traits : public DeviceTraits<Model, Instance>
72 {
73  static const char *name() {return "Rxn Effects Device";}
74  static const char *deviceTypeName() {return "YRXN level 1 (Rxn Device)";};
75  static int numNodes() {return 2;}
76  static bool modelRequired() {return true;}
77  static bool isLinearDevice() {return false;}
78 
79  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
80  static void loadModelParameters(ParametricData<Model> &model_parameters);
81  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
82 };
83 
84 //-----------------------------------------------------------------------------
85 // Class : Instance
86 // Purpose : This class refers to a single instance of the BJT
87 // device. It contains indices into the matrix equation.
88 // See the comments for the ResistorInstance class for
89 // more details.
90 //
91 // The bjt will have 4 external nodes: collector, base,
92 // emitter, and substrate, and 3 internal nodes:
93 // collectorPrime, basePrime, and emitterPrime.
94 // Special Notes :
95 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
96 // Creation Date : 3/16/00
97 //-----------------------------------------------------------------------------
99 {
100  friend class ParametricData<Instance>;
101  friend class Model;
102  friend class Traits;
103 
104  // functions
105 public:
106 
107  Instance(
108  const Configuration & configuration,
109  const InstanceBlock & IB,
110  Model & it_MB,
111  const FactoryBlock & factory_block);
112 
113 
114  Instance(const Instance &right);
115 
116  ~Instance();
117 
118  void registerLIDs( const std::vector<int> & intLIDVecRef,
119  const std::vector<int> & extLIDVecRef );
120  void registerStateLIDs( const std::vector<int> & stateLIDVecRef );
121  std::map<int,std::string> & getIntNameMap ();
122 
123  const std::vector<std::string> & getDepSolnVars();
124 
125  const std::vector< std::vector<int> > & jacobianStamp() const;
126  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
127 
128  bool processParams ();
129  bool updateTemperature (const double & temp = -999.0 );
130 
131  bool getInstanceBreakPoints( std::vector<N_UTL_BreakPoint> &breakPointTimes);
132 
133  bool updateIntermediateVars ();
134  bool updatePrimaryState ();
135  bool updateSecondaryState ();
136 
137  bool loadDeviceMask ();
138 
139  bool plotfileFlag () {return true;}
140 
141  // load functions, residual:
142  bool loadDAEQVector ();
143  bool loadDAEFVector ();
144 
145  // load functions, Jacobian:
146  bool loadDAEdQdx ();
147  bool loadDAEdFdx ();
148 
149  // Debug related load functions for the Jacobian:
150  bool loadQMatrix (N_LAS_Matrix & dQdxMat);
151  bool loadFMatrix (N_LAS_Matrix & dFdxMat);
152 
153  // Debugging Excess Phase function, etc.
154  bool outputPlotFiles ();
155  bool outputTecplot ();
156  bool output2DTecplot ();
157  bool outputCarrierDensities ();
158 
159  void setupJacStamp ();
160 
161  void setupMeshUniform ();
162 
163  void allocateRegions ();
164 
165  void scaleMesh ();
166  void setupFluxVec ();
167 
168  void setupScalingVars ();
169  void initializeChemistry ();
170 
171  void setupPointers();
172 
173 public:
174  // Getters and setters
176  return model_;
177  }
178 
179 private:
180 
181  Model & model_; //< Owning model
182 
183 private:
184 
185  bool haveAnyReactions; // global haveAnyReactions flag for all regions.
189 
193 
198 
199  //external instance params
200  double TEMP; // instance temperature (TEMP)
201 
203 
204  //local indexing of solution and state variables
205  int li_Pos;
206  int li_Neg;
207 
208  // reaction region(s):
209  std::vector<Region*> regVec;
210 
211  std::vector<int> regLastIndexVec;
212  std::vector<int> regFirstReactantIndexVec;
213  std::vector<int> regNumSpecieVec;
214 
215  // these are relative indices for use in the jacStamp setup:
216  std::vector< std::vector<int> > APosEqu_SpeciesOffset;
217  std::vector< std::vector<int> > ANegEqu_SpeciesOffset;
218 
219  std::vector< std::vector<double *> > APosEqu_SpeciesPtr;
220  std::vector< std::vector<double *> > ANegEqu_SpeciesPtr;
221 
222  std::vector< std::vector<double *> > APosEqu_ConstPtr;
223  std::vector< std::vector<double *> > ANegEqu_ConstPtr;
224 
225  // mesh variables:
226  std::vector<double> xVec;
227  std::vector<double> dxVec;
228 
229  std::vector<int> xloStencilVec;
230  std::vector<int> xhiStencilVec;
231 
232  std::vector<TransportHelper> thVec;
233 
235 
236  // Offset variables corresponding to the above declared indices.
239 
242 
243  std::vector< std::vector<int> > jacStamp;
244  std::vector<int> jacMap;
245  std::vector< std::vector<int> > jacMap2;
246 
255 
256  int xloIndex;
257  int xhiIndex;
258 
260 };
261 
262 
263 //-----------------------------------------------------------------------------
264 // Class : Model
265 // Purpose :
266 // Special Notes :
267 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
268 // Creation Date : 3/16/00
269 //-----------------------------------------------------------------------------
270 class Model : public DevicePDEModel
271 {
272  typedef std::vector<Instance *> InstanceVector;
273 
274  friend class ParametricData<Model>;
275  friend class Instance;
276  friend class Traits;
277 
278 public:
279  Model(
280  const Configuration & configuration,
281  const ModelBlock & MB,
282  const FactoryBlock & factory_block);
283 
284  ~Model();
285 
286 private:
287  Model();
288  Model(const Model &);
289  Model &operator=(const Model &);
290 
291 public:
292  CompositeParam *constructComposite (const std::string & cName, const std::string & pName);
293 
294  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
295 
296  virtual std::ostream &printOutInstances(std::ostream &os) const;
297 
298  bool processParams ();
299  bool processInstanceParams ();
300 
301 
302 public:
303  void addInstance(Instance *instance) {
304  instanceContainer.push_back(instance);
305  }
306 
307 private:
308  std::vector<Instance*> instanceContainer;
309 
310 private:
311 
312  //external model params
313  double TNOM; //nominal temperature
314 
316 
317  // File name for reaction specification:
318  std::string rxnFileName;
319 
320  //*************************************
321  // Rxn reaction model stuff:
322  double xlo;
323  double xhi;
324 
325  double xlo_source; // source region, low bound
326  double xhi_source; // source region, high bound
329 
330  std::vector<RegionData*> regionDataVec;
331  std::map<std::string,CompositeParam *> regionDataMap;
332  std::map<std::string,SpecieSource *> defectSourceMap;
333 
334  double masterSource;
335 };
336 
337 void registerDevice();
338 
339 } // namespace RxnSet
340 } // namespace Device
341 } // namespace Xyce
342 
345 
346 #endif