CTFlows.jl
CTFlows.jl is the flow integration layer of the control-toolbox ecosystem. Given a dynamical system — a vector field, a Hamiltonian, or a Hamiltonian vector field — it builds a callable flow that integrates the system from any initial condition to any final time, with a pluggable ODE solver and optional automatic differentiation.
CTFlows handles integration. For modelling optimal control problems see CTModels.jl; for solving NLPs see CTSolvers.jl; the umbrella package is OptimalControl.jl.
Quick start
using CTFlows
using CTBase.Data, CTFlows.Flows, CTFlows.Trajectories
import OrdinaryDiffEqTsit5 # activates the SciML integrator extension
# 1. Wrap the dynamics
vf = Data.VectorField(x -> -x) # autonomous, fixed, out-of-place
# 2. Build the flow
flow = Flows.Flow(vf; reltol=1e-8)
# 3. Integrate — point form (final state)
xf = flow(0.0, [1.0, 0.0], 1.0)
# 4. Integrate — trajectory form (full history)
sol = flow((0.0, 1.0), [1.0, 0.0])
t = Trajectories.time_grid(sol)
x = Trajectories.state(sol) # callable: x(t) → state at time t
x(0.5) # interpolateCTFlows exports nothing at the package level. Every symbol lives in a submodule (CTBase.Data, CTFlows.Flows, …) and is reached via a qualified path or a using CTFlows.SubModule import.
Architecture
CTFlows is organised as a four-layer pipeline:
Data → Systems → Integrators → Flows → Trajectories| Layer | Submodule | Key types |
|---|---|---|
| Data | CTBase.Data | VectorField, Hamiltonian, HamiltonianVectorField |
| Systems | CTFlows.Systems | VectorFieldSystem, HamiltonianSystem |
| Integrators | CTFlows.Integrators | SciML |
| Flows | CTFlows.Flows | StateFlow, HamiltonianFlow |
| Trajectories | CTFlows.Trajectories | VectorFieldTrajectory, HamiltonianVectorFieldTrajectory |
| Multi-phase | CTFlows.MultiPhase | MultiPhaseStateFlow |
The shortcut Flows.Flow(data; opts...) collapses all pipeline steps into a single call. The explicit pipeline (build_system → build_integrator → build_flow) gives full control over each step.
Guides
| Guide | Contents |
|---|---|
| Flows | End-to-end pipeline: data → systems → flows → solutions, traits, multi-phase |
| Differential Geometry | Hamiltonian lift, Lie bracket, Poisson bracket, @Lie macro |