Hi there I want to know is there any particular solution for solving timestep error in KiCAD permanently. My Electronics career is just started with hardware design and for power circuits I want to run simulation. I do all the simulation in KiCAD.But I have been facing so much timestep too small error. If you know the solution kindly let me know. Thank you.
“timestep too small” is not the problem on itself. The “timestep too small” is a result of something else in your simulation not working properly, and because of that other problem, ngSpice keeps on making the time step smaller, until it finally gives up.
“Timestep too small” is one of the most frustrating errors. Try adding a (small) series resistor to supplys, an ESR to capacitors etc. Sometimes adding a (very) small capacitance to GND helps. I had circuits when I changed the OpAmp to a different type, it worked. Sometimes the models you use have internal problems, in some circuits they work, in others they don’t. You can spend plenty of time trying to solve this error.
This is normal. There are thousands of different opamps, and they are not universally exchangeable. For example if you use an opamp that is not unity gain stable as a buffer, and you find your ngSpice simulation oscillating, then that is a good thing, because in real-life it would probably oscillate too. Capacitive loads on outputs of opamps is another common problem. Some opamps can handle this much better then others.
I would have been happy if it did oscillate. But “time step too small” is something completely different.
There is none. There are so many possible reasons for getting this error, that there will be no general solution.
But when for example simulating power circuits, there are some options to play with. The main focus of these options is to relax the tight restriction concerning precision (which might be ok when simulating ICs with 1.8 V supply, but which are too strict for DC/DC converters).
.options CHGTOL=1e-12 trtol=1 abstol=100n reltol=0.01 method=gear RSERIES=0.05
You will have to test which options may be most influential. CHGTOL may be varied between 1e-12 and 1e-10 (default is 1e-14). Info on these options is available in the ngspice manual, chapter 15.1.
Sometimes convergence already fails with calculating the operating point. Then flag UIC added to the tran command may help.
I think that the error is misnamed. It should probably be called: “failed to converge, minimum time step reached giving up”*. So what the error is saying is that there is something wrong in your model. Signaling that it can not work for some reason.
Obviously you cant solve user inputting garbage.
* Yeah time step is too small, but makes you think you put the time step too small. But in fact the system reached the minimum limit and gave up
It would be better if the error message could give a hint on why the convergence failed.
True, but i don’t think the hint would be very good. Though it could tell what parts of the solvers rows don’t converge. But this is not a kicad issue.
@paulvdh, it does give a hint: the time step is too small.
Seriously though, along the lines of what @joojala said, you’d have to dig into the math. That said, 8 times out of 10 for me it’s because I mapped pins the wrong way when attaching a new model to a symbol or some other syntax error on my part, 1 out of 10 its because I was being lazy and gave the simulator a poor circuit in hopes that it could save it, and the final reason is
That said, here is what chatGPT (ALERT NOT MY ORIGINAL THOUGHTS) replies to the prompt “what does ngspice mean when it fails for time step too small.” I think it’s all pretty much on-point.
When NGSPICE (or SPICE simulators in general) reports an error like “time step too small”, it indicates that the simulation is having difficulty progressing due to numerical stability issues. This usually happens when the simulator tries to resolve very rapid changes in the circuit’s behavior, but the required time step becomes too small to accurately compute.
Here’s what this means and some possible reasons for this error:
1. Rapidly Changing Signals:
- If there are very fast transients (e.g., sharp voltage or current spikes), the simulator might struggle to find a suitable time step to accurately model these changes. The simulator automatically reduces the time step to improve accuracy, but if the time step becomes too small, it might trigger this error.
2. High-Frequency Components:
- Components that create high-frequency oscillations (like capacitors, inductors, or certain semiconductor devices) may cause the simulation to require very small time steps. If the circuit contains parasitics or small capacitances/inductances, they can introduce high-frequency behavior that the simulator finds difficult to handle.
3. Poor Convergence:
- Convergence problems in nonlinear components (like diodes, transistors, etc.) can cause the simulator to fail at finding a proper solution, leading it to take very small time steps in an attempt to resolve this. If the time step is too small, it means the simulator couldn’t find a stable point.
4. Inappropriate Time Step Settings:
- Sometimes, user-defined settings such as the maximum or minimum time step might not be appropriate for the circuit’s dynamics. The simulator may get stuck trying to resolve details that are too fine for the given timestep.
How to Address the Issue:
-
Modify Initial Conditions:
- Adjust initial conditions to avoid unrealistic or difficult-to-converge starting points.
-
Increase Circuit Stability:
- Add small resistances in series with inductors or small conductances in parallel with capacitors to help with convergence.
-
Adjust Time Step Control Parameters:
- Try setting limits on the maximum and minimum time steps using
.TRAN
statements (e.g., adjusting thetstep
andtstop
values).
- Try setting limits on the maximum and minimum time steps using
-
Increase Accuracy:
- Use more accurate numerical methods or tolerances in NGSPICE, such as reducing the
RELTOL
parameter (relative tolerance) orABSTOL
(absolute tolerance).
- Use more accurate numerical methods or tolerances in NGSPICE, such as reducing the
-
Check the Circuit for Issues:
- Look for any circuit components or configurations that could be introducing extremely fast or unstable behavior, and if necessary, revise the circuit design or model.
If you share more details about the specific circuit you’re working on, I could suggest a more targeted solution!