# Stability of derivative function

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)

I did the following simulations :

With the following results:

The B1 source should compute the derivative of V(IN_OUT) signal but that is not really the case.

Do you have an explanation for that (my simulation file here included)?

Thank you QSpice community

Davide
question.qsch (3.8 KB)

Try to change the integration method to gear, because that is trapezoidal ringing.
.options method=gear
And check page 20 of this manual.
Achieving Accurate Results With a Circuit Simulator.pdf (176.0 KB)

Best regards
Ivan

1 Like

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.

2 Likes

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.

question-dll.qsch (4.4 KB)
derivativedll.qsym (334 Bytes)
derivativedll.cpp (1.7 KB)

C++ code

2 Likes

Hello Ivan ,

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

https://forum.qorvo.com/t/integration-idt-problem-why/17221

Than you for your documentation !

Regards, Davide

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.

Davide

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.

waveform-derivative.qsch (3.7 KB)

2 Likes