I have a sine source, resistor, and inductor loop. The current through the inductor is always positive, but the sine source goes both positive and negative. Why is it working incorrectly?
If the resistance is small enough, you may have a large L/R time constant. This can often occur when using a sine source since its default series resistance parameter (RS) is 1m. The inductor is working exactly as it is supposed to according to basic circuit theory when the resistor is having very little effect. The inductor current is calculated as:
i = (1/L) * integral from 0 to t of v(x)*dx + i(0)
v(x) = A*sin(2*PI*f*t)
i = (A/L)*(1/(2*PI*f))*(1-cos(2*PI*f*t))
The cosine portion of the equation will always produce a positive result.
If you run the simulation for a longer time, you should see the inductor current settle to the expected values.