Xyce  6.1
N_DEV_Vcvs.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_Vcvs.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.93 $
40 //
41 // Revision Date : $Date: 2015/04/23 21:57:56 $
42 //
43 // Current Owner : $Author: peshola $
44 //-----------------------------------------------------------------------------
45 
46 #ifndef Xyce_N_DEV_Vcvs_h
47 #define Xyce_N_DEV_Vcvs_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 Vcvs {
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 Voltage Source";}
67  static const char *deviceTypeName() {return "E level 1";}
68  static int numNodes() {return 4;}
69  static const char *primaryParameter() {return "G";}
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 
92  Instance(
93  const Configuration & configuration,
94  const InstanceBlock & IBref,
95  Model & Viter,
96  const FactoryBlock & factory_block);
97 
98  ~Instance();
99 
100 private:
101  Instance(const Instance &);
102  Instance &operator=(const Instance &);
103 
104 public:
105  void registerLIDs( const std::vector<int> & intLIDVecRef,
106  const std::vector<int> & extLIDVecRef );
107  void registerStateLIDs( const std::vector<int> & staLIDVecRef );
108 
109  void registerBranchDataLIDs(const std::vector<int> & branchLIDVecRef);
110 
111  void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
112 
113  const std::vector< std::vector<int> > & jacobianStamp() const;
114  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
115 
116  bool updateIntermediateVars () { return true; };
117  bool updatePrimaryState ();
118 
119  // load functions, residual:
120  bool loadDAEQVector () {return true;}
121  bool loadDAEFVector ();
122 
123  // load functions, Jacobian:
124  bool loadDAEdQdx () {return true;}
125  bool loadDAEdFdx ();
126 
127  void setupPointers();
128 
129  void varTypes( std::vector<char> & varTypeVec );
130 
131 public:
132  // iterator reference to the vcvs model which owns this instance.
133  // Getters and setters
135  {
136  return model_;
137  }
138 
139 private:
140  static std::vector< std::vector<int> > jacStamp;
141 
142  Model & model_; //< Owning model
143 
144  double Gain;
145  double LeadCurrent;
146 
148 
149  // Matrix equation index variables:
150 
151  // local indices (offsets)
152  int li_Pos;
153  int li_Neg;
154  int li_Bra;
155 
158 
159  int li_branch_data; ///< Index for lead current and junction voltage (for power calculations)
160 
161  // Offset variables for all of the above index variables.
168 
169  // Ptr variables for all of the above index variables.
176 };
177 
178 //-----------------------------------------------------------------------------
179 // Class : Model
180 // Purpose :
181 // Special Notes :
182 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
183 // Creation Date : 3/16/00
184 //-----------------------------------------------------------------------------
185 class Model : public DeviceModel
186 {
187  typedef std::vector<Instance *> InstanceVector;
188 
189  friend class ParametricData<Model>;
190  friend class Instance;
191  friend class Traits;friend class Master;
192 
193 public:
194  Model(
195  const Configuration & configuration,
196  const ModelBlock & MB,
197  const FactoryBlock & factory_block);
198  ~Model();
199 
200 private:
201  Model();
202  Model(const Model &);
203  Model &operator=(const Model &);
204 
205 public:
206  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
207 
208  virtual std::ostream &printOutInstances(std::ostream &os) const;
209 
210  virtual bool processParams()
211  {
212  return true;
213  }
214 
215  virtual bool processInstanceParams()
216  {
217  return true;
218  }
219 
220 
221 public:
222  void addInstance(Instance *instance)
223  {
224  instanceContainer.push_back(instance);
225  }
226 
227 private:
228  std::vector<Instance*> instanceContainer;
229 
230 private:
231 };
232 
233 //-----------------------------------------------------------------------------
234 // Class : Master
235 // Purpose :
236 // Special Notes :
237 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
238 // Creation Date : 11/26/08
239 //-----------------------------------------------------------------------------
240 class Master : public DeviceMaster<Traits>
241 {
242  friend class Instance;
243  friend class Model;
244 
245 public:
247  const Configuration & configuration,
248  const FactoryBlock & factory_block,
249  const SolverState & ss1,
250  const DeviceOptions & do1)
251  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
252  {}
253 
254  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
255 
256  // load functions:
257  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ, double * leadF, double * leadQ, double * junctionV);
258  virtual bool loadDAEMatrices (Linear::Matrix & dFdx, Linear::Matrix & dQdx);
259 
260 };
261 
262 void registerDevice();
263 
264 } // namespace Vcvs
265 } // namespace Device
266 } // namespace Xyce
267 
268 #endif
Instance(const Configuration &configuration, const InstanceBlock &IBref, Model &Viter, const FactoryBlock &factory_block)
Definition: N_DEV_Vcvs.C:90
static bool isLinearDevice()
Definition: N_DEV_Vcvs.h:70
static const char * deviceTypeName()
Definition: N_DEV_Vcvs.h:67
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
Definition: N_DEV_Vcvs.C:295
void addInstance(Instance *instance)
Definition: N_DEV_Vcvs.h:222
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_Vcvs.C:564
Pure virtual class to augment a linear system.
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Definition: N_DEV_Vcvs.C:67
static std::vector< std::vector< int > > jacStamp
Definition: N_DEV_Vcvs.h:140
virtual bool updateState(double *solVec, double *staVec, double *stoVec)
Updates the devices state information.
Definition: N_DEV_Vcvs.C:551
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
Definition: N_DEV_Vcvs.C:321
static const char * primaryParameter()
Definition: N_DEV_Vcvs.h:69
const std::vector< std::vector< int > > & jacobianStamp() const
Definition: N_DEV_Vcvs.C:308
void registerBranchDataLIDs(const std::vector< int > &branchLIDVecRef)
Register the local store IDs.
Definition: N_DEV_Vcvs.C:259
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
Definition: N_DEV_Vcvs.C:534
DeviceMaster instantiates a device as described by the device traits T.
static void loadModelParameters(ParametricData< Model > &model_parameters)
Definition: N_DEV_Vcvs.C:76
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
Instance & operator=(const Instance &)
Model & operator=(const Model &)
virtual bool processParams()
processParams
Definition: N_DEV_Vcvs.h:210
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
Definition: N_DEV_Vcvs.C:277
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
Definition: N_DEV_Vcvs.C:634
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
Definition: N_DEV_Vcvs.C:174
void varTypes(std::vector< char > &varTypeVec)
Definition: N_DEV_Vcvs.C:447
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
Class Configuration contains device configuration data.
virtual bool processInstanceParams()
processInstanceParams
Definition: N_DEV_Vcvs.h:215
std::vector< Instance * > InstanceVector
Definition: N_DEV_Vcvs.h:187
int li_branch_data
Index for lead current and junction voltage (for power calculations)
Definition: N_DEV_Vcvs.h:159
virtual bool loadDAEMatrices(Linear::Matrix &dFdx, Linear::Matrix &dQdx)
Populates the device's Jacobian object with these pointers.
Definition: N_DEV_Vcvs.C:605
virtual std::ostream & printOutInstances(std::ostream &os) const
Definition: N_DEV_Vcvs.C:499
static const char * name()
Definition: N_DEV_Vcvs.h:66
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 * > instanceContainer
Definition: N_DEV_Vcvs.h:228
Master(const Configuration &configuration, const FactoryBlock &factory_block, const SolverState &ss1, const DeviceOptions &do1)
Definition: N_DEV_Vcvs.h:246