RL Circuit not modelling current as expected

Hello. I’m new to qspice, and am using it for a project.
I’m trying to model the current as a function of time in an RL circuit, the instant a switch is closed (completing the circuit). Image 1 shows my attempts so far.

I have been able to produce a solution to the governing differential equation: I(t) = 5(1 - e^{-3t}). Which, when plotted, shows what I expect the graph to look like. Is there something I am overlooking in the qspice model that is causing the difference?

Thats caused by dc initial operating point solver. To avoid it, you can modify .tran 1 into .tran 1 .uic to force dc inititial operating point solver to not work.

Additionally you can .ic = 0 directive at the inductor to ensure inductor current starts from zero when the simulation starts

@physicboy already explained the critical part. Method 1 is .ic method in above. Or Method 2 with a switch. This example includes a .func to setup your formula, such that you can run simulation and compare with your math together. But three curves are overlapping in this plot. You have to click on its legend to force its on top.

RL network.qsch (6.9 KB)


I’m not sure if I did it correctly, but it still isn’t working.

You wrote wrong…its not .tran 1 .uic, but its only .tran 1 uic (without that dot in front of uic). Try this and you will see that the things will work and will be good

Ah my mistake. I wrote it down incorrectly. Working now.

Got it. I had to label .ic I(l1)=0. Working now, thanks!

If you use .tran 1 uic, you don’t have to add .ic I(L1)=0, as uic force all initial condition to 0A/0V.
Actually, you have one more way, you can set your voltage source to PWL 0 0 1p 6, it will allow voltage start from 0V at 0s, which allow all initial condition to 0. No matter which method, idea is to have initial condition to 0V/0A. This is summary of 4 method. Method 4 needs to change .tran 1 to .tran 1 uic

RL network.qsch (11.3 KB)