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.101 $
42 //
43 // Revision Date : $Date: 2015/04/27 17:50:45 $
44 //
45 // Current Owner : $Author: erkeite $
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 
153  bool getInstanceBreakPoints( std::vector<Util::BreakPoint> &breakPointTimes);
154 
155  bool plotfileFlag () {return true;}
156 
157  // load functions, residual:
158  bool loadDAEQVector ();
159  bool loadDAEQDDFormulation ();
161 
162  bool loadDAEFVector ();
163  bool loadDAEFNonlinPoisson ();
164  bool loadDAEFDDFormulation ();
166 
167  // load functions, Jacobian:
168  bool loadDAEdQdx ();
169 
170  bool loadDAEdQdxDDFormulation ();
172 
173  bool loadDAEdFdx ();
174  bool loadDAEdFdxNonlinPoisson ();
175  bool loadDAEdFdxDDFormulation ();
177 
178  bool calcLifetimes ();
179  bool calcMobilities ();
180  bool updateTemperature(const double & temp_tmp);
181  bool calcVoltDepDensities ();
182 
183  bool setEH_inChemistry ();
184 
185  bool setupSourceProfile ();
186 
187  bool setupDopingProfile ();
188  bool calcDopingProfile ();
189 
190  bool setupDefaultLayer ();
191  bool setupMesh ();
192  bool setupMaterialArrays ();
193  bool calcInitialGuess ();
194  bool obtainSolution ();
195  bool obtainNodeVoltages ();
196  bool applyVoltageLimiting ();
197  bool calcVequBCs ();
198  bool calcDensityBCs ();
199  bool calcBoundaryConditions ();
200  bool setupMiscConstants ();
201  bool setupScalingVars ();
202  bool scaleVariables ();
203  bool unScaleVariables ();
204 
205  bool calcRecombination ();
206  bool calcElectronCurrent ();
207  bool calcHoleCurrent ();
208  bool calcEfield ();
209 
210  bool calcTerminalCurrents ();
211  bool calcConductance (int iElectrode, const Linear::Vector * dxdvPtr);
212  bool calcDXDV ();
213  bool loadDFDV (int ielectrode, Linear::Vector * dfdvPtr);
214 
215  bool pdRecombination ();
216  bool pdElectronCurrent ();
217  bool pdHoleCurrent ();
218  bool pdTerminalCurrents ();
219 
220  bool outputTecplot ();
221  bool outputSgplot ();
222 
223  bool enablePDEContinuation(int &max_PDE_continuation_steps);
224  bool disablePDEContinuation ();
225  void setPDEContinuationAlpha (double alpha);
226 
227  // bool continuationStatus();
228  // void changeContinuationStepSize(double scale);
229  // void updateOldContinuationParam();
230 
231  bool outputPlotFiles(bool force_final_output);
232 
233 public:
234  // iterator reference to the resistor model which owns this instance.
235  // Getters and setters
237  {
238  return model_;
239  }
240 
241 private:
242 
243  Model & model_; //< Owning model
244 
251 
256 
257  // physical constants:
258 
259  double Emax; // maximum electric field (V/cm)
260 
261  double VminExp; // maximum potential (V), used in exponential expressions
262  double VmaxExp; // minimum potential (V), used in exponential expressions
263 
264  double diodeCap; // estimated diode capacitance (F)
265 
266  double LeadCurrent;
267 
268  // inputted doping profiles.
269  // pdope is often phosphorus
270  std::vector<double> xloc_pdope_vec;
271  std::vector<double> pdope_vec;
272  std::vector<double> y2_pdope_vec;
273 
274  // ndope is often boron.
275  std::vector<double> xloc_ndope_vec;
276  std::vector<double> ndope_vec;
277  std::vector<double> y2_ndope_vec;
278 
279  // source file arrays
280  std::vector<double> xloc_source_vec;
281  std::vector<double> source_vec;
282  std::vector<double> y2_source_vec;
283 
284  // temp spline arrays:
285  std::vector<double> xlocVec;
286  std::vector<double> specVec;
287  std::vector<double> y2Vec;
288 
289  // new doping/initial condition storage:
290  std::map<std::string, std::vector<double> > xlocMap;
291  std::map<std::string, std::vector<double> > specMap;
292 
293  // vector of electrode data:
294  std::map<std::string, PDE_1DElectrode*> electrodeMap;
295 
296  // boundary condition array. probably will be of size 2 or 3.
297  std::vector<bcData> bcVec;
298 
299  std::map<std::string,int> bcIndexMap;
300 
301  // doping profile constants:
302  double Na; // acceptor concentration on p-side (cm^-3)
303  double Nd; // donor concentration on n-side (cm^-3)
304  double WJ; // linearly graded junction width (cm)
305  double XC; // center of graded junction (cm)
306  double XL; // start of graded junction (cm)
307  double XR; // end of graded junction (cm)
308 
309  // boundary condition variables:
310  // These should eventually replace Nd and Na.
311  double NnMax; // maximum electron concentration
312  double NpMax; // maximum hole concentration.
313  double NnMin; // maximum electron concentration
314  double NpMin; // maximum hole concentration.
315 
316  // mesh constants:
317  int NX; // number of x mesh points
318  int LX; // index of last x point.
319 
320  bool NXGiven;
321 
322  // continuation parameters:
323  double maxVoltDelta;
325 
326  // option to use the old intrinsic calculation, to maintain backward compatibility.
327  bool useOldNi;
329 
330  // some 2D mesh stuff - mostly to catch netlist mistakes (as this is a 1D device model)
331  std::string meshFileName;
332 
333  // doping files.
334  std::string dopingFileName;
335  std::string ndopeFileName;
336  std::string pdopeFileName;
337 
338  // diode width:
339  double width;
340  double length;
341 
344 
345  // diode cross sectional area:
346  double area;
347 
348  // boundary condition variables. These are superceded by
349  // the data in the bcVec and PDE_1DElectrode structures.
350  double anodebc;
351  double cathodebc;
352  double emitterbc;
353  double collectorbc;
354  double basebc;
355 
356  double anodeArea;
357  double cathodeArea;
358 
359  double emitterArea;
361  double baseArea;
362 
363  double baseLocation;
365 
369  int callsOSG;
370 
372 
374 
380 
384 
388 
391  std::string tunnelingModelName;
392 
397 
398  int NUMRC; // number of row-column pairs.
399 
400  std::vector<double> displCurrent;
401 
402  std::vector<int> boundarySten;
403  std::vector<int> edgeBoundarySten;
404  std::vector<int> internalBoundarySten;
405  std::vector<int> heterojunctionSten;
406  std::vector<int> matIndex;
407  std::vector< std::pair<int,int> > heterojunctionBCs;
408 
409  std::vector<int> regBaseIndexVec;
410  std::vector<int> regNumSpecieVec;
411  std::vector<int> regElectronIndexVec;
412  std::vector<int> regHoleIndexVec;
413 
414  std::vector<double> dxVec; // mesh spacing.
415  std::vector<double> xVec; // mesh points.
416  std::vector<double> CVec; // doping
417  std::vector<double> CdonorVec; // doping
418  std::vector<double> CacceptorVec; // doping
419  std::vector<double> VVec; // electrostatic potential
420  std::vector<double> ExVec; // electric field, x-direction.
421 
422  std::vector<double> JnxVec; // electron current density
423  std::vector<double> JpxVec; // hole current density
424 
425  std::vector<double> RVec; // recombination.
426  std::vector<double> SVec; // radiation source term.
427 
428  std::vector<double> nnVec; // electron density
429  std::vector<double> npVec; // hole density
430 
431 #if 0
432  std::vector<double> unE_Vec; // mobility along edge, electron
433  std::vector<double> upE_Vec; // mobility along edge, hole
434 #else
435  std::vector<pdeFadType> unE_Vec; // mobility along edge, electron
436  std::vector<pdeFadType> upE_Vec; // mobility along edge, hole
437 #endif
438 
439  std::vector<double> tnVec; // spatially dependent lifetimes, electron
440  std::vector<double> tpVec; // spatially dependent lifetimes, hole
441 
442 
443  std::vector<double> NcVec; // conduction band DOS
444  std::vector<double> NvVec; // valance band DOS
445 
446  std::vector<double> EcVec; // conduction band
447  std::vector<double> EvVec; // valance band
448  std::vector<double> EcEffVec; // conduction band, including BGN
449  std::vector<double> EvEffVec; // valance band, including BGN
450 
451  std::vector<double> bgnCVec; // Band-gap narrowing, conduction band
452  std::vector<double> bgnVVec; // Band-gap narrowing, valance band
453 
454  std::vector<double> NiVec; // intrinsic concentration
455  std::vector<double> NiEffVec; // intrinsic concentration
456  std::vector<double> EiVec; // intrinsic Fermi-Level vector.
457  std::vector<double> EiEffVec; // intrinsic Fermi-Level vector.
458  std::vector<double> EfVec; // Fermi-Level vector.
459  std::vector<double> EfEffVec; // Fermi-Level vector.
460  std::vector<double> relPermVec; // relative Permittivity
461 
462  std::vector<std::string> bulkMaterialVec; // material
463 
464  // derivative arrays:
465 
466  std::vector<double> dRdpVec;
467  std::vector<double> dRdnVec;
468 
469  std::vector<double> dJndn1Vec;
470  std::vector<double> dJndn2Vec;
471  std::vector<double> dJndV1Vec;
472  std::vector<double> dJndV2Vec;
473  std::vector<double> dJndp1Vec;
474  std::vector<double> dJndp2Vec;
475 
476  std::vector<double> dJpdn1Vec;
477  std::vector<double> dJpdn2Vec;
478  std::vector<double> dJpdV1Vec;
479  std::vector<double> dJpdV2Vec;
480  std::vector<double> dJpdp1Vec;
481  std::vector<double> dJpdp2Vec;
482 
483  // LID indices.
484  std::vector<int> li_Vrowarray;
485  std::vector< std::vector<int> > li_Vcolarray;
486 
487  std::vector<int> li_Nrowarray;
488  std::vector< std::vector<int> > li_Ncolarray;
489 
490  std::vector<int> li_Prowarray;
491  std::vector< std::vector<int> > li_Pcolarray;
492 
493  // columns needed for coupledMode==2
494  std::vector< std::vector<int> > li_N_rxn_colarray;
495  std::vector< std::vector<int> > li_P_rxn_colarray;
496 
497  std::vector<int> li_stateDispl;
498 
499  // matrix pointers
500  std::vector< std::vector<double *> > fVmatPtr;
501  std::vector< std::vector<double *> > fNmatPtr;
502  std::vector< std::vector<double *> > fPmatPtr;
503  std::vector< std::vector<double *> > qVmatPtr;
504  std::vector< std::vector<double *> > qNmatPtr;
505  std::vector< std::vector<double *> > qPmatPtr;
506 
507  // map between a mesh point index and a list of nearest neighbors
508  // for that mesh point.
509  std::multimap< int, int* > meshNeighborMultiMap;
510 
511  // state variable arrays associated with displacement current.
512  std::vector<int> stateDispl;
513  std::vector<int> stateDispl_owned;
514 
517 
518  // 2d array of conductances, for 2-level "ckt phase" loads.
519  std::vector< std::vector<double> > condVec;
520 
521  // data related to DMA matrix loads.
522  std::vector<int> meshToLID;
523  std::vector< std::vector<int> > jacStamp;
524  std::vector<int> jacMap;
525  std::vector< std::vector<int> > jacMap2;
526 
528 
530  std::vector<MaterialLayer*> materialVec;
531 
533 };
534 
535 //-----------------------------------------------------------------------------
536 // Class : Model
537 // Purpose :
538 // Special Notes :
539 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
540 // Creation Date : 6/29/00
541 //-----------------------------------------------------------------------------
542 class Model : public DevicePDEModel
543 {
544  typedef std::vector<Instance *> InstanceVector;
545 
546  friend class Instance;
547  friend class ParametricData<Model>;
548  friend class Traits;
549 
550 public:
551  Model(
552  const Configuration & configuration,
553  const ModelBlock & MB,
554  const FactoryBlock & factory_block);
555  ~Model();
556 
557 private:
558  Model();
559  Model(const Model &);
560  Model &operator=(const Model &);
561 
562 public:
563  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
564 
565  virtual std::ostream &printOutInstances(std::ostream &os) const;
566 
567  bool processParams ();
568  bool processInstanceParams ();
569 
570 private:
571 
572 
573 public:
574  void addInstance(Instance *instance)
575  {
576  instanceContainer.push_back(instance);
577  }
578 
579 private:
580  std::vector<Instance*> instanceContainer;
581 };
582 
583 void registerDevice();
584 
585 } // namespace DiodePDE
586 } // namespace Device
587 } // namespace Xyce
588 
589 #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)
bool outputPlotFiles(bool force_final_output)
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