API
InvariantManifolds.BilliardVInvariantManifolds.FlawPointInvariantManifolds.NSOneDManifoldInvariantManifolds.NSOneDManifoldProblemInvariantManifolds.NSSetUpInvariantManifolds.NSSolutionInvariantManifolds.NSStateInvariantManifolds.NSVTwoDManifoldInvariantManifolds.NSVTwoDManifoldProblemInvariantManifolds.ODESolverInvariantManifolds.OneDManifoldInvariantManifolds.OneDManifoldProblemInvariantManifolds.PiecewiseImpactVInvariantManifolds.PiecewiseVInvariantManifolds.SaddleInvariantManifolds.TwoDManifoldInvariantManifolds.TwoDManifoldProblemInvariantManifolds.VTwoDManifoldInvariantManifolds.VTwoDManifoldProblemInvariantManifolds.addcircles!InvariantManifolds.addpoints!InvariantManifolds.findsaddleInvariantManifolds.gen_diskInvariantManifolds.gen_segmentInvariantManifolds.grow!InvariantManifolds.growmanifoldInvariantManifolds.initializeInvariantManifolds.iscontactInvariantManifolds.kd_distenceInvariantManifolds.ns_addpoints!InvariantManifolds.ns_solverInvariantManifolds.setmap
InvariantManifolds.BilliardV — TypeBilliardVA callable struct to represent a vector field with multiple hyper surfaces such that the flow jump when hits these hyper surfaces.
Fields
fis the vector field, of typef(x,p,t), and its output is a SVector;hypersis tuple of hyper surfaces:(h1,h2,...),h1(x,p,t);rulesis tuple of rules on hyper surfaces:(r1,r2,r3,...).
InvariantManifolds.FlawPoint — TypeFlawPoint{N,T}FlawPoint is a struct to record the points that don't satisfy the angle and distance request while the program has reached the minimum arc length.
Fields
pointflaw point in the process of continuation;αthe angle recorded;dthe distance recorded.
InvariantManifolds.NSOneDManifold — TypeNSOneDManifold{F,S,N,T}NSOneDManifold is a struct contains all the information of the non-smooth one-dimensional numerical manifold.
Fields
probthe problemNSOneDManifoldProblem;datathe numerical data that should beVector{Vector{Vector{S}}}, whereSis the interpolation curve (we useDataInterpolationin this package);flawpointsthe flaw points generated during continuation.
InvariantManifolds.NSOneDManifoldProblem — TypeNSOneDManifoldProblem{F,T}NSOneDManifoldProblem is a struct to contain the main information for continuing the non-smooth one-dimensional manifold of the time-T-map of a non-smooth ODE.
Fields
fthe structNSSetUp;parathe parameters of the nonlinear map;amaxthe maximum angle between points when continuing the manifold;dthe maximum distance between points when continuing the manifold;ϵthe max value of the following expression: $\max\{|H(x_0,T)|,H(x_1,T)\},$ where $H(x,t)$ is the hypersurface the manifold cross, $x_0$ and $x_1$ are points before and after the cross, $T$ is the end of the time-$T$-map (from 0 to $T$).dsminthe minimum arc length allowing; note that if in a continuation point, this value is achieved and the angle as well as the distance values are not achieved, then we will record this point as aFlawPoint.
Convenient consturctors are NSOneDManifoldProblem(f) and NSOneDManifoldProblem(f,para)
InvariantManifolds.NSSetUp — TypeNSSetUp{T}NSSetUp is a struct to contain all the information needed in continuing the manifold of non-smooth ODE.
Fields
fthe Non-smooth vector field, likePiecewiseV;timespanthe time span of time-T-map;timetmapthe time-t-map of non-smooth ODE, which maps aNSStateand parameters of ODE to aNSState.
InvariantManifolds.NSSolution — TypeNSSolution{N,T<:Number}The NSSolution is a struct to contain all information of the solution of a non-smooth ODE system.
Fields
solODESolutionsolved byOrdinaryDiffEq;event_tthe times when events happen;event_statethe solution's state when events happen;event_atis a vector that contains integers indicating which event happen.
InvariantManifolds.NSState — TypeNSState{N,T<:Number} <: AbstractVector{T}The struct NSState is to record the events data for a time-T-map.
Fields
statethe final state of the time-T-map;event_atis a integer vector that contains the history of the events happened.
The construction of NSState allows to interpolate vectors consisting of NSState. Currently, LinearInterpolation, CubicSpline, and QuadraticInterpolation in DataInterpolations.jl are supported.
InvariantManifolds.NSVTwoDManifold — TypeNSVTwoDManifold{F,S,N,T}NSVTwoDManifold is a struct contains all the information of the non-smooth two-dimensional numerical manifold of an autonomous vector field.
Fields
probthe problemNSVTwoDManifoldProblem;datathe numerical data that should beVector{Vector{S}}, whereSis the interpolation curve (we useDataInterpolationin this package);flawpointsthe flaw points generated during continuation.
InvariantManifolds.NSVTwoDManifoldProblem — TypeNSVTwoDManifoldProblem{F,T}NSVTwoDManifoldProblemVTwoDManifoldProblem is a struct to contain the main information for continuing the two-dimensional manifold of an autonomous vector field.
Fields
ftheNSSetUpof a nonsmooth vector field;parathe parameters of the time flow map;amaxthe maximum angle between points when continuing the manifold;dthe maximum distance between points when continuing the manifold;ϵthe max value of the following expression: $\max\{|H(x_0,T)|,H(x_1,T)\},$ where $H(x,t)$ is the hypersurface of the manifold cross, $x_0$ and $x_1$ are points before and after the cross, $T$ is the end of the time-$T$-map (from 0 to $T$).dsminthe minimum arc length allowing; note that if in a continuation point, this value is achieved and the angle as well as the distance values are not achieved, then we will record this point as aFlawPoint.
Convenient consturctors are NSVTwoDManifoldProblem(f) and NSVTwoDManifoldProblem(f,para)
InvariantManifolds.ODESolver — TypeODESolver{F1,F2,T}A wrapper struct for solving ordinary differential equations (ODEs).
Fields
f: Vector field function of the ODE system in the formf(x,p,t)timespan: Time interval for solving the ODE, of typeTuple{T,T}alg: The numerical algorithm used for solving the ODEabstol: Absolute tolerance for the numerical solver
InvariantManifolds.OneDManifold — TypeOneDManifold{F,S,N,T}OneDManifold is a struct contains all the information of the one-dimensional numerical manifold.
Fields
probthe problemOneDManifoldProblem;datathe numerical data that should beVector{Vector{S}}, whereSis the interpolation curve (we useDataInterpolationin this package);flawpointsthe flaw points generated during continuation.
InvariantManifolds.OneDManifoldProblem — TypeOneDManifoldProblem{F,T}OneDManifoldProblem is a struct to contain the main information for continuing the one-dimensional manifold of a nonlinear map.
Fields
fthe nonlinear map, which should has the formf(x,p)and return aSVector;parathe parameters of the nonlinear map;amaxthe maximum angle between points when continuing the manifold;dthe maximum distance between points when continuing the manifold;dsminthe minimum arc length allowing; note that if in a continuation point, this value is achieved and the angle as well as the distance values are not achieved, then we will record this point as aFlawPoint.
Convenient consturctors are OneDManifoldProblem(f) and OneDManifoldProblem(f,para)
InvariantManifolds.PiecewiseImpactV — TypePiecewiseImpactVA callable struct to represent a vector field with both piecewise non-smoothness and impacts.
fsis a tuple of smooth vector fields in different regions.regionsis a tuple of the region functions:(r1,r2,...), wherer1(x,p,t)should return a Bool value to indicate thatxis in this region or not.hypersis a tuple of the hyper surfaces separating the regions.rulesis a tuple of rules on hyper surfaces:(r1,r2,r3,...). Note that for hypersurfaces that only switch between two vector fields, we can setr1=id.idxsis a vector of integer to indicate hypersurfaces with impact effects.nis a integer to switch between vector fields. Default to be zero.
InvariantManifolds.PiecewiseV — TypePiecewiseVA callable struct to represent a piecewise smooth vector field.
Fields
fsis a tuple of smooth vector fields in different regions.regionsis a tuple of the region functions:(r1,r2,...), wherer1(x,p,t)should return a Bool value to indicate thatxis in this region or not.hypersis a tuple of the hyper surfaces separating the regions.nis a integer to switch between vector fields. Default to be zero.
Example
using StaticArrays, InvariantManifolds
f1(x,p,t)=SA[x[2],-2x[1]]
f2(x,p,t)=SA[x[2],-x[1]]
dom1(x,p,t)=x[1]>0
dom2(x,p,t)=x[2]<0
hyper(x,p,t)=x[1]
PiecewiseV((f1,f2),(dom1,dom2),(hyper,))The above codes generate a piecewise smooth vector field, which when x[1]>0 is f1, and when x[2]<0 is f2. The hyper surface separating these smooth vector fields is x[1]=0.
InvariantManifolds.Saddle — TypeSaddle{N,T,S}Saddle is a struct to contain the information of a saddle point needed in continuing the manifold of non-smooth ODE. For an ODE's saddle, this struct can be constructed by the function findsaddle.
Fields
saddlethe location of the saddle point;unstable_directionsthe unstable directions;unstable_eigen_valueseigenvalues of the linearized map in the saddle at the unstable eigenvectors.
InvariantManifolds.TwoDManifold — TypeTwoDManifold{F,S,N,T}TwoDManifold is a struct contains all the information of the two-dimensional numerical manifold of a nonlinear map.
Fields
probthe problemTwoDManifoldProblem;datathe numerical data that should beVector{S}, whereSis the interpolation curve (we useDataInterpolationin this package);flawpointsthe flaw points generated during continuation.
InvariantManifolds.TwoDManifoldProblem — TypeTwoDManifoldProblem{F,T}TwoDManifoldProblem is a struct to contain the main information for continuing the two-dimensional manifold of a nonlinear map.
Fields
fthe nonlinear map, which should has the formf(x,p)and return aSVector;parathe parameters of the nonlinear map;amaxthe maximum angle between points when continuing the manifold;dthe maximum distance between points when continuing the manifold;dcirclethe maximum distance between circles when continuing the manifold;dsminthe minimum arc length allowing; note that if in a continuation point, this value is achieved and the angle as well as the distance values are not achieved, then we will record this point as aFlawPoint.
Convenient consturctors are TwoDManifoldProblem(f) and TwoDManifoldProblem(f,para)
InvariantManifolds.VTwoDManifold — TypeVTwoDManifold{F,S,N,T}VTwoDManifold is a struct contains all the information of the two-dimensional numerical manifold of an autonomous vector field.
Fields
probthe problemVTwoDManifoldProblem;datathe numerical data that should beVector{S}, whereSis the interpolation curve (we useDataInterpolationin this package);flawpointsthe flaw points generated during continuation.
InvariantManifolds.VTwoDManifoldProblem — TypeVTwoDManifoldProblem{F,T}VTwoDManifoldProblem is a struct to contain the main information for continuing the two-dimensional manifold of an autonomous vector field.
Fields
fthe time flow map of the vector field, which should has the formf(x,p)and return aSVector; note that the vector field should be regularized, e.g., $\dot{x}=v(x)$ should be rewritten as $\dot{x}=v(x)/\sqrt{1+|v(x)|}$;parathe parameters of the time flow map;amaxthe maximum angle between points when continuing the manifold;dthe maximum distance between points when continuing the manifold;dsminthe minimum arc length allowing; note that if in a continuation point, this value is achieved and the angle as well as the distance values are not achieved, then we will record this point as aFlawPoint.
Convenient consturctors are VTwoDManifoldProblem(f) and VTwoDManifoldProblem(f,para)
InvariantManifolds.addcircles! — MethodInvariantManifolds.addcircles!(f, para, d, circles, dsmin, αmax, dcircle, flawpoints; interp=LinearInterpolation)Adds and refines circles in the two-dimensional manifold computation by iterating the map and ensuring proper point distribution.
Arguments
f: The nonlinear map functionpara: Vector of parameters for the mapd: Maximum allowed distance between points in a circlecircles: Vector of interpolated curves representing the current circlesdsmin: Minimum allowed arc length between pointsαmax: Maximum allowed angle between consecutive pointsdcircle: Maximum allowed distance between consecutive circlesflawpoints: Vector to store problematic points during computationinterp: Interpolation method (default: QuadraticInterpolation)
Returns
A vector of new interpolated curves representing the refined circles after one iteration of the map.
Details
The function performs two main steps:
- Iterates each circle forward under the map and refines point distribution within each circle
- Adds intermediate circles where the distance between consecutive circles exceeds
dcircle
Points are added to maintain proper spacing and curvature constraints specified by d and αmax.
InvariantManifolds.addpoints! — MethodInvariantManifolds.addpoints!(f, p, d, oldcurve, newu, olds, dsmin, αmax, flawpoints)Add points to ensure proper spacing and curvature along a one-dimensional manifold curve.
Arguments
f: The nonlinear map functionp: Parameters for the nonlinear mapd: Maximum allowed distance between consecutive pointsoldcurve: Previous curve interpolationnewu::Vector{SVector{N,T}}: New points to be processedolds::Vector{T}: Parameter values of the pointsdsmin: Minimum allowed arc length between pointsαmax: Maximum allowed angle between consecutive segmentsflawpoints: Vector to store problematic points that don't meet criteria
Details
The function iteratively processes points, adding new ones when:
- The distance between consecutive points exceeds
d - The angle between consecutive segments exceeds
αmax - The arc length is greater than
dsmin
If a point fails these criteria and the minimum arc length is reached, it's recorded as a flaw point.
Returns
Vector of parameter values for the new points
InvariantManifolds.findsaddle — Methodfindsaddle(v, dv, timespan, x, p)findsaddle is a function to find the saddle of the time-T-map of smooth ODE systems, by using the Newton's method.
Parameters
vthe vector field, which should be the formf(x,p,t)and return aSVector;dvthe Jacobi matrix function ofv, which should should be the formdv(x,p,t)and return aSMatrix;timespanthe time span of the time-T-map;xthe initial point to iterate.
Keyword arguments
nmaximum iterate times, default to be 100;abstolabsolute tolerance for the fixed point, default to be1e-8;algthe algorithm used to solve the ODE, default to beVern9().
We also provide the finite difference method to find the saddle of the time-T-map of nonsmooth ODE systems:
Parameters
setuptheNSSetUpof the nonsmooth ODE system;xthe initial point to iterate, of typeSVector{N,T}.pthe parameters of the nonsmooth ODE system.
Keyword arguments
nmaximum iterate times, default to be 100;abstolabsolute tolerance for the fixed point, default to be1e-8;
InvariantManifolds.gen_disk — Methodgen_disk(p, times)gen_disk is a function to generate circles around the saddle, which represented as the local manifold.
Parameters
pthe structSaddlewhich should contains two unstable directions; the complex eigenvalues and eigenvectors are allowed.
Keyword arguments
timesthe iteration time, default to be1; for the computation of invariant manifolds of nonlinear map, this parameter is needed to adjust the torsion in different directions in the process of continuation.nthe number of point in each circle, default to be150;dthe max distance between points in a single circle, default to be0.0002;rthe size of the disk, default to be0.05;circlesthe number of the circles, default to be10.
InvariantManifolds.gen_segment — Methodgen_segment(saddle, direction)Generating n points at saddle in the direction, with length d, with default n=50 and d=0.01. Another Convenient consturctor is gen_segment(p::Saddle).
InvariantManifolds.grow! — Methodgrow!(manifold)One time iteration to grow the manifold.
Parameters
manifoldthe manifold struct.
Keyword argument
interpthe interpolation method used, default to beQuadraticInterpolation.
InvariantManifolds.growmanifold — Methodgrowmanifold(prob, points, N)This is the mani function to continuate the numerical manifolds. Its output is a manifold struct.
Parameters
probthe problem such asOneDManifoldProblem.pointsthe points in the local manifold. For one dimensional manifolds, these points should be aVector{SVector}and the start point should be the saddle. For two dimensional manifolds, these points should be aVector{Vector{S}}and its first element should like[saddle, saddle, saddle]. Note that in the both cases, the functionsgen_segmentandgen_diskcan generate these points easily.Nthe number of iterations.
Keyword argument
interpthe interpolation method used, default to beQuadraticInterpolation.
InvariantManifolds.initialize — Methodinitialize(prob, points)This is a function to initialize the continuation process. Its output is a manifold struct.
Parameters
probthe problem such asOneDManifoldProblem.pointsthe points in the local manifold. For one dimensional manifolds, these points should be aVector{SVector}and the start point should be the saddle. For two dimensional manifolds, these points should be aVector{Vector{S}}and its first element should like[saddle, saddle, saddle]. Note that in the both cases, the functionsgen_segmentandgen_diskcan generate these points easily.
Keyword argument
interpthe interpolation method used, default to beQuadraticInterpolation.
InvariantManifolds.iscontact — Methodiscontact(setup, saddle, para)Check if the saddle point of the time-T-map has contacts with the hypersurfaces.
Parameters
Returns
trueif the saddle point has contact with the hypersurfaces.falseif the saddle point has no contact with the hypersurfaces.
InvariantManifolds.kd_distence — MethodInvariantManifolds.kd_distenceThe function to measure the distance between two circles by using the package NearestNeighbors.jl.
InvariantManifolds.ns_addpoints! — MethodInvariantManifolds.ns_addpoints!(tmap, p, d, dsmin, oldcurve, newu, olds, αmax, tend, hypers, ϵ, flawpoints) -> Vector{T}Add points to ensure proper spacing and accuracy when computing the non-smooth one-dimensional manifold.
Arguments
tmap: Time map function that evolves states forwardp: Vector of parametersd: Maximum allowed distance between consecutive pointsdsmin: Minimum allowed arc length between pointsoldcurve: Previous curve data used for interpolationnewu: Vector of new states to be processedolds: Vector of arc length parametersαmax: Maximum allowed angle between consecutive segmentstend: End time of the time maphypers: Vector of hypersurface functionsϵ: Maximum allowed error in hypersurface intersectionflawpoints: Vector to store problematic points encountered
Returns
- Vector of arc length parameters for the processed points
Details
The function adaptively adds points to maintain:
- Maximum distance
dbetween consecutive points - Maximum angle
αmaxbetween segments - Accuracy
ϵat hypersurface intersections
If constraints cannot be satisfied within dsmin, points are marked as flaws.
InvariantManifolds.ns_solver — Methodns_solver(v::T, para, timespan, alg, N, T)The function ns_solver is similar to timetmap. The output of this function is a function which maps a SVector to a NSSolution. This NSSolution contain all data of an non-smooth ODE solution.
Parameters
vvector fields likePiecewiseVorBilliardV.parathe parameter of the vector field.timespanthe time span of the time-T-map.algalgorithm inOrdinaryDiffEqto solve ODE.Nthe dimension of the vector field.Tnumber type used in computation.
To ensure type stable, the numbers in para and timespan should be type of T. The last two parameters have to be specified, since we need to store the event data.
Keyword arguments
repeat_nudge=1//100this is used to set the next testing point after a previously found zero.
For vector fields PiecewiseV and PiecewiseImpactV, we have two special keyword arguments:
cross_time= 0.01when the solutionsolhits the hypersurface at timet, we need to know which domain it enters. We choose the statesol(t+cross_time)to determine which domain it enters.region_detect=_region_detectthe region detect function to determine which domain the state in.
You can also pass the keywords of solve of OrdinaryDiffEq to this function, except the callback and saving related keywords.
InvariantManifolds.setmap — Methodsetmap(v, timespan::Tuple{T,T}, alg) where {T}The function setmap is to get a NSSetUp.
Parameters
va nonsmooth vector field likePiecewiseVorBilliardV.timespanthe time span of the time-T-map.algalgorithm inOrdinaryDiffEqto solve ODE.
To ensure type stable, the numbers in timespan should be type of T.
Keyword arguments
repeat_nudge=1//100this is used to set the next testing point after a previously found zero.
For vector fields PiecewiseV and PiecewiseImpactV, we have two special keyword arguments:
cross_time= 0.01when the solutionsolhits the hypersurface at timet, we need to know which domain it enters. We choose the statesol(t+cross_time)to determine which domain it enters.region_detect=_region_detectthe region detect function to determine which domain the state in.
You can also pass the keywords of solve of OrdinaryDiffEq to this function, except the callback and saving related keywords.