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 in the ecosystem

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)                                  # interpolate
Qualified access

CTFlows 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
LayerSubmoduleKey types
DataCTBase.DataVectorField, Hamiltonian, HamiltonianVectorField
SystemsCTFlows.SystemsVectorFieldSystem, HamiltonianSystem
IntegratorsCTFlows.IntegratorsSciML
FlowsCTFlows.FlowsStateFlow, HamiltonianFlow
TrajectoriesCTFlows.TrajectoriesVectorFieldTrajectory, HamiltonianVectorFieldTrajectory
Multi-phaseCTFlows.MultiPhaseMultiPhaseStateFlow

The shortcut Flows.Flow(data; opts...) collapses all pipeline steps into a single call. The explicit pipeline (build_systembuild_integratorbuild_flow) gives full control over each step.

Guides

GuideContents
FlowsEnd-to-end pipeline: data → systems → flows → solutions, traits, multi-phase
Differential GeometryHamiltonian lift, Lie bracket, Poisson bracket, @Lie macro