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 Circle class as a concrete subclass of AbstractEquation for a problem formulation.

  • Illustrates how (one or multiple) multiple AbstractEquation objects are collected into an EquationSystem

  • Continuation of a solution branch emerging from the EquationSystem with 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:

  1. Instantiating a NewtonSolver with the solver configuration

  2. Instantiating a Circle object which contains the residual

  3. Demonstrating that the NewtonSolver can immediately solve the Circle for the scalar unknown radius, but not for the array unknown y

  4. Constructing an EquationSystem for the unknown y and using the pseudo_arclength_continuator() to iterate along the solution branch.

  5. Constructing another EquationSystem by appending a second AbstractEquation subclass and solving it directly for y.

  6. Using the pseudo_arclength_continuator() to iterate along the solution branch with the extended EquationSystem and the explicit continuation parameter theta

  7. Plotting 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:

  1. Creation of Fourier, NewtonSolver, and KoopmanHillSubharmonic objects to collect method parameters.

  2. Instantiation of a AbstractODE (here: Duffing) object which contains the ODE.

  3. Setup of an initial guess

  4. Setup and solution of the HBMEquation, which formalizes the Harmonic Balance equations.

  5. Creation of an EquationSystem containing only the HBM equations as input to the continuation method.

  6. Continuation of the frequency response curve using pseudo_arclength_continuator() and collecting the branch points

  7. Analyzing 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:

  1. Setup of the Vanderpol ODE

  2. Setup of a HBMSystem object with the Vanderpol ode and a Fourier object, encoding both the HBM equations and the phase anchor.

  3. Continuation of the HBM system w.r.t. nu using the pseudo_arclength_continuator() and a NewtonSolver

  4. Analysis of the resulting branch of solutions, extracting time series, amplitudes, Floquet multipliers, and stability

  5. 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:

  1. Parameter setup.

  2. Creation of a Fourier object to collect FFT parameters.

  3. Creation of a KoopmanHillProjection object which defines the stability method. Other _StabilityHBM subclasses can interchangeably be used, such as:

  4. Setup and solution of the initial HBMSystem.

  5. Visualization of the initial solution and its stability properties.

  6. Continuation of the first force response curve.

  7. Generation of frequency response curves starting from points on the previous force response.

  8. Generation of additional force responses starting from points on the frequency response curve.

  9. 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, the SmoothedMeissner ODE coincides with Mathieu’s equation and for smoothing ==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