Xyce  6.1
N_DEV_OpAmp.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 : N_DEV_OpAmp.h
27 //
28 // Purpose : Ideal Operational Amplifier Model
29 //
30 // Special Notes : This model assumes infinite gain
31 // and unbounded output voltages
32 //
33 // Creator : Brian Fett, SNL
34 //
35 // Creation Date : 08/02/05
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.52 $
41 //
42 // Revision Date : $Date: 2015/04/08 19:18:24 $
43 //
44 // Current Owner : $Author: tvrusso $
45 //-----------------------------------------------------------------------------
46 
47 #ifndef Xyce_N_DEV_OpAmp_h
48 #define Xyce_N_DEV_OpAmp_h
49 
50 // ---------- Xyce Includes ----------
51 #include <N_DEV_Configuration.h>
52 #include <N_DEV_DeviceBlock.h>
53 #include <N_DEV_DeviceInstance.h>
54 #include <N_DEV_DeviceModel.h>
55 
56 namespace Xyce {
57 namespace Device {
58 namespace OpAmp {
59 
60 class Model;
61 class Instance;
62 
63 struct Traits : public DeviceTraits<Model, Instance>
64 {
65  static const char *name() {return "Operational Amplifier";}
66  static const char *deviceTypeName() {return "OpAmp level 1";}
67  static int numNodes() {return 3;}
68  static bool modelRequired() {return true;}
69  static bool isLinearDevice() {return true;}
70 
71  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
72  static void loadModelParameters(ParametricData<Model> &model_parameters);
73  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
74 };
75 
76 //-----------------------------------------------------------------------------
77 // Class : Instance
78 // Purpose :
79 // Special Notes :
80 // Creator : Brian Fett
81 // Creation Date : 08/28/05
82 //-----------------------------------------------------------------------------
83 class Instance : public DeviceInstance
84 {
85  friend class ParametricData<Instance>;
86  friend class Model;
87  friend class Traits;
88 
89 public:
90 
91  Instance(
92  const Configuration & configuration,
93  const InstanceBlock & IB,
94  Model & iter,
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 
108  virtual void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
109 
110  const std::vector< std::vector<int> > & jacobianStamp() const;
111  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
112 
113  bool processParams ();
114 
115  bool updateIntermediateVars ();
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  // iterator reference to the OpAmp model which owns this instance.
127  // Getters and setters
129  {
130  return model_;
131  }
132 
133 private:
134  static std::vector< std::vector<int> > jacStamp;
135 
136  Model & model_; //< Owning model
137 
138  // state variables:
139  double outCurrent;
140  double deltaVoltage;
141 
142 
143  // Parameters
144  double FAKEPARAM;
145 
146  // load variables
147  double v_pos, v_neg, v_out, i_bra;
148 
149  // indices into state vector:
150  int istate_I; // index for i0;
151 
152  // Matrix equation index variables:
153  //local indices (offsets)
154  int li_Pos;
155  int li_Neg;
156  int li_Out;
157  int li_Bra;
158 
159  // Jacobian matrix indices:
160  //Locally indexed offsets for jacobian
161  int ABraEquPosNodeOffset; // Offset, pos. input voltage contribution
162  // branch current equation.
163 
164  int ABraEquNegNodeOffset; // Offset, neg. input voltage contribution
165  // branch current equation.
166 
167  int AOutEquBraVarOffset; // Offset, branch current variable
168  // contribution, KCL of output node
169 };
170 
171 //-----------------------------------------------------------------------------
172 // Class : Model
173 // Purpose :
174 // Special Notes :
175 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
176 // Creation Date : 04/06/00
177 // Modified by : Brian Fett, SNL
178 // Modify Date : 08/02/05
179 //-----------------------------------------------------------------------------
180 class Model : public DeviceModel
181 {
182  typedef std::vector<Instance *> InstanceVector;
183 
184  friend class ParametricData<Model>;
185  friend class Instance;
186  friend class Traits;
187 
188 public:
189  Model(
190  const Configuration & configuration,
191  const ModelBlock & MB,
192  const FactoryBlock & factory_block);
193  ~Model ();
194 
195 private:
196  Model();
197  Model(const Model &);
198  Model &operator=(const Model &);
199 
200 public:
201  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
202 
203  virtual std::ostream &printOutInstances(std::ostream &os) const;
204  virtual bool processParams()
205  {
206  return true;
207  }
208 
209  virtual bool processInstanceParams()
210  {
211  return true;
212  }
213 
214 public:
215  void addInstance(Instance *instance)
216  {
217  instanceContainer.push_back(instance);
218  }
219 
220 private:
221  std::vector<Instance*> instanceContainer;
222 
223 private:
224 
225  // Data Members for Associations
226  double FAKEPARAM;
227 };
228 
229 void registerDevice();
230 
231 } // namespace OpAmp
232 } // namespace Device
233 } // namespace Xyce
234 
235 #endif
virtual bool processInstanceParams()
processInstanceParams
Definition: N_DEV_OpAmp.h:209
static bool modelRequired()
Definition: N_DEV_OpAmp.h:68
Pure virtual class to augment a linear system.
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
Definition: N_DEV_OpAmp.C:257
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
Definition: N_DEV_OpAmp.C:495
Instance & operator=(const Instance &)
virtual std::ostream & printOutInstances(std::ostream &os) const
Definition: N_DEV_OpAmp.C:462
Model & operator=(const Model &)
const std::vector< std::vector< int > > & jacobianStamp() const
Definition: N_DEV_OpAmp.C:244
static const char * deviceTypeName()
Definition: N_DEV_OpAmp.h:66
virtual bool processParams()
processParams
Definition: N_DEV_OpAmp.h:204
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
static const char * name()
Definition: N_DEV_OpAmp.h:65
std::vector< Instance * > instanceContainer
Definition: N_DEV_OpAmp.h:221
virtual void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
Definition: N_DEV_OpAmp.C:274
static bool isLinearDevice()
Definition: N_DEV_OpAmp.h:69
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
Definition: N_DEV_OpAmp.C:171
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
Definition: N_DEV_OpAmp.C:502
Class Configuration contains device configuration data.
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &iter, const FactoryBlock &factory_block)
Definition: N_DEV_OpAmp.C:84
static void loadModelParameters(ParametricData< Model > &model_parameters)
Definition: N_DEV_OpAmp.C:69
std::vector< Instance * > InstanceVector
Definition: N_DEV_OpAmp.h:182
void addInstance(Instance *instance)
Definition: N_DEV_OpAmp.h:215
static std::vector< std::vector< int > > jacStamp
Definition: N_DEV_OpAmp.h:134
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 void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Definition: N_DEV_OpAmp.C:61
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
Definition: N_DEV_OpAmp.C:231