Examples#
The following examples illustrate SKHiPPR capabilities and usage. All files are runnable as Python scripts and are explained by exhaustive in-line commenting.
examples.circle#
Demonstrates the complete the pseudo-arclength continuation workflow on a nonlinear equation.
Use of the
Circleclass as a concrete subclass ofAbstractEquationfor a problem formulation.Illustrates how (one or multiple) multiple
AbstractEquationobjects are collected into anEquationSystemContinuation of a solution branch emerging from the
EquationSystemwith and without an explicit continuation parameter.
- examples.circle.main()#
Runs a demonstration of pseudo-arclength continuation for solving a nonlinear problem using Newton’s method on the circle equation. The process includes:
Instantiating a
NewtonSolverwith the solver configurationInstantiating a
Circleobject which contains the residualDemonstrating that the
NewtonSolvercan immediately solve theCirclefor the scalar unknownradius, but not for the array unknownyConstructing an
EquationSystemfor the unknownyand using thepseudo_arclength_continuator()to iterate along the solution branch.Constructing another
EquationSystemby appending a secondAbstractEquationsubclass and solving it directly fory.Using the
pseudo_arclength_continuator()to iterate along the solution branch with the extendedEquationSystemand the explicit continuation parameterthetaPlotting the results.
- Return type:
None
examples.duffing#
Demonstration / Template for creating a simple frequency response curve of a non-autonomous dynamical system with HBM.
This example uses a Duffing oscillator, but ode can be instantiated as any non-autonomous AbstractODE.
- examples.duffing.main()#
Demonstration for creating a simple frequency response curve of a non-autonomous dynamical system with HBM.
This function performs the following steps:
Creation of
Fourier,NewtonSolver, andKoopmanHillSubharmonicobjects to collect method parameters.Instantiation of a
AbstractODE(here:Duffing) object which contains the ODE.Setup of an initial guess
Setup and solution of the
HBMEquation, which formalizes the Harmonic Balance equations.Creation of an
EquationSystemcontaining only the HBM equations as input to the continuation method.Continuation of the frequency response curve using
pseudo_arclength_continuator()and collecting the branch pointsAnalyzing and plotting the branch points
- Return type:
None
examples.vanderpol_animation#
Van der Pol oscillator: continuation w.r.t. nu and animation of the resulting phase portrait.
- examples.vanderpol_animation.main()#
Demonstration of the continuation of the Van der Pol oscillator w.r.t. nu and animation of the resulting phase portrait. This function performs the following steps:
Setup of the
VanderpolODESetup of a
HBMSystemobject with theVanderpolode and aFourierobject, encoding both the HBM equations and the phase anchor.Continuation of the HBM system w.r.t. nu using the
pseudo_arclength_continuator()and aNewtonSolverAnalysis of the resulting branch of solutions, extracting time series, amplitudes, Floquet multipliers, and stability
Visualization of the results, including an animation of the phase portrait and Floquet multipliers, as well as plots of amplitude and frequency w.r.t. nu
examples.duffing_3d#
Analyze oscillations of the Duffing oscillator using SKHiPPR by performing continuation along both excitation frequency and excitation amplitude.
- examples.duffing_3d.main()#
Runs a demonstration for analyzing the Duffing oscillator with HBM, to illustrate SKHiPPR usage.
This function performs the following steps:
Parameter setup.
Creation of a
Fourierobject to collect FFT parameters.Creation of a
KoopmanHillProjectionobject which defines the stability method. Other_StabilityHBMsubclasses can interchangeably be used, such as:Setup and solution of the initial
HBMSystem.Visualization of the initial solution and its stability properties.
Continuation of the first force response curve.
Generation of frequency response curves starting from points on the previous force response.
Generation of additional force responses starting from points on the frequency response curve.
3D plotting of all computed response curves, including stability information.
numerical convergence studies#
The examples.convergence package provides two examples which illustrate the convergence properties of the Koopman-Hill stability method.
examples.convergence.demo_mathieu_N_convergence#
Demonstration of convergence of Koopman-Hill projection method for the Mathieu equation.
This script analyzes the convergence of the Koopman-Hill projection stability method applied to the MathieuODE and SmoothedMeissner equations around their equilibrium at zero.
The convergence is studied by increasing the number of harmonics (N_HBM) in the Harmonic Balance Method (HBM) and comparing the resulting monodromy matrix to a reference solution obtained via the shooting method.
- examples.convergence.demo_mathieu_N_convergence.analyze_N_mathieu(N_max=60, csv_path=None)#
Analyze the convergence of the Koopman-Hill projection method for the Mathieu equation. Optionally, results can be saved to a csv file.
- examples.convergence.demo_mathieu_N_convergence.analyze_smoothness_effects(N_max=30, csv_path=None, smoothing=None)#
Analyze and visualize the effects of the smoothing parameter on the convergence of a Hill-type system.
For
smoothing==1, theSmoothedMeissnerODE coincides with Mathieu’s equation and forsmoothing==0 with the Meissner equation. This function iterates over a range of smoothing parameter values, runs a convergence analysis for each, and plots the corresponding excitation and the convergence behavior. Optionally, results can be saved to a CSV file.- Parameters:
N_max (int, optional) – Maximum number of harmonics to consider in the convergence analysis (default is 30).
csv_path (str or None, optional) – Path to a CSV file where results will be saved. If None, results are not saved (default is None).
smoothing (array-like or None, optional) – Sequence of smoothing parameter values to analyze. If None, a default sequence from 1 to 0 is used.
examples.convergence.demo_meissner_aliasing#
This script demonstrates the effect of aliasing error on the accuracy of the Koopman-Hill projection (KHP) for the Meissner equation by varying the Discrete Fourier Transform (DFT) length. It compares the accuracy of computed Floquet multipliers for different DFT lengths and visualizes the results.
Run the script directly to generate plots and optionally save results to a CSV file. The main function analyze_N_meissner_aliasing() is called with example parameters to showcase the influence of aliasing on prediction accuracy.
The Meissner equation’s Fourier coefficients decay as
O(1/|k|), with every even coefficient being zero and odd ones alternating in sign.Aliasing errors affect the accuracy of the computed Floquet multipliers.
Knowledge about the sign of the (true) Fourier coefficients can significantly improve the results: In the case of Meissner choosing a DFT length that is divisible by 2 but not by 4