Diode clipper simulation instability
-
- KVRian
- 1379 posts since 26 Apr, 2004 from UK
Agreed. Especially the osciallations at the start of the ramp are not nice.
The other distortion function (SD1) is more pleasant :p
The other distortion function (SD1) is more pleasant :p
-
- KVRian
- Topic Starter
- 513 posts since 3 Sep, 2009 from Poland
I think this can be solved without iterations, just wanna give it a try.
- The equation is of form f(y) = g*x + s, where f(y) is g*y + a*sinh(b*y).
- We can't analytically find inverted function, but we can compute it for a range, store in array and interpolate - assuming than g,a,b are constant - and they are
- then y = inv_f(g*x+s)
btw. what is the other distortion? it's based on a circuit?
- The equation is of form f(y) = g*x + s, where f(y) is g*y + a*sinh(b*y).
- We can't analytically find inverted function, but we can compute it for a range, store in array and interpolate - assuming than g,a,b are constant - and they are
- then y = inv_f(g*x+s)
btw. what is the other distortion? it's based on a circuit?
giq
-
Richard_Synapse Richard_Synapse https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=245936
- KVRian
- 1139 posts since 20 Dec, 2010
IIRC the Simulanalog method involves the derivative of the input signal. Not sure what implications this has regarding accuracy, but it might be better if you can avoid that.
Richard
Richard
Synapse Audio Software - www.synapse-audio.com
-
- KVRian
- 1379 posts since 26 Apr, 2004 from UK
Yes, I made another function based on the SD1 distortion pedal. I'm still in the process of thinking about amps, but I don't have the time at the moment
Richard > it uses the derivative of the signal to analyze the stability of the algorithm. Then the derivative appears due to the trapezoidal integration, but that's OK IMHO.
Richard > it uses the derivative of the signal to analyze the stability of the algorithm. Then the derivative appears due to the trapezoidal integration, but that's OK IMHO.
-
- KVRian
- Topic Starter
- 513 posts since 3 Sep, 2009 from Poland
Any idea on how to make it stable?
y = f*(in-feedback) + s - 0.00016 * sinhf(feedback*40.0)
sinhf acts like 'a switch' and after a threshold quickly approaches to inf. This causes huge numerical problems when using Newton-Rhapson.
y = f*(in-feedback) + s - 0.00016 * sinhf(feedback*40.0)
sinhf acts like 'a switch' and after a threshold quickly approaches to inf. This causes huge numerical problems when using Newton-Rhapson.
giq
-
- KVRAF
- 1607 posts since 12 Apr, 2002
I thought you wanted to use a table (sorry, I'm following this thread only superficially). How about solving for the value rather than the argument of sinh? (Or for anything containing the value of sinh).itoa wrote:Any idea on how to make it stable?
y = f*(in-feedback) + s - 0.00016 * sinhf(feedback*40.0)
sinhf acts like 'a switch' and after a threshold quickly approaches to inf. This causes huge numerical problems when using Newton-Rhapson.
-
- KVRian
- Topic Starter
- 513 posts since 3 Sep, 2009 from Poland
How about off-current inaccuracy in real diodes? How many % is it?
Miles: could you post ODE of your circuit? I can't figure this out from your code :/
Miles: could you post ODE of your circuit? I can't figure this out from your code :/
giq
-
- KVRian
- 1153 posts since 11 Aug, 2004 from Breuillet, France
If you use a table with precomputed tables, do you still have any problem ? If not, that means your problem is about the convergence of Newton-Raphson. If you still have instability, then your ODE may be stiff, and there is a numerical way to verify it. But since you use a trapezoidal integrator, stiffness shouldn't be a problem, so I guess it's Newton Raphson. Or a standard algorithm bug
Could you post some pseudo code showing what you are doing ?
Could you post some pseudo code showing what you are doing ?
-
- KVRian
- Topic Starter
- 513 posts since 3 Sep, 2009 from Poland
Wolfen: I think that diodes make systems stiff as a hell and thats the main problem.
Using table for inverted function improves stability region greatly. Although the limit still exists its quite acceptable.
Using table for inverted function improves stability region greatly. Although the limit still exists its quite acceptable.
giq
-
- KVRAF
- 1607 posts since 12 Apr, 2002
I think, if you try solving for the value rather than the argument of sinh, then sinh works as a saturator, rather than the booster. That should make the system kind of the opposite of being stiff. At least seems so to me at the first look, maybe I'm wrong here.
Speaking of trapezoidal integration and stiffness. Trapezoidal integration may have a problem with that, particularly in case of strong positive feedback. But I don't think that's the case here.
Speaking of trapezoidal integration and stiffness. Trapezoidal integration may have a problem with that, particularly in case of strong positive feedback. But I don't think that's the case here.
-
- KVRian
- Topic Starter
- 513 posts since 3 Sep, 2009 from Poland
Yes you are right.. reverse function forms a sigmoid and this helps a lot + as this is 1 dimensional equation, this is instantly solvable and fast
btw. Just realised that these RC values means 7MHz cutoff SIC?!
btw. Just realised that these RC values means 7MHz cutoff SIC?!
giq
-
Richard_Synapse Richard_Synapse https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=245936
- KVRian
- 1139 posts since 20 Dec, 2010
Inverse function is a really clever idea that should work.
Btw, you can also use Bisection method, should be robust and work fine even in realtime (if you don't like tables). You already know the output is never going to exceed a certain value as it's clipped by the diodes, so you can start the iteration at +/- 1V or something.
Richard
Btw, you can also use Bisection method, should be robust and work fine even in realtime (if you don't like tables). You already know the output is never going to exceed a certain value as it's clipped by the diodes, so you can start the iteration at +/- 1V or something.
Richard
Synapse Audio Software - www.synapse-audio.com
-
- KVRian
- Topic Starter
- 513 posts since 3 Sep, 2009 from Poland
A bit excitation here. Just found a method of doing this analytically for practically any number of dimensions, this reduces aliasing as well. I mean computation of n-dimensional inverse function. Should I share ?
edit: its a bullshit except alias reduction part haha
edit: its a bullshit except alias reduction part haha
Last edited by itoa on Wed Oct 08, 2014 10:18 am, edited 1 time in total.
giq