tmdsimpy.jax.harmonic_utils.time_series_deriv¶
- tmdsimpy.jax.harmonic_utils.time_series_deriv(Nt, htuple, X0, order)¶
Returns derivative of a time series defined by a set of harmonics
- Parameters:
- Ntint, power of 2
Number of times considered, must be even. Must be greater than 2*np.array(h).max().
- htuple(H,) tuple of sorted int
Harmonics considered, 0th harmonic must be first if included.
- X0(Nhc, N) numpy.ndarray
Harmonic Coefficients for columns corresponding to degrees of freedom and rows corresponding to different harmonic components.
- orderint
Order of the derivative returned. 0 is generally displacement, 1 is velocity, 2 is acceleration.
- Returns:
- x_t(Nt, N) numpy.ndarray
Time series of each DOF. Rows are time instants and columns are DOFs.
See also
tmdsimpy.utils.harmonic.time_series_derivImplementation of this function without JAX.
Notes
For JAX/JIT calls to this function, the top level function will likely need to have htuple and Nt set to static.
The number of harmonic components is Nhc = tmdsimpy.utils.harmonic.Nhc(h)
The normalized time instants between [0,1) for a cycle can be calculated as tau = numpy.linspace(0,1,Nt+1)[:-1].
If you have h as a numpy.ndarray of harmonic components, you can use htuple = tuple(h). The tuple is used here to allow for static arguments in JAX compilation.
The following notes are speculation about JIT compilation about this function. Unit tests ensure that this function gives appropriate results.
This function cannot be compiled with partial for the current implementation. Rather this function gets different compiled versions for the top level function being compiled when AFT uses both displacement and velocity.
If this function was compiled with partial, it would be forced to recompile every time that order changed. This could cause excessive recompilation.
If the top level function gets compiled, it appears that two versions of this are created or this code is inlined into the top level function. This could be verified by profiling the final code to ensure that there are not lots of recompiles during evaluations.