# Frequency dependent amplitude of a current source in an .AC analysis in LTspice

In my LTspice simulation I would like to integrate a current source in an .AC analysis which has an amplitude that varies over the simulated frequency spectrum, e.g. something like $$\A(f) = {A_0 \cdot f} \$$.

Is the frequency in .AC not an accessible quantity as time is in a .tran analysis?

• Just multiply by "f" Aug 31 '21 at 13:41
• unfortunately this doesn't work... Aug 31 '21 at 14:34
• You are doing an AC analysis and using I2 as the input stimulus yes? How have you set up the analysis i.e. what is your output node? Is that output linearly dependent on I2? Aug 31 '21 at 14:57
• I use two current inputs, I1 (on the right hand side) with a constant input amplitude, and on the other hand I2 which is supposed to have a varying input amplitude that changes with the frequency. Aug 31 '21 at 15:03
• That's about 50% of what I asked. Aug 31 '21 at 15:07

I will not make any comments on what you're trying to simulate; I'll assume you know what you're doing.

The basic voltage or current source (your I2) can only accept numeric literals or parameter-style values -- and .param statements are all evaluated prior to simulation start, therefore none of them can be time or frequency dependent; i.e. they are "static". What you wrote as a value, {Amp*Frequency} (leaving Phi aside for now) implies the usage of two .param defined values, Amp and Frequency, both of which can only be static. Even if frequency is a keyword with special significance, it is only meaningful for the waveform arithmetic, which happens only inside the waveform viewer.

If you need your AC source to vary as $$\\dfrac{1}{f}\$$ then you need to use an integration, as you correctly assumed. The methods are different, though:

1. use a current source with a capacitor across it, or
2. a behavioural source with the idt() function (or sdt(), same thing).

If you use 1) then you will need to add a buffer between the current + cap and the rest of the circuit, unless the output drives a pure voltage input (e.g. the input of a VCVS). Seeing you are driving an LC tank, you need a buffer. The value of the capacitor will decide the frequency when the magnitude will be 0 dB. For 2) it's easier to simply use a bv or a bi (or bi2). An example for both cases:

B2 is divided by $$\2\pi\$$ which will make it have unity magnitude at 1 Hz.

As a side note, unless it was intended, you can press A to toggle the visibility of the anchors (the small circles beside the labels). Also unless intended, you can draw angled wires instead of that staircase by pressing Ctrl when moving the wires.

• Laplace expressions also work in LTspice (in .AC, .TRAN may be problematic), as per Andy's answer. For that, in the left half of the picture, instead of the value 1 for the VCVS or VCCS, make it Laplace=<...>, and for the right half of the picture, instead of sdt() or idt() use V=V(1) Laplace=<...>, where <...> is some expression in s. Sep 1 '21 at 14:17

I use micro-cap and I would use a Laplace function like this: -

The AC analysis of Vout would be this: -

So, I'm using a voltage source (initially AC phase shifted by 90°) feeding through a Laplace term that happens to be "s" (i.e. integration) then controlling the current source.

As you should be able to see from the AC analysis, 0 dB corresponds with a frequency of 0.15915 Hz or 1 radian per second. Of course, the Laplace function can become whatever you want it to be in order to model the actual frequency relationship you want.

If you don't have the ability to use Laplace functions in your sim then insert an equivalent circuit between V1 and E1 that modifies V1 accordingly.