Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_ACC.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_ACC.h,v $
27 //
28 // Purpose : ACC classes: provide a device that integrates the
29 // equations of motion of an accelerated body to give its
30 // instantaneous position and velocity
31 //
32 // Special Notes : Intended for use in Coil Gun LDRD netlists.
33 //
34 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
35 //
36 // Creation Date : 10/24/07
37 //
38 // Revision Information:
39 // ---------------------
40 //
41 // Revision Number: $Revision: 1.24.2.1 $
42 //
43 // Revision Date : $Date: 2014/02/26 20:16:30 $
44 //
45 // Current Owner : $Author: tvrusso $
46 //-----------------------------------------------------------------------------
47 
48 #ifndef Xyce_N_DEV_ACC_h
49 #define Xyce_N_DEV_ACC_h
50 // ---------- Xyce Includes ----------
51 #include <N_DEV_Configuration.h>
52 #include <N_DEV_DeviceBlock.h>
53 #include <N_DEV_DeviceInstance.h>
54 #include <N_DEV_DeviceModel.h>
55 
56 namespace Xyce {
57 namespace Device {
58 namespace ACC {
59 
60 class Model;
61 class Instance;
62 
63 struct Traits : public DeviceTraits<Model, Instance>
64 {
65  static const char *name() {return "Accelerated Object Device";}
66  static const char *deviceTypeName() {return "ACC level 1";}
67  static const int numNodes() {return 3;}
68  static const bool isLinearDevice() {return true;}
69 
70  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
71  static void loadModelParameters(ParametricData<Model> &model_parameters);
72  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
73 };
74 
75 //-----------------------------------------------------------------------------
76 // Class : Instance
77 // Purpose :
78 //
79 // This is the instance class for accelerated object devices. It
80 // contains "unique" ACC device information - ie stuff that
81 // will be true of only one ACC in the circuit, such
82 // as the nodes to which it is connected. An ACC is
83 // connected to only one circuit node, from which it gets the
84 // acceleration.
85 //
86 // This class does not directly contain information about
87 // its node indices. It contains indices into the 3 parts
88 // (A, dx, and b) of the matrix problem A*dx = b, and
89 // also x. A is the Jacobian matrix, dx is the update to
90 // the solution vector x, and b is the right hand side
91 // function vector. These indices are global, and
92 // determined by topology during the initialization stage
93 // of execution.
94 //
95 // Special Notes :
96 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
97 // Creation Date : 10/24/07
98 //-----------------------------------------------------------------------------
99 class Instance : public DeviceInstance
100 {
101  friend class ParametricData<Instance>;
102  friend class Model;
103  friend class Traits;
104 
105 public:
106 
107  Instance(
108  const Configuration & configuration,
109  const InstanceBlock & IB,
110  Model & Riter,
111  const FactoryBlock & factory_block);
112 
113  ~Instance();
114 
115 private:
116  Instance(const Instance &);
117  Instance &operator=(const Instance &);
118 
119 public:
120  void registerLIDs( const std::vector<int> & intLIDVecRef,
121  const std::vector<int> & extLIDVecRef );
122  void registerStateLIDs( const std::vector<int> & staLIDVecRef );
123 
124  std::map<int,std::string> & getIntNameMap ();
125 
126  bool updateIntermediateVars ();
127  bool updatePrimaryState ();
128  bool updateSecondaryState ();
129 
130  const std::vector< std::vector<int> > & jacobianStamp() const;
131  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
132 
133  // load functions, residual:
134  bool loadDAEQVector ();
135  bool loadDAEFVector ();
136 
137  // load functions, Jacobian:
138  bool loadDAEdQdx ();
139  bool loadDAEdFdx ();
140 
141 public:
142  // iterator reference to the ACC model which owns this instance.
143  // Getters and setters
145  {
146  return model_;
147  }
148 
149 private:
150  static std::vector< std::vector<int> > jacStamp;
151 
152  Model & model_; //< Owning model
153 
154  // user-specified paramters:
155  double v0; // initial velocity
156  double x0; // initial position
157 
158  // Local indices:
159  // Acceleration (an external node)
160  int li_Acc;
161  // velocity (internal node)
163  // position (internal node)
165 
166  // state variable IDs:
169 
170  // Jacobian offsets:
175 
176  // Instance variables --- mostly copies of stuff from solution vector
177  // to reduce calls to operator[]
178  double position;
179  double velocity;
180  double acceleration;
181 
182  //things we take out of the state vector derivatives
183  double xdot;
184  double vdot;
185 };
186 
187 //-----------------------------------------------------------------------------
188 // Class : Model
189 // Purpose :
190 //
191 //
192 // Special Notes :
193 // Creator : Tom Russo, SNL, Electrical and Microsystems Modeling
194 // Creation Date : 10/24/07
195 //-----------------------------------------------------------------------------
196 class Model : public DeviceModel
197 {
198  typedef std::vector<Instance *> InstanceVector;
199 
200  friend class ParametricData<Model>;
201  friend class Instance;
202  friend class Traits;
203 
204 public:
205  Model(
206  const Configuration & configuration,
207  const ModelBlock & MB,
208  const FactoryBlock & factory_block);
209  ~Model();
210 
211 private:
212  Model();
213  Model(const Model &);
214  Model &operator=(const Model &);
215 
216 public:
217  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
218 
219  virtual std::ostream &printOutInstances(std::ostream &os) const;
220 
221  virtual bool processParams()
222  {
223  return true;
224  }
225 
226  virtual bool processInstanceParams()
227  {
228  return true;
229  }
230 
231 public:
232  void addInstance(Instance *instance)
233  {
234  instanceContainer.push_back(instance);
235  }
236 
238  {
239  return instanceContainer;
240  }
241 
243  {
244  return instanceContainer;
245  }
246 
247 private:
248  std::vector<Instance*> instanceContainer;
249 
250 private:
251 };
252 
253 void registerDevice();
254 
255 } // namespace ACC
256 } // namespace Device
257 } // namespace Xyce
258 
261 
262 #endif // Xyce_N_DEV_ACC_h