pyoomph.utils.lyapunov module
- class pyoomph.utils.lyapunov.LyapunovExponentCalculator(k=1, waiting_time=None, prerelaxation_time=None, use_crank_nicholson_integration=False, filename='lyapunov.txt', relative_to_output=True, store_as_eigenvectors=False, gram_schmidt_dt=None)[source]
Bases:
GenericProblemHooksA class for calculating multiple Lyapunov exponents. Add it to the problem by
problem+=LyapunovExponentCalculator(...)and it will do the rest for you. However, note that we cannot use BDF2 time derivatives in the calculation of new pertubations (B matrix). Therefore, we calculate trajectories using BFD2, but the perturbation vectors are updated using either implicit Euler (BDF1) or a Crank-Nicholson-like scheme.- Parameters:
k (
int) – The number of Lyapunov exponents to calculate. k>=2 will invoke Gram-Schmidt on the perturbation vectors. Defaults to 1.waiting_time (
Union[Expression,int,float]) – The time to wait before starting the Lyapunov calculation.prerelaxation_time (
Union[Expression,int,float]) – The time to prerelax the perturbation vectors before starting the Lyapunov calculation. This allows to bypass initial transients.use_crank_nicholson_integration (
bool) – Whether to use a Crank-Nicholson-like integration for the perturbation vectors, instead of BDF1 integration. This may improve accuracy for problems with large time steps. Defaults to False.filename – The name of the output file. Defaults to “lyapunov.txt”.
relative_to_output – Whether to save the output file relative to the problem’s output directory. Defaults to True.
store_as_eigenvectors (
bool) – Whether to store the perturbation vectors as eigenvectors. Defaults to False.
- class pyoomph.utils.lyapunov.LyapunovExponentCalculatorBDF2(average_time=None, N=1, filename='lyapunov.txt', relative_to_output=True, store_as_eigenvectors=False)[source]
Bases:
GenericProblemHooksA class for calculating Lyapunov exponents. Add it to the problem by
problem+=LyapunovExponentCalculator(...)and it will do the rest for you. It works a bit differently than the other Lyapunov exponent calculator: Here, we use the BDF2 time discretization to evolve both the state and the perturbation vectors. However, note that we only may have first order time derivatives in the equations. Second order time derivatives must be rewritten as first order time derivatives before. Also, the time derivatives in the system must use the fully implicit “BDF2” time scheme, which is the default (unless set otherwise stated by either usingscheme="..."inpartial_t()or by alteringdefault_timestepping_schemeof theProblem). Gram-Schmidt ortho*normalization* is only performed if the vectors grow too large or too small, to avoid numerical issues. Otherwise only ortho*gonalization* is performed. This is required since BDF2 has multiple time levels. Also, instead of accumulating the Lyapunov exponents over time, we use a ring buffer to store recent growths and average over a specified time interval.- Parameters:
average_time (
Union[Expression,int,float,None]) – The time interval over which to average the Lyapunov exponents. If None, we average over the entire timeN (
int) – The number of Lyapunov exponents to calculate. N>=2 will invoke Gram-Schmidt on the perturbation vectors. Defaults to 1.filename (
str) – The name of the output file. Defaults to “lyapunov.txt”.relative_to_output (
bool) – Whether to save the output file relative to the problem’s output directory. Defaults to True.store_as_eigenvectors (
bool) – Whether to store the perturbation vectors as eigenvectors. Defaults to False.