Skip to content

CTFlows.jl

CTFlows.jl is the flow integration layer of the control-toolbox ecosystem. Given a dynamical system — a vector field, a Hamiltonian, a Hamiltonian vector field, or directly an optimal control problem — 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; for differential-geometric tools (Lie brackets, Poisson brackets, lifts) see CTLie.jl; the umbrella package is OptimalControl.jl.

Quick start

julia
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.

The same Flow constructor also builds directly from an optimal control problem — a CTModels.Models.Model — with no Hamiltonian to write by hand: Flows.Flow(ocp). This is the entry point most users of the control-toolbox ecosystem actually reach for; see the Getting Started walkthrough and the Optimal control guide.

Architecture

CTFlows is organised as a pipeline:

Data → Systems → Integrators → Flows → Trajectories
LayerSubmoduleKey types
DataCTBase.DataVectorField, Hamiltonian, HamiltonianVectorField, PseudoHamiltonian, ControlledVectorField, OpenLoop, ClosedLoop, DynClosedLoop
ConfigsCTFlows.ConfigsStateEndPointConfig, HamiltonianTrajectoryConfig, AugmentedHamiltonianEndPointConfig
SystemsCTFlows.SystemsVectorFieldSystem, HamiltonianSystem, PseudoHamiltonianSystem
IntegratorsCTFlows.IntegratorsSciML
FlowsCTFlows.FlowsStateFlow, HamiltonianFlow, OptimalControlFlow, ControlledFlow
TrajectoriesCTFlows.TrajectoriesVectorFieldTrajectory, HamiltonianVectorFieldTrajectory, StateFlowTrajectory
Multi-phaseCTFlows.MultiPhaseMultiPhaseStateFlow

The data layer (VectorField, Hamiltonian, HamiltonianVectorField) lives in CTBase.Data; the ODE integrator strategy is provided by CTSolvers.Integrators and re-exported through CTFlows.Integrators.

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
Getting StartedInstallation, mental model, 5-minute walkthrough
FlowsEnd-to-end pipeline: data → systems → flows → trajectories, multi-phase
Building a flowShortcut and explicit constructors
IntegratingCall styles, configuration objects, integrator options
TrajectoriesReading the result: state, costate, time_grid, plotting
Multi-phase flowsConcatenating flows with switching times and jumps
Optimal controlFlows from optimal control problems (Flow(ocp))
Control lawsFlow(ocp, law), Flow(h̃, law), Flow(fc, law)OpenLoop, ClosedLoop, DynClosedLoop
SciML flowsFlows from ODEFunction / ODEProblem (SciML extension)