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