Addendum: Shooting method#
As a reference to compare/check against the HBM methods which are the focus of the toolbox, the shooting method is also implemented as a subclass of AbstractCycleEquation. Similarly as with the HBMEquation and the HBMSystem, there also exists a corresponding ShootingSystem class which may have a ShootingPhaseAnchor.
- class skhippr.cycles.shooting.ShootingBVP(ode: Callable[[float, ndarray], tuple[ndarray, dict[str, ndarray]]], T: float, period_k: int = 1, **kwargs_odesolver)#
ShootingBVP implements the shooting method to solve the boundary value problem for finding periodic solutions of nonautonomous ODEs.
The residual is determined by integrating the initial value problem over a period from
self.ode.ttoself.ode.t+self.Tusingscipy.integrate.solve_ivpand comparing the state at start and end time.- residual_function() ndarray#
Computes the residual function
r = x(T) - x(0)of the shooting problem.
- closed_form_derivative(variable) ndarray#
Returns the closed-form derivative of the residual function with respect to the specified variable.
If the variable is “x”, it returns
Phi_T - np.eye(ode.n_dof), wherePhi_Tis the monodromy matrix.If the variable is “T” and the system is autonomous, it returns the dynamics evaluated at the final time.
Otherwise, it raises a NotImplementedError to enforce the use of finite differences.
- stability_criterion(eigenvalues)#
Checks if all Floquet multipliers lie inside the unit circle. The Floquet multipliers are computed as the eigenvalues of the monodromy matrix
Phi_T, i.e., the eigenvalues of the derivative w.r.t.`xplus one.
- x_time(t_eval=None)#
Computes the state trajectory over time by integrating the system dynamics using
scipy.integrate.solve_ivp.- Parameters:
t_eval (array_like or None, optional) – Time points at which to store the computed solution. If None, a default linspace from 0 to
self.Twith 150 points is used.- Returns:
(
n_dof,L) 2-D array containing the state trajectory evaluated at the specified time points.- Return type:
np.ndarray
- integrate_with_fundamental_matrix(x_0: ndarray = None, t: float = None) tuple[float, ndarray, ndarray]#
Integrates the system dynamics along with its fundamental matrix.
This method solves the initial value problem for the system’s state and its associated fundamental matrix over a given time interval.
- Parameters:
x0 (np.ndarray) – Initial state vector of the system.
t (float) – Final time up to which the integration is performed.
- Returns:
sol.t (np.ndarray) – Array of time points at which the solution was evaluated.
x (np.ndarray) – Array containing the state trajectory of the system at the time points. Shape is (
n_dof,L).fundamental_matrix (np.ndarray) – Array containing the fundamental matrix at each time point. Shape is (
n_dof,n_dof,L).
Notes
The method integrates both the state and the fundamental matrix by augmenting the state vector with the flattened fundamental matrix and integrating both simultaneously.
- class skhippr.cycles.shooting.ShootingSystem(ode: Callable[[float, ndarray], tuple[ndarray, dict[str, ndarray]]], T: float, period_k: int = 1, **kwargs_odesolver)#
This subclass of
EquationSysteminstantiates aShootingBVPand considers it as the first equation. The state vectorxis the first unknown. If the underlying ODE is autonomous, the periodTof the periodic solution is not known in advance and is appended to the unknowns. Correspondingly, aShootingPhaseAnchorequation is appended to the equations.
- class skhippr.cycles.shooting.ShootingPhaseAnchor(ode, x)#
This class implements an anchor equation for the shooting method in autonomous systems. EachNewton update must be orthogonal to the flow at x_0.
- residual_function()#
Always returns zero.
- closed_form_derivative(variable)#
Return the anchor (flow at
(self.t, self.x)) as derivative w.r.txand zero otherwise.