Does Ngspice 23/24 support .FUNC ?

2012-12-15
2013-06-12
  • Amal Banerjee

    Amal Banerjee - 2012-12-15

    Could some ngspice guru please clarify this ? Does ngspice 23/24 support
    .FUNC ?
    I have in a netlist:
    .PARAM ns=1
    .PARAM SOCm=1
    .PARAM k=1
    .PARAM D=1
    .PARAM SOC1=1

    ************ battery
    .SUBCKT TESTBAT 3 2 1
    .FUNC RCHAR() {(0.758+(0.1309/(1.06- SOC1)))*ns*100/SOCm}
    .FUNC RDISCHAR() {(0.19+(0.1037/(SOC1-0.14)))*ns*250/SOCm}
    …..
    …..
    …..
    .ENDS

    I am getting runtime errors as :
    Original line no.: 0, new internal line no.: 19:
    Undefined number
    Original line no.: 0, new internal line no.: 19:
    Cannot compute substitute
    Original line no.: 0, new internal line no.: 20:
    Undefined number
    Original line no.: 0, new internal line no.: 20:
    Cannot compute substitute

    How could I get around this issue ? Any hints/
    suggestions would be of immense help. Thanks
    in advance.

     
  • Robert Larice

    Robert Larice - 2012-12-15

    dakuu,

      here is an excerpt from
         examples/memristor/memristor.sp

    * memristor model with limits and threshold
    * "artificial" parameters alpha, beta, and vt. beta and vt adapted to basic programming frequency 
    * just to obtain nice results!
    * You have to care for the physics and set real values! 
    .subckt memristor plus minus PARAMS: Ron=1K Roff=10K Rinit=7.0K alpha=0 beta=20e3/stime Vt=1.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)) '
    Vx x x1 dc 0
    Cx x1 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))} 
    .ends
    

    note the `=' which is used here in the .func line.
    thats supposed to work with the current git ngspice,
      but I don't know whether ngspice-23/24 will work.

    Robert

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks