API
InvariantManifolds.BilliardV
InvariantManifolds.FlawPoint
InvariantManifolds.NSOneDManifold
InvariantManifolds.NSOneDManifoldProblem
InvariantManifolds.NSSetUp
InvariantManifolds.NSSolution
InvariantManifolds.NSState
InvariantManifolds.NSVTwoDManifold
InvariantManifolds.NSVTwoDManifoldProblem
InvariantManifolds.ODESolver
InvariantManifolds.OneDManifold
InvariantManifolds.OneDManifoldProblem
InvariantManifolds.PiecewiseImpactV
InvariantManifolds.PiecewiseV
InvariantManifolds.Saddle
InvariantManifolds.TwoDManifold
InvariantManifolds.TwoDManifoldProblem
InvariantManifolds.VTwoDManifold
InvariantManifolds.VTwoDManifoldProblem
InvariantManifolds.addcircles!
InvariantManifolds.addpoints!
InvariantManifolds.findsaddle
InvariantManifolds.gen_disk
InvariantManifolds.gen_segment
InvariantManifolds.grow!
InvariantManifolds.growmanifold
InvariantManifolds.initialize
InvariantManifolds.iscontact
InvariantManifolds.kd_distence
InvariantManifolds.ns_addpoints!
InvariantManifolds.ns_solver
InvariantManifolds.setmap
InvariantManifolds.BilliardV
— TypeBilliardV
A callable struct to represent a vector field with multiple hyper surfaces such that the flow jump when hits these hyper surfaces.
Fields
f
is the vector field, of typef(x,p,t)
, and its output is a SVector;hypers
is tuple of hyper surfaces:(h1,h2,...)
,h1(x,p,t)
;rules
is 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
point
flaw point in the process of continuation;α
the angle recorded;d
the 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
prob
the problemNSOneDManifoldProblem
;data
the numerical data that should beVector{Vector{Vector{S}}}
, whereS
is the interpolation curve (we useDataInterpolation
in this package);flawpoints
the 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
f
the structNSSetUp
;para
the parameters of the nonlinear map;amax
the maximum angle between points when continuing the manifold;d
the 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$).dsmin
the 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
f
the Non-smooth vector field, likePiecewiseV
;timespan
the time span of time-T-map;timetmap
the time-t-map of non-smooth ODE, which maps aNSState
and 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
sol
ODESolution
solved byOrdinaryDiffEq
;event_t
the times when events happen;event_state
the solution's state when events happen;event_at
is 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
state
the final state of the time-T-map;event_at
is 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
prob
the problemNSVTwoDManifoldProblem
;data
the numerical data that should beVector{Vector{S}}
, whereS
is the interpolation curve (we useDataInterpolation
in this package);flawpoints
the 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
f
theNSSetUp
of a nonsmooth vector field;para
the parameters of the time flow map;amax
the maximum angle between points when continuing the manifold;d
the 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$).dsmin
the 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
prob
the problemOneDManifoldProblem
;data
the numerical data that should beVector{Vector{S}}
, whereS
is the interpolation curve (we useDataInterpolation
in this package);flawpoints
the 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
f
the nonlinear map, which should has the formf(x,p)
and return aSVector
;para
the parameters of the nonlinear map;amax
the maximum angle between points when continuing the manifold;d
the maximum distance between points when continuing the manifold;dsmin
the 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
— TypePiecewiseImpactV
A callable struct to represent a vector field with both piecewise non-smoothness and impacts.
fs
is a tuple of smooth vector fields in different regions.regions
is a tuple of the region functions:(r1,r2,...)
, wherer1(x,p,t)
should return a Bool value to indicate thatx
is in this region or not.hypers
is a tuple of the hyper surfaces separating the regions.rules
is 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
.idxs
is a vector of integer to indicate hypersurfaces with impact effects.n
is a integer to switch between vector fields. Default to be zero.
InvariantManifolds.PiecewiseV
— TypePiecewiseV
A callable struct to represent a piecewise smooth vector field.
Fields
fs
is a tuple of smooth vector fields in different regions.regions
is a tuple of the region functions:(r1,r2,...)
, wherer1(x,p,t)
should return a Bool value to indicate thatx
is in this region or not.hypers
is a tuple of the hyper surfaces separating the regions.n
is 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
saddle
the location of the saddle point;unstable_directions
the unstable directions;unstable_eigen_values
eigenvalues 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
prob
the problemTwoDManifoldProblem
;data
the numerical data that should beVector{S}
, whereS
is the interpolation curve (we useDataInterpolation
in this package);flawpoints
the 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
f
the nonlinear map, which should has the formf(x,p)
and return aSVector
;para
the parameters of the nonlinear map;amax
the maximum angle between points when continuing the manifold;d
the maximum distance between points when continuing the manifold;dcircle
the maximum distance between circles when continuing the manifold;dsmin
the 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
prob
the problemVTwoDManifoldProblem
;data
the numerical data that should beVector{S}
, whereS
is the interpolation curve (we useDataInterpolation
in this package);flawpoints
the 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
f
the 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)|}$;para
the parameters of the time flow map;amax
the maximum angle between points when continuing the manifold;d
the maximum distance between points when continuing the manifold;dsmin
the 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
v
the vector field, which should be the formf(x,p,t)
and return aSVector
;dv
the Jacobi matrix function ofv
, which should should be the formdv(x,p,t)
and return aSMatrix
;timespan
the time span of the time-T-map;x
the initial point to iterate.
Keyword arguments
n
maximum iterate times, default to be 100;abstol
absolute tolerance for the fixed point, default to be1e-8
;alg
the 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
setup
theNSSetUp
of the nonsmooth ODE system;x
the initial point to iterate, of typeSVector{N,T}
.p
the parameters of the nonsmooth ODE system.
Keyword arguments
n
maximum iterate times, default to be 100;abstol
absolute 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
p
the structSaddle
which should contains two unstable directions; the complex eigenvalues and eigenvectors are allowed.
Keyword arguments
times
the 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.n
the number of point in each circle, default to be150
;d
the max distance between points in a single circle, default to be0.0002
;r
the size of the disk, default to be0.05
;circles
the 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
manifold
the manifold struct.
Keyword argument
interp
the 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
prob
the problem such asOneDManifoldProblem
.points
the 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_segment
andgen_disk
can generate these points easily.N
the number of iterations.
Keyword argument
interp
the 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
prob
the problem such asOneDManifoldProblem
.points
the 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_segment
andgen_disk
can generate these points easily.
Keyword argument
interp
the 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
true
if the saddle point has contact with the hypersurfaces.false
if the saddle point has no contact with the hypersurfaces.
InvariantManifolds.kd_distence
— MethodInvariantManifolds.kd_distence
The 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
d
between consecutive points - Maximum angle
αmax
between 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
v
vector fields likePiecewiseV
orBilliardV
.para
the parameter of the vector field.timespan
the time span of the time-T-map.alg
algorithm inOrdinaryDiffEq
to solve ODE.N
the dimension of the vector field.T
number 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//100
this 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.01
when the solutionsol
hits 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_detect
the 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
v
a nonsmooth vector field likePiecewiseV
orBilliardV
.timespan
the time span of the time-T-map.alg
algorithm inOrdinaryDiffEq
to solve ODE.
To ensure type stable, the numbers in timespan
should be type of T
.
Keyword arguments
repeat_nudge=1//100
this 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.01
when the solutionsol
hits 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_detect
the 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.