tmdsimpy.utils.continuation.print_hbm_amp_phase_stats¶
- tmdsimpy.utils.continuation.print_hbm_amp_phase_stats(XlamP, dirP_prev, fname, freq, amp, h, order, output_recov, output_harmonic)¶
Saves HBM amplitude and phase control key statistics to a text file for easy monitoring.
This function is intended for monitoring active runs. For final solution details, save the full solution and plot based on those results, not based on the results written out by this summary file. Function only intended to work when amplitude and phase control is applied with HBM (Harmonic Balance Method).
- Parameters:
- XlamP(N+1,) numpy.ndarray
Solution at the current step in physical coordinates (including continuation parameter) to a HBM amplitude control set of equations.
Assumes that this is harmonic displacements, then cosine scaling of force, sine scaling of force, ignored lam variable (but requires exactly 1 variable after the two force scaling values for indexing)
- dirP_prev(N+1,) numpy.ndarray
Direction for prediction from previous step to this step. Can be used to get slope of solution at previous point w.r.t. lam by dividing dirP / dirP[-1]
- fnamestr
Filename to save variables to. The output is a text file. Recommended file extension is ‘.dat’.
- freqfloat
Frequency to be printed, rad/s.
- ampamplitude
Control amplitude that should be printed.
- hnumpy.ndarray, sorted
List of harmonics included in HBM solution.
- orderint, zero or positive
Order of the derivative that is output. order=0 means displacement output, order=2 means acceleration output.
- output_recov: (Ndof,) numpy.ndarray
Recovery vector to be used to output response at a specific DOF where Ndof is the number of degrees of freedom of the system.
- output_harmonicint
Which harmonic the amplitude at the output_recov dof should be output for. Behavior is undefined if output_harmonic is not included in h.
- Returns:
- None.
See also
tmdsimpy.ContinuationClass for continuation where this function is intended to be used as a callback function.
tmdsimpy.VibrationSystem.hbm_amp_phase_control_resHBM amplitude and phase control residual function. XlamP works when it matches this unknown vector.
tmdsimpy.VibrationSystem.hbm_amp_phase_control_dA_resHBM with amplitude and phase control residual function. XlamP works when it matches this unknown vector.
combine_callback_funsFunction for combining multiple callback functions for Continuation.
continuation_saveFunction for saving the full solution points.
Notes
Ndof is the number of DOFs of the system while N is the number of unknowns for the HBM residual at a given lam value.
Frequency and amplitude of 1st harmonic are only printed from those arguments and not based on XlamP. Define your anonymous function appropriately.
The output includes (for the current solution) frequency, force scaling magnitude for sine and cosine, and the amplitude at the DOF defined by output_recov corresponding to output_harmonic and order. Other functions in this module correspond to other variants of HBM.
Examples
Define a callback function handle to pass to tmdsimpy.Continuation for continuation with respect to frequency at a constant amplitude with tmdsimpy.VibrationSystem.hbm_amp_phase_control_res
>>> import numpy as np ... ... h = np.arange(5) ... order = 2 # Acceleration ... output_recov = np.array([1, 0, 0]) ... output_harmonic = 1 ... ... control_amp = 40 # m/s^2 since order is 2. ... ... callback_fun = lambda XlamP, dirP_prev : print_hbm_amp_stats(XlamP, ... dirP_prev, 'hbm_sum.dat', XlamP[-1], control_amp, h, ... order, output_recov, output_harmonic)
Define a callback function handle to pass to tmdsimpy.Continuation for continuation with respect to frequency at a constant amplitude with tmdsimpy.VibrationSystem.hbm_amp_phase_control_dA_res
>>> import numpy as np ... ... h = np.arange(5) ... order = 2 # Acceleration ... output_recov = np.array([1, 0, 0]) ... output_harmonic = 1 ... ... constant_freq = 1 # rad/s. ... ... callback_fun = lambda XlamP, dirP_prev : print_hbm_amp_stats(XlamP, ... dirP_prev, 'hbm_sum.dat', constant_freq, XlamP[-1], ... h, order, output_recov, output_harmonic)