tanh_ramp

boulderopal.signals.tanh_ramp(duration, end_value, start_value=None, ramp_duration=None, center_time=None)

Create a Signal object representing a hyperbolic tangent ramp.

Parameters

  • duration (float) – The duration of the signal, TT.
  • end_value (float or complex) – The asymptotic value of the ramp towards t+t \to +\infty, a+a_+.
  • start_value (float or complex or None , optional) – The asymptotic value of the ramp towards tt \to -\infty, aa_-. Defaults to minus end_value.
  • ramp_duration (float or None , optional) – The characteristic time for the hyperbolic tangent ramp, trampt_\mathrm{ramp}. Defaults to T/6T/6.
  • center_time (float or None , optional) – The time at which the ramp has its greatest slope, t0t_0. Defaults to T/2T/2.

Returns

The hyperbolic tangent ramp.

Return type

Signal

SEE ALSO

boulderopal.signals.linear_ramp : Create a Signal object representing a linear ramp.

Graph.signals.tanh_ramp_pwc : Graph operation to create a Pwc representing a hyperbolic tangent ramp.

Graph.signals.tanh_ramp_stf : Graph operation to create a Stf representing a hyperbolic tangent ramp.

Notes

The hyperbolic tangent ramp is defined as

Tanh(t)=a++a2+a+a2tanh(tt0tramp), \mathop{\mathrm{Tanh}}(t) = \frac{a_+ + a_-}{2} + \frac{a_+ - a_-}{2} \tanh\left( \frac{t - t_0}{t_\mathrm{ramp}} \right) ,

where the function’s asymptotic values a±a_\pm are defined by:

a±:=limt±Tanh(t), a_\pm := \lim_{t\to\pm\infty} \mathop{\mathrm{Tanh}}(t) ,

and t0t_0 is related to trampt_\mathrm{ramp} by:

dTanh(t)dtt=t0=(a+a)2tramp. \left.\frac{{\rm d}\mathop{\mathrm{Tanh}}(t)}{{\rm d}t}\right|_{t=t_0} = \frac{ (a_+ - a_-)}{2 t_\mathrm{ramp}} .

Note that if t0t_0 is close to the edges of the ramp, for example t02trampt_0 \lesssim 2 t_\mathrm{ramp}, then the first and last values of the outputted array will differ from the expected asymptotic values.

With the default values of startvalue ($a-),rampduration(), ramp_duration (t_\mathrm{ramp}),andcentertime(), and center_time (t_0$), the ramp expression simplifies to

Tanh(t)=Atanh(tT/2T/6), \mathop{\mathrm{Tanh}}(t) = A \tanh\left( \frac{t - T/2}{T/6} \right),

where A=a+A = a_+ is the end value (the start value is then A-A). This defines a symmetric ramp (around (T/2,0)(T/2, 0)) between 0.995A-0.995 A (at t=0t=0) and 0.995A0.995 A (at t=Tt=T).

Examples

Define a tanh ramp.

>>> signal = bo.signals.tanh_ramp(
...     duration=4, end_value=2, start_value=1, ramp_duration=0.4, center_time=2.
... )
>>> signal.export_with_time_step(time_step=0.4)
array([1.00012339, 1.00091105, 1.00669285, 1.04742587, 1.26894142,
   1.73105858, 1.95257413, 1.99330715, 1.99908895, 1.99987661])

Was this useful?