Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
N_DEV_ISRC.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_ISRC.h,v $
27 //
28 // Purpose : Independent current source
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.104 $
40 //
41 // Revision Date : $Date: 2014/05/22 19:42:13 $
42 //
43 // Current Owner : $Author: erkeite $
44 //-----------------------------------------------------------------------------
45 
46 #ifndef Xyce_N_DEV_ISRC_h
47 #define Xyce_N_DEV_ISRC_h
48 
49 // ---------- Xyce Includes ----------
50 #include <N_DEV_Configuration.h>
51 #include <N_DEV_DeviceMaster.h>
52 #include <N_DEV_Source.h>
53 #include <N_DEV_DeviceBlock.h>
54 #include <N_DEV_DeviceInstance.h>
55 #include <N_DEV_DeviceModel.h>
56 
57 #include <N_DEV_Param.h>
58 
59 #include <N_UTL_BreakPoint.h>
60 
61 namespace Xyce {
62 namespace Device {
63 namespace ISRC {
64 
65 class Model;
66 class Instance;
67 
68 struct Traits : public DeviceTraits<Model, Instance>
69 {
70  static const char *name() {return "Independent Current Source";}
71  static const char *deviceTypeName() {return "I level 1";}
72  static int numNodes() {return 2;}
73  static const char *primaryParameter() {return "DCV0";}
74  static const char *instanceDefaultParameter() {return "DCV0";}
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 //-----------------------------------------------------------------------------
83 // Class : Instance
84 // Purpose :
85 // Special Notes :
86 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
87 // Creation Date : 04/06/00
88 //-----------------------------------------------------------------------------
89 class Instance : public SourceInstance
90 {
91  friend class ParametricData<Instance>;
92  friend class Model;
93  friend class Traits;
94  friend class Master;
95 
96 public:
97  Instance(
98  const Configuration & configuration,
99  const InstanceBlock & instance_block,
100  Model & model,
101  const FactoryBlock & factory_block);
102 
103  ~Instance();
104 
105 private:
106  Instance(const Instance &);
107  Instance &operator=(const Instance &);
108 
109 public:
110  void registerLIDs( const std::vector<int> & intLIDVecRef,
111  const std::vector<int> & extLIDVecRef);
112  void registerStateLIDs( const std::vector<int> & staLIDVecRef);
113 
114  void registerStoreLIDs(const std::vector<int> & stoLIDVecRef );
115 
116  std::map<int,std::string> & getStoreNameMap ();
117 
118  const std::vector< std::vector<int> > & jacobianStamp() const;
119 
120  bool processParams ();
121 
122  bool updateIntermediateVars () { return true;};
123  bool updatePrimaryState ();
124 
125  bool loadTrivialMatrixStamp ();
127 
128  // load functions, residual:
129  bool loadDAEQVector () { return true; }
130  bool loadDAEFVector ();
131  bool loadDAEBVector ();
132 
133  // load functions, Jacobian:
134  bool loadDAEdQdx () { return true; }
135  bool loadDAEdFdx () { return true; }
136 
137  bool loadBVectorsforAC (double * bVecReal, double * bVecImag);
138 
139 protected:
140 private:
141 
142 public:
143  // iterator reference to the ISRC model that owns this instance.
144  // Getters and setters
146  {
147  return model_;
148  }
149 
150 private:
151  static std::vector< std::vector<int> > jacStamp;
152 
153  Model & model_; //< Owning model
154 
155  // index variables:
156  int li_Pos;
157  int li_Neg;
158 
159  // Store variables
161 
162  // Parameters
163  double DCV0;
164  double par0;
165  double par1;
166  double par2;
167  double par3;
168  double par4;
169  double par5;
170  double par6;
171  double par7;
172  double REPEATTIME;
173  double T;
174  double V;
175  int NUM;
176  bool REPEAT;
183  bool gotParams;
184 
185 
186  double ACMAG;
187  double ACPHASE;
188 };
189 
190 //-----------------------------------------------------------------------------
191 // Class : Model
192 // Purpose :
193 // Special Notes :
194 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
195 // Creation Date : 04/06/00
196 //-----------------------------------------------------------------------------
197 class Model : public DeviceModel
198 {
199  typedef std::vector<Instance *> InstanceVector;
200 
201  friend class Instance;
202  friend class Traits;
203  friend class Master;
204 
205 public:
206  Model(
207  const Configuration & configuration,
208  const ModelBlock & MB,
209  const FactoryBlock & factory_block);
210  ~Model ();
211 
212 private:
213  Model();
214  Model(const Model &);
215  Model &operator=(const Model &);
216 
217 public:
218  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
219 
220  virtual std::ostream &printOutInstances(std::ostream &os) const;
221  virtual bool processParams();
222  virtual bool processInstanceParams();
223 
224 public:
225  void addInstance(Instance *instance)
226  {
227  instanceContainer.push_back(instance);
228  }
229 
230 private:
231  std::vector<Instance*> instanceContainer;
232 
233 private:
234 };
235 
236 //-----------------------------------------------------------------------------
237 // Function : Instance::loadTrivialMatrixStamp ()
238 // Purpose :
239 // Special Notes :
240 // Scope : public
241 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
242 // Creation Date : 07/24/03
243 //-----------------------------------------------------------------------------
245 {
246  return true;
247 }
248 
249 //-----------------------------------------------------------------------------
250 // Function : Instance::loadTrivialDAE_FMatrixStamp ()
251 // Purpose :
252 // Special Notes :
253 // Scope : public
254 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
255 // Creation Date : 07/24/03
256 //-----------------------------------------------------------------------------
258 {
259  return true;
260 }
261 
262 //-----------------------------------------------------------------------------
263 // Class : Master
264 // Purpose :
265 // Special Notes :
266 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
267 // Creation Date : 11/26/08
268 //-----------------------------------------------------------------------------
269 class Master : public DeviceMaster<Traits>
270 {
271  friend class Instance;
272  friend class Model;
273 
274 public:
276  const Configuration & configuration,
277  const FactoryBlock & factory_block,
278  const SolverState & ss1,
279  const DeviceOptions & do1)
280  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
281  {}
282 
283  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
284 
285  // new DAE stuff:
286  // new DAE load functions, residual:
287  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ);
288 
289  // new DAE load functions, Jacobian:
290  virtual bool loadDAEMatrices (N_LAS_Matrix & dFdx, N_LAS_Matrix & dQdx);
291 };
292 
293 void registerDevice();
294 
295 } // namespace ISRC
296 } // namespace Device
297 } // namespace Xyce
298 
302 
303 #endif
304