4
\$\begingroup\$

Hi I am trying to simulate a model of a paper in LTSpice but I get an if function error which says "Syntax error: function if(): requires exactly three segments" These are the code of the model:

.subckt SEM + - R
.params
+ H0=0 rs=215 CH0=1e-4 del=0.01 vp=0.1
+ i01=6E-9 a1=2.3 rs1=20K
+ i02=1E-12 a2=15.9 rs2=350
+ i03=9e-4 a3=3
+ nset=7 vset=2 nres=6 vres=0
BH 0 H I=if(ddt(V(A,-))>=0,((D(V(H))-1)*S(V(A,-))
+ +S(D(V(A,-)))-D(V(H)))/S(D(V(A,-)))-1),
+ D(V(H))/R(D(V(A,-)))*R(V(A,-))) Rpar=1
CH H 0 {CH0} ic = {H0}
RS + A {rs}
RS1 A B {rs1}
BD1 B - I = i01*sinh(a1*V(B,-))
RS2 A C {rs2}
BD2 C - I = i02*(exp(a2*V(C,-))-1)
BPL A - I = V(H)*i03*V(A,-)**a3
BI 0 R I = i01*sinh(a1*vp)+i02*(exp(a2*vp)-1)
+ +V(H)*i03*vp**a3
.func D(x){delay(x,del)}
.func S(x){1/(1+exp(-nset*(x-vset)))}
.func R(x){1/(1+exp(-nres*(x-vres)))}
.ends

Is there something wrong?

\$\endgroup\$

1 Answer 1

6
\$\begingroup\$

The error is about exactly what it says: the conditional is defiend as if(a,b,c), and if you check the expression for BH with a text editor that has highlighting for matching braces, you'll see that the first paranthesis in the opening if( ends at the end of the second line, but the expression continues on the third line as if it were the c argument of if(). Either you need to fix that, or let the author do it.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.