Xyce  6.1
N_DEV_Resistor.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_Resistor.h,v $
27 //
28 // Purpose :
29 //
30 // Special Notes :
31 //
32 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
33 //
34 // Creation Date : 02/28/00
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.124.2.1 $
40 //
41 // Revision Date : $Date: 2015/04/02 18:20:11 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-----------------------------------------------------------------------------
45 
46 #ifndef Xyce_N_DEV_Resistor_h
47 #define Xyce_N_DEV_Resistor_h
48 
49 #include <N_DEV_fwd.h>
50 #include <N_DEV_Configuration.h>
51 #include <N_DEV_DeviceInstance.h>
52 #include <N_DEV_DeviceModel.h>
53 #include <N_DEV_DeviceMaster.h>
54 
55 namespace Xyce {
56 namespace Device {
57 namespace Resistor {
58 
59 class Model;
60 class Instance;
61 
62 /// sensitivity functor
64 {
65  public:
67  baseSensitivity() {};
68 
69  virtual ~resistorSensitivity() {};
70 
71  virtual void operator()(
72  const ParameterBase &entity,
73  const std::string &name,
74  std::vector<double> & dfdp,
75  std::vector<double> & dqdp,
76  std::vector<double> & dbdp,
77  std::vector<int> & Findices,
78  std::vector<int> & Qindices,
79  std::vector<int> & Bindices
80  ) const ;
81 };
82 
84 
85 struct Traits : public DeviceTraits<Model, Instance>
86 {
87  static const char *name() {return "Resistor";}
88  static const char *deviceTypeName() {return "R level 1";}
89  static int numNodes() {return 2;}
90  static const char *primaryParameter() {return "R";}
91  static const char *instanceDefaultParameter() {return "R";}
92  static bool isLinearDevice() {return true;}
93 
94  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
97 };
98 
99 //-----------------------------------------------------------------------------
100 // Class : Xyce::Device::Resistor::Instance
101 // Purpose :
102 // Special Notes :
103 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
104 // Creation Date : 3/16/00
105 //-----------------------------------------------------------------------------
106 ///
107 /// Resistor device instance class.
108 ///
109 /// An instance is created for each occurance of the device in the netlist.
110 ///
111 /// It contains "unique" resistor information - ie stuff that will be
112 /// true of only one resistor in the circuit, such as the nodes to
113 /// which it is connected. A resistor is connected to only two
114 /// circuit nodes.
115 ///
116 /// This class does not directly contain information about its node
117 /// indices. It contains indices into the 5 parts (dFdx, dQdx, dx, F,
118 /// and Q) of the matrix problem A*dx = b, and also the solution
119 /// vector x. A is the Jacobian matrix that will be formed from dFdx
120 /// and d(dQ/dt)dx, dx is the update to x, and b is right hand side
121 /// function vector that will be formed from F and dQ/dt. These
122 /// indices are global, and determined by topology during the
123 /// initialization stage of execution.
124 ///
125 class Instance : public DeviceInstance
126 {
127  friend class ParametricData<Instance>; ///< Allow ParametricData to changes member values
128  friend class Model;
129  friend class Traits;
130  friend class Master;
131  friend class resistorSensitivity;
132 
133 public:
134  Instance(
135  const Configuration & configuration,
136  const InstanceBlock & instance_block,
137  Model & model,
138  const FactoryBlock & factory_block);
139 
140  //---------------------------------------------------------------------------
141  // Function : Xyce::Device::Resistor::Instance::~Instance
142  // Purpose : destructor
143  // Special Notes :
144  // Scope : public
145  // Creator : Eric Keiter, SNL, Parallel Computational Sciences
146  // Creation Date : 3/16/00
147  //---------------------------------------------------------------------------
148  ///
149  /// Destroys this instance
150  ///
151  /// @author Eric Keiter, SNL
152  /// @date 3/16/00
154 
155 private:
156  Instance(const Instance &);
157  Instance &operator=(const Instance &);
158 
159 public:
160 
161  //---------------------------------------------------------------------------
162  // Function : Xyce::Device::Resistor::Instance::getModel
163  // Purpose : destructor
164  // Special Notes :
165  // Scope : public
166  // Creator : Eric Keiter, SNL, Parallel Computational Sciences
167  // Creation Date : 3/16/00
168  //---------------------------------------------------------------------------
169  ///
170  /// Gets the resistor model that owns this instance.
171  ///
172  /// @return reference to the owning Resistor::Model
173  ///
174  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
175  /// @date Mon Aug 12 08:36:37 2013
176  Model &getModel() { return model_; }
177 
178  virtual void registerLIDs(const std::vector<int> & intLIDVecRef, const std::vector<int> & extLIDVecRef) /* override */;
179  virtual void registerStateLIDs(const std::vector<int> & staLIDVecRef) /* override */;
180  virtual void registerStoreLIDs(const std::vector<int> & stoLIDVecRef) /* override */;
181  virtual void registerBranchDataLIDs(const std::vector<int> & branchLIDVecRef) /* override */;
182  virtual void registerJacLIDs(const std::vector< std::vector<int> > & jacLIDVec) /* override */;
183 
184  virtual void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
185 
186  virtual bool processParams() /* override */;
187  virtual bool updateTemperature(const double & temp_tmp) /* override */;
188  virtual bool updateIntermediateVars() /* override */;
189  virtual bool updatePrimaryState() /* override */;
190 
191  int getNumNoiseSources () const { return 1; }
192  void setupNoiseSources (Xyce::Analysis::NoiseData & noiseData);
193  void getNoiseSources (Xyce::Analysis::NoiseData & noiseData);
194 
195  //---------------------------------------------------------------------------
196  // Function : Xyce::Device::Resistor::Instance::jacobianStamp
197  // Purpose :
198  // Special Notes :
199  // Scope : public
200  // Creator : Robert Hoekstra, SNL, Parallel Computational Sciences
201  // Creation Date : 08/20/01
202  //---------------------------------------------------------------------------
203  ///
204  /// Return Jacobian stamp that informs topology of the layout of the
205  /// resistor jacobian.
206  ///
207  /// The Jacobian stamp describes the shape of the Jacobian to the
208  /// Topology subsystem. The Topology subsystem, in turn, returns
209  /// the offsets into the matrix and solution vectors where this
210  /// instance data is located.
211  ///
212  /// @return const reference to a std::vector of std::vector of
213  /// integers describing Jacobian stamp shape
214  ///
215  /// @author Robert Hoekstra
216  /// @date 8/20/2001
217  virtual const std::vector< std::vector<int> > &jacobianStamp() const /* override */ {
218  return jacStamp;
219  }
220 
221  virtual bool loadDAEFVector() /* override */;
222  virtual bool loadDAEdFdx() /* override */;
223 
224  //---------------------------------------------------------------------------
225  // Function : Xyce::Device::Resistor::Instance::loadDAEQVector
226  // Purpose :
227  // Special Notes :
228  // Scope : public
229  // Creator : Eric Keiter
230  // Creation Date : 1/24/03
231  //---------------------------------------------------------------------------
232  ///
233  /// Load Q vector
234  ///
235  /// @return true on success
236  ///
237  /// Since the Resistor does no charge storage, this is a no-op.
238  ///
239  /// @author Eric Keiter
240  /// @date 1/24/03
241  virtual bool loadDAEQVector() /* override */
242  {
243  return true;
244  }
245 
246  //---------------------------------------------------------------------------
247  // Function : Xyce::Device::Resistor::Instance::loadDAEdQdx
248  // Purpose :
249  // Special Notes :
250  // Scope : public
251  // Creator : Eric Keiter
252  // Creation Date : 1/24/03
253  //---------------------------------------------------------------------------
254  ///
255  /// Load derivative of Q vector with respect to solution vector
256  ///
257  /// @return true on success
258  ///
259  /// Since the Resistor does no charge storage, this is a no-op.
260  ///
261  /// @author Eric Keiter
262  /// @date 1/24/03
263  virtual bool loadDAEdQdx() /* override */
264  {
265  return true;
266  }
267 
268  virtual void setupPointers() /* override */;
269 
270 private:
271  static std::vector< std::vector<int> > jacStamp; ///< All Resistor instances have a common Jacobian Stamp
272  static void initializeJacobianStamp();
273 
274  Model & model_; ///< Owning model
275 
276  // User-specified parameters:
277  double R; ///< Resistance (ohms)
278 
279  // These are for the semiconductor resistor
280  double length; ///< Resistor length.
281  double width; ///< Resistor width.
282  double temp; ///< Temperature of this instance
283 
284  // Temperature dependence parameters, these can override values specified in the model
285  double tempCoeff1; ///< First order temperature coeff.
286  double tempCoeff2; ///< Second order temperature coeff.
287  double dtemp; ///< Externally specified device temperature.
288  ///< NOT used, only here for compatibility in parsing
289  ///< netlist from simulators that support it
290 
291  // Flags used to tell if the user has specified one of these values on the command line.
292  bool tempCoeff1Given; ///< First order temperation value was given in netlist
293  bool tempCoeff2Given; ///< Second order temperature coeff was given in netlist
294  bool dtempGiven; ///< Externally specified device temperature was given in netlist
295 
296  // Derived parameters:
297  double G; ///< Conductance(1.0/ohms)
298  double i0; ///< Current(ohms)
299 
300  int li_Pos; ///< Index for Positive Node
301  int li_Neg; ///< Index for Negative Node
302  int li_store_dev_i; ///< Index for Lead Current
303  int li_branch_data; ///< Index for Lead Current and junction voltage (for power calculations)
304 
305  // Offset variables corresponding to the above declared indices.
306  int APosEquPosNodeOffset; ///< Column index into force matrix of Pos/Pos conductance
307  int APosEquNegNodeOffset; ///< Column index into force matrix of Pos/Neg conductance
308  int ANegEquPosNodeOffset; ///< Column index into force matrix of Neg/Pos conductance
309  int ANegEquNegNodeOffset; ///< Column index into force matrix of Neg/Neg conductance
310 
311 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
312  // Pointers for Jacobian
317 #endif
318 
319 };
320 
321 
322 //-----------------------------------------------------------------------------
323 // Class : Xyce::Device::Resistor::Model
324 // Purpose :
325 // Special Notes :
326 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
327 // Creation Date : 3/16/00
328 //-----------------------------------------------------------------------------
329 ///
330 /// Resistor model class
331 ///
332 class Model : public DeviceModel
333 {
334  friend class ParametricData<Model>; ///< Allow ParametricData to changes member values
335  friend class Instance; ///< Don't force a lot of pointless getters
336  friend class Traits;
337  friend class Master; ///< Don't force a lot of pointless getters
338 
339 public:
340  typedef std::vector<Instance *> InstanceVector;
341 
342  Model(
343  const Configuration & configuration,
344  const ModelBlock & model_block,
345  const FactoryBlock & factory_block);
346  ~Model();
347 
348 private:
349  Model();
350  Model(const Model &);
351  Model &operator=(const Model &);
352 
353 public:
354 
355  //---------------------------------------------------------------------------
356  // Function : Xyce::Device::Resistor::Model::addInstance
357  // Purpose :
358  // Special Notes :
359  // Scope : public
360  // Creator : David Baur
361  // Creation Date : 8/12/2013
362  //---------------------------------------------------------------------------
363  ///
364  /// Add an instance to the list of instances associated with this model
365  ///
366  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
367  /// @date 8/12/2013
368  void addInstance(Instance *instance)
369  {
370  instanceContainer.push_back(instance);
371  }
372 
373  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
374 
375  virtual std::ostream &printOutInstances(std::ostream &os) const;
376 
377  virtual bool processParams() /* override */;
378  virtual bool processInstanceParams() /* override */;
379 
380 private:
381  InstanceVector instanceContainer; ///< List of owned resistor instances
382 
383  // Semiconductor resistor parameters
384  double tempCoeff1; ///< First order temperature coefficient
385  double tempCoeff2; ///< Second order temperature coefficient
386  double sheetRes; ///< Sheet resistance
387  double resistanceMultiplier; ///< resistance multiplier
388  double defWidth; ///< Default width
389  double narrow; ///< Narrowing due to side etching
390  double tnom; ///< Parameter measurement temperature
391 };
392 
393 
394 //-----------------------------------------------------------------------------
395 // Class : Xyce::Device::Resistor::Master
396 // Purpose :
397 // Special Notes :
398 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
399 // Creation Date : 11/26/08
400 //-----------------------------------------------------------------------------
401 ///
402 /// Resistor master
403 ///
404 /// The "master" class is the one that contains the updateState, loadDAEVectors
405 /// and loadDAEMatrices methods that are actually called when it is time to
406 /// compute and load device contributions.
407 ///
408 /// The default implementations of these methods in the DeviceMaster
409 /// template class simply loops over all instances and calls their
410 /// updatePrimaryState, loadDAEFVector/loadDAEQVector, and
411 /// loadDAEdFdx/loadDAEdQdx methods, respectively.
412 ///
413 /// For efficiency, the Resistor class reimplements these methods to do the
414 /// work directly, instead of calling instance-level functions.
415 ///
416 class Master : public DeviceMaster<Traits>
417 {
418  friend class Instance; ///< Don't force a lot of pointless getters
419  friend class Model; ///< Don't force a lot of pointless getters
420 
421 public:
422 
423  //---------------------------------------------------------------------------
424  // Function : Xyce::Device::Resistor::Master::Master
425  // Purpose :
426  // Special Notes :
427  // Scope : public
428  // Creator : Eric Keiter
429  // Creation Date : 11/26/08
430  //---------------------------------------------------------------------------
431  ///
432  /// Construct a Resistor Device.
433  ///
434  /// @param configuration
435  /// @param factory_block
436  /// @param solver_state
437  /// @param device_options
439  const Configuration & configuration,
440  const FactoryBlock & factory_block,
441  const SolverState & solver_state,
442  const DeviceOptions & device_options)
443  : DeviceMaster<Traits>(configuration, factory_block, solver_state, device_options)
444  {}
445 
446  virtual bool updateState(double * solVec, double * staVec, double * stoVec);
447  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ, double * leadF, double * leadQ, double * junctionV);
448  virtual bool loadDAEMatrices(Linear::Matrix & dFdx, Linear::Matrix & dQdx);
449 };
450 
451 void registerDevice();
452 
453 } // namespace Resistor
454 } // namespace Device
455 } // namespace Xyce
456 
457 #endif // Xyce_N_DEV_Resistor_h
static void loadModelParameters(ParametricData< Model > &p)
Loads the parameter definition into the model parameter map.
Instance & operator=(const Instance &)
virtual bool updatePrimaryState()
Update the state variables.
int li_Pos
Index for Positive Node.
int ANegEquNegNodeOffset
Column index into force matrix of Neg/Neg conductance.
virtual void setupPointers()
Setup direct access pointer to solution matrix and vectors.
double sheetRes
Sheet resistance.
int li_branch_data
Index for Lead Current and junction voltage (for power calculations)
InstanceVector instanceContainer
List of owned resistor instances.
double length
Resistor length.
Resistor model class.
Pure virtual class to augment a linear system.
static resistorSensitivity resSens
static void initializeJacobianStamp()
Common Jacobian stamp initializer for all Resistor devices.
Master(const Configuration &configuration, const FactoryBlock &factory_block, const SolverState &solver_state, const DeviceOptions &device_options)
Construct a Resistor Device.
double tempCoeff2
Second order temperature coeff.
virtual void registerBranchDataLIDs(const std::vector< int > &branchLIDVecRef)
Register the local store IDs.
double resistanceMultiplier
resistance multiplier
int APosEquPosNodeOffset
Column index into force matrix of Pos/Pos conductance.
Base class for all parameters.
Definition: N_DEV_Pars.h:169
virtual bool processParams()
Process parameters.
virtual bool updateState(double *solVec, double *staVec, double *stoVec)
Update state for all resistor instances, regardless of model.
static void loadInstanceParameters(ParametricData< Instance > &p)
Loads the parameter definition into the instance parameter map.
virtual void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
virtual bool loadDAEVectors(double *solVec, double *fVec, double *qVec, double *bVec, double *storeLeadF, double *storeLeadQ, double *leadF, double *leadQ, double *junctionV)
Load DAE vectors of all resistor instances, regardless of model.
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
virtual bool loadDAEFVector()
Load the DAE F vector.
DeviceMaster instantiates a device as described by the device traits T.
double tempCoeff1
First order temperature coeff.
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
virtual void operator()(const ParameterBase &entity, const std::string &name, std::vector< double > &dfdp, std::vector< double > &dqdp, std::vector< double > &dbdp, std::vector< int > &Findices, std::vector< int > &Qindices, std::vector< int > &Bindices) const
void addInstance(Instance *instance)
Add an instance to the list of instances associated with this model.
static const char * name()
double temp
Temperature of this instance.
double dtemp
Externally specified device temperature.
int li_store_dev_i
Index for Lead Current.
virtual bool loadDAEQVector()
Load Q vector.
virtual void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
Register the Jacobian local IDs.
static const char * deviceTypeName()
bool tempCoeff2Given
Second order temperature coeff was given in netlist.
Resistor device instance class.
Model & operator=(const Model &)
double narrow
Narrowing due to side etching.
double R
Resistance (ohms)
~Instance()
Destroys this instance.
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
virtual bool processInstanceParams()
Process the instance parameters of instance owned by this model.
void setupNoiseSources(Xyce::Analysis::NoiseData &noiseData)
virtual void registerStateLIDs(const std::vector< int > &staLIDVecRef)
Register the local state IDs.
virtual const std::vector< std::vector< int > > & jacobianStamp() const
Return Jacobian stamp that informs topology of the layout of the resistor jacobian.
virtual std::ostream & printOutInstances(std::ostream &os) const
Print instances associated with this model.
virtual bool loadDAEdFdx()
Load the DAE the derivative of the F vector with respect to the solution vector x, dFdx.
Model & model_
Owning model.
Class Configuration contains device configuration data.
virtual void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
Register local IDs.
virtual bool loadDAEdQdx()
Load derivative of Q vector with respect to solution vector.
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
Create a new instance of the Resistor device.
double width
Resistor width.
int ANegEquPosNodeOffset
Column index into force matrix of Neg/Pos conductance.
double G
Conductance(1.0/ohms)
virtual bool processParams()
Process model parameters.
static const char * instanceDefaultParameter()
double tempCoeff1
First order temperature coefficient.
double tempCoeff2
Second order temperature coefficient.
virtual bool loadDAEMatrices(Linear::Matrix &dFdx, Linear::Matrix &dQdx)
Load DAE matrices for all resistor instances, regardless of model.
double defWidth
Default width.
virtual void registerStoreLIDs(const std::vector< int > &stoLIDVecRef)
Register the local store IDs.
Base sensitivity functor.
Definition: N_DEV_Pars.h:148
ModelBlock represents a .MODEL line from the netlist.
The DeviceTraits template describes the configuration of a device.
static const char * primaryParameter()
Manages parameter binding for class C.
Definition: N_DEV_Pars.h:214
~Model()
Destroy this model.
int li_Neg
Index for Negative Node.
static std::vector< std::vector< int > > jacStamp
All Resistor instances have a common Jacobian Stamp.
InstanceBlock represent a device instance line from the netlist.
void registerDevice()
Define how to use the device in a netlist.
Instance(const Configuration &configuration, const InstanceBlock &instance_block, Model &model, const FactoryBlock &factory_block)
Construct a resistor instance.
virtual bool updateTemperature(const double &temp_tmp)
Update the parameters that depend on the temperature of the device.
int APosEquNegNodeOffset
Column index into force matrix of Pos/Neg conductance.
std::vector< Instance * > InstanceVector
void getNoiseSources(Xyce::Analysis::NoiseData &noiseData)
Model & getModel()
Gets the resistor model that owns this instance.
double tnom
Parameter measurement temperature.
bool tempCoeff1Given
First order temperation value was given in netlist.
virtual bool updateIntermediateVars()
Update the intermediate variables.
bool dtempGiven
Externally specified device temperature was given in netlist.