Simulate memristors with time-variable resistive parameters

Discussion in 'The Projects Forum' started by d19b, Dec 18, 2015.

  1. d19b

    Thread Starter New Member

    Dec 18, 2015
    15
    0
    Hi everyone,

    I'm working with Capture and Pspice 16.3 and I'm trying to do simulations with the model of a memristor, in particular the one developped by HP (I found it in a pdf file searching on-line so I suppose it is pubblic and available for everyone); here is the SPICE model implementation of the memristor:



    * HP Memristor SPICE Model
    * For Transient Analysis only
    * created by Zdenek and Dalibor Biolek
    **************************
    * Ron, Roff - Resistance in ON / OFF States
    * Rinit - Resistance at T=0
    * D - Width of the thin film
    * uv - Migration coefficient
    * p - Parameter of the WINDOW-function
    * for modeling nonlinear boundary conditions
    * x - W/D Ratio, W is the actual width
    * of the doped area (from 0 to D)
    *
    .SUBCKT memristor Plus Minus PARAMS:
    + Ron=1K Roff=100K Rinit=80K D=10N uv=10F p=1
    ***********************************************
    * DIFFERENTIAL EQUATION MODELING *
    ***********************************************
    Gx 0 x value={ I(Emem)*uv*Ron/D^2*f(V(x),p)}
    Cx x 0 1 IC={(Roff-Rinit)/(Roff-Ron)}
    Raux x 0 1T
    * RESISTIVE PORT OF THE MEMRISTOR *
    *******************************
    Emem plus aux value={-I(Emem)*V(x)*(Roff-Ron)}
    Roff aux minus {Roff}
    ***********************************************
    *Flux computation*
    ***********************************************
    Eflux flux 0 value={SDT(V(plus,minus))}
    ***********************************************
    *Charge computation*
    ***********************************************
    Echarge charge 0 value={SDT(I(Emem))}
    ***********************************************
    * WINDOW FUNCTIONS
    * FOR NONLINEAR DRIFT MODELING *
    ***********************************************
    *window function, according to Joglekar
    .func f(x,p)={1-(2*x-1)^(2*p)}
    *proposed window function
    ;.func f(x,i,p)={1-(x-stp(-i))^(2*p)}
    .ENDS memristor



    I used it in several circuits finding almost no problems (except for some convergence issues, partially solved with autoconvergence) but now I would like to simulate its behaviour changing the resitive parameters of the device with time. There is a way to do this? I've tried to substitute the value of one of the parameters with an expression depending on the TIME variable (such as {5k*EXP(-TIME/10)}), but I only got the error "TIME not allowed in this context" before simulation could start. I've read about some solutions that allow to create voltage-controlled resistors that can simulate the behaviour of a time-dependent resistor, but since the resistor in this case is a parameter defined only inside the device I'm not sure that solution could be used for my purpose, and the same is true also for the voltage current controlled source-based solutions; in this last case I would not be able to apply the current signal on the resistive parameters of the memristor, even because the device is used as feedback in circuits like waveform generators and so the current signal would come in conflict with the one applied by the circuit on the memristor itself. Any suggestions about this?

    Thank you for your attention!
     
  2. Bordodynov

    Active Member

    May 20, 2015
    637
    188
    .SUBCKT memristor Plus Minus PARAMS:
    *+ Ron=1K Roff=100K Rinit=80K
    + D=10N uv=10F p=1
    *
    .func Ron(t) {.........}
    .func Roff(t) {.........}
    .func Rinit(t) {.........}
    Gx 0 x value={ I(Emem)*uv*Ron(Time)/D^2*f(V(x),p)}
    Cx x 0 1000
    E_IC 1000 1 value={(Roff(Time)-Rinit(time))/limit(1m,(Roff(Time)-Ron(time)),1T}
    Raux x 0 1T
    * RESISTIVE PORT OF THE MEMRISTOR *
    *******************************
    Emem plus aux value={-I(Emem)*V(x)*(Roff(Time)-Ron(Time))}
    **** Roff aux minus {Roff}
    G_Roff aux minus value={V(aux, minus)/Roff(Time)}
    ***********************************************
    *Flux computation*
    ***********************************************
    Eflux flux 0 value={SDT(V(plus,minus))}
    ***********************************************
    *Charge computation*
    ***********************************************
    Echarge charge 0 value={SDT(I(Emem))}
    ***********************************************
    * WINDOW FUNCTIONS
    * FOR NONLINEAR DRIFT MODELING *
    ***********************************************
    *window function, according to Joglekar
    .func f(x,p)={1-(2*x-1)^(2*p)}
    *proposed window function
    ;.func f(x,i,p)={1-(x-stp(-i))^(2*p)}
    .ENDS memristor
     
  3. d19b

    Thread Starter New Member

    Dec 18, 2015
    15
    0
    Thank you for your answer, but I still get some issues to resolve! When I begin the simulation of the device with the modified model implementation, I get these two errors:

    ERROR -- Can not re-define "X_MS1.RON". "X_MS1.RON" is either a system defined variable or has already been defined
    and
    ERROR -- .FUNC does not agree with previous instance

    I think that the first error is due to the fact that Ron was still declared as a parameter of the device and still initialized (with the value 1k), so when the "compiler" arrives at the ".FUNC" instruction, it recognize that the two instructions come in conflict and so it is not able to associate the time-dependent expression to the Ron parameter. For what concern the second error, I really don't know where it comes from, I only supposed it is linked to a similar reason.

    Thank you!
     
  4. Bordodynov

    Active Member

    May 20, 2015
    637
    188
    And you have replaced the series of points that you need to function? In my new pattern not defined resistance. I commented out this (set *). Resistance should be determined by a function of time. Is not that what you wanted?
     
  5. d19b

    Thread Starter New Member

    Dec 18, 2015
    15
    0
    Thanks again for you answer! Later I've commented all the parameters originally written in the model (putting a couple of *), except for the non-resistive ones, but I still have the .FUNC error. Moreover are you sure Pspice would recognize "t" as the time variable?

    Thank you!
     
  6. Bordodynov

    Active Member

    May 20, 2015
    637
    188
    For example:
    .func Rx(t) =100kOm(1.1-tanh(t/2sec)) it is Rx --> 100k*0.1=10k
    I took a variable function "t". It may be more understandable and familiar would take for the variable "x".
    "t" is a variable. If in its place will be handling "Time", the function will be calculated at the time of "Time". If in its place will be handling 2sec, then the function will be calculated for t = 2. I have not used the variable "Time" because it is a system variable.
     
  7. d19b

    Thread Starter New Member

    Dec 18, 2015
    15
    0
    Ok, thank you, I've understood this, so the only way to achieve my pourpose is to declare for example Ron as a function of the variable "t" (or "x" or whatever) and then in the application of the device in circuits changing the variable "t" with a numeric value?

    Thank you!
     
  8. Bordodynov

    Active Member

    May 20, 2015
    637
    188
    In my upgraded model already used the current time "time". But if you want to know the resistance value for a specific time value, then add to the circuit-dependent voltage source. example: ERon Ron 0 value {fRon (time)}. Looking at the node voltage circuit with the name "Ron", you will see the value of Ron.
     
  9. d19b

    Thread Starter New Member

    Dec 18, 2015
    15
    0
    Ok, so if I declare Ron as a function of "t" in model implementation and then in the applications of the device in circuits I associate/substitute t="Time" the resistance would change according to time simulation?

    Thank you!
     
  10. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    LTSpice makes this trivial...
    rest.gif
     
  11. Bordodynov

    Active Member

    May 20, 2015
    637
    188
    Yes.
     
    Last edited by a moderator: Dec 20, 2015
  12. Bordodynov

    Active Member

    May 20, 2015
    637
    188
    I did everything. You have only write functions!
    MikeMl. Thread Starter does not need resistors, which are dependent on time. He needs the parameters that depend on time. That's what I did.
     
  13. d19b

    Thread Starter New Member

    Dec 18, 2015
    15
    0
    Thank you for your continuous help! I'm going to show you the changes I've done and the consequent results I've got. Here is the model implementation of the device modifyed according to your suggestions:

    .SUBCKT memristor Plus Minus PARAMS:
    + Roff=100K Rinit=80K t=0 R0=5K Rf=5K tau=20 D=10N uv=10F p=1
    ***********************************************
    * DEFINITION OF THE TIME-VARIABLE RON *
    .PARAM Ron={(R0*exp(-t/tau)+Rf)}
    ***********************************************
    * DIFFERENTIAL EQUATION MODELING *
    ***********************************************
    Gx 0 x value={ I(Emem)*uv*Ron/D^2*f(V(x),p)}
    Cx x 0 1 IC={(Roff-Rinit)/(Roff-Ron)}
    Raux x 0 1T
    * RESISTIVE PORT OF THE MEMRISTOR *
    *******************************
    Emem plus aux value={-I(Emem)*V(x)*(Roff-Ron)}
    Roff aux minus {Roff}
    ***********************************************
    *Flux computation*
    ***********************************************
    Eflux flux 0 value={SDT(V(plus,minus))}
    ***********************************************
    *Charge computation*
    ***********************************************
    Echarge charge 0 value={SDT(I(Emem))}
    ***********************************************
    * WINDOW FUNCTIONS
    * FOR NONLINEAR DRIFT MODELING *
    ***********************************************
    *window function, according to Joglekar
    .func f(x,p)={1-(2*x-1)^(2*p)}
    *proposed window function
    ;.func f(x,i,p)={1-(x-stp(-i))^(2*p)}
    .ENDS memristor

    Where I decided to conventionally initialized "t" with the default value 0. Then I've applyed the device to a simple circuit with a triangle waveform generator and a 2k resistor and I've modified the value of "t" (opening the spreadsheet window of the component), associating to it the value Time (generic, not numerical). Here is the error I've got:

    upload_2015-12-21_15-0-34.png

    Probably once again I've not completely understood what you meant.
    Thank you!
     
  14. Bordodynov

    Active Member

    May 20, 2015
    637
    188
    You do not use my version of the model. I understand that you do not understand and continue to persist in their mistakes. I wash hands. You need to learn the syntax of Pspice.
     
  15. Bordodynov

    Active Member

    May 20, 2015
    637
    188
    * HP Memristor SPICE Model
    * For Transient Analysis only
    * created by Zdenek and Dalibor Biolek
    **************************
    * Ron, Roff - Resistance in ON / OFF States
    * Rinit - Resistance at T=0
    * D - Width of the thin film
    * uv - Migration coefficient
    * p - Parameter of the WINDOW-function
    * for modeling nonlinear boundary conditions
    * x - W/D Ratio, W is the actual width
    * of the doped area (from 0 to D)
    *
    .SUBCKT memristor_Time Plus Minus PARAMS:
    + Roff=100K Rinit=80K D=10N uv=10F p=1 R0=5K Rf=5K tau=20
    * DEFINITION OF THE TIME-VARIABLE RON *
    .func Ron(t)={(R0*exp(-t/tau)+Rf)}
    ***********************************************
    * DIFFERENTIAL EQUATION MODELING *
    ***********************************************
    Gx 0 x value={ I(Emem)*uv*Ron(Time)/D^2*f(V(x),p)}
    Cx x 0 1 IC={(Roff-Rinit)/(Roff-Ron(0))}
    Raux x 0 1T
    * RESISTIVE PORT OF THE MEMRISTOR *
    *******************************
    Emem plus aux value={-I(Emem)*V(x)*(Roff-Ron(Time))}
    Roff aux minus {Roff}
    ***********************************************
    *Flux computation*
    ***********************************************
    Eflux flux 0 value={SDT(V(plus,minus))}
    ***********************************************
    *Charge computation*
    ***********************************************
    Echarge charge 0 value={SDT(I(Emem))}
    ***********************************************
    * WINDOW FUNCTIONS
    * FOR NONLINEAR DRIFT MODELING *
    ***********************************************
    *window function, according to Joglekar
    .func f(x,p)={1-(2*x-1)^(2*p)}
    *proposed window function
    ;.func f(x,i,p)={1-(x-stp(-i))^(2*p)}
    .ENDS memristor_Time
     
  16. d19b

    Thread Starter New Member

    Dec 18, 2015
    15
    0
    Thank you for your support and for your patience! I'm sorry for not understanding your suggestions earlier! I really appreciate your help and I think that now the device works properly! I want other people to know that you have the proper suggestion for every topic!
    Best regards!
     
  17. d19b

    Thread Starter New Member

    Dec 18, 2015
    15
    0
    Hi, it's me once again! Simulations with the last working model went well, but now I'm trying to modify the other parameters of the device the same way I've done with the first one. This is the model I am using in order to make the resistive-parameter Roff time-dependent (as the only time-dependent parameter of the device), according to the one posted in the second reply to this thread (it's exactly the same but with Ron and Rinit without the time dependence):

    .SUBCKT memristor_sensor_off Plus Minus PARAMS:
    + Ron=10K Rinit=80K D=10N uv=10F p=1 R0=5K Rf=5K tau=20
    ***********************************************
    * DEFINITION OF THE TIME-VARIABLE RON *
    .FUNC Roff(t)={(R0*exp(-t/tau)+Rf)}
    ***********************************************
    * DIFFERENTIAL EQUATION MODELING *
    ***********************************************
    Gx 0 x value={ I(Emem)*uv*Ron/D^2*f(V(x),p)}
    Cx x 0 1000
    E_IC 1000 1 value={(Roff(Time)-Rinit)/limit(1m,((Roff(Time)-Ron)),1T}
    Raux x 0 1T
    * RESISTIVE PORT OF THE MEMRISTOR *
    *******************************
    Emem plus aux value={-I(Emem)*V(x)*(Roff(Time)-Ron)}
    **** Roff aux minus {Roff}
    G_Roff aux minus value={V(aux, minus)/Roff(Time)}
    ***********************************************
    *Flux computation*
    ***********************************************
    Eflux flux 0 value={SDT(V(plus,minus))}
    ***********************************************
    *Charge computation*
    ***********************************************
    Echarge charge 0 value={SDT(I(Emem))}
    ***********************************************
    * WINDOW FUNCTIONS
    * FOR NONLINEAR DRIFT MODELING *
    ***********************************************
    *window function, according to Joglekar
    .func f(x,p)={1-(2*x-1)^(2*p)}
    *proposed window function
    ;.func f(x,i,p)={1-(x-stp(-i))^(2*p)}
    .ENDS memristor_sensor_off

    At the time of simulation this time I get this mismatch error:

    upload_2015-12-30_21-26-57.png

    What error I've done this time? The model I used has to be further modified?
    Thank you for your attention!
     
  18. crutschow

    Expert

    Mar 14, 2008
    13,000
    3,229
    Mike, is this described somewhere in the LTspice help files?
     
  19. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    I first learned the R=function trick on the Yahoo Users Group. I think it was called an "undocumented feature". Basically, the function can be anything that a BV or BI can take on. Read the help file entry for BV to get an idea of how rich this is...
     
  20. eetech00

    Active Member

    Jun 8, 2013
    649
    112
    Maybe should be:
    value={(Roff(Time)-Rinit)/limit(1m,(Roff(Time)-Ron),1T)}

    ??
     
Loading...