A harmonic oscillator driven by a trapezoidal forcing ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Let us again consider a nondimensional harmonic oscillator, but now with a custom driving function, which resembles a trapezoidal pulse. This custom pulse function can be implemented in pyoomph via the :py:class:`~pyoomph.expressions.cb.CustomMathExpression` class from the :py:mod:`pyoomph.expressions.cb` as follows: .. code:: python from pyoomph.expressions.cb import * # Import custom math callback expressions class TrapezoidalFunction(CustomMathExpression): def __init__(self,*,wait_time=5, flank_time=0.25,high_time=10,amplitude=1): super(TrapezoidalFunction, self).__init__() self.wait_time=wait_time # Pass some parameters to the function already in the constructor self.flank_time=flank_time self.high_time=high_time self.amplitude=amplitude # This method will be called whenever the function must be evaluated def eval(self,arg_array): t=arg_array[0] # Bind local t to the first passed argument if t` :download:`Download all examples <../../tutorial_example_scripts.zip>`