- Analog modeling of a diode clipper (1): Circuits
- Analog modeling of a diode clipper (2): Discretization
- Analog modeling of a diode clipper (3a): Simulation
- Analog modeling of a diode clipper (3b): Simulation
- Analog modeling of a diode clipper (4): State-space
Now that we have a few methods, let’s try to simulate them. For both circuits, I’ll use the forward Euler, then backward Euler and trapezoidal approximations, then I will show the results of changing the start estimate and then finish by the Newton Raphson optimization. I haven’t checked (yet?) algorithms that don’t use the derivative like the bisection or Brent algorithm.
All graphs are done with a x4 oversampling (although I also tried x8, x16 and x32).
First diode clipper
Let’s start with the original equation:
Let’s now figure out what to do with the integral by deriving the equation:
So now we have the standard form that can used the usual way. For the derivative of the input, I’ll always use the trapezoidal approximation, and then for the output one, I’ll use the forward Euler which leads to the “simple” equation:
For the backward Euler, I’ll start from the integral equation again and remove the time dependency:
Now the discretization becomes:
I didn’t use this equation for the Backward Euler because I would have had a dependency in the sinh term, so I would still have required the numerical methods to solve the equation.
Here, we just need to change the discretization for a trapezoidal one:
Starting from the different rules, we need to replace sinh(x):
- for the pivotal by
- for the tangent rule by
Let’s see now how all these optimizers compare (with an estimate of the next element being the last optimized value):
Obviously, the Forward Euler method is definitely not good. Although is on average 4 times lower, the accuracy is definitely not good enough. On the other end, the other two methods give similar results (probably because I try to achieve a convergence quite strong, with less that 10e-8 difference between two iterations).
Now, how does the original estimate impact the results? I tried the Backward Euler to start, and the results are identical:
To have a better picture, let’s turn down the number of iterations to 1 for all the estimates:
So all the estimates give a similar result. By comparing the number of iterations with the three estimates, the pivotal method gives the worst results, whereas the affine estimates lowers the number of iterations by one. Of course, there is a price to pay in the computation.
So the obvious choice is to use trapezoidal approximation with affine starting point estimate, which is not my default choice in SimpleOverdriveFilter.
To be continued
The post is getting longer than I thought, so let’s keep it there for now and the next post on the subject will tackle the other diode clipper circuit.