Smooth steps

ODE solvers have a hard time with step changes, where the derivative changes discontinuously. The following function help to avoid associated problems by approximating the step by a smoother function. Argument dx controls the smoothness.

MTKHelpers.smoothstepFunction
smoothstep(x, x_step, dx, a=zero(x), b=one(x))

smooth step function:

  • = a for x <= x_step - dx
  • = b for x >= x_step + dx
  • = (a-b)/2 for x == x_step

and smooth in between.

source