Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-2014 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.35.2.1 $
40 //
41 // Revision Date : $Date: 2014/08/28 16:40:51 $
42 //
43 // Current Owner : $Author: tvrusso $
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  std::map<int, std::string> &getStoreNameMap();
128 
129  bool processParams ();
130 
131  bool updateTemperature(const double & temp_tmp);
132 
133  bool updateIntermediateVars ();
134  bool updatePrimaryState ();
135 
136  const std::vector< std::vector<int> > & jacobianStamp() const;
137  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
138 
139  bool plotfileFlag () {return true;}
140 
141  // load functions, residual:
142  bool loadDAEQVector () {return true;}
143  bool loadDAEFVector ();
144 
145  // load functions, Jacobian:
146  bool loadDAEdQdx () {return true;}
147  bool loadDAEdFdx ();
148 
149  void setupPointers();
150 
151  bool outputPlotFiles ();
152 
154  {
155  return model_;
156  }
157 
158 private:
159  static std::vector< std::vector<int> > jacStamp;
160 
161  Model & model_; //< Owning model
162 
163  // user-specified paramters:
164  double R; // resistance (ohms)
165  // these are for the semiconductor resistor
166  double length; // resistor length.
167  double width; // resistor width.
168 
169  double area; // resistor width.
170  double thermalLength; // Length of material thermally coupled to resistor.
171  double thermalArea; // Width of material thermally coupled to resistor.
172 
173  // these four params are copied from the model:
174  double resistivity; // material resistivity
175  double density; // material density
176  double heatCapacity; // conductor volumetric heat capacity
177  double thermalHeatCapacity; // volumetric heat capacity of material thermally coupled to resistor
178 
179  double temp; // temperature of this instance
180 
181  // derived parameters:
182  double G; // conductance (1.0/ohms)
183  double i0; // current (ohms)
184 
185  //Vector local index for Positive Node
186  int li_Pos;
187  //Vector local index for Negative Node
188  int li_Neg;
189 
194 
195  // Offset variables corresponding to the above declared indices.
200 
201  // Pointers for Jacobian
206 };
207 
208 
209 //-----------------------------------------------------------------------------
210 // Class : Model
211 // Purpose :
212 //
213 //
214 // Special Notes :
215 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
216 // Creation Date : 3/16/00
217 //-----------------------------------------------------------------------------
218 class Model : public DeviceModel
219 {
220  typedef std::vector<Instance *> InstanceVector;
221 
222  friend class ParametricData<Model>;
223  friend class Instance;
224  friend class Traits;friend class Master;
225 
226 public:
227  Model(
228  const Configuration & configuration,
229  const ModelBlock & MB,
230  const FactoryBlock & factory_block);
231  ~Model();
232 
233 private:
234  Model();
235  Model(const Model &);
236  Model &operator=(const Model &);
237 
238 public:
239  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
240 
241  virtual std::ostream &printOutInstances(std::ostream &os) const;
242 
243  bool processParams ();
244  bool processInstanceParams ();
245 
246 
247 public:
248  void addInstance(Instance *instance)
249  {
250  instanceContainer.push_back(instance);
251  }
252 
253 private:
254  std::vector<Instance*> instanceContainer;
255 
256 private:
257 
258  // Semiconductor resistor parameters
259  double tempCoeff1; // first order temperature coeff.
260  double tempCoeff2; // second order temperature coeff.
261  double sheetRes; // sheet resistance
262  double resistanceMultiplier; // resistance multiplier
263 
264  double resistivity; // material resistivity
265  double density; // material density
266  double heatCapacity; // conductor volumetric heat capacity
267  double thermalHeatCapacity; // volumetric heat capacity of material thermally coupled to resistor
268  double defArea; // default area
269  double defLength; // default length
270 
271  double defWidth; // default width
272  double narrow; // narrowing due to side etching
273  double tnom; // parameter measurement temperature
274 };
275 
276 //-----------------------------------------------------------------------------
277 // Class : Master
278 // Purpose :
279 // Special Notes :
280 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
281 // Creation Date : 11/26/08
282 //-----------------------------------------------------------------------------
283 class Master : public DeviceMaster<Traits>
284 {
285 public:
287  const Configuration & configuration,
288  const FactoryBlock & factory_block,
289  const SolverState & ss1,
290  const DeviceOptions & do1)
291  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
292  {}
293 
294  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
295 
296  // load functions:
297  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ);
298  virtual bool loadDAEMatrices (N_LAS_Matrix & dFdx, N_LAS_Matrix & dQdx);
299 };
300 
301 void registerDevice();
302 
303 } // namespace ThermalResistor
304 } // namespace Device
305 } // namespace Xyce
306 
310 
311 #endif
312