Xyce  6.1
N_DEV_TransLine.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright (c) 2002-2015, Sandia Corporation, Albuquerque, NM, USA. Under the
5 // terms of Contract DE-AC04-94AL85000, there is a non-exclusive license for
6 // use of this work by or on behalf of the U.S. Government. Export of this
7 // program may require a license from the United States Government.
8 //
9 // Xyce(TM) Parallel Electrical Simulator
10 // Copyright (C) 2002-2015 Sandia Corporation
11 //
12 // This program is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation, either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program. If not, see <http://www.gnu.org/licenses/>.
24 //-----------------------------------------------------------------------------
25 
26 //-----------------------------------------------------------------------------
27 // Filename : $RCSfile: N_DEV_TransLine.h,v $
28 //
29 // Purpose :
30 //
31 // Special Notes :
32 //
33 // Creator : Eric Keiter, SNL
34 //
35 // Creation Date : 12/11/09
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.32.2.2 $
41 //
42 // Revision Date : $Date: 2015/04/02 18:29:38 $
43 //
44 // Current Owner : $Author: tvrusso $
45 //-----------------------------------------------------------------------------
46 
47 #ifndef Xyce_N_DEV_TransLine_h
48 #define Xyce_N_DEV_TransLine_h
49 
50 // ---------- Xyce Includes ----------
51 #include <N_DEV_Configuration.h>
52 #include <N_DEV_DeviceMaster.h>
53 #include <N_DEV_DeviceBlock.h>
54 #include <N_DEV_DeviceInstance.h>
55 #include <N_DEV_DeviceModel.h>
56 
57 
58 #define TRANS_MOD_RLC 1
59 #define TRANS_MOD_LC 2
60 
61 namespace Xyce {
62 namespace Device {
63 namespace TransLine {
64 
65 // ---------- Forward Declarations ----------
66 class Model;
67 class Instance;
68 
69 struct Traits : public DeviceTraits<Model, Instance>
70 {
71  static const char *name() {return "Lumped Transmission Line";}
72  static const char *deviceTypeName() {return "YTRANSLINE level 1";}
73  static int numNodes() {return 2;}
74  static bool modelRequired() {return true;}
75  static bool isLinearDevice() {return true;}
76 
77  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
78  static void loadModelParameters(ParametricData<Model> &model_parameters);
79  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
80 };
81 
82 // note that V1 and V3 are shared by neighbor nodes.
83 struct lumpData
84 {
85 public:
86  int indexV1;
87  int indexV2;
88  int indexI;
89  int indexV3;
90 
91  int li_V1;
92  int li_V2;
93  int li_I;
94  int li_V3;
95 
96  int offset_v1_v2m1; // from previous lump
97  int offset_v1_iim1; // from previous lump
100 
104 
108 
109  int offset_v3_v2; // only used if second external node
111 
112  double f0_ind;
113  double i0_ind;
114  double coef_ind;
115  double i0_res;
116  double q0_cap;
117 };
118 
119 //-----------------------------------------------------------------------------
120 // Class : Instance
121 // Purpose :
122 // Special Notes :
123 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
124 // Creation Date : 12/11/09
125 //-----------------------------------------------------------------------------
126 
127 class Instance : public DeviceInstance
128 {
129  friend class ParametricData<Instance>;
130  friend class Model;
131  friend class Traits;
132 
133 public:
134 
135  Instance(
136  const Configuration & configuration,
137  const InstanceBlock & IB,
138  Model & Citer,
139  const FactoryBlock & factory_block);
140 
141 
142  ~Instance();
143 
144 private:
145  Instance(const Instance &);
146  Instance &operator=(const Instance &);
147 
148 public:
149  // Additional Public Declarations
150  void registerLIDs( const std::vector<int> & intLIDVecRef,
151  const std::vector<int> & extLIDVecRef );
152  void registerStateLIDs( const std::vector<int> & staLIDVecRef );
153 
154  void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
155 
156  const std::vector< std::vector<int> > & jacobianStamp() const;
157  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
158 
159  bool processParams ();
160  bool updateTemperature(const double & temp_tmp);
161 
162  bool updateIntermediateVars ();
163  bool updatePrimaryState ();
164 
165  // load functions, residual:
166  bool loadDAEQVector ();
167  bool loadDAEFVector ();
168 
169  // load functions, Jacobian:
170  bool loadDAEdQdx ();
171  bool loadDAEdFdx ();
172 
173  void setupPointers();
174 
175  void varTypes( std::vector<char> & varTypeVec );
176 
177 public:
178  // iterator reference to the resistor model which owns this instance.
179  // Getters and setters
181  {
182  return model_;
183  }
184 
185 private:
186 
187  Model & model_; //< Owning model
188 
189  // Data Members for Class Attributes
190 
191  // User-specified parameters:
192  int numLumps;
194 
195  double length;
196 
199 
200  double L,C,G,R;
201 
202  std::vector<lumpData>lumpVec;
203 
204  std::vector< std::vector<int> > jacStamp;
205 };
206 
207 //-----------------------------------------------------------------------------
208 // Class : Model
209 // Purpose :
210 // Special Notes :
211 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
212 // Creation Date : 12/11/09
213 //-----------------------------------------------------------------------------
214 class Model : public DeviceModel
215 {
216  typedef std::vector<Instance *> InstanceVector;
217 
218  friend class ParametricData<Model>;
219  friend class Instance;
220  friend class Traits;
221 
222 public:
223  Model(
224  const Configuration & configuration,
225  const ModelBlock & MB,
226  const FactoryBlock & factory_block);
227  ~Model ();
228 
229 private:
230  Model();
231  Model(const Model &);
232  Model &operator=(const Model &);
233 
234 public:
235  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
236 
237  virtual std::ostream &printOutInstances(std::ostream &os) const;
238  bool processParams ();
239  bool processInstanceParams ();
240 
241 public:
242  void addInstance(Instance *instance)
243  {
244  instanceContainer.push_back(instance);
245  }
246 
247 private:
248  // input parameters:
250  double resist;
251  double induct;
252  double conduct;
253  double capac;
254 
260 
261  int specialCase; // what kind of model (RC, RLC, RL, ...)
262 
263  std::vector<Instance*> instanceContainer;
264 
265 private:
266 
267 };
268 
269 void registerDevice();
270 
271 } // namespace TransLine
272 } // namespace Device
273 } // namespace Xyce
274 
275 #endif // Xyce_N_DEV_TransLine_h
276 
bool updateTemperature(const double &temp_tmp)
virtual std::ostream & printOutInstances(std::ostream &os) const
void varTypes(std::vector< char > &varTypeVec)
Pure virtual class to augment a linear system.
const std::vector< std::vector< int > > & jacobianStamp() const
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
bool processInstanceParams()
processInstanceParams
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
Instance & operator=(const Instance &)
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Model & operator=(const Model &)
static void loadModelParameters(ParametricData< Model > &model_parameters)
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
std::vector< Instance * > InstanceVector
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
std::vector< std::vector< int > > jacStamp
static const char * name()
bool processParams()
processParams
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Citer, const FactoryBlock &factory_block)
std::vector< Instance * > instanceContainer
Class Configuration contains device configuration data.
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
void addInstance(Instance *instance)
std::vector< lumpData > lumpVec
static const char * deviceTypeName()
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 registerStateLIDs(const std::vector< int > &staLIDVecRef)