Ngspice to PSpice conversion

Discussion in 'General Electronics Chat' started by captainkirk, Jun 1, 2012.

  1. captainkirk

    Thread Starter New Member

    Jun 1, 2012
    Hi All,

    I have a piece of Ngspice code that I need to convert to PSpice. I feel it is a simple matter of syntax but I have so far failed to make it work.

    The code models a Memristor with thresholding ability (the fourth fundamental component along with resistors, capacitors, and inductors)

    The code is as follows:

    .subckt memristor plus minus PARAMS: Ron=1K Roff=10K Rinit=5K alpha=0 beta=1E13 Vt=4.6
    Bx 0 x I='(f1(V(plus)-V(minus))>0) && (V(x)<Roff) ? {f1(V(plus)-V(minus))}: (f1(V(plus)-V(minus))<0) && (V(x)>Ron) ? {f1(V(plus)-V(minus))}: {0}'
    Cx x 0 1 IC={Rinit}
    Rmem plus minus r={V(x)}
    .func f1(y)={beta*y+0.5*(alpha-beta)*(abs(y+Vt)-abs(y-Vt))}

    The code explanation is as follows:
    - The memristive system is realized as a sub-circuit combining a behavioral resistor R, a current source ↑, and a capacitor C.
    - The second line of code (Bx ...) defines the current source with the current specified through ternary functions. (A ternary function is defined in the code as a ? b : c , which means ”IF a, THEN b, ELSE c” [17].) The purpose of these functions is to limit RM between Ron and Roff.
    - The third line of the code specifies the capacitor C (Cx ...) with an initial condition.
    - The fourth line (Rmem ...) defines the behavioral resistor whose resistance takes the same numerical value as the voltage across the capacitor.
    - The next line (.func ...) provides the function f according to Equation (not important here)

    If you can help me in any way that would be great!!

    Many thanks