Hello
Congratulations for this fantastic simulation tool. Being able to merge analog with programming is really something I’ve been waiting for for a long time (and not only for electronic simulation)

If you search trap ringing in this forum, you can find multiple posts discussed about this and with answer from Mike Engelhardt (author of Qspice).
Your example demonstrated how trap ringing can be observed. Spice uses numerical method and trapezoidal/gear integration method and they exhibit unique characteristics. In default, Qspice uses trapezoidal integration and trapezoidal ringing is one of its characteristics.

As your simulation is basically function and formula, not a circuit with realistic components, where function being integrated has sudden changes, and this is why trap ringing is observed. These slides explains why trap ringing in your setup (I simplified your circuit with a source disabled its timectrl). Change to Gear can eliminate this ringing, but remember this is not a recommended method as it changed your circuit by introduces artificial damping.

This is a method to get rid of trap ringing for derivative. Setup a DLL block (C++) and calculate derivative from two consecutive points can give you result of derivative which not relates to trap integration.

Thank you for your reply. In fact yes there is no more ringing but I got something like one “parasit” spike but this is the effect that the Gear methode can provides , see the post

Hello KSKelvin,
Thank you for your replies. Very complete an interesting.
I will use your dll . I use QSpice to simulate electromecanical actuators (valves) where I compute current , voltage , reluctance, magnetic flux, force, velocity and stroke with some limit conditions which make equations strongly non-linear. Thank you for your Help.

Nice clarification of ddt and trap ringing KSKelvin.

I noticed, if you take derivative of simulated data with waveform viewer function D(x), result will not suffer from trap ringing effect. Naturally you cannot use this during simulation, but if you are only intrested to see derivative of simulated signal this may be an option.

Didn’t think about this post-processing method, thanks for sharing.
Slope of V(IN_OUT) is correct and post-processing with DLL block or Waveform Viewer GUI can yield correct result. Trap ringing is also correct if you consider integration is area under curve which is what integration do.

Your test setup has actually helped me understand why trapezoidal ringing can occur! I have contemplated this topic many times, but this is the first instance where I have been able to comprehend and demonstrate its nature.