Xyce  6.1
N_DEV_DiodePDE.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 //-----------------------------------------------------------------------------
27 // Filename : $RCSfile: N_DEV_DiodePDE.h,v $
28 //
29 // Purpose : This file contains the classes neccessary for a PDE
30 // based diode simulation.
31 //
32 // Special Notes :
33 //
34 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
35 //
36 // Creation Date : 02/28/00
37 //
38 // Revision Information:
39 // ---------------------
40 //
41 // Revision Number: $Revision: 1.98.2.1 $
42 //
43 // Revision Date : $Date: 2015/04/02 18:20:12 $
44 //
45 // Current Owner : $Author: tvrusso $
46 //-----------------------------------------------------------------------------
47 
48 #ifndef Xyce_N_DEV_DiodePDE_h
49 #define Xyce_N_DEV_DiodePDE_h
50 
51 // ---------- Xyce Includes ----------
52 #include <N_UTL_fwd.h>
53 #include <N_DEV_fwd.h>
54 
55 #include <N_DEV_CompositeParam.h>
56 #include <N_DEV_Configuration.h>
57 #include <N_DEV_Configuration.h>
58 #include <N_DEV_DeviceBlock.h>
60 #include <N_DEV_DevicePDEModel.h>
61 #include <N_DEV_MaterialLayer.h>
62 #include <N_DEV_PDE_Electrode.h>
63 #include <N_DEV_Param.h>
64 #include <N_DEV_bcData.h>
65 #include <N_UTL_Expression.h>
66 
67 namespace Xyce {
68 namespace Device {
69 namespace DiodePDE {
70 
71 class Model;
72 class Instance;
73 
74 struct Traits : public DeviceTraits<Model, Instance>
75 {
76  static const char *name() {return "1D PDE (level 1)";}
77  static const char *deviceTypeName() {return "PDE level 1";}
78  static int numNodes() {return 2;}
79  static int numOptionalNodes() {return 100;}
80  static bool modelRequired() {return true;}
81  static bool isPDEDevice() {return true;}
82  static bool isLinearDevice() {return false;}
83 
84  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
85  static void loadModelParameters(ParametricData<Model> &model_parameters);
86  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
87 };
88 
89 //-----------------------------------------------------------------------------
90 // Class : Instance
91 // Purpose : Instance class for DiodePDE.
92 //
93 // Special Notes :6
94 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
95 // Creation Date : 6/29/00
96 //-----------------------------------------------------------------------------
98 {
99  friend class Model;
100  friend class ParametricData<Instance>;
101  friend class Traits;
102 
103 public:
104  Instance(
105  const Configuration & configuration,
106  const InstanceBlock & IB,
107  Model & model,
108  const FactoryBlock & factory_block);
109 
110  Instance(const Instance &right);
111  ~Instance();
112 
113  CompositeParam *constructComposite (const std::string & ccompositeName, const std::string & paramName);
114 
115  void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
116 
117  void registerLIDs( const std::vector<int> & intLIDVecRef,
118  const std::vector<int> & extLIDVecRef );
119  void registerStateLIDs( const std::vector<int> & staLIDVecRef );
120 
121  const std::vector< std::vector<int> > & jacobianStamp() const;
122  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
123 
124  void setupPointers();
125 
126  bool processParams ();
127 
128  bool doAllocations ();
129  bool setupNodes ();
130 
131  bool setupNumVars ();
132 
133  bool setupJacStamp ();
134  bool cleanupJacStamp ();
135 
136  bool updateIntermediateVars ();
137  bool updatePrimaryState ();
138  bool updateSecondaryState ();
139 
140  void loadErrorWeightMask ();
141 
142  // functions that are used by both new-DAE and old-DAE:
143  bool loadVecNLPoisson (double * rhs);
144  bool loadMatNLPoisson (Linear::Matrix & mat);
145  bool loadMatKCLDDForm (Linear::Matrix & mat);
146  bool loadMatDDForm (Linear::Matrix & mat);
147  bool loadVecDDForm (double * rhs);
148  bool loadMatCktTrivial (Linear::Matrix & mat);
149  // end of the "both" DAE functions.
150 
151  bool setInitialGuess ();
152  bool loadRHSNonlinPoisson ();
153  bool loadRHSDDFormulation ();
155 
156  bool getInstanceBreakPoints( std::vector<Util::BreakPoint> &breakPointTimes);
157 
158  bool plotfileFlag () {return true;}
159 
160  bool loadJacNonlinPoisson ();
161  bool loadJacKCLDDFormulation ();
162  bool loadJacDDFormulation ();
164 
165  // load functions, residual:
166  bool loadDAEQVector ();
167  bool loadDAEQDDFormulation ();
169 
170  bool loadDAEFVector ();
171  bool loadDAEFNonlinPoisson ();
172  bool loadDAEFDDFormulation ();
174 
175  // load functions, Jacobian:
176  bool loadDAEdQdx ();
177 
178  bool loadDAEdQdxDDFormulation ();
180 
181  bool loadDAEdFdx ();
182  bool loadDAEdFdxNonlinPoisson ();
183  bool loadDAEdFdxDDFormulation ();
185 
186  bool calcLifetimes ();
187  bool calcMobilities ();
188  bool updateTemperature(const double & temp_tmp);
189  bool calcVoltDepDensities ();
190 
191  bool setEH_inChemistry ();
192 
193  bool setupSourceProfile ();
194 
195  bool setupDopingProfile ();
196  bool calcDopingProfile ();
197 
198  bool setupDefaultLayer ();
199  bool setupMesh ();
200  bool setupMaterialArrays ();
201  bool calcInitialGuess ();
202  bool obtainSolution ();
203  bool obtainNodeVoltages ();
204  bool applyVoltageLimiting ();
205  bool calcVequBCs ();
206  bool calcDensityBCs ();
207  bool calcBoundaryConditions ();
208  bool setupMiscConstants ();
209  bool setupScalingVars ();
210  bool scaleVariables ();
211  bool unScaleVariables ();
212 
213  bool calcRecombination ();
214  bool calcElectronCurrent ();
215  bool calcHoleCurrent ();
216  bool calcEfield ();
217 
218  bool calcTerminalCurrents ();
219  bool calcConductance (int iElectrode, const Linear::Vector * dxdvPtr);
220  bool calcDXDV ();
221  bool loadDFDV (int ielectrode, Linear::Vector * dfdvPtr);
222 
223  bool pdRecombination ();
224  bool pdElectronCurrent ();
225  bool pdHoleCurrent ();
226  bool pdTerminalCurrents ();
227 
228  bool outputTecplot ();
229  bool outputSgplot ();
230 
231  bool enablePDEContinuation(int &max_PDE_continuation_steps);
232  bool disablePDEContinuation ();
233  void setPDEContinuationAlpha (double alpha);
234 
235  // bool continuationStatus();
236  // void changeContinuationStepSize(double scale);
237  // void updateOldContinuationParam();
238 
239  bool outputPlotFiles ();
240 
241 public:
242  // iterator reference to the resistor model which owns this instance.
243  // Getters and setters
245  {
246  return model_;
247  }
248 
249 private:
250 
251  Model & model_; //< Owning model
252 
259 
264 
265  // physical constants:
266 
267  double Emax; // maximum electric field (V/cm)
268 
269  double VminExp; // maximum potential (V), used in exponential expressions
270  double VmaxExp; // minimum potential (V), used in exponential expressions
271 
272  double diodeCap; // estimated diode capacitance (F)
273 
274  double LeadCurrent;
275 
276  // inputted doping profiles.
277  // pdope is often phosphorus
278  std::vector<double> xloc_pdope_vec;
279  std::vector<double> pdope_vec;
280  std::vector<double> y2_pdope_vec;
281 
282  // ndope is often boron.
283  std::vector<double> xloc_ndope_vec;
284  std::vector<double> ndope_vec;
285  std::vector<double> y2_ndope_vec;
286 
287  // source file arrays
288  std::vector<double> xloc_source_vec;
289  std::vector<double> source_vec;
290  std::vector<double> y2_source_vec;
291 
292  // temp spline arrays:
293  std::vector<double> xlocVec;
294  std::vector<double> specVec;
295  std::vector<double> y2Vec;
296 
297  // new doping/initial condition storage:
298  std::map<std::string, std::vector<double> > xlocMap;
299  std::map<std::string, std::vector<double> > specMap;
300 
301  // vector of electrode data:
302  std::map<std::string, PDE_1DElectrode*> electrodeMap;
303 
304  // boundary condition array. probably will be of size 2 or 3.
305  std::vector<bcData> bcVec;
306 
307  std::map<std::string,int> bcIndexMap;
308 
309  // doping profile constants:
310  double Na; // acceptor concentration on p-side (cm^-3)
311  double Nd; // donor concentration on n-side (cm^-3)
312  double WJ; // linearly graded junction width (cm)
313  double XC; // center of graded junction (cm)
314  double XL; // start of graded junction (cm)
315  double XR; // end of graded junction (cm)
316 
317  // boundary condition variables:
318  // These should eventually replace Nd and Na.
319  double NnMax; // maximum electron concentration
320  double NpMax; // maximum hole concentration.
321  double NnMin; // maximum electron concentration
322  double NpMin; // maximum hole concentration.
323 
324  // mesh constants:
325  int NX; // number of x mesh points
326  int LX; // index of last x point.
327 
328  bool NXGiven;
329 
330  // continuation parameters:
331  double maxVoltDelta;
333 
334  // option to use the old intrinsic calculation, to maintain backward compatibility.
335  bool useOldNi;
337 
338  // some 2D mesh stuff - mostly to catch netlist mistakes (as this is a 1D device model)
339  std::string meshFileName;
340 
341  // doping files.
342  std::string dopingFileName;
343  std::string ndopeFileName;
344  std::string pdopeFileName;
345 
346  // diode width:
347  double width;
348  double length;
349 
352 
353  // diode cross sectional area:
354  double area;
355 
356  // boundary condition variables. These are superceded by
357  // the data in the bcVec and PDE_1DElectrode structures.
358  double anodebc;
359  double cathodebc;
360  double emitterbc;
361  double collectorbc;
362  double basebc;
363 
364  double anodeArea;
365  double cathodeArea;
366 
367  double emitterArea;
369  double baseArea;
370 
371  double baseLocation;
373 
377  int callsOSG;
378 
380 
382 
388 
392 
396 
399  std::string tunnelingModelName;
400 
405 
406  int NUMRC; // number of row-column pairs.
407 
408  std::vector<double> displCurrent;
409 
410  std::vector<int> boundarySten;
411  std::vector<int> edgeBoundarySten;
412  std::vector<int> internalBoundarySten;
413  std::vector<int> heterojunctionSten;
414  std::vector<int> matIndex;
415  std::vector< std::pair<int,int> > heterojunctionBCs;
416 
417  std::vector<int> regBaseIndexVec;
418  std::vector<int> regNumSpecieVec;
419  std::vector<int> regElectronIndexVec;
420  std::vector<int> regHoleIndexVec;
421 
422  std::vector<double> dxVec; // mesh spacing.
423  std::vector<double> xVec; // mesh points.
424  std::vector<double> CVec; // doping
425  std::vector<double> CdonorVec; // doping
426  std::vector<double> CacceptorVec; // doping
427  std::vector<double> VVec; // electrostatic potential
428  std::vector<double> ExVec; // electric field, x-direction.
429 
430  std::vector<double> JnxVec; // electron current density
431  std::vector<double> JpxVec; // hole current density
432 
433  std::vector<double> RVec; // recombination.
434  std::vector<double> SVec; // radiation source term.
435 
436  std::vector<double> nnVec; // electron density
437  std::vector<double> npVec; // hole density
438 
439 #if 0
440  std::vector<double> unE_Vec; // mobility along edge, electron
441  std::vector<double> upE_Vec; // mobility along edge, hole
442 #else
443  std::vector<pdeFadType> unE_Vec; // mobility along edge, electron
444  std::vector<pdeFadType> upE_Vec; // mobility along edge, hole
445 #endif
446 
447  std::vector<double> tnVec; // spatially dependent lifetimes, electron
448  std::vector<double> tpVec; // spatially dependent lifetimes, hole
449 
450 
451  std::vector<double> NcVec; // conduction band DOS
452  std::vector<double> NvVec; // valance band DOS
453 
454  std::vector<double> EcVec; // conduction band
455  std::vector<double> EvVec; // valance band
456  std::vector<double> EcEffVec; // conduction band, including BGN
457  std::vector<double> EvEffVec; // valance band, including BGN
458 
459  std::vector<double> bgnCVec; // Band-gap narrowing, conduction band
460  std::vector<double> bgnVVec; // Band-gap narrowing, valance band
461 
462  std::vector<double> NiVec; // intrinsic concentration
463  std::vector<double> NiEffVec; // intrinsic concentration
464  std::vector<double> EiVec; // intrinsic Fermi-Level vector.
465  std::vector<double> EiEffVec; // intrinsic Fermi-Level vector.
466  std::vector<double> EfVec; // Fermi-Level vector.
467  std::vector<double> EfEffVec; // Fermi-Level vector.
468  std::vector<double> relPermVec; // relative Permittivity
469 
470  std::vector<std::string> bulkMaterialVec; // material
471 
472  // derivative arrays:
473 
474  std::vector<double> dRdpVec;
475  std::vector<double> dRdnVec;
476 
477  std::vector<double> dJndn1Vec;
478  std::vector<double> dJndn2Vec;
479  std::vector<double> dJndV1Vec;
480  std::vector<double> dJndV2Vec;
481  std::vector<double> dJndp1Vec;
482  std::vector<double> dJndp2Vec;
483 
484  std::vector<double> dJpdn1Vec;
485  std::vector<double> dJpdn2Vec;
486  std::vector<double> dJpdV1Vec;
487  std::vector<double> dJpdV2Vec;
488  std::vector<double> dJpdp1Vec;
489  std::vector<double> dJpdp2Vec;
490 
491  // LID indices.
492  std::vector<int> li_Vrowarray;
493  std::vector< std::vector<int> > li_Vcolarray;
494 
495  std::vector<int> li_Nrowarray;
496  std::vector< std::vector<int> > li_Ncolarray;
497 
498  std::vector<int> li_Prowarray;
499  std::vector< std::vector<int> > li_Pcolarray;
500 
501  // columns needed for coupledMode==2
502  std::vector< std::vector<int> > li_N_rxn_colarray;
503  std::vector< std::vector<int> > li_P_rxn_colarray;
504 
505  std::vector<int> li_stateDispl;
506 
507  // matrix pointers
508  std::vector< std::vector<double *> > fVmatPtr;
509  std::vector< std::vector<double *> > fNmatPtr;
510  std::vector< std::vector<double *> > fPmatPtr;
511  std::vector< std::vector<double *> > qVmatPtr;
512  std::vector< std::vector<double *> > qNmatPtr;
513  std::vector< std::vector<double *> > qPmatPtr;
514 
515  // map between a mesh point index and a list of nearest neighbors
516  // for that mesh point.
517  std::multimap< int, int* > meshNeighborMultiMap;
518 
519  // state variable arrays associated with displacement current.
520  std::vector<int> stateDispl;
521  std::vector<int> stateDispl_owned;
522 
525 
526  // 2d array of conductances, for 2-level "ckt phase" loads.
527  std::vector< std::vector<double> > condVec;
528 
529  // data related to DMA matrix loads.
530  std::vector<int> meshToLID;
531  std::vector< std::vector<int> > jacStamp;
532  std::vector<int> jacMap;
533  std::vector< std::vector<int> > jacMap2;
534 
536 
538  std::vector<MaterialLayer*> materialVec;
539 
541 };
542 
543 //-----------------------------------------------------------------------------
544 // Class : Model
545 // Purpose :
546 // Special Notes :
547 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
548 // Creation Date : 6/29/00
549 //-----------------------------------------------------------------------------
550 class Model : public DevicePDEModel
551 {
552  typedef std::vector<Instance *> InstanceVector;
553 
554  friend class Instance;
555  friend class ParametricData<Model>;
556  friend class Traits;
557 
558 public:
559  Model(
560  const Configuration & configuration,
561  const ModelBlock & MB,
562  const FactoryBlock & factory_block);
563  ~Model();
564 
565 private:
566  Model();
567  Model(const Model &);
568  Model &operator=(const Model &);
569 
570 public:
571  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
572 
573  virtual std::ostream &printOutInstances(std::ostream &os) const;
574 
575  bool processParams ();
576  bool processInstanceParams ();
577 
578 private:
579 
580 
581 public:
582  void addInstance(Instance *instance)
583  {
584  instanceContainer.push_back(instance);
585  }
586 
587 private:
588  std::vector<Instance*> instanceContainer;
589 };
590 
591 void registerDevice();
592 
593 } // namespace DiodePDE
594 } // namespace Device
595 } // namespace Xyce
596 
597 #endif
std::vector< double > source_vec
std::vector< double > y2_source_vec
std::vector< int > edgeBoundarySten
std::vector< pdeFadType > unE_Vec
std::vector< double > specVec
std::vector< double > bgnCVec
std::map< std::string, PDE_1DElectrode * > electrodeMap
std::map< std::string, std::vector< double > > xlocMap
std::vector< int > heterojunctionSten
std::vector< double > xloc_ndope_vec
std::vector< std::vector< double * > > fPmatPtr
std::map< std::string, std::vector< double > > specMap
std::vector< std::string > bulkMaterialVec
std::vector< double > dJndn1Vec
std::vector< double > dJpdp1Vec
std::vector< std::vector< double * > > fNmatPtr
std::vector< Instance * > InstanceVector
std::map< std::string, int > bcIndexMap
Pure virtual class to augment a linear system.
std::vector< std::vector< int > > li_N_rxn_colarray
bool loadMatDDForm(Linear::Matrix &mat)
std::vector< double > dJpdn2Vec
void addInstance(Instance *instance)
std::vector< double > relPermVec
bool updateTemperature(const double &temp_tmp)
std::vector< std::vector< double * > > fVmatPtr
std::vector< MaterialLayer * > materialVec
std::vector< int > regElectronIndexVec
std::vector< int > stateDispl_owned
std::vector< double > EfEffVec
std::vector< double > dJndn2Vec
std::vector< double > dJndp1Vec
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
std::vector< std::vector< double * > > qPmatPtr
std::vector< double > dRdpVec
std::vector< double > dJpdp2Vec
std::vector< std::vector< int > > li_P_rxn_colarray
bool loadMatNLPoisson(Linear::Matrix &mat)
std::vector< double > dJndV2Vec
std::vector< double > JnxVec
bool loadMatKCLDDForm(Linear::Matrix &mat)
std::vector< std::vector< double * > > qVmatPtr
const std::vector< std::vector< int > > & jacobianStamp() const
bool processParams()
processParams
std::vector< double > EvEffVec
std::vector< int > regNumSpecieVec
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
std::vector< Instance * > instanceContainer
std::vector< double > xloc_source_vec
std::vector< std::vector< int > > li_Vcolarray
virtual std::ostream & printOutInstances(std::ostream &os) const
bool enablePDEContinuation(int &max_PDE_continuation_steps)
std::vector< int > internalBoundarySten
std::vector< int > regBaseIndexVec
std::vector< double > xloc_pdope_vec
std::vector< double > dJndV1Vec
bool loadDFDV(int ielectrode, Linear::Vector *dfdvPtr)
std::vector< double > pdope_vec
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
std::vector< std::pair< int, int > > heterojunctionBCs
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
std::vector< double > dJpdV2Vec
std::vector< pdeFadType > upE_Vec
std::vector< double > EiEffVec
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
std::vector< double > dRdnVec
std::vector< double > dJpdn1Vec
std::vector< std::vector< int > > li_Pcolarray
static const char * name()
std::vector< double > ndope_vec
bool processInstanceParams()
processInstanceParams
CompositeParam * constructComposite(const std::string &ccompositeName, const std::string &paramName)
std::vector< double > xlocVec
Class Configuration contains device configuration data.
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
std::vector< double > dJpdV1Vec
std::vector< double > CdonorVec
std::vector< std::vector< double > > condVec
std::vector< double > bgnVVec
std::vector< double > CacceptorVec
bool calcConductance(int iElectrode, const Linear::Vector *dxdvPtr)
std::vector< double > dJndp2Vec
std::vector< double > displCurrent
std::vector< std::vector< int > > jacStamp
std::vector< double > EcEffVec
std::multimap< int, int * > meshNeighborMultiMap
static const char * deviceTypeName()
std::vector< double > y2_ndope_vec
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
std::vector< std::vector< double * > > qNmatPtr
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
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &model, const FactoryBlock &factory_block)
InstanceBlock represent a device instance line from the netlist.
std::vector< double > y2_pdope_vec
std::vector< std::vector< int > > li_Ncolarray
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
std::vector< double > JpxVec
Model & operator=(const Model &)
static void loadModelParameters(ParametricData< Model > &model_parameters)
bool loadMatCktTrivial(Linear::Matrix &mat)
bool getInstanceBreakPoints(std::vector< Util::BreakPoint > &breakPointTimes)
CompositeParam is the base class for classes that wish to only manage the processing of parameter dat...
std::vector< std::vector< int > > jacMap2
std::vector< double > NiEffVec
std::vector< int > regHoleIndexVec