Xyce  6.1
N_DEV_MemristorTEAM.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_MemristorTEAM.h,v $
27 //
28 // Purpose : Implementation of the TEAM memristor model. See.
29 // TEAM: Threshold Adaptive Memristor Model
30 // Shahar Kvatinsky, Eby G. Friedman, Uri Weiser,
31 // IEEE Transactions on Circuits and Systems-I Vol 60, No. 1, Jan. 2013
32 // model details.
33 //
34 // Special Notes :
35 //
36 // Creator : Richard Schiek, Electrical Models & Simulations
37 //
38 // Creation Date : 10/23/2014
39 //
40 // Revision Information:
41 // ---------------------
42 //
43 // Revision Number: $Revision: 1.7.2.2 $
44 //
45 // Revision Date : $Date: 2015/04/02 18:20:11 $
46 //
47 // Current Owner : $Author: tvrusso $
48 //-----------------------------------------------------------------------------
49 
50 #ifndef Xyce_N_DEV_MemristorTEAM_h
51 #define Xyce_N_DEV_MemristorTEAM_h
52 
53 #include <N_DEV_fwd.h>
54 #include <N_DEV_Configuration.h>
55 #include <N_DEV_DeviceInstance.h>
56 #include <N_DEV_DeviceModel.h>
57 #include <N_DEV_DeviceMaster.h>
58 #include <N_UTL_RandomNumbers.h>
59 
60 namespace Xyce {
61 namespace Device {
62 namespace MemristorTEAM {
63 
64 class Model;
65 class Instance;
66 
67 // sensitivity functor
68 // not yet implemented.
70 {
71  public:
73  baseSensitivity() {};
74 
76 
77  virtual void operator()(
78  const ParameterBase &entity,
79  const std::string &name,
80  std::vector<double> & dfdp,
81  std::vector<double> & dqdp,
82  std::vector<double> & dbdp,
83  std::vector<int> & Findices,
84  std::vector<int> & Qindices,
85  std::vector<int> & Bindices
86  ) const ;
87 };
88 
90 
91 struct Traits : public DeviceTraits<Model, Instance>
92 {
93  static const char *name() {return "MemristorTEAM";}
94  static const char *deviceTypeName() {return "YMEMRISTOR level 2";}
95  static int numNodes() {return 2;}
96  static bool modelRequired() {return true;}
97  static bool isLinearDevice() {return true;}
98 
99  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
102 };
103 
104 //-----------------------------------------------------------------------------
105 // Class : Xyce::Device::MemristorTEAM::Instance
106 // Purpose :
107 // Special Notes :
108 // Creator : Richard Schiek, Electrical Models & Simulations
109 // Creation Date : 10/23/2014
110 //-----------------------------------------------------------------------------
111 //
112 // MemristorTEAM device instance class.
113 //
114 // An instance is created for each occurance of the device in the netlist.
115 //
116 // It contains "unique" device information - ie stuff that will be
117 // true of only one memristor in the circuit, such as the nodes to
118 // which it is connected. A memristor is connected to only two
119 // circuit nodes.
120 //
121 // This class does not directly contain information about its node
122 // indices. It contains indices into the 5 parts (dFdx, dQdx, dx, F,
123 // and Q) of the matrix problem A*dx = b, and also the solution
124 // vector x. A is the Jacobian matrix that will be formed from dFdx
125 // and d(dQ/dt)dx, dx is the update to x, and b is right hand side
126 // function vector that will be formed from F and dQ/dt. These
127 // indices are global, and determined by topology during the
128 // initialization stage of execution.
129 //
130 class Instance : public DeviceInstance
131 {
132  friend class ParametricData<Instance>;
133  friend class Model;
134  friend class Traits;
135  friend class Master;
137 
138 public:
139  Instance(
140  const Configuration & configuration,
141  const InstanceBlock & instance_block,
142  Model & model,
143  const FactoryBlock & factory_block);
144 
145  //---------------------------------------------------------------------------
146  // Function : Xyce::Device::MemristorTEAM::Instance::~Instance
147  // Purpose : destructor
148  // Special Notes :
149  // Scope : public
150  // Creator : Richard Schiek, Electrical Models & Simulations
151  // Creation Date : 10/23/2014
152  //---------------------------------------------------------------------------
153  //
154  // Destroys this instance
155  //
156  // @author Eric Keiter, SNL
157  // @date 3/16/00
159 
160 private:
161  Instance(const Instance &);
162  Instance &operator=(const Instance &);
163 
164 public:
165 
166  //---------------------------------------------------------------------------
167  // Function : Xyce::Device::MemristorTEAM::Instance::getModel
168  // Purpose : destructor
169  // Special Notes :
170  // Scope : public
171  // Creator : Richard Schiek, Electrical Models & Simulations
172  // Creation Date : 10/23/2014
173  //---------------------------------------------------------------------------
174  //
175  // Gets the resistor model that owns this instance.
176  //
177  // @return reference to the owning MemristorTEAM::Model
178  //
179  // @author David G. Baur Raytheon Sandia National Laboratories 1355
180  // @date Mon Aug 12 08:36:37 2013
181  Model &getModel() { return model_; }
182 
183  virtual void registerLIDs(const std::vector<int> & intLIDVecRef, const std::vector<int> & extLIDVecRef) /* override */;
184  virtual void registerStateLIDs(const std::vector<int> & staLIDVecRef) /* override */;
185  virtual void registerStoreLIDs(const std::vector<int> & stoLIDVecRef) /* override */;
186  virtual void registerBranchDataLIDs(const std::vector<int> & branchLIDVecRef) /* override */;
187  virtual void registerJacLIDs(const std::vector< std::vector<int> > & jacLIDVec) /* override */;
188 
189  void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
190 
191  virtual bool processParams() /* override */;
192  virtual bool updateTemperature(const double & temp_tmp) /* override */;
193  virtual bool updateIntermediateVars() /* override */;
194  virtual bool updatePrimaryState() /* override */;
195 
196  //---------------------------------------------------------------------------
197  // Function : Xyce::Device::MemristorTEAM::Instance::jacobianStamp
198  // Purpose :
199  // Special Notes :
200  // Scope : public
201  // Creator : Richard Schiek, Electrical Models & Simulations
202  // Creation Date : 10/23/2014
203  //---------------------------------------------------------------------------
204  //
205  // Return Jacobian stamp that informs topology of the layout of the
206  // resistor jacobian.
207  //
208  // The Jacobian stamp describes the shape of the Jacobian to the
209  // Topology subsystem. The Topology subsystem, in turn, returns
210  // the offsets into the matrix and solution vectors where this
211  // instance data is located.
212  //
213  // @return const reference to a std::vector of std::vector of
214  // integers describing Jacobian stamp shape
215  //
216  // @author Robert Hoekstra
217  // @date 8/20/2001
218  virtual const std::vector< std::vector<int> > &jacobianStamp() const /* override */ {
219  return jacStamp;
220  }
221 
222  virtual bool loadDAEQVector() /* override */;
223  virtual bool loadDAEFVector() /* override */;
224  virtual bool loadDAEdQdx() /* override */;
225  virtual bool loadDAEdFdx() /* override */;
226 
227 
228  virtual void setupPointers() /* override */;
229 
230 private:
231  static std::vector< std::vector<int> > jacStamp; //< All MemristorTEAM instances have a common Jacobian Stamp
232  static void initializeJacobianStamp();
233 
234  Model & model_; //< Owning model
235 
236  // User-specified parameters:
238 
239  // Derived parameters:
240  double G; //< Conductance(1.0/ohms)
241  double Reff; //< Effective resistance
242  double dReffdvpos; //< derivative of Reff with respect to Vpos
243  double dReffdvneg; //< derivative of Reff with respect to Vneg
244  double dReffdx; //< derivative of Reff with respect to x
245  double i0; //< Current(ohms)
246  double xVarFContribution; //< x, internal variable for thickness of conductive layer, F-vector contribution
247  double dxFEqdVpos; //< derivative of X F equation with respect to Vpos
248  double dxFEqdVneg; //< derivative of X F equation with respect to Vneg
249  double dxFEqdx; //< derivative of X F equation with respect to X
250 
251  int li_Pos; //< Index for Positive Node
252  int li_Neg; //< Index for Negative Node
253  int li_x; //< Index for internal x, thickness, variable
254  int li_store_R; //< Index to store resistence value
255  int li_store_dev_i; //< Index to store branch current
256  int li_branch_data; //< Index for Lead Current and junction voltage (for power calculations)
257 
258  // Offset variables corresponding to the above declared indices.
259  int APosEquPosNodeOffset; //< Column index into matrix of Pos/Pos conductance
260  int APosEquNegNodeOffset; //< Column index into matrix of Pos/Neg conductance
261  int APosEquXNodeOffset; //< Column index into matrix for internal varaible x, layer thickness
262  int ANegEquPosNodeOffset; //< Column index into matrix of Neg/Pos conductance
263  int ANegEquNegNodeOffset; //< Column index into matrix of Neg/Neg conductance
264  int ANegEquXNodeOffset; //< Column index into matrix for internal varaible x, layer thickness
265  int XEquVPosOffset; //< Thickness governing equation, VPos dependence
266  int XEquVNegOffset; //< Thickness governing equation, VNeg dependence
267  int XEquXOffset; //< Thickness variable, in thickness governing equation equation
268 
269 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
270  // Pointers for Jacobian
279  double * f_XEquXNodePtr;
280  double * q_XEquXNodePtr;
281 #
282 #endif
283 
284 };
285 
286 
287 //-----------------------------------------------------------------------------
288 // Class : Xyce::Device::MemristorTEAM::Model
289 // Purpose :
290 // Special Notes :
291 // Creator : Richard Schiek, Electrical Models & Simulations
292 // Creation Date : 10/23/2014
293 //-----------------------------------------------------------------------------
294 //
295 // MemristorTEAM model class
296 //
297 class Model : public DeviceModel
298 {
299  friend class ParametricData<Model>; //< Allow ParametricData to changes member values
300  friend class Instance; //< Don't force a lot of pointless getters
301  friend class Traits;
302  friend class Master; //< Don't force a lot of pointless getters
303 
304 public:
305  typedef std::vector<Instance *> InstanceVector;
306 
307  Model(
308  const Configuration & configuration,
309  const ModelBlock & model_block,
310  const FactoryBlock & factory_block);
311  ~Model();
312 
313 private:
314  Model();
315  Model(const Model &);
316  Model &operator=(const Model &);
317 
318 public:
319 
320  //---------------------------------------------------------------------------
321  // Function : Xyce::Device::MemristorTEAM::Model::addInstance
322  // Purpose :
323  // Special Notes :
324  // Scope : public
325  // Creator : Richard Schiek, Electrical Models & Simulations
326  // Creation Date : 10/23/2014
327  //---------------------------------------------------------------------------
328  //
329  // Add an instance to the list of instances associated with this model
330  //
331  // @author David G. Baur Raytheon Sandia National Laboratories 1355
332  // @date 8/12/2013
333  void addInstance(Instance *instance)
334  {
335  instanceContainer.push_back(instance);
336  }
337 
338  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
339 
340  virtual std::ostream &printOutInstances(std::ostream &os) const;
341 
342  virtual bool processParams() /* override */;
343  virtual bool processInstanceParams() /* override */;
344 
345 private:
346  InstanceVector instanceContainer; //< List of owned resistor instances
347 
348  double kOn_;
349  double kOff_;
350  double alphaOn_;
351  double alphaOff_;
352  double xOn_;
353  double xOff_;
354  double ROn_;
355  double ROff_;
356  double iOn_;
357  double iOff_;
358  double D_;
359  double p_;
360  double j_;
361  double aOn_;
362  double aOff_;
363  double wc_;
364  double xScaling_;
366 
367 };
368 
369 
370 //-----------------------------------------------------------------------------
371 // Class : Xyce::Device::MemristorTEAM::Master
372 // Purpose :
373 // Special Notes :
374 // Creator : Richard Schiek, Electrical Models & Simulations
375 // Creation Date : 10/23/2014
376 //-----------------------------------------------------------------------------
377 //
378 // MemristorTEAM master
379 //
380 // The "master" class is the one that contains the updateState, loadDAEVectors
381 // and loadDAEMatrices methods that are actually called when it is time to
382 // compute and load device contributions.
383 //
384 // The default implementations of these methods in the DeviceMaster
385 // template class simply loops over all instances and calls their
386 // updatePrimaryState, loadDAEFVector/loadDAEQVector, and
387 // loadDAEdFdx/loadDAEdQdx methods, respectively.
388 //
389 // For efficiency, the MemristorTEAM class reimplements these methods to do the
390 // work directly, instead of calling instance-level functions.
391 //
392 class Master : public DeviceMaster<Traits>
393 {
394  friend class Instance;
395  friend class Model;
396 
397 public:
398 
399  //---------------------------------------------------------------------------
400  // Function : Xyce::Device::MemristorTEAM::Master::Master
401  // Purpose :
402  // Special Notes :
403  // Scope : public
404  // Creator : Richard Schiek, Electrical Models & Simulations
405  // Creation Date : 10/23/2014
406  //---------------------------------------------------------------------------
407  //
408  // Construct a MemristorTEAM Device.
409  //
410  // @param configuration
411  // @param factory_block
412  // @param solver_state
413  // @param device_options
415  const Configuration & configuration,
416  const FactoryBlock & factory_block,
417  const SolverState & solver_state,
418  const DeviceOptions & device_options)
419  : DeviceMaster<Traits>(configuration, factory_block, solver_state, device_options)
420  {}
421 
422  virtual bool updateState(double * solVec, double * staVec, double * stoVec);
423  virtual bool loadDAEVectors (double * solVec, double * fVec, double * qVec, double * bVec, double * storeLeadF, double * storeLeadQ, double * leadF, double * leadQ, double * junctionV);
424  virtual bool loadDAEMatrices(Linear::Matrix & dFdx, Linear::Matrix & dQdx);
425 
426 };
427 
428 void registerDevice();
429 
430 } // namespace MemristorTEAM
431 } // namespace Device
432 } // namespace Xyce
433 
434 #endif // Xyce_N_DEV_MemristorTEAM_h
virtual void registerStoreLIDs(const std::vector< int > &stoLIDVecRef)
virtual bool loadDAEMatrices(Linear::Matrix &dFdx, Linear::Matrix &dQdx)
Populates the device's Jacobian object with these pointers.
Pure virtual class to augment a linear system.
virtual void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
Model & operator=(const Model &)
void addInstance(Instance *instance)
Base class for all parameters.
Definition: N_DEV_Pars.h:169
virtual std::ostream & printOutInstances(std::ostream &os) const
Instance & operator=(const Instance &)
std::vector< Instance * > InstanceVector
static void loadInstanceParameters(ParametricData< Instance > &p)
virtual const std::vector< std::vector< int > > & jacobianStamp() const
virtual void operator()(const ParameterBase &entity, const std::string &name, std::vector< double > &dfdp, std::vector< double > &dqdp, std::vector< double > &dbdp, std::vector< int > &Findices, std::vector< int > &Qindices, std::vector< int > &Bindices) const
DeviceMaster instantiates a device as described by the device traits T.
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
virtual void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
Instance(const Configuration &configuration, const InstanceBlock &instance_block, Model &model, const FactoryBlock &factory_block)
static memristorTEAMSensitivity memrSens
virtual bool processInstanceParams()
processInstanceParams
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
virtual bool updateTemperature(const double &temp_tmp)
Class Configuration contains device configuration data.
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.
virtual void registerBranchDataLIDs(const std::vector< int > &branchLIDVecRef)
virtual bool updateState(double *solVec, double *staVec, double *stoVec)
Updates the devices state information.
virtual void forEachInstance(DeviceInstanceOp &op) const
Master(const Configuration &configuration, const FactoryBlock &factory_block, const SolverState &solver_state, const DeviceOptions &device_options)
virtual void registerStateLIDs(const std::vector< int > &staLIDVecRef)
static void loadModelParameters(ParametricData< Model > &p)
static std::vector< std::vector< int > > jacStamp
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
Base sensitivity functor.
Definition: N_DEV_Pars.h:148
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 Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
virtual bool processParams()
processParams