Xyce  6.1
N_DEV_ThermalResistor.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_ThermalResistor.h,v $
27 //
28 // Purpose : ThermalResistor classes
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.43 $
40 //
41 // Revision Date : $Date: 2015/04/24 20:25:45 $
42 //
43 // Current Owner : $Author: dgbaur $
44 //-----------------------------------------------------------------------------
45 
46 #ifndef Xyce_N_DEV_ThermalResistor_h
47 #define Xyce_N_DEV_ThermalResistor_h
48 
49 // ---------- Xyce Includes ----------
50 #include <N_DEV_Configuration.h>
51 #include <N_DEV_DeviceMaster.h>
52 #include <N_DEV_DeviceBlock.h>
53 #include <N_DEV_DeviceInstance.h>
54 #include <N_DEV_DeviceInstance.h>
55 
56 #include <N_DEV_Resistor.h>
57 
58 namespace Xyce {
59 namespace Device {
60 namespace ThermalResistor {
61 
62 class Model;
63 class Instance;
64 
65 struct Traits : public DeviceTraits<Model, Instance, Resistor::Traits>
66 {
67  static const char *name() {return "Resistor";}
68  static const char *deviceTypeName() {return "R level 2";}
69  static int numNodes() {return 2;}
70  static const char *primaryParameter() {return "R";}
71  static const char *instanceDefaultParameter() {return "R";}
72  static bool isLinearDevice() {return true;}
73 
74  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
75  static void loadModelParameters(ParametricData<Model> &model_parameters);
76  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
77 };
78 
79 //-----------------------------------------------------------------------------
80 // Class : Instance
81 // Purpose :
82 //
83 // This is the instance class for resistors. It
84 // contains "unique" resistor information - ie stuff that
85 // will be true of only one resistor in the circuit, such
86 // as the nodes to which it is connected. A resistor is
87 // connected to only two circuit nodes.
88 //
89 // This class does not directly contain information about
90 // its node indices. It contains indices into the 3 parts
91 // (A, dx, and b) of the matrix problem A*dx = b, and
92 // also x. A is the Jacobian matrix, dx is the update to
93 // the solution vector x, and b is the right hand side
94 // function vector. These indices are global, and
95 // determined by topology during the initialization stage
96 // of execution.
97 //
98 // Special Notes :
99 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
100 // Creation Date : 3/16/00
101 //-----------------------------------------------------------------------------
102 class Instance : public DeviceInstance
103 {
104  friend class ParametricData<Instance>;
105  friend class Model;
106  friend class Traits;friend class Master;
107 
108 public:
109 
110  Instance(
111  const Configuration & configuration,
112  const InstanceBlock & IB,
113  Model & Riter,
114  const FactoryBlock & factory_block);
115 
116  ~Instance();
117 
118 private:
119  Instance(const Instance &);
120  Instance &operator=(const Instance &);
121 
122 public:
123  void registerLIDs( const std::vector<int> & intLIDVecRef,
124  const std::vector<int> & extLIDVecRef );
125  void registerStateLIDs( const std::vector<int> & staLIDVecRef );
126  void registerStoreLIDs( const std::vector<int> & stoLIDVecRef );
127  virtual void registerBranchDataLIDs(const std::vector<int> & branchLIDVecRef) /* override */;
128 
129  virtual void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
130 
131  bool processParams ();
132 
133  bool updateTemperature(const double & temp_tmp);
134 
135  bool updateIntermediateVars ();
136  bool updatePrimaryState ();
137 
138  const std::vector< std::vector<int> > & jacobianStamp() const;
139  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
140 
141  bool plotfileFlag () {return true;}
142 
143  // load functions, residual:
144  bool loadDAEQVector () {return true;}
145  bool loadDAEFVector ();
146 
147  // load functions, Jacobian:
148  bool loadDAEdQdx () {return true;}
149  bool loadDAEdFdx ();
150 
151  void setupPointers();
152 
153  bool outputPlotFiles(bool force_final_output);
154 
156  {
157  return model_;
158  }
159 
160 private:
161  static std::vector< std::vector<int> > jacStamp;
162 
163  Model & model_; //< Owning model
164 
165  // user-specified paramters:
166  double R; // resistance (ohms)
167  // these are for the semiconductor resistor
168  double length; // resistor length.
169  double width; // resistor width.
170 
171  double area; // resistor width.
172  double thermalLength; // Length of material thermally coupled to resistor.
173  double thermalArea; // Width of material thermally coupled to resistor.
174 
175  // these four params are copied from the model:
176  double resistivity; // material resistivity
177  double density; // material density
178  double heatCapacity; // conductor volumetric heat capacity
179  double thermalHeatCapacity; // volumetric heat capacity of material thermally coupled to resistor
180 
181  double temp; // temperature of this instance
182 
183  // derived parameters:
184  double G; // conductance (1.0/ohms)
185  double i0; // current (ohms)
186 
187  //Vector local index for Positive Node
188  int li_Pos;
189  //Vector local index for Negative Node
190  int li_Neg;
191 
196  int li_branch_data; ///< Index for Lead Current and junction voltage (for power calculations)
197 
198  // Offset variables corresponding to the above declared indices.
203 
204  // Pointers for Jacobian
209 };
210 
211 
212 //-----------------------------------------------------------------------------
213 // Class : Model
214 // Purpose :
215 //
216 //
217 // Special Notes :
218 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
219 // Creation Date : 3/16/00
220 //-----------------------------------------------------------------------------
221 class Model : public DeviceModel
222 {
223  typedef std::vector<Instance *> InstanceVector;
224 
225  friend class ParametricData<Model>;
226  friend class Instance;
227  friend class Traits;friend class Master;
228 
229 public:
230  Model(
231  const Configuration & configuration,
232  const ModelBlock & MB,
233  const FactoryBlock & factory_block);
234  ~Model();
235 
236 private:
237  Model();
238  Model(const Model &);
239  Model &operator=(const Model &);
240 
241 public:
242  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
243 
244  virtual std::ostream &printOutInstances(std::ostream &os) const;
245 
246  bool processParams ();
247  bool processInstanceParams ();
248 
249 
250 public:
251  void addInstance(Instance *instance)
252  {
253  instanceContainer.push_back(instance);
254  }
255 
256 private:
257  std::vector<Instance*> instanceContainer;
258 
259 private:
260 
261  // Semiconductor resistor parameters
262  double tempCoeff1; // first order temperature coeff.
263  double tempCoeff2; // second order temperature coeff.
264  double sheetRes; // sheet resistance
265  double resistanceMultiplier; // resistance multiplier
266 
267  double resistivity; // material resistivity
268  double density; // material density
269  double heatCapacity; // conductor volumetric heat capacity
270  double thermalHeatCapacity; // volumetric heat capacity of material thermally coupled to resistor
271  double defArea; // default area
272  double defLength; // default length
273 
274  double defWidth; // default width
275  double narrow; // narrowing due to side etching
276  double tnom; // parameter measurement temperature
277 };
278 
279 //-----------------------------------------------------------------------------
280 // Class : Master
281 // Purpose :
282 // Special Notes :
283 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
284 // Creation Date : 11/26/08
285 //-----------------------------------------------------------------------------
286 class Master : public DeviceMaster<Traits>
287 {
288 public:
290  const Configuration & configuration,
291  const FactoryBlock & factory_block,
292  const SolverState & ss1,
293  const DeviceOptions & do1)
294  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
295  {}
296 
297  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
298 
299  // load functions:
300  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ, double * leadF, double * leadQ, double * junctionV);
301  virtual bool loadDAEMatrices (Linear::Matrix & dFdx, Linear::Matrix & dQdx);
302 };
303 
304 void registerDevice();
305 
306 } // namespace ThermalResistor
307 } // namespace Device
308 } // namespace Xyce
309 
310 #endif
311 
int li_branch_data
Index for Lead Current and junction voltage (for power calculations)
virtual void registerBranchDataLIDs(const std::vector< int > &branchLIDVecRef)
Register the local store IDs.
virtual void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
void registerStoreLIDs(const std::vector< int > &stoLIDVecRef)
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
Pure virtual class to augment a linear system.
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
static std::vector< std::vector< int > > jacStamp
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
Model & operator=(const Model &)
bool processInstanceParams()
processInstanceParams
DeviceMaster instantiates a device as described by the device traits T.
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
static void loadModelParameters(ParametricData< Model > &model_parameters)
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Riter, const FactoryBlock &factory_block)
virtual std::ostream & printOutInstances(std::ostream &os) const
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
virtual bool loadDAEVectors(double *solVec, double *fVec, double *qVec, double *bVec, double *storeLeadF, double *storeLeadQ, double *leadF, double *leadQ, double *junctionV)
Populates the device's ExternData object with these pointers.
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Class Configuration contains device configuration data.
Master(const Configuration &configuration, const FactoryBlock &factory_block, const SolverState &ss1, const DeviceOptions &do1)
virtual bool updateState(double *solVec, double *staVec, double *stoVec)
Updates the devices state information.
virtual bool loadDAEMatrices(Linear::Matrix &dFdx, Linear::Matrix &dQdx)
Populates the device's Jacobian object with these pointers.
bool updateTemperature(const double &temp_tmp)
Instance & operator=(const Instance &)
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
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.
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
std::vector< Instance * > instanceContainer
const std::vector< std::vector< int > > & jacobianStamp() const
bool outputPlotFiles(bool force_final_output)