Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-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_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.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_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 const int numNodes() {return 4;}
69  static const char *primaryParameter() {return "G";}
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 
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  std::map<int,std::string> & getIntNameMap ();
110 
111  const std::vector< std::vector<int> > & jacobianStamp() const;
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  void varTypes( std::vector<char> & varTypeVec );
128 
129 public:
130  // iterator reference to the vcvs model which owns this instance.
131  // Getters and setters
133  {
134  return model_;
135  }
136 
137 private:
138  static std::vector< std::vector<int> > jacStamp;
139 
140  Model & model_; //< Owning model
141 
142  double Gain;
143  double LeadCurrent;
144 
146 
147  // Matrix equation index variables:
148 
149  // local indices (offsets)
150  int li_Pos;
151  int li_Neg;
152  int li_Bra;
153 
156 
157  // Offset variables for all of the above index variables.
164 
165  // Ptr variables for all of the above index variables.
172 };
173 
174 //-----------------------------------------------------------------------------
175 // Class : Model
176 // Purpose :
177 // Special Notes :
178 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
179 // Creation Date : 3/16/00
180 //-----------------------------------------------------------------------------
181 class Model : public DeviceModel
182 {
183  typedef std::vector<Instance *> InstanceVector;
184 
185  friend class ParametricData<Model>;
186  friend class Instance;
187  friend class Traits;friend class Master;
188 
189 public:
190  Model(
191  const Configuration & configuration,
192  const ModelBlock & MB,
193  const FactoryBlock & factory_block);
194  ~Model();
195 
196 private:
197  Model();
198  Model(const Model &);
199  Model &operator=(const Model &);
200 
201 public:
202  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
203 
204  virtual std::ostream &printOutInstances(std::ostream &os) const;
205 
206  virtual bool processParams()
207  {
208  return true;
209  }
210 
211  virtual bool processInstanceParams()
212  {
213  return true;
214  }
215 
216 
217 public:
218  void addInstance(Instance *instance)
219  {
220  instanceContainer.push_back(instance);
221  }
222 
224  {
225  return instanceContainer;
226  }
227 
229  {
230  return instanceContainer;
231  }
232 
233 private:
234  std::vector<Instance*> instanceContainer;
235 
236 private:
237 };
238 
239 //-----------------------------------------------------------------------------
240 // Class : Master
241 // Purpose :
242 // Special Notes :
243 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
244 // Creation Date : 11/26/08
245 //-----------------------------------------------------------------------------
246 class Master : public DeviceMaster<Traits>
247 {
248  friend class Instance;
249  friend class Model;
250 
251 public:
253  const Configuration & configuration,
254  const FactoryBlock & factory_block,
255  const SolverState & ss1,
256  const DeviceOptions & do1)
257  : DeviceMaster<Traits>(configuration, factory_block, ss1, do1)
258  {}
259 
260  virtual bool updateState (double * solVec, double * staVec, double * stoVec);
261 
262  // load functions:
263  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * storeLeadF, double * storeLeadQ);
264  virtual bool loadDAEMatrices (N_LAS_Matrix & dFdx, N_LAS_Matrix & dQdx);
265 };
266 
267 void registerDevice();
268 
269 } // namespace Vcvs
270 } // namespace Device
271 } // namespace Xyce
272 
276 
277 #endif