49 #include <Xyce_config.h>
57 #include <N_LAS_Matrix.h>
58 #include <N_UTL_FeatureTest.h>
63 namespace MemristorYakopcic {
68 template <
typename ScalarT>
69 void G(
const ScalarT & V1,
const ScalarT & V2,
const ScalarT & Ap,
const ScalarT & An, ScalarT & Vp, ScalarT & Vn, ScalarT & fval )
79 fval = -An * (exp(-(V1-V2)) - exp(Vn) );
84 fval = Ap * (exp((V1-V2)) - exp(Vp) );
92 template <
typename ScalarT>
93 void WP(
const ScalarT & X,
const ScalarT & Xp, ScalarT & fval )
96 fval = 1 + (Xp - X) / (1.0 - Xp);
99 template <
typename ScalarT>
100 void WN(
const ScalarT & X,
const ScalarT & Xn, ScalarT & fval )
103 fval = X / (1.0 - Xn);
107 template <
typename ScalarT>
108 void F_x_equation(
const ScalarT & V1,
const ScalarT & V2,
const ScalarT & X,
const ScalarT & Xp,
const ScalarT & Xn,
109 const ScalarT & AlphaP,
const ScalarT & AlphaN,
const ScalarT & Eta, ScalarT & fval )
111 if( Eta*(V1-V2) > 0 )
117 fval = WPval * exp(-AlphaP * (X - Xp ) );
130 fval = WNval * exp(AlphaN * (X + Xn -1) );
140 template <
typename ScalarT>
142 const ScalarT & Ap,
const ScalarT & An, ScalarT & Vp, ScalarT & Vn,
143 const ScalarT & Xp,
const ScalarT & Xn,
const ScalarT & AlphaP,
const ScalarT & AlphaN,
144 const ScalarT & Eta, ScalarT & fval )
147 G( V1, V2, Ap, An, Vp, Vn, Gval );
150 F_x_equation( V1, V2, X, Xp, Xn, AlphaP, AlphaN, Eta, FXval );
151 fval = Eta * Gval * FXval;
164 template <
typename ScalarT>
165 void I_V_Fxn(
const ScalarT & V1,
const ScalarT & V2,
const ScalarT & X,
const ScalarT & A1,
const ScalarT & A2,
const ScalarT & B, ScalarT & fval )
170 fval = A1 * X * sinh( B * (V1-V2) );
174 fval = A2 * X * sinh( B * (V1-V2) );
275 .setDescription(
"Initial value for internal variable x");
303 .setDescription(
"State variable motion relative to voltage.");
306 .setDescription(
"Positive Voltage Threshold");
309 .setDescription(
"Negative Voltage Threshold");
312 .setDescription(
"Positive Voltage Threshold Magnitude Parameter");
315 .setDescription(
"Negative Voltage Threshold Magnitude Parameter");
318 .setDescription(
"Dielectric layer thickness parameter [dimensionless] ");
321 .setDescription(
"Dielectric layer thickness parameter [dimensionless] ");
324 .setDescription(
"Curvature in I-V relation. Relates to how much conduction in the device is Ohmic and versus tunnel barrier.");
327 .setDescription(
"State variable motion.");
330 .setDescription(
"State variable motion.");
333 .setDescription(
"State variable motion.");
336 .setDescription(
"State variable motion.");
340 .setDescription(
"Scaling for x variable. For example 1e9 if x will be in units of nanometers.");
344 .setDescription(
"RTN model in resistance (on/off)" );
348 .setDescription(
"RTN model in resistance: seed" );
352 .setDescription(
"RTN model: lambda" );
356 .setDescription(
"RTN model in resistance: Update time" );
360 .setDescription(
"RTN model in resistance: Minimum allowed update time" );
364 .setDescription(
"RTN model in resistance: Base change in resistance for RTN" );
368 .setDescription(
"RTN model in resistance: Base change in resistance for RTN scaled by R" );
372 .setDescription(
"RTN model in growth (on/off)" );
376 .setDescription(
"RTN model in growth: seed" );
380 .setDescription(
"RTN growth model: lambda" );
384 .setDescription(
"RTN model in growth: Update time" );
388 .setDescription(
"RTN model in growth: Minimum allowed update time" );
392 .setDescription(
"RTN model in growth: Base change in growth rate for RTN" );
396 .setDescription(
"RTN model in growth: Base change in growth for RTN scaled by X" );
417 :
DeviceInstance(instance_block, configuration.getInstanceParameters(), factory_block),
422 resNoiseLastUpdateStep(-1),
423 resNoiseLastUpdateTime(0.0),
424 resNoiseNextUpdateTime(0.0),
425 resNoiseHiLoState(0),
426 resNoiseRfactor(1.0),
427 xNoiseLastUpdateStep(-1),
428 xNoiseLastUpdateTime(0.0),
429 xNoiseNextUpdateTime(0.0),
438 APosEquPosNodeOffset(-1),
439 APosEquNegNodeOffset(-1),
440 APosEquXNodeOffset(-1),
441 ANegEquPosNodeOffset(-1),
442 ANegEquNegNodeOffset(-1),
443 ANegEquXNodeOffset(-1),
449 f_PosEquPosNodePtr(0),
450 f_PosEquNegNodePtr(0),
452 f_NegEquPosNodePtr(0),
453 f_NegEquNegNodePtr(0),
544 const std::vector<int> & intLIDVecRef,
545 const std::vector<int> & extLIDVecRef)
767 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
814 double v_pos = solVec[
li_Pos];
815 double v_neg = solVec[
li_Neg];
816 double x = solVec[
li_x];
860 G=1.0/(rfactor*
Reff);
996 double x = solVec[
li_x];
1153 bool bsuccess =
true;
1213 (*it)->processParams();
1240 :
DeviceModel(model_block, configuration.getModelParameters(), factory_block),
1253 randomResNoiseOn_(false),
1254 randomResNoiseSeed_(0),
1255 randomResNoiseLambda_(0.0),
1256 randomResNoiseMean_(0.0),
1257 randomResNoiseSD_(0.0),
1258 randomResUpdateTime_(0.0),
1259 randomResEpsilonUpdateTime_(0.0),
1260 randomResDelta_(0.0),
1261 randomResDeltaGrad_(0.0)
1342 os <<
"Number of MemristorYakopcic Instances: " <<
instanceContainer.size() << std::endl;
1343 os <<
" name model name Parameters" << std::endl;
1348 os <<
" " << i <<
": " << (*it)->getName() <<
"\t";
1351 os <<
"\tG(T) = " << (*it)->G;
1377 for (std::vector<Instance *>::const_iterator it = instanceContainer.begin(); it != instanceContainer.end(); ++it)
1423 double v_pos = solVec[ri.
li_Pos];
1424 double v_neg = solVec[ri.
li_Neg];
1425 double x = solVec[ri.
li_x];
1512 Sacado::Fad::SFad<double,3> varV1( 3, 0, v_pos );
1513 Sacado::Fad::SFad<double,3> varV2( 3, 1, v_neg );
1514 Sacado::Fad::SFad<double,3> varX( 3, 2, x );
1517 Sacado::Fad::SFad<double,3> paramB( ri.
model_.
B_ );
1518 Sacado::Fad::SFad<double,3> resultFad;
1519 I_V_Fxn( varV1, varV2, varX, paramA1, paramA2, paramB, resultFad );
1521 ri.
i0 = resultFad.val();
1522 ri.
G = resultFad.dx(0);
1523 ri.
dIdx = resultFad.dx(2);
1529 Sacado::Fad::SFad<double,3> varV1( 3, 0, v_pos );
1530 Sacado::Fad::SFad<double,3> varV2( 3, 1, v_neg );
1531 Sacado::Fad::SFad<double,3> varX( 3, 2, x );
1532 Sacado::Fad::SFad<double,3> paramAp( ri.
model_.
Ap_ );
1533 Sacado::Fad::SFad<double,3> paramAn( ri.
model_.
An_ );
1534 Sacado::Fad::SFad<double,3> paramVp( ri.
model_.
Vp_ );
1535 Sacado::Fad::SFad<double,3> paramVn( ri.
model_.
Vn_ );
1536 Sacado::Fad::SFad<double,3> paramXp( ri.
model_.
XP_ );
1537 Sacado::Fad::SFad<double,3> paramXn( ri.
model_.
XN_ );
1540 Sacado::Fad::SFad<double,3> paramEta( ri.
model_.
Eta_ );
1541 Sacado::Fad::SFad<double,3> resultFad;
1544 paramAp, paramAn, paramVp, paramVn, paramXp, paramXn, paramAlphaP, paramAlphaN, paramEta, resultFad );
1708 bool Master::loadDAEVectors (
double * solVec,
double * fVec,
double *qVec,
double * bVec,
double * storeLeadF,
double * storeLeadQ,
double * leadF,
double * leadQ,
double * junctionV)
1768 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
1837 .registerDevice(
"memristor", 3)
1838 .registerModelType(
"memristor", 3);
1851 const std::string & name,
1852 std::vector<double> & dfdp,
1853 std::vector<double> & dqdp,
1854 std::vector<double> & dbdp,
1855 std::vector<int> & Findices,
1856 std::vector<int> & Qindices,
1857 std::vector<int> & Bindices
1864 double v_pos = solVec[in->
li_Pos];
1865 double v_neg = solVec[in->
li_Neg];
1867 double dfdpLoc = -(v_pos-v_neg)*in->
G*in->
G;
1874 Findices[0] = in->
li_Pos;
1875 Findices[1] = in->
li_Neg;
const InstanceName & getName() const
InstanceVector instanceContainer
bool updateDependentParameters()
static void loadInstanceParameters(ParametricData< Instance > &p)
const DeviceOptions & deviceOptions_
Descriptor & addPar(const char *parName, T default_value, T U::*varPtr)
Adds the parameter description to the parameter map.
double * daeQVectorRawPtr
double randomResDeltaGrad_
void G(const ScalarT &V1, const ScalarT &V2, const ScalarT &Ap, const ScalarT &An, ScalarT &Vp, ScalarT &Vn, ScalarT &fval)
Pure virtual class to augment a linear system.
virtual bool processInstanceParams()
processInstanceParams
void addInternalNode(Util::SymbolTable &symbol_table, int index, const InstanceName &instance_name, const std::string &lead_name)
virtual bool loadDAEdFdx()
void I_V_Fxn(const ScalarT &V1, const ScalarT &V2, const ScalarT &X, const ScalarT &A1, const ScalarT &A2, const ScalarT &B, ScalarT &fval)
void setNumStoreVars(int num_store_vars)
void addBranchDataNode(Util::SymbolTable &symbol_table, int index, const InstanceName &instance_name, const std::string &lead_name)
virtual bool processParams()
InstanceVector::const_iterator getInstanceEnd() const
Returns an iterator to the ending of the vector of all instances created for this device...
Base class for all parameters.
virtual bool loadDAEFVector()
static std::vector< std::vector< int > > jacStamp
virtual void registerJacLIDs(const JacobianStamp &jacLIDVec)
double * nextJunctionVCompRawPtr
double * f_PosEquPosNodePtr
double randomResUpdateTime_
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
virtual void forEachInstance(DeviceInstanceOp &op) const
double randomXEpsilonUpdateTime_
int getNumStoreVars() const
InstanceVector::const_iterator getInstanceBegin() const
Returns an iterator to the beginning of the vector of all instances created for this device...
std::vector< Param > params
Parameters from the line.
virtual bool updatePrimaryState()
virtual bool updateState(double *solVec, double *staVec, double *stoVec)
Updates the devices state information.
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
void setParams(const std::vector< Param > ¶ms)
const std::string & getName() const
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.
double * daeFVectorRawPtr
void F_x_equation(const ScalarT &V1, const ScalarT &V2, const ScalarT &X, const ScalarT &Xp, const ScalarT &Xn, const ScalarT &AlphaP, const ScalarT &AlphaN, const ScalarT &Eta, ScalarT &fval)
double resNoiseNextUpdateTime
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
double * f_NegEquXNodePtr
void WP(const ScalarT &X, const ScalarT &Xp, ScalarT &fval)
int resNoiseLastUpdateStep
int numBranchDataVarsIfAllocated
virtual bool loadDAEdQdx()
double randomXNoiseLambda_
static Config< T > & addConfiguration()
Adds the device to the Xyce device configuration.
virtual void setupPointers()
double * f_PosEquXNodePtr
double * f_XEquPosNodePtr
double resNoiseLastUpdateTime
Linear::Matrix * dFdxMatrixPtr
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.
double * f_NegEquPosNodePtr
void addStoreNode(Util::SymbolTable &symbol_table, int index, const InstanceName &instance_name, const std::string &lead_name)
int timeStepNumber_
Memristor, LTRA, TRA, testing if debug or jacobian for testing.
virtual bool updateTemperature(const double &temp_tmp)
const SolverState & solverState_
Class Configuration contains device configuration data.
static void loadModelParameters(ParametricData< Model > &p)
double xNoiseNextUpdateTime
virtual std::ostream & printOutInstances(std::ostream &os) const
const SolverState & getSolverState() const
void X_var_F_equation(const ScalarT &V1, const ScalarT &V2, const ScalarT &X, const ScalarT &Ap, const ScalarT &An, ScalarT &Vp, ScalarT &Vn, const ScalarT &Xp, const ScalarT &Xn, const ScalarT &AlphaP, const ScalarT &AlphaN, const ScalarT &Eta, ScalarT &fval)
double * nextLeadCurrFCompRawPtr
double randomResNoiseLambda_
virtual void registerStoreLIDs(const std::vector< int > &stoLIDVecRef)
void setNumBranchDataVars(int num_branch_data_vars)
#define Xyce_NONPOINTER_MATRIX_LOAD
Instance(const Configuration &configuration, const InstanceBlock &instance_block, Model &model, const FactoryBlock &factory_block)
double * f_XEquNegNodePtr
double xNoiseLastUpdateTime
double * f_PosEquNegNodePtr
virtual bool updateIntermediateVars()
virtual void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
double * f_NegEquNegNodePtr
virtual void registerBranchDataLIDs(const std::vector< int > &branchLIDVecRef)
double randomXUpdateTime_
void WN(const ScalarT &X, const ScalarT &Xn, ScalarT &fval)
const ExternData & extData
ModelBlock represents a .MODEL line from the netlist.
virtual bool processParams()
processParams
Manages parameter binding for class C.
InstanceBlock represent a device instance line from the netlist.
double currTime_
DeviceEntity for expression time, breakpoints DeviceMgr for dependent parameters, breakpoints...
std::vector< Param > params
virtual void registerStateLIDs(const std::vector< int > &staLIDVecRef)
Linear::Matrix * dQdxMatrixPtr
virtual void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
static void initializeJacobianStamp()
virtual bool loadDAEQVector()
int getNumBranchDataVars() const
double randomResEpsilonUpdateTime_
const SolverState & getSolverState() const
Returns the solver state given during device construction.
void setModParams(const std::vector< Param > ¶ms)
double * nextSolVectorRawPtr
int numLeadCurrentStoreVars
Xyce::Util::RandomNumbers * randomNumberGen_