This toolbox offers an implementation of the Generalised Harmonic Balance method in MATLAB, supporting up to 2 base frequencies. This library can find periodic and quasi-periodic solutions of non-linear ODEs expressed in the following general form:
with an output given by:
This toolbox has been developed to solve problems in structural dynamics, so much of the notation and terminology used stems from this field. However, it could equally be applied to problems in a variety of other disciplines.
The input is assumed to be of the following multi-harmonic form:
where the variable
The output is assumed to contain content at the same frequencies, so can be expressed as:
This toolbox supports both Standard HBM with a single base frequency
Analytical jacbobians have been implemented throughout to speed up the execution.
The problem structure defines the system being simulated. This must have the following fields for the linear parts of the system:
- The mass, stiffness and damping matrices
K,C,M - The constant term
F0(which defaults tozeros) - The matrices for the excitation
Ku,Cu,Mu
The number of DOF and inputs is inferred from the dimensions of the matrices.
The non-linear parts must be specified via the model callback which must have the form:
function varargout = test_model(part,States,hbm,problem)
switch part
case 'nl'
%f_nl
case 'output'
%y
...
end
endwhere part can be one of:
-
nlwhich means this function should return$f_{nl}$ -
nl_x,nl_xdot,nl_xddotwhich means this function should return$\frac{\partial f_{nl}}{\partial x}$ etc -
nl_u,nl_udot,nl_uddotwhich means this function should return$\frac{\partial f_{nl}}{\partial u}$ etc -
outputwhich means this function should return the output$y$
The excitation must be specified via the excite callback which must has the form:
function U = test_excite(hbm, problem, w0)
...
endand returns the
You can also store other useful information in the problem structure which is needed by your model (eg model parameters).
For resonance problems (using hbm_res or hbm_bb), it is necessary to configure the term to be maximised. This can be of the following form:
The res structure should have the following fields to set the numerator and denominator:
iHarmwhich sets harmonic to use the terms fromoutputwhich can be eitherx(or its derivatives),fnl, ornone(to have no output).inputwhich can be eitheru(or its derivatives),feorunity(to have no denominator).NInputwhich selects which DOF fromxto useNOutputwhich selects which index fromfeto use
The other key structure needed to solve problems is the hbm structure, which stores information about the harmonics and other options. This has the following fields:
-
harmcontains information about harmonics -
dependencecontains information about the form of$f_{nl}$ -
contcontains settings for the continuation algorithm -
optionscontains settings for the continuation algorithm
This must have the following fields:
-
rFreqRatiois the ratio of the base harmonics to the base frequency. ie$\lambda$ . For HBM standard problemsrFreqRatioshould be set to 1.0. For GHBM problems this should be vector. -
NHarmis the number of harmonics to include for each base frequency. This should have the same length asrFreqRatio. -
Nfftis the number of FFT points to use for the AFT transformation. This should be set to a power of 2 and have the same length asrFreqRatio. -
iHarmPlotsets which harmonic to plot on the FRF when usinghbm_frforhbm_bb. Typically you want to see the first harmonic so this should be set to 1.
This should have the following fields:
x,xdot,xddotif the non-linearity has a dependence on the state and its derivativesu,udot,uddotif the non-linearity has an explicit dependence on the state and its derivativeswif the non-linearity has an explicit frequency dependence
The value should be set to 1.0 or True where there is a dependence, and 0.0 or False otherwise
This is used to configure settings of the continuation algorithm. This should have the following fields:
method: this should be one of the following values:predcorrfor a predictor-corrector algorithm (default)noneto simply step in frequency forhbm_frfor amplitude forhbm_ampandhbm_bbIf method ispredcorr, you can set the following additional settings in thecont.predcorrstructure:
solverto choose which non-linear solver to use (fipoptto use IPOPT orfsolveto use the inbuilt solver)step0which sets the initial step sizemin_step/max_stepwhich sets the minimum and maximum step sizenum_iter_increase/num_iter_reducewhich sets the threshold for increasing/decreasing the step size depending on the number of iterationsCandcwhich sets the ratio to increase/decrease stepsize after a successful/unsuccessful step
This sets other more general options and can have the following fields:
bUseStandardHBM: force the solver to use the standard HBM when there is a single base frequency.bVerbose: toggle whether to suppress output to consolebPlot: toggle whether to suppress plots
Once problem and hbm have been defined, you must call the setup code:
[hbm,problem] = setuphbm(hbm,problem);You can then call one of the following functions to solve a problem using HBM.
The most simple case is to find a periodic solution for a given excitation. Two different functions are provided to solve such problems, depending on the asumptions made about the base frequency:
-
hbm_solve: this assumes the base frequency$\Omega$ is fixed to a known value. This is the simplest and most common case. This can be called as follows:wheresol = hbm_solve(hbm,problem,w0,A);
solcontains information about the solution including the components of$x$ ,$f_{nl}$ and$u$ at each harmonic -
hbm_res: this assumes that the base frequency$\Omega$ can vary in order to find the maximum response at resonance. This is configured by theproblem.resfield:sol = hbm_res(hbm,problem,w0,A,X0);
If you do not have initial guess for X0, then this can be omitted or set to [].
Each of the different types of one-off problem can then be solved over a range of frequencies. If the base frequency is assumed fixed, there are two potential continuation parameters:
-
hbm_frf: The base frequency$\Omega$ is used as the the continuation parameter, keeping the amplitude$A$ fixed. This yields a non-linear frequency response.sol = hbm_frf(hbm,problem,A,w0,X0,wEnd,XEnd);
-
hbm_amp: The base frequency$\Omega$ is kept fixed, and the amplitude$A$ is used as the the continuation parameter.sol = hbm_frf(hbm,problem,A,w0,X0,wEnd,XEnd);
If the base frequency is allowed to vary, and chosen to satisfy an objective, then there is only one potential continuation parameter:
-
hbm_bb: The excitation amplitude$A$ is the continuation parameter, and the base frequency$\Omega$ is chosen to satisfy the objective. This yields the "backbone" curve.sol = hbm_bb(bb,problem,A0,w0,X0,Aend,wEnd,XEnd);
If you not have an intial guess for X0 or XEnd, then this can be set to [] for any of these functions.