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.98.2.1 $
40 //
41 // Revision Date : $Date: 2014/02/26 20:16:30 $
42 //
43 // Current Owner : $Author: tvrusso $
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 const int numNodes() {return 2;}
73  static const char *primaryParameter() {return "DCV0";}
74  static const char *instanceDefaultParameter() {return "DCV0";}
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 //-----------------------------------------------------------------------------
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;friend class Master;
94 
95 public:
96  Instance(
97  const Configuration & configuration,
98  const InstanceBlock & instance_block,
99  Model & model,
100  const FactoryBlock & factory_block);
101 
102  ~Instance();
103 
104 private:
105  Instance(const Instance &);
106  Instance &operator=(const Instance &);
107 
108 public:
109  void registerLIDs( const std::vector<int> & intLIDVecRef,
110  const std::vector<int> & extLIDVecRef);
111  void registerStateLIDs( const std::vector<int> & staLIDVecRef);
112 
113  void registerStoreLIDs(const std::vector<int> & stoLIDVecRef );
114 
115  std::map<int,std::string> & getStoreNameMap ();
116 
117  const std::vector< std::vector<int> > & jacobianStamp() const;
118 
119  bool processParams ();
120 
121  bool updateIntermediateVars () { return true;};
122  bool updatePrimaryState ();
123 
124  bool loadTrivialMatrixStamp ();
126 
127  // load functions, residual:
128  bool loadDAEQVector () { return true; }
129  bool loadDAEFVector ();
130 
131  // load functions, Jacobian:
132  bool loadDAEdQdx () { return true; }
133  bool loadDAEdFdx () { return true; }
134 
135  bool loadBVectorsforAC (double * bVecReal, double * bVecImag);
136 
137 protected:
138 private:
139 
140 public:
141  // iterator reference to the ISRC model that owns this instance.
142  // Getters and setters
144  {
145  return model_;
146  }
147 
148 private:
149  static std::vector< std::vector<int> > jacStamp;
150 
151  Model & model_; //< Owning model
152 
153  // index variables:
154  int li_Pos;
155  int li_Neg;
156 
157  // Store variables
159 
160  // Parameters
161  double DCV0;
162  double par0;
163  double par1;
164  double par2;
165  double par3;
166  double par4;
167  double par5;
168  double par6;
169  double par7;
170  double REPEATTIME;
171  double T;
172  double V;
173  int NUM;
174  bool REPEAT;
181  bool gotParams;
182 
183 
184  double ACMAG;
185  double ACPHASE;
186 };
187 
188 //-----------------------------------------------------------------------------
189 // Class : Model
190 // Purpose :
191 // Special Notes :
192 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
193 // Creation Date : 04/06/00
194 //-----------------------------------------------------------------------------
195 class Model : public DeviceModel
196 {
197  typedef std::vector<Instance *> InstanceVector;
198 
199  friend class Instance;
200  friend class Traits;friend class Master;
201 
202 public:
203  Model(
204  const Configuration & configuration,
205  const ModelBlock & MB,
206  const FactoryBlock & factory_block);
207  ~Model ();
208 
209 private:
210  Model();
211  Model(const Model &);
212  Model &operator=(const Model &);
213 
214 public:
215  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
216 
217  virtual std::ostream &printOutInstances(std::ostream &os) const;
218  virtual bool processParams();
219  virtual bool processInstanceParams();
220 
221 public:
222  void addInstance(Instance *instance)
223  {
224  instanceContainer.push_back(instance);
225  }
226 
228  {
229  return instanceContainer;
230  }
231 
233  {
234  return instanceContainer;
235  }
236 
237 private:
238  std::vector<Instance*> instanceContainer;
239 
240 private:
241 };
242 
243 //-----------------------------------------------------------------------------
244 // Function : Instance::loadTrivialMatrixStamp ()
245 // Purpose :
246 // Special Notes :
247 // Scope : public
248 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
249 // Creation Date : 07/24/03
250 //-----------------------------------------------------------------------------
252 {
253  return true;
254 }
255 
256 //-----------------------------------------------------------------------------
257 // Function : Instance::loadTrivialDAE_FMatrixStamp ()
258 // Purpose :
259 // Special Notes :
260 // Scope : public
261 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
262 // Creation Date : 07/24/03
263 //-----------------------------------------------------------------------------
265 {
266  return true;
267 }
268 //-----------------------------------------------------------------------------
269 // Class : Master
270 // Purpose :
271 // Special Notes :
272 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
273 // Creation Date : 11/26/08
274 //-----------------------------------------------------------------------------
275 class Master : public DeviceMaster<Traits>
276 {
277  friend class Instance;
278  friend class Model;
279 
280 public:
282  const Configuration & configuration,
283  const FactoryBlock & factory_block,
284  const SolverState & ss1,
285  const DeviceOptions & do1)
286  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
287  {}
288 
289  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
290 
291  // new DAE stuff:
292  // new DAE load functions, residual:
293  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * storeLeadF, double * storeLeadQ);
294 
295  // new DAE load functions, Jacobian:
296  virtual bool loadDAEMatrices (N_LAS_Matrix & dFdx, N_LAS_Matrix & dQdx);
297 };
298 
299 void registerDevice();
300 
301 } // namespace ISRC
302 } // namespace Device
303 } // namespace Xyce
304 
308 
309 #endif
310