Invariant Models
Documentation for InvariantModels.
The primary goal of this software package is to identify mathematical models from data. The identified model can be forced, parameter dependent or autonomous. The mathematical structure of the identified model is a series of invariant foliations. To avoid overfitting the foliation representation can be adjusted. In general, encoders are represented as compressed polynomials, while the underlying low-dimensional model is an ordinary multivariate polynomial.
The software calculates invariant manifolds in vector fields and maps using a direct numerical method. The invariance equation discretised using a mixed Fourier and piecewise-Chebyshev collocation scheme. Then the discretised equations are solved using a similar method to pseude-archlength continuation, which employs a phase and arclength condition. This is much more accurate than using series expansions about the steady state and does not suffer from small radii of convergence.
There are extensive utilities to prepare data for model identification. These include delay embedding and dynamic mode decomposition to find ideal delay embedding coordinates. Approximate linear models can be decomposed into invariant vector bundles to provide an optimal coordinate system for model identification.
Set-up
The system to be identified is in the skew-product form
\[\begin{aligned} \boldsymbol{x}_{k+1} &= \boldsymbol{f} \left(\boldsymbol{x}_{k}, \boldsymbol{\theta} \right)\\ \boldsymbol{\theta}_{k+1} &= \boldsymbol{g}( \boldsymbol{\theta}_{k} ) \end{aligned} \tag{MAP},\]
where $\boldsymbol{f}\in X\times Y\to X$, $\boldsymbol{g}:Y\to Y$ are functions defined on the $d_{X}$-dimensional linear space $X$ and $d_{Y}$-dimensional differentiable manifold $Y$, respectively. The forcing map $\boldsymbol{g}$ is volume preserving, hence it has recurrent dynamics.
Every volume preserving map can be transformed into a coordinate system where its representation is approximately a unitary matrix. To find the unitary matrix $\boldsymbol{\Omega}$ we use the transformation
\[\boldsymbol{\alpha} = \boldsymbol{\Psi}(\boldsymbol{\theta}),\]
where $\boldsymbol{\Psi}$ is a vector of linearly independent scalar valued functions. It is known that as the dimensionality of $\boldsymbol{\Psi}$ increases, the volume preserving map $\boldsymbol{g}$ transforms into a linear unitary map $\boldsymbol{\Omega}$ [KKS16], [KM17]. Another consequence of the transformation is that, when transformed, function $\boldsymbol{f}$ becomes linear in new variables $\boldsymbol{\alpha}$.
Accordingly, system (MAP) is written in the form of
\[\begin{aligned} \boldsymbol{x}_{k+1} &= \boldsymbol{F} \left(\boldsymbol{x}_{k}\right) \boldsymbol{\alpha}\\ \boldsymbol{\alpha}_{k+1} &= \boldsymbol{\Omega} \boldsymbol{\alpha}_{k}, \end{aligned} \tag{MAP-TR}\]
where $\boldsymbol{x}_{k} \in \mathbb{R}^n$ is the state variable, $\boldsymbol{\alpha} \in \mathbb{R}^m$ is the encoded phase variable.
Data representation
The data is a set of $N$ trajectories, each of which are $\ell_{j}-\ell_{j-1}$ points long for $j=1,\ldots,N$, where $\ell_{0}=0$. In formulae the trajectories are
\[\begin{align*} \left(\boldsymbol{x}_{1},\boldsymbol{\alpha}_{1}\right),\left(\boldsymbol{x}_{2},\boldsymbol{\alpha}_{2}\right),\ldots,\left(\boldsymbol{x}_{\ell_{1}},\boldsymbol{\alpha}_{\ell_{1}}\right) & \\ \vdots \qquad \qquad & \\ \left(\boldsymbol{x}_{\ell_{N-1}+1},\boldsymbol{\alpha}_{\ell_{N-1}+1}\right),\left(\boldsymbol{x}_{\ell_{N-1}+2},\boldsymbol{\alpha}_{\ell_{N-1}+2}\right),\ldots,\left(\boldsymbol{x}_{\ell_{N}},\boldsymbol{\alpha}_{\ell_{N}}\right) & \end{align*}\]
Here $\boldsymbol{\alpha}$ represent the state of the forcing dynamics as encoded by the $\boldsymbol{\Psi}$ function.
The data is arranged into two arrays. The array Data is simply the state
\[\begin{pmatrix} \boldsymbol{x}_{1} & \boldsymbol{x}_{2} & \cdots & \boldsymbol{x}_{\ell_N} \end{pmatrix}\]
The second array Encoded_Phase contains the forcing states
\[\begin{pmatrix} \boldsymbol{\alpha}_{1} & \boldsymbol{\alpha}_{2} & \cdots & \boldsymbol{\alpha}_{\ell_N} \end{pmatrix}\]
To make sure that the system know where each trajectory starts and ends, we also must supply the Index_List vector
\[\begin{pmatrix} \ell_{0} & \ell_{1} & \cdots & \ell_N \end{pmatrix}.\]
Why invariant foliations
Invariant foliations are the only architecture that guarantees invariance and uniqueness (under some smoothness and non-resonance conditions) at the same time [Sza20, Sza23].
All dynamic model reduction architectures can be put into four categories. Each architecture must contain functional connections between the model and the data. This functional connection can only go two ways: from the data to the model or in reverse, which are the encoders and decoders, respectively. One has to establish this connection both at the initial condition and at the model prediction. This is exactly four combinations.
There are four ways to connect a low-order model $\boldsymbol{R}$ to $\boldsymbol{F}$. The figure below shows the four combinations. Only invariant foliations and invariant manifolds produce meaningful reduced order models. Only invariant foliations and autoencoders can be fitted to data. The intersection is invariant foliations.
Therefore,
- when a system of equations is given, invariant manifolds are the most appropriate (foliations are still possible),
- when data is given, only invariant foliations are appropriate.
Autoencoders such as SSMLearn do not enforce invariance and therefore generate spurious results as shown in [Sza23].
Invariant Foliations
The sofware identifies the encoder $\boldsymbol{U}$ and the conjugate map $\boldsymbol{R}$ from the invariance equation
\[\boldsymbol{R}\left(\boldsymbol{U}\left(\boldsymbol{x},\boldsymbol{\theta}\right),\boldsymbol{\theta}\right) = \boldsymbol{U}\left(\boldsymbol{f}\left(\boldsymbol{x},\boldsymbol{\theta}\right),\boldsymbol{g}\left(\boldsymbol{\theta}\right)\right). \tag{FOIL}\]
Equation (FOIL) is turned into a least squares optimisation problem and the loss function is minimised.
Invariant Manifolds
The sofware also calculates invariant manifolds from maps and vector fields. The invariance for manifolds is
\[\boldsymbol{S}\left(\boldsymbol{V}\left(\boldsymbol{x},\boldsymbol{\theta}\right),\boldsymbol{\theta}\right) = \boldsymbol{V}\left(\boldsymbol{f}\left(\boldsymbol{x},\boldsymbol{\theta}\right),\boldsymbol{g}\left(\boldsymbol{\theta}\right)\right), \tag{MAN}\]
where $\boldsymbol{V}$ is the decoder and $\boldsymbol{S}$ is the conjugate map. Since we are interested in oscilllatory dynamics on 2D manifolds, the invariance equation can be written in polar coordinates, that is
\[\boldsymbol{V}\left(R\left(\rho\right),T\left(\rho\right),\boldsymbol{g}\left(\boldsymbol{\theta}\right)\right)=\boldsymbol{f}\left(\boldsymbol{V}\left(\rho,\beta,\boldsymbol{\theta}\right),\boldsymbol{\theta}\right),\]
where $R$ and $T$ represent the conjugate dynamics. The parametrisation of the invariant manifold is fixed by the amplitude and phase conditions
\[\begin{aligned} \int_{Y}\int_{0}^{2\pi}\left\langle D_{1}\boldsymbol{V}\left(\rho,\beta,\boldsymbol{\theta}\right),\boldsymbol{V}\left(\rho,\beta,\boldsymbol{\theta}\right)-\boldsymbol{V}\left(0,\beta,\boldsymbol{\theta}\right)\right\rangle \mathrm{d}\beta\mathrm{d}\boldsymbol{\theta} &= \rho \\ \int_{Y}\int_{0}^{2\pi}\left\langle D_{1}\boldsymbol{V}\left(r,\beta,\boldsymbol{\theta}\right),D_{2}\boldsymbol{V}\left(r,\beta,\boldsymbol{\theta}\right)\right\rangle \mathrm{d}\beta\mathrm{d}\boldsymbol{\theta} &= 0. \end{aligned}\]
The instantantaneous damping ratio and frequency are calculated as
\[\begin{aligned} \zeta\left(\rho\right) &=-\frac{\frac{\mathrm{d}}{\mathrm{d}\rho}R\left(\rho\right)}{T\left(\rho\right)}\;\;\text{and}\\ \omega\left(\rho\right) &=T\left(\rho\right), \end{aligned}\]
respectively.
References
- [KKS16]
- S. Klus, P. Koltai and C. Schütte. On the numerical approximation of the Perron-Frobenius and Koopman operator. Journal of Computational Dynamics 3, 51–79 (2016).
- [KM17]
- M. Korda and I. Mezić. On Convergence of Extended Dynamic Mode Decomposition to the Koopman Operator. Journal of Nonlinear Science 28, 687–710 (2017).
- [Sza20]
- R. Szalai. Invariant spectral foliations with applications to model order reduction and synthesis. Nonlinear Dynamics 101, 2645–2669 (2020).
- [Sza23]
- R. Szalai. Data-Driven Reduced Order Models Using Invariant Foliations, Manifolds and Autoencoders. Journal of Nonlinear Science 33, 75 (2023).
Index
InvariantModels.Encoder_Linear_TypeInvariantModels.Encoder_Nonlinear_TypeInvariantModels.MultiStep_ModelInvariantModels.Multi_Foliation_ProblemInvariantModels.Scaling_TypeInvariantModels.Annotate_Plot!InvariantModels.Barycentric_Interpolation_MatrixInvariantModels.Chebyshev_GridInvariantModels.Chop_And_StitchInvariantModels.Create_Linear_DecompositionInvariantModels.Create_PlotInvariantModels.Data_ErrorInvariantModels.Data_ResultInvariantModels.Decompose_DataInvariantModels.Decomposed_Data_ScalingInvariantModels.Delay_EmbedInvariantModels.Estimate_Linear_ModelInvariantModels.EvaluateInvariantModels.Extract_Manifold_EmbeddingInvariantModels.Filter_Linear_ModelInvariantModels.Find_DATA_ManifoldInvariantModels.Find_MAP_ManifoldInvariantModels.Find_ODE_ManifoldInvariantModels.Fourier_GridInvariantModels.Fourier_InterpolateInvariantModels.From_Data!InvariantModels.Generate_From_ODEInvariantModels.Make_SimilarInvariantModels.Model_From_Function_AlphaInvariantModels.Model_From_ODEInvariantModels.Model_ResultInvariantModels.Multi_Foliation_Test_ProblemInvariantModels.Optimise!InvariantModels.Plot_Error_Curves!InvariantModels.Plot_Error_TraceInvariantModels.Rigid_Rotation_GeneratorInvariantModels.Rigid_Rotation_Matrix!InvariantModels.Select_Bundles_By_EnergyInvariantModels.Slice
API
Fourier collocation
InvariantModels.Fourier_Grid — Function
Fourier_Grid(Phase_Dimension::Integer)Creates a uniform grid on the $[0, 2\pi)$ interval.
InvariantModels.Fourier_Interpolate — Function
Fourier_Interpolate(grid, theta::Number)Evaluates the set of Dirichlet kernels specific to the uniform grid at point theta. The result is a vector.
Fourier_Interpolate(grid, theta::AbstractArray{T,1}) where {T}Evaluates the set of Dirichlet kernels specific to the uniform grid at all points in theta. The result is a matrix, where each column corresponds to a value in theta.
InvariantModels.Rigid_Rotation_Matrix! — Function
Rigid_Rotation_Matrix!(Alpha_Matrix, Grid, Omega_ODE::Number, t::Number)Creates the fundamental solution matrix for the rigid rotation on the circle in the space of the uniform Grid on the circle. The angular speed of the rotation is Omega_ODE and the result is written into Alpha_Matrix. The indepedent variabe is t.
InvariantModels.Rigid_Rotation_Generator — Function
Rigid_Rotation_Generator(Grid, Omega_ODE::Number)This is the infinitesimal generator of the rigid rotation with Omega_ODE angular speed.
One-dimensional polynomial collocation and interpolation
InvariantModels.Chebyshev_Grid — Function
Chebyshev_Grid(np::Integer)Creates a Chebyshev grid with np grid points.
\[t_j = \cos\frac{(j-1) \pi }{n-1},\;\; j =1,\ldots,n\]
Chebyshev_Grid(np::Integer, a::T, b::T) where {T<:Number}Creates a Chebyshev grid with np grid points within the interval $[a, b]$.
\[t_j = \frac{a+b}{2} + \frac{a-b}{2} \cos\frac{(j-1) \pi }{n-1},\;\; j =1,\ldots,n\]
InvariantModels.Barycentric_Interpolation_Matrix — Function
Barycentric_Interpolation_Matrix(t::AbstractVector, ti::AbstractVector)Creates a matrix that performs a polynomial interpolation from grid t to grid ti.
Barycentric_Interpolation_Matrix(order::Integer, mesh::Vector, ti::AbstractVector)Creates a matrix that performs a polynomial interpolation from a mesh, where each interval has order number of Chebyshev points. The target points are in grid.
Data pre-processing
InvariantModels.Delay_Embed — Function
Delay_Embed(Signals, Phases; delay = 1, skip = 1, max_length = typemax(Int))Creates a delay embedding of Signals while limits trajectory length to max_length. The delay is delay long and only every skipth point along the trajectory is put into the delay embedded data. Phases are simply copied over to the output while making sure that signal lengths and phase length are the same, limited by max_length.
The return values Delay_Signals, Delay_Phases are matrices of appropriate sizes.
InvariantModels.Chop_And_Stitch — Function
Chop_And_Stitch(Signals, Phases; maxlen = 1000)Chops up Signals and Phases into chunks of maximum maxlen chuncks. Then concatenates the result into the arrays Index_List, Data, Encoded_Phase. The list Index_List tells, where each chunk starts and ends within the arrays Data and Encoded_Phase.
InvariantModels.Estimate_Linear_Model — Function
Estimate_Linear_Model(
Index_List,
Data,
Encoded_Phase,
Scaling;
Iterations = 0,
Order = 1,
)Given the data Index_List, Data, Encoded_Phase this function estimates a linear model, a steady state and a model of forcing.
The output is Steady_State, BB_Linear, SH. Steady_State is the steady state of the system, BB_Linear is the estimated linear model and SH is the unitary transformation representing forcing.
When fitting the linear model Scaling attaches an importance to each data point. Iterations allows us to take into account the data as trajectories and use multi-step optimisation to find BB_Linear. A nonlinear model can also be fitted by making Order $> 1$. When a nonlinear model is identified, its steady state is found by Newton's method and its Jacobian is calculated at the steady state, which is then returned as the linear model BB_Linear.
InvariantModels.Filter_Linear_Model — Function
Filter_Linear_Model(BB, Grid, order)Assuming a uniform Fourier grid Grid, this function returns a truncated Fourier series of the linear model BB. This removes inaccurate higher frequency components of the approximate linear model before decomposing it into invariant vector bundles.
InvariantModels.Create_Linear_Decomposition — Function
Create_Linear_Decomposition(
BB_Filtered,
SH;
Time_Step = 1.0,
Reduce = false,
Align = true,
By_Eigen = false,
)Creates an invariant vector bundle decomposition of the linear system represented by BB_Filtered and the forcing dynamics SH. If Time_Step is specified, the fucntion also prints the estimated natural frequencies and damping ratios. The decomposition outputs vector bundles with orthonormal bases. Therefore the reduced model will be block-diagonal (with at most $2\times 2$ blocks), but not autonomous. If Reduce == true the system will be reduced to an autonomous form and the vector bundles will only be orthogonal in a weaker sense, averaged over the phase space of the forcing dyamics.
The output is a named tuple
(
Unreduced_Model,
Data_Encoder,
Data_Decoder,
Bundles,
Reduced_Model,
Reduced_Encoder,
Reduced_Decoder,
)where
Unreduced_Modelis the block diagonal, but non-autonomous model.Data_Encoderis the transformation that brings the data into the block-diagonal form.Data_Decoderis the transformation that brings the model back into the coordinate system of the data.Bundlesis a list of ranges that point out which entries of theUnreduced_Modelare a vector bundle.Reduced_Modelis the autonomous reduced model, ifReduce == true, otherwise same asUnreduced_Model.Reduced_EncoderbringsUnreduced_ModelintoReduced_ModelifReduce == trueotherwise identity.Reduced_DecoderbringsReduced_Modelback intoUnreduced_ModelifReduce == trueotherwise identity.
The parameter By_Eigen is true if the calculation is carried out by eigenvalue decomposition of the transport operator. Otherwise a specially designed Hessenberg transformation and subsequent QR iteration is carried out on the vector bundles. This latter method
InvariantModels.Select_Bundles_By_Energy — Function
Select_Bundles_By_Energy(
Index_List,
Data,
Encoded_Phase,
Steady_State,
SH,
Decomp;
How_Many,
Ignore_Real = true,
)Takes the named tuple produced by Create_Linear_Decomposition and selects the most energetic How_Many vector bundles of the data. Then produces a new named touple as in Create_Linear_Decomposition, that only contains these most energetic vector bundles. The input arguments are
Index_List,Data,Encoded_Phaseare the training data in the standard form.Steady_Stateis the steady state of the system estimated byEstimate_Linear_Model.SHis the forcing dynamics as produced byEstimate_Linear_Model.Decompis the named tuple produced byCreate_Linear_Decomposition.Ignore_Realiftruethe method only returns two dimensional vector bundles. This is helpful when the data includes slowly varyingDCshift with high energy that would be pick by the method otherwise.
InvariantModels.Decompose_Data — Function
Decompose_Data(Index_List, Data, Encoded_Phase, Steady_State, SH, Data_Encoder)Creates a decomposed and projected data set from the input Index_List, Data, Encoded_Phase. The Steady_State and SH are produced by Estimate_Linear_Model and Data_Encoder id produced by either Select_Bundles_By_Energy or Create_Linear_Decomposition directly.
InvariantModels.Decomposed_Data_Scaling — Function
Decomposed_Data_Scaling(Data_Decomp, Bundles)Creates a scaling tensor which, when applied to Data_Decomp makes each vector bundle have the same maximum amplitude, while also making the whole data set fit inside the unit ball.
Generating data from differential equations
InvariantModels.Generate_From_ODE — Function
Generate_From_ODE(
Vectorfield!,
Forcing_Map!,
Alpha_Map!,
Parameters,
Time_Step,
IC_x,
IC_Force,
IC_Alpha,
Trajectory_Lengths,
)Generates a data set from am ordinary differential equation (ODE). The ODE is defined by the three functions Vectorfield!, Forcing_Map! and Alpha_Map!.
Time_Stepis the sampling time interval of the soluationIC_xeach column contains an initial condition in the state spaceIC_Forcethis is a storage space and will be overwritten with the actual value of the forcing stateAlphaIC_Alphaeach column contains an initial condition of the forcing stateTrajectory_Lengthsa vector of trajectory lengths
The return values are List_Of_Trajectories, List_Of_Phases, which can be further processed by identifying a linear model Estimate_Linear_Model.
An example of the ODE is
function Vectorfield!(dx, x, u, Parameters)
... dx is the dx/dt
... x is the state variable vector
... u is the time varying input or forcing vector
... Parameters is a data structure that is passed around all function
and contains all auxilliary information necessary to calculate dx
...
return x
end
function `Forcing_Map!`(u, Alpha, Parameters)
... This function produces the forcing vector 'u'
... The state variable of the forcing is `Alpha`
... Parameters is a data structure that is passed around all function
... The forcing depends on the state variable of the forcing `Alpha`
... In this case the forcing is just a linear combination of `Alpha`
u[1:2] .= Parameters.Weights * Alpha
return u
end
function Alpha_Map!(x, Parameters, t)
... Returns a matrix, which is the fundamental solution of the forcing dynamics
... 'x' is the fundamental solution
... Parameters is a data structure that is passed around all function
... `t` is the independent time variable
return Rigid_Rotation_Matrix!(x, Parameters.Forcing_Grid, Parameters.Omega, t)
endTypes of encoders
InvariantModels.Encoder_Linear_Type — Type
@enum Encoder_Linear_Type begin
Encoder_Fixed = 0
Encoder_Array_Stiefel = 1
Encoder_Mean_Stiefel = 2
Encoder_Stiefel_Oblique = 3
Encoder_Orthogonal = 4
endEnumeration to describe the linear part of the Encoder.
Encoder_Fixedthe encoder is not optimised, it is left fixed at its initial stateEncoder_Array_Stiefelthe encoder is a pointwise orthogonal set of matricesEncoder_Mean_Stiefelthe encoder is orthogonal in an average sense over all possible forcingEncoder_Stiefel_Obliquethe encoder consist of unit vectors for all points of forcing (not orthogonal)Encoder_Orthogonalthe encoder is orthogonal to all linear parts of the other foliations and this orthogonality is periodically updated with the other foliations
InvariantModels.Encoder_Nonlinear_Type — Type
@enum Encoder_Nonlinear_Type begin
Encoder_Dense_Full = 0
Encoder_Dense_Latent_Linear = 1
Encoder_Dense_Local = 2
Encoder_Compressed_Full = 16
Encoder_Compressed_Latent_Linear = 17
Encoder_Compressed_Local = 18
endEnumeration to describe the nonlinear part of the Encoder
Encoder_Dense_Fullthe encoder is a dense polynomial without any constraintsEncoder_Dense_Latent_Linearthe encoder is a dense polynomial, but it is linear for the latent variablesEncoder_Dense_Localthe encoder is a dense polynomial, but it is locally defined about an invariant manifoldEncoder_Compressed_Fullthe encoder is a compressed polynomial without any constraintsEncoder_Compressed_Latent_Linearthe encoder is a compressed polynomial, but it is linear for the latent variablesEncoder_Compressed_Localthe encoder is a compressed polynomial, but it is locally defined about an invariant manifold
Multivariate polynomial models
These models represent
- The conjugate dynamics
- a vector field
- a nonlinear map produced from a vector field
The representation is used to fit full trajectories to data and therefore making it a highly nonlinear optimisation problem.
InvariantModels.MultiStep_Model — Type
MultiStep_Model(State_Dimension, Skew_Dimension, Start_Order, End_Order, Trajectories)Create a polynomial model representation.
State_Dimensiondimensionality of the state spaceSkew_Dimensiondimensionality of the forcin spaceStart_Orderthe smallest order monomial to includeEnd_Orderthe greatest order monomial to includeTrajectoriesnumber of trajectories to be represented
The model includes an identified initial condition for each fitted trajectory, which is different from the first point of the trajectory.
InvariantModels.From_Data! — Function
From_Data!(M::MultiStep_Model, X, Index_List, Data, Encoded_Phase, Scaling; Linear=false)Creates a polynomial model from data given by Index_List, Data, Encoded_Phase. The model is created using linear least squares and therefore not optimised. This is to provide an initial condition for optimisation later on.
M,Xthe model representationIndex_List,DataandEncoded_Phaseinput dataScalinga scaling factor to represent the importance of each data pointLineariftrueall nonlinear terms are zeroed
InvariantModels.Evaluate — Function
Evaluate(M::MultiStep_Model, X, Index_List, Data, Encoded_Phase)Applies the polynomial representation of the model M, X to the data Index_List, Data, Encoded_Phase as if each data point was an initial condition.
InvariantModels.Slice — Function
Slice(MTF::Multi_Foliation{M,State_Dimension,Skew_Dimension}, XTF, Encoded_Slice) where {M,State_Dimension,Skew_Dimension}In case the system is parameter dependent, this function creates an autonomous slice when the encoded parameter is Encoded_Slice.
InvariantModels.Model_From_ODE — Function
Model_From_ODE(
Vectorfield!,
Forcing_Map!,
Alpha_Map!,
IC_Force,
Parameters,
dt,
Time_Step;
State_Dimension,
Skew_Dimension,
Start_Order,
End_Order,
Steady_State::Bool = true,
Iterations = 100,
)Creates a discrete-time model from the vector field Vectorfield!, Forcing_Map! and Alpha_Map!. The definition is the same as in Generate_From_ODE. The routine first calculates a steady state of the system straight from the ODE. Then it create a polynomial map about the steady state. The resulting map has its steady state at the origin.
dttime step of the ODE solverTime_Stepintegration time of the ODE. One iteration of the resulting map is the same as solveing the ODE forTime_Steptime.State_Dimensionstate space dimensionSkew_Dimensionforcing space dimensionStart_Orderstarting order of the resulting mapEnd_Orderhighest order monomial in the resulting mapIterationshow many Newto iteration to take when solving for the steady state.
InvariantModels.Model_From_Function_Alpha — Function
Model_From_Function_Alpha(
Vectorfield!,
Alpha_Generator,
Parameters;
State_Dimension,
Start_Order,
End_Order
)Create a polynomial vector field by Taylor expanding the ODE given by Vectorfield! and Alpha_Generator.
It uses the same definition a a vector field as Generate_From_ODE. The difference is that Alpha_Generator is the infinitesimal generator matrix of the forcing dynamics.
Start_Order and End_Order set the representing polynomial orders.
Representing invariant foliations
InvariantModels.Scaling_Type — Type
@enum Scaling_Type begin
No_Scaling = 0
Linear_Scaling = 1
Quadratic_Scaling = 2
endDescribes how to scale the loss function as a function of the distance from the steady state.
InvariantModels.Make_Similar — Function
Make_Similar(
MTF::Multi_Foliation{M,State_Dimension,Skew_Dimension},
XTF,
New_Trajectories::Integer,
) where {M,State_Dimension,Skew_Dimension}Creates a new Multi_Foliation except that it will now have space for New_Trajectories initial conditions for the conjugate dynamics. This is used to create a model to evaluate testing data that has different number of trajectories than the training data.
InvariantModels.Multi_Foliation_Problem — Type
Multi_Foliation_Problem(
Index_List,
Data_Decomposed,
Encoded_Phase;
Selection::NTuple{M, Vector{Int}},
Model_Orders::NTuple{M, Int},
Encoder_Orders::NTuple{M, Int},
Unreduced_Model,
Reduced_Model,
Reduced_Encoder,
SH,
Initial_Iterations = 32,
Scaling_Parameter = 2^(-4),
Initial_Scaling_Parameter = 2^(-4),
Scaling_Order = Linear_Scaling,
node_ratio = 0.8,
leaf_ratio = 0.8,
max_rank = 48,
Linear_Type::NTuple{M, Encoder_Linear_Type} = ntuple(i -> Encoder_Array_Stiefel, M),
Nonlinear_Type::NTuple{M, Encoder_Nonlinear_Type} = ntuple(i -> Encoder_Compressed_Latent_Linear, M),
Name = "MTF-output",
Time_Step = 1.0,
) where {M}Creates an object with multiple foliations that can be fitted to the data.
Index_List,Data_DecomposedandEncoded_PhaseThe training data approximately in the cooredinates of the invariant vector bundles of the linear part of the system about the steady state. This transformation can be achieved byDecompose_Dataand the decomposition can be obtained byCreate_Linear_Decomposition, which in turn is obtained by an initial linear approximation of the model usingEstimate_Linear_Model.Selectionsets the vector bundles to be included in the calculated foliations.Model_Ordersthe polynomial orders of the conjugate maps for each foliationEncoder_Ordersthe polynomial orders of the conjugate maps for each foliationUnreduced_Modelapproximate linear model in the coordinate system of the dataReduced_Modelapproximate (autonomous) linear model in the coordinate system ofReduced_EncoderReduced_Encodera linear encoder that reduces the approximate linear mapUnreduced_Modelto an autonomous map. It can also be an identity, in which case theReduced_Modeland theUnreduced_Modelare the sameSHThe forcing map, identified byEstimate_Linear_ModelInitial_Iterationshow many optimisation steps to take to refine the supplied linear model to the encoded dataScaling_Parameterthe parameter the specifies data scalingInitial_Scaling_Parameterthe parameter the specifies data scaling at the initial refinement of the model. Choosing it too small might result in diverging calculations.Scaling_Orderwhether to assign different important to various data points. This is must be one element ofScaling_Typenode_ratiowhen calculating the rank of a component in the compressed tensor representation, by what ratio should we reduced the rank of the connecting parent node.leaf_ratioby how much are we allowed to reduce the rank of a leaf node from the dimeneionality of the tensormax_rankthe maximum rank of any node in the compressed tensor representationLinear_Typethis is a tuple that contains what restriction should apply to the linear part of the encoder. The values are taken fromEncoder_Linear_TypeNonlinear_Typethis is a tuple that contains what restriction should apply to the nonlinear part of the encoder. The values are taken fromEncoder_Nonlinear_TypeNamethis string variabel is used for the name of the data file wher the foliation is periodically save to.Time_Stepthe sampling time step of the supplied data. This is used only to display frequency information during calulation, otherwise has no effect.
InvariantModels.Multi_Foliation_Test_Problem — Function
Multi_Foliation_Test_Problem(
MTFP::Multi_Foliation_Problem{M,State_Dimension,Skew_Dimension},
Index_List,
Data_Decomposed,
Encoded_Phase;
Initial_Scaling_Parameter = 2^(-4),
) where {M,State_Dimension,Skew_Dimension}This creates a test problem with test data included. The test data in Index_List, Data_Decomposed and Encoded_Phase. MTFP is a Multi_Foliation_Problem. Initial_Scaling_Parameter has the same meaning as in Multi_Foliation_Problem but applied to the testing data.
InvariantModels.Optimise! — Function
Optimise!(
MTFP::Multi_Foliation_Problem{M,State_Dimension,Skew_Dimension},
MTFP_Test::Union{Nothing,Multi_Foliation_Problem{M,State_Dimension,Skew_Dimension}} = nothing;
Model_Iterations = 16,
Encoder_Iterations = 8,
Steps = 128,
Gradient_Ratio = 2^(-7),
Gradient_Stop = 2^(-29),
Picks = [Complete_Component_Index(MTFP.XTF.x[k].x[2], (1,)) for k = 1:M],
) where {M,State_Dimension,Skew_Dimension}Fits the set of foliations defined in MTFP to the given data.
MTFPaMulti_Foliation_ProblemMTFP_TestaMulti_Foliation_Test_Problem. The parameters ofMTFP_Testare regularly synchronised withMTFP, except the initial condition of the latent model, which are fitted from the testing trajectories.Model_Iterationsmaximum number of optimisation steps taken when the conjugate dynamics is fitted to latent data. The optimisation is a version of the Levenberg-Marquardt method.Encoder_Iterationsmaximum number of optimisation steps for any component of the encoder. The optimisation technique is a manifold Newton trust region method.Stepsthe number of optimisation cycles for each foliation.Gradient_RatioOptimisation of a component stops when the norm of the gradient has reduced by this factorGradient_StopOptimisation of a component stops when the norm of the gradient has reached this valuePicksUsed for testing the code, leave as is.
Analysing invariant foliations
InvariantModels.Find_DATA_Manifold — Function
Find_DATA_Manifold(MTF::Multi_Foliation{M,State_Dimension,Skew_Dimension}, XTF, SH, Index;
Radial_Order, Radial_Intervals, Radius,
Phase_Dimension, Transformation,
abstol=1e-9, reltol=1e-9, maxiters=12, initial_maxiters=200
) where {M,State_Dimension,Skew_Dimension}Calculates a two-dimensional invariant manifold from the set of invariant foliations MTF, XTF. The calulation is for the invariant foliation selected by Index. SH is the forcing map. The rest of the function arguments are the same as in Find_MAP_Manifold
InvariantModels.Extract_Manifold_Embedding — Function
Extract_Manifold_Embedding(
MTF::Multi_Foliation{M,State_Dimension,Skew_Dimension},
XTF,
Index,
Data_Decomp,
Encoded_Phase;
Radial_Order,
Radial_Intervals,
Radius,
Phase_Dimension,
Output_Transformation = [],
Output_Inverse_Transformation = [],
Output_Scale,
abstol = 1e-9,
reltol = 1e-9,
maxiters = 24,
initial_maxiters = 200,
)Extracts the invariant manifold from a set of invariant foliations MTF, XTF. The parametrisation of the foliation is the same as the identofied conjugate map. Therefore it is not directly useable to obtain backbone curves. The result is primarily used to find out the physical amplitude of an encoded data point that is mapped back onto the invariant manifold.
The input arguments are
MTF,XTFrepresent the set of invariant foliations previously fitted to dataIndexchooses the invariant foliation for which we calculate the invariant manifoldRadial_Orderorder of the Chebyshev in the radial directionRadial_Intervalsnumber of polynomials in the radial directionRadiusthe maximum radius to calculate the invariant manifold forPhase_Dimensionthe number of Fourier collocation points to use in the angular directionOutput_Transformationsame asData_Encoderproduced byCreate_Linear_Decomposition.Output_Inverse_Transformationsame asData_Decoderproduced byCreate_Linear_Decomposition. Note that only one ofOutput_TransformationorOutput_Inverse_Transformationneed to be specified. IfOutput_Inverse_Transformationis specified, it takes precedence.Output_Scalesame asData_Scaleproduced byDecomposed_Data_Scalingabstol = 1e-9absolute tolerance when solving the invariance equationreltol = 1e-9relative tolerance when solving the invariance equationmaxiters = 12number of solution steps when calculating each segment of the manifoldinitial_maxitersthe maximum iteration when calculating the segment containing the steady state. About the steady state the manifold is non-hyperbolic and therefore numerically challenging to calculate.
InvariantModels.Data_Result — Function
Data_Result(
PM::Polar_Manifold{
State_Dimension,
Latent_Dimension,
Radial_Order,
Radial_Dimension,
Phase_Dimension,
Skew_Dimension,
},
PX,
MIP,
XIP,
MTF::Multi_Foliation,
XTF,
Index,
Index_List,
Data,
Encoded_Phase;
Time_Step = 1.0,
Transformation = PM.Transformation,
Slice_Transformation = Transformation,
Hz = false,
Damping_By_Derivative::Bool = true,
Model_IC = false,) where { StateDimension, LatentDimension, RadialOrder, RadialDimension, PhaseDimension, SkewDimension, }
Plots the instantaneous frequency and damping curves for the invariant foliation at Index.
PM,PXthe invariant manifold calculated byFind_DATA_ManifoldMIP,XIPthe manifold embedding calculated byExtract_Manifold_EmbeddingMTF,XTFthe set of invariant foliationsIndexwhich invariant foliation is it calculated forIndex_List,Data,Encoded_Phasethe training dataTime_Stepsampling time-step of data for calulating frequenciesTransformationthe transformation the brings back the data to the physical coordinateSlice_Transformationthe transformation, in casePM,PXare calculated from a fixed parameters slice of the identified foliation. If not a slice, should be the same asTransformation.Hziftruefrequency is displayed in Hz, otherwise it is rad/s.Damping_By_Derivativeiftruea truely instantaneous damping ratio is displayed. Iffalsethe damping ratio commonly (and mistakenly) used in the literature is displayedModel_ICwhether to re-calculate the initial conditions of trajectories stored inXTF
InvariantModels.Data_Error — Function
Data_Error(
PM::Polar_Manifold{
State_Dimension,
Latent_Dimension,
Radial_Order,
Radial_Dimension,
Phase_Dimension,
Skew_Dimension,
},
PX,
MIP,
XIP,
MTF::Multi_Foliation,
XTF,
Index,
Index_List,
Data,
Encoded_Phase;
Transformation,
Model_IC = false,
Iterations = 32,) where { StateDimension, LatentDimension, RadialOrder, RadialDimension, PhaseDimension, SkewDimension, } )
Plots the training and testing errors as a function of vibration amplitude.
PM,PXthe invariant manifold calculated byFind_DATA_ManifoldMIP,XIPthe manifold embedding calculated byExtract_Manifold_EmbeddingMTF,XTFthe set of invariant foliationsIndexwhich invariant foliation is it calculated forIndex_List,Data,Encoded_Phasethe training dataTransformationthe transformation the brings back the data to the physical coordinateColorline colour of the plotModel_ICwhether to re-calculate the initial conditions of trajectories stored inXTF
Calculating invariant manifolds from ODEs and maps
InvariantModels.Find_ODE_Manifold — Function
Find_ODE_Manifold(
MM::MultiStep_Model,
MX,
Generator,
Select;
Radial_Order,
Radial_Intervals,
Radius,
Phase_Dimension,
abstol = 1e-9,
reltol = 1e-9,
maxiters = 12,
initial_maxiters = 200,
)Calculates a two-dimensional invariant manifold from the ODE MM, MX. The result is stored as a piecewise Chebyshev polynomial in the radial direction Fourier collocation in the angular direction.
The input arguments are
MMandMXrepresent the polynomial vector fieldGeneratoris the infinitesimal generator matrix of the forcing dynamicsSelectchooses along which vector bundle to calculate the invariant manifoldRadial_Orderorder of the Chebyshev in the radial directionRadial_Intervalsnumber of polynomials in the radial directionRadiusthe maximum radius to calculate the invariant manifold forPhase_Dimensionthe number of Fourier collocation points to use in the angular directionabstol = 1e-9absolute tolerance when solving the invariance equationreltol = 1e-9relative tolerance when solving the invariance equationmaxiters = 12number of solution steps when calculating each segment of the manifoldinitial_maxitersthe maximum iteration when calculating the segment containing the steady state. About the steady state the manifold is non-hyperbolic and therefore numerically challenging to calculate.
InvariantModels.Find_MAP_Manifold — Function
Find_MAP_Manifold(
MM::MultiStep_Model{State_Dimension,Skew_Dimension,Start_Order,End_Order,Trajectories},
MX,
Select;
Radial_Order,
Radial_Intervals,
Radius,
Phase_Dimension,
abstol = 1e-9,
reltol = 1e-9,
maxiters = 12,
initial_maxiters = 200,
) where {State_Dimension,Skew_Dimension,Start_Order,End_Order,Trajectories}Calculates a two-dimensional invariant manifold from the map MM, MX. The result is stored as a piecewise Chebyshev polynomial in the radial direction Fourier collocation in the angular direction.
The input arguments are
MMandMXare the discrete-time mapSelectchooses along which vector bundle to calculate the invariant manifoldRadial_Orderorder of the Chebyshev in the radial directionRadial_Intervalsnumber of polynomials in the radial directionRadiusthe maximum radius to calculate the invariant manifold forPhase_Dimensionthe number of Fourier collocation points to use in the angular directionabstol = 1e-9absolute tolerance when solving the invariance equationreltol = 1e-9relative tolerance when solving the invariance equationmaxiters = 12number of solution steps when calculating each segment of the manifoldinitial_maxitersthe maximum iteration when calculating the segment containing the steady state. About the steady state the manifold is non-hyperbolic and therefore numerically challenging to calculate.
InvariantModels.Model_Result — Function
Model_Result(
PM::Polar_Manifold,
PX;
Time_Step = 1.0,
Hz = false,
Damping_By_Derivative::Bool = true,
)Calculates the instantaneous frequency and damping ratio for the invariant manifold directly calculated from an ODE or map model.
PM,PXthe invariant manifold calculated byFind_ODE_ManifoldorFind_MAP_ManifoldTime_Stepsampling time-step of data for calulating frequenciesHziftruefrequency is displayed in Hz, otherwise it is rad/s.Damping_By_Derivativeiftruea truely instantaneous damping ratio is displayed. Iffalsethe damping ratio commonly (and mistakenly) used in the literature is displayed
Plotting results
InvariantModels.Create_Plot — Function
Create_Plot(; Amplitude = "Amplitude")Creates a figure to display the results.
- Amplitude is a string that will be put on the vertical axes of the plot
InvariantModels.Plot_Error_Curves! — Function
Plot_Error_Curves!(
fig, Error_Curves, Data_Max_Pre;
Color = Makie.wong_colors()[2],
Dense_Style = :solid,
Max_Style = :dot,
Mean_Style = :solid,
Amplitude_Scale = 1,
)figis the figure to plotError_Curvesproduced byData_ErrorData_Max_Prethe maximum amplitude to considerColorline colourDense_Styleline style for densityMax_Styleline style for maximum errorMean_Styleline style for mean errorAmplitude_Scalea scaling factor for amplitudes. This can be use because the result is in different units.
InvariantModels.Plot_Error_Trace — Function
Plot_Error_Trace(
fig,
Index,
Train_Trace,
Test_Trace = nothing;
Train_Color = Makie.wong_colors()[1],
Test_Color = Makie.wong_colors()[2],
)Adds the training and testing errors to the figure fig for the foliation selected by Index. Train_Trace and Test_Trace are produced by Optimise!.
InvariantModels.Annotate_Plot! — Function
Annotate_Plot!(fig)Perform the final annotation of the figure, so that it is ready for display.