Xyce  6.1
N_DEV_VCCS.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_VCCS.h,v $
27 //
28 // Purpose : Voltage contolled current source classes.
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.91.2.1 $
40 //
41 // Revision Date : $Date: 2015/04/02 18:20:11 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-----------------------------------------------------------------------------
45 
46 #ifndef Xyce_N_DEV_VCCS_h
47 #define Xyce_N_DEV_VCCS_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 namespace Xyce {
58 namespace Device {
59 namespace VCCS {
60 
61 class Model;
62 class Instance;
63 
64 struct Traits : public DeviceTraits<Model, Instance>
65 {
66  static const char *name() {return "Linear Voltage Controlled Current Source";}
67  static const char *deviceTypeName() {return "G level 1";}
68  static int numNodes() {return 4;}
69  static const char *primaryParameter() {return "T";}
70  static bool isLinearDevice() {return true;}
71 
72  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
73  static void loadModelParameters(ParametricData<Model> &model_parameters);
74  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
75 };
76 
77 //-----------------------------------------------------------------------------
78 // Class : Instance
79 // Purpose :
80 // Special Notes :
81 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
82 // Creation Date : 3/16/00
83 //-----------------------------------------------------------------------------
84 class Instance : public DeviceInstance
85 {
86  friend class ParametricData<Instance>;
87  friend class Model;
88  friend class Traits;friend class Master;
89 
90 public:
91  Instance(
92  const Configuration & configuration,
93  const InstanceBlock & instance_block,
94  Model & model,
95  const FactoryBlock & factory_block);
96 
97  ~Instance();
98 
99 private:
100  Instance(const Instance &);
101  Instance &operator=(const Instance &);
102 
103 public:
104  void registerLIDs( const std::vector<int> & intLIDVecRef,
105  const std::vector<int> & extLIDVecRef);
106  void registerStateLIDs( const std::vector<int> & staLIDVecRef);
107  void registerStoreLIDs( const std::vector<int> & stoLIDVecRef);
108 
109  virtual void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
110 
111  const std::vector< std::vector<int> > & jacobianStamp() const;
112 
113  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
114 
115  bool updateIntermediateVars () { return true; };
116  bool updatePrimaryState ();
117 
118  // load functions, residual:
119  bool loadDAEQVector () {return true;}
120  bool loadDAEFVector ();
121 
122  // load functions, Jacobian:
123  bool loadDAEdQdx () {return true;}
124  bool loadDAEdFdx ();
125 
126  void setupPointers();
127 
128 public:
129  // iterator reference to the VCCS model which owns this instance.
130  // Getters and setters
132  {
133  return model_;
134  }
135 
136 private:
137  static std::vector< std::vector<int> > jacStamp;
138 
139  Model & model_; //< Owning model
140 
142 
143  // Matrix equation index variables:
144  // local indices (offsets)
145  int li_Pos;
146  int li_Neg;
147 
150 
152 
153  // Offset variables for all of the above index variables.
158 
163 };
164 
165 //-----------------------------------------------------------------------------
166 // Class : Model
167 // Purpose :
168 // Special Notes :
169 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
170 // Creation Date : 3/16/00
171 //-----------------------------------------------------------------------------
172 class Model : public DeviceModel
173 {
174  typedef std::vector<Instance *> InstanceVector;
175 
176  friend class ParametricData<Model>;
177  friend class Instance;
178  friend class Traits;friend class Master;
179 
180 public:
181  Model(
182  const Configuration & configuration,
183  const ModelBlock & MB,
184  const FactoryBlock & factory_block);
185  ~Model();
186 
187 private:
188  Model();
189  Model(const Model &);
190  Model &operator=(const Model &);
191 
192 public:
193  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
194 
195  virtual std::ostream &printOutInstances(std::ostream &os) const;
196  virtual bool processParams()
197  {
198  return true;
199  }
200 
201  virtual bool processInstanceParams()
202  {
203  return true;
204  }
205 
206 public:
207  void addInstance(Instance *instance)
208  {
209  instanceContainer.push_back(instance);
210  }
211 
212 private:
213  std::vector<Instance*> instanceContainer;
214 
215 private:
216 };
217 
218 //-----------------------------------------------------------------------------
219 // Class : Master
220 // Purpose :
221 // Special Notes :
222 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
223 // Creation Date : 11/26/08
224 //-----------------------------------------------------------------------------
225 class Master : public DeviceMaster<Traits>
226 {
227  friend class Instance;
228  friend class Model;
229 
230 public:
232  const Configuration & configuration,
233  const FactoryBlock & factory_block,
234  const SolverState & ss1,
235  const DeviceOptions & do1)
236  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
237  {}
238 
239  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
240 
241  // load functions:
242  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ, double * leadF, double * leadQ, double * junctionV);
243  virtual bool loadDAEMatrices (Linear::Matrix & dFdx, Linear::Matrix & dQdx);
244 };
245 
246 void registerDevice();
247 
248 } // namespace VCCS
249 } // namespace Device
250 } // namespace Xyce
251 
252 #endif
std::vector< Instance * > instanceContainer
Definition: N_DEV_VCCS.h:213
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_VCCS.C:475
Instance & operator=(const Instance &)
Pure virtual class to augment a linear system.
static const char * primaryParameter()
Definition: N_DEV_VCCS.h:69
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
Definition: N_DEV_VCCS.C:445
virtual bool updateState(double *solVec, double *staVec, double *stoVec)
Updates the devices state information.
Definition: N_DEV_VCCS.C:462
virtual bool processParams()
processParams
Definition: N_DEV_VCCS.h:196
const std::vector< std::vector< int > > & jacobianStamp() const
Definition: N_DEV_VCCS.C:240
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Definition: N_DEV_VCCS.C:68
static const char * deviceTypeName()
Definition: N_DEV_VCCS.h:67
DeviceMaster instantiates a device as described by the device traits T.
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
Definition: N_DEV_VCCS.C:253
Instance(const Configuration &configuration, const InstanceBlock &instance_block, Model &model, const FactoryBlock &factory_block)
Definition: N_DEV_VCCS.C:89
virtual bool processInstanceParams()
processInstanceParams
Definition: N_DEV_VCCS.h:201
Master(const Configuration &configuration, const FactoryBlock &factory_block, const SolverState &ss1, const DeviceOptions &do1)
Definition: N_DEV_VCCS.h:231
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
virtual bool loadDAEMatrices(Linear::Matrix &dFdx, Linear::Matrix &dQdx)
Populates the device's Jacobian object with these pointers.
Definition: N_DEV_VCCS.C:503
static bool isLinearDevice()
Definition: N_DEV_VCCS.h:70
Class Configuration contains device configuration data.
Model & operator=(const Model &)
static void loadModelParameters(ParametricData< Model > &model_parameters)
Definition: N_DEV_VCCS.C:74
static const char * name()
Definition: N_DEV_VCCS.h:66
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
Definition: N_DEV_VCCS.C:161
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
Definition: N_DEV_VCCS.C:206
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
Definition: N_DEV_VCCS.C:526
static std::vector< std::vector< int > > jacStamp
Definition: N_DEV_VCCS.h:137
void addInstance(Instance *instance)
Definition: N_DEV_VCCS.h:207
virtual void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
Definition: N_DEV_VCCS.C:291
virtual std::ostream & printOutInstances(std::ostream &os) const
Definition: N_DEV_VCCS.C:410
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.
std::vector< Instance * > InstanceVector
Definition: N_DEV_VCCS.h:174
void registerStoreLIDs(const std::vector< int > &stoLIDVecRef)
Definition: N_DEV_VCCS.C:220