tanh_ramp_stf

The Boulder Opal Toolkits are currently in beta phase of development. Breaking changes may be introduced.

tanh_ramp_stf(center_time, ramp_duration, end_value, start_value=None)

Create an Stf representing a hyperbolic tangent ramp.

Parameters:
  • center_time (float or Tensor, optional) – The time at which the ramp has its greatest slope, \(t_0\). It must either be a scalar or contain a single element.

  • ramp_duration (float or Tensor, optional) – The characteristic time for the hyperbolic tangent ramp, \(t_\mathrm{ramp}\). It must either be a scalar or contain a single element.

  • end_value (float or complex or Tensor) – The asymptotic value of the ramp towards \(t \to +\infty\), \(a_+\). It must either be a scalar or contain a single element.

  • start_value (float or complex or Tensor, optional) – The asymptotic value of the ramp towards \(t \to -\infty\), \(a_-\). If passed, it must either be a scalar or contain a single element. Defaults to minus end_value.

Returns:

The sampleable hyperbolic tangent ramp.

Return type:

Stf

See also

signals.linear_ramp_stf()

Create an Stf representing a linear ramp.

signals.tanh_ramp()

Function to create a Signal object representing a hyperbolic tangent ramp.

signals.tanh_ramp_pwc()

Corresponding operation with Pwc output.

tanh()

Calculate the element-wise hyperbolic tangent of an object.

Notes

The hyperbolic tangent ramp is defined as

\[\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_\pm\) are defined by:

\[a_\pm := \lim_{t\to\pm\infty} \mathop{\mathrm{Tanh}}(t) ,\]

and \(t_0\) is related to \(t_\mathrm{ramp}\) by:

\[\left.\frac{{\rm d}\mathop{\mathrm{Tanh}}(t)}{{\rm d}t}\right|_{t=t_0} = \frac{ (a_+ - a_-)}{2 t_\mathrm{ramp}} .\]

With the default value of start_value (\(a_-\)), the ramp expression simplifies to

\[\mathop{\mathrm{Tanh}}(t) = A \tanh\left( \frac{t - t_0}{t_\mathrm{ramp}} \right) ,\]

where \(A = a_+\) is the end value (the start value is then \(-A\)).

Examples

Define a simple sampleable hyperbolic tangent ramp.

>>> tanh = graph.signals.tanh_ramp_stf(
...     center_time=0.4, ramp_duration=0.2, end_value=2, start_value=-1
... )
>>> tanh
<Stf: operation_name="add", value_shape=(), batch_shape=()>
>>> graph.sample_stf(stf=tanh, sample_times=np.linspace(0, 1, 7), name="tanh_samples")
<Tensor: name="tanh_samples", operation_name="sample_stf", shape=(7,)>
>>> graph.discretize_stf(tanh, duration=1, segment_count=100, name="discretized_tanh")
<Pwc: name="discretized_tanh", operation_name="discretize_stf", value_shape=(), batch_shape=()>
>>> result = qctrl.functions.calculate_graph(
...     graph=graph, output_node_names=["tanh_samples", "discretized_tanh"]
... )
>>> result.output["tanh_samples"]["value"]
array([-0.946, -0.735,  0.018,  1.193,  1.805,  1.961,  1.993])

Define a hyperbolic tangent ramp with optimizable parameters.

>>> center_time = graph.optimization_variable(
...     count=1, lower_bound=0.25e-6, upper_bound=0.75e-6, name="center_time"
... )
>>> ramp_duration = graph.optimization_variable(
...     count=1, lower_bound=0.1e-6, upper_bound=0.3e-6, name="ramp_duration"
... )
>>> end_value = graph.optimization_variable(
...     count=1, lower_bound=0, upper_bound=3e6, name="end_value"
... )
>>> graph.signals.tanh_ramp_stf(
...     center_time=center_time, ramp_duration=ramp_duration, end_value=end_value
... )
 <Stf: operation_name="add", value_shape=(), batch_shape=()>