Poincaré sections - cchandre/HamLorenz GitHub Wiki
compute_ps
(function)
Usage
hl = HamLorenz(6)
result = hl.compute_ps(x, tf, ps=lambda y: y[5] - a1, dir=-1)
Description
This function computes Poincaré sections in parallel for a set of initial conditions x
. Each trajectory is integrated over a time interval [0, tf]
, and intersections with a user-defined surface of section ps
are recorded.
Parameters
x
: list or array of initial conditions, generated bygenerate_initial_conditions
tf
: final time for integration.ps
: function defining the Poincaré section; must take a state vectory
and return a scalar.dir
: (optional) direction of crossing; default is+1
.method
: (optional) integration method forsolve_ivp
(default:'RK45'
).tol
: (optional) tolerance for the ODE solver.step
: (optional) maximum step size.
Returns
result
: list of solutions for each initial condition, where each solution corresponds to the set of Poincaré section crossings.
plot_ps
(function)
Usage
hl.plot_ps(result, indices=(0, 1, 2))
Description
This function visualizes the Poincaré section data obtained from compute_ps
. It can generate either a 2D or 3D scatter plot depending on the number of indices provided.
Parameters
result
: list of arrays, each array containing Poincaré section points.indices
: list of 2 or 3 integers indicating which variables to plot.
Behavior
- If
indices
has length 2: produces a 2D plot. - If
indices
has length 3: produces a 3D plot. - Raises a
ValueError
ifindices
is not of length 2 or 3.
Output
- A Matplotlib plot window showing the Poincaré section.