Xyce  6.1
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-2015 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.110.2.1 $
40 //
41 // Revision Date : $Date: 2015/04/02 18:20:10 $
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_DeviceBlock.h>
52 #include <N_DEV_DeviceInstance.h>
53 #include <N_DEV_DeviceMaster.h>
54 #include <N_DEV_DeviceModel.h>
55 #include <N_DEV_Param.h>
56 #include <N_DEV_Source.h>
57 
58 namespace Xyce {
59 namespace Device {
60 namespace ISRC {
61 
62 class Model;
63 class Instance;
64 
65 struct Traits : public DeviceTraits<Model, Instance>
66 {
67  static const char *name() {return "Independent Current Source";}
68  static const char *deviceTypeName() {return "I level 1";}
69  static int numNodes() {return 2;}
70  static const char *primaryParameter() {return "DCV0";}
71  static const char *instanceDefaultParameter() {return "DCV0";}
72  static bool isLinearDevice() {return true;}
73 
74  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
75  static void loadModelParameters(ParametricData<Model> &model_parameters);
76  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
77 };
78 
79 //-----------------------------------------------------------------------------
80 // Class : Instance
81 // Purpose :
82 // Special Notes :
83 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
84 // Creation Date : 04/06/00
85 //-----------------------------------------------------------------------------
86 class Instance : public SourceInstance
87 {
88  friend class ParametricData<Instance>;
89  friend class Model;
90  friend class Traits;
91  friend class Master;
92 
93 public:
94  Instance(
95  const Configuration & configuration,
96  const InstanceBlock & instance_block,
97  Model & model,
98  const FactoryBlock & factory_block);
99 
100  ~Instance();
101 
102 private:
103  Instance(const Instance &);
104  Instance &operator=(const Instance &);
105 
106 public:
107  void registerLIDs( const std::vector<int> & intLIDVecRef,
108  const std::vector<int> & extLIDVecRef);
109  void registerStateLIDs( const std::vector<int> & staLIDVecRef);
110 
111  void registerStoreLIDs(const std::vector<int> & stoLIDVecRef );
112  void registerBranchDataLIDs(const std::vector<int> & branchLIDVecRef);
113  virtual void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
114 
115  const std::vector< std::vector<int> > & jacobianStamp() const;
116 
117  bool processParams ();
118 
119  bool updateIntermediateVars () { return true;};
120  bool updatePrimaryState ();
121 
122  bool loadTrivialMatrixStamp ();
124 
125  // load functions, residual:
126  bool loadDAEQVector () { return true; }
127  bool loadDAEFVector ();
128  bool loadDAEBVector ();
129 
130  // load functions, Jacobian:
131  bool loadDAEdQdx () { return true; }
132  bool loadDAEdFdx () { return true; }
133 
134  bool loadBVectorsforAC (double * bVecReal, double * bVecImag);
135 
136 protected:
137 private:
138 
139 public:
140  // iterator reference to the ISRC model that owns this instance.
141  // Getters and setters
143  {
144  return model_;
145  }
146 
147 private:
148  static std::vector< std::vector<int> > jacStamp;
149 
150  Model & model_; //< Owning model
151 
152  // index variables:
153  int li_Pos;
154  int li_Neg;
155 
156  // Store variables
158  int li_branch_data; ///< Index for lead current and junction voltage (for power calculations)
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;
201  friend class Master;
202 
203 public:
204  Model(
205  const Configuration & configuration,
206  const ModelBlock & MB,
207  const FactoryBlock & factory_block);
208  ~Model ();
209 
210 private:
211  Model();
212  Model(const Model &);
213  Model &operator=(const Model &);
214 
215 public:
216  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
217 
218  virtual std::ostream &printOutInstances(std::ostream &os) const;
219  virtual bool processParams();
220  virtual bool processInstanceParams();
221 
222 public:
223  void addInstance(Instance *instance)
224  {
225  instanceContainer.push_back(instance);
226  }
227 
228 private:
229  std::vector<Instance*> instanceContainer;
230 
231 private:
232 };
233 
234 //-----------------------------------------------------------------------------
235 // Function : Instance::loadTrivialMatrixStamp ()
236 // Purpose :
237 // Special Notes :
238 // Scope : public
239 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
240 // Creation Date : 07/24/03
241 //-----------------------------------------------------------------------------
243 {
244  return true;
245 }
246 
247 //-----------------------------------------------------------------------------
248 // Function : Instance::loadTrivialDAE_FMatrixStamp ()
249 // Purpose :
250 // Special Notes :
251 // Scope : public
252 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
253 // Creation Date : 07/24/03
254 //-----------------------------------------------------------------------------
256 {
257  return true;
258 }
259 
260 //-----------------------------------------------------------------------------
261 // Class : Master
262 // Purpose :
263 // Special Notes :
264 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
265 // Creation Date : 11/26/08
266 //-----------------------------------------------------------------------------
267 class Master : public DeviceMaster<Traits>
268 {
269  friend class Instance;
270  friend class Model;
271 
272 public:
274  const Configuration & configuration,
275  const FactoryBlock & factory_block,
276  const SolverState & ss1,
277  const DeviceOptions & do1)
278  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
279  {}
280 
281  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
282 
283  // new DAE stuff:
284  // new DAE load functions, residual:
285  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ, double * leadF, double * leadQ, double * junctionV);
286 
287  // new DAE load functions, Jacobian:
288  virtual bool loadDAEMatrices (Linear::Matrix & dFdx, Linear::Matrix & dQdx);
289 };
290 
291 void registerDevice();
292 
293 } // namespace ISRC
294 } // namespace Device
295 } // namespace Xyce
296 
297 #endif
298 
static const char * instanceDefaultParameter()
Definition: N_DEV_ISRC.h:71
virtual bool processParams()
processParams
Definition: N_DEV_ISRC.C:677
virtual bool loadDAEMatrices(Linear::Matrix &dFdx, Linear::Matrix &dQdx)
Populates the device's Jacobian object with these pointers.
Definition: N_DEV_ISRC.C:836
std::vector< Instance * > InstanceVector
Definition: N_DEV_ISRC.h:197
void registerBranchDataLIDs(const std::vector< int > &branchLIDVecRef)
Register the local store IDs.
Definition: N_DEV_ISRC.C:475
Pure virtual class to augment a linear system.
static void loadModelParameters(ParametricData< Model > &model_parameters)
Definition: N_DEV_ISRC.C:191
Instance(const Configuration &configuration, const InstanceBlock &instance_block, Model &model, const FactoryBlock &factory_block)
Definition: N_DEV_ISRC.C:206
Model & operator=(const Model &)
int li_branch_data
Index for lead current and junction voltage (for power calculations)
Definition: N_DEV_ISRC.h:158
static const char * deviceTypeName()
Definition: N_DEV_ISRC.h:68
static const char * primaryParameter()
Definition: N_DEV_ISRC.h:70
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
Definition: N_DEV_ISRC.C:388
virtual bool updateState(double *solVec, double *staVec, double *stoVec)
Updates the devices state information.
Definition: N_DEV_ISRC.C:782
DeviceMaster instantiates a device as described by the device traits T.
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
Definition: N_DEV_ISRC.C:428
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
Master(const Configuration &configuration, const FactoryBlock &factory_block, const SolverState &ss1, const DeviceOptions &do1)
Definition: N_DEV_ISRC.h:273
bool loadBVectorsforAC(double *bVecReal, double *bVecImag)
Definition: N_DEV_ISRC.C:528
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
Definition: N_DEV_ISRC.C:842
virtual std::ostream & printOutInstances(std::ostream &os) const
Definition: N_DEV_ISRC.C:713
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Definition: N_DEV_ISRC.C:69
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
static std::vector< std::vector< int > > jacStamp
Definition: N_DEV_ISRC.h:148
Class Configuration contains device configuration data.
std::vector< Instance * > instanceContainer
Definition: N_DEV_ISRC.h:229
void registerStoreLIDs(const std::vector< int > &stoLIDVecRef)
Definition: N_DEV_ISRC.C:441
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
Definition: N_DEV_ISRC.C:764
virtual bool processInstanceParams()
processInstanceParams
Definition: N_DEV_ISRC.C:690
virtual bool loadDAEVectors(double *solVec, double *fVec, double *qVec, double *bVec, double *storeLeadF, double *storeLeadQ, double *leadF, double *leadQ, double *junctionV)
Populates the device's ExternData object with these pointers.
Definition: N_DEV_ISRC.C:795
static bool isLinearDevice()
Definition: N_DEV_ISRC.h:72
void addInstance(Instance *instance)
Definition: N_DEV_ISRC.h:223
virtual void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
Definition: N_DEV_ISRC.C:493
const std::vector< std::vector< int > > & jacobianStamp() const
Definition: N_DEV_ISRC.C:511
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.
static const char * name()
Definition: N_DEV_ISRC.h:67
Instance & operator=(const Instance &)