Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-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_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.83.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_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 const int numNodes() {return 4;}
69  static const char *primaryParameter() {return "T";}
70  static const 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  std::map<int,std::string> & getStoreNameMap ();
110  const std::vector< std::vector<int> > & jacobianStamp() const;
111 
112  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
113 
114  bool updateIntermediateVars () { return true; };
115  bool updatePrimaryState ();
116 
117  // load functions, residual:
118  bool loadDAEQVector () {return true;}
119  bool loadDAEFVector ();
120 
121  // load functions, Jacobian:
122  bool loadDAEdQdx () {return true;}
123  bool loadDAEdFdx ();
124 
125  void setupPointers();
126 
127 public:
128  // iterator reference to the VCCS model which owns this instance.
129  // Getters and setters
131  {
132  return model_;
133  }
134 
135 private:
136  static std::vector< std::vector<int> > jacStamp;
137 
138  Model & model_; //< Owning model
139 
141 
142  // Matrix equation index variables:
143  // local indices (offsets)
144  int li_Pos;
145  int li_Neg;
146 
149 
151 
152  // Offset variables for all of the above index variables.
157 
162 };
163 
164 //-----------------------------------------------------------------------------
165 // Class : Model
166 // Purpose :
167 // Special Notes :
168 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
169 // Creation Date : 3/16/00
170 //-----------------------------------------------------------------------------
171 class Model : public DeviceModel
172 {
173  typedef std::vector<Instance *> InstanceVector;
174 
175  friend class ParametricData<Model>;
176  friend class Instance;
177  friend class Traits;friend class Master;
178 
179 public:
180  Model(
181  const Configuration & configuration,
182  const ModelBlock & MB,
183  const FactoryBlock & factory_block);
184  ~Model();
185 
186 private:
187  Model();
188  Model(const Model &);
189  Model &operator=(const Model &);
190 
191 public:
192  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
193 
194  virtual std::ostream &printOutInstances(std::ostream &os) const;
195  virtual bool processParams()
196  {
197  return true;
198  }
199 
200  virtual bool processInstanceParams()
201  {
202  return true;
203  }
204 
205 public:
206  void addInstance(Instance *instance)
207  {
208  instanceContainer.push_back(instance);
209  }
210 
212  {
213  return instanceContainer;
214  }
215 
217  {
218  return instanceContainer;
219  }
220 
221 private:
222  std::vector<Instance*> instanceContainer;
223 
224 private:
225 };
226 
227 //-----------------------------------------------------------------------------
228 // Class : Master
229 // Purpose :
230 // Special Notes :
231 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
232 // Creation Date : 11/26/08
233 //-----------------------------------------------------------------------------
234 class Master : public DeviceMaster<Traits>
235 {
236  friend class Instance;
237  friend class Model;
238 
239 public:
241  const Configuration & configuration,
242  const FactoryBlock & factory_block,
243  const SolverState & ss1,
244  const DeviceOptions & do1)
245  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
246  {}
247 
248  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
249 
250  // load functions:
251  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * storeLeadF, double * storeLeadQ);
252  virtual bool loadDAEMatrices (N_LAS_Matrix & dFdx, N_LAS_Matrix & dQdx);
253 };
254 
255 void registerDevice();
256 
257 } // namespace VCCS
258 } // namespace Device
259 } // namespace Xyce
260 
264 
265 #endif