Function and Parameters

  • NGSPICE 2.3:
    Suppose I have a parameter:
    .param p1=1.0

    …and a function:
    .func foobar(v1)={v1*p1}

    …and a voltage controlled current source invoking the function with n1 being a node in the circuit:
    B1 TOP BOT I=foobar(V(n1))

    This fails, what is the proper syntax to call foobar() and multiply p1 with V(n1) in the I=… syntax for a Voltage Controlled Current Source

  • Holger Vogt
    Holger Vogt

    Syntax is o.k. There must be something else in your circuit.

    What is the error message?
    Can you provide a (simple, but complete) input file which shows the problem?
    The following is o.k.

    .param p1=1.0
    .func foobar(v1)={v1*p1}
    vn1 n1 0 2
    B1 TOP BOT I=foobar(V(n1))
    R1 TOP BOT 1
    R2 TOP 0 1 ; need a connection to ground!