Integrating
Once a flow is built, calling it integrates the underlying ODE. There are two call styles depending on whether you need the full trajectory or just the final state.
Call styles
Point integration — final state only
flow(t0, x0, tf) # returns xf::Vector (StateFlow)
hflow(t0, x0, p0, tf) # returns (xf, pf) (HamiltonianFlow)x0 = [1.0, 0.0]
xf = flow(0.0, x0, 1.0)2-element Vector{Float64}:
0.36787944127643124
0.0p0 = [0.0, 1.0]
xf, pf = hflow(0.0, x0, p0, 1.0)
(xf, pf)([0.5403023057842606, 0.8414709847533869], [-0.8414709847533869, 0.5403023057842606])Trajectory integration — full time history
flow((t0, tf), x0) # returns VectorFieldTrajectory
hflow((t0, tf), x0, p0) # returns HamiltonianVectorFieldTrajectorysol = flow((0.0, 1.0), x0)VectorFieldTrajectory
result: SciMLIntegrationResulthsol = hflow((0.0, 1.0), x0, p0)HamiltonianVectorFieldTrajectory
result: SciMLIntegrationResultVariable parameters
For a NonFixed flow, pass the variable $v$ via the variable keyword:
vf_v = Data.VectorField((x, v) -> -v[1] .* x; is_variable=true)
flow_v = Flows.Flow(vf_v)
xf_v = flow_v(0.0, [1.0, 0.0], 1.0; variable=[2.0])2-element Vector{Float64}:
0.13533528348480484
0.0The variable argument is required when is_variable(flow) is true, and silently ignored for Fixed flows.
Configuration objects
The convenience call signatures above internally build configuration objects that bundle the integration parameters. You can also construct them explicitly and pass them to Flows._invoke_flow:
| Config type | Usage | Arguments |
|---|---|---|
StateEndPointConfig | state final value | (t0, x0, tf) |
StateTrajectoryConfig | state full trajectory | (tspan, x0) |
HamiltonianEndPointConfig | state+costate final value | (t0, x0, p0, tf) |
HamiltonianTrajectoryConfig | state+costate trajectory | (tspan, x0, p0) |
cfg = Configs.StateTrajectoryConfig((0.0, 1.0), [1.0, 0.0])
Configs.tspan(cfg)(0.0, 1.0)Configuration objects separate what to integrate from how to integrate (the flow). This separation is useful when the same config must be passed to several flows.
Integrator options {#integrator-options}
Options are passed as keyword arguments to Flows.Flow(data; opts...) or Integrators.build_integrator(; opts...).
The default integrator is SciML backed by OrdinaryDiffEqTsit5 (loaded when import OrdinaryDiffEqTsit5 appears in your session).
Common options
| Option | Default | Description |
|---|---|---|
reltol | 1e-6 | Relative tolerance |
abstol | 1e-8 | Absolute tolerance |
alg | Tsit5() | ODE algorithm (any SciML algorithm) |
saveat | [] | Extra time points to save |
dense | true | Dense output for interpolation |
# Tighter tolerances
flow_tight = Flows.Flow(vf; reltol=1e-12, abstol=1e-12)
# Different algorithm (requires the matching OrdinaryDiffEq package to be loaded)
# using OrdinaryDiffEqRosenbrock
# flow_rodas = Flows.Flow(vf; alg=Rodas4())Flow
system: VectorFieldSystem
wraps: VectorField: autonomous, fixed (no variable), out-of-place
rhs: IPVFOoPRHS (out-of-place VF → in-place interface)
integrator: SciML (abstol = 1.0e-12, reltol = 1.0e-12)Unsafe mode
By default, a SolverFailure exception is thrown if the ODE solver returns a non-success retcode. Pass unsafe=true to suppress this check:
xf_unsafe = flow(0.0, [1.0, 0.0], 1.0; unsafe=true)2-element Vector{Float64}:
0.36787944127643124
0.0Use unsafe=true inside shooting methods or optimisation loops where you want to handle failures gracefully instead of relying on exceptions.
SciML integrator internals
The SciML strategy wraps SciML's solve under the CTSolvers option system. The build_problem / solve_problem separation lets the same problem definition be re-solved with different parameters efficiently.
integ = Integrators.build_integrator(; reltol=1e-8)
typeof(integ)CTFlows.Integrators.SciML{CTBase.Strategies.StrategyOptions{@NamedTuple{internalnorm::CTBase.Options.OptionValue{typeof(CTFlows.Common.real_norm)}, alg::CTBase.Options.OptionValue{Tsit5{typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!), FastBroadcast.Serial}}, reltol::CTBase.Options.OptionValue{Float64}, save_everystep::CTBase.Options.OptionValue{Symbol}, abstol::CTBase.Options.OptionValue{Float64}, save_start::CTBase.Options.OptionValue{Symbol}, dense::CTBase.Options.OptionValue{Symbol}}}, Dict{Symbol, Any}, Dict{Symbol, Any}}See also
CTFlows.Configs.StateEndPointConfig,CTFlows.Configs.StateTrajectoryConfig— state configuration objects.CTFlows.Configs.HamiltonianEndPointConfig,CTFlows.Configs.HamiltonianTrajectoryConfig— Hamiltonian configuration objects.CTFlows.Configs.tspan,CTFlows.Configs.initial_state,CTFlows.Configs.initial_costate— configuration accessors.CTFlows.Integrators.SciML,CTFlows.Integrators.build_integrator,CTFlows.Integrators.AbstractIntegrator— integrator types.