Xyce  6.1
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-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_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.35 $
40 //
41 // Revision Date : $Date: 2015/10/14 19:31:37 $
42 //
43 // Current Owner : $Author: tvrusso $
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_fwd.h>
53 #include <N_UTL_fwd.h>
54 
55 #include <N_DEV_CompositeParam.h>
56 #include <N_DEV_Configuration.h>
57 #include <N_DEV_DeviceBlock.h>
59 #include <N_DEV_DevicePDEModel.h>
60 #include <N_DEV_Param.h>
61 #include <N_DEV_TransportHelper.h>
62 #include <N_DEV_MaterialLayer.h>
63 
64 namespace Xyce {
65 namespace Device {
66 
67 namespace RxnSet {
68 
69 class Model;
70 class Instance;
71 
72 struct Traits : public DeviceTraits<Model, Instance>
73 {
74  static const char *name() {return "Rxn Effects Device";}
75  static const char *deviceTypeName() {return "YRXN level 1 (Rxn Device)";};
76  static int numNodes() {return 2;}
77  static bool modelRequired() {return true;}
78  static bool isLinearDevice() {return false;}
79 
80  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
81  static void loadModelParameters(ParametricData<Model> &model_parameters);
82  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
83 };
84 
85 //-----------------------------------------------------------------------------
86 // Class : Instance
87 // Purpose : This class refers to a single instance of the BJT
88 // device. It contains indices into the matrix equation.
89 // See the comments for the ResistorInstance class for
90 // more details.
91 //
92 // The bjt will have 4 external nodes: collector, base,
93 // emitter, and substrate, and 3 internal nodes:
94 // collectorPrime, basePrime, and emitterPrime.
95 // Special Notes :
96 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
97 // Creation Date : 3/16/00
98 //-----------------------------------------------------------------------------
100 {
101  friend class ParametricData<Instance>;
102  friend class Model;
103  friend class Traits;
104 
105  // functions
106 public:
107 
108  Instance(
109  const Configuration & configuration,
110  const InstanceBlock & IB,
111  Model & it_MB,
112  const FactoryBlock & factory_block);
113 
114 
115  Instance(const Instance &right);
116 
117  ~Instance();
118 
119  void registerLIDs( const std::vector<int> & intLIDVecRef,
120  const std::vector<int> & extLIDVecRef );
121  void registerStateLIDs( const std::vector<int> & stateLIDVecRef );
122 
123  void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
124 
125  const std::vector<std::string> & getDepSolnVars();
126 
127  const std::vector< std::vector<int> > & jacobianStamp() const;
128  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
129 
130  bool processParams ();
131  bool updateTemperature (const double & temp = -999.0 );
132 
133  bool getInstanceBreakPoints( std::vector<Util::BreakPoint> &breakPointTimes);
134 
135  bool updateIntermediateVars ();
136  bool updatePrimaryState ();
137  bool updateSecondaryState ();
138 
139  void loadErrorWeightMask ();
140 
141  bool plotfileFlag () {return true;}
142 
143  // load functions, residual:
144  bool loadDAEQVector ();
145  bool loadDAEFVector ();
146 
147  // load functions, Jacobian:
148  bool loadDAEdQdx ();
149  bool loadDAEdFdx ();
150 
151  // Debug related load functions for the Jacobian:
152  bool loadQMatrix (Linear::Matrix & dQdxMat);
153  bool loadFMatrix (Linear::Matrix & dFdxMat);
154 
155  // Debugging Excess Phase function, etc.
156  bool outputPlotFiles(bool force_final_output);
157  bool outputTecplot ();
158  bool output2DTecplot ();
159  bool outputCarrierDensities ();
160 
161  void setupJacStamp ();
162 
163  void setupMeshUniform ();
164 
165  void allocateRegions ();
166 
167  void scaleMesh ();
168  void setupFluxVec ();
169 
170  void setupScalingVars ();
171  void initializeChemistry ();
172 
173  void setupPointers();
174 
175 public:
176  // Getters and setters
178  {
179  return model_;
180  }
181 
182 private:
183 
184  Model & model_; //< Owning model
185 
186 private:
187 
188  bool haveAnyReactions; // global haveAnyReactions flag for all regions.
192 
196 
201 
202  //external instance params
203  double TEMP; // instance temperature (TEMP)
204 
205  //local indexing of solution and state variables
206  int li_Pos;
207  int li_Neg;
208 
209  // reaction region(s):
210  std::vector<Region*> regVec;
211 
212  std::vector<int> regLastIndexVec;
213  std::vector<int> regFirstReactantIndexVec;
214  std::vector<int> regNumSpecieVec;
215 
216  // these are relative indices for use in the jacStamp setup:
217  std::vector< std::vector<int> > APosEqu_SpeciesOffset;
218  std::vector< std::vector<int> > ANegEqu_SpeciesOffset;
219 
220  std::vector< std::vector<double *> > APosEqu_SpeciesPtr;
221  std::vector< std::vector<double *> > ANegEqu_SpeciesPtr;
222 
223  std::vector< std::vector<double *> > APosEqu_ConstPtr;
224  std::vector< std::vector<double *> > ANegEqu_ConstPtr;
225 
226  // mesh variables:
227  std::vector<double> xVec;
228  std::vector<double> dxVec;
229 
230  std::vector<int> xloStencilVec;
231  std::vector<int> xhiStencilVec;
232 
233  std::vector<TransportHelper> thVec;
234 
236 
237  // Offset variables corresponding to the above declared indices.
240 
243 
244  std::vector< std::vector<int> > jacStamp;
245  std::vector<int> jacMap;
246  std::vector< std::vector<int> > jacMap2;
247 
256 
257  int xloIndex;
258  int xhiIndex;
259 
261 
262  void resolveMaterialModel();
263 };
264 
265 
266 //-----------------------------------------------------------------------------
267 // Class : Model
268 // Purpose :
269 // Special Notes :
270 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
271 // Creation Date : 3/16/00
272 //-----------------------------------------------------------------------------
273 class Model : public DevicePDEModel
274 {
275  typedef std::vector<Instance *> InstanceVector;
276 
277  friend class ParametricData<Model>;
278  friend class Instance;
279  friend class Traits;
280 
281 public:
282  Model(
283  const Configuration & configuration,
284  const ModelBlock & MB,
285  const FactoryBlock & factory_block);
286 
287  ~Model();
288 
289 private:
290  Model();
291  Model(const Model &);
292  Model &operator=(const Model &);
293 
294 public:
295  CompositeParam *constructComposite (const std::string & cName, const std::string & pName);
296 
297  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
298 
299  virtual std::ostream &printOutInstances(std::ostream &os) const;
300 
301  bool processParams ();
302  bool processInstanceParams ();
303 
304 
305 public:
306  void addInstance(Instance *instance)
307  {
308  instanceContainer.push_back(instance);
309  }
310 
311 private:
312  std::vector<Instance*> instanceContainer;
313 
314 private:
315 
316  //external model params
317  double TNOM; //nominal temperature
318 
320 
321  // File name for reaction specification:
322  std::string rxnFileName;
323 
324  //*************************************
325  // Rxn reaction model stuff:
326  double xlo;
327  double xhi;
328 
329  double xlo_source; // source region, low bound
330  double xhi_source; // source region, high bound
333 
334  std::vector<RegionData*> regionDataVec;
335  std::map<std::string,CompositeParam *> regionDataMap;
336  std::map<std::string,SpecieSource *> defectSourceMap;
337 
338  double masterSource;
339 
340  //LCM
342  std::vector<MaterialLayer*> materialVec;
343 };
344 
345 void registerDevice();
346 
347 } // namespace RxnSet
348 } // namespace Device
349 } // namespace Xyce
350 
351 #endif
std::vector< double > xVec
Definition: N_DEV_RxnSet.h:227
bool outputPlotFiles(bool force_final_output)
Definition: N_DEV_RxnSet.C:970
std::vector< MaterialLayer * > materialVec
Definition: N_DEV_RxnSet.h:342
std::vector< std::vector< double * > > APosEqu_ConstPtr
Definition: N_DEV_RxnSet.h:223
std::vector< std::vector< int > > jacStamp
Definition: N_DEV_RxnSet.h:244
bool loadQMatrix(Linear::Matrix &dQdxMat)
std::vector< std::vector< double * > > APosEqu_SpeciesPtr
Definition: N_DEV_RxnSet.h:220
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
Pure virtual class to augment a linear system.
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
bool processInstanceParams()
processInstanceParams
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
std::vector< int > regFirstReactantIndexVec
Definition: N_DEV_RxnSet.h:213
void addInstance(Instance *instance)
Definition: N_DEV_RxnSet.h:306
virtual std::ostream & printOutInstances(std::ostream &os) const
std::map< std::string, SpecieSource * > defectSourceMap
Definition: N_DEV_RxnSet.h:336
std::vector< std::vector< double * > > ANegEqu_ConstPtr
Definition: N_DEV_RxnSet.h:224
const std::vector< std::string > & getDepSolnVars()
std::vector< RegionData * > regionDataVec
Definition: N_DEV_RxnSet.h:334
std::vector< int > xhiStencilVec
Definition: N_DEV_RxnSet.h:231
CompositeParam * constructComposite(const std::string &cName, const std::string &pName)
const std::vector< std::vector< int > > & jacobianStamp() const
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
bool loadFMatrix(Linear::Matrix &dFdxMat)
std::map< std::string, CompositeParam * > regionDataMap
Definition: N_DEV_RxnSet.h:335
std::vector< std::vector< int > > ANegEqu_SpeciesOffset
Definition: N_DEV_RxnSet.h:218
std::vector< std::vector< int > > jacMap2
Definition: N_DEV_RxnSet.h:246
std::vector< std::vector< double * > > ANegEqu_SpeciesPtr
Definition: N_DEV_RxnSet.h:221
std::vector< Instance * > instanceContainer
Definition: N_DEV_RxnSet.h:312
std::vector< int > xloStencilVec
Definition: N_DEV_RxnSet.h:230
std::vector< std::vector< int > > APosEqu_SpeciesOffset
Definition: N_DEV_RxnSet.h:217
static void loadModelParameters(ParametricData< Model > &model_parameters)
Definition: N_DEV_RxnSet.C:158
bool processParams()
processParams
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
Class Configuration contains device configuration data.
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &it_MB, const FactoryBlock &factory_block)
Definition: N_DEV_RxnSet.C:238
std::vector< Instance * > InstanceVector
Definition: N_DEV_RxnSet.h:275
virtual void forEachInstance(DeviceInstanceOp &op) const
static const char * name()
Definition: N_DEV_RxnSet.h:74
std::vector< double > dxVec
Definition: N_DEV_RxnSet.h:228
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Definition: N_DEV_RxnSet.C:80
void registerStateLIDs(const std::vector< int > &stateLIDVecRef)
static const char * deviceTypeName()
Definition: N_DEV_RxnSet.h:75
std::vector< TransportHelper > thVec
Definition: N_DEV_RxnSet.h:233
std::vector< int > regLastIndexVec
Definition: N_DEV_RxnSet.h:212
std::vector< Region * > regVec
Definition: N_DEV_RxnSet.h:210
bool getInstanceBreakPoints(std::vector< Util::BreakPoint > &breakPointTimes)
Model & operator=(const Model &)
ModelBlock represents a .MODEL line from the netlist.
The DeviceTraits template describes the configuration of a device.
Manages parameter binding for class C.
Definition: N_DEV_Pars.h:214
InstanceBlock represent a device instance line from the netlist.
std::vector< int > regNumSpecieVec
Definition: N_DEV_RxnSet.h:214
CompositeParam is the base class for classes that wish to only manage the processing of parameter dat...
bool updateTemperature(const double &temp=-999.0)