I am running LTspice in batch mode on my Windows. However, I am now migrating to Linux, where the alternative to LTspice is Ngspice. The problem I am facing is the following:

In my LTspice netlist I have different behavioral voltages that are defined with lookup tables as follows:

V1 1 0 AC 1
XR1 1 0 Rskin
.subckt Rskin 1 2
R1 1 11 1n ; <= to avoid parallel voltage sources
V1 11 10 0
B2 10 2 V=I(V1) MAG FREQ=
.inc Rskin.inc
.ac dec 6 1 100k

Example taken from here. Where Rskin.inc file contains a table of (freq,mag,phase) of the frequency behavior of the resistance.

So, a part from the control section that ought be added in the NGspice netlist

set filetype=binary
set ngbehavior = lta
write path_2my_netlist all

where I specify that the ngspice behavior should be that of LTspice, what else is there to do to have this netlist sample run on Ngspice. I still get the error :

Undefined number [mag]

PS: Wine is not an option.

  • \$\begingroup\$ It looks like MAG FREQ= is not recognized, so it might be that it defaults to dB FREQ= (e.g. freq, dB, phase[deg] triplets) -- which means it's not needed to add the dB keyword. If your data is made for MAG FREQ= then you'll need to convert it to dB (if, indeed, Ngspice does not recognize that). \$\endgroup\$ Commented Aug 16, 2022 at 9:44
  • \$\begingroup\$ @aconcernedcitizen Even when I delete the MAG and leave it just to FREQ, I still get an error: freq undefined... \$\endgroup\$
    – Wallflower
    Commented Aug 16, 2022 at 9:47
  • 1
    \$\begingroup\$ Well, that's encouraging. I guess the syntax is not known. If true, your only other option is to approximate the response with RLC elements. But, if you're using this file then the comment above lists a frequency-domain expression, so you can use Laplace (which Ngspice does know). \$\endgroup\$ Commented Aug 16, 2022 at 12:57
  • 1
    \$\begingroup\$ @SteKulov Thank you for your comment, but I have specified in the question that Wine is not an option. The lab is against it for 'security reasons'... \$\endgroup\$
    – Wallflower
    Commented Aug 16, 2022 at 20:54
  • 1
    \$\begingroup\$ Whoops. Roger that. I would've started out your question with that (including the reason) instead of tacking it at the bottom. You're statement of "...migrating to Linux, where the alternative to LTspice is Ngspice." is what threw me off. It's "an" alternative but not "the" alternative until you explain your constraints. Anyway, the answer is below is good. Check my link under the comments there for statements made by one of the ngspice authors regarding the FREQ command. \$\endgroup\$
    – Ste Kulov
    Commented Aug 17, 2022 at 2:41

1 Answer 1


I'll make this an answer, since Ngspice does, indeed, not know the FREQ syntax. But, if your example is this circuit then you have there a Laplace expression, just copy-paste it, since freq is an alias for s. Otherwise it looks like your only other alternative is an RLC approach. It's not that bad, if things are this (relatively) simple. For example, these series RL sections, all in parallel, give a purty good approximation, though a tad higher magnitude:

L1 a b 10u rser=20m
L2 a b 5u rser=30m
L3 a b 3u rser=40m
L4 a b 2u rser=50m

OTOH, you now get a phase which, with the FREQ approach, did not have. Also, that Laplace expression is not exactly quite like the FREQ approach, either...

  • 2
    \$\begingroup\$ Just adding a reference highlighting that FREQ is currently not supported in ngspice, but anyone willing to do it can volunteer writing the code for it! forum.kicad.info/t/import-target-function-for-ngspice/26907/5 \$\endgroup\$
    – Ste Kulov
    Commented Aug 16, 2022 at 18:06
  • 2
    \$\begingroup\$ @SteKulov Thanks for the link. I saw it being discussed in the group, but not the link. \$\endgroup\$ Commented Aug 16, 2022 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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