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.113 $
40 //
41 // Revision Date : $Date: 2015/04/20 20:43:55 $
42 //
43 // Current Owner : $Author: dgbaur $
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 
108  bool isLinearDevice() const { return true; }
109 
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  void registerBranchDataLIDs(const std::vector<int> & branchLIDVecRef);
116  virtual void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
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  int li_branch_data; ///< Index for lead current and junction voltage (for power calculations)
162 
165 
166  // Parameters
167  double DCV0;
168  double par0;
169  double par1;
170  double par2;
171  double par3;
172  double par4;
173  double par5;
174  double par6;
175  double par7;
176  double REPEATTIME;
177  double T;
178  double V;
179  int NUM;
180  bool REPEAT;
187  bool gotParams;
188 
189  double ACMAG;
190  double ACPHASE;
191 };
192 
193 //-----------------------------------------------------------------------------
194 // Class : Model
195 // Purpose :
196 // Special Notes :
197 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
198 // Creation Date : 04/06/00
199 //-----------------------------------------------------------------------------
200 class Model : public DeviceModel
201 {
202  typedef std::vector<Instance *> InstanceVector;
203 
204  friend class Instance;
205  friend class Traits;
206  friend class Master;
207 
208 public:
209  Model(
210  const Configuration & configuration,
211  const ModelBlock & MB,
212  const FactoryBlock & factory_block);
213  ~Model ();
214 
215 private:
216  Model();
217  Model(const Model &);
218  Model &operator=(const Model &);
219 
220 public:
221  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
222 
223  virtual std::ostream &printOutInstances(std::ostream &os) const;
224  virtual bool processParams();
225  virtual bool processInstanceParams();
226 
227 public:
228  void addInstance(Instance *instance)
229  {
230  instanceContainer.push_back(instance);
231  }
232 
233 private:
234  std::vector<Instance*> instanceContainer;
235 
236 private:
237 };
238 
239 //-----------------------------------------------------------------------------
240 // Function : Instance::loadTrivialMatrixStamp ()
241 // Purpose :
242 // Special Notes :
243 // Scope : public
244 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
245 // Creation Date : 07/24/03
246 //-----------------------------------------------------------------------------
248 {
249  return true;
250 }
251 
252 //-----------------------------------------------------------------------------
253 // Function : Instance::loadTrivialDAE_FMatrixStamp ()
254 // Purpose :
255 // Special Notes :
256 // Scope : public
257 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
258 // Creation Date : 07/24/03
259 //-----------------------------------------------------------------------------
261 {
262  return true;
263 }
264 
265 //-----------------------------------------------------------------------------
266 // Class : Master
267 // Purpose :
268 // Special Notes :
269 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
270 // Creation Date : 11/26/08
271 //-----------------------------------------------------------------------------
272 class Master : public DeviceMaster<Traits>
273 {
274  friend class Instance;
275  friend class Model;
276 
277 public:
278  Master(
279  const Configuration & configuration,
280  const FactoryBlock & factory_block,
281  const SolverState & solver_state,
282  const DeviceOptions & device_options);
283 
284  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
285 
286  // new DAE stuff:
287  // new DAE load functions, residual:
288  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ, double * leadF, double * leadQ, double * junctionV);
289 
290  // new DAE load functions, Jacobian:
291  virtual bool loadDAEMatrices (Linear::Matrix & dFdx, Linear::Matrix & dQdx);
292 
293 private:
295 };
296 
297 void registerDevice();
298 
299 } // namespace ISRC
300 } // namespace Device
301 } // namespace Xyce
302 
303 #endif
304 
static const char * instanceDefaultParameter()
Definition: N_DEV_ISRC.h:71
virtual bool processParams()
processParams
Definition: N_DEV_ISRC.C:676
virtual bool loadDAEMatrices(Linear::Matrix &dFdx, Linear::Matrix &dQdx)
Populates the device's Jacobian object with these pointers.
Definition: N_DEV_ISRC.C:844
std::vector< Instance * > InstanceVector
Definition: N_DEV_ISRC.h:202
void registerBranchDataLIDs(const std::vector< int > &branchLIDVecRef)
Register the local store IDs.
Definition: N_DEV_ISRC.C:476
Pure virtual class to augment a linear system.
static void loadModelParameters(ParametricData< Model > &model_parameters)
Definition: N_DEV_ISRC.C:192
Instance(const Configuration &configuration, const InstanceBlock &instance_block, Model &model, const FactoryBlock &factory_block)
Definition: N_DEV_ISRC.C:207
Model & operator=(const Model &)
int li_branch_data
Index for lead current and junction voltage (for power calculations)
Definition: N_DEV_ISRC.h:161
static const char * deviceTypeName()
Definition: N_DEV_ISRC.h:68
static const char * primaryParameter()
Definition: N_DEV_ISRC.h:70
Master(const Configuration &configuration, const FactoryBlock &factory_block, const SolverState &solver_state, const DeviceOptions &device_options)
Definition: N_DEV_ISRC.C:773
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
Definition: N_DEV_ISRC.C:389
virtual bool updateState(double *solVec, double *staVec, double *stoVec)
Updates the devices state information.
Definition: N_DEV_ISRC.C:790
DeviceMaster instantiates a device as described by the device traits T.
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
Definition: N_DEV_ISRC.C:429
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
bool isLinearDevice() const
Definition: N_DEV_ISRC.h:108
bool loadBVectorsforAC(double *bVecReal, double *bVecImag)
Definition: N_DEV_ISRC.C:529
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
Definition: N_DEV_ISRC.C:850
virtual std::ostream & printOutInstances(std::ostream &os) const
Definition: N_DEV_ISRC.C:712
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Definition: N_DEV_ISRC.C:70
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:151
Class Configuration contains device configuration data.
std::vector< Instance * > instanceContainer
Definition: N_DEV_ISRC.h:234
void registerStoreLIDs(const std::vector< int > &stoLIDVecRef)
Definition: N_DEV_ISRC.C:442
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
Definition: N_DEV_ISRC.C:763
virtual bool processInstanceParams()
processInstanceParams
Definition: N_DEV_ISRC.C:689
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:803
static bool isLinearDevice()
Definition: N_DEV_ISRC.h:72
void addInstance(Instance *instance)
Definition: N_DEV_ISRC.h:228
virtual void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
Definition: N_DEV_ISRC.C:494
const std::vector< std::vector< int > > & jacobianStamp() const
Definition: N_DEV_ISRC.C:512
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 &)