Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_TransLine.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright (c) 2002, 2013, 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-2014 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.25.2.1 $
41 //
42 // Revision Date : $Date: 2014/02/26 20:16:30 $
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 "Lossy Transmission Line";}
72  static const char *deviceTypeName() {return "YTRANSLINE level 1";}
73  static const int numNodes() {return 2;}
74  static const bool modelRequired() {return true;}
75  static const 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  std::map<int,std::string> & getIntNameMap ();
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  bool loadDeviceMask ();
166 
167  // load functions, residual:
168  bool loadDAEQVector ();
169  bool loadDAEFVector ();
170 
171  // load functions, Jacobian:
172  bool loadDAEdQdx ();
173  bool loadDAEdFdx ();
174 
175  void setupPointers();
176 
177  void varTypes( std::vector<char> & varTypeVec );
178 
179 public:
180  // iterator reference to the resistor model which owns this instance.
181  // Getters and setters
183  {
184  return model_;
185  }
186 
187 private:
188 
189  Model & model_; //< Owning model
190 
191  // Data Members for Class Attributes
192 
193  // User-specified parameters:
194  int numLumps;
196 
197  double length;
198 
201 
202  double L,C,G,R;
203 
204  std::vector<lumpData>lumpVec;
205 
206  std::vector< std::vector<int> > jacStamp;
207 };
208 
209 //-----------------------------------------------------------------------------
210 // Class : Model
211 // Purpose :
212 // Special Notes :
213 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
214 // Creation Date : 12/11/09
215 //-----------------------------------------------------------------------------
216 class Model : public DeviceModel
217 {
218  typedef std::vector<Instance *> InstanceVector;
219 
220  friend class ParametricData<Model>;
221  friend class Instance;
222  friend class Traits;
223 
224 public:
225  Model(
226  const Configuration & configuration,
227  const ModelBlock & MB,
228  const FactoryBlock & factory_block);
229  ~Model ();
230 
231 private:
232  Model();
233  Model(const Model &);
234  Model &operator=(const Model &);
235 
236 public:
237  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
238 
239  virtual std::ostream &printOutInstances(std::ostream &os) const;
240  bool processParams ();
241  bool processInstanceParams ();
242 
243 public:
244  void addInstance(Instance *instance)
245  {
246  instanceContainer.push_back(instance);
247  }
248 
250  {
251  return instanceContainer;
252  }
253 
255  {
256  return instanceContainer;
257  }
258 
259 private:
260  // input parameters:
262  double resist;
263  double induct;
264  double conduct;
265  double capac;
266 
272 
273  int specialCase; // what kind of model (RC, RLC, RL, ...)
274 
275  std::vector<Instance*> instanceContainer;
276 
277 private:
278 
279 };
280 
281 void registerDevice();
282 
283 } // namespace TransLine
284 } // namespace Device
285 } // namespace Xyce
286 
289 
290 #endif // Xyce__h
291